further variable encapsulation
This commit is contained in:
@@ -75,9 +75,9 @@ public class PixelBlock {
|
||||
this.placeholder = new PixelBlockPlaceholder(this);
|
||||
this.hitbox = new PixelBlockHitbox(this);
|
||||
|
||||
Main.plugin.getLogger().info(String.format("Loaded existing pixelblock '%s'", this.blockUUID));
|
||||
Main.logger().info(String.format("Loaded existing pixelblock '%s'", this.blockUUID));
|
||||
} catch(Exception e) {
|
||||
Main.plugin.getLogger().info(String.format("Failed initializing existing pixelblock '%s': %s", this.blockUUID, e.getMessage()));
|
||||
Main.logger().info(String.format("Failed initializing existing pixelblock '%s': %s", this.blockUUID, e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class PixelBlock {
|
||||
|
||||
this.getBlockTaskChain()
|
||||
.async(() -> {
|
||||
Main.database.savePixelBlock(this);
|
||||
Main.database().savePixelBlock(this);
|
||||
Main.pixelBlocks.add(this);
|
||||
})
|
||||
.execute();
|
||||
@@ -120,7 +120,7 @@ public class PixelBlock {
|
||||
}
|
||||
|
||||
public void enterBlock(@NotNull Player player) {
|
||||
if(Main.configuration.onlyEditableByOwner() && !player.getUniqueId().equals(ownerUUID)) {
|
||||
if(Main.configuration().onlyEditableByOwner() && !player.getUniqueId().equals(ownerUUID)) {
|
||||
player.sendMessage(Component.text("Dieser Pixelblock gehört nicht dir!", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
@@ -128,13 +128,13 @@ public class PixelBlock {
|
||||
getBlockTaskChain()
|
||||
.async(() -> {
|
||||
this.lastEntryLocation = player.getLocation();
|
||||
Main.database.savePixelBlock(this);
|
||||
Main.database().savePixelBlock(this);
|
||||
})
|
||||
.sync(() -> {
|
||||
if(!exists) return;
|
||||
player.teleport(this.pixelWorld.getSpawnLocation());
|
||||
})
|
||||
.current(() -> Main.plugin.getLogger()
|
||||
.current(() -> Main.logger()
|
||||
.info(String.format("'%s' entered PixelBlock '%s' at %s", player.getName(), this.blockUUID, this.pixelBlockLocation.toString())))
|
||||
.execute();
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class PixelBlock {
|
||||
public void exitBlock(@NotNull Player player) {
|
||||
this.getBlockTaskChain()
|
||||
.sync(() -> player.teleport(this.lastEntryLocation != null ? this.lastEntryLocation : this.pixelBlockLocation))
|
||||
.current(() -> Main.plugin.getLogger().info(String.format("%s exited PixelBlock", player.getName())))
|
||||
.current(() -> Main.logger().info(String.format("%s exited PixelBlock", player.getName())))
|
||||
.sync(() -> this.pixelData = this.pixelWorld.getPixels(this.facingDirection))
|
||||
.execute();
|
||||
|
||||
@@ -170,7 +170,7 @@ public class PixelBlock {
|
||||
// @Nullable PixelBlock blockAtLocation = PixelBlock.getPixelBlockFromPlacedLocation(newLocation);
|
||||
// if(blockAtLocation != null && blockAtLocation != this) throw new IllegalArgumentException("Es können nicht mehrere Pixelblöcke ineinander platziert werden.");
|
||||
//
|
||||
// Main.plugin.getLogger().info(String.format("Placing PixelBlock '%s' at %s", this.blockUUID, placeLocation));
|
||||
// Main.logger().info(String.format("Placing PixelBlock '%s' at %s", this.blockUUID, placeLocation));
|
||||
// this.pixelBlockLocation = newLocation;
|
||||
// this.facingDirection = direction;
|
||||
// updateEntities();
|
||||
@@ -181,7 +181,7 @@ public class PixelBlock {
|
||||
|
||||
public void destroy(Player destroyedBy) {
|
||||
if(!this.exists) return;
|
||||
if(Main.configuration.onlyBreakableByOwner() && !destroyedBy.getUniqueId().equals(ownerUUID)) {
|
||||
if(Main.configuration().onlyBreakableByOwner() && !destroyedBy.getUniqueId().equals(ownerUUID)) {
|
||||
destroyedBy.sendMessage("Dieser Pixelblock gehört nicht dir!");
|
||||
return;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class PixelBlock {
|
||||
p.teleport(this.lastEntryLocation);
|
||||
});
|
||||
|
||||
Main.plugin.getLogger().info(String.format("Destroying PixelBlock '%s' at %s", this.blockUUID, pixelBlockLocation));
|
||||
Main.logger().info(String.format("Destroying PixelBlock '%s' at %s", this.blockUUID, pixelBlockLocation));
|
||||
this.exists = false;
|
||||
|
||||
this.pixelWorld.getEntitiesInWorld().stream()
|
||||
@@ -206,7 +206,7 @@ public class PixelBlock {
|
||||
world.dropItem(this.pixelBlockLocation.add(new Vector(0.5, 0.5, 0.5)), PixelBlockItem.getBlockAsItem(this));
|
||||
})
|
||||
.async(() -> {
|
||||
Main.database.deletePixelBlock(this);
|
||||
Main.database().deletePixelBlock(this);
|
||||
Main.pixelBlocks.remove(this);
|
||||
})
|
||||
.execute();
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PixelBlockHitbox {
|
||||
private static final NamespacedKey hitboxOfTag = new NamespacedKey(Main.plugin, "hitbox_of");
|
||||
private static final NamespacedKey hitboxOfTag = new NamespacedKey(Main.plugin(), "hitbox_of");
|
||||
|
||||
private final PixelBlock parentBlock;
|
||||
|
||||
@@ -25,8 +25,8 @@ public class PixelBlockHitbox {
|
||||
List<PixelBlockWorld.PixelData> pixels = this.parentBlock.getPixelData();
|
||||
double scale = pixels.getFirst().scale();
|
||||
|
||||
float offset = (float) Main.configuration.hitboxOffset();
|
||||
int pixelsPerBlock = Main.configuration.pixelsPerBlock();
|
||||
float offset = (float) Main.configuration().hitboxOffset();
|
||||
int pixelsPerBlock = Main.configuration().pixelsPerBlock();
|
||||
|
||||
Interaction interaction;
|
||||
if(true) {
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.bukkit.util.Transformation;
|
||||
import java.util.*;
|
||||
|
||||
public class PixelBlockPlaceholder {
|
||||
private static final NamespacedKey placeholderOfTag = new NamespacedKey(Main.plugin, "placeholder_of");
|
||||
private static final NamespacedKey placeholderOfTag = new NamespacedKey(Main.plugin(), "placeholder_of");
|
||||
|
||||
private final PixelBlock parentBlock;
|
||||
|
||||
|
||||
@@ -17,17 +17,15 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
import static eu.mhsl.minecraft.pixelblocks.Main.plugin;
|
||||
|
||||
public class PixelBlockWorld {
|
||||
private final PixelBlock parentPixelBlock;
|
||||
private final World world;
|
||||
|
||||
int worldGrassBorderWidth = 10;
|
||||
int pixelsPerBlock = Main.configuration.pixelsPerBlock();
|
||||
int pixelsPerBlock = Main.configuration().pixelsPerBlock();
|
||||
|
||||
public static boolean isPixelWorld(@NotNull World world) {
|
||||
return world.getName().startsWith(plugin.getDataFolder().getPath());
|
||||
return world.getName().startsWith(Main.plugin().getDataFolder().getPath());
|
||||
}
|
||||
|
||||
public static @NotNull List<World> getOtherWorlds() {
|
||||
@@ -53,7 +51,7 @@ public class PixelBlockWorld {
|
||||
}
|
||||
|
||||
public @NotNull String getWorldPathName() {
|
||||
return Main.plugin.getDataFolder().getPath() + File.separator + "worlds" + File.separator + this.parentPixelBlock.getBlockUUID();
|
||||
return Main.plugin().getDataFolder().getPath() + File.separator + "worlds" + File.separator + this.parentPixelBlock.getBlockUUID();
|
||||
}
|
||||
|
||||
public @NotNull Location getSpawnLocation() {
|
||||
@@ -146,7 +144,7 @@ public class PixelBlockWorld {
|
||||
}
|
||||
|
||||
private void setBuildingPlatform() {
|
||||
Bukkit.getScheduler().runTask(Main.plugin, () -> {
|
||||
Bukkit.getScheduler().runTask(Main.plugin(), () -> {
|
||||
for (int x = 0; x < (pixelsPerBlock+2) + 2 * worldGrassBorderWidth; x++) {
|
||||
for (int z = 0; z < (pixelsPerBlock+2) + 2 * worldGrassBorderWidth; z++) {
|
||||
getPlatformOrigin().add(x, 0, z).getBlock().setType(Material.GRASS_BLOCK);
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Pixels {
|
||||
private static final NamespacedKey pixelOfTag = new NamespacedKey(Main.plugin, "pixel_of");
|
||||
private static final NamespacedKey pixelOfTag = new NamespacedKey(Main.plugin(), "pixel_of");
|
||||
|
||||
private final @NotNull PixelBlock parentBlock;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user