forked from SteamWar/SteamWar
Merge branch 'main' into world-system
# Conflicts: # VelocityCore/src/de/steamwar/velocitycore/ServerStarter.java # VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java # VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java
This commit is contained in:
@@ -41,7 +41,7 @@ jobs:
|
||||
run: |
|
||||
echo "$SW_MAVEN_CREDENTIALS" > steamwar.properties
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build --no-daemon
|
||||
run: ./gradlew clean build --no-daemon --no-build-cache --refresh-dependencies
|
||||
|
||||
- name: Stage deploy artifacts
|
||||
shell: bash
|
||||
@@ -129,8 +129,12 @@ jobs:
|
||||
ssh-keyscan -p "$port" "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
||||
|
||||
ssh -i ~/.ssh/deploy_key -p "$port" "${DEPLOY_USER}@${DEPLOY_HOST}" "mkdir -p '$DEPLOY_PATH'"
|
||||
ssh -i ~/.ssh/deploy_key -p "$port" "${DEPLOY_USER}@${DEPLOY_HOST}" "rm -f '$DEPLOY_PATH/*'"
|
||||
scp -i ~/.ssh/deploy_key -P "$port" deploy/* "${DEPLOY_USER}@${DEPLOY_HOST}:$DEPLOY_PATH/"
|
||||
ssh -i ~/.ssh/deploy_key -p "$port" "${DEPLOY_USER}@${DEPLOY_HOST}" "mkdir -p '$DEPLOY_PATH/upload'"
|
||||
scp -i ~/.ssh/deploy_key -P "$port" deploy/* "${DEPLOY_USER}@${DEPLOY_HOST}:$DEPLOY_PATH/upload"
|
||||
ssh -i ~/.ssh/deploy_key -p "$port" "${DEPLOY_USER}@${DEPLOY_HOST}" "rm -f '$DEPLOY_PATH'/*.jar '$DEPLOY_PATH'/*.zip"
|
||||
ssh -i ~/.ssh/deploy_key -p "$port" "${DEPLOY_USER}@${DEPLOY_HOST}" "mv '$DEPLOY_PATH'/upload/* '$DEPLOY_PATH'"
|
||||
ssh -i ~/.ssh/deploy_key -p "$port" "${DEPLOY_USER}@${DEPLOY_HOST}" "rm -r '$DEPLOY_PATH/upload'"
|
||||
ssh -i ~/.ssh/deploy_key -p "$port" "${DEPLOY_USER}@${DEPLOY_HOST}" "chmod o-w '$DEPLOY_PATH'/*"
|
||||
- name: Restart Services
|
||||
shell: bash
|
||||
env:
|
||||
|
||||
+12
-4
@@ -76,13 +76,21 @@ public class AttributesCopyCommand extends SWCommand {
|
||||
if (itemStack.getType() == Material.ZOMBIE_HEAD && block.getType() == Material.ZOMBIE_WALL_HEAD) return true;
|
||||
if (itemStack.getType() == Material.CREEPER_HEAD && block.getType() == Material.CREEPER_WALL_HEAD) return true;
|
||||
if (itemStack.getType() == Material.DRAGON_HEAD && block.getType() == Material.DRAGON_WALL_HEAD) return true;
|
||||
if (itemStack.getType() == Material.SKELETON_SKULL && block.getType() == Material.SKELETON_WALL_SKULL) return true;
|
||||
if (itemStack.getType() == Material.WITHER_SKELETON_SKULL && block.getType() == Material.WITHER_SKELETON_WALL_SKULL) return true;
|
||||
if (itemStack.getType() == Material.SKELETON_SKULL && block.getType() == Material.SKELETON_WALL_SKULL) {
|
||||
return true;
|
||||
}
|
||||
if (itemStack.getType() == Material.WITHER_SKELETON_SKULL && block.getType() == Material.WITHER_SKELETON_WALL_SKULL) {
|
||||
return true;
|
||||
}
|
||||
if (itemStack.getType() == Material.TORCH && block.getType() == Material.WALL_TORCH) return true;
|
||||
if (itemStack.getType() == Material.SOUL_TORCH && block.getType() == Material.SOUL_WALL_TORCH) return true;
|
||||
if (itemStack.getType() == Material.REDSTONE_TORCH && block.getType() == Material.REDSTONE_WALL_TORCH) return true;
|
||||
if (itemStack.getType() == Material.REDSTONE_TORCH && block.getType() == Material.REDSTONE_WALL_TORCH) {
|
||||
return true;
|
||||
}
|
||||
if (itemStack.getType() == Material.WHEAT_SEEDS && block.getType() == Material.WHEAT) return true;
|
||||
if (itemStack.getType().name().contains("_BANNER") && block.getType().name().contains("_WALL_BANNER")) return true;
|
||||
if (itemStack.getType().name().contains("_BANNER") && block.getType().name().contains("_WALL_BANNER")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+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
-2
@@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.gui.editor;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.gui.BauGUI;
|
||||
import de.steamwar.bausystem.linkage.BauGuiItem;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
@@ -74,7 +73,7 @@ public class BauGuiEditor implements Listener {
|
||||
|
||||
inv.setItem(mapping.getSize() + 5, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH", p), Arrays.asList(BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH_LORE", p)), false, clickType -> {
|
||||
}).getItemStack());
|
||||
inv.setItem(mapping.getSize() + 6, new SWItem(TrickyTrialsWrapper.impl.getTurtleScute(), BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_MORE", p)).getItemStack());
|
||||
inv.setItem(mapping.getSize() + 6, new SWItem(Material.TURTLE_SCUTE, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_MORE", p)).getItemStack());
|
||||
inv.setItem(mapping.getSize() + 8, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_CLOSE", p)).setCustomModelData(CMDs.BACK).getItemStack());
|
||||
|
||||
p.openInventory(inv);
|
||||
|
||||
+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
|
||||
|
||||
+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]);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+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);
|
||||
}
|
||||
|
||||
+14
-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,10 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
}
|
||||
|
||||
SWInventory swInventory = new SWInventory(player, guiSize, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
|
||||
for (int i = guiSize - 9; i < guiSize; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", clickType -> {}));
|
||||
for (int i = guiSize - 9; i < guiSize; i++) {
|
||||
swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", clickType -> {
|
||||
}));
|
||||
}
|
||||
swInventory.setItem(guiSize - 9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).setCustomModelData(CMDs.BACK).getItemStack(), clickType -> back.run());
|
||||
swInventory.setItem(guiSize - 5, new SWItem(Material.WOODEN_AXE, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_COPY", player)).getItemStack(), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_GUI_COPY_TITLE", player), "1");
|
||||
@@ -197,7 +201,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
for (int power = 0; power < 16; power++) {
|
||||
int finalPowerPosition = power;
|
||||
if (power >= 9) finalPowerPosition++;
|
||||
SWItem powerItem = new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("LOADER_SETTING_POWER", player, power), Arrays.asList(), false, clickType -> {});
|
||||
SWItem powerItem = new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("LOADER_SETTING_POWER", player, power), Arrays.asList(), false, clickType -> {
|
||||
});
|
||||
powerItem.getItemStack().setAmount(Math.max(power, 1));
|
||||
if (extraPower.get(index) == power) powerItem.setEnchanted(true);
|
||||
|
||||
@@ -210,7 +215,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
}
|
||||
|
||||
if (currentElement.hasTicks(this)) {
|
||||
swInventory.setItem(ticksStart + 3, new SWItem(SWItem.getDye(1), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> {
|
||||
swInventory.setItem(ticksStart + 3, new SWItem(Material.RED_DYE, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {
|
||||
}).getItemStack(), clickType -> {
|
||||
long ticks = extraTicks.get(index);
|
||||
ticks -= clickType.isShiftClick() ? 5 : 1;
|
||||
if (ticks < 1) ticks = 1;
|
||||
@@ -218,7 +224,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
openIndividualSettingsMenu(player, index, back, delete);
|
||||
});
|
||||
|
||||
SWItem ticksItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS", player, extraTicks.get(index)), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)), false, clickType -> {});
|
||||
SWItem ticksItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS", player, extraTicks.get(index)), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player)), false, clickType -> {
|
||||
});
|
||||
ticksItem.getItemStack().setAmount((int) Math.min(extraTicks.get(index), 64));
|
||||
swInventory.setItem(ticksStart + 4, ticksItem.getItemStack(), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_NAME", player), extraTicks.get(index) + "");
|
||||
@@ -234,7 +241,8 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
swAnvilInv.open();
|
||||
});
|
||||
|
||||
swInventory.setItem(ticksStart + 5, new SWItem(SWItem.getDye(10), 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(SWItem.getDye(1), 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(SWItem.getDye(10), 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));
|
||||
});
|
||||
|
||||
+2
-4
@@ -146,8 +146,7 @@ public class Loadtimer implements Listener {
|
||||
if ((stage == Stage.COUNTING || stage == Stage.ACTIVATED)) {
|
||||
stage = Stage.IGNITION;
|
||||
ignite = TPSUtils.currentRealTick.get();
|
||||
if (activate == -1)
|
||||
activate = TPSUtils.currentRealTick.get();
|
||||
if (activate == -1) activate = TPSUtils.currentRealTick.get();
|
||||
if (finishOnActive) {
|
||||
stage = Stage.END;
|
||||
print();
|
||||
@@ -184,8 +183,7 @@ public class Loadtimer implements Listener {
|
||||
|
||||
long ignTime = ignite - activate;
|
||||
long explTime = explode - ignTime - activate;
|
||||
if (explTime < 0)
|
||||
explTime = loadTime;
|
||||
if (explTime < 0) explTime = loadTime;
|
||||
|
||||
int finalAllTnt = allTnt;
|
||||
long finalExplTime = explTime;
|
||||
|
||||
+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 {
|
||||
|
||||
+3
-3
@@ -20,9 +20,9 @@
|
||||
package de.steamwar.bausystem.features.loadtimer;
|
||||
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
@@ -57,7 +57,7 @@ public class LoadtimerListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
||||
if (!getTimers().isEmpty() && event.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
|
||||
if (!getTimers().isEmpty() && event.getEntityType() == EntityType.TNT) {
|
||||
Region r = Region.getRegion(event.getLocation());
|
||||
if (hasTimer(r)) {
|
||||
getTimer(r).onTntSpawn();
|
||||
@@ -67,7 +67,7 @@ public class LoadtimerListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
if (!getTimers().isEmpty() && event.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
|
||||
if (!getTimers().isEmpty() && event.getEntityType() == EntityType.TNT) {
|
||||
Region r = Region.getRegion(event.getLocation());
|
||||
if (hasTimer(r)) {
|
||||
getTimer(r).onTntExplode(event);
|
||||
|
||||
+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
|
||||
|
||||
+11
-5
@@ -24,7 +24,6 @@ import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.FreezeMode;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -32,6 +31,7 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.type.NoteBlock;
|
||||
import org.bukkit.block.data.type.Switch;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -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,9 +59,11 @@ 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() == TrickyTrialsWrapper.impl.getTntEntityType()) {
|
||||
if (e.getEntityType() == EntityType.TNT) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
e.getLocation().getBlock().setType(Material.TNT, false);
|
||||
}, 1L);
|
||||
@@ -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);
|
||||
|
||||
+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)
|
||||
|
||||
+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
|
||||
|
||||
@@ -75,7 +75,8 @@ 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();
|
||||
});
|
||||
|
||||
|
||||
+3
-3
@@ -26,10 +26,10 @@ import de.steamwar.bausystem.features.script.lua.SteamWarGlobalLuaPlugin;
|
||||
import de.steamwar.bausystem.features.script.lua.libs.StorageLib;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.core.SWPlayer;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -141,7 +141,7 @@ public class EventListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
||||
if (event.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType()) {
|
||||
if (event.getEntityType() != EntityType.TNT) {
|
||||
return;
|
||||
}
|
||||
Region tntRegion = Region.getRegion(event.getLocation());
|
||||
@@ -156,7 +156,7 @@ public class EventListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
if (event.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType()) {
|
||||
if (event.getEntityType() != EntityType.TNT) {
|
||||
return;
|
||||
}
|
||||
Region tntRegion = Region.getRegion(event.getLocation());
|
||||
|
||||
+14
-6
@@ -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);
|
||||
|
||||
|
||||
+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));
|
||||
|
||||
+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());
|
||||
|
||||
+8
-8
@@ -69,7 +69,7 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Base Tick
|
||||
int baseTicks = simulatorGroup.getBaseTick();
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
@@ -83,7 +83,7 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
});
|
||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||
inventory.setItem(18, baseTick);
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(baseTicks > 0 ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
simulatorGroup.changeBaseTicks(-baseTicks);
|
||||
} else {
|
||||
@@ -163,7 +163,7 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
}
|
||||
|
||||
//Pos X
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(15, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
@@ -177,13 +177,13 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).setItem(Material.PAPER).open();
|
||||
}));
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Y
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(16, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
@@ -197,13 +197,13 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).setItem(Material.PAPER).open();
|
||||
}));
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
|
||||
//Pos Z
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(17, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
@@ -217,7 +217,7 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).setItem(Material.PAPER).open();
|
||||
}));
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
+4
-4
@@ -149,13 +149,13 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
Supplier<Integer> getter = observerPhase::getTickOffset;
|
||||
Consumer<Integer> setter = observerPhase::setTickOffset;
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
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)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||
observer,
|
||||
new SWItem(SWItem.getDye(getter.get() > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
||||
new SWItem(getter.get() > min ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
setter.accept(Math.max(min, getter.get() - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -169,13 +169,13 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
@Override
|
||||
public SWItem[] lastColumn() {
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
addNewPhase(clickType.isShiftClick());
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||
new SWItem(Material.QUARTZ, "§eObserver§8:§a New Phase", clickType -> {
|
||||
addNewPhase(false);
|
||||
}).setCustomModelData(CMDs.Simulator.NEW_PHASE),
|
||||
new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||
new SWItem(Material.GRAY_DYE, "§7", clickType -> {
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
};
|
||||
}
|
||||
|
||||
+4
-4
@@ -96,7 +96,7 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
//Tick Offset
|
||||
int offset = observer.getTickOffset();
|
||||
inventory.setItem(10, new SWItem(SWItem.getDye(offset < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(10, new SWItem(offset < max ? Material.LIME_DYE : Material.GRAY_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
observer.setTickOffset(Math.min(max, offset + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -113,7 +113,7 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
||||
inventory.setItem(19, offsetItem);
|
||||
|
||||
inventory.setItem(28, new SWItem(SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(28, new SWItem(offset > min ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
observer.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -121,7 +121,7 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
//Order
|
||||
int order = observer.getOrder();
|
||||
inventory.setItem(13, new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(13, new SWItem(order < SimulatorPhase.ORDER_LIMIT ? Material.LIME_DYE : Material.GRAY_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
observer.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -139,7 +139,7 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
|
||||
inventory.setItem(22, orderItem);
|
||||
|
||||
inventory.setItem(31, new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(31, new SWItem(order > -SimulatorPhase.ORDER_LIMIT ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
observer.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
|
||||
+8
-8
@@ -67,7 +67,7 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Base Tick
|
||||
int baseTicks = observer.getBaseTick();
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
observer.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -82,7 +82,7 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
});
|
||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||
inventory.setItem(18, baseTick);
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(baseTicks > 0 ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
observer.changeBaseTicks(-baseTicks);
|
||||
@@ -93,7 +93,7 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos X
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(15, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
observer.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -105,14 +105,14 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
observer.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Y
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(16, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
observer.move(0, clickType.isShiftClick() ? 5 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -124,14 +124,14 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
observer.move(0, clickType.isShiftClick() ? -5 : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Z
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(17, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
observer.move(0, 0, clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -143,7 +143,7 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
observer.move(0, 0, clickType.isShiftClick() ? -5 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
|
||||
+4
-4
@@ -164,13 +164,13 @@ 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[]{
|
||||
new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
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)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||
redstone,
|
||||
new SWItem(SWItem.getDye(getter.get() > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
||||
new SWItem(getter.get() > min ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
setter.accept(Math.max(min, getter.get() - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -184,13 +184,13 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
||||
@Override
|
||||
public SWItem[] lastColumn() {
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
addNewPhase(clickType.isShiftClick());
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||
new SWItem(Material.REDSTONE, "§eRedstone§8:§a New Phase", clickType -> {
|
||||
addNewPhase(false);
|
||||
}).setCustomModelData(CMDs.Simulator.NEW_PHASE),
|
||||
new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||
new SWItem(Material.GRAY_DYE, "§7", clickType -> {
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
};
|
||||
}
|
||||
|
||||
+6
-6
@@ -97,7 +97,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
//Tick Offset
|
||||
int offset = redstone.getTickOffset();
|
||||
inventory.setItem(10, new SWItem(SWItem.getDye(offset < maxOffset ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(10, new SWItem(offset < maxOffset ? Material.LIME_DYE : Material.GRAY_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
redstone.setTickOffset(Math.min(maxOffset, offset + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -114,7 +114,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
||||
inventory.setItem(19, offsetItem);
|
||||
|
||||
inventory.setItem(28, new SWItem(SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(28, new SWItem(offset > min ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
redstone.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -122,7 +122,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
//Lifetime
|
||||
int lifetime = redstone.getLifetime();
|
||||
inventory.setItem(11, new SWItem(SWItem.getDye(lifetime < maxLifetime ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(11, new SWItem(lifetime < maxLifetime ? Material.LIME_DYE : Material.GRAY_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
redstone.setLifetime(Math.min(maxLifetime, lifetime + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -139,7 +139,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64)));
|
||||
inventory.setItem(20, lifetimeItem);
|
||||
|
||||
inventory.setItem(29, new SWItem(SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(29, new SWItem(lifetime > 0 ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
redstone.setLifetime(Math.max(0, lifetime - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -147,7 +147,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
//Order
|
||||
int order = redstone.getOrder();
|
||||
inventory.setItem(13, new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(13, new SWItem(order < SimulatorPhase.ORDER_LIMIT ? Material.LIME_DYE : Material.GRAY_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
redstone.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -165,7 +165,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
|
||||
inventory.setItem(22, orderItem);
|
||||
|
||||
inventory.setItem(31, new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(31, new SWItem(order > -SimulatorPhase.ORDER_LIMIT ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
redstone.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
|
||||
+8
-8
@@ -66,7 +66,7 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Base Tick
|
||||
int baseTicks = redstone.getBaseTick();
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
redstone.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -81,7 +81,7 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
});
|
||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||
inventory.setItem(18, baseTick);
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(baseTicks > 0 ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
redstone.changeBaseTicks(-baseTicks);
|
||||
@@ -92,7 +92,7 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos X
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(15, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
redstone.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -104,14 +104,14 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
redstone.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Y
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(16, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
redstone.move(0, clickType.isShiftClick() ? 5 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -123,14 +123,14 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
redstone.move(0, clickType.isShiftClick() ? -5 : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Z
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(17, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
redstone.move(0, 0, clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -142,7 +142,7 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
redstone.move(0, 0, clickType.isShiftClick() ? -5 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
|
||||
+6
-6
@@ -66,37 +66,37 @@ public class SimulatorSettingsGui extends SimulatorBaseGui {
|
||||
}));
|
||||
|
||||
//Pos X
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(15, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulator.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
|
||||
}));
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulator.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Y
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(16, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulator.move(0, clickType.isShiftClick() ? 5 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
|
||||
}));
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulator.move(0, clickType.isShiftClick() ? -5 : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Z
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(17, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulator.move(0, 0, clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
|
||||
}));
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulator.move(0, 0, clickType.isShiftClick() ? -5 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
+4
-4
@@ -134,13 +134,13 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
tnt.getItemStack().setAmount(Math.min(tntSetting.getCount(), 64));
|
||||
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSetting.setCount(tntSetting.getCount() + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||
tnt,
|
||||
new SWItem(SWItem.getDye(tntSetting.getCount() > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
||||
new SWItem(tntSetting.getCount() > 1 ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSetting.setCount(Math.max(1, tntSetting.getCount() - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -154,13 +154,13 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
@Override
|
||||
public SWItem[] lastColumn() {
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
addNewPhase(clickType.isShiftClick());
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||
new SWItem(Material.GUNPOWDER, "§eTNT§8:§a New Phase", clickType -> {
|
||||
addNewPhase(false);
|
||||
}).setCustomModelData(CMDs.Simulator.NEW_PHASE),
|
||||
new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||
new SWItem(Material.GRAY_DYE, "§7", clickType -> {
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
};
|
||||
}
|
||||
|
||||
+8
-8
@@ -77,7 +77,7 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
//Count
|
||||
int count = tnt.getCount();
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.setCount(count + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -94,7 +94,7 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
countItem.getItemStack().setAmount(Math.max(1, Math.min(count, 64)));
|
||||
inventory.setItem(18, countItem);
|
||||
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(count > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(count > 1 ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.setCount(Math.max(1, count - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -102,7 +102,7 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
//Tick Offset
|
||||
int offset = tnt.getTickOffset();
|
||||
inventory.setItem(10, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(10, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.setTickOffset(offset + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -119,7 +119,7 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
||||
inventory.setItem(19, offsetItem);
|
||||
|
||||
inventory.setItem(28, new SWItem(SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(28, new SWItem(offset > 0 ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.setTickOffset(Math.max(0, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -127,7 +127,7 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
//Lifetime
|
||||
int lifetime = tnt.getLifetime();
|
||||
inventory.setItem(11, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(11, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.setLifetime(lifetime + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -144,7 +144,7 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64)));
|
||||
inventory.setItem(20, lifetimeItem);
|
||||
|
||||
inventory.setItem(29, new SWItem(SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(29, new SWItem(lifetime > 0 ? Material.GRAY_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.setLifetime(Math.max(1, lifetime - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -152,7 +152,7 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
//Order
|
||||
int order = tnt.getOrder();
|
||||
inventory.setItem(13, new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(13, new SWItem(order < SimulatorPhase.ORDER_LIMIT ? Material.LIME_DYE : Material.GRAY_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -170,7 +170,7 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
|
||||
inventory.setItem(22, orderItem);
|
||||
|
||||
inventory.setItem(31, new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(31, new SWItem(order > -SimulatorPhase.ORDER_LIMIT ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
|
||||
+8
-8
@@ -75,7 +75,7 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Base Tick
|
||||
int baseTicks = tnt.getBaseTick();
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -90,7 +90,7 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
});
|
||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||
inventory.setItem(18, baseTick);
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(baseTicks > 0 ? Material.RED_DYE : Material.GRAY_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
tnt.changeBaseTicks(-baseTicks);
|
||||
@@ -138,7 +138,7 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
inventory.setItem(30, positivXItem);
|
||||
|
||||
// Pos X
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
inventory.setItem(15, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.move(clickType.isShiftClick() ? 0.0625 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -150,14 +150,14 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.move(clickType.isShiftClick() ? -0.0625 : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
// Pos Y
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
inventory.setItem(16, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.move(0, clickType.isShiftClick() ? 0.0625 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -169,14 +169,14 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.move(0, clickType.isShiftClick() ? -0.0625 : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
// Pos Z
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
inventory.setItem(17, new SWItem(Material.LIME_DYE, "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.move(0, 0, clickType.isShiftClick() ? 0.0625 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
@@ -188,7 +188,7 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(Material.RED_DYE, "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tnt.move(0, 0, clickType.isShiftClick() ? -0.0625 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
|
||||
+3
-2
@@ -23,6 +23,7 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
@@ -51,14 +52,14 @@ public abstract class SimulatorPageGui<T> extends SimulatorBaseGui {
|
||||
headerAndFooter();
|
||||
page = Math.min(page, maxPage());
|
||||
|
||||
inventory.setItem(size - 9, new SWItem(SWItem.getDye(page > 0 ? 10 : 8), page > 0 ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(page > 0 ? "SWLISINV_PREVIOUS_PAGE_ACTIVE" : "SWLISINV_PREVIOUS_PAGE_INACTIVE", player), clickType -> {
|
||||
inventory.setItem(size - 9, new SWItem(page > 0 ? Material.LIME_DYE : Material.GRAY_DYE, page > 0 ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(page > 0 ? "SWLISINV_PREVIOUS_PAGE_ACTIVE" : "SWLISINV_PREVIOUS_PAGE_INACTIVE", player), clickType -> {
|
||||
if (page > 0) {
|
||||
page--;
|
||||
open();
|
||||
}
|
||||
}).setCustomModelData(CMDs.PREVIOUS_PAGE));
|
||||
boolean hasNext = page < maxPage() - (data.size() % (size - 18) == 0 ? 1 : 0);
|
||||
inventory.setItem(size - 1, new SWItem(SWItem.getDye(hasNext ? 10 : 8), hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
|
||||
inventory.setItem(size - 1, new SWItem(hasNext ? Material.LIME_DYE : Material.GRAY_DYE, hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
|
||||
if (hasNext) {
|
||||
page++;
|
||||
open();
|
||||
|
||||
+3
-2
@@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
@@ -51,14 +52,14 @@ public abstract class SimulatorScrollGui<T> extends SimulatorBaseGui {
|
||||
headerAndFooter();
|
||||
scroll = maxScroll();
|
||||
|
||||
inventory.setItem(size - 9, new SWItem(SWItem.getDye(scroll > 0 ? 10 : 8), scroll > 0 ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(scroll > 0 ? "SWLISINV_PREVIOUS_PAGE_ACTIVE" : "SWLISINV_PREVIOUS_PAGE_INACTIVE", player), clickType -> {
|
||||
inventory.setItem(size - 9, new SWItem(scroll > 0 ? Material.LIME_DYE : Material.GRAY_DYE, scroll > 0 ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(scroll > 0 ? "SWLISINV_PREVIOUS_PAGE_ACTIVE" : "SWLISINV_PREVIOUS_PAGE_INACTIVE", player), clickType -> {
|
||||
if (scroll > 0) {
|
||||
scroll = Math.max(0, scroll - 9);
|
||||
open();
|
||||
}
|
||||
}).setCustomModelData(CMDs.PREVIOUS_PAGE));
|
||||
boolean hasNext = (data.size() + 1) - scroll > 9;
|
||||
inventory.setItem(size - 1, new SWItem(SWItem.getDye(hasNext ? 10 : 8), hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
|
||||
inventory.setItem(size - 1, new SWItem(hasNext ? Material.LIME_DYE : Material.GRAY_DYE, hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
|
||||
if (hasNext) {
|
||||
scroll = Math.min(scroll + 9, data.size() + 1 - 9);
|
||||
open();
|
||||
|
||||
+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 -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+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
-3
@@ -23,7 +23,6 @@ import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket;
|
||||
import org.bukkit.*;
|
||||
@@ -76,8 +75,8 @@ public class SmartPlaceListener implements Listener {
|
||||
|
||||
IGNORED.add(Material.TNT);
|
||||
IGNORED.add(Material.REDSTONE_ORE);
|
||||
IGNORED.add(SWItem.getMaterial("BEEHIVE"));
|
||||
IGNORED.add(SWItem.getMaterial("SEA_PICKLE"));
|
||||
IGNORED.add(Material.BEEHIVE);
|
||||
IGNORED.add(Material.SEA_PICKLE);
|
||||
IGNORED.remove(Material.STONE);
|
||||
IGNORED.remove(Material.BARRIER);
|
||||
}
|
||||
|
||||
+1
-2
@@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.team.boundary;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.core.TrickyParticleWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Particle;
|
||||
@@ -53,7 +52,7 @@ public class BoundaryViewer implements Listener {
|
||||
}
|
||||
|
||||
private void showRegion(Region region, Player player) {
|
||||
drawCuboid(player, TrickyParticleWrapper.impl.getVillagerHappy(), region.getArea().getMinPoint(false), region.getArea().getMaxPoint(false));
|
||||
drawCuboid(player, Particle.HAPPY_VILLAGER, region.getArea().getMinPoint(false), region.getArea().getMaxPoint(false));
|
||||
if (!region.getTestblockArea().isEmpty()) {
|
||||
drawCuboid(player, Particle.END_ROD, region.getTestblockArea().getMinPoint(true), region.getTestblockArea().getMaxPoint(true));
|
||||
}
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
|
||||
BauSystem.MESSAGE.sendPrefixless("TECHHIDER_ON", player, ChatMessageType.ACTION_BAR);
|
||||
}
|
||||
region.getBuildArea().forEachChunk((x, z) -> {
|
||||
CraftbukkitWrapper.impl.sendChunk(player, x, z);
|
||||
CraftbukkitWrapper.sendChunk(player, x, z);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+5
-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,9 @@ public class TraceManager implements Listener {
|
||||
.map(Map.Entry::getKey)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (traceId == null) throw new RuntimeException("Trace not found while trying to remove see (c978eb98-b0b2-4009-91d8-acfa34e2831a)");
|
||||
if (traceId == null) {
|
||||
throw new RuntimeException("Trace not found while trying to remove see (c978eb98-b0b2-4009-91d8-acfa34e2831a)");
|
||||
}
|
||||
traces.remove(traceId);
|
||||
trace.hide();
|
||||
trace.getRecordsSaveFile().delete();
|
||||
|
||||
+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());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -147,6 +147,6 @@ public class NoClipCommand extends SWCommand implements Listener {
|
||||
}
|
||||
|
||||
private static void pseudoGameMode(Player player, GameMode gameMode) {
|
||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), gameMode));
|
||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), gameMode));
|
||||
}
|
||||
}
|
||||
+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;
|
||||
|
||||
+11
-7
@@ -42,34 +42,38 @@ public class AFKStopperListener implements Listener {
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (currentTime - lastMovementTime > 10 * 60000) { // 10 Minutes
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
p.kickPlayer(BauSystem.MESSAGE.parse("AFK_KICK_MESSAGE", p));
|
||||
} else if(currentTime - lastMovementTime > 9*60000)
|
||||
}
|
||||
} else if (currentTime - lastMovementTime > 9 * 60000) {
|
||||
BauSystem.MESSAGE.broadcast("AFK_WARNING_MESSAGE");
|
||||
}
|
||||
}, 1200, 1200); //every minute
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Location to = event.getTo();
|
||||
if (to == null)
|
||||
return;
|
||||
if (to == null) return;
|
||||
|
||||
Location from = event.getFrom();
|
||||
if (from.getPitch() != to.getPitch() || from.getYaw() != to.getYaw())
|
||||
if (from.getPitch() != to.getPitch() || from.getYaw() != to.getYaw()) {
|
||||
lastMovementTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST) //Potential fix for potential race condition with WE axe spontaneously not working
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
//Potential fix for potential race condition with WE axe spontaneously not working
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
event.getPlayer().setOp(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer())))
|
||||
if (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer()))) {
|
||||
CheckpointUtils.freeze();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCRIUWakeup(CRIUWakeupEvent event) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+10
-11
@@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.techhider.TechHider;
|
||||
@@ -71,18 +70,18 @@ public class SpectatorListener implements Listener {
|
||||
materials.add(value);
|
||||
}
|
||||
}
|
||||
materials.add(SWItem.getMaterial("SCULK_SENSOR"));
|
||||
materials.add(SWItem.getMaterial("CALIBRATED_SCULK_SENSOR"));
|
||||
materials.add(SWItem.getMaterial("SCULK_SHRIEKER"));
|
||||
materials.add(SWItem.getMaterial("AMETHYST_BLOCK"));
|
||||
materials.add(SWItem.getMaterial("AMETHYST_CLUSTER"));
|
||||
materials.add(SWItem.getMaterial("SMALL_AMETHYST_BUG"));
|
||||
materials.add(SWItem.getMaterial("MEDIUM_AMETHYST_BUG"));
|
||||
materials.add(SWItem.getMaterial("LARGE_AMETHYST_BUG"));
|
||||
materials.add(Material.SCULK_SENSOR);
|
||||
materials.add(Material.CALIBRATED_SCULK_SENSOR);
|
||||
materials.add(Material.SCULK_SHRIEKER);
|
||||
materials.add(Material.AMETHYST_BLOCK);
|
||||
materials.add(Material.AMETHYST_CLUSTER);
|
||||
materials.add(Material.SMALL_AMETHYST_BUD);
|
||||
materials.add(Material.MEDIUM_AMETHYST_BUD);
|
||||
materials.add(Material.LARGE_AMETHYST_BUD);
|
||||
materials.add(Material.TRIPWIRE_HOOK);
|
||||
materials.add(Material.TRIPWIRE);
|
||||
materials.add(Material.DAYLIGHT_DETECTOR);
|
||||
materials.add(SWItem.getMaterial("LIGHTNING_ROD"));
|
||||
materials.add(Material.LIGHTNING_ROD);
|
||||
materials.add(Material.PISTON);
|
||||
materials.add(Material.PISTON_HEAD);
|
||||
materials.add(Material.MOVING_PISTON);
|
||||
@@ -96,7 +95,7 @@ public class SpectatorListener implements Listener {
|
||||
materials.add(Material.ACTIVATOR_RAIL);
|
||||
materials.add(Material.TNT);
|
||||
materials.add(Material.REDSTONE_ORE);
|
||||
materials.add(SWItem.getMaterial("SCAFFOLDING"));
|
||||
materials.add(Material.SCAFFOLDING);
|
||||
materials.add(Material.WATER);
|
||||
materials.remove(Material.BARRIER);
|
||||
materials.remove(Material.STONE);
|
||||
|
||||
+1
@@ -51,6 +51,7 @@ public class ColorReplaceCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private Set<String> types = new HashSet<>();
|
||||
|
||||
{
|
||||
WorldEditListener.addOtherCommand("//colorreplace");
|
||||
WorldEditListener.addOtherCommand("//cr");
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.techhider.TechHiderCommand;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.PlayerMovementWrapper;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.CraftbukkitWrapper;
|
||||
@@ -32,8 +31,10 @@ import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.techhider.TechHider;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -91,24 +92,31 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
||||
BauSystem.MESSAGE.sendPrefixless("XRAY_ON", player, ChatMessageType.ACTION_BAR);
|
||||
}
|
||||
region.getBuildArea().forEachChunk((x, z) -> {
|
||||
CraftbukkitWrapper.impl.sendChunk(player, x, z);
|
||||
CraftbukkitWrapper.sendChunk(player, x, z);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
BiFunction<Player, Object, Object> positionSetter = (player, o) -> {
|
||||
BiFunction<Player, ServerboundMovePlayerPacket, Object> positionSetter = (player, packet) -> {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (hidden.containsKey(region) && hidden.get(region).contains(player)) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
PlayerMovementWrapper.impl.setPosition(player, o);
|
||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||
if (packet.hasPos) {
|
||||
serverPlayer.setPosRaw(packet.x, packet.y, packet.z);
|
||||
}
|
||||
if (packet.hasRot) {
|
||||
serverPlayer.setXRot(packet.xRot);
|
||||
serverPlayer.setYRot(packet.yRot);
|
||||
}
|
||||
}, 0);
|
||||
return null;
|
||||
}
|
||||
return o;
|
||||
return packet;
|
||||
};
|
||||
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Pos.class, positionSetter);
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.PosRot.class, positionSetter);
|
||||
TinyProtocol.instance.addTypedFilter(ServerboundMovePlayerPacket.Pos.class, positionSetter);
|
||||
TinyProtocol.instance.addTypedFilter(ServerboundMovePlayerPacket.PosRot.class, positionSetter);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.core.BountifulWrapper;
|
||||
import de.steamwar.entity.REntity;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerMovementWrapper {
|
||||
Class<?> teleportPacket = REntity.teleportPacket;
|
||||
Reflection.Field<Integer> teleportEntity = REntity.teleportEntity;
|
||||
BountifulWrapper.PositionSetter teleportPosition = REntity.teleportPosition;
|
||||
|
||||
public static final PlayerMovementWrapper impl = new PlayerMovementWrapper();
|
||||
|
||||
public void setPosition(Player player, Object object) {
|
||||
ServerboundMovePlayerPacket packetPlayInFlying = ((ServerboundMovePlayerPacket) object);
|
||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||
if (packetPlayInFlying.hasPos) {
|
||||
serverPlayer.setPosRaw(packetPlayInFlying.x, packetPlayInFlying.y, packetPlayInFlying.z);
|
||||
}
|
||||
if (packetPlayInFlying.hasRot) {
|
||||
serverPlayer.setXRot(packetPlayInFlying.xRot);
|
||||
serverPlayer.setYRot(packetPlayInFlying.yRot);
|
||||
}
|
||||
}
|
||||
|
||||
public Object convertToOut(Player player, Object object) {
|
||||
return object;
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,9 @@ public class RayTraceUtils {
|
||||
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;
|
||||
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()
|
||||
```
|
||||
@@ -31,15 +31,6 @@ dependencies {
|
||||
implementation(project(":BauSystem:BauSystem_Main"))
|
||||
}
|
||||
|
||||
tasks.register<DevServer>("DevBau20") {
|
||||
group = "run"
|
||||
description = "Run a 1.20 Dev Bau"
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":BauSystem:shadowJar")
|
||||
dependsOn(":SchematicSystem:shadowJar")
|
||||
template = "Bau20"
|
||||
}
|
||||
|
||||
tasks.register<DevServer>("DevBau21") {
|
||||
group = "run"
|
||||
description = "Run a 1.21 Dev Bau"
|
||||
|
||||
+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()),
|
||||
|
||||
@@ -12,7 +12,8 @@ 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") {
|
||||
|
||||
@@ -10,7 +10,8 @@ import de.steamwar.db.useDb
|
||||
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(
|
||||
|
||||
@@ -13,7 +13,8 @@ import java.io.File
|
||||
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!")
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.github.ajalt.clikt.core.Context
|
||||
import com.github.ajalt.clikt.parameters.arguments.argument
|
||||
import com.github.ajalt.clikt.parameters.arguments.help
|
||||
import com.github.ajalt.clikt.parameters.arguments.multiple
|
||||
import com.github.ajalt.clikt.parameters.options.default
|
||||
import com.github.ajalt.clikt.parameters.options.defaultLazy
|
||||
import com.github.ajalt.clikt.parameters.options.flag
|
||||
import com.github.ajalt.clikt.parameters.options.help
|
||||
@@ -47,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
|
||||
|
||||
@@ -74,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()) {
|
||||
@@ -109,7 +118,8 @@ class DevCommand : CliktCommand("dev") {
|
||||
|
||||
try {
|
||||
devFile.delete()
|
||||
} catch (_: Exception) { /* ignored */ }
|
||||
} catch (_: Exception) { /* ignored */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,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"
|
||||
@@ -163,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,
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -4,6 +4,9 @@ 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"
|
||||
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%",
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.jetbrains.exposed.v1.jdbc.JdbcTransaction
|
||||
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
|
||||
import java.io.File
|
||||
import java.sql.ResultSet
|
||||
import java.util.Properties
|
||||
import java.util.*
|
||||
|
||||
object Database {
|
||||
lateinit var host: String
|
||||
@@ -49,7 +49,8 @@ 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 }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
|
||||
package de.steamwar.command;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
public @interface CommandMetaData {
|
||||
|
||||
@@ -30,7 +33,9 @@ public @interface CommandMetaData {
|
||||
@Target(ElementType.ANNOTATION_TYPE)
|
||||
@interface Method {
|
||||
Class<?>[] value();
|
||||
|
||||
int minParameterCount() default 0;
|
||||
|
||||
int maxParameterCount() default Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@@ -41,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) {
|
||||
|
||||
@@ -21,7 +21,6 @@ package de.steamwar.command;
|
||||
|
||||
import de.steamwar.command.dto.ExecutionIdentifier;
|
||||
import de.steamwar.command.dto.TestSWCommand;
|
||||
import de.steamwar.command.dto.TestTypeMapper;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.lang.annotation.*;
|
||||
@Repeatable(PluginCheck.PluginChecks.class)
|
||||
public @interface PluginCheck {
|
||||
Has has() default Has.THIS;
|
||||
|
||||
String value();
|
||||
|
||||
enum Has {
|
||||
|
||||
@@ -73,5 +73,6 @@ public abstract class PacketHandler {
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
protected @interface Handler {}
|
||||
protected @interface Handler {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,12 @@
|
||||
package de.steamwar.network;
|
||||
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import de.steamwar.network.packets.client.*;
|
||||
import de.steamwar.network.packets.common.*;
|
||||
import de.steamwar.network.packets.client.ExecuteCommandPacket;
|
||||
import de.steamwar.network.packets.client.ImALobbyPacket;
|
||||
import de.steamwar.network.packets.client.InventoryCallbackPacket;
|
||||
import de.steamwar.network.packets.client.PrepareSchemPacket;
|
||||
import de.steamwar.network.packets.common.FightEndsPacket;
|
||||
import de.steamwar.network.packets.common.FightInfoPacket;
|
||||
import de.steamwar.network.packets.server.*;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
@@ -30,7 +34,7 @@ import java.lang.reflect.Parameter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.RandomGenerator.*;
|
||||
import static de.steamwar.RandomGenerator.generateRandom;
|
||||
|
||||
public class AllPackets {
|
||||
|
||||
|
||||
@@ -25,8 +25,9 @@ import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
|
||||
public class PacketHandlerTest {
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ package de.steamwar.network;
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
public class PacketTest {
|
||||
|
||||
|
||||
@@ -22,12 +22,14 @@ package de.steamwar;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class ImplementationProvider {
|
||||
private ImplementationProvider() {}
|
||||
private ImplementationProvider() {
|
||||
}
|
||||
|
||||
public static <T> T getImpl(String className) {
|
||||
try {
|
||||
return (T) Class.forName(className).getDeclaredConstructor().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) {
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException |
|
||||
ClassNotFoundException e) {
|
||||
throw new SecurityException("Could not load implementation", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ class AuditLog(id: EntityID<Int>): IntEntity(id) {
|
||||
actor: SteamwarUser,
|
||||
actionType: Type,
|
||||
text: String = ""
|
||||
) = useDb {
|
||||
) =
|
||||
useDb {
|
||||
new {
|
||||
this.time = Instant.now()
|
||||
this.server = serverName
|
||||
@@ -58,13 +59,16 @@ class AuditLog(id: EntityID<Int>): IntEntity(id) {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun createJoin(jointServerName: String, serverOwner: SteamwarUser?, joinedPlayer: SteamwarUser) = create(jointServerName, serverOwner, joinedPlayer, Type.JOIN)
|
||||
fun createJoin(jointServerName: String, serverOwner: SteamwarUser?, joinedPlayer: SteamwarUser) =
|
||||
create(jointServerName, serverOwner, joinedPlayer, Type.JOIN)
|
||||
|
||||
@JvmStatic
|
||||
fun createLeave(leftServerName: String, serverOwner: SteamwarUser?, joinedPlayer: SteamwarUser) = create(leftServerName, serverOwner, joinedPlayer, Type.LEAVE)
|
||||
fun createLeave(leftServerName: String, serverOwner: SteamwarUser?, joinedPlayer: SteamwarUser) =
|
||||
create(leftServerName, serverOwner, joinedPlayer, Type.LEAVE)
|
||||
|
||||
@JvmStatic
|
||||
fun createCommand(serverName: String, serverOwner: SteamwarUser?, player: SteamwarUser?, command: String) = player?.let { create(serverName, serverOwner, it, Type.COMMAND, command) }
|
||||
fun createCommand(serverName: String, serverOwner: SteamwarUser?, player: SteamwarUser?, command: String) =
|
||||
player?.let { create(serverName, serverOwner, it, Type.COMMAND, command) }
|
||||
|
||||
@JvmStatic
|
||||
fun createSensitiveCommand(
|
||||
@@ -72,13 +76,16 @@ class AuditLog(id: EntityID<Int>): IntEntity(id) {
|
||||
serverOwner: SteamwarUser?,
|
||||
player: SteamwarUser?,
|
||||
command: String
|
||||
) = player?.let { create(serverName, serverOwner, it, Type.SENSITIVE_COMMAND, command) }
|
||||
) =
|
||||
player?.let { create(serverName, serverOwner, it, Type.SENSITIVE_COMMAND, command) }
|
||||
|
||||
@JvmStatic
|
||||
fun createChat(serverName: String, serverOwner: SteamwarUser?, chatter: SteamwarUser, chat: String) = create(serverName, serverOwner, chatter, Type.CHAT, chat)
|
||||
fun createChat(serverName: String, serverOwner: SteamwarUser?, chatter: SteamwarUser, chat: String) =
|
||||
create(serverName, serverOwner, chatter, Type.CHAT, chat)
|
||||
|
||||
@JvmStatic
|
||||
fun createGuiOpen(serverName: String, serverOwner: SteamwarUser?, player: SteamwarUser, guiName: String) = create(serverName, serverOwner, player, Type.GUI_OPEN, guiName)
|
||||
fun createGuiOpen(serverName: String, serverOwner: SteamwarUser?, player: SteamwarUser, guiName: String) =
|
||||
create(serverName, serverOwner, player, Type.GUI_OPEN, guiName)
|
||||
|
||||
@JvmStatic
|
||||
fun createGuiClick(
|
||||
@@ -89,7 +96,8 @@ class AuditLog(id: EntityID<Int>): IntEntity(id) {
|
||||
clickType: String,
|
||||
slot: Int,
|
||||
itemName: String
|
||||
) = create(
|
||||
) =
|
||||
create(
|
||||
serverName,
|
||||
serverOwner,
|
||||
player,
|
||||
@@ -98,7 +106,8 @@ class AuditLog(id: EntityID<Int>): IntEntity(id) {
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
fun createGuiClose(serverName: String, serverOwner: SteamwarUser?, player: SteamwarUser, guiName: String) = create(serverName, serverOwner, player, Type.GUI_CLOSE, guiName)
|
||||
fun createGuiClose(serverName: String, serverOwner: SteamwarUser?, player: SteamwarUser, guiName: String) =
|
||||
create(serverName, serverOwner, player, Type.GUI_CLOSE, guiName)
|
||||
}
|
||||
|
||||
var time by AuditLogTable.time
|
||||
|
||||
@@ -48,17 +48,20 @@ class BannedUserIPs(id: EntityID<CompositeID>): CompositeEntity(id) {
|
||||
companion object : CompositeEntityClass<BannedUserIPs>(BannedUserIPsTable) {
|
||||
|
||||
@JvmStatic
|
||||
fun get(userId: Int) = useDb {
|
||||
fun get(userId: Int) =
|
||||
useDb {
|
||||
find { BannedUserIPsTable.userId eq userId }.toList()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun get(ip: String) = useDb {
|
||||
fun get(ip: String) =
|
||||
useDb {
|
||||
find { BannedUserIPsTable.ip eq ip }.toList()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun banIP(userId: Int, ip: String) = useDb {
|
||||
fun banIP(userId: Int, ip: String) =
|
||||
useDb {
|
||||
BannedUserIPsTable.insertIgnore {
|
||||
it[BannedUserIPsTable.userId] = userId
|
||||
it[BannedUserIPsTable.ip] = ip
|
||||
@@ -67,7 +70,8 @@ class BannedUserIPs(id: EntityID<CompositeID>): CompositeEntity(id) {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun unbanIPs(userId: Int) = useDb {
|
||||
fun unbanIPs(userId: Int) =
|
||||
useDb {
|
||||
BannedUserIPsTable.deleteWhere { BannedUserIPsTable.userId eq userId }
|
||||
}
|
||||
}
|
||||
@@ -76,7 +80,8 @@ class BannedUserIPs(id: EntityID<CompositeID>): CompositeEntity(id) {
|
||||
val timestamp: Timestamp by BannedUserIPsTable.timestamp.transform({ it.toInstant() }, { Timestamp.from(it) })
|
||||
val ip by BannedUserIPsTable.ip
|
||||
|
||||
fun remove() = useDb {
|
||||
fun remove() =
|
||||
useDb {
|
||||
delete()
|
||||
}
|
||||
}
|
||||
@@ -50,19 +50,24 @@ class BauweltMember(id: EntityID<CompositeID>): CompositeEntity(id) {
|
||||
companion object : CompositeEntityClass<BauweltMember>(BauweltMemberTable) {
|
||||
private val cache = mutableMapOf<Int, BauweltMember>()
|
||||
|
||||
private fun cache(member: BauweltMember) = cache.put(member.memberID, member)
|
||||
private fun cache(member: BauweltMember) =
|
||||
cache.put(member.memberID, member)
|
||||
|
||||
@JvmStatic
|
||||
fun clear() = cache.clear()
|
||||
fun clear() =
|
||||
cache.clear()
|
||||
|
||||
@JvmStatic
|
||||
@Deprecated("Use addMember(ownerId: Int, newMemberId: Int)")
|
||||
fun addMember(ownerId: UUID, newMemberId: UUID) = addMember(SteamwarUser.get(ownerId)!!.id, SteamwarUser.get(newMemberId)!!.id)
|
||||
fun addMember(ownerId: UUID, newMemberId: UUID) =
|
||||
addMember(SteamwarUser.get(ownerId)!!.id, SteamwarUser.get(newMemberId)!!.id)
|
||||
|
||||
@JvmStatic
|
||||
fun addMember(ownerId: Int, newMemberId: Int) = addMember(EntityID(ownerId, SteamwarUserTable), EntityID(newMemberId, SteamwarUserTable))
|
||||
fun addMember(ownerId: Int, newMemberId: Int) =
|
||||
addMember(EntityID(ownerId, SteamwarUserTable), EntityID(newMemberId, SteamwarUserTable))
|
||||
|
||||
fun addMember(ownerId: EntityID<Int>, newMemberId: EntityID<Int>) = useDb {
|
||||
fun addMember(ownerId: EntityID<Int>, newMemberId: EntityID<Int>) =
|
||||
useDb {
|
||||
BauweltMemberTable.insertIgnore {
|
||||
it[bauweltId] = ownerId
|
||||
it[memberId] = newMemberId
|
||||
@@ -74,21 +79,25 @@ class BauweltMember(id: EntityID<CompositeID>): CompositeEntity(id) {
|
||||
|
||||
@JvmStatic
|
||||
@Deprecated("Use getBauMember(bauwelt: Int, member: Int)")
|
||||
fun getBauMember(bauwelt: UUID, member: UUID) = useDb {
|
||||
fun getBauMember(bauwelt: UUID, member: UUID) =
|
||||
useDb {
|
||||
find { (bauweltId eq SteamwarUser.get(bauwelt)!!.id) and (BauweltMemberTable.memberId eq SteamwarUser.get(member)!!.id) }.firstOrNull()?.also { cache(it) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBauMember(bauwelt: Int, member: Int) = useDb {
|
||||
fun getBauMember(bauwelt: Int, member: Int) =
|
||||
useDb {
|
||||
find { (bauweltId eq bauwelt) and (BauweltMemberTable.memberId eq member) }.firstOrNull()?.also { cache(it) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@Deprecated("Use getMembers(bauwelt: Int)")
|
||||
fun getMembers(bauwelt: UUID) = getMembers(SteamwarUser.get(bauwelt)!!.id.value)
|
||||
fun getMembers(bauwelt: UUID) =
|
||||
getMembers(SteamwarUser.get(bauwelt)!!.id.value)
|
||||
|
||||
@JvmStatic
|
||||
fun getMembers(bauwelt: Int) = useDb {
|
||||
fun getMembers(bauwelt: Int) =
|
||||
useDb {
|
||||
find { bauweltId eq bauwelt }.toList().also { it.forEach { cache(it) } }
|
||||
}
|
||||
}
|
||||
@@ -119,12 +128,20 @@ class BauweltMember(id: EntityID<CompositeID>): CompositeEntity(id) {
|
||||
world = value
|
||||
}
|
||||
|
||||
fun isBuild() = build
|
||||
fun isSupervisor() = world
|
||||
fun isWorldEdit() = build
|
||||
fun isWorld() = world
|
||||
fun isBuild() =
|
||||
build
|
||||
|
||||
fun remove() = useDb {
|
||||
fun isSupervisor() =
|
||||
world
|
||||
|
||||
fun isWorldEdit() =
|
||||
build
|
||||
|
||||
fun isWorld() =
|
||||
world
|
||||
|
||||
fun remove() =
|
||||
useDb {
|
||||
delete()
|
||||
}
|
||||
}
|
||||
@@ -20,14 +20,10 @@
|
||||
package de.steamwar.sql
|
||||
|
||||
import de.steamwar.sql.internal.useDb
|
||||
import org.jetbrains.exposed.v1.core.ReferenceOption
|
||||
import org.jetbrains.exposed.v1.core.SortOrder
|
||||
import org.jetbrains.exposed.v1.core.and
|
||||
import org.jetbrains.exposed.v1.core.*
|
||||
import org.jetbrains.exposed.v1.core.dao.id.CompositeID
|
||||
import org.jetbrains.exposed.v1.core.dao.id.CompositeIdTable
|
||||
import org.jetbrains.exposed.v1.core.dao.id.EntityID
|
||||
import org.jetbrains.exposed.v1.core.eq
|
||||
import org.jetbrains.exposed.v1.core.neq
|
||||
import org.jetbrains.exposed.v1.dao.CompositeEntity
|
||||
import org.jetbrains.exposed.v1.dao.CompositeEntityClass
|
||||
import org.jetbrains.exposed.v1.javatime.timestamp
|
||||
@@ -58,7 +54,8 @@ object CheckedSchematicTable: CompositeIdTable("CheckedSchematic") {
|
||||
class CheckedSchematic(id: EntityID<CompositeID>) : CompositeEntity(id) {
|
||||
companion object : CompositeEntityClass<CheckedSchematic>(CheckedSchematicTable) {
|
||||
@JvmStatic
|
||||
fun create(node: SchematicNode, validator: Int, startTime: Timestamp, endTime: Timestamp, reason: String, seen: Boolean) = useDb {
|
||||
fun create(node: SchematicNode, validator: Int, startTime: Timestamp, endTime: Timestamp, reason: String, seen: Boolean) =
|
||||
useDb {
|
||||
CheckedSchematicTable.insertIgnore {
|
||||
it[this.nodeId] = node.id
|
||||
it[this.nodeOwner] = EntityID(node.owner, SteamwarUserTable)
|
||||
@@ -73,17 +70,20 @@ class CheckedSchematic(id: EntityID<CompositeID>): CompositeEntity(id) {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getLastDeclinedOfNode(node: Int) = useDb {
|
||||
fun getLastDeclinedOfNode(node: Int) =
|
||||
useDb {
|
||||
find { (CheckedSchematicTable.nodeId eq node) and (CheckedSchematicTable.declineReason neq "Prüfvorgang abgebrochen") }.orderBy(CheckedSchematicTable.endTime to SortOrder.DESC).toList()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun previousChecks(node: SchematicNode) = useDb {
|
||||
fun previousChecks(node: SchematicNode) =
|
||||
useDb {
|
||||
find { (CheckedSchematicTable.nodeId eq node.id) and (CheckedSchematicTable.declineReason neq "") and (CheckedSchematicTable.declineReason neq "Prüfvorgang abgebrochen") }.orderBy(CheckedSchematicTable.endTime to SortOrder.DESC).toList()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getUnseen(owner: SteamwarUser) = useDb {
|
||||
fun getUnseen(owner: SteamwarUser) =
|
||||
useDb {
|
||||
find { (CheckedSchematicTable.nodeOwner eq owner.id) and (CheckedSchematicTable.seen eq false) }.orderBy(CheckedSchematicTable.endTime to SortOrder.DESC).toList()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ class Event(id: EntityID<Int>) : IntEntity(id) {
|
||||
private var current: Event? = null
|
||||
|
||||
@JvmStatic
|
||||
fun get(): Event? = if (current?.now() == true) {
|
||||
fun get(): Event? =
|
||||
if (current?.now() == true) {
|
||||
current
|
||||
} else useDb {
|
||||
find { EventTable.start.lessEq(Instant.now()) and EventTable.end.greater(Instant.now()) }.firstOrNull()
|
||||
@@ -56,10 +57,12 @@ class Event(id: EntityID<Int>) : IntEntity(id) {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getAll() = useDb { all().toList() }
|
||||
fun getAll() =
|
||||
useDb { all().toList() }
|
||||
|
||||
@JvmStatic
|
||||
fun create(name: String, start: Timestamp, end: Timestamp) = useDb {
|
||||
fun create(name: String, start: Timestamp, end: Timestamp) =
|
||||
useDb {
|
||||
EventTable.insertAndGetId {
|
||||
it[this.name] = name
|
||||
it[this.deadline] = start.toInstant()
|
||||
@@ -71,13 +74,16 @@ class Event(id: EntityID<Int>) : IntEntity(id) {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun byId(id: Int) = useDb { findById(id) }
|
||||
fun byId(id: Int) =
|
||||
useDb { findById(id) }
|
||||
|
||||
@JvmStatic
|
||||
fun get(name: String) = useDb { find { EventTable.name eq name }.firstOrNull() }
|
||||
fun get(name: String) =
|
||||
useDb { find { EventTable.name eq name }.firstOrNull() }
|
||||
|
||||
@JvmStatic
|
||||
fun getComing() = useDb { find { EventTable.start greater Instant.now() }.toList() }
|
||||
fun getComing() =
|
||||
useDb { find { EventTable.start greater Instant.now() }.toList() }
|
||||
}
|
||||
|
||||
val eventID by EventTable.id.transform({ EntityID(it, EventTable) }, { it.value })
|
||||
@@ -96,8 +102,11 @@ class Event(id: EntityID<Int>) : IntEntity(id) {
|
||||
var publicSchemsOnly by EventTable.publicsOnly
|
||||
private set
|
||||
|
||||
fun publicSchemsOnly() = publicSchemsOnly
|
||||
fun now() = Instant.now().let { it.isAfter(start.toInstant()) && it.isBefore(end.toInstant()) }
|
||||
fun publicSchemsOnly() =
|
||||
publicSchemsOnly
|
||||
|
||||
fun now() =
|
||||
Instant.now().let { it.isAfter(start.toInstant()) && it.isBefore(end.toInstant()) }
|
||||
|
||||
fun update(
|
||||
name: String,
|
||||
@@ -107,7 +116,8 @@ class Event(id: EntityID<Int>) : IntEntity(id) {
|
||||
schematicType: SchematicType?,
|
||||
maxPlayers: Int,
|
||||
publicSchemsOnly: Boolean
|
||||
) = useDb {
|
||||
) =
|
||||
useDb {
|
||||
this@Event.eventName = name
|
||||
this@Event.deadline = deadline
|
||||
this@Event.start = start
|
||||
@@ -117,5 +127,6 @@ class Event(id: EntityID<Int>) : IntEntity(id) {
|
||||
this@Event.publicSchemsOnly = publicSchemsOnly
|
||||
}
|
||||
|
||||
override fun delete() = useDb { super.delete() }
|
||||
override fun delete() =
|
||||
useDb { super.delete() }
|
||||
}
|
||||
@@ -52,15 +52,18 @@ class EventFight(id: EntityID<Int>) : IntEntity(id), Comparable<EventFight> {
|
||||
@JvmStatic get
|
||||
|
||||
@JvmStatic
|
||||
fun byId(fightId: Int) = useDb { findById(fightId) }
|
||||
fun byId(fightId: Int) =
|
||||
useDb { findById(fightId) }
|
||||
|
||||
@JvmStatic
|
||||
fun byId(group: EventGroup) = useDb {
|
||||
fun byId(group: EventGroup) =
|
||||
useDb {
|
||||
find { EventFightTable.groupId eq group.id }.orderBy(EventFightTable.startTime to SortOrder.DESC).toList()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getLast(group: EventGroup) = useDb {
|
||||
fun getLast(group: EventGroup) =
|
||||
useDb {
|
||||
Optional.ofNullable(
|
||||
find { EventFightTable.groupId eq group.id }.orderBy(EventFightTable.startTime to SortOrder.DESC)
|
||||
.firstOrNull()
|
||||
@@ -68,13 +71,15 @@ class EventFight(id: EntityID<Int>) : IntEntity(id), Comparable<EventFight> {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun loadAllComingFights() = useDb {
|
||||
fun loadAllComingFights() =
|
||||
useDb {
|
||||
fights.clear()
|
||||
fights.addAll(find { EventFightTable.startTime greaterEq Instant.now() }.orderBy(EventFightTable.startTime to SortOrder.ASC))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getEvent(eventId: Int) = useDb {
|
||||
fun getEvent(eventId: Int) =
|
||||
useDb {
|
||||
find { EventFightTable.eventId eq eventId }.orderBy(EventFightTable.startTime to SortOrder.ASC).toList()
|
||||
}
|
||||
|
||||
@@ -111,7 +116,8 @@ class EventFight(id: EntityID<Int>) : IntEntity(id), Comparable<EventFight> {
|
||||
blueTeam: Int,
|
||||
redTeam: Int,
|
||||
spectatePort: Int?
|
||||
) = useDb {
|
||||
) =
|
||||
useDb {
|
||||
get(
|
||||
EventFightTable.insertAndGetId {
|
||||
it[eventId] = EntityID(event, EventTable)
|
||||
@@ -155,16 +161,25 @@ class EventFight(id: EntityID<Int>) : IntEntity(id), Comparable<EventFight> {
|
||||
val losser: Team?
|
||||
get() = useDb { if (ergebnis == 1) Team[teamRed] else if (ergebnis == 2) Team[teamBlue] else null }
|
||||
|
||||
fun setGroup(group: Int?) = useDb { groupId = group?.let { EntityID(it, EventGroupTable) } }
|
||||
fun hasFinished() = fight != null || ergebnis != 0
|
||||
fun setGroup(group: Int?) =
|
||||
useDb { groupId = group?.let { EntityID(it, EventGroupTable) } }
|
||||
|
||||
fun reschedule() = useDb {
|
||||
fun hasFinished() =
|
||||
fight != null || ergebnis != 0
|
||||
|
||||
fun reschedule() =
|
||||
useDb {
|
||||
startTime = Timestamp.from(Instant.now().plusSeconds(30))
|
||||
}
|
||||
|
||||
override fun hashCode() = fightID
|
||||
override fun equals(other: Any?) = other is EventFight && other.fightID == fightID
|
||||
override fun compareTo(other: EventFight): Int = startTime.compareTo(other.startTime)
|
||||
override fun hashCode() =
|
||||
fightID
|
||||
|
||||
override fun equals(other: Any?) =
|
||||
other is EventFight && other.fightID == fightID
|
||||
|
||||
override fun compareTo(other: EventFight): Int =
|
||||
startTime.compareTo(other.startTime)
|
||||
|
||||
fun update(
|
||||
startTime: Timestamp,
|
||||
@@ -173,7 +188,8 @@ class EventFight(id: EntityID<Int>) : IntEntity(id), Comparable<EventFight> {
|
||||
teamBlue: Int,
|
||||
teamRed: Int,
|
||||
spectatePort: Int?
|
||||
) = useDb {
|
||||
) =
|
||||
useDb {
|
||||
this@EventFight.startTime = startTime
|
||||
this@EventFight.spielmodus = spielmodus
|
||||
this@EventFight.map = map
|
||||
@@ -182,7 +198,8 @@ class EventFight(id: EntityID<Int>) : IntEntity(id), Comparable<EventFight> {
|
||||
this@EventFight.spectatePort = spectatePort
|
||||
}
|
||||
|
||||
override fun delete() = useDb {
|
||||
override fun delete() =
|
||||
useDb {
|
||||
super.delete()
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user