forked from SteamWar/SteamWar
Format code
This commit is contained in:
@@ -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
+1
-1
@@ -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;
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
+2
-1
@@ -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));
|
||||
}
|
||||
|
||||
+1
-1
@@ -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());
|
||||
}
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
+2
-2
@@ -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();
|
||||
|
||||
+6
-2
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
+2
@@ -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);
|
||||
}
|
||||
|
||||
+13
-6
@@ -95,7 +95,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
};
|
||||
updateRunnable.run();
|
||||
|
||||
SWListInv<Integer> listInv = new SWListInv<>(player, "Interaction Settings", false, entries, (clickType, entry) -> {});
|
||||
SWListInv<Integer> listInv = new SWListInv<>(player, "Interaction Settings", false, entries, (clickType, entry) -> {
|
||||
});
|
||||
listInv.setCallback((clickType, entry) -> {
|
||||
openIndividualSettingsMenu(player, entry, () -> {
|
||||
updateRunnable.run();
|
||||
@@ -150,7 +151,9 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
}
|
||||
|
||||
SWInventory swInventory = new SWInventory(player, guiSize, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
|
||||
for (int i = guiSize - 9; i < guiSize; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", clickType -> {}));
|
||||
for (int i = guiSize - 9; i < guiSize; i++)
|
||||
swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", clickType -> {
|
||||
}));
|
||||
swInventory.setItem(guiSize - 9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).setCustomModelData(CMDs.BACK).getItemStack(), clickType -> back.run());
|
||||
swInventory.setItem(guiSize - 5, new SWItem(Material.WOODEN_AXE, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_COPY", player)).getItemStack(), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_GUI_COPY_TITLE", player), "1");
|
||||
@@ -197,7 +200,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
for (int power = 0; power < 16; power++) {
|
||||
int finalPowerPosition = power;
|
||||
if (power >= 9) finalPowerPosition++;
|
||||
SWItem powerItem = new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("LOADER_SETTING_POWER", player, power), Arrays.asList(), false, clickType -> {});
|
||||
SWItem powerItem = new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("LOADER_SETTING_POWER", player, power), Arrays.asList(), false, clickType -> {
|
||||
});
|
||||
powerItem.getItemStack().setAmount(Math.max(power, 1));
|
||||
if (extraPower.get(index) == power) powerItem.setEnchanted(true);
|
||||
|
||||
@@ -210,7 +214,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
}
|
||||
|
||||
if (currentElement.hasTicks(this)) {
|
||||
swInventory.setItem(ticksStart + 3, new SWItem(Material.RED_DYE, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> {
|
||||
swInventory.setItem(ticksStart + 3, new SWItem(Material.RED_DYE, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {
|
||||
}).getItemStack(), clickType -> {
|
||||
long ticks = extraTicks.get(index);
|
||||
ticks -= clickType.isShiftClick() ? 5 : 1;
|
||||
if (ticks < 1) ticks = 1;
|
||||
@@ -218,7 +223,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
openIndividualSettingsMenu(player, index, back, delete);
|
||||
});
|
||||
|
||||
SWItem ticksItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS", player, extraTicks.get(index)), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)), false, clickType -> {});
|
||||
SWItem ticksItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS", player, extraTicks.get(index)), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)), false, clickType -> {
|
||||
});
|
||||
ticksItem.getItemStack().setAmount((int) Math.min(extraTicks.get(index), 64));
|
||||
swInventory.setItem(ticksStart + 4, ticksItem.getItemStack(), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_NAME", player), extraTicks.get(index) + "");
|
||||
@@ -234,7 +240,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
swAnvilInv.open();
|
||||
});
|
||||
|
||||
swInventory.setItem(ticksStart + 5, new SWItem(Material.LIME_DYE, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> {
|
||||
swInventory.setItem(ticksStart + 5, new SWItem(Material.LIME_DYE, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE_SHIFT", player)), false, clickType -> {
|
||||
}).getItemStack(), clickType -> {
|
||||
long ticks = extraTicks.get(index);
|
||||
ticks += clickType.isShiftClick() ? 5 : 1;
|
||||
extraTicks.set(index, ticks);
|
||||
|
||||
+3
@@ -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;
|
||||
}
|
||||
|
||||
+4
-2
@@ -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));
|
||||
});
|
||||
|
||||
+1
-2
@@ -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();
|
||||
|
||||
+4
-2
@@ -40,17 +40,19 @@ 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 {
|
||||
FULL,
|
||||
|
||||
+2
-1
@@ -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 {
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+3
-3
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -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
|
||||
|
||||
+2
-2
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -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);
|
||||
|
||||
+2
-2
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
+3
-1
@@ -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)
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+2
-2
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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());
|
||||
}
|
||||
|
||||
+2
-2
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+15
-7
@@ -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());
|
||||
|
||||
+33
-15
@@ -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);
|
||||
|
||||
|
||||
+1
-1
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -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);
|
||||
|
||||
+2
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -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));
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+2
-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());
|
||||
|
||||
+3
-3
@@ -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);
|
||||
|
||||
+1
-1
@@ -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)));
|
||||
|
||||
+1
-1
@@ -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)));
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
inventory.setItem(12, negativXItem);
|
||||
|
||||
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
|
||||
if(tnt.getAlignment().getX() != 1) tnt.alignX(1);
|
||||
if (tnt.getAlignment().getX() != 1) tnt.alignX(1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
positivXItem.setEnchanted(tnt.getAlignment().getX() == 1);
|
||||
|
||||
+7
-3
@@ -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 -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-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()) {
|
||||
|
||||
+1
@@ -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);
|
||||
}
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
+4
-5
@@ -46,12 +46,10 @@ public class TraceManager implements Listener {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
if (!tracesFolder.exists())
|
||||
tracesFolder.mkdir();
|
||||
if (!tracesFolder.exists()) tracesFolder.mkdir();
|
||||
|
||||
File[] traceFiles = tracesFolder.listFiles();
|
||||
if (traceFiles == null)
|
||||
return;
|
||||
if (traceFiles == null) return;
|
||||
|
||||
boolean hasMetaFiles = false;
|
||||
for (File traceFile : traceFiles) {
|
||||
@@ -152,7 +150,8 @@ public class TraceManager implements Listener {
|
||||
.map(Map.Entry::getKey)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (traceId == null) throw new RuntimeException("Trace not found while trying to remove see (c978eb98-b0b2-4009-91d8-acfa34e2831a)");
|
||||
if (traceId == null)
|
||||
throw new RuntimeException("Trace not found while trying to remove see (c978eb98-b0b2-4009-91d8-acfa34e2831a)");
|
||||
traces.remove(traceId);
|
||||
trace.hide();
|
||||
trace.getRecordsSaveFile().delete();
|
||||
|
||||
+3
-1
@@ -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);
|
||||
|
||||
+1
-2
@@ -102,8 +102,7 @@ public abstract class ViewFlag {
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasMicromotion)
|
||||
toRemove.add(uniqueRecord);
|
||||
if (!hasMicromotion) toRemove.add(uniqueRecord);
|
||||
|
||||
seen.add(uniqueRecord.getTntId());
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+2
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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("<")) {
|
||||
|
||||
+2
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -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) {
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
+6
-3
@@ -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;
|
||||
|
||||
+1
-1
@@ -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();
|
||||
|
||||
+10
-7
@@ -41,35 +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())
|
||||
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
|
||||
public void onCRIUWakeup(CRIUWakeupEvent event) {
|
||||
|
||||
+3
-3
@@ -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);
|
||||
}
|
||||
|
||||
+1
-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();
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
+1
@@ -51,6 +51,7 @@ public class ColorReplaceCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private Set<String> types = new HashSet<>();
|
||||
|
||||
{
|
||||
WorldEditListener.addOtherCommand("//colorreplace");
|
||||
WorldEditListener.addOtherCommand("//cr");
|
||||
|
||||
@@ -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();
|
||||
|
||||
+52
-12
@@ -2,6 +2,7 @@
|
||||
|
||||
---
|
||||
<!-- TOC -->
|
||||
|
||||
* [SteamWar.de - Script System](#steamwarde---script-system)
|
||||
* [Einleitung](#einleitung)
|
||||
* [Nutzung mit einer IDE](#nutzung-mit-einer-ide)
|
||||
@@ -37,32 +38,39 @@
|
||||
* [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,11 +241,12 @@ 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 |
|
||||
|
||||
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,27 +382,30 @@ 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")
|
||||
@@ -383,9 +415,11 @@ event(events.DoubleSwap, handler)
|
||||
```
|
||||
|
||||
## SL Command
|
||||
|
||||
Ein einfacher Command Redefiner.
|
||||
|
||||
#### Code
|
||||
|
||||
```lua
|
||||
function handler(args)
|
||||
exec("stoplag")
|
||||
@@ -395,9 +429,11 @@ command("sl", handler)
|
||||
```
|
||||
|
||||
## Paste Hotkey
|
||||
|
||||
Ein Hotkey zum Pasten des Clipboard-Inhalts.
|
||||
|
||||
#### Code
|
||||
|
||||
```lua
|
||||
function handler(pressed)
|
||||
if pressed then
|
||||
@@ -409,11 +445,15 @@ 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()
|
||||
```
|
||||
@@ -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
@@ -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
|
||||
|
||||
+2
-1
@@ -12,7 +12,8 @@ import de.steamwar.commands.user.UserCommand
|
||||
import de.steamwar.commands.user.UserInfoCommand
|
||||
import de.steamwar.commands.user.UserSearchCommand
|
||||
|
||||
fun main(args: Array<String>) = SteamWar()
|
||||
fun main(args: Array<String>) =
|
||||
SteamWar()
|
||||
.subcommands(
|
||||
DatabaseCommand().subcommands(InfoCommand(), ResetCommand()),
|
||||
UserCommand().subcommands(UserInfoCommand(), UserSearchCommand()),
|
||||
|
||||
@@ -3,7 +3,7 @@ package de.steamwar.commands
|
||||
import com.github.ajalt.clikt.core.CliktCommand
|
||||
import com.github.ajalt.mordant.rendering.TextStyles
|
||||
|
||||
class SteamWar: CliktCommand(name = "sw") {
|
||||
class SteamWar : CliktCommand(name = "sw") {
|
||||
override fun run() {
|
||||
echo(TextStyles.bold("SteamWar-CLI"))
|
||||
}
|
||||
|
||||
@@ -8,11 +8,12 @@ import com.github.ajalt.clikt.parameters.options.flag
|
||||
import com.github.ajalt.clikt.parameters.options.option
|
||||
import de.steamwar.db.Database
|
||||
|
||||
class DatabaseCommand: CliktCommand(name = "db") {
|
||||
class DatabaseCommand : CliktCommand(name = "db") {
|
||||
val useProduction by option().flag()
|
||||
val db by findOrSetObject { Database }
|
||||
|
||||
override fun help(context: Context): String = "Run database commands"
|
||||
override fun help(context: Context): String =
|
||||
"Run database commands"
|
||||
|
||||
override fun run() {
|
||||
if (!useProduction && db.database == "production") {
|
||||
|
||||
@@ -7,10 +7,11 @@ import de.steamwar.db.Database
|
||||
import de.steamwar.db.execute
|
||||
import de.steamwar.db.useDb
|
||||
|
||||
class InfoCommand: CliktCommand() {
|
||||
class InfoCommand : CliktCommand() {
|
||||
val db by requireObject<Database>()
|
||||
|
||||
override fun run() = useDb {
|
||||
override fun run() =
|
||||
useDb {
|
||||
val tables = execute("SHOW TABLES") { it.getString(1) }
|
||||
|
||||
echo(
|
||||
|
||||
@@ -10,10 +10,11 @@ import de.steamwar.db.execute
|
||||
import de.steamwar.db.useDb
|
||||
import java.io.File
|
||||
|
||||
class ResetCommand: CliktCommand() {
|
||||
class ResetCommand : CliktCommand() {
|
||||
val db by requireObject<Database>()
|
||||
|
||||
override fun run() = useDb {
|
||||
override fun run() =
|
||||
useDb {
|
||||
val schemaFile = File("/var/Schema.sql")
|
||||
if (!schemaFile.exists()) {
|
||||
throw CliktError("Schema file not found!")
|
||||
|
||||
@@ -46,7 +46,8 @@ const val LOG4J_CONFIG = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
</Configuration>"""
|
||||
|
||||
class DevCommand : CliktCommand("dev") {
|
||||
override fun help(context: Context): String = "Start a dev Server"
|
||||
override fun help(context: Context): String =
|
||||
"Start a dev Server"
|
||||
|
||||
override val treatUnknownOptionsAsArgs = true
|
||||
|
||||
@@ -73,12 +74,21 @@ class DevCommand : CliktCommand("dev") {
|
||||
if (serverDirectory.exists() && serverDirectory.isDirectory) serverDirectory else File(workingDir, server)
|
||||
|
||||
if (isVelocity(server)) {
|
||||
runServer(args, jvmArgs, listOf(jar?.absolutePath ?: File("/jar/Velocity.jar").absolutePath), serverDir)
|
||||
runServer(
|
||||
args, jvmArgs, listOf(
|
||||
jar?.absolutePath
|
||||
?: File("/jar/Velocity.jar").absolutePath
|
||||
), serverDir
|
||||
)
|
||||
} else {
|
||||
setLogConfig(args)
|
||||
val version = findVersion(server) ?: throw CliktError("Unknown Server Version")
|
||||
val worldFile = world?.absolute()?.toFile() ?: File(serverDir, "devtempworld")
|
||||
val jarFile = jar?.absolutePath ?: additionalVersions[server]?.let { supportedVersionJars[it] } ?: supportedVersionJars[version]
|
||||
val version = findVersion(server)
|
||||
?: throw CliktError("Unknown Server Version")
|
||||
val worldFile = world?.absolute()?.toFile()
|
||||
?: File(serverDir, "devtempworld")
|
||||
val jarFile = jar?.absolutePath
|
||||
?: additionalVersions[server]?.let { supportedVersionJars[it] }
|
||||
?: supportedVersionJars[version]
|
||||
?: throw CliktError("Unknown Server Version")
|
||||
|
||||
if (!worldFile.exists()) {
|
||||
@@ -108,7 +118,8 @@ class DevCommand : CliktCommand("dev") {
|
||||
|
||||
try {
|
||||
devFile.delete()
|
||||
} catch (_: Exception) { /* ignored */ }
|
||||
} catch (_: Exception) { /* ignored */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,11 +156,15 @@ class DevCommand : CliktCommand("dev") {
|
||||
"Lobby" to 20
|
||||
)
|
||||
|
||||
fun findVersion(server: String): Int? = server.dropWhile { !it.isDigit() }.toIntOrNull()
|
||||
fun findVersion(server: String): Int? =
|
||||
server.dropWhile { !it.isDigit() }.toIntOrNull()
|
||||
|
||||
fun isJava8(server: String): Boolean = findVersion(server)?.let { it <= 10 } ?: false
|
||||
fun isJava8(server: String): Boolean =
|
||||
findVersion(server)?.let { it <= 10 }
|
||||
?: false
|
||||
|
||||
fun isVelocity(server: String): Boolean = server.endsWith("Velocity")
|
||||
fun isVelocity(server: String): Boolean =
|
||||
server.endsWith("Velocity")
|
||||
|
||||
fun setLogConfig(args: MutableList<String>) {
|
||||
args += "-DlogPath=${workingDir.absolutePath}/logs"
|
||||
@@ -162,7 +177,8 @@ class DevCommand : CliktCommand("dev") {
|
||||
|
||||
fun runServer(args: List<String>, jvmArgs: List<String>, cmd: List<String>, serverDir: File) {
|
||||
val process = ProcessBuilder(
|
||||
jvm?.absolutePath ?: if (isJava8(server)) "/usr/lib/jvm/openj9-8/bin/java" else "java",
|
||||
jvm?.absolutePath
|
||||
?: if (isJava8(server)) "/usr/lib/jvm/openj9-8/bin/java" else "java",
|
||||
*jvmArgs.toTypedArray(),
|
||||
*args.toTypedArray(),
|
||||
*jvmDefaultParams,
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.github.ajalt.clikt.parameters.types.int
|
||||
|
||||
const val SPARK = "/jars/spark.jar"
|
||||
|
||||
class ProfilerCommand: CliktCommand("profiler") {
|
||||
class ProfilerCommand : CliktCommand("profiler") {
|
||||
val pid by argument().help("Process id").int().optional()
|
||||
val port by option("--port", "-p").int().default(8543)
|
||||
|
||||
@@ -38,5 +38,6 @@ class ProfilerCommand: CliktCommand("profiler") {
|
||||
}
|
||||
}
|
||||
|
||||
override fun help(context: Context): String = "Start a profiler"
|
||||
override fun help(context: Context): String =
|
||||
"Start a profiler"
|
||||
}
|
||||
@@ -3,7 +3,10 @@ package de.steamwar.commands.user
|
||||
import com.github.ajalt.clikt.core.CliktCommand
|
||||
import com.github.ajalt.clikt.core.Context
|
||||
|
||||
class UserCommand: CliktCommand("user") {
|
||||
override fun run() = Unit
|
||||
override fun help(context: Context): String = "User related commands"
|
||||
class UserCommand : CliktCommand("user") {
|
||||
override fun run() =
|
||||
Unit
|
||||
|
||||
override fun help(context: Context): String =
|
||||
"User related commands"
|
||||
}
|
||||
@@ -17,11 +17,15 @@ import java.time.Duration
|
||||
|
||||
class UserInfoCommand : CliktCommand("info") {
|
||||
val userId by argument().help("Id, Name, UUID or DiscordId")
|
||||
val user by lazy { findUser(userId) ?: throw CliktError("User not found") }
|
||||
val user by lazy {
|
||||
findUser(userId)
|
||||
?: throw CliktError("User not found")
|
||||
}
|
||||
|
||||
override val printHelpOnEmptyArgs = true
|
||||
|
||||
override fun run() = useDb {
|
||||
override fun run() =
|
||||
useDb {
|
||||
val sessions =
|
||||
SessionTable.selectAll().where { SessionTable.userId eq user.id.value }
|
||||
.map { it[SessionTable.startTime] to it[SessionTable.endTime] }
|
||||
@@ -49,7 +53,8 @@ class UserInfoCommand : CliktCommand("info") {
|
||||
punishments.map {
|
||||
row(
|
||||
it.type,
|
||||
SteamwarUser.byId(it.punisher)?.userName ?: it.punisher,
|
||||
SteamwarUser.byId(it.punisher)?.userName
|
||||
?: it.punisher,
|
||||
it.startTime.toString(),
|
||||
if (it.perma) "Perma" else it.endTime.toString(),
|
||||
it.reason
|
||||
|
||||
@@ -18,9 +18,11 @@ class UserSearchCommand : CliktCommand("search") {
|
||||
|
||||
override val printHelpOnEmptyArgs = true
|
||||
|
||||
override fun help(context: Context): String = "Search for users"
|
||||
override fun help(context: Context): String =
|
||||
"Search for users"
|
||||
|
||||
override fun run() = useDb {
|
||||
override fun run() =
|
||||
useDb {
|
||||
val users = SteamwarUser.find {
|
||||
joinedOr(
|
||||
SteamwarUserTable.username like "%$query%",
|
||||
|
||||
@@ -49,11 +49,12 @@ object Database {
|
||||
}
|
||||
}
|
||||
|
||||
fun <T: BaseCliktCommand<T>> BaseCliktCommand<T>.findUser(query: String): SteamwarUser? = transaction {
|
||||
fun <T : BaseCliktCommand<T>> BaseCliktCommand<T>.findUser(query: String): SteamwarUser? =
|
||||
transaction {
|
||||
SteamwarUser.find { joinedOr(query.toIntOrNull()?.let { SteamwarUserTable.id eq it }, (SteamwarUserTable.username eq query), SteamwarUserTable.uuid eq query, query.toLongOrNull()?.let { SteamwarUserTable.discordId eq it }) }
|
||||
.firstOrNull()
|
||||
?.let { return@transaction it }
|
||||
}
|
||||
}
|
||||
|
||||
fun joinedOr(vararg expressions: Expression<Boolean>?): Op<Boolean> =
|
||||
expressions.filterNotNull().reduce { acc, expression -> acc or expression } as Op<Boolean>
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@
|
||||
</appender>
|
||||
|
||||
<root level="WARN">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -182,8 +182,9 @@ public abstract class AbstractSWCommand<T> {
|
||||
if (!checkType(method.getAnnotations(), method.getReturnType(), false, annotation -> {
|
||||
CommandMetaData.Method methodMetaData = annotation.annotationType().getAnnotation(CommandMetaData.Method.class);
|
||||
if (methodMetaData == null) return (aClass, varArg) -> true;
|
||||
if (method.getParameterCount() > methodMetaData.maxParameterCount() || method.getParameterCount() < methodMetaData.minParameterCount())
|
||||
if (method.getParameterCount() > methodMetaData.maxParameterCount() || method.getParameterCount() < methodMetaData.minParameterCount()) {
|
||||
return (aClass, varArg) -> false;
|
||||
}
|
||||
return (aClass, varArg) -> {
|
||||
Class<?>[] types = methodMetaData.value();
|
||||
if (types == null) return true;
|
||||
|
||||
@@ -33,7 +33,9 @@ public @interface CommandMetaData {
|
||||
@Target(ElementType.ANNOTATION_TYPE)
|
||||
@interface Method {
|
||||
Class<?>[] value();
|
||||
|
||||
int minParameterCount() default 0;
|
||||
|
||||
int maxParameterCount() default Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@@ -44,6 +46,7 @@ public @interface CommandMetaData {
|
||||
@Target(ElementType.ANNOTATION_TYPE)
|
||||
@interface Parameter {
|
||||
Class<?>[] value() default {};
|
||||
|
||||
Class<?> handler() default void.class;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,8 @@ class CommandPart<T> {
|
||||
List<Object> currentArgs = new ArrayList<>(mappedArgs);
|
||||
List<Object> varArgs = new ArrayList<>();
|
||||
for (int i = startIndex; i < args.length - 1; i++) {
|
||||
CheckArgumentResult validArgument = checkArgument((ignore) -> {}, sender, args, mappedArgs, i);
|
||||
CheckArgumentResult validArgument = checkArgument((ignore) -> {
|
||||
}, sender, args, mappedArgs, i);
|
||||
if (!validArgument.success) return;
|
||||
varArgs.add(validArgument.value);
|
||||
}
|
||||
@@ -162,7 +163,8 @@ class CommandPart<T> {
|
||||
}
|
||||
|
||||
if (args.length - 1 > startIndex) {
|
||||
CheckArgumentResult checkArgumentResult = checkArgument((ignore) -> {}, sender, args, mappedArgs, startIndex);
|
||||
CheckArgumentResult checkArgumentResult = checkArgument((ignore) -> {
|
||||
}, sender, args, mappedArgs, startIndex);
|
||||
if (checkArgumentResult.success && next != null) {
|
||||
if (!ignoreAsArgument) {
|
||||
mappedArgs.add(checkArgumentResult.value);
|
||||
|
||||
@@ -138,7 +138,8 @@ public class SubCommand<T> implements Comparable<SubCommand<T>> {
|
||||
}
|
||||
|
||||
List<String> tabComplete(T sender, String[] args) {
|
||||
if (validator != null && !validator.validate(sender, sender, (s, objects) -> {})) {
|
||||
if (validator != null && !validator.validate(sender, sender, (s, objects) -> {
|
||||
})) {
|
||||
return null;
|
||||
}
|
||||
if (commandPart == null) {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class NullMapperCommandTest {
|
||||
public void testNull() {
|
||||
NullMapperCommand command = new NullMapperCommand();
|
||||
try {
|
||||
command.execute("test", "", new String[] {"Hello World"});
|
||||
command.execute("test", "", new String[]{"Hello World"});
|
||||
assertThat(true, is(false));
|
||||
} catch (Exception e) {
|
||||
assertCMDFramework(e, ExecutionIdentifier.class, "null");
|
||||
@@ -43,7 +43,7 @@ public class NullMapperCommandTest {
|
||||
public void testNonNull() {
|
||||
NullMapperCommand command = new NullMapperCommand();
|
||||
try {
|
||||
command.execute("test", "", new String[] {"Hello"});
|
||||
command.execute("test", "", new String[]{"Hello"});
|
||||
assertThat(true, is(false));
|
||||
} catch (Exception e) {
|
||||
assertCMDFramework(e, ExecutionIdentifier.class, "notnull");
|
||||
|
||||
@@ -43,7 +43,7 @@ public class SimpleCommandTest {
|
||||
public void testVarArgs() {
|
||||
SimpleCommand cmd = new SimpleCommand();
|
||||
try {
|
||||
cmd.execute("test", "", new String[] {"a", "b", "c"});
|
||||
cmd.execute("test", "", new String[]{"a", "b", "c"});
|
||||
} catch (Exception e) {
|
||||
assertCMDFramework(e, ExecutionIdentifier.class, "RunSimple with Varargs");
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user