Merge pull request 'Format code' (#370) from Format into main

Reviewed-on: SteamWar/SteamWar#370
Reviewed-by: Chaoscaot <max@chaoscaot.de>
This commit is contained in:
2026-05-17 10:59:30 +02:00
574 changed files with 11473 additions and 10504 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
name: Feature Idee
about: Du hast eine Idee für ein neues Feature, welches SteamWar nicht hat? Stelle sie hier vor.
labels: ["typ/idee"]
labels: [ "typ/idee" ]
body:
- type: textarea
id: description
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -76,13 +76,21 @@ public class AttributesCopyCommand extends SWCommand {
if (itemStack.getType() == Material.ZOMBIE_HEAD && block.getType() == Material.ZOMBIE_WALL_HEAD) return true;
if (itemStack.getType() == Material.CREEPER_HEAD && block.getType() == Material.CREEPER_WALL_HEAD) return true;
if (itemStack.getType() == Material.DRAGON_HEAD && block.getType() == Material.DRAGON_WALL_HEAD) return true;
if (itemStack.getType() == Material.SKELETON_SKULL && block.getType() == Material.SKELETON_WALL_SKULL) return true;
if (itemStack.getType() == Material.WITHER_SKELETON_SKULL && block.getType() == Material.WITHER_SKELETON_WALL_SKULL) return true;
if (itemStack.getType() == Material.SKELETON_SKULL && block.getType() == Material.SKELETON_WALL_SKULL) {
return true;
}
if (itemStack.getType() == Material.WITHER_SKELETON_SKULL && block.getType() == Material.WITHER_SKELETON_WALL_SKULL) {
return true;
}
if (itemStack.getType() == Material.TORCH && block.getType() == Material.WALL_TORCH) return true;
if (itemStack.getType() == Material.SOUL_TORCH && block.getType() == Material.SOUL_WALL_TORCH) return true;
if (itemStack.getType() == Material.REDSTONE_TORCH && block.getType() == Material.REDSTONE_WALL_TORCH) return true;
if (itemStack.getType() == Material.REDSTONE_TORCH && block.getType() == Material.REDSTONE_WALL_TORCH) {
return true;
}
if (itemStack.getType() == Material.WHEAT_SEEDS && block.getType() == Material.WHEAT) return true;
if (itemStack.getType().name().contains("_BANNER") && block.getType().name().contains("_WALL_BANNER")) return true;
if (itemStack.getType().name().contains("_BANNER") && block.getType().name().contains("_WALL_BANNER")) {
return true;
}
return false;
}
}
@@ -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();
@@ -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]);
@@ -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,10 @@ 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 +201,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 +215,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 +224,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 +241,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();
@@ -184,8 +183,7 @@ public class Loadtimer implements Listener {
long ignTime = ignite - activate;
long explTime = explode - ignTime - activate;
if (explTime < 0)
explTime = loadTime;
if (explTime < 0) explTime = loadTime;
int finalAllTnt = allTnt;
long finalExplTime = explTime;
@@ -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());
}
}
}
@@ -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,9 @@ 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,38 @@ 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())
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();
+85 -45
View File
@@ -2,67 +2,75 @@
---
<!-- TOC -->
* [SteamWar.de - Script System](#steamwarde---script-system)
* [Einleitung](#einleitung)
* [Nutzung mit einer IDE](#nutzung-mit-einer-ide)
* [Einleitung](#einleitung)
* [Nutzung mit einer IDE](#nutzung-mit-einer-ide)
* [Basis-Apis](#basis-apis)
* [SteamWar.de-Api](#steamwarde-api)
* [player](#player)
* [random](#random)
* [region](#region)
* [tnt](#tnt)
* [trace](#trace)
* [server](#server)
* [tps](#tps)
* [storage](#storage)
* [inventory](#inventory)
* [tnt](#tnt)
* [trace](#trace)
* [server](#server)
* [tps](#tps)
* [storage](#storage)
* [inventory](#inventory)
* [SteamWar.de-Global-Api](#steamwarde-global-api)
* [Commands](#commands)
* [Hotkeys](#hotkeys)
* [Eventtypen](#eventtypen)
* [BlockEvent](#blockevent)
* [InteractEvent](#interactevent)
* [Position](#position)
* [Commands](#commands)
* [Hotkeys](#hotkeys)
* [Eventtypen](#eventtypen)
* [BlockEvent](#blockevent)
* [InteractEvent](#interactevent)
* [Position](#position)
* [Instabile APIs](#instabile-apis)
* [_worldedit](#worldedit)
* [_worldedit](#worldedit)
* [Beispiele](#beispiele)
* [Hello, World!](#hello-world)
* [Code](#code)
* [Ausgabe](#ausgabe)
* [BauGUI on DoubleSwap](#baugui-on-doubleswap)
* [Code](#code-1)
* [SL Command](#sl-command)
* [Code](#code-2)
* [Paste Hotkey](#paste-hotkey)
* [Code](#code-3)
* [Inventory](#inventory-1)
* [Code](#code-4)
* [Hello, World!](#hello-world)
* [Code](#code)
* [Ausgabe](#ausgabe)
* [BauGUI on DoubleSwap](#baugui-on-doubleswap)
* [Code](#code-1)
* [SL Command](#sl-command)
* [Code](#code-2)
* [Paste Hotkey](#paste-hotkey)
* [Code](#code-3)
* [Inventory](#inventory-1)
* [Code](#code-4)
<!-- TOC -->
## Einleitung
Das Script System auf SteamWar.de basiert auf [Lua](https://www.lua.org/docs.html).
Der Code wird einfach in ein Minecraft Buch geschrieben und kann mit einem Links-Klick ausgeführt werden.
## Nutzung mit einer IDE
Im Repository liegen [Lua-Definitionen](sw.def.lua) für [Luanalysis](https://plugins.jetbrains.com/plugin/14698-luanalysis).
Im Repository liegen [Lua-Definitionen](sw.def.lua)
für [Luanalysis](https://plugins.jetbrains.com/plugin/14698-luanalysis).
Diese können in der IDE genutzt werden, um die APIs zu nutzen.
Einfach die `sw.def.lua` in denselben Ordner wie das Script legen und die IDE sollte die APIs erkennen.
# Basis-Apis
Es werden folgende Standard-Apis zur Verfügung gestellt:
- [`math`](https://www.lua.org/manual/5.4/manual.html#6.7)
- [`string`](https://www.lua.org/manual/5.4/manual.html#6.4)
- [`table`](https://www.lua.org/manual/5.4/manual.html#6.6)
- [`bit32`](https://www.lua.org/manual/5.2/manual.html#6.7)
# SteamWar.de-Api
APIs, die mit einem `_` beginnen sind noch nicht stabil und können sich jederzeit ändern.
Sie sollten daher nicht verwendet werden, da sie sich noch in der Entwicklung befinden.
Diese können auch undokumentierte Funktionen enthalten, die nicht in der Dokumentation aufgeführt sind.
In den Scripten gibt es dazu noch folgende globale Variablen:
- [`player`](#player)
- [`random`](#random)
- [`region`](#region)
@@ -84,6 +92,7 @@ Ohne eine Kategorie sind folgende Funktionen verfügbar, die nicht allgemein sin
| `join` | length(String, String...): String | Füge die Texte mit den ersten Parameter zusammen |
### player
Das `player`-Modul stellt Funktionen zur Verfügung, die den Spieler betreffen.
Es gibt folgende Funktionen:
@@ -105,6 +114,7 @@ Es gibt folgende Funktionen:
| `closeInventory` | closeInventory() | Schließe das aktuell geöffnete Inventar des Spielers |
### random
Das `random`-Modul stellt Funktionen zur Verfügung, die Zufallszahlen betreffen.
Es gibt folgende Funktionen:
@@ -119,6 +129,7 @@ Es gibt folgende Funktionen:
| nextBool | nextBool(): Boolean | Gibt true oder false zurück |
### region
Das `region`-Modul stellt Funktion zur Verfügung, die die Region des Spielers betreffen.
Es gibt folgende Funktionen:
@@ -141,6 +152,7 @@ Es gibt folgende weitere Module:
| `trace` | [trace](#trace) |
#### tnt
Das `tnt`-Modul stellt Funktionen zur Verfügung, die den TNT-Modus in der Region des Spielers betreffen.
Es gibt folgende Funktionen:
@@ -151,8 +163,8 @@ Es gibt folgende Funktionen:
| `onlyTb` | onlyTb(): Boolean | Gibt zurück, ob der TNT-Modus auf Only-Tb ist |
| `onlyBuild` | onlyBuild(): Boolean | Gibt zurück, ob der TNT-Modus auf Only-Build ist |
#### trace
Das `trace`-Modul stellt Funktionen zur Verfügung, die den Status des Tracers der Region betreffen.
Es gibt folgende Funktionen:
@@ -164,6 +176,7 @@ Es gibt folgende Funktionen:
| `time` | time(): String | Gibt die Zeit des Tracers zurück |
## server
Das `server`-Modul stellt Funktionen zur Verfügung, die den Server betreffen.
Es gibt folgende Funktionen:
@@ -181,6 +194,7 @@ Es gibt folgende weitere Module:
| `tps` | [tps](#tps) |
#### tps
Das `tps`-Modul stellt Funktionen zur Verfügung, die die TPS des Servers betreffen.
Es gibt folgende Funktionen:
@@ -195,6 +209,7 @@ Es gibt folgende Funktionen:
| `limit` | limit(): Number | Gibt das TPS-Limit zurück |
## storage
Das `storage`-Modul stellt Funktionen zur Verfügung, mit welchen man Werte speichern kann.
Es gibt folgende Module:
@@ -217,6 +232,7 @@ Alle Module haben folgende Funktionen:
Ein Accessor ist ein Objekt, womit du direkt auf einen Wert zugreifen kannst und es ändern kannst.
Es geht wie folgt:
```lua
keyAccessor = storage.player.accessor("key")
@@ -225,12 +241,13 @@ print(keyAccessor()) -- Gibt den Wert zurück
```
## inventory
Das `inventory`-Modul stellt Funktionen zur Verfügung, um ein Inventar zu öffnen.
Es gibt folgende Funktionen:
| Name | Signature | Beschreibung |
|----------|-----------------------------------|-------------------------------------------------------------------|
| `create` | create(String, Number): Inventory | Erstellt ein Inventar mit dem Title und der Anzahl an Zeilen |
| Name | Signature | Beschreibung |
|----------|-----------------------------------|--------------------------------------------------------------|
| `create` | create(String, Number): Inventory | Erstellt ein Inventar mit dem Title und der Anzahl an Zeilen |
Das `Inventory`-Objekt hat folgende Funktionen:
@@ -256,6 +273,7 @@ Wenn eine Barrier statt des richtigen Items angezeigt wird, dann ist das angegeb
```
# SteamWar.de-Global-Api
Mit `/script` kann man Script-Bücher global abspeichern. Diese haben dann zugrif auf die `global`-Api.
Die `global`-Api stellt Funktionen zur Verfügung um auf Events, Commands und Hotkeys mit einem Script zu reagieren.
@@ -274,20 +292,28 @@ Es gibt folgende Variablen:
| `events` | Siehe: [Event Type](#eventtypen) |
## Commands
Der Command Handler kriegt eine Liste aller angegeben argumenten. Die Argumente sind vom Typ `String`. Mit dem Wert gespeichert unter `args.alias` oder `args["alias"]` erhältst du, welcher command eingegeben wurde. Wenn ein handler für mehrere Befehle registriert wurde kannst du es hiermit erkennen.
Du kannst `args.hasShortFlag(String)` um herauszufinden ob eine Flag angegeben wurde wie zum Beispiel `-f`. Mit `args.removeShortFlag(String)` kannst du die Flag entfernen und erhältst ob sie angegeben wurde.
Der Command Handler kriegt eine Liste aller angegeben argumenten. Die Argumente sind vom Typ `String`. Mit dem Wert
gespeichert unter `args.alias` oder `args["alias"]` erhältst du, welcher command eingegeben wurde. Wenn ein handler für
mehrere Befehle registriert wurde kannst du es hiermit erkennen.
Du kannst `args.hasShortFlag(String)` um herauszufinden ob eine Flag angegeben wurde wie zum Beispiel `-f`. Mit
`args.removeShortFlag(String)` kannst du die Flag entfernen und erhältst ob sie angegeben wurde.
## Hotkeys
Hotkeys werden im folgenden Format angegeben: `MODIFIER+KEY`. Bei den Hotkey erstellung ist die Großschreibung egal. Es gibt folgende Modifier:
Hotkeys werden im folgenden Format angegeben: `MODIFIER+KEY`. Bei den Hotkey erstellung ist die Großschreibung egal. Es
gibt folgende Modifier:
- `ctrl`
- `shift`
- `alt`
- `meta`
Es können auch mehrere Modifier angegeben werden, z.B. `ctrl+shift+alt+c`. Die Reihenfolge der Modifier und des Keys ist egal.
Es können auch mehrere Modifier angegeben werden, z.B. `ctrl+shift+alt+c`. Die Reihenfolge der Modifier und des Keys ist
egal.
## Eventtypen
Einige Events sind auch abbrechbar, dazu muss die Funktion `setCancelled()` aufgerufen werden.
| Name | Wenn | Parameter | Abbrechbar |
@@ -306,6 +332,7 @@ Einige Events sind auch abbrechbar, dazu muss die Funktion `setCancelled()` aufg
| `EntityDeath` | Wenn ein Entity stirbt | (type: Entity Type) | false |
### BlockEvent
Das übergebene Objekt an den Handler hat folgende Variablen:
| Name | Beschreibung |
@@ -316,6 +343,7 @@ Das übergebene Objekt an den Handler hat folgende Variablen:
| `type` | Das Material des Blocks |
### InteractEvent
Das übergebene Objekt an den Handler hat folgende Variablen:
| Name | Beschreibung |
@@ -334,8 +362,8 @@ Wenn `hasBlock` wahr ist, gibt es folgende Variablen:
| `blockZ` | Die Z-Koordinate des Blocks |
| `blockFace` | Die Seite des Blocks die geklickt wurde |
### Position
Die Position ist ein Objekt mit folgenden Variablen:
| Name | Beschreibung |
@@ -345,6 +373,7 @@ Die Position ist ein Objekt mit folgenden Variablen:
| `z` | Die Z-Koordinate |
# Instabile APIs
Hier sind einige APIs aufgelistet, die nicht stabil sind und sich jederzeit ändern können.
## _worldedit
@@ -353,67 +382,78 @@ Hier sind einige APIs aufgelistet, die nicht stabil sind und sich jederzeit änd
|-------------|-----------------------------------------------------------|-----------------------------------|
| `selection` | selection(Liste\<Pos>), selection(): {min: Pos, max: Pos} | Die aktuelle auswahl des Spielers |
# Beispiele
## Hello, World!
Ein einfaches Hello, World!-Script.
#### Code
```lua
print("Hello, World!")
```
#### Ausgabe
```
Hello, World!
```
## BauGUI on DoubleSwap
Das Standardskript für das Öffnen des BauGUIs
#### Code
```lua
function handler(event)
exec("gui")
exec("gui")
end
event(events.DoubleSwap, handler)
```
## SL Command
Ein einfacher Command Redefiner.
#### Code
```lua
function handler(args)
exec("stoplag")
exec("stoplag")
end
command("sl", handler)
```
## Paste Hotkey
Ein Hotkey zum Pasten des Clipboard-Inhalts.
#### Code
```lua
function handler(pressed)
if pressed then
exec("/paste -o")
end
if pressed then
exec("/paste -o")
end
end
hotkey("ctrl+v", handler)
```
## Inventory
Ein Beispiel für ein Inventar.
#### Code
```lua
inv = inventory.create("Test Inv", 3)
inv.item(13, "STONE", "Ich bin ein Stein", function(e) player.chat(e) end, {"Die Lore", "Die Zweite Zeile"}, true)
inv.item(13, "STONE", "Ich bin ein Stein", function(e)
player.chat(e)
end, { "Die Lore", "Die Zweite Zeile" }, true)
inv.open()
```
+1 -1
View File
@@ -43,7 +43,7 @@ function hotkeys_cycle_trace_view(pressed)
return
end
trace_cycle = (trace_cycle + 1) % 3
trace_commands = {"trace hide", "trace show", "trace show -e -c"}
trace_commands = { "trace hide", "trace show", "trace show -e -c" }
exec(trace_commands[trace_cycle + 1])
end
+213 -81
View File
@@ -26,7 +26,9 @@ inventory = {}
---@param title string
---@param size number
---@return Inventory
function inventory.create(title, size) return nil end
function inventory.create(title, size)
return nil
end
---@alias InventoryClick 'LEFT' | 'SHIFT_LEFT' | 'RIGHT' | 'SHIFT_RIGHT' | 'MIDDLE' | 'NUMBER_KEY'
@@ -44,66 +46,88 @@ local Inventory = {}
---@param enchanted boolean
---@param amount number
---@return void
function Inventory.item(slot, material, name, handler, lore, enchanted, amount) end
function Inventory.item(slot, material, name, handler, lore, enchanted, amount)
end
---@param handler fun(): void
---@return void
function Inventory.setCloseHandler(handler) end
function Inventory.setCloseHandler(handler)
end
---@return void
function Inventory.open() end
function Inventory.open()
end
player = {}
---@return string
---Get the name of the player.
function player.name() return "" end
function player.name()
return ""
end
---@return void
function player.chat(...) end
function player.chat(...)
end
---@return void
---Send a message to the actionbar of the player.
function player.actionbar(...) end
function player.actionbar(...)
end
---@overload fun(): number
---@param newX number
function player.x(newX) end
function player.x(newX)
end
---@overload fun(): number
---@param newY number
function player.y(newY) end
function player.y(newY)
end
---@overload fun(): number
---@param newZ number
function player.z(newZ) end
function player.z(newZ)
end
---@overload fun(): number
---@param newYaw number
function player.yaw(newYaw) end
function player.yaw(newYaw)
end
---@overload fun(): number
---@param newPitch number
function player.pitch(newPitch) end
function player.pitch(newPitch)
end
---@return boolean
function player.sneaking() return nil end
function player.sneaking()
return nil
end
---@return boolean
function player.sprinting() return nil end
function player.sprinting()
return nil
end
---@overload fun(): number
---@param newSlot number
function player.slot(newSlot) end
function player.slot(newSlot)
end
---@return string
function player.item() return nil end
function player.item()
return nil
end
---@return string
function player.offHandItem() return nil end
function player.offHandItem()
return nil
end
---@return void
function player.closeInventory() end
function player.closeInventory()
end
---@field nextBool fun(): boolean
random = {}
@@ -113,17 +137,23 @@ random = {}
---@param origin number
---@param bound number
---@return number
function random.nextInt(origin, bound) return nil end
function random.nextInt(origin, bound)
return nil
end
---@overload fun(): number
---@overload fun(bound: number): number
---@param origin number
---@param bound number
---@return number
function random.nextDouble(origin, bound) return nil end
function random.nextDouble(origin, bound)
return nil
end
---@return boolean
function random.nextBool() return nil end
function random.nextBool()
return nil
end
---@alias RegionType 'wg' | 'mwg' | 'as' | 'ws' | 'ws_inner' | 'ws_rumpf' | 'ws_rahmen' | 'spawn'
@@ -136,52 +166,84 @@ local iregion = {}
region = {}
---@return string
function iregion.name() return nil end
function iregion.name()
return nil
end
---@return RegionType
function iregion.type() return nil end
function iregion.type()
return nil
end
---@return boolean
function iregion.fire() return nil end
function iregion.fire()
return nil
end
---@return boolean
function iregion.freeze() return nil end
function iregion.freeze()
return nil
end
---@return boolean
function iregion.protect() return nil end
function iregion.protect()
return nil
end
---@return string
function iregion.loader() return nil end
function iregion.loader()
return nil
end
---@return Position
function iregion.copyPoint() return nil end
function iregion.copyPoint()
return nil
end
---@return Position
function iregion.minPointBuild() return nil end
function iregion.minPointBuild()
return nil
end
---@return Position
function iregion.maxPointBuild() return nil end
function iregion.maxPointBuild()
return nil
end
---@return Position
function iregion.minPointBuildExtension() return nil end
function iregion.minPointBuildExtension()
return nil
end
---@return Position
function iregion.maxPointBuildExtension() return nil end
function iregion.maxPointBuildExtension()
return nil
end
---@return Position
function iregion.testblockPoint() return nil end
function iregion.testblockPoint()
return nil
end
---@return Position
function iregion.minPointTestblock() return nil end
function iregion.minPointTestblock()
return nil
end
---@return Position
function iregion.maxPointTestblock() return nil end
function iregion.maxPointTestblock()
return nil
end
---@return Position
function iregion.minPointTestblockExtension() return nil end
function iregion.minPointTestblockExtension()
return nil
end
---@return Position
function iregion.maxPointTestblockExtension() return nil end
function iregion.maxPointTestblockExtension()
return nil
end
---@alias TNTMode 'ALLOW' | 'DENY' | 'ONLY_TB'
@@ -189,23 +251,35 @@ function iregion.maxPointTestblockExtension() return nil end
local tnt = {}
---@return TNTMode
function tnt.mode() return nil end
function tnt.mode()
return nil
end
---@return boolean
function tnt.enabled() return nil end
function tnt.enabled()
return nil
end
---@return boolean
function tnt.onlyTb() return nil end
function tnt.onlyTb()
return nil
end
---@return boolean
function tnt.onlyBuild() return nil end
function tnt.onlyBuild()
return nil
end
---@param name string
---@return iregion
function region.get(name) return nil end
function region.get(name)
return nil
end
---@return iregion[]
function region.list() return nil end
function region.list()
return nil
end
---@class tracerLib
tracer = {}
@@ -224,7 +298,9 @@ tracer = {}
---@field getId fun(): string
---@field getRecords fun(): {[number]: {[number]: TraceRecord}}
function tracer.getTraces() return nil end
function tracer.getTraces()
return nil
end
---@class Position
---@field x number
@@ -236,43 +312,65 @@ function tracer.getTraces() return nil end
server = {}
---@return string
function server.time() return nil end
function server.time()
return nil
end
---@return number
function server.ticks() return nil end
function server.ticks()
return nil
end
---@param position Position
---@return string
function getBlockAt(position) return nil end
function getBlockAt(position)
return nil
end
---@param position Position
---@param material string
---@return void
function setBlockAt(position, material) return nil end
function setBlockAt(position, material)
return nil
end
---@class tps
local tps = {}
---@return number
function tps.oneSecond() return nil end
function tps.oneSecond()
return nil
end
---@return number
function tps.tenSecond() return nil end
function tps.tenSecond()
return nil
end
---@return number
function tps.oneMinute() return nil end
function tps.oneMinute()
return nil
end
---@return number
function tps.fiveMinute() return nil end
function tps.fiveMinute()
return nil
end
---@return number
function tps.tenMinute() return nil end
function tps.tenMinute()
return nil
end
---@return number
function tps.current() return nil end
function tps.current()
return nil
end
---@return number
function tps.limit() return nil end
function tps.limit()
return nil
end
---@class storage
---@field global storageLib
@@ -286,24 +384,32 @@ local storageLib = {}
---@param key string
---@return any
function storageLib.get(key) return nil end
function storageLib.get(key)
return nil
end
---@param key string
---@param value any
---@return void
function storageLib.set(key, value) end
function storageLib.set(key, value)
end
---@param key string
---@return boolean
function storageLib.has(key) return nil end
function storageLib.has(key)
return nil
end
---@param key string
---@return void
function storageLib.remove(key) end
function storageLib.remove(key)
end
---@param key string
---@return Accessor
function storageLib.accessor(key) return nil end
function storageLib.accessor(key)
return nil
end
---@class Accessor
---@overload fun(): any
@@ -318,35 +424,46 @@ _worldedit = {}
---@overload fun(pos: Position[]): void
---@return Selection
function _worldedit.selection() return nil end
function _worldedit.selection()
return nil
end
---@param msg string
---@param callback fun(value: string): void
---@return void
function input(msg, callback) end
function input(msg, callback)
end
---@param ticks number
---@param callback fun(): void
---@return void
function delayed(ticks, callback) end
function delayed(ticks, callback)
end
---@param x number
---@param y number
---@param z number
---@return Position
function pos(x, y, z) return nil end
function pos(x, y, z)
return nil
end
---@return void
function exec(...) end
function exec(...)
end
---@param obj any
---@return number
function length(obj) return 0 end
function length(obj)
return 0
end
---@param separator string
---@param table any[]
---@return string
function join(separator, table) return "" end
function join(separator, table)
return ""
end
---@class EventType
---@class events
@@ -364,21 +481,23 @@ function join(separator, table) return "" end
---@field EntityDeath EventType
events = {}
---@param id EventType
---@param handler fun(params: any): void
---@return void
function event(id, handler) end
function event(id, handler)
end
---@param command string
---@param handler fun(params: string[]): void
---@return void
function command(command, handler) end
function command(command, handler)
end
---@param trigger string
---@param handler fun(pressed: boolean): void
---@return void
function hotkey(trigger, handler) end
function hotkey(trigger, handler)
end
---@class bossbar
bossbar = {}
@@ -394,39 +513,52 @@ local BossBar = {}
---@param color BossBarColor
---@param style BossBarStyle
---@return BossBar
function bossbar.create(title, color, style) return nil end
function bossbar.create(title, color, style)
return nil
end
---@return string
---@overload fun(title: string): void
function BossBar.title() end
function BossBar.title()
end
---@return BossBarColor
---@overload fun(color: BossBarColor): void
function BossBar.color() end
function BossBar.color()
end
---@return BossBarStyle
---@overload fun(style: BossBarStyle): void
function BossBar.style() end
function BossBar.style()
end
---@return number
---@overload fun(progress: number): void
function BossBar.progress() end
function BossBar.progress()
end
---@return boolean
---@overload fun(visible: boolean): void
function BossBar.visible() end
function BossBar.visible()
end
---@return boolean
---@param flag BossBarFlag
function BossBar.hasFlag(flag) return nil end
function BossBar.hasFlag(flag)
return nil
end
---@return void
---@param flag BossBarFlag
function BossBar.addFlag(flag) end
function BossBar.addFlag(flag)
end
---@return boolean
---@param flag BossBarFlag
function BossBar.removeFlag(flag) return nil end
function BossBar.removeFlag(flag)
return nil
end
---@return void
function BossBar.destroy() end
function BossBar.destroy()
end
+9 -8
View File
@@ -12,11 +12,12 @@ import de.steamwar.commands.user.UserCommand
import de.steamwar.commands.user.UserInfoCommand
import de.steamwar.commands.user.UserSearchCommand
fun main(args: Array<String>) = SteamWar()
.subcommands(
DatabaseCommand().subcommands(InfoCommand(), ResetCommand()),
UserCommand().subcommands(UserInfoCommand(), UserSearchCommand()),
DevCommand(),
ProfilerCommand()
)
.main(args)
fun main(args: Array<String>) =
SteamWar()
.subcommands(
DatabaseCommand().subcommands(InfoCommand(), ResetCommand()),
UserCommand().subcommands(UserInfoCommand(), UserSearchCommand()),
DevCommand(),
ProfilerCommand()
)
.main(args)

Some files were not shown because too many files have changed in this diff Show More