Format code

This commit is contained in:
2026-05-16 23:08:09 +02:00
parent 81dd8045f2
commit d110df924e
562 changed files with 11025 additions and 10059 deletions
@@ -41,7 +41,7 @@ public class AttributesPlaceListener implements Listener {
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
ItemStack itemStack = event.getItemInHand();
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta == null) return;
@@ -65,7 +65,7 @@ public class AutostartListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!ItemUtils.isItem(event.getItem(), "autostart")) {
return;
}
@@ -89,7 +89,7 @@ public class AutostartListener implements Listener {
if (!(event.getPlayer() instanceof Player)) {
return;
}
if(!Permission.BUILD.hasPermission((Player) event.getPlayer())) return;
if (!Permission.BUILD.hasPermission((Player) event.getPlayer())) return;
if (!ItemUtils.isItem(event.getPlayer().getInventory().getItemInMainHand(), "autostart")) {
return;
}
@@ -104,7 +104,8 @@ public class BackupCommand extends SWCommand {
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("BACKUP_LORE", p));
for (int i = 0; i < backups.size(); i++) {
RegionBackups.Backup backup = backups.get(i);
SWItem swItem = new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("BACKUP_ITEM_NAME", p, backup.getName()), lore, false, clickType -> {});
SWItem swItem = new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("BACKUP_ITEM_NAME", p, backup.getName()), lore, false, clickType -> {
});
swItem.getItemStack().setAmount(i + 1);
swListEntries.add(new SWListInv.SWListEntry<>(swItem, backup));
}
@@ -58,14 +58,14 @@ public class Countingwand {
}
}
public static ItemStack getWandItem(Player player) {
ItemStack itemStack = new SWItem(Material.STICK, BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_LORE1", player), BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_LORE2", player)), false, null).getItemStack();
ItemUtils.setItem(itemStack, "countingwand");
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setCustomModelData(1);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack getWandItem(Player player) {
ItemStack itemStack = new SWItem(Material.STICK, BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_LORE1", player), BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_LORE2", player)), false, null).getItemStack();
ItemUtils.setItem(itemStack, "countingwand");
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setCustomModelData(1);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public boolean isCountingwand(ItemStack itemStack) {
return ItemUtils.isItem(itemStack, "countingwand");
@@ -28,12 +28,12 @@ import org.bukkit.entity.Player;
@Linked
public class CountingwandCommand extends SWCommand {
public CountingwandCommand() {
super("countingwand", "/countingwand", "cwand", "/cwand", "zollstock", "/zollstock");
}
public CountingwandCommand() {
super("countingwand", "/countingwand", "cwand", "/cwand", "zollstock", "/zollstock");
}
@Register(description = "COUNTINGWAND_COMMAND_HELP")
public void genericCommand(final Player p) {
SWUtils.giveItemToPlayer(p, Countingwand.getWandItem(p));
}
@Register(description = "COUNTINGWAND_COMMAND_HELP")
public void genericCommand(final Player p) {
SWUtils.giveItemToPlayer(p, Countingwand.getWandItem(p));
}
}
@@ -30,24 +30,24 @@ import org.bukkit.inventory.ItemStack;
@Linked
public class CountingwandGuiItem extends BauGuiItem {
public CountingwandGuiItem() {
super(22);
}
public CountingwandGuiItem() {
super(22);
}
@Override
public ItemStack getItem(Player player) {
return Countingwand.getWandItem(player);
}
@Override
public ItemStack getItem(Player player) {
return Countingwand.getWandItem(player);
}
@Override
public boolean click(ClickType click, Player p) {
p.closeInventory();
p.performCommand("countingwand");
return false;
}
@Override
public boolean click(ClickType click, Player p) {
p.closeInventory();
p.performCommand("countingwand");
return false;
}
@Override
public Permission permission() {
return Permission.MEMBER;
}
@Override
public Permission permission() {
return Permission.MEMBER;
}
}
@@ -35,35 +35,35 @@ import java.util.Objects;
@Linked
public class CountingwandListener implements Listener {
@EventHandler
public void onBlockBreak(final BlockBreakEvent event) {
if (!Countingwand.isCountingwand(event.getPlayer().getInventory().getItemInMainHand())) {
return;
}
@EventHandler
public void onBlockBreak(final BlockBreakEvent event) {
if (!Countingwand.isCountingwand(event.getPlayer().getInventory().getItemInMainHand())) {
return;
}
event.setCancelled(true);
Countingwand.checkSelection(Point.fromLocation(event.getBlock().getLocation()), true, event.getPlayer());
}
event.setCancelled(true);
Countingwand.checkSelection(Point.fromLocation(event.getBlock().getLocation()), true, event.getPlayer());
}
@EventHandler
public void onPlayerInteract(final PlayerInteractEvent event) {
if (!Countingwand.isCountingwand(event.getItem())) {
return;
}
@EventHandler
public void onPlayerInteract(final PlayerInteractEvent event) {
if (!Countingwand.isCountingwand(event.getItem())) {
return;
}
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR) {
RayTraceResult rayTraceResult = event.getPlayer().rayTraceBlocks(200, FluidCollisionMode.NEVER);
if (rayTraceResult == null) {
return;
}
Countingwand.checkSelection(Point.fromLocation(Objects.requireNonNull(rayTraceResult.getHitBlock()).getLocation()), event.getAction() == Action.LEFT_CLICK_AIR, event.getPlayer());
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR) {
RayTraceResult rayTraceResult = event.getPlayer().rayTraceBlocks(200, FluidCollisionMode.NEVER);
if (rayTraceResult == null) {
return;
}
Countingwand.checkSelection(Point.fromLocation(Objects.requireNonNull(rayTraceResult.getHitBlock()).getLocation()), event.getAction() == Action.LEFT_CLICK_AIR, event.getPlayer());
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
event.setCancelled(true);
Countingwand.checkSelection(Point.fromLocation(Objects.requireNonNull(event.getClickedBlock()).getLocation()), false, event.getPlayer());
}
event.setCancelled(true);
Countingwand.checkSelection(Point.fromLocation(Objects.requireNonNull(event.getClickedBlock()).getLocation()), false, event.getPlayer());
}
}
@@ -31,7 +31,7 @@ public class HotbarListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (allNull(event.getPlayer().getInventory().getContents()) && allNull(event.getPlayer().getInventory().getArmorContents())) {
DefaultHotbar.setHotbar(event.getPlayer());
}
@@ -50,7 +50,8 @@ public class InventoryFillBauGuiItem extends BauGuiItem {
@Override
public ItemStack getItem(Player player) {
String loreKey = Config.getInstance().get(player).getPlainValueOrDefault("inventoryfill", false) ? "OTHER_ITEMS_INVENTORY_FILL_LORE_ACTIVE" : "OTHER_ITEMS_INVENTORY_FILL_LORE_INACTIVE";
return new SWItem(Material.HOPPER, BauSystem.MESSAGE.parse("OTHER_ITEMS_INVENTORY_FILL_NAME", player), Collections.singletonList(BauSystem.MESSAGE.parse(loreKey, player)), false, clickType -> {}).getItemStack();
return new SWItem(Material.HOPPER, BauSystem.MESSAGE.parse("OTHER_ITEMS_INVENTORY_FILL_NAME", player), Collections.singletonList(BauSystem.MESSAGE.parse(loreKey, player)), false, clickType -> {
}).getItemStack();
}
@Override
@@ -39,7 +39,7 @@ public class InventoryFiller implements Listener {
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return;
if (!event.getPlayer().isSneaking()) return;
Block block = event.getPlayer().getTargetBlockExact(5);
@@ -61,7 +61,7 @@ public class InventoryFiller implements Listener {
*/
@EventHandler
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return;
if (!event.getPlayer().isSneaking()) return;
ItemStack itemStack = event.getPlayer().getInventory().getItemInMainHand();
@@ -58,9 +58,9 @@ public class KillcheckerVisualizer {
Material.BLACK_CONCRETE,
};
private static final World WORLD = Bukkit.getWorlds().get(0);
private static final double SURROUND = 4.5;
private final Point minPoint;
private final Point maxPoint;
@@ -104,7 +104,9 @@ public class KillcheckerVisualizer {
Block block = WORLD.getBlockAt(x, y, z);
if (block.getType().isAir()) continue;
String name = block.getType().name();
if (!name.endsWith("_WOOL") && !name.endsWith("_STAINED_GLASS") && !name.endsWith("_CONCRETE") && !name.endsWith("_TERRACOTTA")) continue;
if (!name.endsWith("_WOOL") && !name.endsWith("_STAINED_GLASS") && !name.endsWith("_CONCRETE") && !name.endsWith("_TERRACOTTA")) {
continue;
}
if (name.equals("_GLAZED_TERRACOTTA")) continue;
Cuboid cuboid = create(block.getType(), x, y, z);
cuboids.add(cuboid);
@@ -283,7 +285,9 @@ public class KillcheckerVisualizer {
}
kill.forEach((point, count) -> {
if (rEntities.containsKey(point)) {
if (killCount.get(point) == count && outlinePoints.contains(point) == outlinePointsCacheLast.contains(point)) return;
if (killCount.get(point) == count && outlinePoints.contains(point) == outlinePointsCacheLast.contains(point)) {
return;
}
rEntities.get(point).die();
}
RFallingBlockEntity entity = new RFallingBlockEntity(outlinePoints.contains(point) ? outline : inner, point.toLocation(WORLD, 0.5, 0, 0.5), MATERIALS[Math.min(count - 1, MATERIALS.length) - 1]);
@@ -325,7 +329,7 @@ public class KillcheckerVisualizer {
if (point.getX() < minPoint.getX() || point.getX() > maxPoint.getX()) continue;
if (point.getY() < minPoint.getY() || point.getY() > maxPoint.getY()) continue;
if (point.getZ() < minPoint.getZ() || point.getZ() > maxPoint.getZ()) continue;
if (WORLD.getBlockAt(point.getX() + 1, point.getY(), point.getZ()).getType() == type) {
points.add(new Point(point.getX() + 1, point.getY(), point.getZ()));
}
@@ -71,7 +71,7 @@ public class Loader implements Listener, SWPlayer.Component {
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
if (stage != Stage.RUNNING && stage != Stage.SINGLE) return;
if(!Permission.BUILD.hasPermission(p)) return;
if (!Permission.BUILD.hasPermission(p)) return;
if (waitTime > 0) {
waitTime--;
return;
@@ -213,7 +213,8 @@ public class Loader implements Listener, SWPlayer.Component {
};
updateRunnable.run();
SWListInv<LoaderElement> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("LOADER_GUI_TITLE", p), false, list, (clickType, loaderElement) -> {});
SWListInv<LoaderElement> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("LOADER_GUI_TITLE", p), false, list, (clickType, loaderElement) -> {
});
swListInv.setCallback((clickType, entry) -> entry.click(p, () -> {
updateRunnable.run();
swListInv.open();
@@ -363,7 +364,9 @@ public class Loader implements Listener, SWPlayer.Component {
public static int LENGTH = SettingsSorting.values().length;
public abstract Material getMaterial();
public abstract String getName();
public abstract boolean shouldShow(LoaderElement previous, LoaderElement current, LoaderElement next);
}
@@ -41,7 +41,7 @@ public class LoaderScoreboardElement implements ScoreboardElement {
@Override
public String get(Region region, Player p) {
if(!Permission.BUILD.hasPermission(p)) return null;
if (!Permission.BUILD.hasPermission(p)) return null;
Loader loader = Loader.getLoader(p);
if (loader == null) return null;
if (loader.getStage() == Loader.Stage.RUNNING) {
@@ -26,6 +26,8 @@ import java.util.function.Consumer;
public interface LoaderElement {
SWItem menu(Player player);
void execute(Consumer<Long> delay);
void click(Player player, Runnable backAction);
}
@@ -95,7 +95,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
};
updateRunnable.run();
SWListInv<Integer> listInv = new SWListInv<>(player, "Interaction Settings", false, entries, (clickType, entry) -> {});
SWListInv<Integer> listInv = new SWListInv<>(player, "Interaction Settings", false, entries, (clickType, entry) -> {
});
listInv.setCallback((clickType, entry) -> {
openIndividualSettingsMenu(player, entry, () -> {
updateRunnable.run();
@@ -150,7 +151,9 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
}
SWInventory swInventory = new SWInventory(player, guiSize, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
for (int i = guiSize - 9; i < guiSize; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", clickType -> {}));
for (int i = guiSize - 9; i < guiSize; i++)
swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", clickType -> {
}));
swInventory.setItem(guiSize - 9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).setCustomModelData(CMDs.BACK).getItemStack(), clickType -> back.run());
swInventory.setItem(guiSize - 5, new SWItem(Material.WOODEN_AXE, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_COPY", player)).getItemStack(), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_GUI_COPY_TITLE", player), "1");
@@ -197,7 +200,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
for (int power = 0; power < 16; power++) {
int finalPowerPosition = power;
if (power >= 9) finalPowerPosition++;
SWItem powerItem = new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("LOADER_SETTING_POWER", player, power), Arrays.asList(), false, clickType -> {});
SWItem powerItem = new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("LOADER_SETTING_POWER", player, power), Arrays.asList(), false, clickType -> {
});
powerItem.getItemStack().setAmount(Math.max(power, 1));
if (extraPower.get(index) == power) powerItem.setEnchanted(true);
@@ -210,7 +214,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
}
if (currentElement.hasTicks(this)) {
swInventory.setItem(ticksStart + 3, new SWItem(Material.RED_DYE, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> {
swInventory.setItem(ticksStart + 3, new SWItem(Material.RED_DYE, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {
}).getItemStack(), clickType -> {
long ticks = extraTicks.get(index);
ticks -= clickType.isShiftClick() ? 5 : 1;
if (ticks < 1) ticks = 1;
@@ -218,7 +223,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
openIndividualSettingsMenu(player, index, back, delete);
});
SWItem ticksItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS", player, extraTicks.get(index)), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)), false, clickType -> {});
SWItem ticksItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS", player, extraTicks.get(index)), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)), false, clickType -> {
});
ticksItem.getItemStack().setAmount((int) Math.min(extraTicks.get(index), 64));
swInventory.setItem(ticksStart + 4, ticksItem.getItemStack(), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_NAME", player), extraTicks.get(index) + "");
@@ -234,7 +240,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
swAnvilInv.open();
});
swInventory.setItem(ticksStart + 5, new SWItem(Material.LIME_DYE, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> {
swInventory.setItem(ticksStart + 5, new SWItem(Material.LIME_DYE, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE_SHIFT", player)), false, clickType -> {
}).getItemStack(), clickType -> {
long ticks = extraTicks.get(index);
ticks += clickType.isShiftClick() ? 5 : 1;
extraTicks.set(index, ticks);
@@ -28,10 +28,13 @@ import java.util.function.Consumer;
public interface LoaderSettingsEnum<T, P extends LoaderInteractionElement<E>, E extends Enum<E> & LoaderSettingsEnum<T, P, E>> {
int getPos();
SWItem menu(Player player, P parent, int power, long ticks);
default boolean hasPower(P parent) {
return false;
}
default boolean hasTicks(P parent) {
return false;
}
@@ -63,7 +63,8 @@ public class LoaderWait implements LoaderElement {
for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7"));
swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_BACK", player)).setCustomModelData(CMDs.BACK).getItemStack(), clickType -> backAction.run());
swInventory.setItem(3, new SWItem(Material.RED_DYE, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> {
swInventory.setItem(3, new SWItem(Material.RED_DYE, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {
}).getItemStack(), clickType -> {
delay -= clickType.isShiftClick() ? 5 : 1;
if (delay < 0) delay = 0;
swInventory.setItem(4, menu(player));
@@ -80,7 +81,8 @@ public class LoaderWait implements LoaderElement {
});
swAnvilInv.open();
});
swInventory.setItem(5, new SWItem(Material.LIME_DYE, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> {
swInventory.setItem(5, new SWItem(Material.LIME_DYE, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE_SHIFT", player)), false, clickType -> {
}).getItemStack(), clickType -> {
delay += clickType.isShiftClick() ? 5 : 1;
swInventory.setItem(4, menu(player));
});
@@ -146,8 +146,7 @@ public class Loadtimer implements Listener {
if ((stage == Stage.COUNTING || stage == Stage.ACTIVATED)) {
stage = Stage.IGNITION;
ignite = TPSUtils.currentRealTick.get();
if (activate == -1)
activate = TPSUtils.currentRealTick.get();
if (activate == -1) activate = TPSUtils.currentRealTick.get();
if (finishOnActive) {
stage = Stage.END;
print();
@@ -40,16 +40,18 @@ public class LoadtimerCommand extends SWCommand {
public void start(@Validator Player p, TimerMode mode) {
Region r = Region.getRegion(p.getLocation());
if (r.getType().isGlobal()) return;
if (!Loadtimer.hasTimer(r))
if (!Loadtimer.hasTimer(r)) {
Loadtimer.createLoadtimer(r, mode == TimerMode.HALF);
}
}
@Register(value = "stop", description = "LOADTIMER_HELP_STOP")
public void stop(@Validator Player p) {
Region r = Region.getRegion(p.getLocation());
if (r.getType().isGlobal()) return;
if (Loadtimer.hasTimer(r))
if (Loadtimer.hasTimer(r)) {
Loadtimer.getTimer(r).delete();
}
}
public enum TimerMode {
@@ -46,8 +46,9 @@ public class LoadtimerGuiItem extends BauGuiItem {
@Override
public ItemStack getItem(Player player) {
Region r = Region.getRegion(player.getLocation());
if (r.getType().isGlobal())
if (r.getType().isGlobal()) {
return new SWItem(Material.BOWL, BauSystem.MESSAGE.parse("LOADTIMER_GUI_GLOBAL", player)).getItemStack();
}
if (Loadtimer.hasTimer(r)) {
return new SWItem(Material.BOW, BauSystem.MESSAGE.parse("LOADTIMER_GUI_STOP", player)).getItemStack();
} else {
@@ -54,7 +54,7 @@ public class ObserverTracerListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!enabled.contains(event.getPlayer())) return;
if (event.getClickedBlock() == null) return;
ObserverTracer observerTracer = SWPlayer.of(event.getPlayer()).getComponent(ObserverTracer.class).orElse(null);
@@ -61,9 +61,9 @@ public class RayVisualizerCommand extends SWCommand implements Listener {
}
private boolean locEquals(Location loc1, Location loc2) {
if ((long)(loc1.getX() * 1000) != (long)(loc2.getX() * 1000)) return false;
if ((long)(loc1.getY() * 1000) != (long)(loc2.getY() * 1000)) return false;
if ((long)(loc1.getZ() * 1000) != (long)(loc2.getZ() * 1000)) return false;
if ((long) (loc1.getX() * 1000) != (long) (loc2.getX() * 1000)) return false;
if ((long) (loc1.getY() * 1000) != (long) (loc2.getY() * 1000)) return false;
if ((long) (loc1.getZ() * 1000) != (long) (loc2.getZ() * 1000)) return false;
return true;
}
@@ -36,12 +36,16 @@ public class FireListener implements Listener, ScoreboardElement {
@EventHandler
public void onFireDamage(BlockBurnEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FIRE).isWithDefault(FireMode.DENY)) {
e.setCancelled(true);
}
}
@EventHandler
public void onFireSpread(BlockSpreadEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FIRE).isWithDefault(FireMode.DENY)) {
e.setCancelled(true);
}
}
@Override
@@ -44,11 +44,11 @@ public class FreezeCommand extends SWCommand {
}
}
private String getEnableMessage(){
private String getEnableMessage() {
return "REGION_FREEZE_ENABLED";
}
private String getDisableMessage(){
private String getDisableMessage() {
return "REGION_FREEZE_DISABLED";
}
@@ -47,7 +47,9 @@ public class FreezeListener implements Listener, ScoreboardElement {
@EventHandler
public void onBlockExplode(BlockExplodeEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) {
return;
}
e.setCancelled(true);
BlockState state = e.getBlock().getState();
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
@@ -57,7 +59,9 @@ public class FreezeListener implements Listener, ScoreboardElement {
@EventHandler
public void onEntitySpawn(EntitySpawnEvent e) {
if (Region.getRegion(e.getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
if (Region.getRegion(e.getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) {
return;
}
e.setCancelled(true);
if (e.getEntityType() == EntityType.TNT) {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
@@ -69,7 +73,9 @@ public class FreezeListener implements Listener, ScoreboardElement {
@EventHandler
public void onBlockCanBuild(BlockCanBuildEvent e) {
if (!e.isBuildable()) return;
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) {
return;
}
if (e.getMaterial() == Material.TNT) {
e.setBuildable(false);
e.getBlock().setType(Material.TNT, false);
@@ -44,11 +44,11 @@ public class ItemsCommand extends SWCommand {
}
}
private String getEnableMessage(){
private String getEnableMessage() {
return "REGION_ITEMS_ENABLED";
}
private String getDisableMessage(){
private String getDisableMessage() {
return "REGION_ITEMS_DISABLED";
}
@@ -97,7 +97,7 @@ public class RegionCommand extends SWCommand {
@Register(value = "restore", description = "REGION_REGION_HELP_RESTORE")
public void genericRestoreCommand(@Validator Player p) {
Region region = Region.getRegion(p.getLocation());
if(checkGlobalRegion(region, p)) return;
if (checkGlobalRegion(region, p)) return;
try {
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
@@ -116,7 +116,7 @@ public class RegionCommand extends SWCommand {
Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) return;
if(node.isDir()) {
if (node.isDir()) {
BauSystem.MESSAGE.send("ONLY_SCHEMS", p);
return;
}
@@ -59,7 +59,9 @@ public class RegionListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPhysics(final BlockPhysicsEvent event) {
if (event.getBlock().getType() != event.getChangedType()) RegionListener.tagChangedRegion(event.getBlock().getLocation());
if (event.getBlock().getType() != event.getChangedType()) {
RegionListener.tagChangedRegion(event.getBlock().getLocation());
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@@ -72,7 +72,7 @@ public class TestblockCommand extends SWCommand {
resetRegion(p, node, isExtension ? RegionExtensionType.EXTENSION : RegionExtensionType.NORMAL, isIgnoreAir, isOnlyColor, replaceTNT, replaceWater);
}
@Register(value="default")
@Register(value = "default")
public void setTestblockDefault(Player p) {
Region region = regionCheck(p);
if (region == null) return;
@@ -33,11 +33,11 @@ public class WaterDestroyCommand extends SWCommand {
super("waterdestroy");
}
private String getEnableMessage(){
private String getEnableMessage() {
return "REGION_WATER_ENABLED";
}
private String getDisableMessage(){
private String getDisableMessage() {
return "REGION_WATER_DISABLED";
}
@@ -36,7 +36,9 @@ public class WaterDestroyListener implements Listener, ScoreboardElement {
@EventHandler
public void onBlockFromTo(BlockFromToEvent event) {
if (event.getBlock().getType() == Material.WATER && event.getToBlock().getType() != Material.AIR && Region.getRegion(event.getBlock().getLocation()).getRegionData().get(Flag.WATER_DESTROY).isWithDefault(WaterDestroyMode.DENY)) event.setCancelled(true);
if (event.getBlock().getType() == Material.WATER && event.getToBlock().getType() != Material.AIR && Region.getRegion(event.getBlock().getLocation()).getRegionData().get(Flag.WATER_DESTROY).isWithDefault(WaterDestroyMode.DENY)) {
event.setCancelled(true);
}
}
@Override
@@ -67,7 +67,7 @@ public class ScriptGUI implements Listener {
lore.add(BauSystem.MESSAGE.parse("SCRIPT_ERROR_GUI", player, String.join(":", Arrays.copyOfRange(sp, 1, sp.length))));
}
if(!lore.isEmpty()) {
if (!lore.isEmpty()) {
lore.add("");
}
lore.add(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_1", player));
@@ -75,16 +75,17 @@ public class ScriptGUI implements Listener {
lore.add(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_3", player));
lore.add(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_4", player));
entries.add(new SWListInv.SWListEntry<>(new SWItem(Material.ENCHANTED_BOOK, script.getName(), new ArrayList<>(lore), false, clickType -> {}), script));
entries.add(new SWListInv.SWListEntry<>(new SWItem(Material.ENCHANTED_BOOK, script.getName(), new ArrayList<>(lore), false, clickType -> {
}), script));
lore.clear();
});
SWListInv<Script> inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_NAME", player), false, entries, (clickType, script) -> {
ItemStack itemStack = ScriptHelper.getScriptItem(script, clickType.isRightClick());
if(clickType == ClickType.MIDDLE) {
if (clickType == ClickType.MIDDLE) {
player.openBook(itemStack);
} else if(!clickType.isShiftClick()) {
} else if (!clickType.isShiftClick()) {
script.delete();
ScriptRunner.updateGlobalScript(player);
open(player, itemStack);
@@ -93,14 +94,14 @@ public class ScriptGUI implements Listener {
}
});
inv.setItem(49, Material.HOPPER, BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_ADD_NAME", player), Collections.singletonList(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_ADD_LORE", player)), false, click -> {
if(player.getOpenInventory().getCursor() != null) {
if (player.getOpenInventory().getCursor() != null) {
ItemStack cursor = player.getOpenInventory().getCursor();
if(!(cursor.getItemMeta() instanceof BookMeta)) {
if (!(cursor.getItemMeta() instanceof BookMeta)) {
return;
}
BookMeta meta = (BookMeta) cursor.getItemMeta();
if(meta == null) {
if (meta == null) {
return;
}
@@ -108,14 +109,14 @@ public class ScriptGUI implements Listener {
}
});
inv.open();
if(setCursor != null) {
if (setCursor != null) {
player.getOpenInventory().setCursor(setCursor);
}
}
private static void saveWithName(Player player, BookMeta meta, String name) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(name != null && Script.list(user).stream().noneMatch(script -> script.getName().equalsIgnoreCase(name))) {
if (name != null && Script.list(user).stream().noneMatch(script -> script.getName().equalsIgnoreCase(name))) {
Script.create(user, name, ScriptHelper.getScriptString(meta.getPages()));
player.getOpenInventory().setCursor(null);
ScriptRunner.updateGlobalScript(player);
@@ -36,7 +36,7 @@ public class ScriptHelper {
public static ItemStack getScriptItem(Script script, boolean writeable) {
ItemStack itemStack = new ItemStack(writeable ? Material.WRITABLE_BOOK : Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) itemStack.getItemMeta();
if(!writeable) {
if (!writeable) {
meta.setTitle(script.getName());
meta.setAuthor(SteamwarUser.byId(script.getUserId()).getUserName());
}
@@ -44,7 +44,7 @@ public class ScriptListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onLeftClick(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
ItemStack item = event.getItem();
if (item == null || FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) {
@@ -72,7 +72,7 @@ public class ScriptListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
ScriptRunner.updateGlobalScript(event.getPlayer());
}
@@ -102,7 +102,7 @@ public class ScriptRunner {
.orElse(Collections.emptyMap())
.getOrDefault(event, Collections.emptyList());
if (luaFunctions.isEmpty()) {
if(event == SteamWarGlobalLuaPlugin.EventType.DoubleSwap) {
if (event == SteamWarGlobalLuaPlugin.EventType.DoubleSwap) {
player.performCommand("gui");
}
return;
@@ -32,7 +32,7 @@ public class CommandListener implements Listener {
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
String[] split = event.getMessage().split(" ");
ScriptRunner.ScriptData scriptData = SWPlayer.of(event.getPlayer()).getComponentOrDefault(ScriptRunner.ScriptData.class, ScriptRunner.ScriptData::new);
if (scriptData.getCalledCommands().contains(split[0])) return;
@@ -72,7 +72,7 @@ public interface LuaLib {
default LuaTable toPos(Point point) {
if (point == null) return LuaTable.tableOf();
return LuaValue.tableOf(new LuaValue[] {
return LuaValue.tableOf(new LuaValue[]{
LuaValue.valueOf("x"), LuaValue.valueOf(point.getX()),
LuaValue.valueOf("y"), LuaValue.valueOf(point.getY()),
LuaValue.valueOf("z"), LuaValue.valueOf(point.getZ())
@@ -82,7 +82,9 @@ public interface LuaLib {
default Class<? extends LuaLib> parent() {
return null;
}
String name();
LuaTable get(Player player);
@AllArgsConstructor
@@ -103,27 +105,33 @@ public interface LuaLib {
try {
consumer.accept(luaValue.toboolean());
return NIL;
} catch (Exception ingored) {}
} catch (Exception ingored) {
}
try {
consumer.accept((long) luaValue.toint());
return NIL;
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
try {
consumer.accept(luaValue.toint());
return NIL;
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
try {
consumer.accept(luaValue.todouble());
return NIL;
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
try {
consumer.accept((float) luaValue.todouble());
return NIL;
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
try {
consumer.accept(luaValue.toString());
return NIL;
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
throw new LuaError("Invalid lua type: " + luaValue.typename());
} catch (Throwable throwable) {
throw new LuaError("Error in '" + name + "' " + throwable.getMessage());
@@ -84,12 +84,12 @@ public class RandomLib implements LuaLib {
private static class NextBool extends VarArgFunction {
@Override
public Varargs invoke(Varargs args) {
if (args.narg() == 0) {
return LuaValue.valueOf(random.nextBoolean());
}
throw new LuaError("Invalid number of arguments for random.nextBoolean() zero expected got " + args.narg());
@Override
public Varargs invoke(Varargs args) {
if (args.narg() == 0) {
return LuaValue.valueOf(random.nextBoolean());
}
throw new LuaError("Invalid number of arguments for random.nextBoolean() zero expected got " + args.narg());
}
}
}
@@ -78,7 +78,7 @@ public class RegionLib implements LuaLib {
Loader loader = Loader.getLoader(player);
table.set("loader", getter(() -> loader == null ? "OFF" : loader.getStage().name()));
table.set("copyPoint", getter(() -> toPos(region.get().getBuildArea().getCopyPoint())));
table.set("minPointBuild", getter(() -> toPos(region.get().getBuildArea().getMinPoint(false))));
table.set("maxPointBuild", getter(() -> toPos(region.get().getBuildArea().getMinPoint(false))));
@@ -62,7 +62,8 @@ public class StorageLib implements LuaLib, Enable, Disable {
jsonObject.keySet().forEach(key -> {
GLOBAL_STORAGE.put(key, fromJson(jsonObject.get(key)));
});
} catch (Exception e) {}
} catch (Exception e) {
}
File regionStorageDirectory = new File(storageDirectory, "region");
regionStorageDirectory.mkdirs();
@@ -75,7 +76,8 @@ public class StorageLib implements LuaLib, Enable, Disable {
});
Region region = RegionSystem.INSTANCE.getRegion(UUID.fromString(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length()))).orElse(null);
REGION_STORAGE.put(region, map);
} catch (Exception e) {}
} catch (Exception e) {
}
}
File playerStorageDirectory = new File(storageDirectory, "player");
@@ -89,7 +91,8 @@ public class StorageLib implements LuaLib, Enable, Disable {
});
SteamwarUser steamwarUser = SteamwarUser.byId(Integer.parseInt(playerStorage.getName().substring(0, playerStorage.getName().length() - ".json".length())));
PLAYER_STORAGE.put(steamwarUser.getUUID(), map);
} catch (Exception e) {}
} catch (Exception e) {
}
}
}
@@ -105,10 +108,12 @@ public class StorageLib implements LuaLib, Enable, Disable {
if (jsonPrimitive.isNumber()) {
try {
return LuaValue.valueOf(jsonPrimitive.getAsInt());
} catch (NumberFormatException e) {}
} catch (NumberFormatException e) {
}
try {
return LuaValue.valueOf(jsonPrimitive.getAsDouble());
} catch (NumberFormatException e) {}
} catch (NumberFormatException e) {
}
}
if (jsonPrimitive.isString()) {
return LuaValue.valueOf(jsonPrimitive.getAsString());
@@ -135,7 +140,8 @@ public class StorageLib implements LuaLib, Enable, Disable {
FileWriter fileWriter = new FileWriter(new File(storageDirectory, "global.json"));
gson.toJson(toJson(GLOBAL_STORAGE), fileWriter);
fileWriter.close();
} catch (IOException e) {}
} catch (IOException e) {
}
File regionStorageDirectory = new File(storageDirectory, "region");
regionStorageDirectory.mkdirs();
@@ -144,7 +150,8 @@ public class StorageLib implements LuaLib, Enable, Disable {
FileWriter fileWriter = new FileWriter(new File(regionStorageDirectory, entry.getKey().getID().toString() + ".json"));
gson.toJson(toJson(entry.getValue()), fileWriter);
fileWriter.close();
} catch (IOException e) {}
} catch (IOException e) {
}
}
File playerStorageDirectory = new File(storageDirectory, "player");
@@ -154,7 +161,8 @@ public class StorageLib implements LuaLib, Enable, Disable {
FileWriter fileWriter = new FileWriter(new File(playerStorageDirectory, SteamwarUser.get(entry.getKey()).getId() + ".json"));
gson.toJson(toJson(entry.getValue()), fileWriter);
fileWriter.close();
} catch (IOException e) {}
} catch (IOException e) {
}
}
}
@@ -174,13 +182,16 @@ public class StorageLib implements LuaLib, Enable, Disable {
}
try {
return new JsonPrimitive(luaValue.checkboolean());
} catch (Exception e) {}
} catch (Exception e) {
}
try {
return new JsonPrimitive(luaValue.checkint());
} catch (Exception e) {}
} catch (Exception e) {
}
try {
return new JsonPrimitive(luaValue.checkdouble());
} catch (Exception e) {}
} catch (Exception e) {
}
if (luaValue.isstring()) {
return new JsonPrimitive(luaValue.tojstring());
@@ -193,7 +204,8 @@ public class StorageLib implements LuaLib, Enable, Disable {
if (value == null) continue;
try {
jsonObject.add(key.checkjstring(), value);
} catch (Exception e) {}
} catch (Exception e) {
}
}
return jsonObject;
}
@@ -249,7 +261,9 @@ public class StorageLib implements LuaLib, Enable, Disable {
}
}
};
};
}
;
});
storageLib.set("global", global);
@@ -294,7 +308,9 @@ public class StorageLib implements LuaLib, Enable, Disable {
}
}
};
};
}
;
});
storageLib.set("player", playerStorage);
@@ -343,7 +359,9 @@ public class StorageLib implements LuaLib, Enable, Disable {
}
}
};
};
}
;
});
storageLib.set("region", regionStorage);
@@ -45,7 +45,7 @@ public class WorldEditLib implements LuaLib {
return selection;
}, o -> {
LuaTable selection = o.checktable();
if(selection.length() != 2) {
if (selection.length() != 2) {
throw new IllegalArgumentException("selection must have exactly 2 elements");
}
@@ -26,7 +26,9 @@ import org.bukkit.entity.Player;
public interface BlockDataConfiguration<T extends BlockData> {
void previous();
void next();
SWItem get(Player player);
void apply(T copied, T worldOriginal);
@@ -293,8 +293,9 @@ public class SimulatorCursor implements Listener {
if (!player.isSneaking()) {
pos.setX(pos.getBlockX() + 0.5);
if (face == null || face.getModY() == 0)
if (face == null || face.getModY() == 0) {
pos.setY(pos.getBlockY() + 0.0);
}
pos.setZ(pos.getBlockZ() + 0.5);
}
@@ -120,6 +120,10 @@ public abstract class SimulatorElement<T extends SimulatorPhase> {
}
public abstract String getType();
public void saveExtra(YAPIONObject elementObject) {}
public void loadExtra(YAPIONObject elementObject) {}
public void saveExtra(YAPIONObject elementObject) {
}
public void loadExtra(YAPIONObject elementObject) {
}
}
@@ -37,6 +37,10 @@ public abstract class SimulatorPhase {
protected int order = 0;
public abstract void toSimulatorActions(Vector position, BiConsumer<Integer, SimulatorAction> tickStart, BiConsumer<Integer, SimulatorAction> tickEnd);
public void saveExtra(YAPIONObject phaseObject) {}
public void loadExtra(YAPIONObject phaseObject) {}
public void saveExtra(YAPIONObject phaseObject) {
}
public void loadExtra(YAPIONObject phaseObject) {
}
}
@@ -65,7 +65,9 @@ public final class TNTPhase extends SimulatorPhase {
@Override
public void accept(World world) {
Location location = position.toLocation(world);
if (Region.getRegion(location).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) return;
if (Region.getRegion(location).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
return;
}
TNTPrimed tnt = world.spawn(location, TNTPrimed.class);
if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0));
if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0));
@@ -140,7 +140,7 @@ public class SimulatorExecutor implements Listener {
private void runActions(List<SimulatorAction> actionsToRun) {
while (!actionsToRun.isEmpty()) {
Collections.shuffle(actionsToRun);
for (int i = actionsToRun.size() - 1 ; i >= 0; i--) {
for (int i = actionsToRun.size() - 1; i >= 0; i--) {
SimulatorAction action = actionsToRun.get(i);
action.accept(WORLD);
action.setCount(action.getCount() - 1);
@@ -55,8 +55,9 @@ public class StabGenerator extends StabStep implements Listener {
if (!(event.getEntity() instanceof TNTPrimed)) return;
if (Region.getRegion(event.getEntity().getLocation()) == data.region) {
event.blockList().forEach(block -> {
if (!data.region.getTestblockArea().inRegion(block.getLocation(), true))
if (!data.region.getTestblockArea().inRegion(block.getLocation(), true)) {
return;
}
int component = data.direction.component.apply(block.getLocation().toVector());
destroyedBlocksPerSlice.computeIfAbsent(component, __ -> new HashSet<>())
.add(block.getLocation());
@@ -148,7 +148,7 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
.allMatch(tntElement -> tntElement.getAlignment().getX() == -1));
inventory.setItem(12, negativXItem);
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.forEach(tntElement -> {
@@ -169,7 +169,7 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
new SimulatorAnvilGui<>(player, "Relative X", "", Double::parseDouble, number -> {
if(!allTNT){
if (!allTNT) {
number = (double) Math.round(number);
}
simulatorGroup.move(number, 0, 0);
@@ -189,7 +189,7 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
new SimulatorAnvilGui<>(player, "Relative Y", "", Double::parseDouble, number -> {
if(!allTNT){
if (!allTNT) {
number = (double) Math.round(number);
}
simulatorGroup.move(0, number, 0);
@@ -209,7 +209,7 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
new SimulatorAnvilGui<>(player, "Relative Z", "", Double::parseDouble, number -> {
if(!allTNT){
if (!allTNT) {
number = (double) Math.round(number);
}
simulatorGroup.move(0, 0, number);
@@ -148,7 +148,7 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
Supplier<Integer> getter = observerPhase::getTickOffset;
Consumer<Integer> setter = observerPhase::setTickOffset;
return new SWItem[] {
return new SWItem[]{
new SWItem(getter.get() < max ? Material.LIME_DYE : Material.GRAY_DYE, "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
if (clickType == ClickType.DOUBLE_CLICK) return;
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
@@ -93,7 +93,7 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
//Pos X
inventory.setItem(15, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
inventory.setItem(15, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
if (clickType == ClickType.DOUBLE_CLICK) return;
observer.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
SimulatorWatcher.update(simulator);
@@ -163,7 +163,7 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
Supplier<Integer> getter = redstoneSubPhase.place ? redstoneSubPhase.phase::getTickOffset : redstoneSubPhase.phase::getLifetime;
Consumer<Integer> setter = redstoneSubPhase.place ? redstoneSubPhase.phase::setTickOffset : redstoneSubPhase.phase::setLifetime;
return new SWItem[] {
return new SWItem[]{
new SWItem(getter.get() < max ? Material.LIME_DYE : Material.GRAY_DYE, "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
if (clickType == ClickType.DOUBLE_CLICK) return;
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
@@ -130,8 +130,8 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
negativXItem.setEnchanted(tnt.getAlignment().getX() == -1);
inventory.setItem(12, negativXItem);
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
if(tnt.getAlignment().getX() != 1) tnt.alignX(1);
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
if (tnt.getAlignment().getX() != 1) tnt.alignX(1);
SimulatorWatcher.update(simulator);
});
positivXItem.setEnchanted(tnt.getAlignment().getX() == 1);
@@ -33,6 +33,7 @@ import java.util.*;
public class LaufbauSettings {
private static Map<Pair<Material, String>, List<BlockBoundingBox>> groupMap = new LinkedHashMap<>();
static {
BlockBoundingBox.elements.forEach(blockBoundingBox -> {
if (blockBoundingBox.getSwItem() == null) return;
@@ -115,12 +116,15 @@ public class LaufbauSettings {
} else {
long count = blockBoundingBoxes.stream().filter(bb -> LaufbauUtils.isDeactivated(p, bb)).count();
if (count == 0) {
return new SWItem(material, BauSystem.MESSAGE.parse(group, p), Arrays.asList("", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_ACTIVE", p), "", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_ADVANCED", p), BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_TOGGLE", p)), false, clickType -> {});
return new SWItem(material, BauSystem.MESSAGE.parse(group, p), Arrays.asList("", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_ACTIVE", p), "", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_ADVANCED", p), BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_TOGGLE", p)), false, clickType -> {
});
}
if (count == blockBoundingBoxes.size()) {
return new SWItem(material, BauSystem.MESSAGE.parse(group, p), Arrays.asList("", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_INACTIVE", p), "", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_ADVANCED", p), BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_TOGGLE", p)), false, clickType -> {});
return new SWItem(material, BauSystem.MESSAGE.parse(group, p), Arrays.asList("", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_INACTIVE", p), "", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_ADVANCED", p), BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_TOGGLE", p)), false, clickType -> {
});
}
return new SWItem(material, BauSystem.MESSAGE.parse(group, p), Arrays.asList("", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_MIXED", p, blockBoundingBoxes.size() - count, blockBoundingBoxes.size()), "", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_ADVANCED", p), BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_TOGGLE", p)), false, clickType -> {});
return new SWItem(material, BauSystem.MESSAGE.parse(group, p), Arrays.asList("", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_MIXED", p, blockBoundingBoxes.size() - count, blockBoundingBoxes.size()), "", BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_ADVANCED", p), BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_TOGGLE", p)), false, clickType -> {
});
}
}
@@ -56,7 +56,7 @@ public class CandleBoundingBox implements BoundingBoxLoader {
Candle candle = (Candle) Material.CYAN_CANDLE.createBlockData();
candle.setCandles(1);
List<Cuboid> cuboidList = new ArrayList<>();
cuboidList.add(pixelCuboid(7, 0,7, 2, 6, 2));
cuboidList.add(pixelCuboid(7, 0, 7, 2, 6, 2));
new BlockBoundingBox(candle, cuboidList, createItem("LAUFBAU_BLOCK_CANDLE", Material.CYAN_CANDLE, "LAUFBAU_COUNT_1"));
}
}
@@ -87,8 +87,9 @@ public class ProcessingTracesState implements LaufbauState {
TNTPoint current = TNTPoints.remove(0);
if (FlatteningWrapper.impl.inWater(world, current.getLocation().toVector())) return;
if (!(inRegion(current.getLocation().toVector(), 1) || (current.getPrevious().isPresent() && inRegion(current.getPrevious().get().getLocation().toVector(), 1))))
if (!(inRegion(current.getLocation().toVector(), 1) || (current.getPrevious().isPresent() && inRegion(current.getPrevious().get().getLocation().toVector(), 1)))) {
return;
}
Location location = current.getLocation();
if (current.getPrevious().isPresent()) {
@@ -40,6 +40,7 @@ import java.util.*;
public class Panzern {
private static List<PanzernAlgorithm> panzernAlgorithmList = new ArrayList<>();
public static void add(PanzernAlgorithm panzernAlgorithm) {
panzernAlgorithmList.add(panzernAlgorithm);
}
@@ -121,7 +121,7 @@ public class PanzernCommand extends SWCommand {
if (!material.isBlock()) {
continue;
}
if (material.name().contains("STAIRS") || material.name().contains("SLAB") || material.name().contains("GLASS")) {
if (material.name().contains("STAIRS") || material.name().contains("SLAB") || material.name().contains("GLASS")) {
strings.add(material.name().toLowerCase());
}
}
@@ -86,7 +86,7 @@ public class SmartPlaceListener implements Listener {
public SmartPlaceListener() {
TinyProtocol.instance.addFilter(ServerboundUseItemOnPacket.class, (player, packet) -> {
if(!Permission.BUILD.hasPermission(player)) return packet;
if (!Permission.BUILD.hasPermission(player)) return packet;
if (!Config.getInstance().get(player).getPlainValueOrDefault("smartPlace", false)) return packet;
RayTraceResult rayTraceResult = player.rayTraceBlocks(6);
Block block = rayTraceResult != null ? rayTraceResult.getHitBlock() : null;
@@ -126,7 +126,7 @@ public class SmartPlaceListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return;
WAS_EXECUTED.add(event.getPlayer());
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
@@ -50,7 +50,7 @@ public class BlockCounter {
}
public String getMessage(Player player, int count, int tntCount, long tick, long lastTick) {
if(!Permission.BUILD.hasPermission(player)) return null;
if (!Permission.BUILD.hasPermission(player)) return null;
double countPerTNT = (double) count / tntCount;
double countPerTick = (double) count / Math.max((lastTick - tick), 1);
@@ -144,8 +144,9 @@ public class Trace {
entityServer = new REntityServer();
entityServer.addPlayer(player);
entityServer.setCallback((p, rEntity, entityAction) -> {
if (entityAction != REntityServer.EntityAction.INTERACT)
if (entityAction != REntityServer.EntityAction.INTERACT) {
return;
}
if (rEntity instanceof TraceEntity) {
((TraceEntity) rEntity).printIntoChat(p);
}
@@ -167,8 +168,9 @@ public class Trace {
REntityServer newEntityServer = new REntityServer();
newEntityServer.addPlayer(k);
newEntityServer.setCallback((p, rEntity, entityAction) -> {
if (entityAction != REntityServer.EntityAction.INTERACT)
if (entityAction != REntityServer.EntityAction.INTERACT) {
return;
}
if (rEntity instanceof TraceEntity) {
((TraceEntity) rEntity).printIntoChat(p);
}
@@ -46,12 +46,10 @@ public class TraceManager implements Listener {
}
public void init() {
if (!tracesFolder.exists())
tracesFolder.mkdir();
if (!tracesFolder.exists()) tracesFolder.mkdir();
File[] traceFiles = tracesFolder.listFiles();
if (traceFiles == null)
return;
if (traceFiles == null) return;
boolean hasMetaFiles = false;
for (File traceFile : traceFiles) {
@@ -152,7 +150,8 @@ public class TraceManager implements Listener {
.map(Map.Entry::getKey)
.findFirst()
.orElse(null);
if (traceId == null) throw new RuntimeException("Trace not found while trying to remove see (c978eb98-b0b2-4009-91d8-acfa34e2831a)");
if (traceId == null)
throw new RuntimeException("Trace not found while trying to remove see (c978eb98-b0b2-4009-91d8-acfa34e2831a)");
traces.remove(traceId);
trace.hide();
trace.getRecordsSaveFile().delete();
@@ -70,7 +70,9 @@ public class TraceEntity extends RFallingBlockEntity {
* @param player the player the message should be printed for
*/
public void printIntoChat(Player player) {
if (!Config.getInstance().get(player).getOrSetDefault(TNT_CLICK_DETAILS, new YAPIONValue<>(true)).asBoolean().orElse(true)) return;
if (!Config.getInstance().get(player).getOrSetDefault(TNT_CLICK_DETAILS, new YAPIONValue<>(true)).asBoolean().orElse(true)) {
return;
}
TNTPoint representative = records.get(0);
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_HEADER", player);
@@ -102,8 +102,7 @@ public abstract class ViewFlag {
}
}
if (!hasMicromotion)
toRemove.add(uniqueRecord);
if (!hasMicromotion) toRemove.add(uniqueRecord);
seen.add(uniqueRecord.getTntId());
}
@@ -126,7 +125,7 @@ public abstract class ViewFlag {
TNTPoint previous = prev.get();
Location delta = representative.getLocation().clone().subtract(previous.getLocation());
Vector previousVelocity = previous.isAfterFirstExplosion() ? previous.getVelocity() : delta.toVector().clone().divide(DRAG_FACTOR).subtract(GRAVATY);
Vector previousVelocity = previous.isAfterFirstExplosion() ? previous.getVelocity() : delta.toVector().clone().divide(DRAG_FACTOR).subtract(GRAVATY);
Location yLocation = previous.getLocation().clone().add(0, delta.getY(), 0);
if (yLocation.distanceSquared(representative.getLocation()) >= 1.0 / 256.0 && yLocation.distanceSquared(previous.getLocation()) >= 1.0 / 256.0) {
@@ -80,7 +80,7 @@ public class BindCommand extends SWCommand implements Listener {
try {
knownCommandsField = Bukkit.getServer().getClass().getDeclaredField("commandMap");
knownCommandsField.setAccessible(true);
commandMap = (CommandMap)knownCommandsField.get(Bukkit.getServer());
commandMap = (CommandMap) knownCommandsField.get(Bukkit.getServer());
} catch (IllegalAccessException | NoSuchFieldException var2) {
Bukkit.shutdown();
throw new SecurityException("Oh shit. Commands cannot be registered.", var2);
@@ -123,7 +123,7 @@ public class BindCommand extends SWCommand implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (!event.hasItem()) return;
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
ItemStack itemStack = event.getItem();
ItemMeta meta = itemStack.getItemMeta();
if (meta == null) {
@@ -28,33 +28,33 @@ import org.bukkit.entity.Player;
@Linked
public class GamemodeCommand extends SWCommand {
public GamemodeCommand() {
super("gamemode", "gm", "g");
}
public GamemodeCommand() {
super("gamemode", "gm", "g");
}
@Register(help = true)
public void help(final Player p, final String... args) {
BauSystem.MESSAGE.sendPrefixless("OTHER_GAMEMODE_UNKNOWN", p);
BauSystem.MESSAGE.sendPrefixless("OTHER_GAMEMODE_POSSIBLE", p);
}
@Register(help = true)
public void help(final Player p, final String... args) {
BauSystem.MESSAGE.sendPrefixless("OTHER_GAMEMODE_UNKNOWN", p);
BauSystem.MESSAGE.sendPrefixless("OTHER_GAMEMODE_POSSIBLE", p);
}
@Register
public void genericCommand(final Player p) {
@Register
public void genericCommand(final Player p) {
SWPlayer swPlayer = SWPlayer.of(p);
if (swPlayer.hasComponent(NoClipCommand.NoClipData.class)) {
swPlayer.removeComponent(NoClipCommand.NoClipData.class);
return;
}
if (p.getGameMode() == GameMode.CREATIVE) {
p.setGameMode(GameMode.SPECTATOR);
} else {
p.setGameMode(GameMode.CREATIVE);
}
}
if (p.getGameMode() == GameMode.CREATIVE) {
p.setGameMode(GameMode.SPECTATOR);
} else {
p.setGameMode(GameMode.CREATIVE);
}
}
@Register
public void gamemodeCommand(final Player p, final GameMode gameMode) {
@Register
public void gamemodeCommand(final Player p, final GameMode gameMode) {
SWPlayer.of(p).removeComponent(NoClipCommand.NoClipData.class);
p.setGameMode(gameMode);
}
p.setGameMode(gameMode);
}
}
@@ -104,6 +104,7 @@ public class MaterialCommand extends SWCommand implements Listener {
}
private static final Map<String, BiConsumer<SearchParameter, SearchType>> elements = new HashMap<>();
static {
elements.put("-transparent", (search, searchType) -> search.transparent = searchType);
elements.put("-solid", (search, searchType) -> search.solid = searchType);
@@ -121,7 +122,7 @@ public class MaterialCommand extends SWCommand implements Listener {
SearchParameter searchParameter = SWPlayer.of(p).getComponentOrDefault(SearchParameter.class, SearchParameter::new);
for (String s : searches) {
boolean has = false;
for (Map.Entry<String, BiConsumer<SearchParameter, SearchType>> element: elements.entrySet()) {
for (Map.Entry<String, BiConsumer<SearchParameter, SearchType>> element : elements.entrySet()) {
if (s.startsWith(element.getKey() + ":")) {
element.getValue().accept(searchParameter, SearchType.valueOf(s.substring(element.getKey().length() + 1).toUpperCase()));
has = true;
@@ -156,7 +156,7 @@ public class MaterialLazyInit {
} else if (string.startsWith(">=")) {
if (blastResistance < Double.parseDouble(string.substring(2))) return false;
} else if (string.startsWith("<=")) {
if (blastResistance > Double.parseDouble(string.substring(2)))return false;
if (blastResistance > Double.parseDouble(string.substring(2))) return false;
} else if (string.startsWith(">")) {
if (blastResistance <= Double.parseDouble(string.substring(1))) return false;
} else if (string.startsWith("<")) {
@@ -282,8 +282,9 @@ public class PistonCalculator implements Listener {
immovableBlocks.add(block.getLocation());
return;
}
if (facing != direction && (block.equals(origin) || block.getRelative(facing.getOppositeFace()).equals(origin)))
if (facing != direction && (block.equals(origin) || block.getRelative(facing.getOppositeFace()).equals(origin))) {
return;
}
if (!movedBlocks.contains(block.getLocation())) toCalc.add(block);
}
}
@@ -60,7 +60,9 @@ public class TNTClickListener extends SWCommand implements Listener {
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (event.getHand() != EquipmentSlot.HAND) return;
if (!Config.getInstance().get(event.getPlayer()).getOrSetDefault(TNT_CLICK_DETAILS, new YAPIONValue<>(true)).asBoolean().orElse(true)) return;
if (!Config.getInstance().get(event.getPlayer()).getOrSetDefault(TNT_CLICK_DETAILS, new YAPIONValue<>(true)).asBoolean().orElse(true)) {
return;
}
Entity entity = event.getRightClicked();
if (event.getRightClicked() instanceof TNTPrimed) {
@@ -41,7 +41,8 @@ public class GamemodeBauGuiItem extends BauGuiItem {
@Override
public ItemStack getItem(Player player) {
return new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("OTHER_ITEMS_GAMEMODE_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("OTHER_ITEMS_GAMEMODE_LORE_1", player), BauSystem.MESSAGE.parse("OTHER_ITEMS_GAMEMODE_LORE_2", player)), false, clickType -> {}).getItemStack();
return new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("OTHER_ITEMS_GAMEMODE_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("OTHER_ITEMS_GAMEMODE_LORE_1", player), BauSystem.MESSAGE.parse("OTHER_ITEMS_GAMEMODE_LORE_2", player)), false, clickType -> {
}).getItemStack();
}
@Override
@@ -46,7 +46,8 @@ public class KillAllBauGuiItem extends BauGuiItem {
@Override
public ItemStack getItem(Player player) {
return new SWItem(Material.LAVA_BUCKET, BauSystem.MESSAGE.parse("OTHER_ITEMS_KILLALL_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("OTHER_ITEMS_KILLALL_LORE_1", player), BauSystem.MESSAGE.parse("OTHER_ITEMS_KILLALL_LORE_2", player)), false, clickType -> {}).getItemStack();
return new SWItem(Material.LAVA_BUCKET, BauSystem.MESSAGE.parse("OTHER_ITEMS_KILLALL_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("OTHER_ITEMS_KILLALL_LORE_1", player), BauSystem.MESSAGE.parse("OTHER_ITEMS_KILLALL_LORE_2", player)), false, clickType -> {
}).getItemStack();
}
@Override
@@ -38,16 +38,19 @@ public class NavWandBauGuiItem extends BauGuiItem {
super(27);
}
@Override public Permission permission() {
@Override
public Permission permission() {
return Permission.MEMBER;
}
@Override public ItemStack getItem(Player player) {
@Override
public ItemStack getItem(Player player) {
return new SWItem(Material.COMPASS, BauSystem.MESSAGE.parse("NAVIGATION_WAND", player), Arrays.asList(BauSystem.MESSAGE.parse("NAVIGATION_WAND_LEFT_CLICK", player), BauSystem.MESSAGE.parse("NAVIGATION_WAND_RIGHT_CLICK", player)), false, clickType -> {
}).getItemStack();
}
@Override public boolean click(ClickType click, Player p) {
@Override
public boolean click(ClickType click, Player p) {
p.performCommand("/wand -n");
p.closeInventory();
return false;
@@ -45,7 +45,7 @@ public class SkullBauGuiItem extends BauGuiItem {
@Override
public boolean click(ClickType click, Player p) {
p.closeInventory();
SWAnvilInv inv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("ANVIL_INV_NAME",p));
SWAnvilInv inv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("ANVIL_INV_NAME", p));
inv.setItem(Material.NAME_TAG);
inv.setCallback(s -> p.performCommand("skull " + s));
inv.open();
@@ -41,34 +41,37 @@ public class AFKStopperListener implements Listener {
public AFKStopperListener() {
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
long currentTime = System.currentTimeMillis();
if(currentTime - lastMovementTime > 10*60000) { // 10 Minutes
for (Player p : Bukkit.getOnlinePlayers())
if (currentTime - lastMovementTime > 10 * 60000) { // 10 Minutes
for (Player p : Bukkit.getOnlinePlayers()) {
p.kickPlayer(BauSystem.MESSAGE.parse("AFK_KICK_MESSAGE", p));
} else if(currentTime - lastMovementTime > 9*60000)
}
} else if (currentTime - lastMovementTime > 9 * 60000) {
BauSystem.MESSAGE.broadcast("AFK_WARNING_MESSAGE");
}
}, 1200, 1200); //every minute
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Location to = event.getTo();
if (to == null)
return;
if (to == null) return;
Location from = event.getFrom();
if (from.getPitch() != to.getPitch() || from.getYaw() != to.getYaw())
lastMovementTime = System.currentTimeMillis();
}
@EventHandler(priority = EventPriority.LOWEST) //Potential fix for potential race condition with WE axe spontaneously not working
@EventHandler(priority = EventPriority.LOWEST)
//Potential fix for potential race condition with WE axe spontaneously not working
public void onPlayerJoin(PlayerJoinEvent event) {
event.getPlayer().setOp(true);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) {
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer())))
if (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer()))) {
CheckpointUtils.freeze();
}
}
@EventHandler
@@ -63,7 +63,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
if (!SPECTATORS.contains(player)) {
SPECTATORS.add(player);
newSpectator.add(player);
player.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false));
player.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false, false, false));
showSpectatorNotice(player);
}
} else {
@@ -82,7 +82,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
public void onPlayerJoin(PlayerJoinEvent event) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) {
SPECTATORS.add(event.getPlayer());
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false));
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false, false, false));
showSpectatorNotice(event.getPlayer());
} else {
event.getPlayer().removePotionEffect(PotionEffectType.GLOWING);
@@ -123,7 +123,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
public void onPlayerItemConsume(PlayerItemConsumeEvent event) {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
if (SPECTATORS.contains(event.getPlayer())) {
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false));
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false, false, false));
}
}, 1);
}
@@ -42,7 +42,7 @@ public class ItemFrameListener implements Listener {
return;
}
if(!Permission.BUILD.hasPermission((Player) event.getDamager())) return;
if (!Permission.BUILD.hasPermission((Player) event.getDamager())) return;
event.setCancelled(true);
ItemFrame itemFrame = (ItemFrame) event.getEntity();
@@ -39,7 +39,7 @@ public class KickallCommand extends SWCommand {
@Register(description = "KICKALL_HELP")
public void genericCommand(Player player) {
if(!Permission.OWNER.hasPermission(player)) return;
if (!Permission.OWNER.hasPermission(player)) return;
Bukkit.getOnlinePlayers().forEach(p -> {
if (!bauServer.getOwner().equals(p.getUniqueId())) p.kickPlayer("");
@@ -105,8 +105,9 @@ public class SignEdit implements Listener {
Bukkit.getScheduler().runTask(BauSystem.getInstance(), () -> {
ServerLevel serverLevel = ((CraftWorld) player.getWorld()).getHandle();
Block signLoc = CraftBlock.at(serverLevel, o.getPos());
if (!signLoc.getType().name().contains("SIGN"))
if (!signLoc.getType().name().contains("SIGN")) {
return;
}
String[] lines = o.getLines();
Sign sign = ((Sign) signLoc.getState());
@@ -32,8 +32,7 @@ public class SignListener implements Listener {
public void onSignChange(SignChangeEvent event) {
for (int i = 0; i <= 3; ++i) {
String line = event.getLine(i);
if (line == null)
continue;
if (line == null) continue;
line = ChatColor.translateAlternateColorCodes('&', line);
event.setLine(i, line);
}
@@ -43,7 +43,7 @@ public class WorldEditSelectionSaver implements Listener {
private File WORLD_EDIT_SELECTIONS = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "world_edit_selections");
{
WORLD_EDIT_SELECTIONS.mkdir();
WORLD_EDIT_SELECTIONS.mkdir();
}
@EventHandler
@@ -51,6 +51,7 @@ public class ColorReplaceCommand extends SWCommand {
}
private Set<String> types = new HashSet<>();
{
WorldEditListener.addOtherCommand("//colorreplace");
WorldEditListener.addOtherCommand("//cr");
@@ -34,49 +34,49 @@ import org.bukkit.entity.Player;
@AllArgsConstructor
public class Point {
public static final Point ZERO = new Point(0, 0, 0);
public static final Point ZERO = new Point(0, 0, 0);
private final int x;
private final int y;
private final int z;
private final int x;
private final int y;
private final int z;
public static Point fromLocation(final Location location) {
return new Point(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
public static Point fromLocation(final Location location) {
return new Point(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
public static Point fromBlockVector3(final BlockVector3 blockVector3) {
return new Point(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ());
}
public static Point fromBlockVector3(final BlockVector3 blockVector3) {
return new Point(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ());
}
public Point add(int x, int y, int z) {
return new Point(this.x + x, this.y + y, this.z + z);
}
public Point add(int x, int y, int z) {
return new Point(this.x + x, this.y + y, this.z + z);
}
public Point subtract(int x, int y, int z) {
return new Point(this.x - x, this.y - y, this.z - z);
}
public Point subtract(int x, int y, int z) {
return new Point(this.x - x, this.y - y, this.z - z);
}
public Point divide(int factor) {
return new Point(x / factor, y / factor, z / factor);
}
public Point divide(int factor) {
return new Point(x / factor, y / factor, z / factor);
}
public Location toLocation(World world) {
return new Location(world, x, y, z);
}
public Location toLocation(World world) {
return new Location(world, x, y, z);
}
public Location toLocation(World world, double dx, double dy, double dz) {
return new Location(world, x + dx, y + dy, z + dz);
}
public Location toLocation(World world, double dx, double dy, double dz) {
return new Location(world, x + dx, y + dy, z + dz);
}
public Location toLocation(Player player) {
return new Location(player.getWorld(), x, y, z, player.getLocation().getYaw(), player.getLocation().getPitch());
}
public Location toLocation(Player player) {
return new Location(player.getWorld(), x, y, z, player.getLocation().getYaw(), player.getLocation().getPitch());
}
public Location toLocation(Player player, double dx, double dy, double dz) {
return new Location(player.getWorld(), x + dx, y + dy, z + dz, player.getLocation().getYaw(), player.getLocation().getPitch());
}
public Location toLocation(Player player, double dx, double dy, double dz) {
return new Location(player.getWorld(), x + dx, y + dy, z + dz, player.getLocation().getYaw(), player.getLocation().getPitch());
}
public BlockVector3 toBlockVector3() {
return BlockVector3.at(this.x, this.y, this.z);
}
public BlockVector3 toBlockVector3() {
return BlockVector3.at(this.x, this.y, this.z);
}
}
@@ -29,32 +29,32 @@ import lombok.Getter;
@AllArgsConstructor
public enum ChangedMode implements Flag.Value<ChangedMode> {
NO_CHANGE("FLAG_CHANGED_NO_CHANGE", false),
HAS_CHANGE("FLAG_CHANGED_HAS_CHANGE", true);
NO_CHANGE("FLAG_CHANGED_NO_CHANGE", false),
HAS_CHANGE("FLAG_CHANGED_HAS_CHANGE", true);
private static ChangedMode[] values;
private final String chatValue;
private final Boolean changed;
private static ChangedMode[] values;
private final String chatValue;
private final Boolean changed;
@Override
public ChangedMode[] getValues() {
if (ChangedMode.values == null) {
ChangedMode.values = ChangedMode.values();
}
return ChangedMode.values;
}
@Override
public ChangedMode[] getValues() {
if (ChangedMode.values == null) {
ChangedMode.values = ChangedMode.values();
}
return ChangedMode.values;
}
@Override
public ChangedMode getValue() {
return this;
}
@Override
public ChangedMode getValue() {
return this;
}
@Override
public ChangedMode getValueOf(final String name) {
try {
return ChangedMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
return NO_CHANGE;
}
}
@Override
public ChangedMode getValueOf(final String name) {
try {
return ChangedMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
return NO_CHANGE;
}
}
}
@@ -29,34 +29,34 @@ import lombok.Getter;
@AllArgsConstructor
public enum FireMode implements Flag.Value<FireMode> {
ALLOW("FLAG_FIRE_ALLOW"),
DENY("FLAG_FIRE_DENY");
ALLOW("FLAG_FIRE_ALLOW"),
DENY("FLAG_FIRE_DENY");
private static FireMode[] values;
private final String chatValue;
private static FireMode[] values;
private final String chatValue;
@Override
public FireMode[] getValues() {
if (FireMode.values == null) {
FireMode.values = FireMode.values();
}
return FireMode.values;
}
@Override
public FireMode[] getValues() {
if (FireMode.values == null) {
FireMode.values = FireMode.values();
}
return FireMode.values;
}
@Override
public FireMode getValue() {
return this;
}
@Override
public FireMode getValue() {
return this;
}
@Override
public FireMode getValueOf(final String name) {
try {
return FireMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
if (name.equalsIgnoreCase("false")) {
return FireMode.DENY;
}
return FireMode.ALLOW;
}
}
@Override
public FireMode getValueOf(final String name) {
try {
return FireMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
if (name.equalsIgnoreCase("false")) {
return FireMode.DENY;
}
return FireMode.ALLOW;
}
}
}
@@ -30,34 +30,34 @@ import lombok.Getter;
@AllArgsConstructor
public enum FreezeMode implements Flag.Value<FreezeMode> {
ACTIVE("FLAG_FREEZE_ACTIVE"),
INACTIVE("FLAG_FREEZE_INACTIVE");
ACTIVE("FLAG_FREEZE_ACTIVE"),
INACTIVE("FLAG_FREEZE_INACTIVE");
private static FreezeMode[] values;
private final String chatValue;
private static FreezeMode[] values;
private final String chatValue;
@Override
public FreezeMode[] getValues() {
if (FreezeMode.values == null) {
FreezeMode.values = FreezeMode.values();
}
return FreezeMode.values;
}
@Override
public FreezeMode[] getValues() {
if (FreezeMode.values == null) {
FreezeMode.values = FreezeMode.values();
}
return FreezeMode.values;
}
@Override
public FreezeMode getValue() {
return this;
}
@Override
public FreezeMode getValue() {
return this;
}
@Override
public FreezeMode getValueOf(final String name) {
try {
return FreezeMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
if (name.equalsIgnoreCase("false")) {
return FreezeMode.INACTIVE;
}
return FreezeMode.INACTIVE;
}
}
@Override
public FreezeMode getValueOf(final String name) {
try {
return FreezeMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
if (name.equalsIgnoreCase("false")) {
return FreezeMode.INACTIVE;
}
return FreezeMode.INACTIVE;
}
}
}
@@ -29,32 +29,32 @@ import lombok.Getter;
@AllArgsConstructor
public enum TNTMode implements Flag.Value<TNTMode> {
ALLOW("FLAG_TNT_ALLOW"),
DENY("FLAG_TNT_DENY"),
ONLY_TB("FLAG_TNT_ONLY_TB");
ALLOW("FLAG_TNT_ALLOW"),
DENY("FLAG_TNT_DENY"),
ONLY_TB("FLAG_TNT_ONLY_TB");
private static TNTMode[] values;
private final String chatValue;
private static TNTMode[] values;
private final String chatValue;
@Override
public TNTMode[] getValues() {
if (TNTMode.values == null) {
TNTMode.values = TNTMode.values();
}
return TNTMode.values;
}
@Override
public TNTMode[] getValues() {
if (TNTMode.values == null) {
TNTMode.values = TNTMode.values();
}
return TNTMode.values;
}
@Override
public TNTMode getValue() {
return this;
}
@Override
public TNTMode getValue() {
return this;
}
@Override
public TNTMode getValueOf(final String name) {
try {
return TNTMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
return TNTMode.ALLOW;
}
}
@Override
public TNTMode getValueOf(final String name) {
try {
return TNTMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
return TNTMode.ALLOW;
}
}
}
@@ -29,33 +29,33 @@ import lombok.Getter;
@AllArgsConstructor
public enum TestblockMode implements Flag.Value<TestblockMode> {
NO_VALUE("FLAG_TESTBLOCK_NO_VALUE", false),
NORTH("FLAG_TESTBLOCK_NORTH", true),
SOUTH("FLAG_TESTBLOCK_SOUTH", false);
NO_VALUE("FLAG_TESTBLOCK_NO_VALUE", false),
NORTH("FLAG_TESTBLOCK_NORTH", true),
SOUTH("FLAG_TESTBLOCK_SOUTH", false);
private static TestblockMode[] values;
private final String chatValue;
private final boolean north;
private static TestblockMode[] values;
private final String chatValue;
private final boolean north;
@Override
public TestblockMode[] getValues() {
if (TestblockMode.values == null) {
TestblockMode.values = TestblockMode.values();
}
return TestblockMode.values;
}
@Override
public TestblockMode[] getValues() {
if (TestblockMode.values == null) {
TestblockMode.values = TestblockMode.values();
}
return TestblockMode.values;
}
@Override
public TestblockMode getValue() {
return this;
}
@Override
public TestblockMode getValue() {
return this;
}
@Override
public TestblockMode getValueOf(final String name) {
try {
return TestblockMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
return NO_VALUE;
}
}
@Override
public TestblockMode getValueOf(final String name) {
try {
return TestblockMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
return NO_VALUE;
}
}
}
@@ -27,30 +27,30 @@ import lombok.Getter;
@EqualsAndHashCode
public class Pair<K, V> {
private K key;
private K key;
private V value;
private V value;
public Pair(final K key, final V value) {
this.key = key;
this.value = value;
}
public Pair(final K key, final V value) {
this.key = key;
this.value = value;
}
public K setKey(final K key) {
final K currentKey = this.key;
this.key = key;
return currentKey;
}
public K setKey(final K key) {
final K currentKey = this.key;
this.key = key;
return currentKey;
}
public V setValue(final V value) {
final V currentValue = this.value;
this.value = value;
return currentValue;
}
public V setValue(final V value) {
final V currentValue = this.value;
this.value = value;
return currentValue;
}
@Override
public String toString() {
return this.key + "=" + this.value;
}
@Override
public String toString() {
return this.key + "=" + this.value;
}
}
@@ -218,12 +218,10 @@ public class FlatteningWrapper {
public boolean inWater(org.bukkit.World world, Vector tntPosition) {
Block block = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ());
if (block.getType() == Material.WATER)
return true;
if (block.getType() == Material.WATER) return true;
BlockData data = block.getBlockData();
if (!(data instanceof Waterlogged))
return false;
if (!(data instanceof Waterlogged)) return false;
return ((Waterlogged) data).isWaterlogged();
}
@@ -48,8 +48,10 @@ public class RayTraceUtils {
REntity nearestHitEntity = null;
RRayTraceResult nearestHitResult = null;
double nearestDistanceSq = Double.MAX_VALUE;
for (REntity entity: entityList) {
if (!isOccluded(startPos.toVector(), direction, new Vector(entity.getX(), entity.getY() + 0.5, entity.getZ()))) continue;
for (REntity entity : entityList) {
if (!isOccluded(startPos.toVector(), direction, new Vector(entity.getX(), entity.getY() + 0.5, entity.getZ()))) {
continue;
}
double distanceSq = new Vector(entity.getX(), entity.getY() + 0.5, entity.getZ()).distanceSquared(startPos.toVector());
if (distanceSq > 100.0) continue;
if (distanceSq < nearestDistanceSq) {
@@ -24,6 +24,7 @@ import org.bukkit.entity.Player;
public interface ScoreboardElement {
ScoreboardGroup getGroup();
int order();
String get(Region region, Player p);
@@ -27,22 +27,29 @@ import org.bukkit.boss.BarStyle;
public interface BauSystemBossbar {
String getTitle();
void setTitle(String title);
double getProgress();
void setProgress(double progress);
BarColor getColor();
void setColor(BarColor color);
BarStyle getStyle();
void setStyle(BarStyle style);
boolean hasFlag(BarFlag flag);
void addFlag(BarFlag flag);
void removeFlag(BarFlag flag);
boolean isVisible();
void setVisible(boolean visible);
Region getRegion();
@@ -69,7 +69,7 @@ public class SimulatorData {
strings.remove("");
return strings;
}
public void saveSimulator(Player player, String name) {
YAPIONObject yapionObject = getSimulator(player);
yapionObject.put(name, yapionObject.getArray("").copy());
@@ -81,7 +81,7 @@ public class SimulatorData {
yapionObject.put("", simulator);
internalSaveSimulator(player, yapionObject);
}
public void loadSimulator(Player player, String name) {
YAPIONObject yapionObject = getSimulator(player);
yapionObject.put("", yapionObject.getArray(name).copy());