Compare commits
10 Commits
BauSystem/
...
BauSystem/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de4f32feb2 | ||
|
|
a3d2d2be1e | ||
|
|
7a000efb93 | ||
|
|
42c9d6d612 | ||
|
|
67c679a20f | ||
|
|
a071d8a1f2 | ||
|
|
7b25bd31fc | ||
|
|
139a2c275c | ||
|
|
aa787b5a25 | ||
|
|
54adc12045 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -16,8 +16,4 @@ bin/
|
||||
.vscode
|
||||
|
||||
# Other
|
||||
lib
|
||||
/WebsiteBackend/data
|
||||
/WebsiteBackend/logs
|
||||
/WebsiteBackend/skins
|
||||
/WebsiteBackend/config.json
|
||||
lib
|
||||
@@ -21,39 +21,41 @@ package de.steamwar.bausystem.utils;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import io.papermc.paper.datacomponent.item.ItemContainerContents;
|
||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundExplodePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundGameEventPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInSetCreativeSlot;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutExplosion;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.PlayerInteractManager;
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.entity.player.PlayerAbilities;
|
||||
import net.minecraft.world.item.component.CustomData;
|
||||
import net.minecraft.world.level.EnumGamemode;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class NMSWrapper21 implements NMSWrapper {
|
||||
|
||||
private static final Reflection.Field<ServerPlayerGameMode> playerInteractManager = Reflection.getField(ServerPlayer.class, null, ServerPlayerGameMode.class);
|
||||
private static final Reflection.Field<PlayerInteractManager> playerInteractManager = Reflection.getField(EntityPlayer.class, null, PlayerInteractManager.class);
|
||||
|
||||
@Override
|
||||
public void setInternalGameMode(Player player, GameMode gameMode) {
|
||||
playerInteractManager.get(((CraftPlayer) player).getHandle()).changeGameModeForPlayer(GameType.byId(gameMode.getValue()), PlayerGameModeChangeEvent.Cause.UNKNOWN, null);
|
||||
playerInteractManager.get(((CraftPlayer) player).getHandle()).a(EnumGamemode.a(gameMode.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlotToItemStack(Player player, Object o) {
|
||||
ClientboundContainerSetSlotPacket packetPlayInSetCreativeSlot = (ClientboundContainerSetSlotPacket) o;
|
||||
int index = packetPlayInSetCreativeSlot.getSlot();
|
||||
PacketPlayInSetCreativeSlot packetPlayInSetCreativeSlot = (PacketPlayInSetCreativeSlot) o;
|
||||
int index = packetPlayInSetCreativeSlot.b();
|
||||
if (index >= 36 && index <= 44) {
|
||||
index -= 36;
|
||||
} else if (index > 44) {
|
||||
@@ -61,23 +63,25 @@ public class NMSWrapper21 implements NMSWrapper {
|
||||
} else if (index <= 8) {
|
||||
index = index - 8 + 36;
|
||||
}
|
||||
player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.getItem()));
|
||||
player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.e()));
|
||||
if (index < 9) player.getInventory().setHeldItemSlot(index);
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
private static final Reflection.Field<ClientboundGameEventPacket.Type> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, ClientboundGameEventPacket.Type.class, 12);
|
||||
private static final Reflection.Field<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
|
||||
|
||||
@Override
|
||||
public void setGameStateChangeReason(Object packet) {
|
||||
gameStateChangeReason.set(packet, ClientboundGameEventPacket.CHANGE_GAME_MODE);
|
||||
gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d);
|
||||
}
|
||||
|
||||
private static final Reflection.Field<PlayerAbilities> playerAbilities = Reflection.getField(EntityHuman.class, null, PlayerAbilities.class);
|
||||
|
||||
@Override
|
||||
public void setPlayerBuildAbilities(Player player) {
|
||||
Abilities abilities = (((CraftPlayer) player).getHandle()).getAbilities();
|
||||
abilities.mayBuild = true;
|
||||
abilities.mayfly = true;
|
||||
PlayerAbilities abilities = playerAbilities.get(((CraftPlayer) player).getHandle());
|
||||
abilities.d = true;
|
||||
abilities.e = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,45 +93,49 @@ public class NMSWrapper21 implements NMSWrapper {
|
||||
|
||||
@Override
|
||||
public boolean checkItemStack(ItemStack item) {
|
||||
ItemContainerContents data = item.getData(DataComponentTypes.CONTAINER);
|
||||
if (data == null) {
|
||||
return false;
|
||||
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound tag = nmsItem.a(DataComponents.b, CustomData.a).c();
|
||||
if (tag.e("BlockEntityTag")) {
|
||||
NBTTagCompound blockTag = tag.p("BlockEntityTag");
|
||||
if (blockTag.e("Items")) {
|
||||
return drillDown(blockTag.c("Items", 10), 0, 0) > threshold;
|
||||
}
|
||||
}
|
||||
|
||||
return drillDown(data.contents(), 0, 0) <= threshold;
|
||||
return false;
|
||||
}
|
||||
|
||||
private int drillDown(List<ItemStack> items, int layer, int start) {
|
||||
private int drillDown(NBTTagList items, int layer, int start) {
|
||||
if (layer > 2) return start + threshold;
|
||||
int invalid = start;
|
||||
for (int i = start; i < items.size(); i++) {
|
||||
ItemStack item = items.get(i);
|
||||
if (item.isEmpty()) continue;
|
||||
|
||||
invalid += item.getAmount();
|
||||
|
||||
ItemContainerContents data = item.getData(DataComponentTypes.CONTAINER);
|
||||
if (data == null) {
|
||||
for (NBTBase nbtBase : items) {
|
||||
if (!(nbtBase instanceof NBTTagCompound slot))
|
||||
continue;
|
||||
if (slot.e("tag")) {
|
||||
invalid += slot.f("Count");
|
||||
NBTTagCompound iTag = slot.p("tag");
|
||||
if (iTag.e("BlockEntityTag")) {
|
||||
NBTTagCompound blockTag = iTag.p("BlockEntityTag");
|
||||
if (blockTag.e("Items")) {
|
||||
invalid = drillDown(blockTag.c("Items", 10), layer + 1, invalid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<ItemStack> subItems = data.contents();
|
||||
if (subItems.size() > 1) {
|
||||
invalid = drillDown(subItems, layer + 1, invalid);
|
||||
}
|
||||
if (invalid > threshold)
|
||||
break;
|
||||
}
|
||||
return invalid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resetExplosionKnockback(Object packet) {
|
||||
ClientboundExplodePacket explosion = (ClientboundExplodePacket) packet;
|
||||
PacketPlayOutExplosion explosion = (PacketPlayOutExplosion) packet;
|
||||
|
||||
return new ClientboundExplodePacket(
|
||||
explosion.center(),
|
||||
return new PacketPlayOutExplosion(
|
||||
explosion.b(),
|
||||
Optional.empty(),
|
||||
explosion.explosionParticle(),
|
||||
explosion.explosionSound()
|
||||
explosion.f(),
|
||||
explosion.g()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ SCOREBOARD_TRACE_TICKS=Ticks
|
||||
SCOREBOARD_TECHHIDER=TechHider§8: §aOn
|
||||
SCOREBOARD_XRAY=XRay§8: §aOn
|
||||
SCOREBOARD_LOCK_TEAM=Bau Lock§8: §eTeam
|
||||
SCOREBOARD_LOCK_SUPERVISOR=Bau Lock§8: §eSupervisor
|
||||
SCOREBOARD_LOCK_TEAM_AND_SERVERTEAM=Bau Lock§8: §e(Server) Team
|
||||
SCOREBOARD_LOCK_SERVERTEAM=Bau Lock§8: §eServer Team
|
||||
SCOREBOARD_LOCK_NOBODY=Bau Lock§8: §cNobody
|
||||
@@ -515,7 +514,7 @@ LOADER_HELP_GUI=§8/§7loader gui §8- §7Shows Loader gui
|
||||
LOADER_HELP_STOP=§8/§eloader stop §8- §7Stops recording/playback
|
||||
LOADER_HELP_WAIT=§8/§7loader wait §8[§7Ticks§8] - §7Sets wait time between shots
|
||||
LOADER_HELP_SPEED=§8/§7loader speed §8[§7Ticks§8] - §7Sets wait time between actions
|
||||
LOADER_NO_LOADER=§cYou have no Loader. Create one with /loader setup
|
||||
LOADER_NO_LOADER=§cYou have no Laoder. Create one with /loader setup
|
||||
LOADER_NEW=§7Load your cannon and fire it once, to initialise the loader.
|
||||
LOADER_HOW_TO_START=§7Then, execute /§eloader start§7 to start the Loader
|
||||
LOADER_ACTIVE=§7The Loader is now active.
|
||||
@@ -847,7 +846,7 @@ LAUFBAU_SETTINGS_INACTIVE=§cInactive
|
||||
LAUFBAU_SETTINGS_MIXED=§e{0}§8/§e{1} §aActive
|
||||
LAUFBAU_SETTINGS_GUI_BACK=§eBack
|
||||
LAUFBAU_SETTINGS_TOGGLE=§eClick §8-§7 Toggle
|
||||
LAUFBAU_SETTINGS_ADVANCED=§eLeft-Click §8-§7 Advanced settings
|
||||
LAUFBAU_SETTINGS_ADVANCED=§eMiddle-Click §8-§7 Advanced settings
|
||||
LAUFBAU_BLOCK_COBWEB=§eCobweb
|
||||
LAUFBAU_BLOCK_GRASS_PATH=§eGrass Path
|
||||
LAUFBAU_BLOCK_SOUL_SAND=§eSoul Sand
|
||||
|
||||
@@ -792,7 +792,7 @@ LAUFBAU_SETTINGS_INACTIVE=§cInaktiv
|
||||
LAUFBAU_SETTINGS_MIXED=§e{0}§8/§e{1} §aAktiv
|
||||
LAUFBAU_SETTINGS_GUI_BACK=§eBack
|
||||
LAUFBAU_SETTINGS_TOGGLE=§eClick §8-§7 Toggle
|
||||
LAUFBAU_SETTINGS_ADVANCED=§eLinks-Click §8-§7 Erweiterte Einstellung
|
||||
LAUFBAU_SETTINGS_ADVANCED=§eMiddle-Click §8-§7 Erweiterte Einstellung
|
||||
LAUFBAU_BLOCK_COBWEB=§eCobweb
|
||||
LAUFBAU_BLOCK_GRASS_PATH=§eGrass Path
|
||||
LAUFBAU_BLOCK_SOUL_SAND=§eSoul Sand
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.bausystem;
|
||||
|
||||
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.configplayer.ConfigConverter;
|
||||
@@ -207,8 +206,6 @@ public class BauSystem extends JavaPlugin {
|
||||
|
||||
TraceManager.instance.init();
|
||||
TraceRecorder.instance.init();
|
||||
|
||||
new WorldEditRendererCUIEditor();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.gui.BauGUI;
|
||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@@ -75,7 +74,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() + 8, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_CLOSE", p)).setCustomModelData(CMDs.BACK).getItemStack());
|
||||
inv.setItem(mapping.getSize() + 8, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_CLOSE", p)).getItemStack());
|
||||
|
||||
p.openInventory(inv);
|
||||
p.getOpenInventory().setCursor(cursor == null ? new SWItem().getItemStack() : cursor);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package de.steamwar.bausystem.features.loader.elements;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@@ -114,7 +113,7 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
});
|
||||
listInv.setItem(48, new SWItem(Material.ARROW, "§7Back", clickType -> {
|
||||
backAction.run();
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
listInv.setItem(50, new SWItem(Material.GHAST_SPAWN_EGG, "§7Insert another Setting", clickType -> {
|
||||
elements.add(defaultSetting);
|
||||
extraPower.add(0);
|
||||
@@ -151,7 +150,7 @@ 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 -> {}));
|
||||
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 - 9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).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");
|
||||
swAnvilInv.setCallback(s -> {
|
||||
|
||||
@@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.loader.elements.impl;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.loader.elements.LoaderElement;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@@ -61,7 +60,7 @@ public class LoaderWait implements LoaderElement {
|
||||
public void click(Player player, Runnable backAction) {
|
||||
SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_TITLE", player));
|
||||
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(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_BACK", player)).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 -> {
|
||||
delay -= clickType.isShiftClick() ? 5 : 1;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package de.steamwar.bausystem.features.printerTool;
|
||||
|
||||
import de.steamwar.bausystem.utils.ItemUtils;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
@Linked
|
||||
public class PrinterToolItem implements Listener {
|
||||
public static ItemStack getItem(Player p) {
|
||||
ItemStack itemStack = new SWItem(Material.WOODEN_PICKAXE, "Printer Tool").getItemStack();
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.setCustomModelData(1);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
ItemUtils.setItem(itemStack, "printer_tool");
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public static boolean isItem(ItemStack itemStack) {
|
||||
return itemStack != null && ItemUtils.isItem(itemStack, "printer_tool");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
ItemStack item = event.getItem();
|
||||
|
||||
if(PrinterToolItem.isItem(item)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,8 +166,6 @@ public class SteamWarLuaPlugin extends TwoArgFunction {
|
||||
env.set("rawlen", NIL);
|
||||
env.set("rawset", NIL);
|
||||
env.set("xpcall", NIL);
|
||||
env.set("require", NIL);
|
||||
env.set("package", NIL);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
|
||||
import de.steamwar.bausystem.features.simulator.preview.SimulatorPreviewCalculator;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
@@ -31,7 +30,6 @@ import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -92,20 +90,6 @@ public class SimulatorCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Register(value = "test")
|
||||
public void test(Player player) {
|
||||
for (int i = 0; i < 1; i++) {
|
||||
SimulatorPreviewCalculator data = new SimulatorPreviewCalculator(null);
|
||||
data.spawnTNT(0, 166, 0);
|
||||
data.calculate(simulatorPreviewResult -> {
|
||||
simulatorPreviewResult.show(player);
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
simulatorPreviewResult.hide(player);
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ClassMapper(value = Simulator.class, local = true)
|
||||
public TypeMapper<Simulator> allSimulators() {
|
||||
return new TypeMapper<>() {
|
||||
|
||||
@@ -25,7 +25,6 @@ import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -71,12 +70,12 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
|
||||
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
simulatorGroup.getElements().clear();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
}));
|
||||
|
||||
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
|
||||
if (simulatorGroup.getMaterial() == null) return;
|
||||
@@ -86,7 +85,7 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
|
||||
|
||||
inventory.setItem(48, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorGroupSettingsGui(player, simulator, simulatorGroup, this).open();
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
}));
|
||||
boolean disabled = simulatorGroup.getMaterial() == null ? simulatorGroup.getElements().stream().allMatch(SimulatorElement::isDisabled) : simulatorGroup.isDisabled();
|
||||
inventory.setItem(50, new SWItem(disabled ? Material.ENDER_PEARL : Material.ENDER_EYE, simulatorGroup.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
if (simulatorGroup.getMaterial() == null) {
|
||||
@@ -97,7 +96,7 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
|
||||
simulatorGroup.setDisabled(!disabled);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,10 +25,10 @@ import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
|
||||
@@ -69,10 +69,10 @@ 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, SWItem.getDye(10), "§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));
|
||||
});
|
||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
@@ -83,14 +83,14 @@ 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, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
simulatorGroup.changeBaseTicks(-baseTicks);
|
||||
} else {
|
||||
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
boolean allTNT = simulatorGroup.getElements().stream().allMatch(TNTElement.class::isInstance);
|
||||
|
||||
@@ -163,10 +163,10 @@ 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, SWItem.getDye(10), "§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));
|
||||
});
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Relative X", "", Double::parseDouble, number -> {
|
||||
if(!allTNT){
|
||||
@@ -177,16 +177,16 @@ 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, SWItem.getDye(1), "§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, SWItem.getDye(10), "§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));
|
||||
});
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Relative Y", "", Double::parseDouble, number -> {
|
||||
if(!allTNT){
|
||||
@@ -197,16 +197,16 @@ 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, SWItem.getDye(1), "§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, SWItem.getDye(10), "§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));
|
||||
});
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Relative Z", "", Double::parseDouble, number -> {
|
||||
if(!allTNT){
|
||||
@@ -217,9 +217,9 @@ 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, SWItem.getDye(1), "§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));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -51,7 +50,7 @@ public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
|
||||
}));
|
||||
inventory.setItem(49, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorSettingsGui(player, simulator, this).open();
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,6 @@ import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -76,7 +75,7 @@ public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
|
||||
}));
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,7 +26,6 @@ import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -83,12 +82,12 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
new SimulatorGroupGui(player, simulator, newParent, simulatorGui).open();
|
||||
}
|
||||
}
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
observer.getPhases().clear();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
}));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, observer.toItem(player, clickType -> {
|
||||
@@ -98,18 +97,18 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
// Settings
|
||||
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorObserverSettingsGui(player, simulator, observer, this).open();
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
}));
|
||||
|
||||
// Enable/Disable
|
||||
inventory.setItem(48, new SWItem(observer.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, observer.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
observer.setDisabled(!observer.isDisabled());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
}));
|
||||
|
||||
// Group chooser
|
||||
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
|
||||
new SimulatorGroupChooserGui(player, simulator, observer, observer.getGroup(simulator), this).open();
|
||||
}).setCustomModelData(CMDs.Simulator.JOIN_GROUP));
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,15 +151,15 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
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 -> {
|
||||
setter.accept(Math.max(min, getter.get() - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
}),
|
||||
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
|
||||
new SimulatorObserverPhaseSettingsGui(player, simulator, this.observer, observerPhase, this).open();
|
||||
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -169,12 +168,12 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§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 -> {
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -63,7 +62,7 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, observerElement.toItem(player, clickType -> {
|
||||
@@ -75,7 +74,7 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
observerElement.getPhases().remove(observer);
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
}));
|
||||
|
||||
int index = observerElement.getPhases().indexOf(observer);
|
||||
int min;
|
||||
@@ -96,10 +95,10 @@ 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, SWItem.getDye(offset < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.setTickOffset(Math.min(max, offset + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
||||
@@ -112,17 +111,17 @@ 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, SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
//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, SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
|
||||
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> {
|
||||
@@ -137,10 +136,10 @@ 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, SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
// Update orientation
|
||||
inventory.setItem(25, new SWItem(Material.SUNFLOWER, "§7", clickType -> {
|
||||
|
||||
@@ -24,7 +24,6 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -57,7 +56,7 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, observer.toItem(player, clickType -> {
|
||||
@@ -66,10 +65,10 @@ 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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
@@ -80,20 +79,20 @@ 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, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
observer.changeBaseTicks(-baseTicks);
|
||||
} else {
|
||||
observer.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + observer.getPosition().getBlockX(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "X", observer.getPosition().getBlockX() + "", Integer::parseInt, i -> {
|
||||
observer.getPosition().setX(i);
|
||||
@@ -101,16 +100,16 @@ 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, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.move(0, clickType.isShiftClick() ? 5 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
});
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + observer.getPosition().getBlockY(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Y", observer.getPosition().getBlockY() + "", Integer::parseInt, i -> {
|
||||
observer.getPosition().setY(i);
|
||||
@@ -118,16 +117,16 @@ 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, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.move(0, 0, clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
});
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + observer.getPosition().getBlockZ(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Z", observer.getPosition().getBlockZ() + "", Integer::parseInt, i -> {
|
||||
observer.getPosition().setZ(i);
|
||||
@@ -135,9 +134,9 @@ 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, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.move(0, 0, clickType.isShiftClick() ? -5 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.Material;
|
||||
@@ -89,12 +88,12 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
||||
new SimulatorGroupGui(player, simulator, newParent, simulatorGui).open();
|
||||
}
|
||||
}
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
redstone.getPhases().clear();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
}));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, redstone.toItem(player, clickType -> {
|
||||
@@ -104,18 +103,18 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
||||
// Settings
|
||||
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorRedstoneSettingsGui(player, simulator, redstone, this).open();
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
}));
|
||||
|
||||
// Enable/Disable
|
||||
inventory.setItem(48, new SWItem(redstone.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, redstone.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
redstone.setDisabled(!redstone.isDisabled());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
}));
|
||||
|
||||
// Group chooser
|
||||
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
|
||||
new SimulatorGroupChooserGui(player, simulator, redstone, redstone.getGroup(simulator), this).open();
|
||||
}).setCustomModelData(CMDs.Simulator.JOIN_GROUP));
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,15 +166,15 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
||||
new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
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 -> {
|
||||
setter.accept(Math.max(min, getter.get() - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
}),
|
||||
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
|
||||
new SimulatorRedstonePhaseSettingsGui(player, simulator, this.redstone, redstoneSubPhase.phase, this).open();
|
||||
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -184,12 +183,12 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§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 -> {
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -61,7 +60,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, redstoneElement.toItem(player, clickType -> {
|
||||
@@ -73,7 +72,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
redstoneElement.getPhases().remove(redstone);
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
}));
|
||||
|
||||
int index = redstoneElement.getPhases().indexOf(redstone);
|
||||
int min;
|
||||
@@ -97,10 +96,10 @@ 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, SWItem.getDye(offset < maxOffset ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.setTickOffset(Math.min(maxOffset, offset + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
||||
@@ -113,17 +112,17 @@ 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, SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
//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, SWItem.getDye(lifetime < maxLifetime ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.setLifetime(Math.min(maxLifetime, lifetime + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eActivation Time§8:§7 " + lifetime, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Activation Time", lifetime + "", Integer::parseInt, integer -> {
|
||||
@@ -136,17 +135,17 @@ 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, SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.setLifetime(Math.max(0, lifetime - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
//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, SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
|
||||
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> {
|
||||
@@ -161,9 +160,9 @@ 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, SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -56,7 +55,7 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, redstone.toItem(player, clickType -> {
|
||||
@@ -65,10 +64,10 @@ 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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
@@ -79,20 +78,20 @@ 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, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
redstone.changeBaseTicks(-baseTicks);
|
||||
} else {
|
||||
redstone.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + redstone.getPosition().getBlockX(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "X", redstone.getPosition().getBlockX() + "", Integer::parseInt, i -> {
|
||||
redstone.getPosition().setX(i);
|
||||
@@ -100,16 +99,16 @@ 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, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.move(0, clickType.isShiftClick() ? 5 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + redstone.getPosition().getBlockY(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Y", redstone.getPosition().getBlockY() + "", Integer::parseInt, i -> {
|
||||
redstone.getPosition().setY(i);
|
||||
@@ -117,16 +116,16 @@ 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, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.move(0, 0, clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + redstone.getPosition().getBlockZ(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Z", redstone.getPosition().getBlockZ() + "", Integer::parseInt, i -> {
|
||||
redstone.getPosition().setZ(i);
|
||||
@@ -134,9 +133,9 @@ 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, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.move(0, 0, clickType.isShiftClick() ? -5 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.simulator.gui;
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -48,7 +47,7 @@ public class SimulatorSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, simulator.toItem(player, clickType -> {
|
||||
@@ -62,39 +61,39 @@ 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, SWItem.getDye(10), "§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, SWItem.getDye(1), "§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, SWItem.getDye(10), "§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, SWItem.getDye(1), "§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, SWItem.getDye(10), "§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, SWItem.getDye(1), "§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));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@ import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -83,12 +81,12 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
new SimulatorGroupGui(player, simulator, newParent, simulatorGui).open();
|
||||
}
|
||||
}
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
tnt.getPhases().clear();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
}));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, tnt.toItem(player, clickType -> {
|
||||
@@ -97,31 +95,29 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
|
||||
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorTNTSettingsGui(player, simulator, tnt, this).open();
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
}));
|
||||
inventory.setItem(48, new SWItem(tnt.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, tnt.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
tnt.setDisabled(!tnt.isDisabled());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
if (Core.getVersion() > 19) {
|
||||
inventory.setItem(49, new SWItem(Material.CALIBRATED_SCULK_SENSOR, "§eCreate Stab", click -> {
|
||||
new SimulatorAnvilGui<>(player, "Depth Limit", "", Integer::parseInt, depthLimit -> {
|
||||
if (depthLimit <= 0) return false;
|
||||
simulator.setStabGenerator(new SimulatorStabGenerator(Region.getRegion(player.getLocation()), simulator, tnt, depthLimit));
|
||||
SimulatorWatcher.update(simulator);
|
||||
return true;
|
||||
}, null).open();
|
||||
}).setCustomModelData(CMDs.Simulator.CREATE_STAB));
|
||||
}
|
||||
}));
|
||||
inventory.setItem(49, new SWItem(Material.CALIBRATED_SCULK_SENSOR, "§eCreate Stab", click -> {
|
||||
new SimulatorAnvilGui<>(player, "Depth Limit", "", Integer::parseInt, depthLimit -> {
|
||||
if (depthLimit <= 0) return false;
|
||||
simulator.setStabGenerator(new SimulatorStabGenerator(Region.getRegion(player.getLocation()), simulator, tnt, depthLimit));
|
||||
SimulatorWatcher.update(simulator);
|
||||
return true;
|
||||
}, null).open();
|
||||
}));
|
||||
inventory.setItem(50, new SWItem(Material.CHEST, parent.getElements().size() == 1 ? "§eMake Group" : "§eAdd another TNT to Group", clickType -> {
|
||||
TNTElement tntElement = new TNTElement(tnt.getPosition().clone());
|
||||
tntElement.add(new TNTPhase());
|
||||
parent.add(tntElement);
|
||||
new SimulatorGroupGui(player, simulator, parent, new SimulatorGui(player, simulator)).open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.MAKE_GROUP));
|
||||
}));
|
||||
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
|
||||
new SimulatorGroupChooserGui(player, simulator, tnt, tnt.getGroup(simulator), this).open();
|
||||
}).setCustomModelData(CMDs.Simulator.JOIN_GROUP));
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,15 +136,15 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
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 -> {
|
||||
tntSetting.setCount(Math.max(1, tntSetting.getCount() - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
}),
|
||||
new SWItem(Material.ANVIL, "§eEdit Phase", clickType -> {
|
||||
new SimulatorTNTPhaseSettingsGui(player, simulator, this.tnt, tntSetting, this).open();
|
||||
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -157,12 +153,12 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§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 -> {
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -61,7 +60,7 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, tntElement.toItem(player, clickType -> {
|
||||
@@ -73,14 +72,14 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
tntElement.getPhases().remove(tnt);
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
}));
|
||||
|
||||
//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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setCount(count + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
SWItem countItem = new SWItem(Material.TNT, "§eCount§8:§7 " + count, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Count", count + "", Integer::parseInt, integer -> {
|
||||
@@ -93,17 +92,17 @@ 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, SWItem.getDye(count > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
tnt.setCount(Math.max(1, count - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
//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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setTickOffset(offset + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
||||
@@ -116,17 +115,17 @@ 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, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
tnt.setTickOffset(Math.max(0, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
//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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setLifetime(lifetime + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eLifetime§8:§7 " + lifetime, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Lifetime", lifetime + "", Integer::parseInt, integer -> {
|
||||
@@ -139,17 +138,17 @@ 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, SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
tnt.setLifetime(Math.max(1, lifetime - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
//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, SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
|
||||
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eCalculation Order§8:§7 " + order, clickType -> {
|
||||
@@ -164,10 +163,10 @@ 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, SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
tnt.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
//Jump
|
||||
SWItem jumpX = new SWItem(tnt.isXJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump X§8: " + (tnt.isZJump() ? "§aon" : "§coff"), clickType -> {
|
||||
|
||||
@@ -24,10 +24,10 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -58,7 +58,7 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
|
||||
// Material Chooser
|
||||
List<String> lore = new ArrayList<>();
|
||||
@@ -74,10 +74,10 @@ 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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
@@ -88,14 +88,14 @@ 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, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
tnt.changeBaseTicks(-baseTicks);
|
||||
} else {
|
||||
tnt.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
|
||||
// Subpixel Alignment
|
||||
inventory.setItem(21, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> {
|
||||
@@ -135,10 +135,10 @@ 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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
tnt.move(clickType.isShiftClick() ? 0.0625 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + tnt.getPosition().getX(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "X", tnt.getPosition().getX() + "", Double::parseDouble, d -> {
|
||||
tnt.getPosition().setX(d);
|
||||
@@ -146,16 +146,16 @@ 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, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
tnt.move(0, clickType.isShiftClick() ? 0.0625 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + tnt.getPosition().getY(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Y", tnt.getPosition().getY() + "", Double::parseDouble, d -> {
|
||||
tnt.getPosition().setY(d);
|
||||
@@ -163,16 +163,16 @@ 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, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
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, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
tnt.move(0, 0, clickType.isShiftClick() ? 0.0625 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
});
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + tnt.getPosition().getZ(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Z", tnt.getPosition().getZ() + "", Double::parseDouble, d -> {
|
||||
tnt.getPosition().setZ(d);
|
||||
@@ -180,9 +180,9 @@ 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, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
tnt.move(0, 0, clickType.isShiftClick() ? -0.0625 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.simulator.gui.base;
|
||||
|
||||
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.entity.Player;
|
||||
|
||||
@@ -51,19 +50,19 @@ 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, 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 -> {
|
||||
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, SWItem.getDye(hasNext ? 10 : 8), hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
|
||||
if (hasNext) {
|
||||
page++;
|
||||
open();
|
||||
}
|
||||
}).setCustomModelData(CMDs.NEXT_PAGE));
|
||||
});
|
||||
|
||||
int minElement = page * (size - 18);
|
||||
int maxElement = Math.min(data.size(), (page + 1) * (size - 18));
|
||||
|
||||
@@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.simulator.gui.base;
|
||||
|
||||
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.entity.Player;
|
||||
|
||||
@@ -51,19 +50,19 @@ 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, 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 -> {
|
||||
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, SWItem.getDye(hasNext ? 10 : 8), 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();
|
||||
}
|
||||
}).setCustomModelData(CMDs.NEXT_PAGE));
|
||||
});
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (scroll + i < data.size()) {
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.features.simulator.preview;
|
||||
|
||||
public class SimulatorPreview {
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.features.simulator.preview;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.VoxelShape;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class SimulatorPreviewAABB {
|
||||
public double minX;
|
||||
public double minY;
|
||||
public double minZ;
|
||||
public double maxX;
|
||||
public double maxY;
|
||||
public double maxZ;
|
||||
|
||||
public SimulatorPreviewAABB copy() {
|
||||
return new SimulatorPreviewAABB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
public void expandTowards(double vx, double vy, double vz) {
|
||||
if (vx < 0) {
|
||||
minX += vx;
|
||||
} else {
|
||||
maxX += vx;
|
||||
}
|
||||
if (vy < 0) {
|
||||
minY += vy;
|
||||
} else {
|
||||
maxY += vy;
|
||||
}
|
||||
if (vz < 0) {
|
||||
minZ += vz;
|
||||
} else {
|
||||
maxZ += vz;
|
||||
}
|
||||
}
|
||||
|
||||
public void add(double vx, double vy, double vz) {
|
||||
minX += vx;
|
||||
minY += vy;
|
||||
minZ += vz;
|
||||
}
|
||||
|
||||
public boolean intersects(double x, double y, double z, BoundingBox boundingBox) {
|
||||
return minX - (x + boundingBox.getMaxX()) < -1.0E-7 &&
|
||||
maxX - (x + boundingBox.getMinX()) > 1.0E-7 &&
|
||||
minY - (y + boundingBox.getMaxY()) < -1.0E-7 &&
|
||||
maxY - (y + boundingBox.getMinY()) > 1.0E-7 &&
|
||||
minZ - (z + boundingBox.getMaxZ()) < -1.0E-7 &&
|
||||
maxZ - (z + boundingBox.getMinZ()) > 1.0E-7;
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.features.simulator.preview;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||
import de.steamwar.bausystem.features.tracer.Trace;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.util.Consumer;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.bukkit.util.VoxelShape;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class SimulatorPreviewCalculator {
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
public final Simulator simulator;
|
||||
public final List<SimulatorPreviewTNT> tnts = new ArrayList<>();
|
||||
|
||||
private int ticks = 0;
|
||||
private final Set<SimulatorPreviewPos> air = new HashSet<>();
|
||||
private final Map<SimulatorPreviewPos, BlockData> datas = new HashMap<>();
|
||||
private final Map<SimulatorPreviewPos, VoxelShape> shapes = new HashMap<>();
|
||||
|
||||
public BlockData getBlockData(int x, int y, int z) {
|
||||
SimulatorPreviewPos pos = new SimulatorPreviewPos(x, y, z);
|
||||
if (air.contains(pos)) return null;
|
||||
return datas.computeIfAbsent(pos, __ -> {
|
||||
BlockData blockData = WORLD.getBlockData(x, y, z);
|
||||
if (blockData.getMaterial().isAir()) {
|
||||
air.add(pos);
|
||||
return null;
|
||||
}
|
||||
return blockData;
|
||||
});
|
||||
}
|
||||
|
||||
public VoxelShape getBlockShape(int x, int y, int z) {
|
||||
SimulatorPreviewPos pos = new SimulatorPreviewPos(x, y, z);
|
||||
if (air.contains(pos)) return null;
|
||||
return shapes.computeIfAbsent(pos, __ -> {
|
||||
Block block = WORLD.getBlockAt(x, y, z);
|
||||
if (block.getType().isAir()) {
|
||||
air.add(pos);
|
||||
return null;
|
||||
}
|
||||
return block.getCollisionShape();
|
||||
});
|
||||
}
|
||||
|
||||
public void setAir(int x, int y, int z) {
|
||||
SimulatorPreviewPos pos = new SimulatorPreviewPos(x, y, z);
|
||||
air.add(pos);
|
||||
datas.remove(pos);
|
||||
shapes.remove(pos);
|
||||
}
|
||||
|
||||
public void spawnTNT(double x, double y, double z) {
|
||||
tnts.add(new SimulatorPreviewTNT(this, x, y, z));
|
||||
}
|
||||
|
||||
public void calculate(Consumer<SimulatorPreviewResult> result) {
|
||||
List<TNTPoint> tntPoints = new ArrayList<>();
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), bukkitTask -> {
|
||||
long time = System.currentTimeMillis();
|
||||
while (!tnts.isEmpty()) {
|
||||
if (System.currentTimeMillis() - time > 40) {
|
||||
return;
|
||||
}
|
||||
tick(tntPoints);
|
||||
}
|
||||
bukkitTask.cancel();
|
||||
System.out.println(tntPoints);
|
||||
result.accept(new SimulatorPreviewResult(new Trace(null, tntPoints), air));
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
private void tick(List<TNTPoint> tntPoints) {
|
||||
System.out.println("TICK");
|
||||
tnts.removeIf(simulatorPreviewTNT -> {
|
||||
tntPoints.add(new TNTPoint(0, false, false, true, false, false, ticks, simulatorPreviewTNT.fuse, new Location(WORLD, simulatorPreviewTNT.x + 0.49, simulatorPreviewTNT.y, simulatorPreviewTNT.z + 0.49), new Vector(simulatorPreviewTNT.vx, simulatorPreviewTNT.vy, simulatorPreviewTNT.vz), tntPoints));
|
||||
simulatorPreviewTNT.tick();
|
||||
if (!simulatorPreviewTNT.removed) return false;
|
||||
tntPoints.add(new TNTPoint(0, true, false, true, false, false, ticks, simulatorPreviewTNT.fuse, new Location(WORLD, simulatorPreviewTNT.x + 0.49, simulatorPreviewTNT.y, simulatorPreviewTNT.z + 0.49), new Vector(simulatorPreviewTNT.vx, simulatorPreviewTNT.vy, simulatorPreviewTNT.vz), tntPoints));
|
||||
return true;
|
||||
});
|
||||
ticks++;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.features.simulator.preview;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
final class SimulatorPreviewPos {
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.features.simulator.preview;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.Trace;
|
||||
import de.steamwar.bausystem.features.tracer.rendering.BundleFilter;
|
||||
import de.steamwar.bausystem.features.tracer.rendering.PlayerTraceShowData;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
public class SimulatorPreviewResult {
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
private static final BlockData AIR = Material.AIR.createBlockData();
|
||||
|
||||
private final Trace trace;
|
||||
private final Set<SimulatorPreviewPos> air;
|
||||
|
||||
public SimulatorPreviewResult(Trace trace, Set<SimulatorPreviewPos> air) {
|
||||
this.trace = trace;
|
||||
this.air = air;
|
||||
}
|
||||
|
||||
public void show(Player player) {
|
||||
trace.render(player, new PlayerTraceShowData(BundleFilter.DEFAULT));
|
||||
air.forEach(simulatorPreviewPos -> {
|
||||
player.sendBlockChange(new Location(WORLD, simulatorPreviewPos.x, simulatorPreviewPos.y, simulatorPreviewPos.z, 0, 0), AIR);
|
||||
});
|
||||
}
|
||||
|
||||
public void hide(Player player) {
|
||||
trace.hide(player);
|
||||
air.forEach(simulatorPreviewPos -> {
|
||||
player.sendBlockChange(new Location(WORLD, simulatorPreviewPos.x, simulatorPreviewPos.y, simulatorPreviewPos.z, 0, 0), WORLD.getBlockData(simulatorPreviewPos.x, simulatorPreviewPos.y, simulatorPreviewPos.z));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,228 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.features.simulator.preview;
|
||||
|
||||
import org.bukkit.Axis;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.bukkit.util.VoxelShape;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class SimulatorPreviewTNT {
|
||||
|
||||
private static final double size = 0.98;
|
||||
private static final Random random = new Random();
|
||||
|
||||
private final SimulatorPreviewCalculator data;
|
||||
private boolean gravity = true;
|
||||
int fuse = 80;
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
double vx;
|
||||
double vy;
|
||||
double vz;
|
||||
|
||||
private SimulatorPreviewVec collide = new SimulatorPreviewVec();
|
||||
private boolean onGround;
|
||||
boolean removed = false;
|
||||
|
||||
public SimulatorPreviewTNT(SimulatorPreviewCalculator data, double x, double y, double z) {
|
||||
this.data = data;
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
double d = random.nextDouble() * Math.PI * 2;
|
||||
this.vx = -Math.sin(d) * 0.02;
|
||||
this.vy = 0.2;
|
||||
this.vz = -Math.cos(d) * 0.02;
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
System.out.println(x + " " + y + " " + z);
|
||||
// TODO: Issue in movement still!
|
||||
// System.out.println(x + " " + y + " " + z);
|
||||
// Gravity
|
||||
if (gravity) {
|
||||
vy -= 0.04;
|
||||
}
|
||||
|
||||
// Movement
|
||||
move();
|
||||
|
||||
// TODO: EffectsFromOtherBlocks
|
||||
|
||||
// Velocity * 0.98
|
||||
vx *= 0.98;
|
||||
vy *= 0.98;
|
||||
vz *= 0.98;
|
||||
|
||||
// OnGround Velocity * 0.7 -0.5 0.7
|
||||
if (onGround) {
|
||||
vx *= 0.7;
|
||||
vy *= -0.5;
|
||||
vz *= 0.7;
|
||||
}
|
||||
|
||||
// Decrease Fuse
|
||||
fuse--;
|
||||
if (fuse <= 0) {
|
||||
// Explode on zero Fuse
|
||||
explode();
|
||||
} else {
|
||||
// TODO: or do water Movement!
|
||||
}
|
||||
}
|
||||
|
||||
public void move() {
|
||||
collide();
|
||||
double collisionLengthSquared = collide.lengthSquared();
|
||||
if (collisionLengthSquared > 1.0E-7 || new Vector(vx, vy, vz).lengthSquared() - collisionLengthSquared < 1.0E-7) {
|
||||
x += collide.x;
|
||||
y += collide.y;
|
||||
z += collide.z;
|
||||
}
|
||||
|
||||
boolean xCollision = !equal(vx, collide.x);
|
||||
boolean zCollision = !equal(vz, collide.z);
|
||||
boolean horizontalCollision = xCollision || zCollision;
|
||||
if (Math.abs(vy) > 0.0F) {
|
||||
boolean verticalCollision = vy != collide.y;
|
||||
onGround = verticalCollision && vy < (double) 0.0F;
|
||||
}
|
||||
|
||||
if (horizontalCollision) {
|
||||
if (xCollision) vx = 0;
|
||||
if (zCollision) vz = 0;
|
||||
}
|
||||
vx = collide.x;
|
||||
vy = collide.y;
|
||||
vz = collide.z;
|
||||
// TODO: Get Block -> updateEntityMovementAfterFallOn!
|
||||
// TODO: Get BlockSpeedFactor multiply
|
||||
}
|
||||
|
||||
public static boolean equal(double first, double second) {
|
||||
return Math.abs(second - first) < (double) 1.0E-5F;
|
||||
}
|
||||
|
||||
public void collide() {
|
||||
boolean xZero = vx == 0;
|
||||
boolean zZero = vz == 0;
|
||||
if (xZero && vy == 0 && zZero) {
|
||||
collide.x = 0;
|
||||
collide.y = 0;
|
||||
collide.z = 0;
|
||||
return;
|
||||
}
|
||||
SimulatorPreviewAABB box = new SimulatorPreviewAABB(x, y, z, x + size, y + size, z + size);
|
||||
|
||||
double vx = this.vx;
|
||||
double vy = this.vy;
|
||||
double vz = this.vz;
|
||||
|
||||
if (vy != 0) {
|
||||
vy = iterateBlocks(box.copy(), Axis.Y, vy);
|
||||
if (vy != 0) box.add(0, vy, 0);
|
||||
}
|
||||
|
||||
boolean xSmaller = Math.abs(vx) < Math.abs(vz);
|
||||
if (xSmaller && vz != 0) {
|
||||
vz = iterateBlocks(box.copy(), Axis.Z, vz);
|
||||
if (vz != 0) box.add(0, 0, vz);
|
||||
}
|
||||
|
||||
if (vx != 0) {
|
||||
vx = iterateBlocks(box.copy(), Axis.X, vx);
|
||||
if (vx != 0) box.add(vx, 0, 0);
|
||||
}
|
||||
|
||||
if (!xSmaller && vz != 0) {
|
||||
vz = iterateBlocks(box.copy(), Axis.Z, vz);
|
||||
if (vz != 0) box.add(0, 0, vz);
|
||||
}
|
||||
|
||||
collide.x = vx;
|
||||
collide.y = vy;
|
||||
collide.z = vz;
|
||||
}
|
||||
|
||||
private double iterateBlocks(SimulatorPreviewAABB box, Axis axis, double v) {
|
||||
switch (axis) {
|
||||
case X -> box.expandTowards(v, 0, 0);
|
||||
case Y -> box.expandTowards(0, v, 0);
|
||||
case Z -> box.expandTowards(0, 0, v);
|
||||
}
|
||||
boolean negative = v < 0;
|
||||
for (int x = floor(box.minX - 1.0E-7) - 1; x < floor(box.maxX + 1.0E-7) + 1; x++) {
|
||||
for (int y = floor(box.minY - 1.0E-7) - 1; y < floor(box.maxY + 1.0E-7) + 1; y++) {
|
||||
for (int z = floor(box.minZ - 1.0E-7) - 1; z < floor(box.maxZ + 1.0E-7) + 1; z++) {
|
||||
VoxelShape shape = data.getBlockShape(x, y, z);
|
||||
if (shape == null) continue;
|
||||
for (BoundingBox other : shape.getBoundingBoxes()) {
|
||||
switch (axis) {
|
||||
case X -> {
|
||||
if (box.intersects(x, y, z, other)) {
|
||||
if (negative) {
|
||||
v = Math.max(v, x + other.getMaxX() - this.x);
|
||||
} else {
|
||||
v = Math.min(v, x + other.getMinX() - this.x - size);
|
||||
}
|
||||
}
|
||||
}
|
||||
case Y -> {
|
||||
if (box.intersects(x, y, z, other)) {
|
||||
if (negative) {
|
||||
v = Math.max(v, y + other.getMaxY() - this.y);
|
||||
} else {
|
||||
v = Math.min(v, y + other.getMinY() - this.y - size);
|
||||
}
|
||||
}
|
||||
}
|
||||
case Z -> {
|
||||
if (box.intersects(x, y, z, other)) {
|
||||
if (negative) {
|
||||
v = Math.max(v, z + other.getMaxZ() - this.z);
|
||||
} else {
|
||||
v = Math.min(v, z + other.getMinZ() - this.z - size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
public static int floor(double value) {
|
||||
int i = (int) value;
|
||||
return value < (double) i ? i - 1 : i;
|
||||
}
|
||||
|
||||
public void explode() {
|
||||
removed = true;
|
||||
// TODO: Implement
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.features.simulator.preview;
|
||||
|
||||
public class SimulatorPreviewVec {
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
|
||||
public double lengthSquared() {
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.slaves.laufbau;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import org.bukkit.Material;
|
||||
@@ -60,7 +59,7 @@ public class LaufbauSettings {
|
||||
open();
|
||||
return;
|
||||
}
|
||||
if (clickType.isLeftClick()) {
|
||||
if (clickType.isCreativeAction()) {
|
||||
open(entry.getKey());
|
||||
return;
|
||||
}
|
||||
@@ -92,7 +91,7 @@ public class LaufbauSettings {
|
||||
});
|
||||
inv.setItem(49, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_GUI_BACK", p), clickType -> {
|
||||
open();
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
inv.open();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@ public class SmartPlaceListener implements Listener {
|
||||
static {
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
Block block = world.getBlockAt(0, 0, 0);
|
||||
block.setType(Material.AIR);
|
||||
BlockState state = block.getState();
|
||||
for (Material material : Material.values()) {
|
||||
if (material.isLegacy()) continue;
|
||||
@@ -69,7 +68,6 @@ public class SmartPlaceListener implements Listener {
|
||||
} else if (blockData instanceof Stairs) {
|
||||
CONTAINERS.add(material);
|
||||
}
|
||||
state.update(true, false);
|
||||
}
|
||||
CONTAINERS.add(Material.GRINDSTONE);
|
||||
CONTAINERS.remove(Material.COMPARATOR);
|
||||
|
||||
@@ -25,18 +25,23 @@ import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Recording of a tnt at a specific tick
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@AllArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
@Getter
|
||||
public class TNTPoint{
|
||||
/**
|
||||
|
||||
@@ -50,6 +50,12 @@ public class Trace {
|
||||
@Getter
|
||||
private final File recordsSaveFile;
|
||||
|
||||
/**
|
||||
* File the metadata are saved in
|
||||
*/
|
||||
@Getter
|
||||
private final File metadataSaveFile;
|
||||
|
||||
/**
|
||||
* Region the trace was recorded in
|
||||
*/
|
||||
@@ -69,7 +75,7 @@ public class Trace {
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private int tntIdCount;
|
||||
private int recordsCount;
|
||||
|
||||
/**
|
||||
* A map of all REntityServers rendering this trace
|
||||
@@ -89,19 +95,21 @@ public class Trace {
|
||||
this.date = new Date();
|
||||
records = new SoftReference<>(recordList);
|
||||
recordsSaveFile = new File(TraceRepository.tracesFolder, uuid + ".records");
|
||||
metadataSaveFile = new File(TraceRepository.tracesFolder, uuid + ".meta");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for deserialising a trace from the file system
|
||||
*/
|
||||
@SneakyThrows
|
||||
protected Trace(UUID uuid, Region region, Date date, File recordsFile, int tntIdCount) {
|
||||
protected Trace(UUID uuid, Region region, Date date, File metadataFile, File recordsFile, int recordsCount) {
|
||||
this.metadataSaveFile = metadataFile;
|
||||
recordsSaveFile = recordsFile;
|
||||
this.uuid = uuid;
|
||||
this.region = region;
|
||||
this.date = date;
|
||||
this.records = new SoftReference<>(null);
|
||||
this.tntIdCount = tntIdCount;
|
||||
this.recordsCount = recordsCount;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,7 +311,7 @@ public class Trace {
|
||||
", region=" + region +
|
||||
", creationTime=" + date +
|
||||
", recordsSaveFile=" + recordsSaveFile.getName() +
|
||||
", tntCount=" + tntIdCount +
|
||||
", recordCount=" + recordsCount +
|
||||
", records=" + getRecords() +
|
||||
'}';
|
||||
}
|
||||
|
||||
@@ -57,26 +57,19 @@ public class TraceManager implements Listener {
|
||||
if (traceFiles == null)
|
||||
return;
|
||||
|
||||
boolean hasMetaFiles = false;
|
||||
for (File traceFile : traceFiles) {
|
||||
if (traceFile.getName().contains(".meta")) {
|
||||
hasMetaFiles = true;
|
||||
}
|
||||
}
|
||||
if (hasMetaFiles) {
|
||||
for (File traceFile : traceFiles) {
|
||||
traceFile.delete();
|
||||
}
|
||||
traceFiles = new File[0];
|
||||
}
|
||||
|
||||
for (File traceFile : traceFiles) {
|
||||
Trace trace = TraceRepository.readTrace(traceFile);
|
||||
if (trace == null) {
|
||||
traceFile.delete();
|
||||
if (traceFile.getName().contains(".records"))
|
||||
continue;
|
||||
|
||||
if (TraceRepository.getVersion(traceFile) == TraceRepository.SERIALISATION_VERSION) {
|
||||
add(TraceRepository.readTrace(traceFile));
|
||||
} else {
|
||||
String uuid = traceFile.getName().replace(".meta", "");
|
||||
|
||||
new File(tracesFolder, uuid + ".records").deleteOnExit();
|
||||
new File(tracesFolder, uuid + ".meta").deleteOnExit();
|
||||
}
|
||||
add(trace);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +152,7 @@ public class TraceManager implements Listener {
|
||||
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.getMetadataSaveFile().delete();
|
||||
trace.getRecordsSaveFile().delete();
|
||||
}
|
||||
|
||||
@@ -178,6 +172,7 @@ public class TraceManager implements Listener {
|
||||
tracesByRegion.getOrDefault(region, new HashMap<>())
|
||||
.forEach((i, trace) -> {
|
||||
if (trace.getRegion() != region) return;
|
||||
trace.getMetadataSaveFile().delete();
|
||||
trace.getRecordsSaveFile().delete();
|
||||
});
|
||||
tracesByRegion.getOrDefault(region, new HashMap<>()).clear();
|
||||
|
||||
@@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
@@ -32,6 +31,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
@@ -40,9 +40,12 @@ import java.util.logging.Logger;
|
||||
@Linked
|
||||
public class TraceRecorder implements Listener {
|
||||
|
||||
@LinkedInstance
|
||||
public static TraceRecorder instance;
|
||||
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map for all traces being actively recorded
|
||||
*/
|
||||
|
||||
@@ -65,7 +65,7 @@ public class TraceRecordingWrapper {
|
||||
TraceManager.instance.showPartial(trace, recordsToAdd);
|
||||
|
||||
recordList.addAll(recordsToAdd);
|
||||
trace.setTntIdCount((int) recordList.stream().map(TNTPoint::getTntId).distinct().count());
|
||||
trace.setRecordsCount(recordList.size());
|
||||
recordsToAdd.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,125 +9,95 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class TraceRepository {
|
||||
|
||||
/**
|
||||
* Increment this when changing serialisation format
|
||||
*/
|
||||
public static final int SERIALISATION_VERSION = 2;
|
||||
public static final int WRITE_TICK_DATA = 0b00000001;
|
||||
public static final int EXPLOSION = 0b00000010;
|
||||
public static final int IN_WATER = 0b00000100;
|
||||
public static final int AFTER_FIRST_EXPLOSION = 0b00001000;
|
||||
public static final int DESTROYED_BUILD_AREA = 0b00010000;
|
||||
public static final int DESTROYED_TEST_BLOCK = 0b00100000;
|
||||
public static final int SERIALISATION_VERSION = 1;
|
||||
public static File tracesFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "traces");
|
||||
|
||||
@SneakyThrows
|
||||
public static Trace readTrace(File recordsFile) {
|
||||
protected static int getVersion(File metadataFile) {
|
||||
@Cleanup
|
||||
ObjectInputStream reader = new ObjectInputStream(new GZIPInputStream(new FileInputStream(recordsFile)));
|
||||
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(metadataFile));
|
||||
reader.readUTF();
|
||||
reader.readUTF();
|
||||
reader.readObject();
|
||||
try {
|
||||
int version = reader.readInt();
|
||||
return version;
|
||||
} catch (EOFException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static Trace readTrace(File metadataFile) {
|
||||
@Cleanup
|
||||
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(metadataFile));
|
||||
UUID uuid = UUID.fromString(reader.readUTF());
|
||||
Region region = Region.getREGION_MAP().get(reader.readUTF());
|
||||
Date date = (Date) reader.readObject();
|
||||
File recordsFile = new File(tracesFolder,uuid + ".records");
|
||||
int serialisationVersion = reader.readInt();
|
||||
if (serialisationVersion != SERIALISATION_VERSION) {
|
||||
return null;
|
||||
}
|
||||
int tntIdCount = reader.readInt();
|
||||
int recordsCount = reader.readInt();
|
||||
|
||||
return new Trace(uuid, region, date, recordsFile, tntIdCount);
|
||||
return new Trace(uuid, region, date, metadataFile, recordsFile, recordsCount);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
protected static void writeTrace(Trace trace, List<TNTPoint> records) {
|
||||
ObjectOutputStream outputStream = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(trace.getRecordsSaveFile())));
|
||||
ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(trace.getMetadataSaveFile()));
|
||||
outputStream.writeUTF(trace.getUuid().toString());
|
||||
outputStream.writeUTF(trace.getRegion().getName());
|
||||
outputStream.writeObject(trace.getDate());
|
||||
outputStream.writeInt(SERIALISATION_VERSION);
|
||||
outputStream.writeInt(records.size());
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
|
||||
Map<Integer, List<TNTPoint>> pointsByTNTId = new HashMap<>();
|
||||
records.forEach(tntPoint -> {
|
||||
pointsByTNTId.computeIfAbsent(tntPoint.getTntId(), integer -> new ArrayList<>()).add(tntPoint);
|
||||
});
|
||||
|
||||
outputStream.writeInt(pointsByTNTId.size());
|
||||
for (Map.Entry<Integer, List<TNTPoint>> entry : pointsByTNTId.entrySet()) {
|
||||
outputStream.writeInt(entry.getKey());
|
||||
outputStream.writeInt(entry.getValue().size());
|
||||
writeTraceRecords(trace.getRecordsSaveFile(), records);
|
||||
}
|
||||
|
||||
for (int i = 0; i < entry.getValue().size(); i++) {
|
||||
TNTPoint current = entry.getValue().get(i);
|
||||
if (i == 0) {
|
||||
writeTNTPoint(outputStream, current, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
TNTPoint last = entry.getValue().get(i - 1);
|
||||
|
||||
boolean writeTickData = true;
|
||||
if (last.getTicksSinceStart() + 1 == current.getTicksSinceStart() && last.getFuse() - 1 == current.getFuse()) {
|
||||
writeTickData = false;
|
||||
}
|
||||
|
||||
writeTNTPoint(outputStream, current, writeTickData);
|
||||
}
|
||||
@SneakyThrows
|
||||
protected static void writeTraceRecords(File recordsFile, List<TNTPoint> records) {
|
||||
DataOutputStream outputStream = new DataOutputStream(new FileOutputStream(recordsFile));
|
||||
for (TNTPoint record : records) {
|
||||
outputStream.writeInt(record.getTntId());
|
||||
outputStream.writeBoolean(record.isExplosion());
|
||||
outputStream.writeBoolean(record.isInWater());
|
||||
outputStream.writeBoolean(record.isAfterFirstExplosion());
|
||||
outputStream.writeBoolean(record.isDestroyedBuildArea());
|
||||
outputStream.writeBoolean(record.isDestroyedTestBlock());
|
||||
outputStream.writeLong(record.getTicksSinceStart());
|
||||
outputStream.writeInt(record.getFuse());
|
||||
Location location = record.getLocation();
|
||||
outputStream.writeDouble(location.getX());
|
||||
outputStream.writeDouble(location.getY());
|
||||
outputStream.writeDouble(location.getZ());
|
||||
Vector velocity = record.getVelocity();
|
||||
outputStream.writeDouble(velocity.getX());
|
||||
outputStream.writeDouble(velocity.getY());
|
||||
outputStream.writeDouble(velocity.getZ());
|
||||
}
|
||||
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private static void writeTNTPoint(ObjectOutputStream outputStream, TNTPoint tntPoint, boolean writeTickData) {
|
||||
byte data = 0;
|
||||
if (writeTickData) data |= WRITE_TICK_DATA;
|
||||
if (tntPoint.isExplosion()) data |= EXPLOSION;
|
||||
if (tntPoint.isInWater()) data |= IN_WATER;
|
||||
if (tntPoint.isAfterFirstExplosion()) data |= AFTER_FIRST_EXPLOSION;
|
||||
if (tntPoint.isDestroyedBuildArea()) data |= DESTROYED_BUILD_AREA;
|
||||
if (tntPoint.isDestroyedTestBlock()) data |= DESTROYED_TEST_BLOCK;
|
||||
outputStream.write(data);
|
||||
protected static TNTPoint readTraceRecord(DataInputStream objectInput) {
|
||||
|
||||
if (writeTickData) {
|
||||
outputStream.writeLong(tntPoint.getTicksSinceStart());
|
||||
outputStream.writeInt(tntPoint.getFuse());
|
||||
}
|
||||
|
||||
Location location = tntPoint.getLocation();
|
||||
outputStream.writeDouble(location.getX());
|
||||
outputStream.writeDouble(location.getY());
|
||||
outputStream.writeDouble(location.getZ());
|
||||
|
||||
Vector velocity = tntPoint.getVelocity();
|
||||
outputStream.writeDouble(velocity.getX());
|
||||
outputStream.writeDouble(velocity.getY());
|
||||
outputStream.writeDouble(velocity.getZ());
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
protected static TNTPoint readTraceRecord(int tntId, TNTPoint last, ObjectInputStream objectInput) {
|
||||
|
||||
int data = objectInput.read();
|
||||
boolean explosion = (data & EXPLOSION) > 0;
|
||||
boolean inWater = (data & IN_WATER) > 0;
|
||||
boolean afterFirstExplosion = (data & AFTER_FIRST_EXPLOSION) > 0;
|
||||
boolean destroyedBuildArea = (data & DESTROYED_BUILD_AREA) > 0;
|
||||
boolean destroyedTestBlock = (data & DESTROYED_TEST_BLOCK) > 0;
|
||||
|
||||
long ticksSinceStart;
|
||||
int fuse;
|
||||
if ((data & WRITE_TICK_DATA) > 0) {
|
||||
ticksSinceStart = objectInput.readLong();
|
||||
fuse = objectInput.readInt();
|
||||
} else {
|
||||
ticksSinceStart = last.getTicksSinceStart() + 1;
|
||||
fuse = last.getFuse() - 1;
|
||||
}
|
||||
int tntId = objectInput.readInt();
|
||||
boolean explosion = objectInput.readBoolean();
|
||||
boolean inWater = objectInput.readBoolean();
|
||||
boolean afterFirstExplosion = objectInput.readBoolean();
|
||||
boolean destroyedBuildArea = objectInput.readBoolean();
|
||||
boolean destroyedTestBlock = objectInput.readBoolean();
|
||||
long ticksSinceStart = objectInput.readLong();
|
||||
int fuse = objectInput.readInt();
|
||||
|
||||
double locX = objectInput.readDouble();
|
||||
double locY = objectInput.readDouble();
|
||||
@@ -146,29 +116,21 @@ public class TraceRepository {
|
||||
protected static List<TNTPoint> readTraceRecords(Trace trace) {
|
||||
File recordsFile = trace.getRecordsSaveFile();
|
||||
@Cleanup
|
||||
ObjectInputStream inputStream = new ObjectInputStream(new GZIPInputStream(new FileInputStream(recordsFile)));
|
||||
inputStream.readUTF();
|
||||
inputStream.readUTF();
|
||||
inputStream.readObject();
|
||||
inputStream.readInt();
|
||||
inputStream.readInt();
|
||||
DataInputStream inputStream = new DataInputStream(new FileInputStream(recordsFile));
|
||||
|
||||
List<TNTPoint> records = new ArrayList<>();
|
||||
Map<Integer, List<TNTPoint>> histories = new HashMap<>();
|
||||
for (int i = 0; i < trace.getTntIdCount(); i++) {
|
||||
int tntId = inputStream.readInt();
|
||||
int size = inputStream.readInt();
|
||||
List<TNTPoint> points = histories.computeIfAbsent(tntId, id -> new ArrayList<>());
|
||||
|
||||
TNTPoint last = null;
|
||||
for (int j = 0; j < size; j++) {
|
||||
TNTPoint point = readTraceRecord(tntId, last, inputStream);
|
||||
point.setHistory(points);
|
||||
points.add(point);
|
||||
last = point;
|
||||
records.add(point);
|
||||
}
|
||||
for (int i = 0; i < trace.getRecordsCount(); i++) {
|
||||
records.add(readTraceRecord(inputStream));
|
||||
}
|
||||
|
||||
Map<Integer, List<TNTPoint>> histories = new HashMap<>();
|
||||
for (TNTPoint record : records) {
|
||||
int tntId = record.getTntId();
|
||||
List<TNTPoint> history = histories.computeIfAbsent(tntId, id -> new ArrayList<>());
|
||||
history.add(record);
|
||||
record.setHistory(history);
|
||||
}
|
||||
|
||||
return records;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import de.steamwar.bausystem.shared.EnumDisplay;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@@ -203,9 +202,9 @@ public class MaterialCommand extends SWCommand implements Listener {
|
||||
private void searchGUI(Player p) {
|
||||
SWInventory swInventory = new SWInventory(p, 54, BauSystem.MESSAGE.parse("MATERIAL_SEARCH", p));
|
||||
Search search = searchMap.get(p);
|
||||
swInventory.setItem(0, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("MATERIAL_BACK", p), clickType -> {
|
||||
swInventory.setItem(45, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("MATERIAL_BACK", p), clickType -> {
|
||||
materialGUI(p);
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}));
|
||||
swInventory.setItem(10, new SWItem(Material.NAME_TAG, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_NAME", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.name), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_NAME", p), search.name);
|
||||
swAnvilInv.setCallback(s -> {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Warp {
|
||||
|
||||
public static void enable() {
|
||||
Warp worldSpawn = new Warp("WorldSpawn");
|
||||
worldSpawn.setLocation(Bukkit.getWorlds().get(0).getSpawnLocation().clone().add(0.5, Core.getVersion() >= 20 ? 124 : 1, 0.5));
|
||||
worldSpawn.setLocation(Bukkit.getWorlds().get(0).getSpawnLocation().clone().add(0.5, Core.getVersion() == 20 ? 124 : 1, 0.5));
|
||||
worldSpawn.setMat(Material.NETHER_STAR);
|
||||
warpMap.put("WorldSpawn", worldSpawn);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ public class BauLockStateScoreboard implements ScoreboardElement {
|
||||
public enum BauLockState {
|
||||
|
||||
NOBODY,
|
||||
SUPERVISOR,
|
||||
SERVERTEAM,
|
||||
TEAM_AND_SERVERTEAM,
|
||||
TEAM,
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
package de.steamwar.bausystem.utils.cursor;
|
||||
|
||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.util.Vector;
|
||||
import yapion.hierarchy.types.YAPIONType;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@Getter
|
||||
public class RCursor {
|
||||
private final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
private final REntityServer targetServer;
|
||||
private final REntityServer cursorServer;
|
||||
|
||||
private final Player owner;
|
||||
private final Material highlightMaterial;
|
||||
private final ClickHandler onClickHandler;
|
||||
|
||||
private RFallingBlockEntity cursorEntity;
|
||||
|
||||
private Location cursorLocation;
|
||||
private boolean isHittingEntity = false;
|
||||
|
||||
@Setter
|
||||
private Material cursorMaterial;
|
||||
@Setter
|
||||
private CursorMode cursorMode;
|
||||
private boolean visible = true;
|
||||
|
||||
|
||||
|
||||
public RCursor(REntityServer targetServer, Player owner, Material highlightMaterial, Material cursorMaterial, CursorMode cursorMode, ClickHandler onClickHandler) {
|
||||
this.targetServer = targetServer;
|
||||
this.owner = owner;
|
||||
this.highlightMaterial = highlightMaterial;
|
||||
this.cursorMaterial = cursorMaterial;
|
||||
this.cursorMode = cursorMode;
|
||||
this.onClickHandler = onClickHandler;
|
||||
|
||||
cursorServer = new REntityServer();
|
||||
cursorServer.addPlayer(owner);
|
||||
|
||||
RCursorManager.getInstance().registerCursor(this);
|
||||
}
|
||||
|
||||
public void render() {
|
||||
if (!visible) return;
|
||||
|
||||
RayTraceUtils.RRayTraceResult rayTraceResult = RayTraceUtils.traceREntity(owner, owner.getLocation(), targetServer.getEntities());
|
||||
if (rayTraceResult == null) {
|
||||
if(cursorEntity != null) cursorEntity.die();
|
||||
cursorEntity = null;
|
||||
return;
|
||||
}
|
||||
|
||||
REntity hitEntity = rayTraceResult.getHitEntity() == cursorEntity ? null : rayTraceResult.getHitEntity();
|
||||
|
||||
|
||||
Material activeCursorMaterial = hitEntity == null ? cursorMaterial : highlightMaterial;
|
||||
Location activeCursorLocation = hitEntity == null ? cursorMode.positionTransform.apply(owner, rayTraceResult).toLocation(WORLD)
|
||||
: new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ()).toLocation(WORLD);
|
||||
|
||||
cursorLocation = activeCursorLocation;
|
||||
isHittingEntity = hitEntity != null;
|
||||
|
||||
if (cursorEntity == null) {
|
||||
cursorEntity = new RFallingBlockEntity(cursorServer, activeCursorLocation, activeCursorMaterial);
|
||||
cursorEntity.setNoGravity(true);
|
||||
} if (cursorEntity.getMaterial() == activeCursorMaterial) {
|
||||
cursorEntity.move(activeCursorLocation);
|
||||
} else {
|
||||
cursorEntity.die();
|
||||
cursorEntity = new RFallingBlockEntity(cursorServer, activeCursorLocation, activeCursorMaterial);
|
||||
cursorEntity.setNoGravity(true);
|
||||
if(activeCursorMaterial == highlightMaterial) {
|
||||
cursorEntity.setGlowing(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
visible = false;
|
||||
if (cursorEntity != null) {
|
||||
cursorEntity.die();
|
||||
cursorEntity = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void show() {
|
||||
visible = true;
|
||||
}
|
||||
|
||||
void handleClick(Action action) {
|
||||
if(!visible || cursorLocation == null) return;
|
||||
|
||||
onClickHandler.handle(cursorLocation, isHittingEntity, action);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
cursorServer.close();
|
||||
RCursorManager.getInstance().unregisterCursor(this);
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum CursorMode {
|
||||
FREE((player, rayTraceResult) -> {
|
||||
Vector pos = rayTraceResult.getHitPosition();
|
||||
|
||||
BlockFace face = rayTraceResult.getHitBlockFace();
|
||||
if (face != null) {
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
pos.setY(pos.getY() - 0.98);
|
||||
break;
|
||||
case EAST:
|
||||
pos.setX(pos.getX() + 0.49);
|
||||
break;
|
||||
case WEST:
|
||||
pos.setX(pos.getX() - 0.49);
|
||||
break;
|
||||
case NORTH:
|
||||
pos.setZ(pos.getZ() - 0.49);
|
||||
break;
|
||||
case SOUTH:
|
||||
pos.setZ(pos.getZ() + 0.49);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (face.getModY() == 0 && player.isSneaking()) {
|
||||
pos.setY(pos.getY() - 0.49);
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.isSneaking()) {
|
||||
pos.setX(pos.getBlockX() + 0.5);
|
||||
if (face == null || face.getModY() == 0)
|
||||
pos.setY(pos.getBlockY() + 0.0);
|
||||
pos.setZ(pos.getBlockZ() + 0.5);
|
||||
}
|
||||
|
||||
return pos;
|
||||
}),
|
||||
BLOCK_ALIGNED((player, rayTraceResult) -> {
|
||||
Vector pos = rayTraceResult.getHitPosition();
|
||||
|
||||
BlockFace face = rayTraceResult.getHitBlockFace();
|
||||
if (face != null) {
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
pos.setY(pos.getY() - 0.98);
|
||||
break;
|
||||
case EAST:
|
||||
pos.setX(pos.getX() + 0.49);
|
||||
break;
|
||||
case WEST:
|
||||
pos.setX(pos.getX() - 0.49);
|
||||
break;
|
||||
case NORTH:
|
||||
pos.setZ(pos.getZ() - 0.49);
|
||||
break;
|
||||
case SOUTH:
|
||||
pos.setZ(pos.getZ() + 0.49);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pos.setX(pos.getBlockX() + 0.5);
|
||||
if (pos.getY() - pos.getBlockY() != 0 && face == BlockFace.UP) {
|
||||
pos.setY(pos.getBlockY() + 1.0);
|
||||
} else {
|
||||
pos.setY(pos.getBlockY());
|
||||
}
|
||||
pos.setZ(pos.getBlockZ() + 0.5);
|
||||
return pos;
|
||||
});
|
||||
|
||||
|
||||
private final BiFunction<Player, RayTraceUtils.RRayTraceResult, Vector> positionTransform;
|
||||
}
|
||||
|
||||
public interface ClickHandler{
|
||||
public void handle(Location cursorLocation, boolean didHitEntity, Action action);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package de.steamwar.bausystem.utils.cursor;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@Linked
|
||||
public class RCursorManager implements Listener {
|
||||
@Getter
|
||||
private static RCursorManager instance;
|
||||
|
||||
private final Set<Player> calculationActive = new HashSet<>();
|
||||
private final Map<Player, RCursor> activeCursors = new HashMap<>();
|
||||
|
||||
public RCursorManager() {
|
||||
if (instance == null) {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
BiFunction<Player, Object, Object> function = (player, object) -> {
|
||||
updateCursor(player);
|
||||
return object;
|
||||
};
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
Set<Player> playersWithActiveCursor = activeCursors.keySet();
|
||||
|
||||
playersWithActiveCursor.forEach(this::updateCursor);
|
||||
}, 0);
|
||||
|
||||
Class<?> positionPacketClass = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos");
|
||||
Class<?> lookPacketClass = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Rot");
|
||||
Class<?> positionLookPacketClass = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot");
|
||||
|
||||
TinyProtocol.instance.addFilter(positionPacketClass, function);
|
||||
TinyProtocol.instance.addFilter(lookPacketClass, function);
|
||||
TinyProtocol.instance.addFilter(positionLookPacketClass, function);
|
||||
}
|
||||
|
||||
void registerCursor(RCursor cursor) {
|
||||
closeCursorOf(cursor.getOwner());
|
||||
|
||||
activeCursors.put(cursor.getOwner(), cursor);
|
||||
}
|
||||
|
||||
void unregisterCursor(RCursor cursor) {
|
||||
activeCursors.remove(cursor.getOwner());
|
||||
}
|
||||
|
||||
private void closeCursorOf(Player player) {
|
||||
RCursor currentPlayerCursor = activeCursors.get(player);
|
||||
|
||||
if(currentPlayerCursor != null) {
|
||||
currentPlayerCursor.close();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void updateCursor(Player player) {
|
||||
if (!activeCursors.containsKey(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (calculationActive) {
|
||||
if (calculationActive.contains(player)) {
|
||||
return;
|
||||
} else {
|
||||
calculationActive.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
RCursor cursor = activeCursors.get(player);
|
||||
|
||||
if (cursor != null) {
|
||||
cursor.render();
|
||||
}
|
||||
|
||||
synchronized (calculationActive) {
|
||||
calculationActive.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
RCursor cursorOfPlayer = activeCursors.get(player);
|
||||
|
||||
cursorOfPlayer.handleClick(event.getAction());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void handlePlayerQuit(PlayerQuitEvent event) {
|
||||
closeCursorOf(event.getPlayer());
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,6 @@ tasks.register<DevServer>("DevBau20") {
|
||||
description = "Run a 1.20 Dev Bau"
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":BauSystem:shadowJar")
|
||||
dependsOn(":SchematicSystem:shadowJar")
|
||||
template = "Bau20"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.data;
|
||||
|
||||
// Custom Model Data Constants
|
||||
public interface CMDs {
|
||||
|
||||
// Material.ARROW
|
||||
int BACK = 1;
|
||||
|
||||
// Material.DYE (Color 10/8)
|
||||
int PREVIOUS_PAGE = 1;
|
||||
|
||||
// Material.DYE (Color 10/8)
|
||||
int NEXT_PAGE = 2;
|
||||
|
||||
// BauSystem Simulator
|
||||
interface Simulator {
|
||||
|
||||
// Material.BARRIER
|
||||
int DELETE = 1;
|
||||
|
||||
// Material.REPEATER
|
||||
int SETTINGS = 1;
|
||||
|
||||
// Material.ENDER_PEARL and Material.ENDER_EYE
|
||||
int ENABLED_OR_DISABLED = 1;
|
||||
|
||||
// Material.DYE (Color 10/8)
|
||||
int INCREMENT_OR_DISABLED = 3;
|
||||
|
||||
// Material.DYE (Color 1/8)
|
||||
int DECREMENT_OR_DISABLED = 3;
|
||||
|
||||
// Material.LEAD
|
||||
int JOIN_GROUP = 1;
|
||||
|
||||
// Material.ANVIL
|
||||
int EDIT_ACTIVATION = 1;
|
||||
|
||||
// Material.QUARTZ, Material.REDSTONE, Material.GUNPOWDER
|
||||
int NEW_PHASE = 1;
|
||||
|
||||
// Material.CALIBRATED_SCULK_SENSOR
|
||||
int CREATE_STAB = 1;
|
||||
|
||||
// Material.CHEST
|
||||
int MAKE_GROUP = 1;
|
||||
}
|
||||
|
||||
// Schematic System
|
||||
interface Schematic {
|
||||
|
||||
// Material.LEAD
|
||||
int BACK = 2;
|
||||
|
||||
// Material.BUCKET
|
||||
int OWN_SCHEMS = 1;
|
||||
|
||||
// Material.GLASS
|
||||
int PUBLIC_SCHEMS = 1;
|
||||
|
||||
// Material.CHEST
|
||||
int NEW_DIR = 2;
|
||||
|
||||
// Material.NAME_TAG
|
||||
int FILTER = 3;
|
||||
|
||||
// Material.PAPER, Material.CAULDRON, Material.CLOCK
|
||||
int SORT_ASCENDING = 3;
|
||||
|
||||
// Material.PAPER, Material.CAULDRON, Material.CLOCK
|
||||
int SORT_DESCENDING = 4;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.network.packets.common;
|
||||
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@ToString
|
||||
public class PlayerSkinRequestPacket extends NetworkPacket {
|
||||
|
||||
private static final long serialVersionUID = 277267302555671765L;
|
||||
private UUID uuid;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.network.packets.common;
|
||||
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@ToString
|
||||
public class PlayerSkinResponsePacket extends NetworkPacket {
|
||||
|
||||
private static final long serialVersionUID = 5792855362547625112L;
|
||||
private UUID uuid;
|
||||
private String skin;
|
||||
private String signature;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.network.packets.server;
|
||||
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class ClientVersionPacket extends NetworkPacket {
|
||||
private static final long serialVersionUID = 3686482311704273200L;
|
||||
|
||||
private UUID player;
|
||||
private int version;
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import lombok.Getter;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class CheckedSchematic {
|
||||
@@ -38,14 +37,15 @@ public class CheckedSchematic {
|
||||
private static final SelectStatement<CheckedSchematic> nodeHistory = new SelectStatement<>(table, "SELECT * FROM CheckedSchematic WHERE NodeId = ? AND DeclineReason != '' AND DeclineReason != 'Prüfvorgang abgebrochen' ORDER BY EndTime DESC");
|
||||
private static final Statement insert = table.insertAll();
|
||||
|
||||
private static final SelectStatement<CheckedSchematic> getUnseen = new SelectStatement<>(table, "SELECT * FROM CheckedSchematic WHERE Seen = 0 AND NodeOwner = ? ORDER BY StartTime DESC");
|
||||
private static final Statement updateSeen = new Statement("UPDATE CheckedSchematic SET Seen = ? WHERE StartTime = ? AND EndTime = ? AND NodeName = ?");
|
||||
|
||||
public static void create(SchematicNode node, int validator, Timestamp startTime, Timestamp endTime, String reason, boolean seen) {
|
||||
insert.update(node.getId(), node.getOwner(), node.getName(), validator, startTime, endTime, reason, seen, node.getSchemtype().toDB().substring(1));
|
||||
public static void create(int nodeId, String name, int owner, int validator, Timestamp startTime, Timestamp endTime, String reason){
|
||||
insert.update(nodeId, owner, name, validator, startTime, endTime, reason);
|
||||
}
|
||||
|
||||
public static List<CheckedSchematic> getLastDeclinedOfNode(int node) {
|
||||
public static void create(SchematicNode node, int validator, Timestamp startTime, Timestamp endTime, String reason){
|
||||
create(node.getId(), node.getName(), node.getOwner(), validator, startTime, endTime, reason);
|
||||
}
|
||||
|
||||
public static List<CheckedSchematic> getLastDeclinedOfNode(int node){
|
||||
return statusOfNode.listSelect(node);
|
||||
}
|
||||
|
||||
@@ -53,10 +53,6 @@ public class CheckedSchematic {
|
||||
return nodeHistory.listSelect(node.getId());
|
||||
}
|
||||
|
||||
public static List<CheckedSchematic> getUnseen(SteamwarUser owner) {
|
||||
return getUnseen.listSelect(owner);
|
||||
}
|
||||
|
||||
@Field(nullable = true)
|
||||
private final Integer nodeId;
|
||||
@Field
|
||||
@@ -75,12 +71,6 @@ public class CheckedSchematic {
|
||||
@Getter
|
||||
@Field
|
||||
private final String declineReason;
|
||||
@Getter
|
||||
@Field
|
||||
private boolean seen;
|
||||
@Getter
|
||||
@Field
|
||||
private final String nodeType;
|
||||
|
||||
public int getNode() {
|
||||
return nodeId;
|
||||
@@ -93,9 +83,4 @@ public class CheckedSchematic {
|
||||
public int getSchemOwner() {
|
||||
return nodeOwner;
|
||||
}
|
||||
|
||||
public void setSeen(boolean seen) {
|
||||
this.seen = seen;
|
||||
updateSeen.update(seen, startTime, endTime, nodeName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,18 +37,14 @@ public class EventFight implements Comparable<EventFight> {
|
||||
|
||||
private static final Table<EventFight> table = new Table<>(EventFight.class);
|
||||
private static final SelectStatement<EventFight> byId = table.select(Table.PRIMARY);
|
||||
private static final SelectStatement<EventFight> byGroup = new SelectStatement<EventFight>(table, "SELECT * FROM EventFight WHERE GroupID = ? ORDER BY StartTime ASC");
|
||||
private static final SelectStatement<EventFight> byGroupLast = new SelectStatement<EventFight>(table, "SELECT * FROM EventFight WHERE GroupID = ? ORDER BY StartTime DESC LIMIT 1");
|
||||
private static final SelectStatement<EventFight> allComing = new SelectStatement<>(table, "SELECT * FROM EventFight WHERE StartTime > now() ORDER BY StartTime ASC");
|
||||
private static final SelectStatement<EventFight> event = new SelectStatement<>(table, "SELECT * FROM EventFight WHERE EventID = ? ORDER BY StartTime ASC");
|
||||
private static final SelectStatement<EventFight> activeFights = new SelectStatement<>(table, "SELECT * FROM EventFight WHERE Fight IS NOT NULL AND StartTime < now() AND DATEDIFF(StartTime, now()) < 0");
|
||||
private static final Statement reschedule = table.update(Table.PRIMARY, "StartTime");
|
||||
private static final Statement setResult = table.update(Table.PRIMARY, "Ergebnis");
|
||||
private static final Statement setFight = table.update(Table.PRIMARY, "Fight");
|
||||
|
||||
private static final Statement create = table.insertFields(true, "eventID", "startTime", "spielmodus", "map", "teamBlue", "teamRed", "spectatePort");
|
||||
private static final Statement update = table.update(Table.PRIMARY, "startTime", "spielModus", "map", "teamBlue", "teamRed", "spectatePort");
|
||||
private static final Statement setGroup = table.update(Table.PRIMARY, "GroupID");
|
||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||
|
||||
@Getter
|
||||
@@ -58,14 +54,6 @@ public class EventFight implements Comparable<EventFight> {
|
||||
return byId.select(fightID);
|
||||
}
|
||||
|
||||
public static List<EventFight> get(EventGroup group) {
|
||||
return byGroup.listSelect(group.getId());
|
||||
}
|
||||
|
||||
public static Optional<EventFight> getLast(EventGroup group) {
|
||||
return Optional.ofNullable(byGroupLast.select(group.getId()));
|
||||
}
|
||||
|
||||
public static void loadAllComingFights() {
|
||||
fights.clear();
|
||||
fights.addAll(allComing.listSelect());
|
||||
@@ -75,19 +63,6 @@ public class EventFight implements Comparable<EventFight> {
|
||||
return event.listSelect(eventID);
|
||||
}
|
||||
|
||||
private static List<EventFight> activeFightsCache = null;
|
||||
|
||||
public static void clearActiveFightsCache() {
|
||||
activeFightsCache = null;
|
||||
}
|
||||
|
||||
public static List<EventFight> getActiveFights() {
|
||||
if (activeFightsCache == null) {
|
||||
activeFightsCache = activeFights.listSelect();
|
||||
}
|
||||
return activeFightsCache;
|
||||
}
|
||||
|
||||
public static EventFight create(int event, Timestamp from, String spielmodus, String map, int blueTeam, int redTeam, Integer spectatePort) {
|
||||
return get(create.insertGetKey(event, from, spielmodus, map, blueTeam, redTeam, spectatePort));
|
||||
}
|
||||
@@ -100,10 +75,6 @@ public class EventFight implements Comparable<EventFight> {
|
||||
private final int fightID;
|
||||
@Getter
|
||||
@Setter
|
||||
@Field(nullable = true, def = "null")
|
||||
private Integer groupId;
|
||||
@Getter
|
||||
@Setter
|
||||
@Field
|
||||
private Timestamp startTime;
|
||||
@Getter
|
||||
@@ -127,35 +98,11 @@ public class EventFight implements Comparable<EventFight> {
|
||||
@Field(nullable = true)
|
||||
private Integer spectatePort;
|
||||
@Getter
|
||||
@Setter
|
||||
@Field(def = "1")
|
||||
private int bestOf;
|
||||
@Getter
|
||||
@Field(def = "0")
|
||||
private int ergebnis;
|
||||
@Field(nullable = true)
|
||||
private int fight;
|
||||
|
||||
public Optional<EventGroup> getGroup() {
|
||||
return Optional.ofNullable(groupId).flatMap(EventGroup::get);
|
||||
}
|
||||
|
||||
public Optional<Team> getWinner() {
|
||||
if(ergebnis == 0)
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(ergebnis == 1 ? Team.get(teamBlue) : Team.get(teamRed));
|
||||
}
|
||||
|
||||
public Optional<Team> getLosser() {
|
||||
if(ergebnis == 0)
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(ergebnis == 1 ? Team.get(teamRed) : Team.get(teamBlue));
|
||||
}
|
||||
|
||||
public List<EventRelation> getDependents() {
|
||||
return EventRelation.getFightRelations(this);
|
||||
}
|
||||
|
||||
public void setErgebnis(int winner) {
|
||||
this.ergebnis = winner;
|
||||
setResult.update(winner, fightID);
|
||||
@@ -167,11 +114,6 @@ public class EventFight implements Comparable<EventFight> {
|
||||
setFight.update(fight, fightID);
|
||||
}
|
||||
|
||||
public void setGroup(Integer group) {
|
||||
setGroup.update(group, fightID);
|
||||
this.groupId = group;
|
||||
}
|
||||
|
||||
public boolean hasFinished() {
|
||||
return fight != 0 || ergebnis != 0;
|
||||
}
|
||||
|
||||
@@ -1,173 +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.sql;
|
||||
|
||||
import de.steamwar.sql.internal.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class EventGroup {
|
||||
static {
|
||||
SqlTypeMapper.ordinalEnumMapper(EventGroupType.class);
|
||||
}
|
||||
|
||||
private static final Table<EventGroup> table = new Table<>(EventGroup.class);
|
||||
|
||||
private static final SelectStatement<EventGroup> get = table.select(Table.PRIMARY);
|
||||
private static final SelectStatement<EventGroup> byEvent = new SelectStatement<>(table, "SELECT * FROM EventGroup WHERE EventID = ?");
|
||||
|
||||
private static final Statement insert = table.insertFields(true, "EventID", "Name", "Type");
|
||||
private static final Statement update = table.update(Table.PRIMARY, "Name", "Type", "PointsPerWin", "PointsPerLoss", "PointsPerDraw");
|
||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||
|
||||
public static List<EventGroup> get(Event eventID) {
|
||||
return byEvent.listSelect(eventID.getEventID());
|
||||
}
|
||||
|
||||
public static EventGroup create(Event event, String name, EventGroupType type) {
|
||||
int key = insert.insertGetKey(event.getEventID(), name, type);
|
||||
return EventGroup.get(key).get();
|
||||
}
|
||||
|
||||
public static Optional<EventGroup> get(int id) {
|
||||
return Optional.ofNullable(get.select(id));
|
||||
}
|
||||
|
||||
@Field(keys = Table.PRIMARY)
|
||||
private final int id;
|
||||
|
||||
@Field(keys = "EVENT_NAME")
|
||||
private int eventID;
|
||||
|
||||
@Field(keys = "EVENT_NAME")
|
||||
private String name;
|
||||
|
||||
@Field
|
||||
private EventGroupType type;
|
||||
|
||||
@Field
|
||||
private int pointsPerWin;
|
||||
|
||||
@Field
|
||||
private int pointsPerLoss;
|
||||
|
||||
@Field
|
||||
private int pointsPerDraw;
|
||||
|
||||
public EventGroup(int id, int eventID, String name, EventGroupType type, int pointsPerWin, int pointsPerLoss, int pointsPerDraw) {
|
||||
this.id = id;
|
||||
this.eventID = eventID;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.pointsPerWin = pointsPerWin;
|
||||
this.pointsPerLoss = pointsPerLoss;
|
||||
this.pointsPerDraw = pointsPerDraw;
|
||||
}
|
||||
|
||||
private Map<Team, Integer> points;
|
||||
|
||||
public List<EventFight> getFights() {
|
||||
return EventFight.get(this);
|
||||
}
|
||||
|
||||
public Set<Integer> getTeamsId() {
|
||||
return getFights().stream().flatMap(fight -> Stream.of(fight.getTeamBlue(), fight.getTeamRed()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public Set<Team> getTeams() {
|
||||
return getTeamsId().stream().map(Team::get).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public Optional<EventFight> getLastFight() {
|
||||
return EventFight.getLast(this);
|
||||
}
|
||||
|
||||
public List<EventRelation> getDependents() {
|
||||
return EventRelation.getGroupRelations(this);
|
||||
}
|
||||
|
||||
public Map<Team, Integer> calculatePoints() {
|
||||
if (points == null) {
|
||||
Map<Integer, Integer> p = getTeamsId().stream().collect(Collectors.toMap(team -> team, team -> 0));
|
||||
|
||||
for (EventFight fight : getFights()) {
|
||||
int blueTeamAdd = 0;
|
||||
int redTeamAdd = 0;
|
||||
|
||||
if (!fight.hasFinished()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (fight.getErgebnis()) {
|
||||
case 1:
|
||||
blueTeamAdd += pointsPerWin;
|
||||
redTeamAdd += pointsPerLoss;
|
||||
break;
|
||||
case 2:
|
||||
blueTeamAdd += pointsPerLoss;
|
||||
redTeamAdd += pointsPerWin;
|
||||
break;
|
||||
case 0:
|
||||
if (fight.getFightID() != 0) {
|
||||
blueTeamAdd += pointsPerDraw;
|
||||
redTeamAdd += pointsPerDraw;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
p.put(fight.getTeamBlue(), p.get(fight.getTeamBlue()) + blueTeamAdd);
|
||||
p.put(fight.getTeamRed(), p.get(fight.getTeamRed()) + redTeamAdd);
|
||||
}
|
||||
|
||||
points = p.entrySet().stream().collect(Collectors.toMap(integerIntegerEntry -> Team.get(integerIntegerEntry.getKey()), Map.Entry::getValue));
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
public void update(String name, EventGroupType type, int pointsPerWin, int pointsPerLoss, int pointsPerDraw) {
|
||||
update.update(name, type, pointsPerWin, pointsPerLoss, pointsPerDraw, id);
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.pointsPerWin = pointsPerWin;
|
||||
this.pointsPerLoss = pointsPerLoss;
|
||||
this.pointsPerDraw = pointsPerDraw;
|
||||
}
|
||||
|
||||
public boolean needsTieBreak() {
|
||||
return calculatePoints().values().stream().sorted().limit(2).distinct().count() < 2;
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
delete.update(id);
|
||||
}
|
||||
|
||||
public static enum EventGroupType {
|
||||
GROUP_STAGE,
|
||||
ELIMINATION_STAGE
|
||||
}
|
||||
}
|
||||
@@ -1,192 +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.sql;
|
||||
|
||||
import de.steamwar.sql.internal.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class EventRelation {
|
||||
|
||||
static {
|
||||
SqlTypeMapper.ordinalEnumMapper(FightTeam.class);
|
||||
SqlTypeMapper.ordinalEnumMapper(FromType.class);
|
||||
}
|
||||
|
||||
private static final Table<EventRelation> table = new Table<>(EventRelation.class);
|
||||
|
||||
private static final SelectStatement<EventRelation> get = new SelectStatement<>(table, "SELECT * FROM EventRelation WHERE FromType = ? AND FromId = ?");
|
||||
private static final SelectStatement<EventRelation> byId = new SelectStatement<>(table, "SELECT * FROM EventRelation WHERE id = ?");
|
||||
private static final SelectStatement<EventRelation> byEvent = new SelectStatement<>(table, "SELECT ER.* FROM EventRelation ER JOIN EventFight EF ON EF.id = ER.fightId WHERE EF.EventID = ?");
|
||||
private static final Statement insert = table.insertAll(true);
|
||||
private static final Statement update = table.update(Table.PRIMARY, "fromType", "fromId", "fromPlace");
|
||||
private static final Statement updateTeam = table.update(Table.PRIMARY, "fightTeam");
|
||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||
|
||||
public static List<EventRelation> get(Event event) {
|
||||
return byId.listSelect(event.getEventID());
|
||||
}
|
||||
|
||||
public static EventRelation get(int id) {
|
||||
return byId.select(id);
|
||||
}
|
||||
|
||||
public static List<EventRelation> getFightRelations(EventFight fight) {
|
||||
return get.listSelect(FromType.FIGHT, fight.getFightID());
|
||||
}
|
||||
|
||||
public static List<EventRelation> getGroupRelations(EventGroup group) {
|
||||
return get.listSelect(FromType.GROUP, group.getId());
|
||||
}
|
||||
|
||||
public static EventRelation create(EventFight fight, FightTeam fightTeam, FromType fromType, int fromId, int fromPlace) {
|
||||
int id = insert.insertGetKey(fight.getFightID(), fightTeam, fromType, fromId, fromPlace);
|
||||
return get(id);
|
||||
}
|
||||
|
||||
@Field(keys = Table.PRIMARY)
|
||||
private final int id;
|
||||
|
||||
@Field
|
||||
private int fightId;
|
||||
|
||||
@Field
|
||||
private FightTeam fightTeam;
|
||||
|
||||
@Field
|
||||
private FromType fromType;
|
||||
|
||||
@Field
|
||||
private int fromId;
|
||||
|
||||
@Field
|
||||
private int fromPlace;
|
||||
|
||||
public EventFight getFight() {
|
||||
return EventFight.get(fightId);
|
||||
}
|
||||
|
||||
public Optional<EventFight> getFromFight() {
|
||||
if(fromType == FromType.FIGHT) {
|
||||
return Optional.of(EventFight.get(fromId));
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<EventGroup> getFromGroup() {
|
||||
if(fromType == FromType.GROUP) {
|
||||
return EventGroup.get(fromId);
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
delete.update(id);
|
||||
}
|
||||
|
||||
public void setUpdateTeam(FightTeam team) {
|
||||
updateTeam.update(id, team);
|
||||
this.fightTeam = team;
|
||||
}
|
||||
|
||||
public void setFromFight(EventFight fight, int place) {
|
||||
setFrom(fight.getFightID(), place, FromType.FIGHT);
|
||||
}
|
||||
|
||||
public void setFromGroup(EventGroup group, int place) {
|
||||
setFrom(group.getId(), place, FromType.GROUP);
|
||||
}
|
||||
|
||||
private void setFrom(int id, int place, FromType type) {
|
||||
update.update(id, type, id, place);
|
||||
this.fromType = type;
|
||||
this.fromId = id;
|
||||
this.fromPlace = place;
|
||||
}
|
||||
|
||||
public Optional<Team> getAdvancingTeam() {
|
||||
if (fromType == FromType.FIGHT) {
|
||||
if (fromPlace == 0) {
|
||||
return getFromFight().flatMap(EventFight::getWinner);
|
||||
} else {
|
||||
return getFromFight().flatMap(EventFight::getLosser);
|
||||
}
|
||||
} else if (fromType == FromType.GROUP) {
|
||||
return getFromGroup().map(EventGroup::calculatePoints)
|
||||
.flatMap(points -> points.entrySet().stream()
|
||||
.sorted(Map.Entry.<Team, Integer>comparingByValue().reversed())
|
||||
.skip(fromPlace)
|
||||
.findFirst()
|
||||
.map(Map.Entry::getKey));
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean apply() {
|
||||
Optional<Integer> team = getAdvancingTeam().map(Team::getTeamId);
|
||||
if(!team.isPresent())
|
||||
return false;
|
||||
|
||||
EventFight fight = getFight();
|
||||
if(fightTeam == FightTeam.RED) {
|
||||
fight.update(
|
||||
fight.getStartTime(),
|
||||
fight.getSpielmodus(),
|
||||
fight.getMap(),
|
||||
team.get(),
|
||||
fight.getTeamBlue(),
|
||||
fight.getSpectatePort()
|
||||
);
|
||||
} else {
|
||||
fight.update(
|
||||
fight.getStartTime(),
|
||||
fight.getSpielmodus(),
|
||||
fight.getMap(),
|
||||
fight.getTeamRed(),
|
||||
team.get(),
|
||||
fight.getSpectatePort()
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static enum FightTeam {
|
||||
RED,
|
||||
BLUE
|
||||
}
|
||||
|
||||
public static enum FromType {
|
||||
FIGHT,
|
||||
GROUP
|
||||
}
|
||||
}
|
||||
94
CommonCore/SQL/src/de/steamwar/sql/Tutorial.java
Normal file
94
CommonCore/SQL/src/de/steamwar/sql/Tutorial.java
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 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.sql;
|
||||
|
||||
import de.steamwar.sql.internal.Field;
|
||||
import de.steamwar.sql.internal.SelectStatement;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import de.steamwar.sql.internal.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class Tutorial {
|
||||
|
||||
private static final Table<Tutorial> table = new Table<>(Tutorial.class);
|
||||
private static final SelectStatement<Tutorial> by_popularity = new SelectStatement<>(table, "SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Released = ? GROUP BY t.TutorialID ORDER BY SUM(r.Stars) DESC LIMIT ?, ?");
|
||||
private static final SelectStatement<Tutorial> own = new SelectStatement<>(table, "SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Creator = ? GROUP BY t.TutorialID ORDER BY t.TutorialID ASC LIMIT ?, ?");
|
||||
private static final SelectStatement<Tutorial> by_creator_name = new SelectStatement<>(table, "SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Creator = ? AND t.Name = ? GROUP BY t.TutorialID");
|
||||
private static final SelectStatement<Tutorial> by_id = new SelectStatement<>(table, "SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.TutorialID = ? GROUP BY t.TutorialID");
|
||||
private static final Statement rate = new Statement("INSERT INTO TutorialRating (TutorialID, UserID, Stars) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Stars = VALUES(Stars)");
|
||||
private static final Statement create = new Statement("INSERT INTO Tutorial (Creator, Name, Item) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Item = VALUES(Item), Released = 0");
|
||||
private static final Statement release = table.update(Table.PRIMARY, "released");
|
||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||
|
||||
public static List<Tutorial> getPage(int page, int elementsPerPage, boolean released) {
|
||||
List<Tutorial> tutorials = by_popularity.listSelect(released, page * elementsPerPage, elementsPerPage);
|
||||
SteamwarUser.batchCache(tutorials.stream().map(tutorial -> tutorial.creator).collect(Collectors.toSet()));
|
||||
return tutorials;
|
||||
}
|
||||
|
||||
public static List<Tutorial> getOwn(int user, int page, int elementsPerPage) {
|
||||
return own.listSelect(user, page * elementsPerPage, elementsPerPage);
|
||||
}
|
||||
|
||||
public static Tutorial create(int creator, String name, String item) {
|
||||
create.update(creator, name, item);
|
||||
return by_creator_name.select(creator, name);
|
||||
}
|
||||
|
||||
public static Tutorial get(int id) {
|
||||
return by_id.select(id);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
||||
private final int tutorialId;
|
||||
@Getter
|
||||
@Field(keys = {"CreatorName"})
|
||||
private final int creator;
|
||||
@Getter
|
||||
@Field(keys = {"CreatorName"})
|
||||
private final String name;
|
||||
@Getter
|
||||
@Field(def = "'BOOK'")
|
||||
private final String item;
|
||||
@Getter
|
||||
@Field(def = "0")
|
||||
private final boolean released;
|
||||
@Getter
|
||||
@Field(def = "0") // Not really a field, but necessary for select generation
|
||||
private final double stars;
|
||||
|
||||
public void release() {
|
||||
release.update(1, tutorialId);
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
delete.update(tutorialId);
|
||||
}
|
||||
|
||||
public void rate(int user, int rating) {
|
||||
rate.update(tutorialId, user, rating);
|
||||
}
|
||||
}
|
||||
@@ -48,19 +48,18 @@ public enum UserPerm {
|
||||
public static final Map<UserPerm, Prefix> prefixes;
|
||||
public static final Prefix emptyPrefix;
|
||||
static {
|
||||
// https://www.digminecraft.com/lists/color_list_pc.php
|
||||
SqlTypeMapper.nameEnumMapper(UserPerm.class);
|
||||
Map<UserPerm, Prefix> p = new EnumMap<>(UserPerm.class);
|
||||
emptyPrefix = new Prefix("§7", "");
|
||||
p.put(PREFIX_NONE, emptyPrefix);
|
||||
p.put(PREFIX_YOUTUBER, new Prefix("§7", "YT"));
|
||||
p.put(PREFIX_GUIDE, new Prefix("§a", "Guide")); // 55FF55
|
||||
p.put(PREFIX_GUIDE, new Prefix("§a", "Guide"));
|
||||
|
||||
p.put(PREFIX_SUPPORTER, new Prefix("§x§3§4§0§0§f§f", "Sup")); // 3400ff
|
||||
p.put(PREFIX_MODERATOR, new Prefix("§x§c§7§5§e§2§2", "Mod")); // C75E22
|
||||
p.put(PREFIX_BUILDER, new Prefix("§2", "Arch")); // 00AA00
|
||||
p.put(PREFIX_DEVELOPER, new Prefix("§3", "Dev")); // 00AAAA
|
||||
p.put(PREFIX_ADMIN, new Prefix("§x§F§2§2§8§2§4", "Admin")); // F22824
|
||||
p.put(PREFIX_SUPPORTER, new Prefix("§6", "Sup"));
|
||||
p.put(PREFIX_MODERATOR, new Prefix("§6", "Mod"));
|
||||
p.put(PREFIX_BUILDER, new Prefix("§e", "Arch"));
|
||||
p.put(PREFIX_DEVELOPER, new Prefix("§e", "Dev"));
|
||||
p.put(PREFIX_ADMIN, new Prefix("§e", "Admin"));
|
||||
prefixes = Collections.unmodifiableMap(p);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,5 +24,4 @@ plugins {
|
||||
dependencies {
|
||||
api(project(":CommonCore:SQL"))
|
||||
api(project(":CommonCore:Network"))
|
||||
api(project(":CommonCore:Data"))
|
||||
}
|
||||
|
||||
@@ -25,6 +25,6 @@ public class CraftbukkitWrapper21 extends CraftbukkitWrapper18 {
|
||||
|
||||
@Override
|
||||
public float headRotation(Entity e) {
|
||||
return getEntity(e).getYHeadRot();
|
||||
return getEntity(e).bS();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,10 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
|
||||
@@ -59,7 +59,6 @@ public class Config {
|
||||
public static final Region RedExtendRegion;
|
||||
public static final Region ArenaRegion;
|
||||
public static final Region PlayerRegion;
|
||||
public static final Region BlueInsetRegion;
|
||||
|
||||
public static final Location TeamBlueSpawn;
|
||||
public static final Location TeamRedSpawn;
|
||||
@@ -194,11 +193,6 @@ public class Config {
|
||||
ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates", false);
|
||||
UnlimitedPrepare = config.getBoolean("Schematic.UnlimitedPrepare", false);
|
||||
|
||||
int schemInsetX = config.getInt("Schematic.Inset.x", 0);
|
||||
int schemInsetZ = config.getInt("Schematic.Inset.z", 0);
|
||||
int schemInsetBottom = config.getInt("Schematic.Inset.bottom", 0);
|
||||
int schemInsetTop = config.getInt("Schematic.Inset.top", 0);
|
||||
|
||||
GameName = config.getString("GameName", "WarGear");
|
||||
TeamChatDetection = config.getString("TeamChatPrefix", "+");
|
||||
|
||||
@@ -324,8 +318,6 @@ public class Config {
|
||||
ArenaRegion = Region.withExtension(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0);
|
||||
PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX, world.getMaxHeight(), arenaMaxZ);
|
||||
|
||||
BlueInsetRegion = new Region(BluePasteRegion.getMinX() + schemInsetX, BluePasteRegion.getMinY() + schemInsetBottom, BluePasteRegion.getMinZ() + schemInsetZ, BluePasteRegion.getMaxX() - schemInsetX, BluePasteRegion.getMaxY() - schemInsetTop, BluePasteRegion.getMaxZ() - schemInsetZ);
|
||||
|
||||
int eventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||
if(eventKampfID >= 1){
|
||||
EventKampf = EventFight.get(eventKampfID);
|
||||
@@ -367,7 +359,7 @@ public class Config {
|
||||
}else{
|
||||
//No event
|
||||
TeamRedColor = config.getString("Red.Prefix", "§c");
|
||||
TeamBlueColor = config.getString("Blue.Prefix", "§9");
|
||||
TeamBlueColor = config.getString("Blue.Prefix", "§3");
|
||||
TeamRedName = config.getString("Red.Name", "Rot");
|
||||
TeamBlueName = config.getString("Blue.Name", "Blau");
|
||||
OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics", false);
|
||||
|
||||
@@ -20,17 +20,19 @@
|
||||
package de.steamwar.fightsystem;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.commands.*;
|
||||
import de.steamwar.fightsystem.countdown.*;
|
||||
import de.steamwar.fightsystem.event.*;
|
||||
import de.steamwar.fightsystem.event.HellsBells;
|
||||
import de.steamwar.fightsystem.event.Meteor;
|
||||
import de.steamwar.fightsystem.event.PersistentDamage;
|
||||
import de.steamwar.fightsystem.event.TNTDistributor;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import de.steamwar.fightsystem.fight.HotbarKit;
|
||||
import de.steamwar.fightsystem.listener.*;
|
||||
import de.steamwar.fightsystem.listener.Shutdown;
|
||||
import de.steamwar.fightsystem.listener.*;
|
||||
import de.steamwar.fightsystem.record.FileRecorder;
|
||||
import de.steamwar.fightsystem.record.FileSource;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
@@ -107,7 +109,6 @@ public class FightSystem extends JavaPlugin {
|
||||
new HotbarKit.HotbarKitListener();
|
||||
new JoinRequestListener();
|
||||
new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
|
||||
new OneShotStateDependent(ArenaMode.Test, FightState.All, WorldEditRendererCUIEditor::new);
|
||||
|
||||
new EnterHandler();
|
||||
techHider = new TechHiderWrapper();
|
||||
@@ -135,7 +136,6 @@ public class FightSystem extends JavaPlugin {
|
||||
new PersistentDamage();
|
||||
new TNTDistributor();
|
||||
new WinconditionAmongUs();
|
||||
new NoGravity();
|
||||
|
||||
new NoPlayersOnlineCountdown();
|
||||
new PreSchemCountdown();
|
||||
@@ -179,8 +179,6 @@ public class FightSystem extends JavaPlugin {
|
||||
Fight.getRedTeam().setSchem(unpreparedSchematicNode);
|
||||
}
|
||||
}
|
||||
|
||||
new TechareaCommand();
|
||||
}else if(Config.mode == ArenaMode.PREPARE) {
|
||||
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID));
|
||||
}
|
||||
|
||||
@@ -76,7 +76,6 @@ KITSEARCH_TITLE=Search for kit
|
||||
|
||||
SCHEM_NO_ENEMY=§cNo schematic selection without an opponent
|
||||
SCHEM_TITLE={0} selection
|
||||
SCHEM_DIRT=§eDirt Block
|
||||
SCHEM_PUBLIC=§ePublic {0}
|
||||
SCHEM_UNCHECKED=§eUnchecked {0}
|
||||
SCHEM_PRIVATE=§ePrivate {0}
|
||||
|
||||
@@ -70,7 +70,6 @@ KITSEARCH_TITLE=Nach Kit suchen
|
||||
|
||||
SCHEM_NO_ENEMY=§cKeine Schematicwahl ohne Gegner
|
||||
SCHEM_TITLE={0}-Auswahl
|
||||
SCHEM_DIRT=§eErdblock
|
||||
SCHEM_PUBLIC=§eÖffentliches {0}
|
||||
SCHEM_UNCHECKED=§eUngeprüftes {0}
|
||||
SCHEM_PRIVATE=§ePrivates {0}
|
||||
|
||||
@@ -24,14 +24,15 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.ai.AIManager;
|
||||
import de.steamwar.fightsystem.fight.*;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||
import de.steamwar.inventory.*;
|
||||
import de.steamwar.message.Message;
|
||||
import de.steamwar.sql.*;
|
||||
import de.steamwar.sql.PersonalKit;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -39,10 +40,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUI {
|
||||
@@ -208,14 +206,6 @@ public class GUI {
|
||||
for (int i = 0; i < Config.SubTypes.size(); i++) {
|
||||
setupSchemTypeRow(p, inv, Config.SubTypes.get(i), i + 1);
|
||||
}
|
||||
if (!Config.test() && SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.TEAM)) {
|
||||
SchematicNode node = SchematicNode.getSchematicNode(-1, Config.GameName, (Integer) null);
|
||||
if (node != null) {
|
||||
inv.setItem(2, new SWItem(SWItem.getMaterial(node.getItem()), msg.parse("SCHEM_DIRT", p), click -> {
|
||||
schemSelect(p, node);
|
||||
}));
|
||||
}
|
||||
}
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
@@ -251,18 +241,14 @@ public class GUI {
|
||||
|
||||
private static void schemDialog(Player p, SchematicType type, boolean publicSchems, boolean unchecked){
|
||||
SchematicSelector selector = new SchematicSelector(p, Config.test() ? SchematicSelector.selectSchematic() : SchematicSelector.selectSchematicType(unchecked ? type.checkType() : type), node -> {
|
||||
schemSelect(p, node);
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
||||
if(fightTeam == null)
|
||||
return;
|
||||
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||
fightTeam.pasteSchem(node);
|
||||
p.closeInventory();
|
||||
});
|
||||
selector.setPublicMode(publicSchems?SchematicSelector.PublicMode.PUBLIC_ONLY:SchematicSelector.PublicMode.PRIVATE_ONLY);
|
||||
selector.open();
|
||||
}
|
||||
|
||||
private static void schemSelect(Player p, SchematicNode node) {
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
||||
if(fightTeam == null)
|
||||
return;
|
||||
if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||
fightTeam.pasteSchem(node);
|
||||
p.closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.entity.CWireframe;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TechareaCommand extends SWCommand {
|
||||
private final Map<UUID, REntityServer> servers = new HashMap<>();
|
||||
|
||||
public TechareaCommand() {
|
||||
super("techarea");
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> servers.forEach((uuid, rEntityServer) -> rEntityServer.tick()), 2, 2);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player player) {
|
||||
if (servers.containsKey(player.getUniqueId())) {
|
||||
servers.get(player.getUniqueId()).close();
|
||||
} else {
|
||||
REntityServer server = new REntityServer();
|
||||
CWireframe wireframe = new CWireframe(server);
|
||||
|
||||
wireframe.setPos1(Config.BlueInsetRegion.getMinLocation(Config.world));
|
||||
wireframe.setPos2(Config.BlueInsetRegion.getMaxLocation(Config.world).subtract(1, 1, 1));
|
||||
wireframe.setBlock(Material.RED_CONCRETE.createBlockData());
|
||||
|
||||
server.addPlayer(player);
|
||||
servers.put(player.getUniqueId(), server);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -40,9 +39,7 @@ public class WGCommand implements CommandExecutor {
|
||||
if(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
FightWorld.resetWorld();
|
||||
Fight.getBlueTeam().pasteSchem();
|
||||
Fight.getRedTeam().pasteSchem();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,6 @@ public class FightSchematic extends StateDependent {
|
||||
FreezeWorld freezer = new FreezeWorld();
|
||||
|
||||
team.teleportToSpawn();
|
||||
|
||||
Vector dims = WorldeditWrapper.impl.getDimensions(clipboard);
|
||||
WorldeditWrapper.impl.pasteClipboard(
|
||||
clipboard,
|
||||
|
||||
@@ -86,10 +86,7 @@ public class PrepareSchem implements Listener {
|
||||
if(schemExists(schem))
|
||||
return;
|
||||
|
||||
SchematicNode old = schem;
|
||||
schem = SchematicNode.createSchematicNode(schem.getOwner(), preparedName(schem), schem.getParent(), Config.SchematicType.checkType().toDB(), schem.getItem());
|
||||
schem.setReplaceColor(old.replaceColor());
|
||||
schem.setAllowReplay(old.allowReplay());
|
||||
|
||||
try{
|
||||
WorldeditWrapper.impl.saveSchem(schem, region, minY);
|
||||
|
||||
@@ -33,8 +33,6 @@ import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.fightsystem.winconditions.Wincondition;
|
||||
import de.steamwar.network.NetworkSender;
|
||||
import de.steamwar.network.packets.common.FightEndsPacket;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.EventRelation;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.Getter;
|
||||
@@ -72,21 +70,12 @@ public class FightStatistics {
|
||||
}
|
||||
|
||||
private void setEventResult() {
|
||||
if (FightSystem.getLastWinner() == null) {
|
||||
if (FightSystem.getLastWinner() == null)
|
||||
Config.EventKampf.setErgebnis(0);
|
||||
} else if (FightSystem.getLastWinner().isBlue()) {
|
||||
else if (FightSystem.getLastWinner().isBlue())
|
||||
Config.EventKampf.setErgebnis(1);
|
||||
} else {
|
||||
else
|
||||
Config.EventKampf.setErgebnis(2);
|
||||
}
|
||||
|
||||
Config.EventKampf.getDependents().forEach(EventRelation::apply);
|
||||
|
||||
Config.EventKampf.getGroup().ifPresent(group -> {
|
||||
if (group.getLastFight().map(EventFight::getFightID).orElse(-1) == Config.EventKampf.getFightID() && !group.needsTieBreak()) {
|
||||
group.getDependents().forEach(EventRelation::apply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void disable() {
|
||||
|
||||
@@ -23,7 +23,6 @@ import de.steamwar.techhider.ProtocolUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.function.ObjIntConsumer;
|
||||
@@ -78,14 +77,6 @@ public class Region {
|
||||
return ProtocolUtils.posToChunk(maxZ);
|
||||
}
|
||||
|
||||
public Location getMinLocation(World world) {
|
||||
return new Location(world, minX, minY, minZ);
|
||||
}
|
||||
|
||||
public Location getMaxLocation(World world) {
|
||||
return new Location(world, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
public boolean chunkOutside(int cX, int cZ) {
|
||||
return getMinChunkX() > cX || cX > getMaxChunkX() ||
|
||||
getMinChunkZ() > cZ || cZ > getMaxChunkZ();
|
||||
|
||||
@@ -84,9 +84,6 @@ public class WinconditionBlocks extends Wincondition implements PrintableWincond
|
||||
}
|
||||
|
||||
private void check() {
|
||||
// Edge Case for DirtBlock
|
||||
if (blocks.isEmpty()) return;
|
||||
|
||||
blocks.removeIf(block -> !isOfType.test(block));
|
||||
if(blocks.isEmpty())
|
||||
win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName());
|
||||
|
||||
@@ -78,7 +78,6 @@ public class WinconditionPercent extends Wincondition implements PrintableWincon
|
||||
|
||||
private int totalBlocks = 0;
|
||||
private int currentBlocks = 0;
|
||||
private boolean countAnyBlock = false;
|
||||
|
||||
private TeamPercent(FightTeam team, Winconditions wincondition) {
|
||||
this.team = team;
|
||||
@@ -99,7 +98,7 @@ public class WinconditionPercent extends Wincondition implements PrintableWincon
|
||||
}
|
||||
|
||||
event.blockList().forEach(block -> {
|
||||
if (countAnyBlock || Config.PercentBlocks.contains(block.getType()) == Config.PercentBlocksWhitelist) {
|
||||
if (Config.PercentBlocks.contains(block.getType()) == Config.PercentBlocksWhitelist) {
|
||||
currentBlocks--;
|
||||
}
|
||||
});
|
||||
@@ -109,16 +108,10 @@ public class WinconditionPercent extends Wincondition implements PrintableWincon
|
||||
|
||||
private void enable() {
|
||||
totalBlocks = 0;
|
||||
countAnyBlock = false;
|
||||
team.getSchemRegion().forEach((x, y, z) -> {
|
||||
if (Config.PercentBlocks.contains(Config.world.getBlockAt(x, y, z).getType()) == Config.PercentBlocksWhitelist)
|
||||
totalBlocks++;
|
||||
});
|
||||
// Edge Case for DirtBlock
|
||||
if (totalBlocks == 0) {
|
||||
totalBlocks = team.getSchemRegion().volume();
|
||||
countAnyBlock = true;
|
||||
}
|
||||
currentBlocks = totalBlocks;
|
||||
postEnable.accept(team);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,5 @@ public enum Winconditions {
|
||||
METEOR,
|
||||
AMONG_US,
|
||||
PERSISTENT_DAMAGE,
|
||||
TNT_DISTRIBUTION,
|
||||
NO_GRAVITY,
|
||||
TNT_DISTRIBUTION
|
||||
}
|
||||
|
||||
@@ -34,12 +34,3 @@ dependencies {
|
||||
compileOnly(libs.nms20)
|
||||
compileOnly(libs.worldedit15)
|
||||
}
|
||||
|
||||
tasks.register<DevServer>("DevLobby20") {
|
||||
group = "run"
|
||||
description = "Run a 1.20 Dev Lobby"
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":LobbySystem:jar")
|
||||
template = "Lobby20"
|
||||
worldName = "Lobby"
|
||||
}
|
||||
|
||||
@@ -78,17 +78,14 @@ public enum CustomEasterParticle implements ParticleEnum {
|
||||
// TODO: Implement TheReaper22122!
|
||||
// TODO: Implement Bosslar!
|
||||
// TODO: Implement ATOM65!
|
||||
PLAYER_3266(new ParticleData(Material.BREAD, "PARTICLE_PLAYER_3266", ParticleRequirement.easterEventSpecificPlayer(3266),
|
||||
new Group(
|
||||
new Always(new Sneaking(new LocationMutator(new None(), location -> location))),
|
||||
new Always(new NonFlying(new LocationMutator(new TrippleCircle(
|
||||
new DustParticle(Particle.REDSTONE, new Gradient(Color.CYAN, Color.BLUE, Color.MAGENTA.darker(), Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN)),
|
||||
new DustParticle(Particle.REDSTONE, new Gradient(Color.CYAN, Color.BLUE, Color.MAGENTA.darker(), Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN)),
|
||||
new DustParticle(Particle.REDSTONE, new Gradient(Color.CYAN, Color.BLUE, Color.MAGENTA.darker(), Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN)),
|
||||
0.7,
|
||||
0.5), location -> location.add(0, 0.6, 0)
|
||||
))))
|
||||
)
|
||||
PLAYER_3266(new ParticleData(Material.CHORUS_FRUIT, "PARTICLE_PLAYER_3266", ParticleRequirement.easterEventSpecificPlayer(3266),
|
||||
new Always(new NonFlying(new Cloud(new LocationMutator(new TrippleCircle(
|
||||
new DustParticle(Particle.REDSTONE, new Gradient(Color.CYAN, Color.BLUE, Color.MAGENTA.darker(), Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN)),
|
||||
new DustParticle(Particle.REDSTONE, new Gradient(Color.CYAN, Color.BLUE, Color.MAGENTA.darker(), Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN)),
|
||||
new DustParticle(Particle.REDSTONE, new Gradient(Color.CYAN, Color.BLUE, Color.MAGENTA.darker(), Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN)),
|
||||
0.7,
|
||||
0.5), location -> location.add(0, 0.6, 0)
|
||||
)))))
|
||||
),
|
||||
// TODO: Implement Gehfxhler!
|
||||
// TODO: Implement SchwarzerFuerst
|
||||
|
||||
@@ -37,7 +37,7 @@ public class EndCountdown extends StateDependent {
|
||||
@Override
|
||||
public void enable() {
|
||||
if (Config.isEvent()) {
|
||||
task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::stop, 200);
|
||||
task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::stop, 1200);
|
||||
} else {
|
||||
task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::restart, Config.EndTime);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,57 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class AutoChecker15 implements AutoChecker.IAutoChecker {
|
||||
private static final Set<Material> INVENTORY = EnumSet.of(
|
||||
Material.BARREL,
|
||||
Material.BLAST_FURNACE,
|
||||
Material.BREWING_STAND,
|
||||
Material.CAMPFIRE,
|
||||
Material.CHEST,
|
||||
Material.DISPENSER,
|
||||
Material.DROPPER,
|
||||
Material.FURNACE,
|
||||
Material.HOPPER,
|
||||
Material.JUKEBOX,
|
||||
Material.SHULKER_BOX,
|
||||
Material.WHITE_SHULKER_BOX,
|
||||
Material.ORANGE_SHULKER_BOX,
|
||||
Material.MAGENTA_SHULKER_BOX,
|
||||
Material.LIGHT_BLUE_SHULKER_BOX,
|
||||
Material.YELLOW_SHULKER_BOX,
|
||||
Material.LIME_SHULKER_BOX,
|
||||
Material.PINK_SHULKER_BOX,
|
||||
Material.GRAY_SHULKER_BOX,
|
||||
Material.LIGHT_GRAY_SHULKER_BOX,
|
||||
Material.CYAN_SHULKER_BOX,
|
||||
Material.PURPLE_SHULKER_BOX,
|
||||
Material.BLUE_SHULKER_BOX,
|
||||
Material.BROWN_SHULKER_BOX,
|
||||
Material.GREEN_SHULKER_BOX,
|
||||
Material.RED_SHULKER_BOX,
|
||||
Material.BLACK_SHULKER_BOX,
|
||||
Material.SMOKER,
|
||||
Material.TRAPPED_CHEST);
|
||||
|
||||
private static final Set<Material> FLOWERS = EnumSet.of(
|
||||
Material.CORNFLOWER,
|
||||
Material.POPPY,
|
||||
Material.FERN,
|
||||
Material.DANDELION,
|
||||
Material.BLUE_ORCHID,
|
||||
Material.ALLIUM,
|
||||
Material.AZURE_BLUET,
|
||||
Material.RED_TULIP,
|
||||
Material.ORANGE_TULIP,
|
||||
Material.WHITE_TULIP,
|
||||
Material.PINK_TULIP,
|
||||
Material.OXEYE_DAISY,
|
||||
Material.LILY_OF_THE_VALLEY,
|
||||
Material.WITHER_ROSE,
|
||||
Material.SUNFLOWER,
|
||||
Material.DIAMOND_HORSE_ARMOR,
|
||||
Material.IRON_HORSE_ARMOR,
|
||||
Material.GOLDEN_HORSE_ARMOR,
|
||||
Material.HONEY_BOTTLE);
|
||||
|
||||
public AutoChecker.BlockScanResult scan(Clipboard clipboard) {
|
||||
AutoChecker.BlockScanResult result = new AutoChecker.BlockScanResult();
|
||||
@@ -47,7 +98,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker {
|
||||
|
||||
result.getBlockCounts().merge(material, 1, Integer::sum);
|
||||
|
||||
if(AutoCheckerItems.impl.getInventoryMaterials().contains(material)) {
|
||||
if(INVENTORY.contains(material)) {
|
||||
checkInventory(result, block, material, new BlockPos(x, y, z));
|
||||
}
|
||||
|
||||
@@ -74,7 +125,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker {
|
||||
));
|
||||
itemsInInv.put(Material.FIRE_CHARGE, EnumSet.of(Material.DISPENSER));
|
||||
itemsInInv.put(Material.ARROW, EnumSet.of(Material.DISPENSER));
|
||||
AutoCheckerItems.impl.getAllowedMaterialsInInventory().forEach(material -> itemsInInv.put(material, AutoCheckerItems.impl.getInventoryMaterials()));
|
||||
FLOWERS.forEach(material -> itemsInInv.put(material, INVENTORY));
|
||||
}
|
||||
|
||||
private void checkInventory(AutoChecker.BlockScanResult result, BaseBlock block, Material material, BlockPos pos) {
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.schematicsystem.autocheck;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class AutoCheckerItems15 implements AutoCheckerItems {
|
||||
|
||||
private static final Set<Material> INVENTORY = EnumSet.of(
|
||||
Material.BARREL,
|
||||
Material.BLAST_FURNACE,
|
||||
Material.BREWING_STAND,
|
||||
Material.CAMPFIRE,
|
||||
Material.CHEST,
|
||||
Material.DISPENSER,
|
||||
Material.DROPPER,
|
||||
Material.FURNACE,
|
||||
Material.HOPPER,
|
||||
Material.JUKEBOX,
|
||||
Material.SHULKER_BOX,
|
||||
Material.WHITE_SHULKER_BOX,
|
||||
Material.ORANGE_SHULKER_BOX,
|
||||
Material.MAGENTA_SHULKER_BOX,
|
||||
Material.LIGHT_BLUE_SHULKER_BOX,
|
||||
Material.YELLOW_SHULKER_BOX,
|
||||
Material.LIME_SHULKER_BOX,
|
||||
Material.PINK_SHULKER_BOX,
|
||||
Material.GRAY_SHULKER_BOX,
|
||||
Material.LIGHT_GRAY_SHULKER_BOX,
|
||||
Material.CYAN_SHULKER_BOX,
|
||||
Material.PURPLE_SHULKER_BOX,
|
||||
Material.BLUE_SHULKER_BOX,
|
||||
Material.BROWN_SHULKER_BOX,
|
||||
Material.GREEN_SHULKER_BOX,
|
||||
Material.RED_SHULKER_BOX,
|
||||
Material.BLACK_SHULKER_BOX,
|
||||
Material.SMOKER,
|
||||
Material.TRAPPED_CHEST);
|
||||
|
||||
private static final Set<Material> FLOWERS = EnumSet.of(
|
||||
Material.CORNFLOWER,
|
||||
Material.POPPY,
|
||||
Material.FERN,
|
||||
Material.DANDELION,
|
||||
Material.BLUE_ORCHID,
|
||||
Material.ALLIUM,
|
||||
Material.AZURE_BLUET,
|
||||
Material.RED_TULIP,
|
||||
Material.ORANGE_TULIP,
|
||||
Material.WHITE_TULIP,
|
||||
Material.PINK_TULIP,
|
||||
Material.OXEYE_DAISY,
|
||||
Material.LILY_OF_THE_VALLEY,
|
||||
Material.WITHER_ROSE,
|
||||
Material.SUNFLOWER,
|
||||
Material.DIAMOND_HORSE_ARMOR,
|
||||
Material.IRON_HORSE_ARMOR,
|
||||
Material.GOLDEN_HORSE_ARMOR,
|
||||
Material.HONEY_BOTTLE);
|
||||
|
||||
@Override
|
||||
public Set<Material> getInventoryMaterials() {
|
||||
return INVENTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Material> getAllowedMaterialsInInventory() {
|
||||
return FLOWERS;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +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/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
steamwar.java
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":SpigotCore", "default"))
|
||||
compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default"))
|
||||
compileOnly(project(":SchematicSystem:SchematicSystem_15", "default"))
|
||||
|
||||
compileOnly(libs.spigotapi)
|
||||
|
||||
compileOnly(libs.nms19)
|
||||
compileOnly(libs.fawe18)
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.schematicsystem.autocheck;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class AutoCheckerItems19 extends AutoCheckerItems15 {
|
||||
|
||||
private static final Set<Material> ALLOWED_ITEMS_IN_INVENTORY = EnumSet.of(
|
||||
// 64-stackable Items
|
||||
Material.CORNFLOWER,
|
||||
Material.POPPY,
|
||||
Material.FERN,
|
||||
Material.DANDELION,
|
||||
Material.BLUE_ORCHID,
|
||||
Material.ALLIUM,
|
||||
Material.AZURE_BLUET,
|
||||
Material.RED_TULIP,
|
||||
Material.ORANGE_TULIP,
|
||||
Material.WHITE_TULIP,
|
||||
Material.PINK_TULIP,
|
||||
Material.OXEYE_DAISY,
|
||||
Material.LILY_OF_THE_VALLEY,
|
||||
Material.WITHER_ROSE,
|
||||
Material.SUNFLOWER,
|
||||
// 16-stackable Items
|
||||
Material.HONEY_BOTTLE,
|
||||
// Non-stackable items
|
||||
Material.DIAMOND_HORSE_ARMOR,
|
||||
Material.IRON_HORSE_ARMOR,
|
||||
Material.GOLDEN_HORSE_ARMOR,
|
||||
// Disks
|
||||
Material.MUSIC_DISC_11,
|
||||
Material.MUSIC_DISC_13,
|
||||
Material.MUSIC_DISC_CAT,
|
||||
Material.MUSIC_DISC_BLOCKS,
|
||||
Material.MUSIC_DISC_CHIRP,
|
||||
Material.MUSIC_DISC_FAR,
|
||||
Material.MUSIC_DISC_MALL,
|
||||
Material.MUSIC_DISC_MELLOHI,
|
||||
Material.MUSIC_DISC_STAL,
|
||||
Material.MUSIC_DISC_STRAD,
|
||||
Material.MUSIC_DISC_WAIT,
|
||||
Material.MUSIC_DISC_WARD,
|
||||
Material.MUSIC_DISC_OTHERSIDE,
|
||||
Material.MUSIC_DISC_PIGSTEP,
|
||||
Material.MUSIC_DISC_RELIC,
|
||||
Material.MUSIC_DISC_5
|
||||
);
|
||||
|
||||
@Override
|
||||
public Set<Material> getAllowedMaterialsInInventory() {
|
||||
return ALLOWED_ITEMS_IN_INVENTORY;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.schematicsystem.autocheck;
|
||||
|
||||
import de.steamwar.core.VersionDependent;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface AutoCheckerItems {
|
||||
|
||||
AutoCheckerItems impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance());
|
||||
|
||||
Set<Material> getInventoryMaterials();
|
||||
Set<Material> getAllowedMaterialsInInventory();
|
||||
}
|
||||
@@ -21,12 +21,12 @@ package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.*;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.schematicsystem.SafeSchematicNode;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.schematicsystem.autocheck.AutoChecker;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils;
|
||||
import de.steamwar.sql.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -38,7 +38,7 @@ import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.getUser;
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*;
|
||||
|
||||
public class GUI {
|
||||
private GUI() {}
|
||||
@@ -101,9 +101,9 @@ public class GUI {
|
||||
});
|
||||
}
|
||||
|
||||
inv.setItem(9, new SWItem(SWItem.getMaterial("LEASH"), SchematicSystem.MESSAGE.parse("GUI_INFO_BACK", player), clickType -> {
|
||||
inv.setItem(9, SWItem.getMaterial("LEASH"), SchematicSystem.MESSAGE.parse("GUI_INFO_BACK", player), clickType -> {
|
||||
back.reOpen();
|
||||
}).setCustomModelData(CMDs.Schematic.BACK));
|
||||
});
|
||||
|
||||
if(node.getOwner() == user.getId()){
|
||||
if(!node.isDir() && node.getSchemtype().writeable()){
|
||||
|
||||
@@ -46,7 +46,6 @@ public class ModifyPart extends SWCommand {
|
||||
}
|
||||
|
||||
@Register("changetype")
|
||||
@Register("submit")
|
||||
public void changeType(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node) {
|
||||
TextComponent base = new TextComponent();
|
||||
|
||||
@@ -75,13 +74,11 @@ public class ModifyPart extends SWCommand {
|
||||
}
|
||||
|
||||
@Register("changetype")
|
||||
@Register("submit")
|
||||
public void changeType(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node, SchematicType type) {
|
||||
changeType(player, node, type, null);
|
||||
}
|
||||
|
||||
@Register("changetype")
|
||||
@Register("submit")
|
||||
public void changeType(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node, SchematicType type, SchematicCommand.Extend extend) {
|
||||
SchematicCommandUtils.changeType(player, node, type, extend);
|
||||
}
|
||||
|
||||
@@ -30,5 +30,4 @@ dependencies {
|
||||
implementation(project(":SchematicSystem:SchematicSystem_Core"))
|
||||
implementation(project(":SchematicSystem:SchematicSystem_8"))
|
||||
implementation(project(":SchematicSystem:SchematicSystem_15"))
|
||||
implementation(project(":SchematicSystem:SchematicSystem_19"))
|
||||
}
|
||||
|
||||
@@ -26,6 +26,5 @@ dependencies {
|
||||
|
||||
compileOnly(libs.spigotapi)
|
||||
|
||||
compileOnly(libs.fawe18)
|
||||
compileOnly(libs.nms20)
|
||||
}
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.core;
|
||||
|
||||
import de.steamwar.entity.CWireframe;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class WorldEditRendererWrapper20 implements WorldEditRendererWrapper {
|
||||
|
||||
private static final class BoxPair {
|
||||
private CWireframe regionBox;
|
||||
private CWireframe clipboardBox;
|
||||
|
||||
public CWireframe get(boolean clipboard) {
|
||||
if (clipboard) {
|
||||
return clipboardBox;
|
||||
} else {
|
||||
return regionBox;
|
||||
}
|
||||
}
|
||||
|
||||
public void set(boolean clipboard, CWireframe box) {
|
||||
if (clipboard) {
|
||||
this.clipboardBox = box;
|
||||
} else {
|
||||
this.regionBox = box;
|
||||
}
|
||||
}
|
||||
|
||||
public void die() {
|
||||
if (clipboardBox != null) {
|
||||
clipboardBox.die();
|
||||
}
|
||||
if (regionBox != null) {
|
||||
regionBox.die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<Player, REntityServer> servers = new HashMap<>();
|
||||
private static final Map<Player, BoxPair> boxes = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void draw(Player player, boolean scheduled, boolean clipboard, Vector pos1, Vector pos2) {
|
||||
REntityServer server = servers.computeIfAbsent(player, __ -> {
|
||||
REntityServer entityServer = new REntityServer();
|
||||
entityServer.addPlayer(player);
|
||||
return entityServer;
|
||||
});
|
||||
|
||||
WorldEditRendererCUIEditor.Type type = clipboard ? WorldEditRendererCUIEditor.Type.CLIPBOARD : WorldEditRendererCUIEditor.Type.SELECTION;
|
||||
float width = type.getWidth(player).value;
|
||||
Material material = type.getMaterial(player);
|
||||
if (material == Material.BARRIER) {
|
||||
hide(player, clipboard, true);
|
||||
return;
|
||||
}
|
||||
BlockData block = material.createBlockData();
|
||||
|
||||
BoxPair boxPair = boxes.computeIfAbsent(player, __ -> new BoxPair());
|
||||
CWireframe box = boxPair.get(clipboard);
|
||||
if (box == null) {
|
||||
box = new CWireframe(server);
|
||||
boxPair.set(clipboard, box);
|
||||
}
|
||||
box.setPos1(null).setPos2(null);
|
||||
box.setPos1(pos1.toLocation(player.getWorld()));
|
||||
box.setPos2(pos2.toLocation(player.getWorld()));
|
||||
box.setWidth(width);
|
||||
box.setBlock(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Player player) {
|
||||
REntityServer server = servers.get(player);
|
||||
if (server != null) server.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide(Player player, boolean clipboard, boolean hide) {
|
||||
BoxPair boxPair = boxes.get(player);
|
||||
if (boxPair == null) return;
|
||||
CWireframe box = boxPair.get(clipboard);
|
||||
if (box == null) return;
|
||||
box.hide(hide);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Player player) {
|
||||
BoxPair boxPair = boxes.remove(player);
|
||||
if (boxPair != null) boxPair.die();
|
||||
REntityServer server = servers.remove(player);
|
||||
if (server != null) server.close();
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ package de.steamwar.core;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import net.minecraft.world.entity.PositionMoveRotation;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
public class BountifulWrapper21 extends BountifulWrapper9 {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class BountifulWrapper21 extends BountifulWrapper9 {
|
||||
return (packet, x, y, z, pitch, yaw) -> {
|
||||
PositionMoveRotation pos = field.get(packet);
|
||||
|
||||
field.set(packet, new PositionMoveRotation(new Vec3(x, y, z), pos.deltaMovement(), yaw, pitch));
|
||||
field.set(packet, new PositionMoveRotation(new Vec3D(x, y, z), pos.b(), yaw, pitch));
|
||||
};
|
||||
} catch (IllegalArgumentException e) {
|
||||
return super.getPositionSetter(packetClass, fieldOffset);
|
||||
|
||||
@@ -19,26 +19,26 @@
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.contents.PlainTextContents;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.network.chat.IChatMutableComponent;
|
||||
import net.minecraft.network.chat.contents.LiteralContents;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.network.syncher.DataWatcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ChatWrapper21 implements ChatWrapper {
|
||||
@Override
|
||||
public Object stringToChatComponent(String text) {
|
||||
return MutableComponent.create(PlainTextContents.create(text));
|
||||
return IChatMutableComponent.a(LiteralContents.a(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDataWatcherPacket(int entityId, Object... dataWatcherKeyValues) {
|
||||
ArrayList<SynchedEntityData.DataValue<?>> nativeWatchers = new ArrayList<>(1);
|
||||
ArrayList<DataWatcher.c<?>> nativeWatchers = new ArrayList<>(1);
|
||||
for(int i = 0; i < dataWatcherKeyValues.length; i+=2) {
|
||||
nativeWatchers.add(((SynchedEntityData.DataItem<?>) BountifulWrapper.impl.getDataWatcherItem(dataWatcherKeyValues[i], dataWatcherKeyValues[i+1])).value());
|
||||
nativeWatchers.add(((DataWatcher.Item<?>) BountifulWrapper.impl.getDataWatcherItem(dataWatcherKeyValues[i], dataWatcherKeyValues[i+1])).e());
|
||||
}
|
||||
|
||||
return new ClientboundSetEntityDataPacket(entityId, nativeWatchers);
|
||||
return new PacketPlayOutEntityMetadata(entityId, nativeWatchers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,18 +22,20 @@ package de.steamwar.core;
|
||||
import de.steamwar.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import org.bukkit.craftbukkit.CraftChunk;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CraftbukkitWrapper21 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||
|
||||
private static final Reflection.Method getHandle = Reflection.getMethod("org.bukkit.craftbukkit.CraftChunk", "getHandle", ChunkStatus.class);
|
||||
private static final Reflection.Method getLightEngine = Reflection.getTypedMethod(World.class, null, LevelLightEngine.class);
|
||||
|
||||
@Override
|
||||
public void sendChunk(Player p, int chunkX, int chunkZ) {
|
||||
LevelChunk chunk = (LevelChunk) ((CraftChunk) p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(ChunkStatus.FULL);
|
||||
TinyProtocol.instance.sendPacket(p, new ClientboundLevelChunkWithLightPacket(chunk, chunk.level.getLightEngine(), null, null, true));
|
||||
Chunk chunk = (Chunk) getHandle.invoke(p.getWorld().getChunkAt(chunkX, chunkZ), ChunkStatus.n);
|
||||
TinyProtocol.instance.sendPacket(p, new ClientboundLevelChunkWithLightPacket(chunk, (LevelLightEngine) getLightEngine.invoke(chunk.r), null, null, true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,5 +26,4 @@ dependencies {
|
||||
compileOnly(project(":SpigotCore:SpigotCore_8", "default"))
|
||||
|
||||
compileOnly(libs.nms9)
|
||||
compileOnly(libs.worldedit12)
|
||||
}
|
||||
|
||||
@@ -85,12 +85,11 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
||||
@Override
|
||||
public BountifulWrapper.PositionSetter getRelMoveSetter(Class<?> packetClass) {
|
||||
Class<?> type = Core.getVersion() > 12 ? short.class : int.class;
|
||||
int fieldOffset = Core.getVersion() > 12 ? 0 : 1;
|
||||
Reflection.Field<?> moveX = Reflection.getField(packetClass, type, 0 + fieldOffset);
|
||||
Reflection.Field<?> moveY = Reflection.getField(packetClass, type, 1 + fieldOffset);
|
||||
Reflection.Field<?> moveZ = Reflection.getField(packetClass, type, 2 + fieldOffset);
|
||||
Reflection.Field<Byte> moveYaw = Reflection.getField(packetClass, byte.class, 0);
|
||||
Reflection.Field<Byte> movePitch = Reflection.getField(packetClass, byte.class, 1);
|
||||
Reflection.Field<?> moveX = Reflection.getField(packetClass, "b", type);
|
||||
Reflection.Field<?> moveY = Reflection.getField(packetClass, "c", type);
|
||||
Reflection.Field<?> moveZ = Reflection.getField(packetClass, "d", type);
|
||||
Reflection.Field<Byte> moveYaw = Reflection.getField(packetClass, "e", byte.class);
|
||||
Reflection.Field<Byte> movePitch = Reflection.getField(packetClass, "f", byte.class);
|
||||
|
||||
return (packet, x, y, z, pitch, yaw) -> {
|
||||
moveX.set(packet, (short)(x*4096));
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.core;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class WorldEditRendererWrapper9 implements WorldEditRendererWrapper {
|
||||
|
||||
private static final int VIEW_DISTANCE = 64;
|
||||
private static final int SQ_VIEW_DISTANCE = VIEW_DISTANCE * VIEW_DISTANCE;
|
||||
|
||||
private static final double STEP_SIZE = 0.5;
|
||||
private static final Vector ONES = new Vector(1, 1, 1);
|
||||
private static final Vector STEPS = new Vector(STEP_SIZE, STEP_SIZE, STEP_SIZE);
|
||||
|
||||
@Override
|
||||
public void draw(Player player, boolean scheduled, boolean clipboard, Vector min, Vector max) {
|
||||
if (!scheduled) return;
|
||||
|
||||
max = max.clone().add(ONES);
|
||||
drawLine(player, clipboard, new Vector(min.getX(), min.getY(), min.getZ()), new Vector(max.getX(), min.getY(), min.getZ()));
|
||||
drawLine(player, clipboard, new Vector(min.getX(), max.getY(), min.getZ()), new Vector(max.getX(), max.getY(), min.getZ()));
|
||||
drawLine(player, clipboard, new Vector(min.getX(), min.getY(), max.getZ()), new Vector(max.getX(), min.getY(), max.getZ()));
|
||||
drawLine(player, clipboard, new Vector(min.getX(), max.getY(), max.getZ()), new Vector(max.getX(), max.getY(), max.getZ()));
|
||||
|
||||
drawLine(player, clipboard, new Vector(min.getX(), min.getY(), min.getZ()), new Vector(min.getX(), max.getY(), min.getZ()));
|
||||
drawLine(player, clipboard, new Vector(max.getX(), min.getY(), min.getZ()), new Vector(max.getX(), max.getY(), min.getZ()));
|
||||
drawLine(player, clipboard, new Vector(min.getX(), min.getY(), max.getZ()), new Vector(min.getX(), max.getY(), max.getZ()));
|
||||
drawLine(player, clipboard, new Vector(max.getX(), min.getY(), max.getZ()), new Vector(max.getX(), max.getY(), max.getZ()));
|
||||
|
||||
drawLine(player, clipboard, new Vector(min.getX(), min.getY(), min.getZ()), new Vector(min.getX(), min.getY(), max.getZ()));
|
||||
drawLine(player, clipboard, new Vector(max.getX(), min.getY(), min.getZ()), new Vector(max.getX(), min.getY(), max.getZ()));
|
||||
drawLine(player, clipboard, new Vector(min.getX(), max.getY(), min.getZ()), new Vector(min.getX(), max.getY(), max.getZ()));
|
||||
drawLine(player, clipboard, new Vector(max.getX(), max.getY(), min.getZ()), new Vector(max.getX(), max.getY(), max.getZ()));
|
||||
}
|
||||
|
||||
private void drawLine(Player player, boolean clipboard, Vector min, Vector max) {
|
||||
Particle particle;
|
||||
if (clipboard) {
|
||||
particle = TrickyParticleWrapper.impl.getVillagerHappy();
|
||||
} else {
|
||||
particle = Particle.DRAGON_BREATH;
|
||||
}
|
||||
|
||||
Vector stepSize = max.clone().subtract(min).normalize().multiply(STEPS);
|
||||
while (min.getX() <= max.getX() && min.getY() <= max.getY() && min.getZ() <= max.getZ()) {
|
||||
Location location = player.getLocation();
|
||||
double dx = min.getX() - location.getX();
|
||||
double dy = min.getY() - location.getY();
|
||||
double dz = min.getZ() - location.getZ();
|
||||
if (dx * dx + dy * dy + dz * dz > SQ_VIEW_DISTANCE) {
|
||||
min.add(stepSize);
|
||||
continue;
|
||||
}
|
||||
|
||||
player.spawnParticle(particle, min.getX(), min.getY(), min.getZ(), 1, 0.0, 0.0, 0.0, 0.0);
|
||||
min.add(stepSize);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide(Player player, boolean clipboard, boolean hide) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Player player) {
|
||||
}
|
||||
}
|
||||
@@ -105,22 +105,3 @@ NOSCHEMSUBMITTING_PERMA=§7You are §epermanently§7 excluded from submitting §
|
||||
NOSCHEMSUBMITTING_UNTIL=§7You are excluded from submitting §e§lschematics §euntil {0}§8: §e{1}
|
||||
UNNOSCHEMSUBMITTING_ERROR=§cThe player is not excluded from submitting schematics.
|
||||
UNNOSCHEMSUBMITTING=§e{0} §7may now submit §e§lschematics§7 again§8.
|
||||
|
||||
WORLDEDIT_CUI_TITLE = WorldEdit CUI
|
||||
WORLDEDIT_CUI_TITLE_SUBMENU = WorldEdit CUI - {0}
|
||||
WORLDEDIT_CUI_SELECTION = Own Selection
|
||||
WORLDEDIT_CUI_CLIPBOARD = Own Clipboard
|
||||
WORLDEDIT_CUI_SELECTION_OTHER = Other Selection
|
||||
WORLDEDIT_CUI_CLIPBOARD_OTHER = Other Clipboard
|
||||
|
||||
WORLDEDIT_CUI_MATERIAL_NAME = §eWorldEdit {0}
|
||||
WORLDEDIT_CUI_MATERIAL_CLICK = §7Click to edit
|
||||
|
||||
WORLDEDIT_CUI_WIDTH_NAME = §eWidth {0}
|
||||
WORLDEDIT_CUI_WIDTH_LORE = §8> §7{0}
|
||||
WORLDEDIT_CUI_WIDTH_LORE_SELECTED = §8> §e{0}
|
||||
WORLDEDIT_CUI_WIDTH_CLICK = §7Click to change
|
||||
WORLDEDIT_CUI_WIDTH_HUGE = 1/ 8 Block
|
||||
WORLDEDIT_CUI_WIDTH_LARGE = 1/16 Block
|
||||
WORLDEDIT_CUI_WIDTH_MEDIUM = 1/32 Block
|
||||
WORLDEDIT_CUI_WIDTH_SLIM = 1/64 Block
|
||||
@@ -99,15 +99,4 @@ NOSCHEMSUBMITTING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematic
|
||||
NOSCHEMSUBMITTING_PERMA=§7Du bist §epermanent §7vom §e§lEinsenden von Schematics§7 ausgeschlossen§8: §e{0}
|
||||
NOSCHEMSUBMITTING_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lEinsenden von Schematics§7 ausgeschlossen§8: §e{1}
|
||||
UNNOSCHEMSUBMITTING_ERROR=§cDer Spieler ist nicht vom Einsenden von Schematics ausgeschlossen.
|
||||
UNNOSCHEMSUBMITTING=§e{0} §7darf nun wieder §e§lSchematis§7 einsenden§8.
|
||||
|
||||
WORLDEDIT_CUI_SELECTION = Eigene Auswahl
|
||||
WORLDEDIT_CUI_CLIPBOARD = Eigene Kopie
|
||||
WORLDEDIT_CUI_SELECTION_OTHER = Auswahl Anderer
|
||||
WORLDEDIT_CUI_CLIPBOARD_OTHER = Kopie Anderer
|
||||
|
||||
WORLDEDIT_CUI_MATERIAL_NAME = §eWorldEdit {0}
|
||||
WORLDEDIT_CUI_MATERIAL_CLICK = §7Klicke zum Editieren
|
||||
|
||||
WORLDEDIT_CUI_WIDTH_NAME = §eDicke - {0}
|
||||
WORLDEDIT_CUI_WIDTH_CLICK = §7Klicke zum ändern
|
||||
UNNOSCHEMSUBMITTING=§e{0} §7darf nun wieder §e§lSchematis§7 einsenden§8.
|
||||
@@ -160,10 +160,10 @@ public class TinyProtocol implements Listener {
|
||||
private PacketInterceptor(Player player) {
|
||||
this.player = player;
|
||||
|
||||
channel = connections.stream().filter(connection -> player.getUniqueId().equals(getUUID.get(connection))).map(getChannel::get).filter(Channel::isActive).findAny().orElseThrow(() -> {
|
||||
channel = getChannel.get(connections.stream().filter(connection -> player.getUniqueId().equals(getUUID.get(connection))).findAny().orElseThrow(() -> {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> player.kickPlayer("Connection failure."));
|
||||
return new SecurityException("Could not find channel for player " + player.getName());
|
||||
});
|
||||
}));
|
||||
|
||||
if(!channel.isActive())
|
||||
return;
|
||||
@@ -175,11 +175,11 @@ public class TinyProtocol implements Listener {
|
||||
|
||||
try {
|
||||
channel.pipeline().addBefore("packet_handler", HANDLER_NAME, this);
|
||||
} catch (IllegalArgumentException | NoSuchElementException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> player.kickPlayer("Connection failure."));
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendPacket(Object packet) {
|
||||
channel.pipeline().writeAndFlush(packet);
|
||||
|
||||
@@ -94,7 +94,6 @@ public final class Reflection {
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundContainerClickPacket", "net.minecraft.network.protocol.game.PacketPlayInWindowClick");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundInteractPacket", "net.minecraft.network.protocol.game.PacketPlayInUseEntity");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundInteractPacket$Action", "net.minecraft.network.protocol.game.PacketPlayInUseEntity$EnumEntityUseAction");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundInteractPacket$ActionType", "net.minecraft.network.protocol.game.PacketPlayInUseEntity$b");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos", "net.minecraft.network.protocol.game.PacketPlayInFlying$PacketPlayInPosition");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot", "net.minecraft.network.protocol.game.PacketPlayInFlying$PacketPlayInPositionLook");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Rot", "net.minecraft.network.protocol.game.PacketPlayInFlying$PacketPlayInLook");
|
||||
|
||||
@@ -23,10 +23,7 @@ import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.command.*;
|
||||
import de.steamwar.core.authlib.AuthlibInjector;
|
||||
import de.steamwar.core.events.AntiNocom;
|
||||
import de.steamwar.core.events.ChattingEvent;
|
||||
import de.steamwar.core.events.PlayerJoinedEvent;
|
||||
import de.steamwar.core.events.WorldLoadEvent;
|
||||
import de.steamwar.core.events.*;
|
||||
import de.steamwar.message.Message;
|
||||
import de.steamwar.network.NetworkReceiver;
|
||||
import de.steamwar.network.handlers.ServerDataHandler;
|
||||
@@ -44,7 +41,7 @@ import java.io.InputStreamReader;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Core extends JavaPlugin {
|
||||
public class Core extends JavaPlugin{
|
||||
|
||||
public static final Message MESSAGE = new Message("SpigotCore", Core.class.getClassLoader());
|
||||
|
||||
@@ -70,8 +67,6 @@ public class Core extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
new PlayerVersion();
|
||||
|
||||
errorHandler = new ErrorHandler();
|
||||
crashDetector = new CrashDetector();
|
||||
|
||||
@@ -107,7 +102,7 @@ public class Core extends JavaPlugin {
|
||||
if(Core.getVersion() >= 19)
|
||||
new ServerDataHandler();
|
||||
|
||||
if(Bukkit.getPluginManager().getPlugin("WorldEdit") != null)
|
||||
if(Core.getVersion() > 8 && Bukkit.getPluginManager().getPlugin("WorldEdit") != null)
|
||||
new WorldEditRenderer();
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(this, TabCompletionCache::invalidateOldEntries, 20, 20);
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.core;
|
||||
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.server.ClientVersionPacket;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerVersion extends PacketHandler implements Listener {
|
||||
|
||||
private static final Map<UUID, Integer> playerVersions = new HashMap<>();
|
||||
|
||||
public static int getVersion(Player player) {
|
||||
return playerVersions.getOrDefault(player.getUniqueId(), -1);
|
||||
}
|
||||
|
||||
public static boolean isBedrock(Player player) {
|
||||
return player.getName().startsWith(".");
|
||||
}
|
||||
|
||||
public PlayerVersion() {
|
||||
Bukkit.getPluginManager().registerEvents(this, Core.getInstance());
|
||||
register();
|
||||
}
|
||||
|
||||
@Handler
|
||||
public void handlePacket(ClientVersionPacket clientVersionPacket) {
|
||||
playerVersions.put(clientVersionPacket.getPlayer(), clientVersionPacket.getVersion());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
playerVersions.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user