From d62f4d39ea340f65fc36f56e21f994d8b614e167 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Fri, 29 Mar 2024 18:26:22 +1300 Subject: [PATCH 01/96] Start modelled consoles --- .../dev/TARDISDisplayItemCommand.java | 35 +----------- .../commands/dev/TARDISFrameCommand.java | 2 +- .../eccentric_nz/TARDIS/console/Console.java | 5 ++ .../TARDIS/console/ConsoleBuilder.java | 56 +++++++++++++++++++ .../TARDIS/console/ConsoleChanger.java | 38 +++++++++++++ .../TARDIS/console/ControlMonitor.java | 34 +++++++++++ todo.md | 2 +- 7 files changed, 137 insertions(+), 35 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/Console.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/ConsoleChanger.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java index 84daa2a8d..a8752e33b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java @@ -20,6 +20,7 @@ import me.eccentric_nz.TARDIS.ARS.TARDISARSSlot; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISConstants; +import me.eccentric_nz.TARDIS.console.ConsoleBuilder; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayBlockConverter; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayBlockRoomConverter; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItem; @@ -30,7 +31,6 @@ import me.eccentric_nz.TARDIS.utility.TARDISNumberParsers; import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; import org.bukkit.Chunk; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -233,38 +233,7 @@ public boolean display(Player player, String[] args) { return true; } case "console" -> { - Block up = block.getRelative(BlockFace.UP); - for (int i = 0; i < 6; i++) { - ItemStack shard = new ItemStack(Material.AMETHYST_SHARD); - ItemMeta im = shard.getItemMeta(); - im.setCustomModelData(1001 + i); - im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, i); - shard.setItemMeta(im); - ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(up.getLocation().add(0.5d, 0.5d, 0.5d), EntityType.ITEM_DISPLAY); - display.setItemStack(shard); - display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); - display.setPersistent(true); - display.setInvulnerable(true); - float yaw = i * 60.0f; - yaw = Location.normalizeYaw(yaw); - // set display rotation - display.setRotation(yaw, 0); - } - for (int i = 30; i < 360; i += 60) { - ItemStack shard = new ItemStack(Material.AMETHYST_SHARD); - ItemMeta im = shard.getItemMeta(); - im.setCustomModelData(1007); - im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, i); - shard.setItemMeta(im); - ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(up.getLocation().add(0.5d, 0.5d, 0.5d), EntityType.ITEM_DISPLAY); - display.setItemStack(shard); - display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); - display.setPersistent(true); - display.setInvulnerable(true); - float yaw = Location.normalizeYaw(i); - // set display rotation - display.setRotation(yaw, 0); - } + new ConsoleBuilder(plugin).create(block, 1); return true; } default -> { diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISFrameCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISFrameCommand.java index 73417a77c..4db6c818a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISFrameCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISFrameCommand.java @@ -40,7 +40,7 @@ public TARDISFrameCommand(TARDIS plugin) { public static ItemFrame getItemFrame(Player player) { ItemFrame frame = null; - // get the armour stand player is looking at + // get the item frame player is looking at Location observerPos = player.getEyeLocation(); Vector3D observerDir = new Vector3D(observerPos.getDirection()); Vector3D observerStart = new Vector3D(observerPos); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/Console.java b/src/main/java/me/eccentric_nz/TARDIS/console/Console.java new file mode 100644 index 000000000..c3dd7b0ea --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/Console.java @@ -0,0 +1,5 @@ +package me.eccentric_nz.TARDIS.console; + +public class Console { + +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java new file mode 100644 index 000000000..9a6b607a1 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -0,0 +1,56 @@ +package me.eccentric_nz.TARDIS.console; + +import me.eccentric_nz.TARDIS.TARDIS; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataType; + +public class ConsoleBuilder { + + private final TARDIS plugin; + + public ConsoleBuilder(TARDIS plugin) { + this.plugin = plugin; + } + + public void create(Block block, int type) { + Block up = block.getRelative(BlockFace.UP); + for (int i = 0; i < 6; i++) { + ItemStack shard = new ItemStack(Material.AMETHYST_SHARD); + ItemMeta im = shard.getItemMeta(); + im.setCustomModelData((1000 * type) + (i + 1)); + im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, i); + shard.setItemMeta(im); + ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(up.getLocation().add(0.5d, 0.5d, 0.5d), EntityType.ITEM_DISPLAY); + display.setItemStack(shard); + display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); + display.setPersistent(true); + display.setInvulnerable(true); + float yaw = i * 60.0f; + yaw = Location.normalizeYaw(yaw); + // set display rotation + display.setRotation(yaw, 0); + } + for (int i = 30; i < 360; i += 60) { + ItemStack shard = new ItemStack(Material.AMETHYST_SHARD); + ItemMeta im = shard.getItemMeta(); + im.setCustomModelData((1000 * type) + 7); + im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, i); + shard.setItemMeta(im); + ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(up.getLocation().add(0.5d, 0.5d, 0.5d), EntityType.ITEM_DISPLAY); + display.setItemStack(shard); + display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); + display.setPersistent(true); + display.setInvulnerable(true); + float yaw = Location.normalizeYaw(i); + // set display rotation + display.setRotation(yaw, 0); + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleChanger.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleChanger.java new file mode 100644 index 000000000..08ebf218c --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleChanger.java @@ -0,0 +1,38 @@ +package me.eccentric_nz.TARDIS.console; + +import me.eccentric_nz.TARDIS.TARDIS; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class ConsoleChanger { + + private final TARDIS plugin; + + public ConsoleChanger(TARDIS plugin) { + this.plugin = plugin; + } + + public void setType(Block block, int type) { + // get item displays around the block + for (Entity entity : block.getWorld().getNearbyEntities(block.getLocation(), 2,2,2)) { + if (entity instanceof ItemDisplay display) { + // get the item stack + ItemStack is = display.getItemStack(); + if (is != null && is.getType() == Material.AMETHYST_SHARD) { + ItemMeta im = is.getItemMeta(); + if (im.hasCustomModelData()) { + // cmd % 10 + (1000 * type) + int cmd = (im.getCustomModelData() % 10) + (1000 * type); + im.setCustomModelData(cmd); + is.setItemMeta(im); + display.setItemStack(is); + } + } + } + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java b/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java new file mode 100644 index 000000000..74eb40a37 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java @@ -0,0 +1,34 @@ +package me.eccentric_nz.TARDIS.console; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.TARDISConstants; +import org.bukkit.entity.Entity; +import org.bukkit.entity.TextDisplay; +import org.bukkit.util.Transformation; +import org.joml.Vector3f; + +import java.util.UUID; + +public class ControlMonitor { + private final TARDIS plugin; + private final Transformation transformation = new Transformation(TARDISConstants.VECTOR_ZERO, TARDISConstants.AXIS_ANGLE_ZERO, new Vector3f(0.5f, 0.5f, 0.5f), TARDISConstants.AXIS_ANGLE_ZERO); + + public ControlMonitor(TARDIS plugin) { + this.plugin = plugin; + } + + public void update(int id, UUID uuid, boolean coords) { + Entity entity = plugin.getServer().getEntity(uuid); + if (!(entity instanceof TextDisplay textDisplay)) { + return; + } + // line_width or just \n? + // billboard - vertical + textDisplay.setText(makeText(id)); + } + + private String makeText(int id) { + + return ""; + } +} diff --git a/todo.md b/todo.md index 3d84d99bd..b4a433da9 100644 --- a/todo.md +++ b/todo.md @@ -2,7 +2,7 @@ ## Current version `5.6.0` -1. Custom display doors [#833](https://github.com/eccentricdevotion/TARDIS/issues/833) +1. Fix fifteenth console redstone piston door 2. ? ## Next version `5.7.0` From 3fa5fbae079aeb309a76b3b05fd7307a11b93151 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sat, 30 Mar 2024 19:08:47 +1300 Subject: [PATCH 02/96] #833 Fix crafted custom doors not placing --- .../TARDIS/listeners/TARDISCraftListener.java | 104 +++++++++--------- 1 file changed, 55 insertions(+), 49 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISCraftListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISCraftListener.java index 431024d0e..620898cfd 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISCraftListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISCraftListener.java @@ -37,6 +37,7 @@ import org.bukkit.inventory.Recipe; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.persistence.PersistentDataType; import java.util.*; @@ -120,59 +121,64 @@ public void onCraftTARDISItem(PrepareItemCraftEvent event) { if (recipe != null) { ItemStack is = recipe.getResult(); CraftingInventory ci = event.getInventory(); - if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) { - String dn = is.getItemMeta().getDisplayName(); - if (dn.equals(ChatColor.GOLD + "TARDIS Seed Block")) { - ItemMeta im = is.getItemMeta(); - List lore = im.getLore(); - lore.add("Walls: " + ci.getItem(6).getType()); - lore.add("Floors: " + ci.getItem(9).getType()); - lore.add("Chameleon: FACTORY"); - im.setLore(lore); - is.setItemMeta(im); - ci.setResult(is); - } else if (is.getType().equals(Material.GLOWSTONE_DUST)) { - if (DiskCircuit.getCircuitNames().contains(dn)) { - // which circuit is it? - String[] split = dn.split(" "); - String which = split[1].toLowerCase(Locale.ENGLISH); - // set the second line of lore - ItemMeta im = is.getItemMeta(); - List lore; - String uses = (plugin.getConfig().getString("circuits.uses." + which).equals("0") || !plugin.getConfig().getBoolean("circuits.damage")) ? ChatColor.YELLOW + "unlimited" : ChatColor.YELLOW + plugin.getConfig().getString("circuits.uses." + which); - if (im.hasLore()) { - lore = im.getLore(); - lore.set(1, uses); - } else { - lore = Arrays.asList("Uses left", uses); - } + if (is.hasItemMeta()) { + ItemMeta im = is.getItemMeta(); + if (im.hasDisplayName()) { + String dn = im.getDisplayName(); + if (dn.equals(ChatColor.GOLD + "TARDIS Seed Block")) { + List lore = im.getLore(); + lore.add("Walls: " + ci.getItem(6).getType()); + lore.add("Floors: " + ci.getItem(9).getType()); + lore.add("Chameleon: FACTORY"); im.setLore(lore); is.setItemMeta(im); ci.setResult(is); - } - } else if (is.getType().equals(Material.IRON_SWORD) && dn.equals("Rust Plague Sword")) { - // enchant the result - is.addEnchantment(Enchantment.DAMAGE_UNDEAD, 2); - ci.setResult(is); - } else if (is.getType().equals(Material.LEATHER_HELMET) && dn.equals("3-D Glasses") || dn.equals("TARDIS Communicator")) { - LeatherArmorMeta lam = (LeatherArmorMeta) is.getItemMeta(); - lam.setColor(Color.WHITE); - is.setItemMeta(lam); - ci.setResult(is); - } else if (dn.contains("Key") || dn.contains("Authorised Control")) { - HumanEntity human = event.getView().getPlayer(); - if (human instanceof Player) { - ItemMeta im = is.getItemMeta(); - im.getPersistentDataContainer().set(plugin.getTimeLordUuidKey(), plugin.getPersistentDataTypeUUID(), human.getUniqueId()); - List lore = im.getLore(); - if (lore == null) { - lore = new ArrayList<>(); + } else if (is.getType().equals(Material.GLOWSTONE_DUST)) { + if (DiskCircuit.getCircuitNames().contains(dn)) { + // which circuit is it? + String[] split = dn.split(" "); + String which = split[1].toLowerCase(Locale.ENGLISH); + // set the second line of lore + List lore; + String uses = (plugin.getConfig().getString("circuits.uses." + which).equals("0") || !plugin.getConfig().getBoolean("circuits.damage")) ? ChatColor.YELLOW + "unlimited" : ChatColor.YELLOW + plugin.getConfig().getString("circuits.uses." + which); + if (im.hasLore()) { + lore = im.getLore(); + lore.set(1, uses); + } else { + lore = Arrays.asList("Uses left", uses); + } + im.setLore(lore); + is.setItemMeta(im); + ci.setResult(is); } - String format = ChatColor.AQUA + "" + ChatColor.ITALIC; - String what = dn.contains("Key") ? "key" : "disk"; - lore.add(format + "This " + what + " belongs to"); - lore.add(format + human.getName()); - im.setLore(lore); + } else if (is.getType().equals(Material.IRON_SWORD) && dn.equals("Rust Plague Sword")) { + // enchant the result + is.addEnchantment(Enchantment.DAMAGE_UNDEAD, 2); + ci.setResult(is); + } else if (is.getType().equals(Material.LEATHER_HELMET) && dn.equals("3-D Glasses") || dn.equals("TARDIS Communicator")) { + LeatherArmorMeta lam = (LeatherArmorMeta) im; + lam.setColor(Color.WHITE); + is.setItemMeta(lam); + ci.setResult(is); + } else if (dn.contains("Key") || dn.contains("Authorised Control")) { + HumanEntity human = event.getView().getPlayer(); + if (human instanceof Player) { + im.getPersistentDataContainer().set(plugin.getTimeLordUuidKey(), plugin.getPersistentDataTypeUUID(), human.getUniqueId()); + List lore = im.getLore(); + if (lore == null) { + lore = new ArrayList<>(); + } + String format = ChatColor.AQUA + "" + ChatColor.ITALIC; + String what = dn.contains("Key") ? "key" : "disk"; + lore.add(format + "This " + what + " belongs to"); + lore.add(format + human.getName()); + im.setLore(lore); + is.setItemMeta(im); + ci.setResult(is); + } + } else if (dn.startsWith("Door ") && im.hasCustomModelData()) { + // add custom block key to PDC + im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, 10000); is.setItemMeta(im); ci.setResult(is); } From 056c4f11cea98f66783d55632c49a09e3557a423 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sun, 31 Mar 2024 19:30:48 +1300 Subject: [PATCH 03/96] Populate console text display --- .../TARDIS/console/ConsoleBuilder.java | 1 + .../TARDIS/console/ControlMonitor.java | 87 ++++++++++++- .../TARDIS/control/TARDISControlRunnable.java | 59 +-------- .../resultset/ResultSetOccupiedConsole.java | 121 ++++++++++++++++++ .../TARDIS/utility/TARDISStaticUtils.java | 49 +++++++ todo.md | 3 +- 6 files changed, 258 insertions(+), 62 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetOccupiedConsole.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index 9a6b607a1..b24a31e90 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -52,5 +52,6 @@ public void create(Block block, int type) { // set display rotation display.setRotation(yaw, 0); } + // TODO set interaction entities for console controls } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java b/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java index 74eb40a37..9d050c047 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java @@ -1,7 +1,15 @@ package me.eccentric_nz.TARDIS.console; +import com.mojang.datafixers.util.Pair; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISConstants; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetConsole; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetOccupiedConsole; +import me.eccentric_nz.TARDIS.enumeration.WorldManager; +import me.eccentric_nz.TARDIS.planets.TARDISAliasResolver; +import me.eccentric_nz.TARDIS.utility.TARDISStaticUtils; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Display; import org.bukkit.entity.Entity; import org.bukkit.entity.TextDisplay; import org.bukkit.util.Transformation; @@ -9,26 +17,91 @@ import java.util.UUID; -public class ControlMonitor { +public class ControlMonitor implements Runnable { + private final TARDIS plugin; private final Transformation transformation = new Transformation(TARDISConstants.VECTOR_ZERO, TARDISConstants.AXIS_ANGLE_ZERO, new Vector3f(0.5f, 0.5f, 0.5f), TARDISConstants.AXIS_ANGLE_ZERO); + private int modulo = 0; public ControlMonitor(TARDIS plugin) { this.plugin = plugin; } + @Override + public void run() { + ResultSetOccupiedConsole rsoc = new ResultSetOccupiedConsole(plugin); + rsoc.resultSetAsync(resultSetOccupied -> { + for (Pair pair : rsoc.getData()) { + update(pair.getFirst(), pair.getSecond(), modulo % 2 == 0); + } + }); + modulo++; + if (modulo == 2) { + modulo = 0; + } + } + public void update(int id, UUID uuid, boolean coords) { Entity entity = plugin.getServer().getEntity(uuid); if (!(entity instanceof TextDisplay textDisplay)) { return; } - // line_width or just \n? - // billboard - vertical - textDisplay.setText(makeText(id)); + textDisplay.setTransformation(transformation); + textDisplay.setBillboard(Display.Billboard.FIXED); + textDisplay.setText(makeText(id, coords)); } - private String makeText(int id) { - - return ""; + private String makeText(int id, boolean coords) { + ResultSetConsole rsc = new ResultSetConsole(plugin, id); + StringBuilder builder = new StringBuilder(); + if (plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { + builder.append(ChatColor.DARK_PURPLE) + .append("Drifting\n") + .append("in the\n") + .append("time\n") + .append("vortex..."); + } else if (coords) { + rsc.locationAsync((hasResult, resultSetConsole) -> { + if (hasResult) { + String worldName = (resultSetConsole.getWorld() != null) ? TARDISAliasResolver.getWorldAlias(resultSetConsole.getWorld()) : ""; + if (!plugin.getPlanetsConfig().getBoolean("planets." + resultSetConsole.getWorld() + ".enabled") && plugin.getWorldManager().equals(WorldManager.MULTIVERSE) && !worldName.isEmpty()) { + worldName = plugin.getMVHelper().getAlias(worldName); + } + builder.append(ChatColor.DARK_PURPLE) + .append(worldName) + .append("\n") + .append(ChatColor.BLACK) + .append(resultSetConsole.getX()) + .append("\n") + .append(resultSetConsole.getY()) + .append("\n") + .append(resultSetConsole.getZ()); + } + }); + } else { + // get the artron data + rsc.artronAsync((hasResult, resultSetConsole) -> { + if (hasResult) { + builder.append(ChatColor.BLACK) + .append(plugin.getLanguage().getString("ARTRON_DISPLAY")) + .append("\n") + .append(ChatColor.AQUA) + .append(resultSetConsole.getArtronLevel()) + .append("\n") + .append(ChatColor.BLACK) + .append(plugin.getLanguage().getString("CHAM_DISPLAY")) + .append("\n"); + String preset = ""; + if (resultSetConsole.getPreset().startsWith("POLICE_BOX_")) { + ChatColor colour = TARDISStaticUtils.policeBoxToChatColor(resultSetConsole.getPreset()); + preset = colour + "POLICE_BOX"; + } else { + preset = ChatColor.BLUE + resultSetConsole.getPreset().replace("ITEM:", ""); + } + builder.append(preset); + } + }); + } + return builder.toString(); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlRunnable.java index 40b4c49bb..00654a20b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlRunnable.java @@ -21,6 +21,7 @@ import me.eccentric_nz.TARDIS.database.resultset.ResultSetOccupied; import me.eccentric_nz.TARDIS.enumeration.WorldManager; import me.eccentric_nz.TARDIS.planets.TARDISAliasResolver; +import me.eccentric_nz.TARDIS.utility.TARDISStaticUtils; import net.md_5.bungee.api.ChatColor; import org.bukkit.Tag; import org.bukkit.block.Sign; @@ -88,7 +89,7 @@ public void run() { front.setLine(2, ChatColor.BLACK + plugin.getLanguage().getString("CHAM_DISPLAY")); String preset = ""; if (resultSetConsole.getPreset().startsWith("POLICE_BOX_")) { - ChatColor colour = policeBoxToChatColor(resultSetConsole.getPreset()); + ChatColor colour = TARDISStaticUtils.policeBoxToChatColor(resultSetConsole.getPreset()); preset = colour + "POLICE_BOX"; } else { preset = ChatColor.BLUE + resultSetConsole.getPreset().replace("ITEM:", ""); @@ -100,60 +101,10 @@ public void run() { }); } } - modulo++; - if (modulo == 2) { - modulo = 0; - } }); - } - - private ChatColor policeBoxToChatColor(String preset) { - switch (preset) { - case "POLICE_BOX_WHITE" -> { - return ChatColor.WHITE; - } - case "POLICE_BOX_BROWN", "POLICE_BOX_ORANGE" -> { - return ChatColor.GOLD; - } - case "POLICE_BOX_BLACK" -> { - return ChatColor.BLACK; - } - case "POLICE_BOX_CYAN" -> { - return ChatColor.DARK_AQUA; - } - case "POLICE_BOX_LIGHT_BLUE" -> { - return ChatColor.BLUE; - } - case "POLICE_BOX_GRAY" -> { - return ChatColor.DARK_GRAY; - } - case "POLICE_BOX_GREEN" -> { - return ChatColor.DARK_GREEN; - } - case "POLICE_BOX_PURPLE" -> { - return ChatColor.DARK_PURPLE; - } - case "POLICE_BOX_RED" -> { - return ChatColor.DARK_RED; - } - case "POLICE_BOX_LIGHT_GRAY" -> { - return ChatColor.GRAY; - } - case "POLICE_BOX_LIME" -> { - return ChatColor.GREEN; - } - case "POLICE_BOX_PINK" -> { - return ChatColor.LIGHT_PURPLE; - } - case "POLICE_BOX_MAGENTA" -> { - return ChatColor.RED; - } - case "POLICE_BOX_YELLOW" -> { - return ChatColor.YELLOW; - } - default -> { - return ChatColor.DARK_BLUE; - } + modulo++; + if (modulo == 2) { + modulo = 0; } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetOccupiedConsole.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetOccupiedConsole.java new file mode 100644 index 000000000..329014b44 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetOccupiedConsole.java @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2024 eccentric_nz + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package me.eccentric_nz.TARDIS.database.resultset; + +import com.mojang.datafixers.util.Pair; +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.TARDISDatabaseConnection; +import me.eccentric_nz.TARDIS.utility.TARDISStaticUtils; +import org.bukkit.Bukkit; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.UUID; + +/** + * Many facts, figures, and formulas are contained within the Matrix, including... the companions who travel in the + * TARDIS. + *

+ * Companions are the Doctor's closest friends. Such people knew the Doctor's "secret": that he was someone non-human + * who travelled in space and time in a police box-shaped craft called the TARDIS. + * + * @author eccentric_nz + */ +public class ResultSetOccupiedConsole { + + private final TARDISDatabaseConnection service = TARDISDatabaseConnection.getINSTANCE(); + private final Connection connection = service.getConnection(); + private final TARDIS plugin; + private final List> data = new ArrayList<>(); + private final String prefix; + + /** + * Creates a class instance that can be used to retrieve an SQL ResultSet from the travellers table. + * + * @param plugin an instance of the main class. + */ + public ResultSetOccupiedConsole(TARDIS plugin) { + this.plugin = plugin; + prefix = this.plugin.getPrefix(); + } + + public void resultSetAsync(final ResultSetOccupiedCallback callback) { + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + resultSet(); + // go back to the tick loop + Bukkit.getScheduler().runTask(plugin, () -> { + // call the callback with the result + callback.onDone(this); + }); + }); + } + + /** + * Retrieves an SQL ResultSet from the travellers table. This method builds an SQL query string from the parameters + * supplied and then executes the query. Use the getters to retrieve the results. + */ + public void resultSet() { + Statement statement = null; + ResultSet rs = null; + long time = System.currentTimeMillis() - 86400000; + String query = "SELECT DISTINCT " + prefix + "travellers.tardis_id, " + prefix + "consoles.uuid FROM " + prefix + "travellers, " + prefix + "tardis, " + prefix + "consoles WHERE " + prefix + "tardis.lastuse > " + time + " AND " + prefix + "tardis.tardis_id = " + prefix + "travellers.tardis_id AND " + prefix + "tardis.tardis_id = " + prefix + "consoles.tardis_id"; + try { + service.testConnection(connection); + statement = connection.createStatement(); + rs = statement.executeQuery(query); + if (rs.isBeforeFirst()) { + while (rs.next()) { + UUID uuid; + try { + uuid = UUID.fromString(rs.getString("uuid")); + } catch (IllegalArgumentException e) { + uuid = TARDISStaticUtils.getZERO_UUID(); + } + Pair pair = new Pair<>(rs.getInt("tardis_id"), uuid); + data.add(pair); + } + } + } catch (SQLException e) { + plugin.debug("ResultSet error for ResultSetOccupiedConsole! " + e.getMessage()); + } finally { + try { + if (rs != null) { + rs.close(); + } + if (statement != null) { + statement.close(); + } + } catch (SQLException e) { + plugin.debug("Error closing ResultSetOccupiedConsole! " + e.getMessage()); + } + } + } + + public List> getData() { + return Collections.unmodifiableList(data); + } + + public interface ResultSetOccupiedCallback { + + void onDone(ResultSetOccupiedConsole resultSetOccupied); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISStaticUtils.java b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISStaticUtils.java index bb9cd8d4c..3312c99b9 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISStaticUtils.java +++ b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISStaticUtils.java @@ -47,6 +47,55 @@ public class TARDISStaticUtils { private static final UUID ZERO_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); + public static ChatColor policeBoxToChatColor(String preset) { + switch (preset) { + case "POLICE_BOX_WHITE" -> { + return ChatColor.WHITE; + } + case "POLICE_BOX_BROWN", "POLICE_BOX_ORANGE" -> { + return ChatColor.GOLD; + } + case "POLICE_BOX_BLACK" -> { + return ChatColor.BLACK; + } + case "POLICE_BOX_CYAN" -> { + return ChatColor.DARK_AQUA; + } + case "POLICE_BOX_LIGHT_BLUE" -> { + return ChatColor.BLUE; + } + case "POLICE_BOX_GRAY" -> { + return ChatColor.DARK_GRAY; + } + case "POLICE_BOX_GREEN" -> { + return ChatColor.DARK_GREEN; + } + case "POLICE_BOX_PURPLE" -> { + return ChatColor.DARK_PURPLE; + } + case "POLICE_BOX_RED" -> { + return ChatColor.DARK_RED; + } + case "POLICE_BOX_LIGHT_GRAY" -> { + return ChatColor.GRAY; + } + case "POLICE_BOX_LIME" -> { + return ChatColor.GREEN; + } + case "POLICE_BOX_PINK" -> { + return ChatColor.LIGHT_PURPLE; + } + case "POLICE_BOX_MAGENTA" -> { + return ChatColor.RED; + } + case "POLICE_BOX_YELLOW" -> { + return ChatColor.YELLOW; + } + default -> { + return ChatColor.DARK_BLUE; + } + } + } /** * diff --git a/todo.md b/todo.md index b4a433da9..b78a942b8 100644 --- a/todo.md +++ b/todo.md @@ -3,7 +3,8 @@ ## Current version `5.6.0` 1. Fix fifteenth console redstone piston door -2. ? +2. Fix follower persistence +3. ? ## Next version `5.7.0` From 46a758db0508a4db061789694a403157ced82a82 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sun, 31 Mar 2024 19:39:01 +1300 Subject: [PATCH 04/96] #833 Fix custom door close animation when actually used as interior door --- .../me/eccentric_nz/TARDIS/doors/DoorToggleAction.java | 2 +- .../eccentric_nz/TARDIS/doors/TARDISInnerDoorCloser.java | 8 ++++---- .../eccentric_nz/TARDIS/hads/TARDISHostileDispersal.java | 2 +- .../TARDIS/listeners/TARDISTimeLordDeathListener.java | 4 ++-- .../TARDIS/move/TARDISCustomModelDataChanger.java | 5 +++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/doors/DoorToggleAction.java b/src/main/java/me/eccentric_nz/TARDIS/doors/DoorToggleAction.java index aa57b2e06..25dff73de 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/doors/DoorToggleAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/doors/DoorToggleAction.java @@ -209,7 +209,7 @@ public boolean openClose(int id, Player player, ArmorStand stand) { return true; } // close portal & inner door - new TARDISInnerDoorCloser(plugin, uuid, id).closeDoor(); + new TARDISInnerDoorCloser(plugin, uuid, id).closeDoor(!plugin.getUtils().inTARDISWorld(player)); if (dye.getType() == Material.ENDER_PEARL) { new PandoricaOpens(plugin).animate(stand, false); } else { diff --git a/src/main/java/me/eccentric_nz/TARDIS/doors/TARDISInnerDoorCloser.java b/src/main/java/me/eccentric_nz/TARDIS/doors/TARDISInnerDoorCloser.java index fdab614cb..1a6f46d54 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/doors/TARDISInnerDoorCloser.java +++ b/src/main/java/me/eccentric_nz/TARDIS/doors/TARDISInnerDoorCloser.java @@ -52,14 +52,14 @@ public TARDISInnerDoorCloser(TARDIS plugin, UUID uuid, int id) { this.id = id; } - public void closeDoor() { + public void closeDoor(boolean outside) { // get inner door location ResultSetDoorBlocks rs = new ResultSetDoorBlocks(plugin, id); if (rs.resultSet()) { if (!rs.getInnerBlock().getChunk().isLoaded()) { rs.getInnerBlock().getChunk().load(); } - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> close(rs.getInnerBlock()), 5L); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> close(rs.getInnerBlock(), outside), 5L); } } @@ -68,7 +68,7 @@ public void closeDoor() { * * @param block the bottom door block */ - private void close(Block block) { + private void close(Block block, boolean outside) { if (block != null && Tag.DOORS.isTagged(block.getType())) { Openable closeable = (Openable) block.getBlockData(); closeable.setOpen(false); @@ -81,7 +81,7 @@ private void close(Block block) { if (tdi != null) { ItemStack itemStack = display.getItemStack(); ItemMeta im = itemStack.getItemMeta(); - if (tdi == TARDISDisplayItem.DOOR_OPEN || tdi == TARDISDisplayItem.DOOR_BOTH_OPEN || tdi == TARDISDisplayItem.CLASSIC_DOOR_OPEN || tdi == TARDISDisplayItem.CUSTOM_DOOR) { + if ((tdi == TARDISDisplayItem.DOOR_OPEN || tdi == TARDISDisplayItem.DOOR_BOTH_OPEN || tdi == TARDISDisplayItem.CLASSIC_DOOR_OPEN || tdi == TARDISDisplayItem.CUSTOM_DOOR) && outside) { im.setCustomModelData(10000); } itemStack.setItemMeta(im); diff --git a/src/main/java/me/eccentric_nz/TARDIS/hads/TARDISHostileDispersal.java b/src/main/java/me/eccentric_nz/TARDIS/hads/TARDISHostileDispersal.java index ae6dd6dde..4e08bcace 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/hads/TARDISHostileDispersal.java +++ b/src/main/java/me/eccentric_nz/TARDIS/hads/TARDISHostileDispersal.java @@ -80,7 +80,7 @@ void disperseTARDIS(int id, UUID uuid, Player hostile, ChameleonPreset preset) { if (plugin.getConfig().getBoolean("preferences.walk_in_tardis")) { // always remove the portal plugin.getTrackerKeeper().getPortals().remove(l); - // toggle the doors if neccessary + // toggle the doors if necessary new DoorCloserAction(plugin, uuid, id).closeDoors(); } World w = l.getWorld(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISTimeLordDeathListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISTimeLordDeathListener.java index 9993bf5a0..8835a3399 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISTimeLordDeathListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISTimeLordDeathListener.java @@ -184,7 +184,7 @@ public void onTimeLordDeath(PlayerDeathEvent event) { going_home = true; } } else { - // died in home world get closest location + // died in home world, get closest location Location recharger = getRecharger(death_world, player); if (recharger != null) { // which is closer? @@ -304,7 +304,7 @@ public void onTimeLordDeath(PlayerDeathEvent event) { HashMap setp = new HashMap<>(); // power down setp.put("powered_on", 0); - // police box lamp, delay it incase the TARDIS needs rebuilding + // police box lamp, delay it in case the TARDIS needs rebuilding if (tardis.getPreset().equals(ChameleonPreset.ADAPTIVE) || tardis.getPreset().usesArmourStand()) { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new TARDISAdaptiveBoxLampToggler(plugin).toggleLamp(id, false, tardis.getPreset()), 1L); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISCustomModelDataChanger.java b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISCustomModelDataChanger.java index 77f814c8e..a4bdd8940 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISCustomModelDataChanger.java +++ b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISCustomModelDataChanger.java @@ -77,11 +77,12 @@ public void toggleOuterDoor() { if (cmd == 1001 || cmd == 1002) { boolean open = (cmd == 1001); int newData; + boolean outside = !plugin.getUtils().inTARDISWorld(player); if (open) { - new TARDISInnerDoorOpener(plugin, uuid, id).openDoor(!plugin.getUtils().inTARDISWorld(player)); + new TARDISInnerDoorOpener(plugin, uuid, id).openDoor(outside); newData = 1002; } else { - new TARDISInnerDoorCloser(plugin, uuid, id).closeDoor(); + new TARDISInnerDoorCloser(plugin, uuid, id).closeDoor(outside); newData = 1001; } if (preset != ChameleonPreset.PANDORICA) { From 5ce1d405bd7487ef0a571d12977d4e6aa2ec7ccd Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Mon, 1 Apr 2024 18:16:22 +1300 Subject: [PATCH 05/96] Add interactions table to database --- .../TARDIS/console/ControlMonitor.java | 4 +- .../TARDIS/database/TARDISSQLiteDatabase.java | 4 + .../resultset/ResultSetInteraction.java | 122 ++++++++++++++++++ ...sole.java => ResultSetOccupiedScreen.java} | 25 ++-- .../TARDIS/database/tool/Converter.java | 4 + .../TARDIS/database/tool/Main.java | 4 + .../TARDIS/database/tool/SQL.java | 6 + .../TARDIS/database/tool/Table.java | 1 + .../TARDIS/enumeration/Control.java | 3 +- 9 files changed, 159 insertions(+), 14 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteraction.java rename src/main/java/me/eccentric_nz/TARDIS/database/resultset/{ResultSetOccupiedConsole.java => ResultSetOccupiedScreen.java} (76%) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java b/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java index 9d050c047..2d228007f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java @@ -4,7 +4,7 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISConstants; import me.eccentric_nz.TARDIS.database.resultset.ResultSetConsole; -import me.eccentric_nz.TARDIS.database.resultset.ResultSetOccupiedConsole; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetOccupiedScreen; import me.eccentric_nz.TARDIS.enumeration.WorldManager; import me.eccentric_nz.TARDIS.planets.TARDISAliasResolver; import me.eccentric_nz.TARDIS.utility.TARDISStaticUtils; @@ -29,7 +29,7 @@ public ControlMonitor(TARDIS plugin) { @Override public void run() { - ResultSetOccupiedConsole rsoc = new ResultSetOccupiedConsole(plugin); + ResultSetOccupiedScreen rsoc = new ResultSetOccupiedScreen(plugin); rsoc.resultSetAsync(resultSetOccupied -> { for (Pair pair : rsoc.getData()) { update(pair.getFirst(), pair.getSecond(), modulo % 2 == 0); diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/TARDISSQLiteDatabase.java b/src/main/java/me/eccentric_nz/TARDIS/database/TARDISSQLiteDatabase.java index 220f574e4..727017936 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/TARDISSQLiteDatabase.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/TARDISSQLiteDatabase.java @@ -160,6 +160,10 @@ public void createTables() { String queryHomes = "CREATE TABLE IF NOT EXISTS " + prefix + "homes (home_id INTEGER PRIMARY KEY NOT NULL, tardis_id INTEGER, world TEXT COLLATE NOCASE DEFAULT '', x INTEGER, y INTEGER, z INTEGER, direction TEXT DEFAULT '', submarine INTEGER DEFAULT 0, preset TEXT DEFAULT '')"; statement.executeUpdate(queryHomes); + // Table structure for table 'interactions' + String queryInteractions = "CREATE TABLE IF NOT EXISTS " + prefix + "interactions (i_id INTEGER PRIMARY KEY NOT NULL, tardis_id INTEGER, uuid TEXT DEFAULT '', control TEXT DEFAULT '', state INTEGER)"; + statement.executeUpdate(queryInteractions); + // Table structure for inventories String queryInventories = "CREATE TABLE IF NOT EXISTS " + prefix + "inventories (id INTEGER PRIMARY KEY NOT NULL, uuid TEXT, player TEXT, arch INTEGER, inventory TEXT, armour TEXT, attributes TEXT, armour_attributes TEXT)"; statement.executeUpdate(queryInventories); diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteraction.java new file mode 100644 index 000000000..a9c823b39 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteraction.java @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2024 eccentric_nz + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package me.eccentric_nz.TARDIS.database.resultset; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.TARDISDatabaseConnection; +import me.eccentric_nz.TARDIS.enumeration.Control; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.UUID; + +/** + * A TARDIS control room, also referred to as a console room, is any place on a TARDIS that contains a functioning + * control console. This flight deck also functions as a point of exit. A control room's look can be changed over + * time, to suit one's tastes and personality. The process by which an operator can transform a control room is + * fairly simple, once compared by the Fifth Doctor to changing a "desktop theme". + * + * @author eccentric_nz + */ +public class ResultSetInteraction { + + private final TARDISDatabaseConnection service = TARDISDatabaseConnection.getINSTANCE(); + private final Connection connection = service.getConnection(); + private final TARDIS plugin; + private final String prefix; + private final UUID uuid; + private int interaction_id; + private int tardis_id; + private Control control; + private int state; + + /** + * Creates a class instance that can be used to retrieve an SQL ResultSet from the interactions table. + * + * @param plugin an instance of the main class. + */ + public ResultSetInteraction(TARDIS plugin, UUID uuid) { + this.plugin = plugin; + this.uuid = uuid; + prefix = this.plugin.getPrefix(); + } + + /** + * Retrieves an SQL ResultSet from the interactions table. This method builds an SQL query string from the parameters + * supplied and then executes the query. Use the getters to retrieve the results. + * + * @return true or false depending on whether any data matches the query + */ + public boolean resultSet() { + PreparedStatement statement = null; + ResultSet rs = null; + String query = "SELECT * FROM " + prefix + "interactions WHERE uuid = ?"; + try { + service.testConnection(connection); + statement = connection.prepareStatement(query); + statement.setString(1, uuid.toString()); + rs = statement.executeQuery(); + if (rs.isBeforeFirst()) { + while (rs.next()) { + interaction_id = rs.getInt("i_id"); + tardis_id = rs.getInt("tardis_id"); + control = Control.valueOf(rs.getString("control")); + state = rs.getInt("state"); + } + } else { + return false; + } + } catch (SQLException e) { + plugin.debug("ResultSet error for interactions table! " + e.getMessage()); + return false; + } finally { + try { + if (rs != null) { + rs.close(); + } + if (statement != null) { + statement.close(); + } + } catch (SQLException e) { + plugin.debug("Error closing interactions table! " + e.getMessage()); + } + } + return true; + } + + public int getInteraction_id() { + return interaction_id; + } + + public int getTardis_id() { + return tardis_id; + } + + public UUID getUniqueId() { + return uuid; + } + + public Control getControl() { + return control; + } + + public int getState() { + return state; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetOccupiedConsole.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetOccupiedScreen.java similarity index 76% rename from src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetOccupiedConsole.java rename to src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetOccupiedScreen.java index 329014b44..25e5c3902 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetOccupiedConsole.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetOccupiedScreen.java @@ -32,15 +32,13 @@ import java.util.UUID; /** - * Many facts, figures, and formulas are contained within the Matrix, including... the companions who travel in the - * TARDIS. - *

- * Companions are the Doctor's closest friends. Such people knew the Doctor's "secret": that he was someone non-human - * who travelled in space and time in a police box-shaped craft called the TARDIS. + * The TARDIS scanner, also known as the video screen, vid-screen or, in its smoke-like monitor-less configuration, + * the smoke screen is the main method for the occupants of the vessel to observe the outside environment. + * The appearance and specifications of the scanner system have varied significantly in the course of the Doctor's travels. * * @author eccentric_nz */ -public class ResultSetOccupiedConsole { +public class ResultSetOccupiedScreen { private final TARDISDatabaseConnection service = TARDISDatabaseConnection.getINSTANCE(); private final Connection connection = service.getConnection(); @@ -53,7 +51,7 @@ public class ResultSetOccupiedConsole { * * @param plugin an instance of the main class. */ - public ResultSetOccupiedConsole(TARDIS plugin) { + public ResultSetOccupiedScreen(TARDIS plugin) { this.plugin = plugin; prefix = this.plugin.getPrefix(); } @@ -77,7 +75,12 @@ public void resultSet() { Statement statement = null; ResultSet rs = null; long time = System.currentTimeMillis() - 86400000; - String query = "SELECT DISTINCT " + prefix + "travellers.tardis_id, " + prefix + "consoles.uuid FROM " + prefix + "travellers, " + prefix + "tardis, " + prefix + "consoles WHERE " + prefix + "tardis.lastuse > " + time + " AND " + prefix + "tardis.tardis_id = " + prefix + "travellers.tardis_id AND " + prefix + "tardis.tardis_id = " + prefix + "consoles.tardis_id"; + String query = "SELECT DISTINCT " + prefix + "travellers.tardis_id, " + prefix + "interactions.uuid FROM " + + prefix + "travellers, " + prefix + "tardis, " + prefix + "interactions WHERE " + + prefix + "interactions.control = 'SCREEN' AND " + + prefix + "tardis.lastuse > " + time + " AND " + + prefix + "tardis.tardis_id = " + prefix + "travellers.tardis_id AND " + + prefix + "tardis.tardis_id = " + prefix + "interactions.tardis_id"; try { service.testConnection(connection); statement = connection.createStatement(); @@ -95,7 +98,7 @@ public void resultSet() { } } } catch (SQLException e) { - plugin.debug("ResultSet error for ResultSetOccupiedConsole! " + e.getMessage()); + plugin.debug("ResultSet error for ResultSetOccupiedScreen! " + e.getMessage()); } finally { try { if (rs != null) { @@ -105,7 +108,7 @@ public void resultSet() { statement.close(); } } catch (SQLException e) { - plugin.debug("Error closing ResultSetOccupiedConsole! " + e.getMessage()); + plugin.debug("Error closing ResultSetOccupiedScreen! " + e.getMessage()); } } } @@ -116,6 +119,6 @@ public List> getData() { public interface ResultSetOccupiedCallback { - void onDone(ResultSetOccupiedConsole resultSetOccupied); + void onDone(ResultSetOccupiedScreen resultSetOccupied); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/tool/Converter.java b/src/main/java/me/eccentric_nz/TARDIS/database/tool/Converter.java index 6e80ee0b9..176382f3c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/tool/Converter.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/tool/Converter.java @@ -201,6 +201,10 @@ public void run() { str = String.format(SQL.VALUES.get(i), rs.getInt("home_id"), rs.getInt("tardis_id"), rs.getString("world"), rs.getInt("x"), rs.getInt("y"), rs.getInt("z"), rs.getString("direction"), rs.getInt("submarine"), rs.getString("preset")) + end; sb.append(str); } + case interactions -> { + str = String.format(SQL.VALUES.get(i), rs.getInt("i_id"), rs.getInt("tardis_id"), rs.getString("uuid"), rs.getString("control"), rs.getInt("state")) + end; + sb.append(str); + } case inventories -> { str = String.format(SQL.VALUES.get(i), rs.getInt("id"), rs.getString("uuid"), rs.getString("player"), rs.getInt("arch"), rs.getString("inventory"), rs.getString("armour"), rs.getString("attributes"), rs.getString("armour_attributes")) + end; sb.append(str); diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/tool/Main.java b/src/main/java/me/eccentric_nz/TARDIS/database/tool/Main.java index 79b03bf6b..2016e9cf7 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/tool/Main.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/tool/Main.java @@ -238,6 +238,10 @@ public static void process(PrintWriter console, File sqlite, File mysql, String str = String.format(SQL.VALUES.get(i), rs.getInt("home_id"), rs.getInt("tardis_id"), rs.getString("world"), rs.getInt("x"), rs.getInt("y"), rs.getInt("z"), rs.getString("direction"), rs.getInt("submarine"), rs.getString("preset")) + end; bw.write(str); } + case interactions -> { + str = String.format(SQL.VALUES.get(i), rs.getInt("i_id"), rs.getInt("tardis_id"), rs.getString("uuid"), rs.getString("control"), rs.getInt("state")) + end; + bw.write(str); + } case inventories -> { str = String.format(SQL.VALUES.get(i), rs.getInt("id"), rs.getString("uuid"), rs.getString("player"), rs.getInt("arch"), rs.getString("inventory"), rs.getString("armour"), rs.getString("attributes"), rs.getString("armour_attributes")) + end; bw.write(str); diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/tool/SQL.java b/src/main/java/me/eccentric_nz/TARDIS/database/tool/SQL.java index 8a827b217..c0e0fab4a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/tool/SQL.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/tool/SQL.java @@ -80,6 +80,8 @@ public class SQL { "CREATE TABLE IF NOT EXISTS %shomes (home_id int(11) NOT NULL AUTO_INCREMENT, tardis_id int(11) DEFAULT '0', world varchar(64) DEFAULT '', x int(7) DEFAULT '0', y int(3) DEFAULT '0', z int(7) DEFAULT '0', direction varchar(5) DEFAULT '', submarine int(1) DEFAULT '0', preset varchar(64) DEFAULT '', PRIMARY KEY (home_id)) DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;", + "CREATE TABLE IF NOT EXISTS %sinteractions (i_id int(11) NOT NULL AUTO_INCREMENT, tardis_id int(11) DEFAULT '0', uuid varchar(48) DEFAULT '', control varchar(48) DEFAULT '', state int(2) DEFAULT '0', PRIMARY KEY (i_id)) DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;", + "CREATE TABLE IF NOT EXISTS %sinventories (id int(11) NOT NULL AUTO_INCREMENT, uuid varchar(48) DEFAULT '', player varchar(24) DEFAULT '', arch int(1), inventory text, armour text, attributes text, armour_attributes text, PRIMARY KEY (id)) DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;", "CREATE TABLE IF NOT EXISTS %sjunk (id int(11) NOT NULL AUTO_INCREMENT, uuid varchar(48) DEFAULT '', tardis_id int(11) DEFAULT '0', save_sign varchar(512) DEFAULT '', handbrake varchar(512) DEFAULT '', wall varchar(64) DEFAULT 'ORANGE_WOOL', floor varchar(64) DEFAULT 'LIGHT_GRAY_WOOL', preset varchar(32) DEFAULT '', PRIMARY KEY (id)) DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;", @@ -202,6 +204,8 @@ public class SQL { "(%s, %s, '%s', %s, %s, %s, '%s', %s, '%s')", + "(%s, %s, '%s', '%s', %s)", + "(%s, '%s', '%s', %s, '%s', '%s', '%s', '%s')", "(%s, '%s', %s, '%s', '%s', '%s', '%s', '%s')", @@ -324,6 +328,8 @@ public class SQL { "INSERT INTO `%shomes` (`home_id`, `tardis_id`, `world`, `x`, `y`, `z`, `direction`, `submarine`, `preset`) VALUES ", + "INSERT INTO `%sinteractions` (`i_id`, `tardis_id`, `uuid`, `control`, `state`) VALUES ", + "INSERT INTO `%sinventories` (`id`, `uuid`, `player`, `arch`, `inventory`, `armour`, `attributes`, `armour_attributes`) VALUES ", "INSERT INTO `%sjunk` (`id`, `uuid`, `tardis_id`, `save_sign`, `handbrake`, `wall`, `floor`, `preset`) VALUES ", diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/tool/Table.java b/src/main/java/me/eccentric_nz/TARDIS/database/tool/Table.java index 9c69eadc7..3ac3b8b97 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/tool/Table.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/tool/Table.java @@ -46,6 +46,7 @@ public enum Table { gardens("garden_id"), gravity_well("g_id"), homes, + interactions("i_id"), inventories("id"), junk("id"), lamps("l_id"), diff --git a/src/main/java/me/eccentric_nz/TARDIS/enumeration/Control.java b/src/main/java/me/eccentric_nz/TARDIS/enumeration/Control.java index 9481b6546..4982b0ccc 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/enumeration/Control.java +++ b/src/main/java/me/eccentric_nz/TARDIS/enumeration/Control.java @@ -73,7 +73,8 @@ public enum Control { RELATIVITY_DIFFERENTIATOR(47, "relativity-differentiator", false, true), SONIC_DOCK(48, "sonic-dock", false, true), EXTERIOR_LAMP(49, "exterior-lamp", false, true), - LIGHT_LEVEL(50, "light-level", false, true); + LIGHT_LEVEL(50, "light-level", false, true), + SCREEN(51, "screen", true, false); private static final HashMap UPDATE_CONTROLS = new HashMap<>(); From 1f31cc54f5019297ccbacc3a22c9e28b254fabf6 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Mon, 1 Apr 2024 22:23:58 +1300 Subject: [PATCH 06/96] Create Interaction.java --- .../TARDIS/console/Interaction.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/Interaction.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/Interaction.java b/src/main/java/me/eccentric_nz/TARDIS/console/Interaction.java new file mode 100644 index 000000000..e42cdb062 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/Interaction.java @@ -0,0 +1,68 @@ +package me.eccentric_nz.TARDIS.console; + +import org.bukkit.util.Vector; + +public enum Interaction { + + // section zero + HANDBRAKE("Time Rotor Handbrake", new Vector(1, 1, 1), 0.25f, 0.25f), + THROTTLE("Flight Speed", new Vector(1, 1, 1), 0.25f, 0.25f), + RELATIVITY_DIFFERENTIATOR("Exterior Flight Switch", new Vector(1, 1, 1), 0.25f, 0.25f), + + // section one + WORLD("Dimension Selector", new Vector(1, 1, 1), 0.25f, 0.25f), + X("X Distance", new Vector(1, 1, 1), 0.25f, 0.25f), + Z("Z Distance", new Vector(1, 1, 1), 0.25f, 0.25f), + MULTIPLIER("Coordinate Increment Modifier", new Vector(1, 1, 1), 0.25f, 0.25f), + HELMIC_REGULATOR("Dimension Selector", new Vector(1, 1, 1), 0.25f, 0.25f), + + // section two + RANDOMISER("Random Location Finder", new Vector(1, 1, 1), 0.25f, 0.25f), + WAYPOINT_SELECTOR("Saves", new Vector(1, 1, 1), 0.25f, 0.25f), + FAST_RETURN("Back Button", new Vector(1,1,1), 0.25f, 0.25f), + + // section three + SONIC_DOCK("Sonic Screwdriver Dock", new Vector(1,1,1), 0.25f, 0.25f), + ARTRON("Artron Energy Button", new Vector(1, 1, 1), 0.25f, 0.25f), + DIRECTION("Exterior Directional Control", new Vector(1,1,1), 0.25f, 0.25f), + TELEPATHIC_CIRCUIT("Telepathic Circuit", new Vector(1,1,1), 0.25f, 0.25f), + + // section four + LIGHT_SWITCH("Interior Light Switch", new Vector(1,1,1), 0.25f, 0.25f), + INTERIOR_LIGHT_LEVEL_SWITCH("Exterior Directional Control", new Vector(1,1,1), 0.25f, 0.25f), + EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Directional Control", new Vector(1,1,1), 0.25f, 0.25f), + DOOR_TOGGLE("Toggle Wool Switch", new Vector(1,1,1), 0.25f, 0.25f), + + // section five + SCREEN("Information Display", new Vector(1, 1, 1), 0.25f, 0.25f), + SCANNER("Exterior Environment Scanner", new Vector(1, 1, 1), 0.25f, 0.25f), + REBUILD("Chameleon Circuit Re-initialiser", new Vector(1, 1, 1), 0.25f, 0.25f); + + private final String alternateName; + private final Vector relativePosition; + private final float width; + private final float height; + + Interaction(String alternateName, Vector relativePosition, float width, float height) { + this.alternateName = alternateName; + this.relativePosition = relativePosition; + this.width = width; + this.height = height; + } + + public String getAlternateName() { + return alternateName; + } + + public Vector getRelativePosition() { + return relativePosition; + } + + public float getWidth() { + return width; + } + + public float getHeight() { + return height; + } +} From 04b93df9a541a2ca4d0f8fd56a877793c4d1b25f Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Tue, 2 Apr 2024 22:22:03 +1300 Subject: [PATCH 07/96] Grrr, Interaction entities can't be rotated But still works okay after getting the positioning sorted --- .../java/me/eccentric_nz/TARDIS/TARDIS.java | 12 ++++ .../TARDIS/TARDISListenerRegisterer.java | 2 + .../TARDIS/console/ConsoleBuilder.java | 22 +++++- .../TARDIS/console/ConsoleInteraction.java | 69 +++++++++++++++++++ .../console/ConsoleInteractionListener.java | 67 ++++++++++++++++++ .../TARDIS/console/ControlMonitor.java | 12 ++-- .../TARDIS/console/Interaction.java | 68 ------------------ .../resultset/ResultSetInteraction.java | 8 +-- 8 files changed, 182 insertions(+), 78 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java delete mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/Interaction.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java b/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java index 318aeb1d3..43a17576b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java +++ b/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java @@ -202,6 +202,7 @@ public class TARDIS extends JavaPlugin { private NamespacedKey tardisIdKey; private NamespacedKey timeLordUuidKey; private NamespacedKey standUuidKey; + private NamespacedKey interactionUuidKey; private NamespacedKey blueprintKey; private NamespacedKey sonicUuidKey; private NamespacedKey sonicChargeKey; @@ -306,6 +307,7 @@ public void onEnable() { tardisIdKey = new NamespacedKey(this, "tardis_id"); timeLordUuidKey = new NamespacedKey(this, "timelord_uuid"); standUuidKey = new NamespacedKey(this, "stand_uuid"); + interactionUuidKey = new NamespacedKey(this, "interaction_uuid"); blueprintKey = new NamespacedKey(this, "blueprint"); sonicUuidKey = new NamespacedKey(this, "sonic_uuid"); sonicChargeKey = new NamespacedKey(this, "sonic_charge"); @@ -1323,6 +1325,16 @@ public NamespacedKey getTimeLordUuidKey() { public NamespacedKey getStandUuidKey() { return standUuidKey; } + + /** + * Gets the console interaction UUID NamespacedKey + * + * @return the console interaction UUID NamespacedKey + */ + public NamespacedKey getInteractionUuidKey() { + return interactionUuidKey; + } + /** * Gets the TARDIS Blueprint NamespacedKey * diff --git a/src/main/java/me/eccentric_nz/TARDIS/TARDISListenerRegisterer.java b/src/main/java/me/eccentric_nz/TARDIS/TARDISListenerRegisterer.java index 1822ffd3c..d334c4a91 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/TARDISListenerRegisterer.java +++ b/src/main/java/me/eccentric_nz/TARDIS/TARDISListenerRegisterer.java @@ -38,6 +38,7 @@ import me.eccentric_nz.TARDIS.commands.utils.TARDISWeatherListener; import me.eccentric_nz.TARDIS.companionGUI.TARDISCompanionAddGUIListener; import me.eccentric_nz.TARDIS.companionGUI.TARDISCompanionGUIListener; +import me.eccentric_nz.TARDIS.console.ConsoleInteractionListener; import me.eccentric_nz.TARDIS.control.TARDISControlListener; import me.eccentric_nz.TARDIS.control.TARDISControlMenuListener; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayBlockListener; @@ -193,6 +194,7 @@ TARDISInformationSystemListener registerListeners() { plugin.getPM().registerEvents(new TARDISDismountListener(plugin), plugin); plugin.getPM().registerEvents(new TARDISDisplayBlockListener(plugin), plugin); plugin.getPM().registerEvents(new TARDISDisplayListener(plugin), plugin); + plugin.getPM().registerEvents(new ConsoleInteractionListener(plugin), plugin); plugin.getPM().registerEvents(new TARDISEjectListener(plugin), plugin); plugin.getPM().registerEvents(new TARDISEntityGriefListener(plugin), plugin); plugin.getPM().registerEvents(new TARDISExplosionAndDamageListener(plugin), plugin); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index b24a31e90..d7e79d7b2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -6,11 +6,14 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Interaction; import org.bukkit.entity.ItemDisplay; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataType; +import java.util.HashMap; + public class ConsoleBuilder { private final TARDIS plugin; @@ -52,6 +55,23 @@ public void create(Block block, int type) { // set display rotation display.setRotation(yaw, 0); } - // TODO set interaction entities for console controls + // set interaction entities for console controls + for (ConsoleInteraction i : ConsoleInteraction.values()) { + double x = i.getRelativePosition().getX(); + double z = i.getRelativePosition().getZ(); + Location location = block.getLocation().clone().add(x, 1, z); + Interaction interaction = (Interaction) location.getWorld().spawnEntity(location, EntityType.INTERACTION); + interaction.getPersistentDataContainer().set(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID(), interaction.getUniqueId()); + interaction.setInteractionWidth(i.getWidth()); + interaction.setInteractionHeight(i.getHeight()); + interaction.setPersistent(true); + interaction.setInvulnerable(true); + HashMap data = new HashMap<>(); + data.put("tardis_id", 3); + data.put("uuid", interaction.getUniqueId()); + data.put("control", i.toString()); + data.put("state", 0); + plugin.getQueryFactory().doInsert("interactions", data); + } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java new file mode 100644 index 000000000..1860e7965 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java @@ -0,0 +1,69 @@ +package me.eccentric_nz.TARDIS.console; + +import org.bukkit.util.Vector; + +public enum ConsoleInteraction { + + // section zero + HANDBRAKE("Time Rotor Handbrake", new Vector(0.0d, 1d, 2.25d), 0.5f, 0.4f), + THROTTLE("Flight Speed", new Vector(0.9d, 1.0d, 2.375d), 0.5f, 0.33f), + RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.575d, 1.0d, 1.75d), 0.5f, 0.65f), + + // section one + WORLD("Dimension Selector", new Vector(-0.525d, 1.0d, 0.95d), 0.15f, 0.65f), + MULTIPLIER("Coordinate Increment Modifier", new Vector(-0.4d, 1.0d, 1.2d), 0.15f, 0.65f), + X("X Distance", new Vector(-0.75d, 1.0d, 1.1d), 0.15f, 0.4f), + Z("Z Distance", new Vector(-0.6d, 1.0d, 1.3d), 0.15f, 0.4f), + HELMIC_REGULATOR("Dimension Selector", new Vector(-0.85d, 1d, 1.8d), 0.5f, 0.6f), + + // section two + RANDOMISER("Random Location Finder", new Vector(-0.85d, 1d, -0.8125d), 0.25f, 0.33f), + WAYPOINT_SELECTOR("Saves", new Vector(-1.1d, 1d, -0.4d), 0.25f, 0.33f), + FAST_RETURN("Back Button", new Vector(-1.35d, 1d, 0d), 0.25f, 0.33f), + TELEPATHIC_CIRCUIT("Telepathic Circuit", new Vector(-0.55d, 1d, -0.15d), 0.5f, 0.65f), + + // section three + SONIC_DOCK("Sonic Screwdriver Dock", new Vector(0.45d, 1d, -0.65d), 0.5f, 0.65f), + DIRECTION("Exterior Directional Control", new Vector(0.125d, 1d, -1.2d), 0.625f, 0.5f), + + // section four + LIGHT_SWITCH("Interior Light Switch", new Vector(2.475d, 1d, 0.1d), 0.25f, 0.33f), + INTERIOR_LIGHT_LEVEL_SWITCH("Interior Light Level", new Vector(1.8d, 1d, 0.0d), 0.25f, 0.5f), + EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Lamp Level", new Vector(1.5d, 1d, -0.3d), 0.25f, 0.5f), + DOOR_TOGGLE("Toggle Wool Switch", new Vector(1.825d, 1d, -1.0d), 0.25f, 0.33f), + + // section five + SCREEN_RIGHT("Coordinates Display", new Vector(1.825d, 1d, 0.95d), 0.5f, 1.1f), + SCREEN_LEFT("Information Display", new Vector(1.525d, 1d, 1.45d), 0.5f, 1.1f), + SCANNER("Exterior Environment Scanner", new Vector(1.825d, 1d, 1.95d), 0.25f, 0.33f), + ARTRON("Artron Energy Button", new Vector(2.125d, 1d, 1.475d), 0.25f, 0.33f), + REBUILD("Chameleon Circuit Re-initialiser", new Vector(2.4d, 1d, 1.025d), 0.25f, 0.33f); + + private final String alternateName; + private final Vector relativePosition; + private final float width; + private final float height; + + ConsoleInteraction(String alternateName, Vector relativePosition, float width, float height) { + this.alternateName = alternateName; + this.relativePosition = relativePosition; + this.width = width; + this.height = height; + } + + public String getAlternateName() { + return alternateName; + } + + public Vector getRelativePosition() { + return relativePosition; + } + + public float getWidth() { + return width; + } + + public float getHeight() { + return height; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java new file mode 100644 index 000000000..101d133bd --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -0,0 +1,67 @@ +package me.eccentric_nz.TARDIS.console; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetInteraction; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.TextDisplay; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.util.Vector; + +import java.util.UUID; + +public class ConsoleInteractionListener implements Listener { + + private final TARDIS plugin; + + public ConsoleInteractionListener(TARDIS plugin) { + this.plugin = plugin; + } + + @EventHandler + public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { + if (event.getRightClicked() instanceof Interaction interaction) { + if (interaction.getPersistentDataContainer().has(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID())) { + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID()); + ResultSetInteraction rsi = new ResultSetInteraction(plugin, uuid); + if (rsi.resultSet()) { + switch (rsi.getControl()) { + case SCREEN_LEFT, SCREEN_RIGHT -> { + plugin.getMessenger().announceRepeater(event.getPlayer(), rsi.getControl().getAlternateName()); + // spawn a text display + boolean coords = rsi.getControl() == ConsoleInteraction.SCREEN_RIGHT; + TextDisplay display = getTextDisplay(interaction.getLocation(), coords); + if (display != null) { + display.setRotation(Location.normalizeYaw(300), -10f); + plugin.debug(display.getLocation()); + new ControlMonitor(plugin).update(3, display.getUniqueId(), coords); + } else { + plugin.getMessenger().announceRepeater(event.getPlayer(), "No text display :("); + } + } + default -> plugin.getMessenger().announceRepeater(event.getPlayer(), rsi.getControl().getAlternateName()); + } + } + } + } + } + + private TextDisplay getTextDisplay(Location location, boolean coords) { + TextDisplay textDisplay = null; + for (Entity entity : location.getWorld().getNearbyEntities(location, 1.0d, 1.0d, 1.0d, (e) -> e.getType() == EntityType.TEXT_DISPLAY)) { + textDisplay = (TextDisplay) entity; + break; + } + if (textDisplay == null) { + Location adjusted = location.clone(); + Vector vector = coords ? new Vector(0.33f,0,0.5f) : new Vector(1.1f,0,0); + adjusted.add(vector); + textDisplay = (TextDisplay) location.getWorld().spawnEntity(adjusted, EntityType.TEXT_DISPLAY); + } + return textDisplay; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java b/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java index 2d228007f..c3048cdb5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java @@ -48,7 +48,9 @@ public void update(int id, UUID uuid, boolean coords) { } textDisplay.setTransformation(transformation); textDisplay.setBillboard(Display.Billboard.FIXED); - textDisplay.setText(makeText(id, coords)); + String text = makeText(id, coords); + plugin.debug(text); + textDisplay.setText(text); } private String makeText(int id, boolean coords) { @@ -70,7 +72,7 @@ private String makeText(int id, boolean coords) { builder.append(ChatColor.DARK_PURPLE) .append(worldName) .append("\n") - .append(ChatColor.BLACK) + .append(ChatColor.WHITE) .append(resultSetConsole.getX()) .append("\n") .append(resultSetConsole.getY()) @@ -82,16 +84,16 @@ private String makeText(int id, boolean coords) { // get the artron data rsc.artronAsync((hasResult, resultSetConsole) -> { if (hasResult) { - builder.append(ChatColor.BLACK) + builder.append(ChatColor.WHITE) .append(plugin.getLanguage().getString("ARTRON_DISPLAY")) .append("\n") .append(ChatColor.AQUA) .append(resultSetConsole.getArtronLevel()) .append("\n") - .append(ChatColor.BLACK) + .append(ChatColor.WHITE) .append(plugin.getLanguage().getString("CHAM_DISPLAY")) .append("\n"); - String preset = ""; + String preset; if (resultSetConsole.getPreset().startsWith("POLICE_BOX_")) { ChatColor colour = TARDISStaticUtils.policeBoxToChatColor(resultSetConsole.getPreset()); preset = colour + "POLICE_BOX"; diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/Interaction.java b/src/main/java/me/eccentric_nz/TARDIS/console/Interaction.java deleted file mode 100644 index e42cdb062..000000000 --- a/src/main/java/me/eccentric_nz/TARDIS/console/Interaction.java +++ /dev/null @@ -1,68 +0,0 @@ -package me.eccentric_nz.TARDIS.console; - -import org.bukkit.util.Vector; - -public enum Interaction { - - // section zero - HANDBRAKE("Time Rotor Handbrake", new Vector(1, 1, 1), 0.25f, 0.25f), - THROTTLE("Flight Speed", new Vector(1, 1, 1), 0.25f, 0.25f), - RELATIVITY_DIFFERENTIATOR("Exterior Flight Switch", new Vector(1, 1, 1), 0.25f, 0.25f), - - // section one - WORLD("Dimension Selector", new Vector(1, 1, 1), 0.25f, 0.25f), - X("X Distance", new Vector(1, 1, 1), 0.25f, 0.25f), - Z("Z Distance", new Vector(1, 1, 1), 0.25f, 0.25f), - MULTIPLIER("Coordinate Increment Modifier", new Vector(1, 1, 1), 0.25f, 0.25f), - HELMIC_REGULATOR("Dimension Selector", new Vector(1, 1, 1), 0.25f, 0.25f), - - // section two - RANDOMISER("Random Location Finder", new Vector(1, 1, 1), 0.25f, 0.25f), - WAYPOINT_SELECTOR("Saves", new Vector(1, 1, 1), 0.25f, 0.25f), - FAST_RETURN("Back Button", new Vector(1,1,1), 0.25f, 0.25f), - - // section three - SONIC_DOCK("Sonic Screwdriver Dock", new Vector(1,1,1), 0.25f, 0.25f), - ARTRON("Artron Energy Button", new Vector(1, 1, 1), 0.25f, 0.25f), - DIRECTION("Exterior Directional Control", new Vector(1,1,1), 0.25f, 0.25f), - TELEPATHIC_CIRCUIT("Telepathic Circuit", new Vector(1,1,1), 0.25f, 0.25f), - - // section four - LIGHT_SWITCH("Interior Light Switch", new Vector(1,1,1), 0.25f, 0.25f), - INTERIOR_LIGHT_LEVEL_SWITCH("Exterior Directional Control", new Vector(1,1,1), 0.25f, 0.25f), - EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Directional Control", new Vector(1,1,1), 0.25f, 0.25f), - DOOR_TOGGLE("Toggle Wool Switch", new Vector(1,1,1), 0.25f, 0.25f), - - // section five - SCREEN("Information Display", new Vector(1, 1, 1), 0.25f, 0.25f), - SCANNER("Exterior Environment Scanner", new Vector(1, 1, 1), 0.25f, 0.25f), - REBUILD("Chameleon Circuit Re-initialiser", new Vector(1, 1, 1), 0.25f, 0.25f); - - private final String alternateName; - private final Vector relativePosition; - private final float width; - private final float height; - - Interaction(String alternateName, Vector relativePosition, float width, float height) { - this.alternateName = alternateName; - this.relativePosition = relativePosition; - this.width = width; - this.height = height; - } - - public String getAlternateName() { - return alternateName; - } - - public Vector getRelativePosition() { - return relativePosition; - } - - public float getWidth() { - return width; - } - - public float getHeight() { - return height; - } -} diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteraction.java index a9c823b39..a8cbb33d1 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteraction.java @@ -17,8 +17,8 @@ package me.eccentric_nz.TARDIS.database.resultset; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.ConsoleInteraction; import me.eccentric_nz.TARDIS.database.TARDISDatabaseConnection; -import me.eccentric_nz.TARDIS.enumeration.Control; import java.sql.Connection; import java.sql.PreparedStatement; @@ -43,7 +43,7 @@ public class ResultSetInteraction { private final UUID uuid; private int interaction_id; private int tardis_id; - private Control control; + private ConsoleInteraction control; private int state; /** @@ -76,7 +76,7 @@ public boolean resultSet() { while (rs.next()) { interaction_id = rs.getInt("i_id"); tardis_id = rs.getInt("tardis_id"); - control = Control.valueOf(rs.getString("control")); + control = ConsoleInteraction.valueOf(rs.getString("control")); state = rs.getInt("state"); } } else { @@ -112,7 +112,7 @@ public UUID getUniqueId() { return uuid; } - public Control getControl() { + public ConsoleInteraction getControl() { return control; } From 333e2f064887e17ba02ba4f24e0444c2e7979ee4 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Wed, 3 Apr 2024 09:55:05 +1300 Subject: [PATCH 08/96] Make text display work --- .../console/ConsoleInteractionListener.java | 9 +++------ .../TARDIS/console/ControlMonitor.java | 20 +++++++++---------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index 101d133bd..d6ac672bf 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -16,7 +16,7 @@ public class ConsoleInteractionListener implements Listener { - private final TARDIS plugin; + private final TARDIS plugin; public ConsoleInteractionListener(TARDIS plugin) { this.plugin = plugin; @@ -32,15 +32,12 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { switch (rsi.getControl()) { case SCREEN_LEFT, SCREEN_RIGHT -> { plugin.getMessenger().announceRepeater(event.getPlayer(), rsi.getControl().getAlternateName()); - // spawn a text display boolean coords = rsi.getControl() == ConsoleInteraction.SCREEN_RIGHT; + // get the text display TextDisplay display = getTextDisplay(interaction.getLocation(), coords); if (display != null) { display.setRotation(Location.normalizeYaw(300), -10f); - plugin.debug(display.getLocation()); new ControlMonitor(plugin).update(3, display.getUniqueId(), coords); - } else { - plugin.getMessenger().announceRepeater(event.getPlayer(), "No text display :("); } } default -> plugin.getMessenger().announceRepeater(event.getPlayer(), rsi.getControl().getAlternateName()); @@ -58,7 +55,7 @@ private TextDisplay getTextDisplay(Location location, boolean coords) { } if (textDisplay == null) { Location adjusted = location.clone(); - Vector vector = coords ? new Vector(0.33f,0,0.5f) : new Vector(1.1f,0,0); + Vector vector = coords ? new Vector(0.0d, 0.5d, 0.35d) : new Vector(0.32d, 0.5d, -0.225d); adjusted.add(vector); textDisplay = (TextDisplay) location.getWorld().spawnEntity(adjusted, EntityType.TEXT_DISPLAY); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java b/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java index c3048cdb5..30bf46823 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java @@ -20,7 +20,7 @@ public class ControlMonitor implements Runnable { private final TARDIS plugin; - private final Transformation transformation = new Transformation(TARDISConstants.VECTOR_ZERO, TARDISConstants.AXIS_ANGLE_ZERO, new Vector3f(0.5f, 0.5f, 0.5f), TARDISConstants.AXIS_ANGLE_ZERO); + private final Transformation transformation = new Transformation(TARDISConstants.VECTOR_ZERO, TARDISConstants.AXIS_ANGLE_ZERO, new Vector3f(0.4f, 0.4f, 0.4f), TARDISConstants.AXIS_ANGLE_ZERO); private int modulo = 0; public ControlMonitor(TARDIS plugin) { @@ -29,9 +29,9 @@ public ControlMonitor(TARDIS plugin) { @Override public void run() { - ResultSetOccupiedScreen rsoc = new ResultSetOccupiedScreen(plugin); - rsoc.resultSetAsync(resultSetOccupied -> { - for (Pair pair : rsoc.getData()) { + ResultSetOccupiedScreen rsos = new ResultSetOccupiedScreen(plugin); + rsos.resultSetAsync(resultSetOccupied -> { + for (Pair pair : rsos.getData()) { update(pair.getFirst(), pair.getSecond(), modulo % 2 == 0); } }); @@ -48,12 +48,8 @@ public void update(int id, UUID uuid, boolean coords) { } textDisplay.setTransformation(transformation); textDisplay.setBillboard(Display.Billboard.FIXED); - String text = makeText(id, coords); - plugin.debug(text); - textDisplay.setText(text); - } - - private String makeText(int id, boolean coords) { + textDisplay.setSeeThrough(true); + // get text ResultSetConsole rsc = new ResultSetConsole(plugin, id); StringBuilder builder = new StringBuilder(); if (plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { @@ -62,6 +58,7 @@ private String makeText(int id, boolean coords) { .append("in the\n") .append("time\n") .append("vortex..."); + textDisplay.setText(builder.toString()); } else if (coords) { rsc.locationAsync((hasResult, resultSetConsole) -> { if (hasResult) { @@ -78,6 +75,7 @@ private String makeText(int id, boolean coords) { .append(resultSetConsole.getY()) .append("\n") .append(resultSetConsole.getZ()); + textDisplay.setText(builder.toString()); } }); } else { @@ -101,9 +99,9 @@ private String makeText(int id, boolean coords) { preset = ChatColor.BLUE + resultSetConsole.getPreset().replace("ITEM:", ""); } builder.append(preset); + textDisplay.setText(builder.toString()); } }); } - return builder.toString(); } } From fc727f60ec1a658c354b17a37228c85a3db70c1e Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Wed, 3 Apr 2024 13:58:41 +1300 Subject: [PATCH 09/96] Process interactions --- .../console/ConsoleInteractionListener.java | 42 +--- .../interaction/FlightModeInteraction.java | 38 +++ .../interaction/HandbrakeInteraction.java | 225 ++++++++++++++++++ .../interaction/RebuildInteraction.java | 23 ++ .../interaction/ScannerIntraction.java | 26 ++ .../interaction/ScreenInteraction.java | 42 ++++ .../interaction/SonicConsoleRecharge.java | 118 +++++++++ .../interaction/SonicDockInteraction.java | 30 +++ .../interaction/ThrottleInteraction.java | 38 +++ .../customblocks/TARDISDisplayItemUtils.java | 34 +++ .../resultset/ResultSetPlayerPrefs.java | 6 +- .../TARDIS/enumeration/FlightMode.java | 3 +- .../TARDIS/enumeration/SpaceTimeThrottle.java | 2 +- .../TARDIS/flight/TARDISExteriorFlight.java | 8 +- .../TARDIS/flight/TARDISTakeoff.java | 6 +- .../TARDIS/sonic/TARDISSonicDock.java | 92 +++++-- 16 files changed, 668 insertions(+), 65 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/RebuildInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerIntraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicConsoleRecharge.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicDockInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index d6ac672bf..ad60fd719 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -1,16 +1,12 @@ package me.eccentric_nz.TARDIS.console; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.interaction.*; import me.eccentric_nz.TARDIS.database.resultset.ResultSetInteraction; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Interaction; -import org.bukkit.entity.TextDisplay; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import org.bukkit.util.Vector; import java.util.UUID; @@ -29,36 +25,20 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { UUID uuid = interaction.getPersistentDataContainer().get(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID()); ResultSetInteraction rsi = new ResultSetInteraction(plugin, uuid); if (rsi.resultSet()) { - switch (rsi.getControl()) { - case SCREEN_LEFT, SCREEN_RIGHT -> { - plugin.getMessenger().announceRepeater(event.getPlayer(), rsi.getControl().getAlternateName()); - boolean coords = rsi.getControl() == ConsoleInteraction.SCREEN_RIGHT; - // get the text display - TextDisplay display = getTextDisplay(interaction.getLocation(), coords); - if (display != null) { - display.setRotation(Location.normalizeYaw(300), -10f); - new ControlMonitor(plugin).update(3, display.getUniqueId(), coords); - } - } + ConsoleInteraction ci = rsi.getControl(); + switch (ci) { + case SCREEN_LEFT, SCREEN_RIGHT -> new ScreenInteraction(plugin).display(interaction.getLocation(), ci == ConsoleInteraction.SCREEN_RIGHT); + case SCANNER -> new ScannerIntraction(plugin).process(rsi.getTardis_id(), event.getPlayer()); + case ARTRON -> plugin.getMessenger().sendArtron(event.getPlayer(), rsi.getTardis_id(), 0); + case REBUILD -> new RebuildInteraction(plugin).process(rsi.getTardis_id(), event.getPlayer()); + case SONIC_DOCK -> new SonicDockInteraction(plugin).process(event.getPlayer(), interaction, rsi.getTardis_id()); + case HANDBRAKE -> new HandbrakeInteraction(plugin).process(rsi.getTardis_id(), rsi.getState(), event.getPlayer(), interaction.getLocation()); + case THROTTLE -> new ThrottleInteraction(plugin).process(event.getPlayer()); + case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(event.getPlayer()); default -> plugin.getMessenger().announceRepeater(event.getPlayer(), rsi.getControl().getAlternateName()); } } } } } - - private TextDisplay getTextDisplay(Location location, boolean coords) { - TextDisplay textDisplay = null; - for (Entity entity : location.getWorld().getNearbyEntities(location, 1.0d, 1.0d, 1.0d, (e) -> e.getType() == EntityType.TEXT_DISPLAY)) { - textDisplay = (TextDisplay) entity; - break; - } - if (textDisplay == null) { - Location adjusted = location.clone(); - Vector vector = coords ? new Vector(0.0d, 0.5d, 0.35d) : new Vector(0.32d, 0.5d, -0.225d); - adjusted.add(vector); - textDisplay = (TextDisplay) location.getWorld().spawnEntity(adjusted, EntityType.TEXT_DISPLAY); - } - return textDisplay; - } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java new file mode 100644 index 000000000..9ab72aa9a --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java @@ -0,0 +1,38 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; +import me.eccentric_nz.TARDIS.enumeration.FlightMode; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; +import org.bukkit.entity.Player; + +import java.util.HashMap; + +public class FlightModeInteraction { + + private final TARDIS plugin; + + public FlightModeInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void process(Player player) { + String uuid = player.getUniqueId().toString(); + // get current throttle setting + ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, uuid); + int mode = rsp.getFlightMode() + 1; + if (mode > 4) { + mode = 1; + } + FlightMode fm = FlightMode.getByMode().get(mode); + plugin.getMessenger().announceRepeater(player, TARDISStringUtils.capitalise(fm.toString())); + HashMap setf = new HashMap<>(); + setf.put("flying_mode", mode); + HashMap where = new HashMap<>(); + where.put("uuid", player.getUniqueId().toString()); + TARDIS.plugin.getQueryFactory().doUpdate("player_prefs", setf, where); + plugin.getMessenger().send(player, TardisModule.TARDIS, "FLIGHT_SAVED"); + // TODO set custom model data for relativity differentiator item display + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java new file mode 100644 index 000000000..aab82547a --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java @@ -0,0 +1,225 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.TARDISConstants; +import me.eccentric_nz.TARDIS.advanced.TARDISCircuitChecker; +import me.eccentric_nz.TARDIS.advanced.TARDISCircuitDamager; +import me.eccentric_nz.TARDIS.artron.TARDISArtronLevels; +import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; +import me.eccentric_nz.TARDIS.builders.TARDISSculkShrieker; +import me.eccentric_nz.TARDIS.camera.TARDISCameraTracker; +import me.eccentric_nz.TARDIS.database.data.Tardis; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentFromId; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; +import me.eccentric_nz.TARDIS.enumeration.*; +import me.eccentric_nz.TARDIS.flight.TARDISExteriorFlight; +import me.eccentric_nz.TARDIS.flight.TARDISTakeoff; +import me.eccentric_nz.TARDIS.rotors.Rotor; +import me.eccentric_nz.TARDIS.rotors.TARDISTimeRotor; +import me.eccentric_nz.TARDIS.utility.Handbrake; +import me.eccentric_nz.TARDIS.utility.TARDISSounds; +import org.bukkit.Location; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Optional; +import java.util.UUID; + +public class HandbrakeInteraction { + + private final TARDIS plugin; + + public HandbrakeInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void process(int id, int state, Player player, Location handbrake) { + UUID uuid = player.getUniqueId(); + TARDISCircuitChecker tcc = null; + if (!plugin.getDifficulty().equals(Difficulty.EASY) && !plugin.getUtils().inGracePeriod(player, state == 0)) { + tcc = new TARDISCircuitChecker(plugin, id); + tcc.getCircuits(); + } + if (tcc != null && !tcc.hasMaterialisation()) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_MAT_CIRCUIT"); + return; + } + if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); + return; + } + if (plugin.getTrackerKeeper().getDispersedTARDII().contains(id)) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_WHILE_DISPERSED"); + return; + } + HashMap wherei = new HashMap<>(); + wherei.put("tardis_id", id); + ResultSetTardis rs = new ResultSetTardis(plugin, wherei, "", false, 2); + if (rs.resultSet()) { + Tardis tardis = rs.getTardis(); + ChameleonPreset preset = tardis.getPreset(); + if (preset.equals(ChameleonPreset.JUNK)) { + return; + } + UUID ownerUUID = tardis.getUuid(); + if ((tardis.isIso_on() && !uuid.equals(ownerUUID) && !TARDISPermission.hasPermission(player, "tardis.skeletonkey")) || plugin.getTrackerKeeper().getJohnSmith().containsKey(uuid)) { + // check if cancelled, so we don't get double messages from the bind listener + plugin.getMessenger().send(player, TardisModule.TARDIS, "ISO_HANDS_OFF"); + return; + } + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); + return; + } + String beacon = tardis.getBeacon(); + if (plugin.getTrackerKeeper().getInVortex().contains(id) || plugin.getTrackerKeeper().getDidDematToVortex().contains(id) || plugin.getTrackerKeeper().getDestinationVortex().containsKey(id) || plugin.getTrackerKeeper().getMaterialising().contains(id) || plugin.getTrackerKeeper().getDematerialising().contains(id)) { + plugin.getMessenger().sendStatus(player, "HANDBRAKE_IN_VORTEX"); + } else { + // should the beacon turn on + ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, uuid.toString()); + boolean beac_on = true; + boolean bar = false; + SpaceTimeThrottle spaceTimeThrottle = SpaceTimeThrottle.NORMAL; + if (rsp.resultSet()) { + beac_on = rsp.isBeaconOn(); + bar = rsp.isTravelbarOn(); + spaceTimeThrottle = SpaceTimeThrottle.getByDelay().get(rsp.getThrottle()); + } + if (state == 1) { + if (tardis.isHandbrake_on()) { + if (preset.equals(ChameleonPreset.JUNK_MODE) && !plugin.getTrackerKeeper().getHasDestination().containsKey(id)) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "TRAVEL_NEED_DEST"); + return; + } + // check there is enough power for at least random travel + if (!plugin.getTrackerKeeper().getHasDestination().containsKey(id) && tardis.getArtron_level() < plugin.getArtronConfig().getInt("random")) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NOT_ENOUGH"); + return; + } + Handbrake check = new Handbrake(plugin); + // check if door is open + if (check.isDoorOpen(id)) { + plugin.getMessenger().sendStatus(player, "DOOR_CLOSE"); + // track handbrake clicked for takeoff when door closed + plugin.getTrackerKeeper().getHasClickedHandbrake().add(id); + // give them 30 seconds to close the door + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> plugin.getTrackerKeeper().getHasClickedHandbrake().removeAll(Collections.singleton(id)), 600L); + return; + } + // check the state of the Relativity Differentiator + if (check.isRelativityDifferentiated(id) && TARDISPermission.hasPermission(player, "tardis.fly") && preset.usesArmourStand() && !player.isSneaking()) { + ResultSetCurrentFromId rsc = new ResultSetCurrentFromId(plugin, id); + if (!rsc.resultSet()) { + plugin.debug("No current location"); + return; + } + // check if TARDIS is underground + for (int y = rsc.getY() + 4; y < rsc.getY() + 8; y++) { + if (!rsc.getWorld().getBlockAt(rsc.getX(), y, rsc.getZ()).getType().isAir()) { + plugin.getMessenger().sendStatus(player, "FLIGHT_AIR"); + return; + } + } + if (TARDISCameraTracker.CAMERA_IN_USE.contains(id)) { + plugin.getMessenger().sendStatus(player, "FLIGHT_CAMERA"); + return; + } + // fly the TARDIS exterior + Location current = new Location(rsc.getWorld(), rsc.getX(), rsc.getY(), rsc.getZ(), player.getLocation().getYaw(), player.getLocation().getPitch()); + new TARDISExteriorFlight(plugin).startFlying(player, id, null, current, beac_on, beacon, preset.equals(ChameleonPreset.PANDORICA)); + TARDISSounds.playTARDISSound(handbrake, "tardis_handbrake_release"); + } else { + new TARDISTakeoff(plugin).run(id, null, handbrake, player, beac_on, beacon, bar, spaceTimeThrottle); + } + // start time rotor? + if (tardis.getRotor() != null) { + if (tardis.getRotor() == TARDISConstants.UUID_ZERO) { + // get sculk shrieker and set shreiking + TARDISSculkShrieker.setRotor(id); + } else { + ItemFrame itemFrame = TARDISTimeRotor.getItemFrame(tardis.getRotor()); + if (itemFrame != null) { + // get the rotor type + Rotor rotor = Rotor.getByModelData(TARDISTimeRotor.getRotorModelData(itemFrame)); + TARDISTimeRotor.setRotor(rotor, itemFrame); + } + } + } + } else { + plugin.getMessenger().sendStatus(player, "HANDBRAKE_OFF_ERR"); + } + } + if (state == 0) { + if (!tardis.isHandbrake_on()) { + // stop time rotor? + if (tardis.getRotor() != null) { + if (tardis.getRotor() == TARDISConstants.UUID_ZERO) { + TARDISSculkShrieker.stopRotor(id); + } else { + ItemFrame itemFrame = TARDISTimeRotor.getItemFrame(tardis.getRotor()); + if (itemFrame != null) { + // cancel the animation + int task = TARDISTimeRotor.ANIMATED_ROTORS.getOrDefault(itemFrame.getUniqueId(), -1); + plugin.getServer().getScheduler().cancelTask(task); + TARDISTimeRotor.setRotor(TARDISTimeRotor.getRotorOffModelData(itemFrame), itemFrame); + } + } + } + // if player is flying TARDIS exterior stop sound loop + Optional.ofNullable(plugin.getTrackerKeeper().getFlyingReturnLocation().get(uuid)).ifPresent(value -> { + player.stopAllSounds(); + if (value.getSound() != -1) { + plugin.getServer().getScheduler().cancelTask(value.getSound()); + } + plugin.getTrackerKeeper().getFlyingReturnLocation().remove(uuid); + }); + TARDISSounds.playTARDISSound(handbrake, "tardis_handbrake_engage"); + // TODO change the custom model data so the lever is on +// TARDISHandbrake.setLevers(block, true, true, handbrake.toString(), id, plugin); + // Check if it's at a recharge point + new TARDISArtronLevels(plugin).recharge(id); + Handbrake hb = new Handbrake(plugin); + if (!beac_on && !beacon.isEmpty()) { + hb.toggleBeacon(beacon, false); + } + hb.handleSensor(id); + // Remove energy from TARDIS and sets database + plugin.getMessenger().sendStatus(player, "HANDBRAKE_ON"); + if (plugin.getTrackerKeeper().getHasDestination().containsKey(id)) { + int amount = Math.round(plugin.getTrackerKeeper().getHasDestination().get(id).getCost() * spaceTimeThrottle.getArtronMultiplier()); + HashMap wheret = new HashMap<>(); + wheret.put("tardis_id", id); + plugin.getQueryFactory().alterEnergyLevel("tardis", -amount, wheret, player); + if (!uuid.equals(ownerUUID)) { + Player ptl = plugin.getServer().getPlayer(ownerUUID); + if (ptl != null) { + plugin.getMessenger().sendArtron(ptl, id, Math.abs(amount)); + } + } + } + plugin.getTrackerKeeper().getHasDestination().remove(id); + if (plugin.getTrackerKeeper().getHasRandomised().contains(id)) { + plugin.getTrackerKeeper().getHasRandomised().removeAll(Collections.singleton(id)); + } + // damage the circuit if configured + if (tcc != null && plugin.getConfig().getBoolean("circuits.damage") && plugin.getConfig().getInt("circuits.uses.materialisation") > 0) { + // decrement uses + int uses_left = tcc.getMaterialisationUses(); + new TARDISCircuitDamager(plugin, DiskCircuit.MATERIALISATION, uses_left, id, player).damage(); + } + HashMap set = new HashMap<>(); + set.put("handbrake_on", 1); + HashMap whereh = new HashMap<>(); + whereh.put("tardis_id", id); + plugin.getQueryFactory().doUpdate("tardis", set, whereh); + } else { + plugin.getMessenger().sendStatus(player, "HANDBRAKE_ON_ERR"); + } + } + } + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RebuildInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RebuildInteraction.java new file mode 100644 index 000000000..d6d343122 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RebuildInteraction.java @@ -0,0 +1,23 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.commands.tardis.TARDISRebuildCommand; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.entity.Player; + +public class RebuildInteraction { + + private final TARDIS plugin; + + public RebuildInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void process(int id, Player player) { + if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); + return; + } + new TARDISRebuildCommand(plugin).rebuildPreset(player); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerIntraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerIntraction.java new file mode 100644 index 000000000..7f1382fcf --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerIntraction.java @@ -0,0 +1,26 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.control.TARDISScanner; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; +import org.bukkit.entity.Player; + +import java.util.HashMap; + +public class ScannerIntraction { + + private final TARDIS plugin; + + public ScannerIntraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void process(int id, Player player) { + HashMap where = new HashMap<>(); + where.put("tardis_id", id); + ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); + if (rs.resultSet()) { + new TARDISScanner(plugin).scan(id, player, rs.getTardis().getRenderer(), rs.getTardis().getArtron_level()); + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java new file mode 100644 index 000000000..4326698f6 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java @@ -0,0 +1,42 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.ControlMonitor; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.TextDisplay; +import org.bukkit.util.Vector; + +public class ScreenInteraction { + + private final TARDIS plugin; + + public ScreenInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void display(Location location, boolean coords) { + // get the text display + TextDisplay display = getTextDisplay(location, coords); + if (display != null) { + display.setRotation(Location.normalizeYaw(300), -10f); + new ControlMonitor(plugin).update(3, display.getUniqueId(), coords); + } + } + + private TextDisplay getTextDisplay(Location location, boolean coords) { + TextDisplay textDisplay = null; + for (Entity entity : location.getWorld().getNearbyEntities(location, 1.0d, 1.0d, 1.0d, (e) -> e.getType() == EntityType.TEXT_DISPLAY)) { + textDisplay = (TextDisplay) entity; + break; + } + if (textDisplay == null) { + Location adjusted = location.clone(); + Vector vector = coords ? new Vector(0.0d, 0.5d, 0.35d) : new Vector(0.32d, 0.5d, -0.225d); + adjusted.add(vector); + textDisplay = (TextDisplay) location.getWorld().spawnEntity(adjusted, EntityType.TEXT_DISPLAY); + } + return textDisplay; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicConsoleRecharge.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicConsoleRecharge.java new file mode 100644 index 000000000..9e6b6577e --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicConsoleRecharge.java @@ -0,0 +1,118 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.TARDISConstants; +import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItemUtils; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetArtronLeveID; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import me.eccentric_nz.TARDIS.utility.TARDISSounds; +import org.bukkit.entity.*; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; +import org.bukkit.util.Transformation; +import org.joml.Vector3f; + +import java.util.HashMap; +import java.util.UUID; + +public class SonicConsoleRecharge implements Runnable { + + private final TARDIS plugin; + private final UUID display_uuid; + private final Interaction interaction; + private final int id; + private final Player player; + private final int full; + private final int amount; + private final Transformation transformation = new Transformation(TARDISConstants.VECTOR_ZERO, TARDISConstants.AXIS_ANGLE_ZERO, new Vector3f(0.33f, 0.33f, 0.33f), TARDISConstants.AXIS_ANGLE_ZERO); + private TextDisplay text; + private int task; + + public SonicConsoleRecharge(TARDIS plugin, UUID display_uuid, Interaction interaction, int id, Player player) { + this.plugin = plugin; + this.display_uuid = display_uuid; + this.interaction = interaction; + this.id = id; + this.player = player; + full = this.plugin.getConfig().getInt("sonic.charge_level"); + amount = (int) Math.ceil(this.plugin.getConfig().getDouble("sonic.charge_level") / this.plugin.getConfig().getDouble("sonic.charge_interval")); + } + + @Override + public void run() { + Entity entity = plugin.getServer().getEntity(display_uuid); + if (entity instanceof ItemDisplay display) { + ItemStack is = display.getItemStack(); + if (is == null || !is.hasItemMeta()) { + cancel(); + } + // check TARDIS has energy to recharge + ResultSetArtronLeveID rsa = new ResultSetArtronLeveID(plugin, id); + if (!rsa.resultset() || rsa.getArtronLevel() < amount) { + TARDISSounds.playTARDISSound(interaction.getLocation(), "charge_fail"); + plugin.getMessenger().send(player, TardisModule.TARDIS, "DOCK_ENERGY"); + cancel(); + } else { + // take some energy + HashMap where = new HashMap<>(); + where.put("tardis_id", id); + plugin.getQueryFactory().alterEnergyLevel("tardis", -amount, where, null); + } + ItemMeta im = is.getItemMeta(); + PersistentDataContainer pdc = im.getPersistentDataContainer(); + if (!pdc.has(plugin.getSonicChargeKey(), PersistentDataType.INTEGER)) { + pdc.set(plugin.getSonicChargeKey(), PersistentDataType.INTEGER, amount); + is.setItemMeta(im); + display.setItemStack(is); + setTextDisplay(interaction, amount); + } else { + int current = pdc.get(plugin.getSonicChargeKey(), PersistentDataType.INTEGER); + if (current < full - amount) { + int charge = current + amount; + pdc.set(plugin.getSonicChargeKey(), PersistentDataType.INTEGER, charge); + is.setItemMeta(im); + display.setItemStack(is); + setTextDisplay(interaction, charge); + } else { + pdc.set(plugin.getSonicChargeKey(), PersistentDataType.INTEGER, full); + is.setItemMeta(im); + display.setItemStack(is); + setTextDisplay(interaction, full); + // play charge done sound + TARDISSounds.playTARDISSound(interaction.getLocation(), "charge_done"); + cancel(); + } + } + } else { + cancel(); + } + } + + public void setTask(int task) { + this.task = task; + } + + private void cancel() { + plugin.getServer().getScheduler().cancelTask(task); + task = 0; + if (text != null) { + text.remove(); + } + } + + private void setTextDisplay(Interaction interaction, int amount) { + text = TARDISDisplayItemUtils.getText(interaction); + if (text == null) { + // spawn a new one + text = (TextDisplay) interaction.getLocation().getWorld().spawnEntity(interaction.getLocation().clone().add(0, 0.65d, 0), EntityType.TEXT_DISPLAY); + } + if (text.isValid()) { + text.setTransformation(transformation); + text.setSeeThrough(true); + text.setBillboard(Display.Billboard.VERTICAL); + text.setText("Sonic Dock: " + amount); + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicDockInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicDockInteraction.java new file mode 100644 index 000000000..f7c3a9bf4 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicDockInteraction.java @@ -0,0 +1,30 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.sonic.TARDISSonicDock; +import org.bukkit.Material; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class SonicDockInteraction { + + private final TARDIS plugin; + + public SonicDockInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void process(Player player, Interaction interaction, int id) { + ItemStack is = player.getInventory().getItemInMainHand(); + if (is.getType().equals(Material.BLAZE_ROD) && is.hasItemMeta()) { + ItemMeta im = player.getInventory().getItemInMainHand().getItemMeta(); + if (im.getDisplayName().endsWith("Sonic Screwdriver")) { + new TARDISSonicDock(plugin).dock(id, interaction, player, is); + } + } else if (is.getType() == Material.AIR) { + new TARDISSonicDock(plugin).undock(interaction, player); + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java new file mode 100644 index 000000000..56103ed8f --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java @@ -0,0 +1,38 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; +import me.eccentric_nz.TARDIS.enumeration.SpaceTimeThrottle; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.entity.Player; + +import java.util.HashMap; + +public class ThrottleInteraction { + private final TARDIS plugin; + + public ThrottleInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void process(Player player) { + String uuid = player.getUniqueId().toString(); + // get current throttle setting + ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, uuid); + if (rsp.resultSet()) { + int delay = rsp.getThrottle() - 1; + if (delay < 1) { + delay = 4; + } + String throttle = SpaceTimeThrottle.getByDelay().get(delay).toString(); + // update player prefs + HashMap wherer = new HashMap<>(); + wherer.put("uuid", uuid); + HashMap setr = new HashMap<>(); + setr.put("throttle", delay); + plugin.getQueryFactory().doUpdate("player_prefs", setr, wherer); + plugin.getMessenger().send(player, TardisModule.TARDIS, "THROTTLE", throttle); + // TODO set custom model data for throttle item display + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayItemUtils.java b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayItemUtils.java index b97360ef2..5891bc296 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayItemUtils.java +++ b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayItemUtils.java @@ -18,6 +18,7 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISConstants; +import me.eccentric_nz.TARDIS.utility.TARDISStaticUtils; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.data.Levelled; @@ -116,6 +117,39 @@ public static ItemDisplay get(Interaction interaction) { return null; } + /** + * Get an item display entity from an Interaction entity. Used for console sonic docks. + * + * @param interaction the Interaction entity to use as the search location + * @return The Item Display entity at the Interaction location or null if there isn't one + */ + public static ItemDisplay getSonic(Interaction interaction) { + for (Entity e : interaction.getWorld().getNearbyEntities(interaction.getBoundingBox().expand(0.75d), (d) -> d.getType() == EntityType.ITEM_DISPLAY)) { + if (e instanceof ItemDisplay display) { + ItemStack is = display.getItemStack(); + if (TARDISStaticUtils.isSonic(is)) { + return display; + } + } + } + return null; + } + + /** + * Get a text display entity from an Interaction entity. Used for console sonic docks. + * + * @param interaction the Interaction entity to use as the search location + * @return The Text Display entity at the Interaction location or null if there isn't one + */ + public static TextDisplay getText(Interaction interaction) { + for (Entity e : interaction.getWorld().getNearbyEntities(interaction.getBoundingBox().expand(0.1d), (d) -> d.getType() == EntityType.TEXT_DISPLAY)) { + if (e instanceof TextDisplay display) { + return display; + } + } + return null; + } + public static Interaction getInteraction(Location location) { while (!location.getChunk().isLoaded()) { location.getChunk().load(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetPlayerPrefs.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetPlayerPrefs.java index 680ab877c..dbc8c8c94 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetPlayerPrefs.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetPlayerPrefs.java @@ -86,11 +86,11 @@ public class ResultSetPlayerPrefs { * Creates a class instance that can be used to retrieve an SQL ResultSet from the player_prefs table. * * @param plugin an instance of the main class. - * @param where the UUID to select the preferences for. + * @param uuid the UUID to select the preferences for. */ - public ResultSetPlayerPrefs(TARDIS plugin, String where) { + public ResultSetPlayerPrefs(TARDIS plugin, String uuid) { this.plugin = plugin; - this.where = where; + this.where = uuid; prefix = this.plugin.getPrefix(); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/enumeration/FlightMode.java b/src/main/java/me/eccentric_nz/TARDIS/enumeration/FlightMode.java index 2c986a6f7..8c79ed07f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/enumeration/FlightMode.java +++ b/src/main/java/me/eccentric_nz/TARDIS/enumeration/FlightMode.java @@ -22,7 +22,8 @@ public enum FlightMode { NORMAL(1), REGULATOR(2), - MANUAL(3); + MANUAL(3), + EXTERIOR(4); private static final HashMap byMode = new HashMap<>(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/enumeration/SpaceTimeThrottle.java b/src/main/java/me/eccentric_nz/TARDIS/enumeration/SpaceTimeThrottle.java index 85e73c37c..2294102ec 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/enumeration/SpaceTimeThrottle.java +++ b/src/main/java/me/eccentric_nz/TARDIS/enumeration/SpaceTimeThrottle.java @@ -20,7 +20,7 @@ /** * The Space Time Throttle controls the effective "speed" of the TARDIS by - * altering the "length" of the route (and thus shorten the perceived travel + * altering the "length" of the route (and thus shortening the perceived travel * time) through the Time Vortex. */ public enum SpaceTimeThrottle { diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISExteriorFlight.java b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISExteriorFlight.java index d271588a6..bdfb4803a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISExteriorFlight.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISExteriorFlight.java @@ -122,7 +122,7 @@ public void stopFlying(Player player, ArmorStand stand) { }); } - void startFlying(Player player, int id, Block block, Location current, boolean beac_on, String beacon, boolean pandorica) { + public void startFlying(Player player, int id, Block block, Location current, boolean beac_on, String beacon, boolean pandorica) { // get the TARDIS's current location ResultSetCurrentFromId rsc = new ResultSetCurrentFromId(plugin, id); if (!rsc.resultSet()) { @@ -131,11 +131,13 @@ void startFlying(Player player, int id, Block block, Location current, boolean b } Location interior = player.getLocation(); // set the handbrake - TARDISHandbrake.setLevers(block, false, true, block.getLocation().toString(), id, plugin); + if (block != null) { + TARDISHandbrake.setLevers(block, false, true, block.getLocation().toString(), id, plugin); + TARDISSounds.playTARDISSound(block.getLocation(), "tardis_handbrake_release"); + } if (plugin.getConfig().getBoolean("circuits.damage")) { plugin.getTrackerKeeper().getHasNotClickedHandbrake().remove(id); } - TARDISSounds.playTARDISSound(block.getLocation(), "tardis_handbrake_release"); Handbrake hb = new Handbrake(plugin); if (!beac_on && !beacon.isEmpty()) { hb.toggleBeacon(beacon, true); diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISTakeoff.java b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISTakeoff.java index 4b94393f6..9750f271c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISTakeoff.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISTakeoff.java @@ -44,8 +44,10 @@ public TARDISTakeoff(TARDIS plugin) { } public void run(int id, Block block, Location handbrake, Player player, boolean beac_on, String beacon, boolean bar, SpaceTimeThrottle spaceTimeThrottle) { - // set the handbrake - TARDISHandbrake.setLevers(block, false, true, handbrake.toString(), id, plugin); + if (block != null) { + // set the handbrake + TARDISHandbrake.setLevers(block, false, true, handbrake.toString(), id, plugin); + } if (plugin.getConfig().getBoolean("circuits.damage")) { plugin.getTrackerKeeper().getHasNotClickedHandbrake().remove(id); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java index 8596cfb84..8b3872e69 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java @@ -6,6 +6,7 @@ import me.eccentric_nz.TARDIS.api.Parameters; import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; import me.eccentric_nz.TARDIS.builders.TARDISSculkShrieker; +import me.eccentric_nz.TARDIS.console.interaction.SonicConsoleRecharge; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItemUtils; import me.eccentric_nz.TARDIS.database.data.Tardis; import me.eccentric_nz.TARDIS.database.resultset.*; @@ -29,6 +30,7 @@ import org.bukkit.entity.*; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.util.Vector; import java.util.Collections; import java.util.HashMap; @@ -42,26 +44,54 @@ public TARDISSonicDock(TARDIS plugin) { this.plugin = plugin; } + public void dock(int id, Interaction interaction, Player player, ItemStack sonic) { + // check for existing display item + if (TARDISDisplayItemUtils.getSonic(interaction) != null) { + return; + } + ItemDisplay display = doDocking(sonic, interaction.getLocation(), new Vector(0.05d, 0.75d, -0.05d), player, id); + display.setRotation(0.0f, -15.0f); + if (plugin.getConfig().getBoolean("sonic.charge") || plugin.getDifficulty() == Difficulty.HARD) { + long delay = plugin.getConfig().getLong("sonic.charge_level") / plugin.getConfig().getLong("sonic.charge_interval"); + SonicConsoleRecharge recharge = new SonicConsoleRecharge(plugin, display.getUniqueId(), interaction, id, player); + int task = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, recharge, 1L, delay); + recharge.setTask(task); + } + } + public void dock(int id, ItemFrame frame, Player player, ItemStack sonic) { Block block = frame.getLocation().getBlock(); // check for existing display item if (TARDISDisplayItemUtils.get(block) != null) { return; } + ItemDisplay display = doDocking(sonic, block.getLocation(), new Vector(0.5d, 0.5d, 0.5d), player, id); + // change the dock model + updateModel(frame, 1001, false); + // start charging + if (plugin.getConfig().getBoolean("sonic.charge") || plugin.getDifficulty() == Difficulty.HARD) { + long delay = plugin.getConfig().getLong("sonic.charge_level") / plugin.getConfig().getLong("sonic.charge_interval"); + SonicRecharge recharge = new SonicRecharge(plugin, display.getUniqueId(), frame, id, player); + int task = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, recharge, 1L, delay); + recharge.setTask(task); + } + } + + private ItemDisplay doDocking(ItemStack sonic, Location location, Vector vector, Player player, int id) { // remove enchantments if any sonic.removeEnchantment(Enchantment.DURABILITY); // get sonic uuid UUID uuid = sonic.getItemMeta().getPersistentDataContainer().get(plugin.getSonicUuidKey(), plugin.getPersistentDataTypeUUID()); // set item display - ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(block.getLocation().clone().add(0.5d, 0.5d, 0.5d), EntityType.ITEM_DISPLAY); + ItemDisplay display = (ItemDisplay) location.getWorld().spawnEntity(location.clone().add(vector), EntityType.ITEM_DISPLAY); display.setItemStack(sonic); display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.FIXED); display.setBillboard(Display.Billboard.FIXED); display.setInvulnerable(true); // remove item from hand player.getInventory().setItemInMainHand(null); - // change the dock model - updateModel(frame, 1001, false); +// // change the dock model +// updateModel(frame, 1001, false); if (uuid != null) { // get last scan coordinates ResultSetSonicLocation rssc = new ResultSetSonicLocation(plugin, uuid); @@ -71,39 +101,39 @@ public void dock(int id, ItemFrame frame, Player player, ItemStack sonic) { if (dest != null) { if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); - return; + return display; } if (plugin.getTrackerKeeper().getDispersedTARDII().contains(id)) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "NOT_WHILE_DISPERSED"); - return; + return display; } if (plugin.getTrackerKeeper().getInVortex().contains(id) || plugin.getTrackerKeeper().getMaterialising().contains(id) || plugin.getTrackerKeeper().getDematerialising().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_WHILE_MAT"); - return; + return display; } if (!plugin.getConfig().getBoolean("travel.include_default_world") && plugin.getConfig().getBoolean("creation.default_world") && dest.getWorld().getName().equals(plugin.getConfig().getString("creation.default_world_name"))) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_WORLD_TRAVEL"); - return; + return display; } if (!plugin.getPluginRespect().getRespect(dest, new Parameters(player, Flag.getDefaultFlags()))) { - return; + return display; } if (TARDISPermission.hasPermission(player, "tardis.exile") && plugin.getConfig().getBoolean("travel.exile")) { String areaPerm = plugin.getTardisArea().getExileArea(player); if (plugin.getTardisArea().areaCheckInExile(areaPerm, dest)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "EXILE_NO_TRAVEL"); - return; + return display; } } if (plugin.getTardisArea().isInExistingArea(dest)) { plugin.getMessenger().sendColouredCommand(player, "AREA_NO_SONIC", "/tardistravel area [area name]", plugin); - return; + return display; } // check the world is not excluded String world = dest.getWorld().getName(); if (!plugin.getPlanetsConfig().getBoolean("planets." + world + ".time_travel")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_PB_IN_WORLD"); - return; + return display; } HashMap where = new HashMap<>(); where.put("tardis_id", id); @@ -112,7 +142,7 @@ public void dock(int id, ItemFrame frame, Player player, ItemStack sonic) { Tardis tardis = rs.getTardis(); if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); - return; + return display; } TARDISCircuitChecker tcc = null; if (!plugin.getDifficulty().equals(Difficulty.EASY) && !plugin.getUtils().inGracePeriod(player, true)) { @@ -121,7 +151,7 @@ public void dock(int id, ItemFrame frame, Player player, ItemStack sonic) { } if (tcc != null && !tcc.hasMaterialisation()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_MAT_CIRCUIT"); - return; + return display; } COMPASS player_d = COMPASS.valueOf(TARDISStaticUtils.getPlayersDirection(player, false)); int[] start_loc = TARDISTimeTravel.getStartLocation(dest, player_d); @@ -135,13 +165,13 @@ public void dock(int id, ItemFrame frame, Player player, ItemStack sonic) { } if (count > 0) { plugin.getMessenger().send(player, TardisModule.TARDIS, "WOULD_GRIEF_BLOCKS"); - return; + return display; } SpaceTimeThrottle spaceTimeThrottle = new ResultSetThrottle(plugin).getSpeed(player.getUniqueId().toString()); int ch = Math.round(plugin.getArtronConfig().getInt("comehere") * spaceTimeThrottle.getArtronMultiplier()); if (tardis.getArtron_level() < ch) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_ENOUGH_ENERGY"); - return; + return display; } // set next location HashMap tid = new HashMap<>(); @@ -174,7 +204,7 @@ public void dock(int id, ItemFrame frame, Player player, ItemStack sonic) { plugin.getTrackerKeeper().getHasClickedHandbrake().add(id); // give them 30 seconds to close the door plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> plugin.getTrackerKeeper().getHasClickedHandbrake().removeAll(Collections.singleton(id)), 600L); - return; + return display; } ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, player.getUniqueId().toString()); if (rsp.resultSet()) { @@ -208,13 +238,23 @@ public void dock(int id, ItemFrame frame, Player player, ItemStack sonic) { } else { plugin.getMessenger().send(player, TardisModule.TARDIS, "DOCK_NOT_SCANNED"); } - // start charging - if (plugin.getConfig().getBoolean("sonic.charge") || plugin.getDifficulty() == Difficulty.HARD) { - long delay = plugin.getConfig().getLong("sonic.charge_level") / plugin.getConfig().getLong("sonic.charge_interval"); - SonicRecharge recharge = new SonicRecharge(plugin, display.getUniqueId(), frame, id, player); - int task = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, recharge, 1L, delay); - recharge.setTask(task); +// // start charging +// if (plugin.getConfig().getBoolean("sonic.charge") || plugin.getDifficulty() == Difficulty.HARD) { +// long delay = plugin.getConfig().getLong("sonic.charge_level") / plugin.getConfig().getLong("sonic.charge_interval"); +// SonicRecharge recharge = new SonicRecharge(plugin, display.getUniqueId(), frame, id, player); +// int task = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, recharge, 1L, delay); +// recharge.setTask(task); +// } + return display; + } + + public void undock(Interaction interaction, Player player) { + // check for existing display item + ItemDisplay display = TARDISDisplayItemUtils.getSonic(interaction); + if (display == null) { + return; } + doUndock(display, player); } public void undock(ItemFrame frame, Player player) { @@ -223,6 +263,12 @@ public void undock(ItemFrame frame, Player player) { if (display == null) { return; } + doUndock(display, player); + // change the dock model + updateModel(frame, 1000, true); + } + + private void doUndock(ItemDisplay display, Player player) { // get the itemstack ItemStack sonic = display.getItemStack(); // set the charge level in lore @@ -233,8 +279,6 @@ public void undock(ItemFrame frame, Player player) { player.getInventory().addItem(sonic); } display.remove(); - // change the dock model - updateModel(frame, 1000, true); } private void updateModel(ItemFrame frame, int cmd, boolean setDisplay) { From bb81dee13db68f61151f11148bb2b6b78bfb8509 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Wed, 3 Apr 2024 16:05:30 +1300 Subject: [PATCH 10/96] More on interactions --- .../interaction/FlightModeInteraction.java | 26 ++++++++++--------- .../interaction/HandbrakeInteraction.java | 16 +++++++++++- .../TARDIS/utility/Handbrake.java | 6 +++++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java index 9ab72aa9a..f3536c40a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java @@ -21,18 +21,20 @@ public void process(Player player) { String uuid = player.getUniqueId().toString(); // get current throttle setting ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, uuid); - int mode = rsp.getFlightMode() + 1; - if (mode > 4) { - mode = 1; + if (rsp.resultSet()) { + int mode = rsp.getFlightMode() + 1; + if (mode > 4) { + mode = 1; + } + FlightMode fm = FlightMode.getByMode().get(mode); + plugin.getMessenger().announceRepeater(player, TARDISStringUtils.capitalise(fm.toString())); + HashMap setf = new HashMap<>(); + setf.put("flying_mode", mode); + HashMap where = new HashMap<>(); + where.put("uuid", player.getUniqueId().toString()); + TARDIS.plugin.getQueryFactory().doUpdate("player_prefs", setf, where); + plugin.getMessenger().send(player, TardisModule.TARDIS, "FLIGHT_SAVED"); + // TODO set custom model data for relativity differentiator item display } - FlightMode fm = FlightMode.getByMode().get(mode); - plugin.getMessenger().announceRepeater(player, TARDISStringUtils.capitalise(fm.toString())); - HashMap setf = new HashMap<>(); - setf.put("flying_mode", mode); - HashMap where = new HashMap<>(); - where.put("uuid", player.getUniqueId().toString()); - TARDIS.plugin.getQueryFactory().doUpdate("player_prefs", setf, where); - plugin.getMessenger().send(player, TardisModule.TARDIS, "FLIGHT_SAVED"); - // TODO set custom model data for relativity differentiator item display } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java index aab82547a..a18d0fd70 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java @@ -110,7 +110,7 @@ public void process(int id, int state, Player player, Location handbrake) { return; } // check the state of the Relativity Differentiator - if (check.isRelativityDifferentiated(id) && TARDISPermission.hasPermission(player, "tardis.fly") && preset.usesArmourStand() && !player.isSneaking()) { + if (check.isFlightModeExterior(uuid.toString()) && TARDISPermission.hasPermission(player, "tardis.fly") && preset.usesArmourStand() && !player.isSneaking()) { ResultSetCurrentFromId rsc = new ResultSetCurrentFromId(plugin, id); if (!rsc.resultSet()) { plugin.debug("No current location"); @@ -148,6 +148,14 @@ public void process(int id, int state, Player player, Location handbrake) { } } } + // update handbrake state + HashMap seti = new HashMap<>(); + seti.put("state", 0); + HashMap whereinteraction = new HashMap<>(); + whereinteraction.put("tardis_id", id); + whereinteraction.put("control", "HANDBRAKE"); + plugin.getQueryFactory().doUpdate("interactions", seti, whereinteraction); + } else { plugin.getMessenger().sendStatus(player, "HANDBRAKE_OFF_ERR"); } @@ -215,6 +223,12 @@ public void process(int id, int state, Player player, Location handbrake) { HashMap whereh = new HashMap<>(); whereh.put("tardis_id", id); plugin.getQueryFactory().doUpdate("tardis", set, whereh); + HashMap seti = new HashMap<>(); + seti.put("state", 1); + HashMap whereinteraction = new HashMap<>(); + whereinteraction.put("tardis_id", id); + whereinteraction.put("control", "HANDBRAKE"); + plugin.getQueryFactory().doUpdate("interactions", seti, whereinteraction); } else { plugin.getMessenger().sendStatus(player, "HANDBRAKE_ON_ERR"); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/utility/Handbrake.java b/src/main/java/me/eccentric_nz/TARDIS/utility/Handbrake.java index 20cd138c8..683442d1e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/utility/Handbrake.java +++ b/src/main/java/me/eccentric_nz/TARDIS/utility/Handbrake.java @@ -5,6 +5,7 @@ import me.eccentric_nz.TARDIS.control.SensorToggle; import me.eccentric_nz.TARDIS.database.resultset.ResultSetControls; import me.eccentric_nz.TARDIS.database.resultset.ResultSetDoors; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; import me.eccentric_nz.TARDIS.database.resultset.ResultSetSensors; import org.bukkit.Material; import org.bukkit.block.Block; @@ -40,6 +41,11 @@ public boolean isRelativityDifferentiated(int id) { return false; } + public boolean isFlightModeExterior(String uuid) { + ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, uuid); + return (rsp.resultSet()) && rsp.getFlightMode() == 4; + } + public boolean isDoorOpen(int id) { HashMap where = new HashMap<>(); where.put("tardis_id", id); From 5e1973e36e1dee5f7b36bee0a024e437d9d939cb Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Wed, 3 Apr 2024 22:06:30 +1300 Subject: [PATCH 11/96] Yeah, we actually need to use the correct tardis_id... --- .../TARDIS/commands/dev/TARDISDisplayItemCommand.java | 6 +++++- .../java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java | 4 ++-- .../TARDIS/console/ConsoleInteractionListener.java | 2 +- .../TARDIS/console/interaction/ScreenInteraction.java | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java index a8752e33b..2fd1fdd6d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java @@ -233,7 +233,11 @@ public boolean display(Player player, String[] args) { return true; } case "console" -> { - new ConsoleBuilder(plugin).create(block, 1); + // get TARDIS id + ResultSetTardisID rs = new ResultSetTardisID(plugin); + if (rs.fromUUID(player.getUniqueId().toString())) { + new ConsoleBuilder(plugin).create(block, 1, rs.getTardis_id()); + } return true; } default -> { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index d7e79d7b2..cac9da2cf 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -22,7 +22,7 @@ public ConsoleBuilder(TARDIS plugin) { this.plugin = plugin; } - public void create(Block block, int type) { + public void create(Block block, int type, int id) { Block up = block.getRelative(BlockFace.UP); for (int i = 0; i < 6; i++) { ItemStack shard = new ItemStack(Material.AMETHYST_SHARD); @@ -67,7 +67,7 @@ public void create(Block block, int type) { interaction.setPersistent(true); interaction.setInvulnerable(true); HashMap data = new HashMap<>(); - data.put("tardis_id", 3); + data.put("tardis_id", id); data.put("uuid", interaction.getUniqueId()); data.put("control", i.toString()); data.put("state", 0); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index ad60fd719..914ddaec1 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -27,7 +27,7 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { if (rsi.resultSet()) { ConsoleInteraction ci = rsi.getControl(); switch (ci) { - case SCREEN_LEFT, SCREEN_RIGHT -> new ScreenInteraction(plugin).display(interaction.getLocation(), ci == ConsoleInteraction.SCREEN_RIGHT); + case SCREEN_LEFT, SCREEN_RIGHT -> new ScreenInteraction(plugin).display(rsi.getTardis_id(), interaction.getLocation(), ci == ConsoleInteraction.SCREEN_RIGHT); case SCANNER -> new ScannerIntraction(plugin).process(rsi.getTardis_id(), event.getPlayer()); case ARTRON -> plugin.getMessenger().sendArtron(event.getPlayer(), rsi.getTardis_id(), 0); case REBUILD -> new RebuildInteraction(plugin).process(rsi.getTardis_id(), event.getPlayer()); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java index 4326698f6..7b6d81370 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java @@ -16,12 +16,12 @@ public ScreenInteraction(TARDIS plugin) { this.plugin = plugin; } - public void display(Location location, boolean coords) { + public void display(int id, Location location, boolean coords) { // get the text display TextDisplay display = getTextDisplay(location, coords); if (display != null) { display.setRotation(Location.normalizeYaw(300), -10f); - new ControlMonitor(plugin).update(3, display.getUniqueId(), coords); + new ControlMonitor(plugin).update(id, display.getUniqueId(), coords); } } From 387e2fc3ed34c5f1c60a9b14fd3049431e21fb63 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Thu, 4 Apr 2024 22:45:53 +1300 Subject: [PATCH 12/96] Prepare for more interactions --- .../console/ConsoleInteractionListener.java | 31 ++++++++++++++++--- .../interaction/DirectionInteraction.java | 16 ++++++++++ .../interaction/DoorToggleInteraction.java | 16 ++++++++++ .../interaction/FastReturnInteraction.java | 16 ++++++++++ .../HelmicRegulatorInteraction.java | 16 ++++++++++ .../interaction/LampLevelInteraction.java | 16 ++++++++++ .../interaction/LightLevelInteraction.java | 16 ++++++++++ .../interaction/LightSwitchInteraction.java | 16 ++++++++++ .../interaction/MultiplierInteraction.java | 16 ++++++++++ .../interaction/RandomiserInteraction.java | 16 ++++++++++ .../TelepathicCircuitInteraction.java | 16 ++++++++++ .../interaction/WayPointInteraction.java | 16 ++++++++++ .../console/interaction/WorldInteraction.java | 16 ++++++++++ .../console/interaction/XInteraction.java | 16 ++++++++++ .../console/interaction/ZInteraction.java | 16 ++++++++++ 15 files changed, 251 insertions(+), 4 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/XInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/ZInteraction.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index 914ddaec1..a24f697ba 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -27,14 +27,37 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { if (rsi.resultSet()) { ConsoleInteraction ci = rsi.getControl(); switch (ci) { + // section zero + case HANDBRAKE -> new HandbrakeInteraction(plugin).process(rsi.getTardis_id(), rsi.getState(), event.getPlayer(), interaction.getLocation()); + case THROTTLE -> new ThrottleInteraction(plugin).process(event.getPlayer()); + case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(event.getPlayer()); + // section one + case WORLD -> new WorldInteraction(plugin).selectWorld(); + case MULTIPLIER -> new MultiplierInteraction(plugin).setRange(); + case X -> new XInteraction(plugin).setRange(); + case Z -> new ZInteraction(plugin).setRange(); + case HELMIC_REGULATOR -> { + // TODO add config options to planets.yml - helmic_regulator: [1-8|-1] + new HelmicRegulatorInteraction(plugin).selectWorld(); + } + // section two + case RANDOMISER -> new RandomiserInteraction(plugin).generateDestination(); + case WAYPOINT_SELECTOR -> new WayPointInteraction(plugin).openSaveGUI(); + case FAST_RETURN -> new FastReturnInteraction(plugin).setBack(); + case TELEPATHIC_CIRCUIT -> new TelepathicCircuitInteraction(plugin).openGUI(); + // section three + case SONIC_DOCK -> new SonicDockInteraction(plugin).process(event.getPlayer(), interaction, rsi.getTardis_id()); + case DIRECTION -> new DirectionInteraction(plugin).rotate(); + // section four + case LIGHT_SWITCH -> new LightSwitchInteraction(plugin).toggle(); + case INTERIOR_LIGHT_LEVEL_SWITCH -> new LightLevelInteraction(plugin).setInterior(); + case EXTERIOR_LAMP_LEVEL_SWITCH -> new LampLevelInteraction(plugin).setExterior(); + case DOOR_TOGGLE -> new DoorToggleInteraction(plugin).toggle(); + // section five case SCREEN_LEFT, SCREEN_RIGHT -> new ScreenInteraction(plugin).display(rsi.getTardis_id(), interaction.getLocation(), ci == ConsoleInteraction.SCREEN_RIGHT); case SCANNER -> new ScannerIntraction(plugin).process(rsi.getTardis_id(), event.getPlayer()); case ARTRON -> plugin.getMessenger().sendArtron(event.getPlayer(), rsi.getTardis_id(), 0); case REBUILD -> new RebuildInteraction(plugin).process(rsi.getTardis_id(), event.getPlayer()); - case SONIC_DOCK -> new SonicDockInteraction(plugin).process(event.getPlayer(), interaction, rsi.getTardis_id()); - case HANDBRAKE -> new HandbrakeInteraction(plugin).process(rsi.getTardis_id(), rsi.getState(), event.getPlayer(), interaction.getLocation()); - case THROTTLE -> new ThrottleInteraction(plugin).process(event.getPlayer()); - case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(event.getPlayer()); default -> plugin.getMessenger().announceRepeater(event.getPlayer(), rsi.getControl().getAlternateName()); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java new file mode 100644 index 000000000..667a0f3ba --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class DirectionInteraction { + + private final TARDIS plugin; + + public DirectionInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void rotate() { + + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java new file mode 100644 index 000000000..7932b872f --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class DoorToggleInteraction { + + private final TARDIS plugin; + + public DoorToggleInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void toggle() { + + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java new file mode 100644 index 000000000..abbce0078 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class FastReturnInteraction { + + private final TARDIS plugin; + + public FastReturnInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void setBack() { + + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java new file mode 100644 index 000000000..9ba9d9759 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class HelmicRegulatorInteraction { + + private final TARDIS plugin; + + public HelmicRegulatorInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void selectWorld() { + + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java new file mode 100644 index 000000000..741a186a5 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class LampLevelInteraction { + + private final TARDIS plugin; + + public LampLevelInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void setExterior() { + + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java new file mode 100644 index 000000000..bf77615e8 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class LightLevelInteraction { + + private final TARDIS plugin; + + public LightLevelInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void setInterior() { + + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java new file mode 100644 index 000000000..40c2336c2 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class LightSwitchInteraction { + + private final TARDIS plugin; + + public LightSwitchInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void toggle() { + + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierInteraction.java new file mode 100644 index 000000000..6f761ca89 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class MultiplierInteraction { + + private final TARDIS plugin; + + public MultiplierInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void setRange() { + + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java new file mode 100644 index 000000000..33d3f2c09 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class RandomiserInteraction { + + private final TARDIS plugin; + + public RandomiserInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void generateDestination() { + + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java new file mode 100644 index 000000000..5332cb9b2 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class TelepathicCircuitInteraction { + + private final TARDIS plugin; + + public TelepathicCircuitInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void openGUI() { + + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java new file mode 100644 index 000000000..60b7c76a0 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class WayPointInteraction { + + private final TARDIS plugin; + + public WayPointInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void openSaveGUI() { + + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java new file mode 100644 index 000000000..58180ac82 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class WorldInteraction { + + private final TARDIS plugin; + + public WorldInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void selectWorld() { + + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/XInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/XInteraction.java new file mode 100644 index 000000000..0fce6fdd1 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/XInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class XInteraction { + + private final TARDIS plugin; + + public XInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void setRange() { + + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ZInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ZInteraction.java new file mode 100644 index 000000000..1a272c215 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ZInteraction.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; + +public class ZInteraction { + + private final TARDIS plugin; + + public ZInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void setRange() { + + } +} From 962d556af540401a1cc2041dfbd99f58d860e897 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Thu, 4 Apr 2024 23:00:19 +1300 Subject: [PATCH 13/96] Refactor some Tardis class getter names --- .../TARDIS/ARS/TARDISARSRunnable.java | 4 ++-- .../advanced/TARDISConsoleSwitchListener.java | 4 ++-- .../advanced/TARDISDiskWriterCommand.java | 2 +- .../me/eccentric_nz/TARDIS/api/TARDII.java | 6 +++--- .../TARDIS/api/event/TARDISRoomGrowEvent.java | 2 +- .../artron/TARDISArtronCapacitorListener.java | 8 ++++---- .../TARDIS/artron/TARDISBeaconToggler.java | 2 +- .../artron/TARDISCondenserListener.java | 10 +++++----- .../TARDIS/artron/TARDISCreeperChecker.java | 2 +- .../commands/TARDISCallRequestCommand.java | 11 ++++++----- .../commands/admin/TARDISAbandonLister.java | 4 ++-- .../commands/admin/TARDISDeleteCommand.java | 2 +- .../commands/admin/TARDISEnterCommand.java | 2 +- .../commands/admin/TARDISListCommand.java | 6 +++--- .../dev/TARDISInteractionCommand.java | 2 +- .../commands/give/TARDISGiveCommand.java | 4 ++-- .../handles/TARDISHandlesLandCommand.java | 2 +- .../handles/TARDISHandlesTakeoffCommand.java | 11 ++++++----- .../handles/TARDISHandlesTeleportCommand.java | 11 ++++++----- .../preferences/TARDISBuildCommand.java | 2 +- .../preferences/TARDISIsomorphicCommand.java | 6 +++--- .../preferences/TARDISJunkPreference.java | 2 +- .../preferences/TARDISPrefsMenuInventory.java | 2 +- .../preferences/TARDISPrefsMenuListener.java | 2 +- .../remote/TARDISRemoteComehereCommand.java | 2 +- .../commands/remote/TARDISRemoteCommands.java | 12 ++++++------ .../TARDIS/commands/sudo/SudoAssemble.java | 2 +- .../TARDIS/commands/sudo/SudoRepair.java | 7 ++++--- .../TARDIS/commands/sudo/SudoUpdate.java | 4 ++-- .../tardis/TARDISAddCompanionCommand.java | 2 +- .../commands/tardis/TARDISArchiveCommand.java | 4 ++-- .../tardis/TARDISColouriseCommand.java | 2 +- .../tardis/TARDISComehereCommand.java | 6 +++--- .../tardis/TARDISDirectionCommand.java | 6 +++--- .../TARDISEmergencyProgrammeCommand.java | 2 +- .../commands/tardis/TARDISHideCommand.java | 13 +++++++------ .../commands/tardis/TARDISLampsCommand.java | 2 +- .../tardis/TARDISMakeHerBlueCommand.java | 8 ++++---- .../commands/tardis/TARDISRebuildCommand.java | 8 ++++---- .../tardis/TARDISRemoveCompanionCommand.java | 2 +- .../commands/tardis/TARDISRoomCommand.java | 15 ++++++++------- .../tardis/TARDISSaveLocationCommand.java | 2 +- .../commands/tardis/TARDISUpdateCommand.java | 6 +++--- .../commands/tardis/TARDISUpgradeCommand.java | 7 ++++--- .../commands/travel/TARDISTravelCommands.java | 8 ++++---- .../commands/utils/TARDISWeatherListener.java | 10 +++++----- .../TARDISCompanionAddGUIListener.java | 4 ++-- .../TARDISCompanionGUIListener.java | 2 +- .../interaction/HandbrakeInteraction.java | 10 +++++----- .../interaction/ScannerIntraction.java | 2 +- .../control/TARDISControlInventory.java | 10 +++++----- .../TARDIS/control/TARDISControlListener.java | 16 ++++++++-------- .../control/TARDISControlMenuListener.java | 18 +++++++++--------- .../TARDIS/control/actions/ARSAction.java | 4 ++-- .../control/actions/FastReturnAction.java | 4 ++-- .../TARDIS/control/actions/RandomAction.java | 4 ++-- .../control/actions/TerminalAction.java | 4 ++-- .../control/actions/ZeroRoomAction.java | 2 +- .../TARDISDisplayBlockConverter.java | 2 +- .../TARDISDisplayBlockListener.java | 2 +- .../TARDIS/database/data/Tardis.java | 19 ++++++++++--------- .../desktop/TARDISArchiveMenuListener.java | 2 +- .../TARDIS/desktop/TARDISDelavafier.java | 2 +- .../desktop/TARDISFullThemeRunnable.java | 4 ++-- .../TARDIS/desktop/TARDISRepair.java | 4 ++-- .../TARDIS/desktop/TARDISThemeProcessor.java | 2 +- .../desktop/TARDISThemeRepairRunnable.java | 4 ++-- .../desktop/TARDISUpgradeBlockScanner.java | 2 +- .../desktop/TARDISWallFloorRunnable.java | 2 +- .../TARDIS/destroyers/TARDISExterminator.java | 2 +- .../TARDIS/doors/DisplayItemDoorMover.java | 6 +++--- .../TARDIS/doors/DisplayItemDoorToggler.java | 2 +- .../TARDIS/doors/DoorToggleAction.java | 8 ++++---- .../flight/TARDISHandbrakeListener.java | 10 +++++----- .../floodgate/FloodgateAddCompanionsForm.java | 2 +- .../floodgate/FloodgateCompanionsForm.java | 2 +- .../floodgate/FloodgateControlForm.java | 16 ++++++++-------- .../floodgate/FloodgateWeatherForm.java | 10 +++++----- .../TARDIS/hads/TARDISHostileAction.java | 2 +- .../handles/TARDISHandlesProcessor.java | 14 +++++++------- .../TARDIS/handles/TARDISHandlesRequest.java | 10 +++++----- .../TARDIS/listeners/TARDISBindListener.java | 6 +++--- .../TARDIS/listeners/TARDISJoinListener.java | 2 +- .../listeners/TARDISLightningListener.java | 7 ++++--- .../listeners/TARDISMinecartListener.java | 2 +- .../TARDIS/listeners/TARDISQuitListener.java | 10 +++++----- .../listeners/TARDISRemoteKeyListener.java | 4 ++-- .../listeners/TARDISStattenheimListener.java | 10 +++++----- .../TARDISTimeLordDeathListener.java | 8 ++++---- .../TARDISDirectionFrameListener.java | 2 +- .../TARDIS/messaging/AdventureComponents.java | 4 ++-- .../TARDIS/messaging/SpigotComponents.java | 4 ++-- .../TARDIS/messaging/TARDISLister.java | 2 +- .../TARDIS/move/TARDISAnyoneDoorListener.java | 10 +++++----- .../TARDIS/move/TARDISDoorClickListener.java | 14 +++++++------- .../TARDIS/move/TARDISDoorWalkListener.java | 14 +++++++------- .../TARDIS/move/TARDISMonsterRunnable.java | 6 ++++-- .../TARDIS/move/TARDISMoveListener.java | 4 ++-- .../TARDISPlaceholderExpansion.java | 2 +- .../TARDIS/siegemode/TARDISSiegeListener.java | 4 ++-- .../TARDIS/siegemode/TARDISSiegeMode.java | 4 ++-- .../TARDIS/siegemode/TARDISSiegeRunnable.java | 7 ++++--- .../TARDISSiegeWallFloorRunnable.java | 2 +- .../TARDIS/sonic/TARDISSonicDock.java | 4 ++-- .../sonic/actions/TARDISSonicAdmin.java | 9 +++++---- .../travel/TARDISMalfunctionExplosion.java | 2 +- .../TARDIS/travel/TARDISRescue.java | 6 +++--- .../TARDIS/update/TARDISUpdateListener.java | 8 ++++---- .../update/TARDISUpdateableChecker.java | 8 ++++---- .../utility/TARDISJunkPlayerPersister.java | 2 +- .../TARDIS/utility/TARDISStaticUtils.java | 2 +- todo.md | 5 +++-- 112 files changed, 318 insertions(+), 304 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSRunnable.java index f65b1c1d0..c862d7b89 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSRunnable.java @@ -67,11 +67,11 @@ public void run() { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - plugin.getTrackerKeeper().getIsGrowingRooms().add(tardis.getTardis_id()); + plugin.getTrackerKeeper().getIsGrowingRooms().add(tardis.getTardisId()); World w = TARDISStaticLocationGetters.getWorldFromSplitString(tardis.getChunk()); ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, p.getUniqueId().toString()); TARDISRoomData roomData = new TARDISRoomData(); - roomData.setTardis_id(tardis.getTardis_id()); + roomData.setTardis_id(tardis.getTardisId()); // get middle data, default to orange wool if not set Material wall_type, floor_type; if (rsp.resultSet()) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISConsoleSwitchListener.java b/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISConsoleSwitchListener.java index f53f282d0..062ceab29 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISConsoleSwitchListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISConsoleSwitchListener.java @@ -116,14 +116,14 @@ public void onConsoleInventoryClick(InventoryClickEvent event) { } // Memory circuit (saves/areas) case 10001975, 20001975 -> { new_inv = plugin.getServer().createInventory(p, 54, ChatColor.DARK_RED + "TARDIS Dimension Map"); - stack = new TARDISSavesPlanetInventory(plugin, tardis.getTardis_id()).getPlanets(); + stack = new TARDISSavesPlanetInventory(plugin, tardis.getTardisId()).getPlanets(); } // Input circuit (terminal) case 10001976, 20001976 -> { new_inv = plugin.getServer().createInventory(p, 54, ChatColor.DARK_RED + "Destination Terminal"); stack = new TARDISTerminalInventory(plugin).getTerminal(); } // scanner circuit - default -> new TARDISScanner(plugin).scan(tardis.getTardis_id(), p, tardis.getRenderer(), tardis.getArtron_level()); + default -> new TARDISScanner(plugin).scan(tardis.getTardisId(), p, tardis.getRenderer(), tardis.getArtronLevel()); } // close inventory p.closeInventory(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISDiskWriterCommand.java b/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISDiskWriterCommand.java index d17a33bc3..c7e05f49b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISDiskWriterCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISDiskWriterCommand.java @@ -83,7 +83,7 @@ public boolean writeSave(Player player, String[] args) { return false; } else { Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); ChameleonPreset preset = tardis.getPreset(); // check has unique name - this will always return false in HARD & MEDIUM difficulty // TODO check for disk lore if MEDIUM difficulty diff --git a/src/main/java/me/eccentric_nz/TARDIS/api/TARDII.java b/src/main/java/me/eccentric_nz/TARDIS/api/TARDII.java index 81dce4d91..625e0ee05 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/api/TARDII.java +++ b/src/main/java/me/eccentric_nz/TARDIS/api/TARDII.java @@ -172,8 +172,8 @@ public TARDISData getTARDISMapData(int id) { } } } - String powered = (tardis.isPowered_on()) ? "Yes" : "No"; - String siege = (tardis.isSiege_on()) ? "Yes" : "No"; + String powered = (tardis.isPoweredOn()) ? "Yes" : "No"; + String siege = (tardis.isSiegeOn()) ? "Yes" : "No"; String abandoned = (tardis.isAbandoned()) ? "Yes" : "No"; List occupants = getPlayersInTARDIS(id); data = new TARDISData(owner, current, console, chameleon, door, powered, siege, abandoned, occupants); @@ -819,7 +819,7 @@ public String setDesktopWallAndFloor(UUID uuid, String wall, String floor, boole TARDISUpgradeData tud = new TARDISUpgradeData(); tud.setSchematic(current_console); tud.setPrevious(current_console); - tud.setLevel(rs.getTardis().getArtron_level()); + tud.setLevel(rs.getTardis().getArtronLevel()); tud.setWall(wall); tud.setFloor(floor); // change the wall and floor diff --git a/src/main/java/me/eccentric_nz/TARDIS/api/event/TARDISRoomGrowEvent.java b/src/main/java/me/eccentric_nz/TARDIS/api/event/TARDISRoomGrowEvent.java index d1a186fac..6ef08ca8b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/api/event/TARDISRoomGrowEvent.java +++ b/src/main/java/me/eccentric_nz/TARDIS/api/event/TARDISRoomGrowEvent.java @@ -34,7 +34,7 @@ public final class TARDISRoomGrowEvent extends TARDISEvent { * * @param player the player growing the room * @param tardis the Tardis data object, may be null - if room was manually grown, use {@link - * #getRoomData()}.getTardis_id() + * #getRoomData()}.getTardisId() * @param slot the TARDISARSSlot data object, may be null - if the room was manually grown, use {@link * #getRoomData()}.getLocation() * @param roomData the TARDISRoomData data object diff --git a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronCapacitorListener.java b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronCapacitorListener.java index 0315c0c42..289fa20c8 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronCapacitorListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronCapacitorListener.java @@ -118,9 +118,9 @@ public void onCapacitorInteract(PlayerInteractEvent event) { boolean abandoned = tardis.isAbandoned(); HashMap whereid = new HashMap<>(); whereid.put("tardis_id", id); - int current_level = tardis.getArtron_level(); - boolean init = tardis.isTardis_init(); - boolean lights = tardis.isLights_on(); + int current_level = tardis.getArtronLevel(); + boolean init = tardis.isTardisInit(); + boolean lights = tardis.isLightsOn(); int fc = plugin.getArtronConfig().getInt("full_charge"); Material item = player.getInventory().getItemInMainHand().getType(); Material full = Material.valueOf(plugin.getArtronConfig().getString("full_charge_item")); @@ -243,7 +243,7 @@ public void onCapacitorInteract(PlayerInteractEvent event) { pu = claimAbandoned(player, id, block, tardis); } if (pu) { - new TARDISPowerButton(plugin, id, player, tardis.getPreset(), tardis.isPowered_on(), tardis.isHidden(), lights, player.getLocation(), current_level, tardis.getSchematic().getLights()).clickButton(); + new TARDISPowerButton(plugin, id, player, tardis.getPreset(), tardis.isPoweredOn(), tardis.isHidden(), lights, player.getLocation(), current_level, tardis.getSchematic().getLights()).clickButton(); } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISBeaconToggler.java b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISBeaconToggler.java index bff742fb5..6696b41bc 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISBeaconToggler.java +++ b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISBeaconToggler.java @@ -65,7 +65,7 @@ public void flickSwitch(UUID uuid, int id, boolean on) { } b.setBlockData((on) ? TARDISConstants.GLASS : TARDISConstants.POWER); if (!plugin.getGeneralKeeper().getProtectBlockMap().containsKey(bl.toString())) { - plugin.getGeneralKeeper().getProtectBlockMap().put(bl.toString(), tardis.getTardis_id()); + plugin.getGeneralKeeper().getProtectBlockMap().put(bl.toString(), tardis.getTardisId()); } } else { updateBeacon(schm, uuid); diff --git a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISCondenserListener.java b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISCondenserListener.java index 94fb95569..b870f8dcb 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISCondenserListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISCondenserListener.java @@ -236,15 +236,15 @@ public void onChestClose(InventoryCloseEvent event) { item_counts.forEach((key, value) -> { // check if the tardis has condensed this material before HashMap wherec = new HashMap<>(); - wherec.put("tardis_id", tardis.getTardis_id()); + wherec.put("tardis_id", tardis.getTardisId()); wherec.put("block_data", key); ResultSetCondenser rsc = new ResultSetCondenser(plugin, wherec); HashMap setc = new HashMap<>(); if (rsc.resultSet()) { int new_stack_size = value + rsc.getBlock_count(); - plugin.getQueryFactory().updateCondensedBlockCount(new_stack_size, tardis.getTardis_id(), key); + plugin.getQueryFactory().updateCondensedBlockCount(new_stack_size, tardis.getTardisId(), key); } else { - setc.put("tardis_id", tardis.getTardis_id()); + setc.put("tardis_id", tardis.getTardisId()); setc.put("block_data", key); setc.put("block_count", value); plugin.getQueryFactory().doInsert("condenser", setc); @@ -258,13 +258,13 @@ public void onChestClose(InventoryCloseEvent event) { // halve it cause 1:1 is too much... amount = Math.round(amount / 2.0F); HashMap wheret = new HashMap<>(); - wheret.put("tardis_id", tardis.getTardis_id()); + wheret.put("tardis_id", tardis.getTardisId()); plugin.getQueryFactory().alterEnergyLevel("tardis", amount, wheret, player); if (amount > 0) { // are we doing an achievement? if (plugin.getAchievementConfig().getBoolean("energy.enabled")) { // determine the current percentage - int current_level = tardis.getArtron_level() + amount; + int current_level = tardis.getArtronLevel() + amount; int fc = plugin.getArtronConfig().getInt("full_charge"); int percent = Math.round((current_level * 100F) / fc); TARDISAchievementFactory taf = new TARDISAchievementFactory(plugin, player, Advancement.ENERGY, 1); diff --git a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISCreeperChecker.java b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISCreeperChecker.java index be8ca46e3..2637fe2b6 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISCreeperChecker.java +++ b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISCreeperChecker.java @@ -55,7 +55,7 @@ public void checkCreeper() { // only if there is a saved creeper location if (!tardis.getCreeper().isEmpty()) { // only if the TARDIS has been initialised - if (tardis.isTardis_init()) { + if (tardis.isTardisInit()) { World w = TARDISStaticLocationGetters.getWorldFromSplitString(tardis.getCreeper()); if (w != null) { Location l = TARDISStaticLocationGetters.getLocationFromDB(tardis.getCreeper()); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISCallRequestCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISCallRequestCommand.java index e5d2ec28d..dc7da8e25 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISCallRequestCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISCallRequestCommand.java @@ -16,8 +16,6 @@ */ package me.eccentric_nz.TARDIS.commands; -import java.util.HashMap; -import java.util.UUID; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.api.Parameters; import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; @@ -39,6 +37,9 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; +import java.util.HashMap; +import java.util.UUID; + /** * @author eccentric_nz */ @@ -60,12 +61,12 @@ public boolean requestComeHere(Player player, Player requested) { return true; } Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + int id = tardis.getTardisId(); + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "PLAYER_NOT_POWERED", requested.getName()); return true; } - int level = tardis.getArtron_level(); + int level = tardis.getArtronLevel(); boolean hidden = tardis.isHidden(); // get location Location eyeLocation = player.getTargetBlock(plugin.getGeneralKeeper().getTransparent(), 50).getLocation(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISAbandonLister.java b/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISAbandonLister.java index 46cf66280..70cb8b6d4 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISAbandonLister.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISAbandonLister.java @@ -51,13 +51,13 @@ public void list(CommandSender sender) { String owner = (t.getOwner().isEmpty()) ? "TARDIS Admin" : t.getOwner(); // get current location HashMap wherec = new HashMap<>(); - wherec.put("tardis_id", t.getTardis_id()); + wherec.put("tardis_id", t.getTardisId()); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherec); if (rsc.resultSet()) { String w = (!plugin.getPlanetsConfig().getBoolean("planets." + rsc.getWorld().getName() + ".enabled") && plugin.getWorldManager().equals(WorldManager.MULTIVERSE)) ? plugin.getMVHelper().getAlias(rsc.getWorld()) : TARDISAliasResolver.getWorldAlias(rsc.getWorld()); String l = w + " " + rsc.getX() + ", " + rsc.getY() + ", " + rsc.getZ(); if (click) { - plugin.getMessenger().sendAbandoned(sender, i, owner, l, t.getTardis_id()); + plugin.getMessenger().sendAbandoned(sender, i, owner, l, t.getTardisId()); } else { sender.sendMessage(i + ". Abandoned by: " + owner + ", location: " + l); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISDeleteCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISDeleteCommand.java index 3d34e8095..b68f02f97 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISDeleteCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISDeleteCommand.java @@ -86,7 +86,7 @@ boolean deleteTARDIS(CommandSender sender, String[] args) { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, abandoned); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); int tips = tardis.getTIPS(); Schematic schm = tardis.getSchematic(); String chunkLoc = tardis.getChunk(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISEnterCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISEnterCommand.java index 6112ce037..897cbd281 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISEnterCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISEnterCommand.java @@ -75,7 +75,7 @@ boolean enterTARDIS(CommandSender sender, String[] args) { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 2); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); String owner = tardis.getOwner(); HashMap wherei = new HashMap<>(); wherei.put("door_type", 1); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISListCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISListCommand.java index 8d4ffac80..57133e9c1 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISListCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/admin/TARDISListCommand.java @@ -54,13 +54,13 @@ boolean listStuff(CommandSender sender, String[] args) { try (BufferedWriter bw = new BufferedWriter(new FileWriter(file, false))) { for (Tardis t : rsl.getData()) { HashMap wherecl = new HashMap<>(); - wherecl.put("tardis_id", t.getTardis_id()); + wherecl.put("tardis_id", t.getTardisId()); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherecl); if (!rsc.resultSet()) { plugin.getMessenger().send(sender, TardisModule.TARDIS, "CURRENT_NOT_FOUND"); return true; } - String line = "ID: " + t.getTardis_id() + ", Time Lord: " + t.getOwner() + ", Location: " + rsc.getWorld().getName() + ":" + rsc.getX() + ":" + rsc.getY() + ":" + rsc.getZ(); + String line = "ID: " + t.getTardisId() + ", Time Lord: " + t.getOwner() + ", Location: " + rsc.getWorld().getName() + ":" + rsc.getX() + ":" + rsc.getY() + ":" + rsc.getZ(); bw.write(line); bw.newLine(); } @@ -100,7 +100,7 @@ boolean listStuff(CommandSender sender, String[] args) { plugin.getMessenger().message(sender, ""); for (Tardis t : rsl.getData()) { HashMap wherecl = new HashMap<>(); - wherecl.put("tardis_id", t.getTardis_id()); + wherecl.put("tardis_id", t.getTardisId()); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherecl); if (!rsc.resultSet()) { plugin.getMessenger().send(sender, TardisModule.TARDIS, "CURRENT_NOT_FOUND"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISInteractionCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISInteractionCommand.java index 3f2e6ae7d..bfc16a0ee 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISInteractionCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISInteractionCommand.java @@ -22,7 +22,7 @@ public boolean process(UUID uuid) { where.put("uuid", uuid.toString()); ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 2); if (rs.resultSet()) { - int id = rs.getTardis().getTardis_id(); + int id = rs.getTardis().getTardisId(); HashMap wherec = new HashMap<>(); wherec.put("tardis_id", id); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherec); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISGiveCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISGiveCommand.java index ec8f537fe..b54811faf 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISGiveCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISGiveCommand.java @@ -357,8 +357,8 @@ private void giveArtron(CommandSender sender, String player, int amount) { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); - int level = tardis.getArtron_level(); + int id = tardis.getTardisId(); + int level = tardis.getArtronLevel(); int set_level; if (amount == 0) { set_level = 0; diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesLandCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesLandCommand.java index f18ed6e3e..272500632 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesLandCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesLandCommand.java @@ -64,7 +64,7 @@ public boolean exitVortex(Player player, int id, String uuid) { plugin.getMessenger().handlesSend(player, "HANDLES_JUNK"); return true; } - if (tardis.isHandbrake_on()) { + if (tardis.isHandbrakeOn()) { plugin.getMessenger().handlesSend(player, "HANDBRAKE_ON_ERR"); return true; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesTakeoffCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesTakeoffCommand.java index 5742e331d..f3189b28e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesTakeoffCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesTakeoffCommand.java @@ -16,8 +16,6 @@ */ package me.eccentric_nz.TARDIS.commands.handles; -import java.util.Collections; -import java.util.HashMap; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.database.data.Tardis; import me.eccentric_nz.TARDIS.database.resultset.*; @@ -31,6 +29,9 @@ import org.bukkit.block.data.Openable; import org.bukkit.entity.Player; +import java.util.Collections; +import java.util.HashMap; + /** * @author eccentric_nz */ @@ -58,7 +59,7 @@ public boolean enterVortex(Player player, String[] args) { if (tardis.getPreset().equals(ChameleonPreset.JUNK)) { return true; } - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().handlesSend(player, "POWER_DOWN"); return true; } @@ -71,9 +72,9 @@ public boolean enterVortex(Player player, String[] args) { whereh.put("tardis_id", id); ResultSetControls rsc = new ResultSetControls(plugin, whereh, false); if (rsc.resultSet()) { - if (tardis.isHandbrake_on()) { + if (tardis.isHandbrakeOn()) { // check there is enough power for at last random travel - if (!plugin.getTrackerKeeper().getHasDestination().containsKey(id) && tardis.getArtron_level() < plugin.getArtronConfig().getInt("random")) { + if (!plugin.getTrackerKeeper().getHasDestination().containsKey(id) && tardis.getArtronLevel() < plugin.getArtronConfig().getInt("random")) { plugin.getMessenger().handlesSend(player, "ENERGY_NOT_ENOUGH"); return true; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesTeleportCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesTeleportCommand.java index 1d5a4d462..e1487006c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesTeleportCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesTeleportCommand.java @@ -16,8 +16,6 @@ */ package me.eccentric_nz.TARDIS.commands.handles; -import java.util.HashMap; -import java.util.UUID; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.api.Parameters; import me.eccentric_nz.TARDIS.builders.BuildData; @@ -31,6 +29,9 @@ import org.bukkit.Location; import org.bukkit.entity.Player; +import java.util.HashMap; +import java.util.UUID; + /** * @author eccentric_nz */ @@ -59,12 +60,12 @@ public void beamMeUp(Player player) { return; } Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); - if (!tardis.isHandbrake_on() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { + int id = tardis.getTardisId(); + if (!tardis.isHandbrakeOn() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { plugin.getMessenger().handlesSend(player, "NOT_WHILE_TRAVELLING"); return; } - int level = tardis.getArtron_level(); + int level = tardis.getArtronLevel(); int travel = plugin.getArtronConfig().getInt("travel"); if (level < travel) { plugin.getMessenger().handlesSend(player, "NOT_ENOUGH_ENERGY"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISBuildCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISBuildCommand.java index 6f5a7d28e..3081c3854 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISBuildCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISBuildCommand.java @@ -52,7 +52,7 @@ boolean toggleCompanionBuilding(Player player, String[] args) { return true; } Tardis tardis = rs.getTardis(); - Integer id = tardis.getTardis_id(); + Integer id = tardis.getTardisId(); HashMap setp = new HashMap<>(); HashMap wherep = new HashMap<>(); wherep.put("uuid", player.getUniqueId().toString()); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISIsomorphicCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISIsomorphicCommand.java index 4f8337ff1..c66db1388 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISIsomorphicCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISIsomorphicCommand.java @@ -47,9 +47,9 @@ public boolean toggleIsomorphicControls(UUID uuid, CommandSender sender) { // does the player have a TARDIS if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - int iso = (tardis.isIso_on()) ? 0 : 1; - String onoff = (tardis.isIso_on()) ? "ISO_OFF" : "ISO_ON"; - int id = tardis.getTardis_id(); + int iso = (tardis.isIsomorphicOn()) ? 0 : 1; + String onoff = (tardis.isIsomorphicOn()) ? "ISO_OFF" : "ISO_ON"; + int id = tardis.getTardisId(); HashMap seti = new HashMap<>(); seti.put("iso_on", iso); HashMap wheret = new HashMap<>(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISJunkPreference.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISJunkPreference.java index 2457ec775..6fd42fa9b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISJunkPreference.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISJunkPreference.java @@ -48,7 +48,7 @@ public boolean toggle(Player player, String arg) { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); // get current preset String current = tardis.getPreset().toString(); // must be outside of the TARDIS diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuInventory.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuInventory.java index 7b12c40a1..ce48e3018 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuInventory.java @@ -161,7 +161,7 @@ private ItemStack[] getItemStack() { ItemStack hand = new ItemStack(Material.LEVER, 1); ItemMeta brake = hand.getItemMeta(); brake.setDisplayName("Handbrake"); - brake.setLore(Collections.singletonList((tardis != null && tardis.isHandbrake_on()) ? plugin.getLanguage().getString("SET_ON") : plugin.getLanguage().getString("SET_OFF"))); + brake.setLore(Collections.singletonList((tardis != null && tardis.isHandbrakeOn()) ? plugin.getLanguage().getString("SET_ON") : plugin.getLanguage().getString("SET_OFF"))); brake.setCustomModelData(GUIPlayerPreferences.HANDBRAKE.getCustomModelData()); hand.setItemMeta(brake); stack[GUIPlayerPreferences.HANDBRAKE.getSlot()] = hand; diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuListener.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuListener.java index 9eb8944b3..99d976317 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuListener.java @@ -334,7 +334,7 @@ public void onPrefsMenuClick(InventoryClickEvent event) { plugin.getMessenger().send(p, TardisModule.TARDIS, "JUNK_ALREADY_OFF"); return; } - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); String cham_set; HashMap setj = new HashMap<>(); if (has) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/remote/TARDISRemoteComehereCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/remote/TARDISRemoteComehereCommand.java index 451e4ec4e..bb79ac0f5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/remote/TARDISRemoteComehereCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/remote/TARDISRemoteComehereCommand.java @@ -85,7 +85,7 @@ public boolean doRemoteComeHere(Player player, UUID uuid) { return true; } Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); // check they are not in the tardis HashMap wherettrav = new HashMap<>(); wherettrav.put("uuid", player.getUniqueId().toString()); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/remote/TARDISRemoteCommands.java b/src/main/java/me/eccentric_nz/TARDIS/commands/remote/TARDISRemoteCommands.java index 9e04818e5..3f7cc099c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/remote/TARDISRemoteCommands.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/remote/TARDISRemoteCommands.java @@ -78,15 +78,15 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String if (rs.resultSet()) { Tardis tardis = rs.getTardis(); // not in siege mode - if (plugin.getTrackerKeeper().getInSiegeMode().contains(tardis.getTardis_id())) { + if (plugin.getTrackerKeeper().getInSiegeMode().contains(tardis.getTardisId())) { plugin.getMessenger().send(sender, TardisModule.TARDIS, "SIEGE_NO_CMD"); return true; } // we're good to go - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); boolean hidden = tardis.isHidden(); - boolean handbrake = tardis.isHandbrake_on(); - int level = tardis.getArtron_level(); + boolean handbrake = tardis.isHandbrakeOn(); + int level = tardis.getArtronLevel(); if (sender instanceof Player && !sender.hasPermission("tardis.admin")) { HashMap wheret = new HashMap<>(); wheret.put("uuid", ((Player) sender).getUniqueId().toString()); @@ -96,12 +96,12 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String return true; } Tardis t = rst.getTardis(); - int tardis_id = t.getTardis_id(); + int tardis_id = t.getTardisId(); if (tardis_id != id) { plugin.getMessenger().send(sender, TardisModule.TARDIS, "CMD_ONLY_TL_REMOTE"); return true; } - if (plugin.getConfig().getBoolean("allow.power_down") && !t.isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !t.isPoweredOn()) { plugin.getMessenger().send(sender, TardisModule.TARDIS, "POWER_DOWN"); return true; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/sudo/SudoAssemble.java b/src/main/java/me/eccentric_nz/TARDIS/commands/sudo/SudoAssemble.java index d9c2ccdd5..112effe56 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/sudo/SudoAssemble.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/sudo/SudoAssemble.java @@ -46,7 +46,7 @@ boolean restore(CommandSender sender, UUID uuid, String player) { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - plugin.getTrackerKeeper().getDispersedTARDII().remove(tardis.getTardis_id()); + plugin.getTrackerKeeper().getDispersedTARDII().remove(tardis.getTardisId()); plugin.getMessenger().send(sender, TardisModule.TARDIS, "ASSEMBLE_PLAYER", player); Player dispersed = plugin.getServer().getPlayer(uuid); if (dispersed != null) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/sudo/SudoRepair.java b/src/main/java/me/eccentric_nz/TARDIS/commands/sudo/SudoRepair.java index c8a225b73..0578e1e65 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/sudo/SudoRepair.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/sudo/SudoRepair.java @@ -16,8 +16,6 @@ */ package me.eccentric_nz.TARDIS.commands.sudo; -import java.util.HashMap; -import java.util.UUID; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.database.data.Tardis; import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; @@ -27,6 +25,9 @@ import me.eccentric_nz.TARDIS.enumeration.TardisModule; import org.bukkit.entity.Player; +import java.util.HashMap; +import java.util.UUID; + public class SudoRepair { private final TARDIS plugin; @@ -51,7 +52,7 @@ public boolean repair() { Tardis tardis = rs.getTardis(); // get player's current console Schematic current_console = tardis.getSchematic(); - int level = tardis.getArtron_level(); + int level = tardis.getArtronLevel(); TARDISUpgradeData tud = new TARDISUpgradeData(); tud.setPrevious(current_console); tud.setLevel(level); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/sudo/SudoUpdate.java b/src/main/java/me/eccentric_nz/TARDIS/commands/sudo/SudoUpdate.java index cf9b63c91..42060b64c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/sudo/SudoUpdate.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/sudo/SudoUpdate.java @@ -115,9 +115,9 @@ boolean initiate(Player player, String[] args, int id, UUID uuid) { ItemFrame itemFrame = null; switch (updateable) { case ROTOR -> itemFrame = TARDISTimeRotor.getItemFrame(tardis.getRotor()); - case MONITOR -> itemFrame = MonitorUtils.getItemFrameFromLocation(tardis.getTardis_id(), true); + case MONITOR -> itemFrame = MonitorUtils.getItemFrameFromLocation(tardis.getTardisId(), true); case MONITOR_FRAME -> { - itemFrame = MonitorUtils.getItemFrameFromLocation(tardis.getTardis_id(), false); + itemFrame = MonitorUtils.getItemFrameFromLocation(tardis.getTardisId(), false); // reinstate display name ItemStack glass = itemFrame.getItem(); ItemMeta im = glass.getItemMeta(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISAddCompanionCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISAddCompanionCommand.java index e303d4c07..f2cf6df78 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISAddCompanionCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISAddCompanionCommand.java @@ -75,7 +75,7 @@ boolean doAdd(Player player, String[] args) { return true; } else { Tardis tardis = rs.getTardis(); - id = tardis.getTardis_id(); + id = tardis.getTardisId(); comps = tardis.getCompanions(); data = tardis.getChunk(); owner = tardis.getOwner(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISArchiveCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISArchiveCommand.java index 8c0e2d549..f69bbf8be 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISArchiveCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISArchiveCommand.java @@ -188,7 +188,7 @@ boolean zip(Player player, String[] args) { } // calculate startx, starty, startz int slot = tardis.getTIPS(); - id = tardis.getTardis_id(); + id = tardis.getTardisId(); int sx, sz; if (slot != -1000001) { // default world - use TIPS TARDISInteriorPostioning tintpos = new TARDISInteriorPostioning(plugin); @@ -196,7 +196,7 @@ boolean zip(Player player, String[] args) { sx = pos.getCentreX(); sz = pos.getCentreZ(); } else { - int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardis_id()); + int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardisId()); sx = gsl[0]; sz = gsl[2]; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISColouriseCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISColouriseCommand.java index 417f86dbb..a3d1375c0 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISColouriseCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISColouriseCommand.java @@ -70,7 +70,7 @@ boolean updateBeaconGlass(Player player) { plugin.getMessenger().send(player, TardisModule.TARDIS, "COLOUR_SONIC"); return true; } - int ownerid = tardis.getTardis_id(); + int ownerid = tardis.getTardisId(); HashMap wheret = new HashMap<>(); wheret.put("uuid", player.getUniqueId().toString()); ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISComehereCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISComehereCommand.java index c2d767dda..ca6167b6c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISComehereCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISComehereCommand.java @@ -65,12 +65,12 @@ boolean doComeHere(Player player) { } if (plugin.getDifficulty().equals(Difficulty.EASY) || plugin.getUtils().inGracePeriod(player, true)) { Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + int id = tardis.getTardisId(); + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return true; } - int level = tardis.getArtron_level(); + int level = tardis.getArtronLevel(); boolean hidden = tardis.isHidden(); // get location Location eyeLocation = player.getTargetBlock(plugin.getGeneralKeeper().getTransparent(), 50).getLocation(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISDirectionCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISDirectionCommand.java index aa25b7532..dfe161902 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISDirectionCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISDirectionCommand.java @@ -75,11 +75,11 @@ public boolean changeDirection(Player player, String[] args) { plugin.getMessenger().send(player, TardisModule.TARDIS, "DIRECTION_PRESET"); return true; } - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return true; } - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); TARDISCircuitChecker tcc = null; if (!plugin.getDifficulty().equals(Difficulty.EASY) && !plugin.getUtils().inGracePeriod(player, true)) { tcc = new TARDISCircuitChecker(plugin, id); @@ -89,7 +89,7 @@ public boolean changeDirection(Player player, String[] args) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_MAT_CIRCUIT"); return true; } - int level = tardis.getArtron_level(); + int level = tardis.getArtronLevel(); int amount = plugin.getArtronConfig().getInt("random"); if (level < amount) { plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NO_DIRECTION"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISEmergencyProgrammeCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISEmergencyProgrammeCommand.java index af4c3f48d..e67d5a3eb 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISEmergencyProgrammeCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISEmergencyProgrammeCommand.java @@ -58,7 +58,7 @@ boolean showEP1(Player p) { return true; } Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); String eps = tardis.getEps(); String creeper = tardis.getCreeper(); HashMap wherem = new HashMap<>(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISHideCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISHideCommand.java index 836417d9c..884290bf2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISHideCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISHideCommand.java @@ -16,8 +16,6 @@ */ package me.eccentric_nz.TARDIS.commands.tardis; -import java.util.HashMap; -import java.util.UUID; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.advanced.TARDISCircuitChecker; import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; @@ -33,6 +31,9 @@ import org.bukkit.Location; import org.bukkit.OfflinePlayer; +import java.util.HashMap; +import java.util.UUID; + /** * @author eccentric_nz */ @@ -66,7 +67,7 @@ public boolean hide(OfflinePlayer player) { return false; } Tardis tardis = rs.getTardis(); - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "POWER_DOWN"); return true; } @@ -74,7 +75,7 @@ public boolean hide(OfflinePlayer player) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "INVISIBILITY_ENGAGED"); return true; } - id = tardis.getTardis_id(); + id = tardis.getTardisId(); TARDISCircuitChecker tcc = null; if (!plugin.getDifficulty().equals(Difficulty.EASY) && !plugin.getUtils().inGracePeriod(player.getPlayer(), true)) { tcc = new TARDISCircuitChecker(plugin, id); @@ -105,14 +106,14 @@ public boolean hide(OfflinePlayer player) { return true; } HashMap wherecl = new HashMap<>(); - wherecl.put("tardis_id", tardis.getTardis_id()); + wherecl.put("tardis_id", tardis.getTardisId()); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherecl); if (!rsc.resultSet()) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "CURRENT_NOT_FOUND"); return true; } Location l = new Location(rsc.getWorld(), rsc.getX(), rsc.getY(), rsc.getZ()); - int level = tardis.getArtron_level(); + int level = tardis.getArtronLevel(); int hide = plugin.getArtronConfig().getInt("hide"); if (level < hide) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "ENERGY_NO_HIDE"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISLampsCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISLampsCommand.java index 025e1a9c4..5b27448e4 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISLampsCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISLampsCommand.java @@ -69,7 +69,7 @@ boolean addLampBlocks(Player owner) { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); // check if they have already got lamp records HashMap wherel = new HashMap<>(); wherel.put("tardis_id", id); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISMakeHerBlueCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISMakeHerBlueCommand.java index 22a989871..f20c3854f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISMakeHerBlueCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISMakeHerBlueCommand.java @@ -67,7 +67,7 @@ public boolean show(Player player) { return true; } Tardis tardis = rs.getTardis(); - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "POWER_DOWN"); return true; } @@ -75,7 +75,7 @@ public boolean show(Player player) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "INVISIBILITY_NOT"); return true; } - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); TARDISCircuitChecker tcc = null; if (!plugin.getDifficulty().equals(Difficulty.EASY)) { tcc = new TARDISCircuitChecker(plugin, id); @@ -100,7 +100,7 @@ public boolean show(Player player) { return true; } HashMap wherecl = new HashMap<>(); - wherecl.put("tardis_id", tardis.getTardis_id()); + wherecl.put("tardis_id", tardis.getTardisId()); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherecl); if (!rsc.resultSet()) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "CURRENT_NOT_FOUND"); @@ -108,7 +108,7 @@ public boolean show(Player player) { return true; } Location l = new Location(rsc.getWorld(), rsc.getX(), rsc.getY(), rsc.getZ()); - int level = tardis.getArtron_level(); + int level = tardis.getArtronLevel(); int rebuild = plugin.getArtronConfig().getInt("random"); if (level < rebuild) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "ENERGY_NO_REBUILD"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISRebuildCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISRebuildCommand.java index fa6a6598a..3e026aa99 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISRebuildCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISRebuildCommand.java @@ -65,7 +65,7 @@ public boolean rebuildPreset(OfflinePlayer player) { return true; } Tardis tardis = rs.getTardis(); - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "POWER_DOWN"); return true; } @@ -73,7 +73,7 @@ public boolean rebuildPreset(OfflinePlayer player) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "INVISIBILITY_ENGAGED"); return true; } - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); TARDISCircuitChecker tcc = null; if (!plugin.getDifficulty().equals(Difficulty.EASY) && !plugin.getUtils().inGracePeriod(player.getPlayer(), true)) { tcc = new TARDISCircuitChecker(plugin, id); @@ -103,7 +103,7 @@ public boolean rebuildPreset(OfflinePlayer player) { return true; } HashMap wherecl = new HashMap<>(); - wherecl.put("tardis_id", tardis.getTardis_id()); + wherecl.put("tardis_id", tardis.getTardisId()); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherecl); if (!rsc.resultSet()) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "CURRENT_NOT_FOUND"); @@ -111,7 +111,7 @@ public boolean rebuildPreset(OfflinePlayer player) { return true; } Location l = new Location(rsc.getWorld(), rsc.getX(), rsc.getY(), rsc.getZ()); - int level = tardis.getArtron_level(); + int level = tardis.getArtronLevel(); int rebuild = plugin.getArtronConfig().getInt("random"); if (level < rebuild) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "ENERGY_NO_REBUILD"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISRemoveCompanionCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISRemoveCompanionCommand.java index adeda2837..989e0d3b6 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISRemoveCompanionCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISRemoveCompanionCommand.java @@ -62,7 +62,7 @@ boolean doRemoveCompanion(Player player, String[] args) { plugin.getMessenger().send(player, TardisModule.TARDIS, "COMPANIONS_NONE"); return true; } - id = tardis.getTardis_id(); + id = tardis.getTardisId(); data = tardis.getChunk(); owner = tardis.getOwner(); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISRoomCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISRoomCommand.java index 8ddfb7852..c25b994a5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISRoomCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISRoomCommand.java @@ -16,10 +16,6 @@ */ package me.eccentric_nz.TARDIS.commands.tardis; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.UUID; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.advanced.TARDISCircuitChecker; import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; @@ -35,6 +31,11 @@ import org.bukkit.Material; import org.bukkit.entity.Player; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.UUID; + /** * @author eccentric_nz */ @@ -70,7 +71,7 @@ boolean startRoom(Player player, String[] args) { return true; } Tardis tardis = rs.getTardis(); - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return true; } @@ -82,7 +83,7 @@ boolean startRoom(Player player, String[] args) { plugin.getMessenger().send(player, TardisModule.TARDIS, "RENDER_EXISTS"); return true; } - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); TARDISCircuitChecker tcc = null; if (!plugin.getDifficulty().equals(Difficulty.EASY) && !plugin.getUtils().inGracePeriod(player, true)) { tcc = new TARDISCircuitChecker(plugin, id); @@ -92,7 +93,7 @@ boolean startRoom(Player player, String[] args) { plugin.getMessenger().send(player, TardisModule.TARDIS, "ARS_MISSING"); return true; } - int level = tardis.getArtron_level(); + int level = tardis.getArtronLevel(); String chunk = tardis.getChunk(); Schematic schm = tardis.getSchematic(); int tips = tardis.getTIPS(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISSaveLocationCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISSaveLocationCommand.java index d9c55224c..d26062a01 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISSaveLocationCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISSaveLocationCommand.java @@ -59,7 +59,7 @@ boolean doSave(Player player, String[] args) { plugin.getMessenger().sendColouredCommand(player, "SAVE_RESERVED", "/tardis home", plugin); return false; } else { - int id = rs.getTardis().getTardis_id(); + int id = rs.getTardis().getTardisId(); // check has unique name HashMap wherename = new HashMap<>(); wherename.put("tardis_id", id); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISUpdateCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISUpdateCommand.java index b0e080442..175c3c19d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISUpdateCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISUpdateCommand.java @@ -169,7 +169,7 @@ boolean startUpdate(Player player, String[] args) { Block block = player.getTargetBlock(plugin.getGeneralKeeper().getTransparent(), 10); if (block.getType().equals(Material.NOTE_BLOCK) || block.getType().equals(Material.MUSHROOM_STEM)) { block.setBlockData(TARDISConstants.BARRIER, true); - TARDISDisplayItemUtils.set(TARDISDisplayItem.DISK_STORAGE, block, tardis.getTardis_id()); + TARDISDisplayItemUtils.set(TARDISDisplayItem.DISK_STORAGE, block, tardis.getTardisId()); } } if (new TARDISUpdateableChecker(plugin, updateable, player, tardis, tardis_block).canUpdate()) { @@ -179,9 +179,9 @@ boolean startUpdate(Player player, String[] args) { ItemFrame itemFrame = null; switch (updateable) { case ROTOR -> itemFrame = TARDISTimeRotor.getItemFrame(tardis.getRotor()); - case MONITOR -> itemFrame = MonitorUtils.getItemFrameFromLocation(tardis.getTardis_id(), true); + case MONITOR -> itemFrame = MonitorUtils.getItemFrameFromLocation(tardis.getTardisId(), true); case MONITOR_FRAME -> { - itemFrame = MonitorUtils.getItemFrameFromLocation(tardis.getTardis_id(), false); + itemFrame = MonitorUtils.getItemFrameFromLocation(tardis.getTardisId(), false); // reinstate display name ItemStack glass = itemFrame.getItem(); ItemMeta im = glass.getItemMeta(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISUpgradeCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISUpgradeCommand.java index 11b7af586..eee42ba1f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISUpgradeCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISUpgradeCommand.java @@ -16,7 +16,6 @@ */ package me.eccentric_nz.TARDIS.commands.tardis; -import java.util.HashMap; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; import me.eccentric_nz.TARDIS.builders.TARDISInteriorPostioning; @@ -33,6 +32,8 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import java.util.HashMap; + /** * @author eccentric_nz */ @@ -64,7 +65,7 @@ boolean openUpgradeGUI(Player player) { return true; } // check they are not growing rooms - if (plugin.getTrackerKeeper().getIsGrowingRooms().contains(tardis.getTardis_id())) { + if (plugin.getTrackerKeeper().getIsGrowingRooms().contains(tardis.getTardisId())) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_UPGRADE_WHILE_GROWING"); return true; } @@ -91,7 +92,7 @@ boolean openUpgradeGUI(Player player) { } // get player's current console Schematic current_console = tardis.getSchematic(); - int level = tardis.getArtron_level(); + int level = tardis.getArtronLevel(); TARDISUpgradeData tud = new TARDISUpgradeData(); tud.setPrevious(current_console); tud.setLevel(level); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/travel/TARDISTravelCommands.java b/src/main/java/me/eccentric_nz/TARDIS/commands/travel/TARDISTravelCommands.java index f8ec06671..9508cc42a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/travel/TARDISTravelCommands.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/travel/TARDISTravelCommands.java @@ -68,7 +68,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String return true; } Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); if (args[0].equalsIgnoreCase("cancel")) { return new TARDISTravelCancel(plugin).action(player, id); } @@ -82,9 +82,9 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String if (args.length == 1 && args[0].equalsIgnoreCase("stop")) { return new TARDISTravelStop(plugin).action(player, id); } - int level = tardis.getArtron_level(); - boolean powered = tardis.isPowered_on(); - if (!tardis.isHandbrake_on() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { + int level = tardis.getArtronLevel(); + boolean powered = tardis.isPoweredOn(); + if (!tardis.isHandbrakeOn() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_WHILE_TRAVELLING"); return true; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/utils/TARDISWeatherListener.java b/src/main/java/me/eccentric_nz/TARDIS/commands/utils/TARDISWeatherListener.java index aad6d063f..7ac55414e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/utils/TARDISWeatherListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/utils/TARDISWeatherListener.java @@ -79,21 +79,21 @@ public void onWeatherMenuInteract(InventoryClickEvent event) { } Tardis tardis = rs.getTardis(); // check they initialised - if (!tardis.isTardis_init()) { + if (!tardis.isTardisInit()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NO_INIT"); return; } - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return; } - if (!tardis.isHandbrake_on()) { + if (!tardis.isHandbrakeOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_WHILE_TRAVELLING"); return; } // get current location HashMap wherec = new HashMap<>(); - wherec.put("tardis_id", tardis.getTardis_id()); + wherec.put("tardis_id", tardis.getTardisId()); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherec); if (!rsc.resultSet()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "CURRENT_NOT_FOUND"); @@ -136,7 +136,7 @@ public void onWeatherMenuInteract(InventoryClickEvent event) { plugin.getMessenger().send(player, TardisModule.TARDIS, "CMD_EXCITE"); return; } - new TARDISAtmosphericExcitation(plugin).excite(tardis.getTardis_id(), player); + new TARDISAtmosphericExcitation(plugin).excite(tardis.getTardisId(), player); plugin.getTrackerKeeper().getExcitation().add(player.getUniqueId()); close(player); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/companionGUI/TARDISCompanionAddGUIListener.java b/src/main/java/me/eccentric_nz/TARDIS/companionGUI/TARDISCompanionAddGUIListener.java index b4cf7834d..4271c9846 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/companionGUI/TARDISCompanionAddGUIListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/companionGUI/TARDISCompanionAddGUIListener.java @@ -101,7 +101,7 @@ public void onCompanionAddGUIClick(InventoryClickEvent event) { ResultSetTardis rsa = new ResultSetTardis(plugin, wherea, "", false, 0); if (rsa.resultSet()) { Tardis tardis = rsa.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); String comps = tardis.getCompanions(); addCompanion(id, comps, "everyone"); if (plugin.isWorldGuardOnServer() && plugin.getConfig().getBoolean("preferences.use_worldguard")) { @@ -121,7 +121,7 @@ public void onCompanionAddGUIClick(InventoryClickEvent event) { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); String comps = tardis.getCompanions(); // ItemStack h = view.getItem(slot); ItemMeta m = is.getItemMeta(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/companionGUI/TARDISCompanionGUIListener.java b/src/main/java/me/eccentric_nz/TARDIS/companionGUI/TARDISCompanionGUIListener.java index 98579e8a6..ec67263c6 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/companionGUI/TARDISCompanionGUIListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/companionGUI/TARDISCompanionGUIListener.java @@ -121,7 +121,7 @@ public void onCompanionGUIClick(InventoryClickEvent event) { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); String comps = tardis.getCompanions(); ItemStack h = view.getItem(selected_head.get(uuid)); ItemMeta m = h.getItemMeta(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java index a18d0fd70..9997a578c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java @@ -65,12 +65,12 @@ public void process(int id, int state, Player player, Location handbrake) { return; } UUID ownerUUID = tardis.getUuid(); - if ((tardis.isIso_on() && !uuid.equals(ownerUUID) && !TARDISPermission.hasPermission(player, "tardis.skeletonkey")) || plugin.getTrackerKeeper().getJohnSmith().containsKey(uuid)) { + if ((tardis.isIsomorphicOn() && !uuid.equals(ownerUUID) && !TARDISPermission.hasPermission(player, "tardis.skeletonkey")) || plugin.getTrackerKeeper().getJohnSmith().containsKey(uuid)) { // check if cancelled, so we don't get double messages from the bind listener plugin.getMessenger().send(player, TardisModule.TARDIS, "ISO_HANDS_OFF"); return; } - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return; } @@ -89,13 +89,13 @@ public void process(int id, int state, Player player, Location handbrake) { spaceTimeThrottle = SpaceTimeThrottle.getByDelay().get(rsp.getThrottle()); } if (state == 1) { - if (tardis.isHandbrake_on()) { + if (tardis.isHandbrakeOn()) { if (preset.equals(ChameleonPreset.JUNK_MODE) && !plugin.getTrackerKeeper().getHasDestination().containsKey(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "TRAVEL_NEED_DEST"); return; } // check there is enough power for at least random travel - if (!plugin.getTrackerKeeper().getHasDestination().containsKey(id) && tardis.getArtron_level() < plugin.getArtronConfig().getInt("random")) { + if (!plugin.getTrackerKeeper().getHasDestination().containsKey(id) && tardis.getArtronLevel() < plugin.getArtronConfig().getInt("random")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NOT_ENOUGH"); return; } @@ -161,7 +161,7 @@ public void process(int id, int state, Player player, Location handbrake) { } } if (state == 0) { - if (!tardis.isHandbrake_on()) { + if (!tardis.isHandbrakeOn()) { // stop time rotor? if (tardis.getRotor() != null) { if (tardis.getRotor() == TARDISConstants.UUID_ZERO) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerIntraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerIntraction.java index 7f1382fcf..cc2518d5f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerIntraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerIntraction.java @@ -20,7 +20,7 @@ public void process(int id, Player player) { where.put("tardis_id", id); ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); if (rs.resultSet()) { - new TARDISScanner(plugin).scan(id, player, rs.getTardis().getRenderer(), rs.getTardis().getArtron_level()); + new TARDISScanner(plugin).scan(id, player, rs.getTardis().getRenderer(), rs.getTardis().getArtronLevel()); } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlInventory.java b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlInventory.java index 2e72cacdb..cd56a6d38 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlInventory.java @@ -71,13 +71,13 @@ private ItemStack[] getItemStack() { boolean open = false; if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - siege_onoff = (tardis.isSiege_on()) ? on : off; - lights_onoff = (tardis.isLights_on()) ? on : off; - open = new TARDISBlackWoolToggler(plugin).isOpen(tardis.getTardis_id()); + siege_onoff = (tardis.isSiegeOn()) ? on : off; + lights_onoff = (tardis.isLightsOn()) ? on : off; + open = new TARDISBlackWoolToggler(plugin).isOpen(tardis.getTardisId()); toggle_openclosed = (open) ? plugin.getLanguage().getString("SET_OPEN") : plugin.getLanguage().getString("SET_CLOSED"); - power_onoff = (tardis.isPowered_on()) ? on : off; + power_onoff = (tardis.isPoweredOn()) ? on : off; HashMap wheret = new HashMap<>(); - wheret.put("tardis_id", tardis.getTardis_id()); + wheret.put("tardis_id", tardis.getTardisId()); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wheret); if (rsc.resultSet()) { direction = rsc.getDirection().toString(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlListener.java b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlListener.java index ff85b22a2..0cb3f75f3 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlListener.java @@ -125,16 +125,16 @@ public void onControlInteract(PlayerInteractEvent event) { return; } // check they initialised - if (!tardis.isTardis_init()) { + if (!tardis.isTardisInit()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NO_INIT"); return; } // check isomorphic controls - if (tardis.isIso_on() && !player.getUniqueId().equals(tardis.getUuid())) { + if (tardis.isIsomorphicOn() && !player.getUniqueId().equals(tardis.getUuid())) { plugin.getMessenger().send(player, TardisModule.TARDIS, "ISO_HANDS_OFF"); return; } - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on() && !control.allowUnpowered()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn() && !control.allowUnpowered()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return; } @@ -142,8 +142,8 @@ public void onControlInteract(PlayerInteractEvent event) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; } - boolean lights = tardis.isLights_on(); - if (!lights && type == 12 && plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + boolean lights = tardis.isLightsOn(); + if (!lights && type == 12 && plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return; } @@ -181,7 +181,7 @@ public void onControlInteract(PlayerInteractEvent event) { // toggle black wool blocks behind door case 20 -> new TARDISBlackWoolToggler(plugin).toggleBlocks(id, player); // siege lever - case 21 -> new SiegeAction(plugin).clickButton(tcc, player, tardis.isPowered_on(), id); + case 21 -> new SiegeAction(plugin).clickButton(tcc, player, tardis.isPoweredOn(), id); // open control menu GUI case 22 -> { event.setCancelled(true); @@ -197,7 +197,7 @@ public void onControlInteract(PlayerInteractEvent event) { new CustardCreamAction(plugin, player, block, id).dispense(); } // force field - case 29 -> new ForceFieldAction(plugin).toggleSheilds(player, blockLocation, tardis.getArtron_level()); + case 29 -> new ForceFieldAction(plugin).toggleSheilds(player, blockLocation, tardis.getArtronLevel()); // flight mode button case 30 -> new FlightModeAction(plugin).setMode(ownerUUID.toString(), player); // chameleon sign @@ -211,7 +211,7 @@ public void onControlInteract(PlayerInteractEvent event) { } } // scanner - case 33 -> new TARDISScanner(plugin).scan(id, player, tardis.getRenderer(), tardis.getArtron_level()); + case 33 -> new TARDISScanner(plugin).scan(id, player, tardis.getRenderer(), tardis.getArtronLevel()); // cloister bell case 35 -> new CloisterBellAction(plugin).ring(id, tardis); // weather menu diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlMenuListener.java b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlMenuListener.java index 781644d30..08d3a3a90 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlMenuListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlMenuListener.java @@ -105,15 +105,15 @@ public void onControlMenuInteract(InventoryClickEvent event) { } Tardis tardis = rs.getTardis(); // check they initialised - if (!tardis.isTardis_init()) { + if (!tardis.isTardisInit()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NO_INIT"); return; } - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on() && slot != 6 && slot != 13 && slot != 20) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn() && slot != 6 && slot != 13 && slot != 20) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return; } - if (!tardis.isHandbrake_on()) { + if (!tardis.isHandbrakeOn()) { switch (slot) { case 2, 4, 11, 13, 40 -> { if (!plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { @@ -125,8 +125,8 @@ public void onControlMenuInteract(InventoryClickEvent event) { } } } - boolean lights = tardis.isLights_on(); - int level = tardis.getArtron_level(); + boolean lights = tardis.isLightsOn(); + int level = tardis.getArtronLevel(); TARDISCircuitChecker tcc = null; if (!plugin.getDifficulty().equals(Difficulty.EASY)) { tcc = new TARDISCircuitChecker(plugin, id); @@ -226,7 +226,7 @@ public void onControlMenuInteract(InventoryClickEvent event) { // 9 = saves for the TARDIS the player is in // 18 = saves for the player's TARDIS (if they're not in their own) // so, determine player's TARDIS id vs occupied TARDIS id - int whichId = tardis.getTardis_id(); + int whichId = tardis.getTardisId(); if (slot == 18) { ResultSetTardisID tstid = new ResultSetTardisID(plugin); if (tstid.fromUUID(uuid.toString())) { @@ -268,7 +268,7 @@ public void onControlMenuInteract(InventoryClickEvent event) { case 13 -> { // siege close(player, true); - new SiegeAction(plugin).clickButton(tcc, player, tardis.isPowered_on(), id); + new SiegeAction(plugin).clickButton(tcc, player, tardis.isPoweredOn(), id); } case 15 -> { // scanner @@ -289,7 +289,7 @@ public void onControlMenuInteract(InventoryClickEvent event) { return; } close(player, true); - new TARDISPowerButton(plugin, id, player, tardis.getPreset(), tardis.isPowered_on(), tardis.isHidden(), lights, player.getLocation(), level, tardis.getSchematic().getLights()).clickButton(); + new TARDISPowerButton(plugin, id, player, tardis.getPreset(), tardis.isPoweredOn(), tardis.isHidden(), lights, player.getLocation(), level, tardis.getSchematic().getLights()).clickButton(); } else { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN_DISABLED"); } @@ -348,7 +348,7 @@ public void onControlMenuInteract(InventoryClickEvent event) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; } - if (!lights && plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (!lights && plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/ARSAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/ARSAction.java index d1f033387..3fab6e82f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/actions/ARSAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/ARSAction.java @@ -20,7 +20,7 @@ public ARSAction(TARDIS plugin) { } public void openGUI(Player player, Tardis tardis, TARDISCircuitChecker tcc, int id) { - if (!tardis.isHandbrake_on()) { + if (!tardis.isHandbrakeOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "ARS_NO_TRAVEL"); return; } @@ -40,7 +40,7 @@ public void openGUI(Player player, Tardis tardis, TARDISCircuitChecker tcc, int return; } // upgrade menu - new TARDISThemeButton(plugin, player, tardis.getSchematic(), tardis.getArtron_level(), id).clickButton(); + new TARDISThemeButton(plugin, player, tardis.getSchematic(), tardis.getArtronLevel(), id).clickButton(); } else { // check they have permission to grow rooms if (!TARDISPermission.hasPermission(player, "tardis.architectural")) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/FastReturnAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/FastReturnAction.java index a709c3f55..cbe7c7f61 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/actions/FastReturnAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/FastReturnAction.java @@ -41,7 +41,7 @@ public FastReturnAction(TARDIS plugin) { } public void clickButton(Player player, int id, Tardis tardis) { - if (plugin.getTrackerKeeper().getMaterialising().contains(id) || plugin.getTrackerKeeper().getDematerialising().contains(id) || (!tardis.isHandbrake_on() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) || plugin.getTrackerKeeper().getHasRandomised().contains(id)) { + if (plugin.getTrackerKeeper().getMaterialising().contains(id) || plugin.getTrackerKeeper().getDematerialising().contains(id) || (!tardis.isHandbrakeOn() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) || plugin.getTrackerKeeper().getHasRandomised().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_WHILE_TRAVELLING"); return; } @@ -49,7 +49,7 @@ public void clickButton(Player player, int id, Tardis tardis) { plugin.getTrackerKeeper().getHasRandomised().add(id); } int cost = plugin.getArtronConfig().getInt("travel"); - if (tardis.getArtron_level() < cost) { + if (tardis.getArtronLevel() < cost) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_ENOUGH_ENERGY"); return; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/RandomAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/RandomAction.java index a94224526..4b45d43ae 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/actions/RandomAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/RandomAction.java @@ -24,13 +24,13 @@ public void process(Set cooldown, Player player, int id, Tardis tardis, in } cooldown.add(player.getUniqueId()); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> cooldown.remove(player.getUniqueId()), 60L); - if (plugin.getTrackerKeeper().getMaterialising().contains(id) || plugin.getTrackerKeeper().getDematerialising().contains(id) || (!tardis.isHandbrake_on() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) || plugin.getTrackerKeeper().getHasRandomised().contains(id)) { + if (plugin.getTrackerKeeper().getMaterialising().contains(id) || plugin.getTrackerKeeper().getDematerialising().contains(id) || (!tardis.isHandbrakeOn() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) || plugin.getTrackerKeeper().getHasRandomised().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_WHILE_TRAVELLING"); return; } if (plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { plugin.getTrackerKeeper().getHasRandomised().add(id); } - new TARDISRandomButton(plugin, player, id, tardis.getArtron_level(), secondary, tardis.getCompanions(), tardis.getUuid()).clickButton(); + new TARDISRandomButton(plugin, player, id, tardis.getArtronLevel(), secondary, tardis.getCompanions(), tardis.getUuid()).clickButton(); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/TerminalAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/TerminalAction.java index 73fd52695..110ae7f5e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/actions/TerminalAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/TerminalAction.java @@ -23,14 +23,14 @@ public TerminalAction(TARDIS plugin) { } public void openGUI(Player player, int id, Tardis tardis, TARDISCircuitChecker tcc) { - if (plugin.getTrackerKeeper().getMaterialising().contains(id) || plugin.getTrackerKeeper().getDematerialising().contains(id) || (!tardis.isHandbrake_on() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) || plugin.getTrackerKeeper().getHasRandomised().contains(id)) { + if (plugin.getTrackerKeeper().getMaterialising().contains(id) || plugin.getTrackerKeeper().getDematerialising().contains(id) || (!tardis.isHandbrakeOn() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) || plugin.getTrackerKeeper().getHasRandomised().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_WHILE_TRAVELLING"); return; } if (plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { plugin.getTrackerKeeper().getHasRandomised().add(id); } - if (tardis.getArtron_level() < plugin.getArtronConfig().getInt("travel")) { + if (tardis.getArtronLevel() < plugin.getArtronConfig().getInt("travel")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_ENOUGH_ENERGY"); return; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/ZeroRoomAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/ZeroRoomAction.java index f61a54e3f..2198e2b4f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/actions/ZeroRoomAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/ZeroRoomAction.java @@ -24,7 +24,7 @@ public ZeroRoomAction(TARDIS plugin) { public void doEntry(Player player, Tardis tardis, int id) { // enter zero room int zero_amount = plugin.getArtronConfig().getInt("zero"); - if (tardis.getArtron_level() < zero_amount) { + if (tardis.getArtronLevel() < zero_amount) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_ENOUGH_ZERO_ENERGY"); return; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockConverter.java b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockConverter.java index e2c4d429e..b0a6bd31b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockConverter.java +++ b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockConverter.java @@ -68,7 +68,7 @@ public void run() { startx = pos.getCentreX(); startz = pos.getCentreZ(); } else { - int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardis_id()); + int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardisId()); startx = gsl[0]; startz = gsl[2]; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java index e920de87b..347cf0d0c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java @@ -302,7 +302,7 @@ public void onInteractionClick(PlayerInteractAtEntityEvent event) { return; } Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); new UpdateDoor(plugin).process(Updateable.DOOR, block, false, id, player); plugin.getTrackerKeeper().getUpdatePlayers().remove(playerUUID); TARDISSudoTracker.SUDOERS.remove(playerUUID); diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/data/Tardis.java b/src/main/java/me/eccentric_nz/TARDIS/database/data/Tardis.java index 38c2e0a55..5961c8ec2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/data/Tardis.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/data/Tardis.java @@ -16,13 +16,14 @@ */ package me.eccentric_nz.TARDIS.database.data; -import java.util.UUID; import me.eccentric_nz.TARDIS.enumeration.Adaption; import me.eccentric_nz.TARDIS.enumeration.ChameleonPreset; import me.eccentric_nz.TARDIS.enumeration.Schematic; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import java.util.UUID; + /** * @author eccentric_nz */ @@ -101,7 +102,7 @@ public Tardis(int tardis_id, UUID uuid, String owner, String lastKnownName, Stri * * @return the TARDIS id */ - public int getTardis_id() { + public int getTardisId() { return tardis_id; } @@ -234,7 +235,7 @@ public Adaption getAdaption() { * * @return the Artron Energy level */ - public int getArtron_level() { + public int getArtronLevel() { return artron_level; } @@ -263,7 +264,7 @@ public String getBeacon() { * * @return true if on, false if off */ - public boolean isHandbrake_on() { + public boolean isHandbrakeOn() { return handbrake_on; } @@ -272,7 +273,7 @@ public boolean isHandbrake_on() { * * @return true if initialized, false if not */ - public boolean isTardis_init() { + public boolean isTardisInit() { return tardis_init; } @@ -308,7 +309,7 @@ public long getLastuse() { * * @return true if on, false if off */ - public boolean isIso_on() { + public boolean isIsomorphicOn() { return iso_on; } @@ -367,7 +368,7 @@ public UUID getRotor() { * * @return true if powered on, false if off */ - public boolean isPowered_on() { + public boolean isPoweredOn() { return powered_on; } @@ -376,7 +377,7 @@ public boolean isPowered_on() { * * @return true if on, false if off */ - public boolean isLights_on() { + public boolean isLightsOn() { return lights_on; } @@ -385,7 +386,7 @@ public boolean isLights_on() { * * @return true if Siege Mode is on, false if off */ - public boolean isSiege_on() { + public boolean isSiegeOn() { return siege_on; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISArchiveMenuListener.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISArchiveMenuListener.java index 0b223f406..5259dfc53 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISArchiveMenuListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISArchiveMenuListener.java @@ -79,7 +79,7 @@ public void onThemeMenuClick(InventoryClickEvent event) { Tardis tardis = rs.getTardis(); // return to Desktop Theme GUI close(p); - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new TARDISThemeButton(plugin, p, tardis.getSchematic(), tardis.getArtron_level(), tardis.getTardis_id()).clickButton(), 2L); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new TARDISThemeButton(plugin, p, tardis.getSchematic(), tardis.getArtronLevel(), tardis.getTardisId()).clickButton(), 2L); } case 18 -> { // size diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISDelavafier.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISDelavafier.java index ffb430f57..60d94cbe5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISDelavafier.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISDelavafier.java @@ -60,7 +60,7 @@ void swap() { startx = pos.getCentreX(); startz = pos.getCentreZ(); } else { - int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardis_id()); + int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardisId()); startx = gsl[0]; startz = gsl[2]; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java index b737af570..30296d984 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java @@ -213,7 +213,7 @@ public void run() { } Tardis tardis = rs.getTardis(); slot = tardis.getTIPS(); - id = tardis.getTardis_id(); + id = tardis.getTardisId(); chunk = TARDISStaticLocationGetters.getChunk(tardis.getChunk()); if (tud.getPrevious().getPermission().equals("ender")) { // remove ender crystal @@ -272,7 +272,7 @@ public void run() { startz = pos.getCentreZ(); resetz = pos.getCentreZ(); } else { - int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardis_id()); + int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardisId()); startx = gsl[0]; resetx = gsl[1]; startz = gsl[2]; diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISRepair.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISRepair.java index f506999e8..825a0bfe7 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISRepair.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISRepair.java @@ -111,7 +111,7 @@ boolean hasCondensedMissingBlocks() { if (rs.resultSet()) { Tardis tardis = rs.getTardis(); int slot = tardis.getTIPS(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); int startx, startz; if (slot != -1000001) { // default world - use TIPS TARDISInteriorPostioning tintpos = new TARDISInteriorPostioning(plugin); @@ -119,7 +119,7 @@ boolean hasCondensedMissingBlocks() { startx = pos.getCentreX(); startz = pos.getCentreZ(); } else { - int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardis_id()); + int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardisId()); startx = gsl[0]; startz = gsl[2]; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeProcessor.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeProcessor.java index ed1a02f31..5f9ed588d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeProcessor.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeProcessor.java @@ -62,7 +62,7 @@ public void changeDesktop() { // check if the player has a Handles placed HashMap whereh = new HashMap<>(); whereh.put("type", 26); - whereh.put("tardis_id", tardis.getTardis_id()); + whereh.put("tardis_id", tardis.getTardisId()); ResultSetControls rsc = new ResultSetControls(plugin, whereh, false); if (rsc.resultSet()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPGRADE_REMOVE_HANDLES"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java index 6fbfb4a3f..9eae7cf05 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java @@ -158,7 +158,7 @@ public void run() { } Tardis tardis = rs.getTardis(); slot = tardis.getTIPS(); - id = tardis.getTardis_id(); + id = tardis.getTardisId(); Chunk chunk = TARDISStaticLocationGetters.getChunk(tardis.getChunk()); if (tud.getPrevious().getPermission().equals("ender")) { // remove ender crystal @@ -211,7 +211,7 @@ public void run() { startz = pos.getCentreZ(); resetz = pos.getCentreZ(); } else { - int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardis_id()); + int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardisId()); startx = gsl[0]; resetx = gsl[1]; startz = gsl[2]; diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISUpgradeBlockScanner.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISUpgradeBlockScanner.java index 31531bd74..8d61d4663 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISUpgradeBlockScanner.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISUpgradeBlockScanner.java @@ -80,7 +80,7 @@ public TARDISBlockScannerData check() { startx = pos.getCentreX(); startz = pos.getCentreZ(); } else { - int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardis_id()); + int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardisId()); startx = gsl[0]; startz = gsl[2]; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISWallFloorRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISWallFloorRunnable.java index 047249ed7..1e135b889 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISWallFloorRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISWallFloorRunnable.java @@ -106,7 +106,7 @@ public void run() { startx = pos.getCentreX(); startz = pos.getCentreZ(); } else { - int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardis_id()); + int[] gsl = plugin.getLocationUtils().getStartLocation(tardis.getTardisId()); startx = gsl[0]; startz = gsl[2]; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/destroyers/TARDISExterminator.java b/src/main/java/me/eccentric_nz/TARDIS/destroyers/TARDISExterminator.java index e0f95d2e1..31642004f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/destroyers/TARDISExterminator.java +++ b/src/main/java/me/eccentric_nz/TARDIS/destroyers/TARDISExterminator.java @@ -134,7 +134,7 @@ public boolean playerExterminate(Player player) { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); // check that the player is not currently in their TARDIS HashMap travid = new HashMap<>(); travid.put("tardis_id", id); diff --git a/src/main/java/me/eccentric_nz/TARDIS/doors/DisplayItemDoorMover.java b/src/main/java/me/eccentric_nz/TARDIS/doors/DisplayItemDoorMover.java index 8588fe7f7..5e6c0b32a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/doors/DisplayItemDoorMover.java +++ b/src/main/java/me/eccentric_nz/TARDIS/doors/DisplayItemDoorMover.java @@ -74,16 +74,16 @@ public void exit(Player player, Block block) { ResultSetTardis rs = new ResultSetTardis(plugin, tid, "", false, 2); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - if (!tardis.isHandbrake_on()) { + if (!tardis.isHandbrakeOn()) { plugin.getMessenger().sendStatus(player, "HANDBRAKE_ENGAGE"); return; } ChameleonPreset preset = tardis.getPreset(); float yaw = player.getLocation().getYaw(); float pitch = player.getLocation().getPitch(); - boolean hb = tardis.isHandbrake_on(); + boolean hb = tardis.isHandbrakeOn(); HashMap wherecl = new HashMap<>(); - wherecl.put("tardis_id", tardis.getTardis_id()); + wherecl.put("tardis_id", tardis.getTardisId()); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherecl); if (!rsc.resultSet()) { // emergency TARDIS relocation diff --git a/src/main/java/me/eccentric_nz/TARDIS/doors/DisplayItemDoorToggler.java b/src/main/java/me/eccentric_nz/TARDIS/doors/DisplayItemDoorToggler.java index ea9efe7a5..2ef0a1493 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/doors/DisplayItemDoorToggler.java +++ b/src/main/java/me/eccentric_nz/TARDIS/doors/DisplayItemDoorToggler.java @@ -67,7 +67,7 @@ public void openClose(Player player, Block block, boolean close, TARDISDisplayIt tid.put("tardis_id", id); ResultSetTardis rs = new ResultSetTardis(plugin, tid, "", false, 2); if (rs.resultSet()) { - if (!rs.getTardis().isHandbrake_on()) { + if (!rs.getTardis().isHandbrakeOn()) { plugin.getMessenger().sendStatus(player, "HANDBRAKE_ENGAGE"); return; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/doors/DoorToggleAction.java b/src/main/java/me/eccentric_nz/TARDIS/doors/DoorToggleAction.java index 25dff73de..4ad674f10 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/doors/DoorToggleAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/doors/DoorToggleAction.java @@ -74,7 +74,7 @@ public boolean openClose(int id, Player player, ArmorStand stand) { ResultSetTardis rs = new ResultSetTardis(plugin, tid, "", false, 2); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - if (!tardis.isHandbrake_on()) { + if (!tardis.isHandbrakeOn()) { plugin.getMessenger().sendStatus(player, "HANDBRAKE_ENGAGE"); return true; } @@ -140,9 +140,9 @@ public boolean openClose(int id, Player player, ArmorStand stand) { new TARDISFollowerSpawner(plugin).spawn(petsAndFollowers.getFollowers(), tardis_loc, player, d, true); } } - if (canPowerUp && !tardis.isPowered_on() && !tardis.isAbandoned()) { + if (canPowerUp && !tardis.isPoweredOn() && !tardis.isAbandoned()) { // power up the TARDIS - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new TARDISPowerButton(plugin, id, player, tardis.getPreset(), false, tardis.isHidden(), tardis.isLights_on(), player.getLocation(), tardis.getArtron_level(), tardis.getSchematic().getLights()).clickButton(), 20L); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new TARDISPowerButton(plugin, id, player, tardis.getPreset(), false, tardis.isHidden(), tardis.isLightsOn(), player.getLocation(), tardis.getArtronLevel(), tardis.getSchematic().getLights()).clickButton(), 20L); } // put player into travellers table // remove them first as they may have exited incorrectly, and we only want them listed once @@ -199,7 +199,7 @@ public boolean openClose(int id, Player player, ArmorStand stand) { set.put("chameleon_preset", c); set.put("chameleon_demat", c); HashMap wheret = new HashMap<>(); - wheret.put("tardis_id", tardis.getTardis_id()); + wheret.put("tardis_id", tardis.getTardisId()); plugin.getQueryFactory().doUpdate("tardis", set, wheret); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISHandbrakeListener.java b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISHandbrakeListener.java index 81dd67de7..36eb2493a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISHandbrakeListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISHandbrakeListener.java @@ -138,12 +138,12 @@ public void onInteract(PlayerInteractEvent event) { return; } UUID ownerUUID = tardis.getUuid(); - if ((tardis.isIso_on() && !uuid.equals(ownerUUID) && event.useInteractedBlock().equals(Event.Result.DENY) && !TARDISPermission.hasPermission(player, "tardis.skeletonkey")) || plugin.getTrackerKeeper().getJohnSmith().containsKey(uuid)) { + if ((tardis.isIsomorphicOn() && !uuid.equals(ownerUUID) && event.useInteractedBlock().equals(Event.Result.DENY) && !TARDISPermission.hasPermission(player, "tardis.skeletonkey")) || plugin.getTrackerKeeper().getJohnSmith().containsKey(uuid)) { // check if cancelled, so we don't get double messages from the bind listener plugin.getMessenger().send(player, TardisModule.TARDIS, "ISO_HANDS_OFF"); return; } - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return; } @@ -163,13 +163,13 @@ public void onInteract(PlayerInteractEvent event) { spaceTimeThrottle = SpaceTimeThrottle.getByDelay().get(rsp.getThrottle()); } if (action == Action.RIGHT_CLICK_BLOCK) { - if (tardis.isHandbrake_on()) { + if (tardis.isHandbrakeOn()) { if (preset.equals(ChameleonPreset.JUNK_MODE) && !plugin.getTrackerKeeper().getHasDestination().containsKey(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "TRAVEL_NEED_DEST"); return; } // check there is enough power for at least random travel - if (!plugin.getTrackerKeeper().getHasDestination().containsKey(id) && tardis.getArtron_level() < plugin.getArtronConfig().getInt("random")) { + if (!plugin.getTrackerKeeper().getHasDestination().containsKey(id) && tardis.getArtronLevel() < plugin.getArtronConfig().getInt("random")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NOT_ENOUGH"); return; } @@ -226,7 +226,7 @@ public void onInteract(PlayerInteractEvent event) { } } if (action == Action.LEFT_CLICK_BLOCK) { - if (!tardis.isHandbrake_on()) { + if (!tardis.isHandbrakeOn()) { // stop time rotor? if (tardis.getRotor() != null) { if (tardis.getRotor() == TARDISConstants.UUID_ZERO) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateAddCompanionsForm.java b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateAddCompanionsForm.java index 8c7b27fa0..c1f8cf5b1 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateAddCompanionsForm.java +++ b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateAddCompanionsForm.java @@ -62,7 +62,7 @@ private void handleResponse(SimpleFormResponse response) { ResultSetTardis rsa = new ResultSetTardis(plugin, wherea, "", false, 0); if (rsa.resultSet()) { Tardis tardis = rsa.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); String comps = tardis.getCompanions(); if (label.equals("Everyone")) { TARDISCompanionAddGUIListener.addCompanion(id, comps, "everyone"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateCompanionsForm.java b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateCompanionsForm.java index 3498f3c50..59ef786ee 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateCompanionsForm.java +++ b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateCompanionsForm.java @@ -66,7 +66,7 @@ private void handleResponse(SimpleFormResponse response) { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); String comps = tardis.getCompanions(); // get UUID for offline player OfflinePlayer op = plugin.getServer().getOfflinePlayer(label); diff --git a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateControlForm.java b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateControlForm.java index 568ab2133..2eb8f77ae 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateControlForm.java +++ b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateControlForm.java @@ -95,15 +95,15 @@ private void handleResponse(SimpleFormResponse response) { if (rs.resultSet()) { Tardis tardis = rs.getTardis(); // check they initialised - if (!tardis.isTardis_init()) { + if (!tardis.isTardisInit()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NO_INIT"); return; } - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on() && buttonId != 7 && buttonId != 12 && buttonId != 17) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn() && buttonId != 7 && buttonId != 12 && buttonId != 17) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return; } - if (!tardis.isHandbrake_on()) { + if (!tardis.isHandbrakeOn()) { switch (buttonId) { case 5 -> { plugin.getMessenger().send(player, TardisModule.TARDIS, "ARS_NO_TRAVEL"); @@ -118,8 +118,8 @@ private void handleResponse(SimpleFormResponse response) { default -> {} } } - boolean lights = tardis.isLights_on(); - int level = tardis.getArtron_level(); + boolean lights = tardis.isLightsOn(); + int level = tardis.getArtronLevel(); TARDISCircuitChecker tcc = null; if (!plugin.getDifficulty().equals(Difficulty.EASY)) { tcc = new TARDISCircuitChecker(plugin, id); @@ -233,7 +233,7 @@ private void handleResponse(SimpleFormResponse response) { } case 7 -> { // power if (plugin.getConfig().getBoolean("allow.power_down")) { - new TARDISPowerButton(plugin, id, player, tardis.getPreset(), tardis.isPowered_on(), tardis.isHidden(), lights, player.getLocation(), level, tardis.getSchematic().getLights()).clickButton(); + new TARDISPowerButton(plugin, id, player, tardis.getPreset(), tardis.isPoweredOn(), tardis.isHidden(), lights, player.getLocation(), level, tardis.getSchematic().getLights()).clickButton(); } else { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN_DISABLED"); } @@ -243,7 +243,7 @@ private void handleResponse(SimpleFormResponse response) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; } - if (!lights && plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (!lights && plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return; } @@ -273,7 +273,7 @@ private void handleResponse(SimpleFormResponse response) { new FloodgateChameleonCircuitForm(plugin, uuid, id, tardis.getPreset()).send(); } case 12 -> { // siege mode - new SiegeAction(plugin).clickButton(tcc, player, tardis.isPowered_on(), id); + new SiegeAction(plugin).clickButton(tcc, player, tardis.isPoweredOn(), id); } case 13 -> { // hide if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateWeatherForm.java b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateWeatherForm.java index 176bfc65a..c58757f25 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateWeatherForm.java +++ b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateWeatherForm.java @@ -60,21 +60,21 @@ private void handleResponse(SimpleFormResponse response) { if (rs.resultSet()) { Tardis tardis = rs.getTardis(); // check they initialised - if (!tardis.isTardis_init()) { + if (!tardis.isTardisInit()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NO_INIT"); return; } - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return; } - if (!tardis.isHandbrake_on()) { + if (!tardis.isHandbrakeOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_WHILE_TRAVELLING"); return; } // get current location HashMap wherec = new HashMap<>(); - wherec.put("tardis_id", tardis.getTardis_id()); + wherec.put("tardis_id", tardis.getTardisId()); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherec); if (!rsc.resultSet()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "CURRENT_NOT_FOUND"); @@ -85,7 +85,7 @@ private void handleResponse(SimpleFormResponse response) { plugin.getMessenger().send(player, TardisModule.TARDIS, "CMD_EXCITE"); return; } - new TARDISAtmosphericExcitation(plugin).excite(tardis.getTardis_id(), player); + new TARDISAtmosphericExcitation(plugin).excite(tardis.getTardisId(), player); plugin.getTrackerKeeper().getExcitation().add(player.getUniqueId()); } else { // change weather diff --git a/src/main/java/me/eccentric_nz/TARDIS/hads/TARDISHostileAction.java b/src/main/java/me/eccentric_nz/TARDIS/hads/TARDISHostileAction.java index babc38591..6671e78ab 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/hads/TARDISHostileAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/hads/TARDISHostileAction.java @@ -48,7 +48,7 @@ public void processAction(int id, Player hostile) { if (rs.resultSet()) { Tardis tardis = rs.getTardis(); UUID uuid = tardis.getUuid(); - boolean poweredOn = tardis.isPowered_on(); + boolean poweredOn = tardis.isPoweredOn(); ChameleonPreset preset = tardis.getPreset(); ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, uuid.toString()); if (rsp.resultSet()) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/handles/TARDISHandlesProcessor.java b/src/main/java/me/eccentric_nz/TARDIS/handles/TARDISHandlesProcessor.java index 83c35cae4..47b4897dc 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/handles/TARDISHandlesProcessor.java +++ b/src/main/java/me/eccentric_nz/TARDIS/handles/TARDISHandlesProcessor.java @@ -116,7 +116,7 @@ void processCommand(int pos) { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 2); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); switch (thb) { case DOOR -> { switch (next) { @@ -147,23 +147,23 @@ void processCommand(int pos) { } case LIGHTS -> { boolean onoff = next.equals(TARDISHandlesBlock.ON); - if ((onoff && !tardis.isLights_on()) || (!onoff && tardis.isLights_on())) { + if ((onoff && !tardis.isLightsOn()) || (!onoff && tardis.isLightsOn())) { new TARDISLampToggler(plugin).flickSwitch(id, uuid, onoff, tardis.getSchematic().getLights()); } } case POWER -> { switch (next) { case ON -> { - if (!tardis.isPowered_on()) { + if (!tardis.isPoweredOn()) { if (plugin.getConfig().getBoolean("allow.power_down")) { - new TARDISPowerButton(plugin, id, player, tardis.getPreset(), false, tardis.isHidden(), tardis.isLights_on(), player.getLocation(), tardis.getArtron_level(), tardis.getSchematic().getLights()).clickButton(); + new TARDISPowerButton(plugin, id, player, tardis.getPreset(), false, tardis.isHidden(), tardis.isLightsOn(), player.getLocation(), tardis.getArtronLevel(), tardis.getSchematic().getLights()).clickButton(); } } } case OFF -> { - if (tardis.isPowered_on()) { + if (tardis.isPoweredOn()) { if (plugin.getConfig().getBoolean("allow.power_down")) { - new TARDISPowerButton(plugin, id, player, tardis.getPreset(), true, tardis.isHidden(), tardis.isLights_on(), player.getLocation(), tardis.getArtron_level(), tardis.getSchematic().getLights()).clickButton(); + new TARDISPowerButton(plugin, id, player, tardis.getPreset(), true, tardis.isHidden(), tardis.isLightsOn(), player.getLocation(), tardis.getArtronLevel(), tardis.getSchematic().getLights()).clickButton(); } } } @@ -189,7 +189,7 @@ void processCommand(int pos) { } } case SIEGE -> { - if ((next.equals(TARDISHandlesBlock.ON) && !tardis.isSiege_on()) || (next.equals(TARDISHandlesBlock.OFF) && tardis.isSiege_on())) { + if ((next.equals(TARDISHandlesBlock.ON) && !tardis.isSiegeOn()) || (next.equals(TARDISHandlesBlock.OFF) && tardis.isSiegeOn())) { new TARDISSiegeMode(plugin).toggleViaSwitch(id, player); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/handles/TARDISHandlesRequest.java b/src/main/java/me/eccentric_nz/TARDIS/handles/TARDISHandlesRequest.java index e5aefdb79..615aa575b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/handles/TARDISHandlesRequest.java +++ b/src/main/java/me/eccentric_nz/TARDIS/handles/TARDISHandlesRequest.java @@ -210,8 +210,8 @@ public void process(UUID uuid, String chat) { ResultSetTardis rst = new ResultSetTardis(plugin, wherel, "", false, 2); if (rst.resultSet()) { Tardis tardis = rst.getTardis(); - if ((onoff && !tardis.isLights_on()) || (!onoff && tardis.isLights_on())) { - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new LightSwitchAction(plugin, id, tardis.isLights_on(), player, tardis.getSchematic().getLights()).flickSwitch(), 1L); + if ((onoff && !tardis.isLightsOn()) || (!onoff && tardis.isLightsOn())) { + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new LightSwitchAction(plugin, id, tardis.isLightsOn(), player, tardis.getSchematic().getLights()).flickSwitch(), 1L); } } } @@ -225,9 +225,9 @@ public void process(UUID uuid, String chat) { ResultSetTardis rst = new ResultSetTardis(plugin, wherel, "", false, 2); if (rst.resultSet()) { Tardis tardis = rst.getTardis(); - if ((onoff && tardis.isPowered_on()) || (!onoff && !tardis.isPowered_on())) { + if ((onoff && tardis.isPoweredOn()) || (!onoff && !tardis.isPoweredOn())) { if (plugin.getConfig().getBoolean("allow.power_down")) { - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new TARDISPowerButton(plugin, id, player, tardis.getPreset(), tardis.isPowered_on(), tardis.isHidden(), tardis.isLights_on(), player.getLocation(), tardis.getArtron_level(), tardis.getSchematic().getLights()).clickButton(), 1L); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new TARDISPowerButton(plugin, id, player, tardis.getPreset(), tardis.isPoweredOn(), tardis.isHidden(), tardis.isLightsOn(), player.getLocation(), tardis.getArtronLevel(), tardis.getSchematic().getLights()).clickButton(), 1L); } } } @@ -257,7 +257,7 @@ public void process(UUID uuid, String chat) { ResultSetTardis rsr = new ResultSetTardis(plugin, wherel, "", false, 2); if (rsr.resultSet()) { Tardis tardis = rsr.getTardis(); - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new TARDISRandomButton(plugin, player, id, tardis.getArtron_level(), 0, tardis.getCompanions(), tardis.getUuid()).clickButton(), 1L); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new TARDISRandomButton(plugin, player, id, tardis.getArtronLevel(), 0, tardis.getCompanions(), tardis.getUuid()).clickButton(), 1L); return; } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISBindListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISBindListener.java index 56050a060..59afdd97a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISBindListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISBindListener.java @@ -123,16 +123,16 @@ public void onInteract(PlayerInteractEvent event) { whereb.put("location", l); ResultSetBind rsb = new ResultSetBind(plugin, whereb); if (rsb.resultSet()) { - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return; } - if ((tardis.isIso_on() && !player.getUniqueId().equals(ownerUUID) && !event.useInteractedBlock().equals(Event.Result.DENY)) || plugin.getTrackerKeeper().getJohnSmith().containsKey(player.getUniqueId())) { + if ((tardis.isIsomorphicOn() && !player.getUniqueId().equals(ownerUUID) && !event.useInteractedBlock().equals(Event.Result.DENY)) || plugin.getTrackerKeeper().getJohnSmith().containsKey(player.getUniqueId())) { plugin.getMessenger().send(player, TardisModule.TARDIS, "ISO_HANDS_OFF"); return; } int type = rsb.getType(); - if (type != 6 && !tardis.isHandbrake_on() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { + if (type != 6 && !tardis.isHandbrakeOn() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_WHILE_TRAVELLING"); return; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISJoinListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISJoinListener.java index 4ccd4c7d5..89079f2b6 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISJoinListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISJoinListener.java @@ -139,7 +139,7 @@ public void onJoin(PlayerJoinEvent event) { ResultSetTardis rs = new ResultSetTardis(plugin, wherep, "", false, 0); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); String owner = tardis.getOwner(); String last_known_name = tardis.getLastKnownName(); HashMap wherecl = new HashMap<>(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISLightningListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISLightningListener.java index 172d14ead..1a8be74a7 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISLightningListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISLightningListener.java @@ -16,7 +16,6 @@ */ package me.eccentric_nz.TARDIS.listeners; -import java.util.HashMap; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.database.data.Tardis; import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentLocation; @@ -29,6 +28,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.weather.LightningStrikeEvent; +import java.util.HashMap; + /** * Artron energy is vital in the running of a TARDIS; it can run low and when down to 10% it means even backup power is * unavailable, as this requires artron energy as well. @@ -61,7 +62,7 @@ public void onLightningStrike(LightningStrikeEvent e) { if (rs.resultSet()) { for (Tardis t : rs.getData()) { boolean charging = !t.isRecharging(); - int id = t.getTardis_id(); + int id = t.getTardisId(); if (plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { return; } @@ -75,7 +76,7 @@ public void onLightningStrike(LightningStrikeEvent e) { Location loc = new Location(w, rsc.getX(), rsc.getY(), rsc.getZ()); // only recharge if the TARDIS is within range if (plugin.getUtils().compareLocations(loc, loc)) { - int amount = plugin.getArtronConfig().getInt("lightning_recharge") + t.getArtron_level(); + int amount = plugin.getArtronConfig().getInt("lightning_recharge") + t.getArtronLevel(); HashMap set = new HashMap<>(); set.put("artron_level", amount); HashMap where = new HashMap<>(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISMinecartListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISMinecartListener.java index 08e3d26f0..b7454ab10 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISMinecartListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISMinecartListener.java @@ -104,7 +104,7 @@ public void onVehicleBlockCollision(VehicleBlockCollisionEvent event) { if (rsp.resultSet()) { Tardis tardis = rsp.getTardis(); playerUUID = tardis.getUuid(); - id = tardis.getTardis_id(); + id = tardis.getTardisId(); HashMap whereinner = new HashMap<>(); whereinner.put("tardis_id", id); whereinner.put("door_type", 1); diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISQuitListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISQuitListener.java index 4511ceda4..0c532018c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISQuitListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISQuitListener.java @@ -80,7 +80,7 @@ public void onPlayerQuit(PlayerQuitEvent event) { if (rs.resultSet()) { Tardis tardis = rs.getTardis(); HashMap wherecl = new HashMap<>(); - wherecl.put("tardis_id", tardis.getTardis_id()); + wherecl.put("tardis_id", tardis.getTardisId()); if (plugin.getConfig().getBoolean("police_box.keep_chunk_force_loaded")) { ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherecl); if (rsc.resultSet()) { @@ -94,16 +94,16 @@ public void onPlayerQuit(PlayerQuitEvent event) { // power down TARDIS if (plugin.getConfig().getBoolean("allow.power_down") && plugin.getConfig().getBoolean("allow.power_down_on_quit")) { // check if powered on - if (tardis.isPowered_on()) { + if (tardis.isPoweredOn()) { // not if flying or uninitialised - int id = tardis.getTardis_id(); - if (!tardis.isTardis_init() || isTravelling(id) || !tardis.isHandbrake_on()) { + int id = tardis.getTardisId(); + if (!tardis.isTardisInit() || isTravelling(id) || !tardis.isHandbrakeOn()) { return; } // power off ChameleonPreset preset = tardis.getPreset(); boolean hidden = tardis.isHidden(); - boolean lights = tardis.isLights_on(); + boolean lights = tardis.isLightsOn(); // police box lamp, delay it incase the TARDIS needs rebuilding long delay = 1L; // if hidden, rebuild diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISRemoteKeyListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISRemoteKeyListener.java index f1acef021..d756f515f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISRemoteKeyListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISRemoteKeyListener.java @@ -83,8 +83,8 @@ public void onInteract(PlayerInteractEvent event) { return; } Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); - boolean powered = tardis.isPowered_on(); + int id = tardis.getTardisId(); + boolean powered = tardis.isPoweredOn(); ChameleonPreset preset = tardis.getPreset(); if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISStattenheimListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISStattenheimListener.java index e83a7ae0f..5092840d6 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISStattenheimListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISStattenheimListener.java @@ -98,7 +98,7 @@ public void onStattenheimInteract(PlayerInteractEvent event) { return; } Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; @@ -107,7 +107,7 @@ public void onStattenheimInteract(PlayerInteractEvent event) { plugin.getMessenger().send(player.getPlayer(), TardisModule.TARDIS, "NOT_WHILE_DISPERSED"); return; } - boolean power = tardis.isPowered_on(); + boolean power = tardis.isPoweredOn(); if (action.equals(Action.RIGHT_CLICK_BLOCK)) { Block b = event.getClickedBlock(); Material m = b.getType(); @@ -158,7 +158,7 @@ public void onStattenheimInteract(PlayerInteractEvent event) { return; } boolean hidden = tardis.isHidden(); - int level = tardis.getArtron_level(); + int level = tardis.getArtronLevel(); // check they are not in the tardis HashMap wherettrav = new HashMap<>(); wherettrav.put("uuid", uuid.toString()); @@ -174,7 +174,7 @@ public void onStattenheimInteract(PlayerInteractEvent event) { } // get TARDIS's current location HashMap wherecl = new HashMap<>(); - wherecl.put("tardis_id", tardis.getTardis_id()); + wherecl.put("tardis_id", tardis.getTardisId()); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherecl); if (!rsc.resultSet()) { hidden = true; @@ -312,7 +312,7 @@ public void onStattenheimInteract(PlayerInteractEvent event) { setp.put("powered_on", 1); plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_ON"); // if lights are off, turn them on - if (tardis.isLights_on()) { + if (tardis.isLightsOn()) { new TARDISLampToggler(plugin).flickSwitch(id, uuid, false, tardis.getSchematic().getLights()); } // if beacon is off turn it on diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISTimeLordDeathListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISTimeLordDeathListener.java index 8835a3399..81021c084 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISTimeLordDeathListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISTimeLordDeathListener.java @@ -90,21 +90,21 @@ public void onTimeLordDeath(PlayerDeathEvent event) { // are they a time lord? if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - if (tardis.isPowered_on()) { - int id = tardis.getTardis_id(); + if (tardis.isPoweredOn()) { + int id = tardis.getTardisId(); String eps = tardis.getEps(); String creeper = tardis.getCreeper(); ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, uuid.toString()); if (rsp.resultSet()) { SpaceTimeThrottle spaceTimeThrottle = SpaceTimeThrottle.getByDelay().get(rsp.getThrottle()); // do they have the autonomous circuit on? - if (rsp.isAutoOn() && !tardis.isSiege_on() && !plugin.getTrackerKeeper().getDispersedTARDII().contains(id)) { + if (rsp.isAutoOn() && !tardis.isSiegeOn() && !plugin.getTrackerKeeper().getDispersedTARDII().contains(id)) { boolean isHomeDefault = rsp.getAutoDefault() == Autonomous.Default.HOME; // close doors new DoorCloserAction(plugin, uuid, id).closeDoors(); Location death_loc = player.getLocation(); int amount = Math.round(plugin.getArtronConfig().getInt("autonomous") * spaceTimeThrottle.getArtronMultiplier()); - if (tardis.getArtron_level() > amount) { + if (tardis.getArtronLevel() > amount) { if (plugin.getConfig().getBoolean("allow.emergency_npc") && rsp.isEpsOn()) { // check if there are players in the TARDIS HashMap wherev = new HashMap<>(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/controls/TARDISDirectionFrameListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/controls/TARDISDirectionFrameListener.java index 10986fe12..8398f1d20 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/controls/TARDISDirectionFrameListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/controls/TARDISDirectionFrameListener.java @@ -67,7 +67,7 @@ public void onDirectionFrameClick(PlayerInteractEntityEvent event) { } // if the item frame has a tripwire hook in it if (frame.getItem().getType().equals(Material.TRIPWIRE_HOOK)) { - if (plugin.getConfig().getBoolean("allow.power_down") && !rso.getTardis().isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !rso.getTardis().isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/messaging/AdventureComponents.java b/src/main/java/me/eccentric_nz/TARDIS/messaging/AdventureComponents.java index 0a131eeb0..07244192f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/messaging/AdventureComponents.java +++ b/src/main/java/me/eccentric_nz/TARDIS/messaging/AdventureComponents.java @@ -111,9 +111,9 @@ public static TextComponent getTransmat(Transmat t) { } public static TextComponent getTARDISForList(Tardis t, String world, int x, int y, int z) { - return Component.text(String.format("%s %s", t.getTardis_id(), t.getOwner()), NamedTextColor.GREEN) + return Component.text(String.format("%s %s", t.getTardisId(), t.getOwner()), NamedTextColor.GREEN) .hoverEvent(HoverEvent.showText(Component.text(String.format("%s %s, %s, %s", world, x, y, z)))) - .clickEvent(ClickEvent.runCommand("/tardisadmin enter " + t.getTardis_id())); + .clickEvent(ClickEvent.runCommand("/tardisadmin enter " + t.getTardisId())); } public static TextComponent getExterminate(TARDIS plugin) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/messaging/SpigotComponents.java b/src/main/java/me/eccentric_nz/TARDIS/messaging/SpigotComponents.java index 89db155be..67b6e89e9 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/messaging/SpigotComponents.java +++ b/src/main/java/me/eccentric_nz/TARDIS/messaging/SpigotComponents.java @@ -131,10 +131,10 @@ public static TextComponent getTransmat(Transmat t) { } public static TextComponent getTARDISForList(Tardis t, String world, int x, int y, int z) { - TextComponent textComponent = new TextComponent(String.format("%s %s", t.getTardis_id(), t.getOwner())); + TextComponent textComponent = new TextComponent(String.format("%s %s", t.getTardisId(), t.getOwner())); textComponent.setColor(ChatColor.GREEN); textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(String.format("%s %s, %s, %s", world, x, y, z)))); - textComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tardisadmin enter " + t.getTardis_id())); + textComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tardisadmin enter " + t.getTardisId())); return textComponent; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/messaging/TARDISLister.java b/src/main/java/me/eccentric_nz/TARDIS/messaging/TARDISLister.java index e219272df..7df2ddf95 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/messaging/TARDISLister.java +++ b/src/main/java/me/eccentric_nz/TARDIS/messaging/TARDISLister.java @@ -108,7 +108,7 @@ public void list(Player player, String list) { ResultSetTardis rst = new ResultSetTardis(TARDIS.plugin, where, "", false, 0); if (rst.resultSet()) { Tardis tardis = rst.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); // list TARDIS saves if (list.equalsIgnoreCase("saves")) { plugin.getMessenger().messageWithColour(player, "TARDIS " + plugin.getLanguage().getString("SAVES"), "#FFAA00"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISAnyoneDoorListener.java b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISAnyoneDoorListener.java index e9fce9e79..43e0b060e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISAnyoneDoorListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISAnyoneDoorListener.java @@ -167,7 +167,7 @@ public void onDoorInteract(PlayerInteractEvent event) { tid.put("tardis_id", id); ResultSetTardis rs = new ResultSetTardis(plugin, tid, "", false, 2); if (rs.resultSet()) { - if (!rs.getTardis().isHandbrake_on()) { + if (!rs.getTardis().isHandbrakeOn()) { plugin.getMessenger().sendStatus(player, "HANDBRAKE_ENGAGE"); return; } @@ -243,19 +243,19 @@ public void onDoorInteract(PlayerInteractEvent event) { ResultSetTardis rs = new ResultSetTardis(plugin, tid, "", false, 2); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - if (!tardis.isHandbrake_on()) { + if (!tardis.isHandbrakeOn()) { plugin.getMessenger().sendStatus(player, "HANDBRAKE_ENGAGE"); return; } - int artron = tardis.getArtron_level(); + int artron = tardis.getArtronLevel(); int required = plugin.getArtronConfig().getInt("backdoor"); UUID tlUUID = tardis.getUuid(); ChameleonPreset preset = tardis.getPreset(); float yaw = player.getLocation().getYaw(); float pitch = player.getLocation().getPitch(); String companions = tardis.getCompanions(); - boolean hb = tardis.isHandbrake_on(); - ResultSetCurrentFromId rsc = new ResultSetCurrentFromId(plugin, tardis.getTardis_id()); + boolean hb = tardis.isHandbrakeOn(); + ResultSetCurrentFromId rsc = new ResultSetCurrentFromId(plugin, tardis.getTardisId()); if (!rsc.resultSet()) { // emergency TARDIS relocation new TARDISEmergencyRelocation(plugin).relocate(id, player); diff --git a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISDoorClickListener.java b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISDoorClickListener.java index a6e259e7f..535f8bf54 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISDoorClickListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISDoorClickListener.java @@ -186,7 +186,7 @@ public void onDoorInteract(PlayerInteractEvent event) { tid.put("tardis_id", id); ResultSetTardis rs = new ResultSetTardis(plugin, tid, "", false, 2); if (rs.resultSet()) { - if (!rs.getTardis().isHandbrake_on()) { + if (!rs.getTardis().isHandbrakeOn()) { plugin.getMessenger().sendStatus(player, "HANDBRAKE_ENGAGE"); return; } @@ -237,20 +237,20 @@ public void onDoorInteract(PlayerInteractEvent event) { ResultSetTardis rs = new ResultSetTardis(plugin, tid, "", false, 2); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - if (!tardis.isHandbrake_on()) { + if (!tardis.isHandbrakeOn()) { plugin.getMessenger().sendStatus(player, "HANDBRAKE_ENGAGE"); return; } - int artron = tardis.getArtron_level(); + int artron = tardis.getArtronLevel(); int required = plugin.getArtronConfig().getInt("backdoor"); UUID tlUUID = tardis.getUuid(); ChameleonPreset preset = tardis.getPreset(); float yaw = player.getLocation().getYaw(); float pitch = player.getLocation().getPitch(); String companions = tardis.getCompanions(); - boolean hb = tardis.isHandbrake_on(); - boolean po = !tardis.isPowered_on() && !tardis.isAbandoned(); - ResultSetCurrentFromId rsc = new ResultSetCurrentFromId(plugin, tardis.getTardis_id()); + boolean hb = tardis.isHandbrakeOn(); + boolean po = !tardis.isPoweredOn() && !tardis.isAbandoned(); + ResultSetCurrentFromId rsc = new ResultSetCurrentFromId(plugin, tardis.getTardisId()); if (!rsc.resultSet()) { // emergency TARDIS relocation new TARDISEmergencyRelocation(plugin).relocate(id, player); @@ -417,7 +417,7 @@ public void onDoorInteract(PlayerInteractEvent event) { } if (canPowerUp && po) { // power up the TARDIS - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new TARDISPowerButton(plugin, id, player, tardis.getPreset(), false, tardis.isHidden(), tardis.isLights_on(), player.getLocation(), artron, tardis.getSchematic().getLights()).clickButton(), 20L); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new TARDISPowerButton(plugin, id, player, tardis.getPreset(), false, tardis.isHidden(), tardis.isLightsOn(), player.getLocation(), artron, tardis.getSchematic().getLights()).clickButton(), 20L); } // put player into travellers table diff --git a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISDoorWalkListener.java b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISDoorWalkListener.java index 818539153..7860e6023 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISDoorWalkListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISDoorWalkListener.java @@ -178,7 +178,7 @@ public void onDoorInteract(PlayerInteractEvent event) { tid.put("tardis_id", id); ResultSetTardis rs = new ResultSetTardis(plugin, tid, "", false, 2); if (rs.resultSet()) { - if (!rs.getTardis().isHandbrake_on()) { + if (!rs.getTardis().isHandbrakeOn()) { plugin.getMessenger().sendStatus(player, "HANDBRAKE_ENGAGE"); return; } @@ -245,20 +245,20 @@ public void onDoorInteract(PlayerInteractEvent event) { ResultSetTardis rs = new ResultSetTardis(plugin, tid, "", false, 2); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - if (!tardis.isHandbrake_on()) { + if (!tardis.isHandbrakeOn()) { plugin.getMessenger().sendStatus(player, "HANDBRAKE_ENGAGE"); return; } - int artron = tardis.getArtron_level(); + int artron = tardis.getArtronLevel(); int required = plugin.getArtronConfig().getInt("backdoor"); UUID tlUUID = tardis.getUuid(); ChameleonPreset preset = tardis.getPreset(); float yaw = player.getLocation().getYaw(); float pitch = player.getLocation().getPitch(); String companions = tardis.getCompanions(); - boolean hb = tardis.isHandbrake_on(); - boolean po = !tardis.isPowered_on() && !tardis.isAbandoned(); - ResultSetCurrentFromId rsc = new ResultSetCurrentFromId(plugin, tardis.getTardis_id()); + boolean hb = tardis.isHandbrakeOn(); + boolean po = !tardis.isPoweredOn() && !tardis.isAbandoned(); + ResultSetCurrentFromId rsc = new ResultSetCurrentFromId(plugin, tardis.getTardisId()); if (!rsc.resultSet()) { // emergency TARDIS relocation new TARDISEmergencyRelocation(plugin).relocate(id, player); @@ -430,7 +430,7 @@ public void onDoorInteract(PlayerInteractEvent event) { } if (canPowerUp && po) { // power up the TARDIS - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new TARDISPowerButton(plugin, id, player, tardis.getPreset(), false, tardis.isHidden(), tardis.isLights_on(), player.getLocation(), artron, tardis.getSchematic().getLights()).clickButton(), 20L); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> new TARDISPowerButton(plugin, id, player, tardis.getPreset(), false, tardis.isHidden(), tardis.isLightsOn(), player.getLocation(), artron, tardis.getSchematic().getLights()).clickButton(), 20L); } // put player into travellers table // remove them first as they may have exited incorrectly, and we only want them listed once diff --git a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java index 3d43912d4..616ddb4f3 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java @@ -16,7 +16,6 @@ */ package me.eccentric_nz.TARDIS.move; -import java.util.*; import me.eccentric_nz.TARDIS.ARS.TARDISARSMethods; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISConstants; @@ -37,6 +36,8 @@ import org.bukkit.inventory.EntityEquipment; import org.bukkit.persistence.PersistentDataType; +import java.util.*; + /** * @author eccentric_nz */ @@ -310,7 +311,7 @@ private void moveMonster(TARDISTeleportLocation tpl, TARDISMonster m, Entity e, } } HashMap wherer = new HashMap<>(); - wherer.put("tardis_id", rst.getTardis().getTardis_id()); + wherer.put("tardis_id", rst.getTardis().getTardisId()); wherer.put("type", 5); wherer.put("secondary", 0); ResultSetControls rsc = new ResultSetControls(plugin, wherer, false); @@ -325,6 +326,7 @@ private void moveMonster(TARDISTeleportLocation tpl, TARDISMonster m, Entity e, loc.getChunk().load(); } // spawn a monster in the TARDIS + // TODO update monsters count in database plugin.setTardisSpawn(true); Entity ent = loc.getWorld().spawnEntity(loc, m.getType()); switch (m.getType()) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMoveListener.java b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMoveListener.java index d93ec5b72..f0c573a82 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMoveListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMoveListener.java @@ -208,8 +208,8 @@ public void onPlayerMoveToFromTARDIS(PlayerMoveEvent event) { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 2); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - if (!tardis.isPowered_on()) { - new TARDISPowerButton(plugin, id, player, tardis.getPreset(), false, tardis.isHidden(), tardis.isLights_on(), loc, tardis.getArtron_level(), tardis.getSchematic().getLights()).clickButton(); + if (!tardis.isPoweredOn()) { + new TARDISPowerButton(plugin, id, player, tardis.getPreset(), false, tardis.isHidden(), tardis.isLightsOn(), loc, tardis.getArtronLevel(), tardis.getSchematic().getLights()).clickButton(); } } }, 20L); diff --git a/src/main/java/me/eccentric_nz/TARDIS/placeholders/TARDISPlaceholderExpansion.java b/src/main/java/me/eccentric_nz/TARDIS/placeholders/TARDISPlaceholderExpansion.java index 0ee0100e4..96280d871 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/placeholders/TARDISPlaceholderExpansion.java +++ b/src/main/java/me/eccentric_nz/TARDIS/placeholders/TARDISPlaceholderExpansion.java @@ -106,7 +106,7 @@ public String onRequest(OfflinePlayer player, String identifier) { where.put("tardis_id", rsv.getTardis_id()); rst = new ResultSetTardis(plugin, where, "", false, 2); if (rst.resultSet()) { - if (rst.getTardis().getTardis_id() == rsv.getTardis_id()) { + if (rst.getTardis().getTardisId() == rsv.getTardis_id()) { result = "their own"; } else { result = rst.getTardis().getOwner() + "'s"; diff --git a/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeListener.java b/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeListener.java index 0d1bbad9d..7491872b7 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeListener.java @@ -310,7 +310,7 @@ public void onSiegeCubeInteract(PlayerInteractEvent event) { return; } Tardis tardis = rst.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); if (!uuid.equals(tardis.getUuid())) { boolean isCompanion = false; if (!tardis.getCompanions().isEmpty()) { @@ -351,7 +351,7 @@ public void onSiegeCubeInteract(PlayerInteractEvent event) { } else { // attempt to unsiege the TARDIS // check TARDIS has minimum energy level - if (min > tardis.getArtron_level()) { + if (min > tardis.getArtronLevel()) { plugin.getMessenger().send(p, TardisModule.TARDIS, "SIEGE_POWER"); return; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeMode.java b/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeMode.java index 4475c9e1d..cfc139545 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeMode.java +++ b/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeMode.java @@ -81,10 +81,10 @@ public void toggleViaSwitch(int id, Player p) { HashMap wheres = new HashMap<>(); wheres.put("tardis_id", id); HashMap set = new HashMap<>(); - if (tardis.isSiege_on()) { + if (tardis.isSiegeOn()) { // must have at least 10% power int min = (plugin.getArtronConfig().getInt("full_charge") / 100) * plugin.getArtronConfig().getInt("siege_transfer"); - if (min > tardis.getArtron_level()) { + if (min > tardis.getArtronLevel()) { plugin.getMessenger().send(p, TardisModule.TARDIS, "SIEGE_POWER"); return; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeRunnable.java index 89155fa3a..849ba771f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeRunnable.java @@ -16,8 +16,6 @@ */ package me.eccentric_nz.TARDIS.siegemode; -import java.util.HashMap; -import java.util.List; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.database.data.Tardis; import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; @@ -29,6 +27,9 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import java.util.HashMap; +import java.util.List; + /** * @author eccentric_nz */ @@ -51,7 +52,7 @@ public void run() { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 2); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - int level = tardis.getArtron_level(); + int level = tardis.getArtronLevel(); if (level > deplete) { // remove some energy HashMap whered = new HashMap<>(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeWallFloorRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeWallFloorRunnable.java index 604e92282..6e9160baf 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeWallFloorRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/siegemode/TARDISSiegeWallFloorRunnable.java @@ -127,7 +127,7 @@ public void run() { } Tardis tardis = rs.getTardis(); int slot = tardis.getTIPS(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); if (slot != -1000001) { // default world - use TIPS TARDISInteriorPostioning tintpos = new TARDISInteriorPostioning(plugin); TARDISTIPSData pos = tintpos.getTIPSData(slot); diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java index 8b3872e69..3a40855b6 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java @@ -140,7 +140,7 @@ private ItemDisplay doDocking(ItemStack sonic, Location location, Vector vector, ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPowered_on()) { + if (plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return display; } @@ -169,7 +169,7 @@ private ItemDisplay doDocking(ItemStack sonic, Location location, Vector vector, } SpaceTimeThrottle spaceTimeThrottle = new ResultSetThrottle(plugin).getSpeed(player.getUniqueId().toString()); int ch = Math.round(plugin.getArtronConfig().getInt("comehere") * spaceTimeThrottle.getArtronMultiplier()); - if (tardis.getArtron_level() < ch) { + if (tardis.getArtronLevel() < ch) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_ENOUGH_ENERGY"); return display; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicAdmin.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicAdmin.java index 2e3c18883..adb581014 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicAdmin.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicAdmin.java @@ -16,9 +16,6 @@ */ package me.eccentric_nz.TARDIS.sonic.actions; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.database.data.Tardis; import me.eccentric_nz.TARDIS.database.resultset.ResultSetBackLocation; @@ -32,6 +29,10 @@ import org.bukkit.block.data.Bisected; import org.bukkit.entity.Player; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + public class TARDISSonicAdmin { public static void displayInfo(TARDIS plugin, Player player, Block block) { @@ -63,7 +64,7 @@ public static void displayInfo(TARDIS plugin, Player player, Block block) { Tardis tardis = rsn.getTardis(); String name = plugin.getServer().getOfflinePlayer(tardis.getUuid()).getName(); plugin.getMessenger().send(player, TardisModule.TARDIS, "TARDIS_WHOSE", name); - int percent = Math.round((tardis.getArtron_level() * 100F) / plugin.getArtronConfig().getInt("full_charge")); + int percent = Math.round((tardis.getArtronLevel() * 100F) / plugin.getArtronConfig().getInt("full_charge")); plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_LEVEL", String.format("%d", percent)); HashMap whereb = new HashMap<>(); whereb.put("tardis_id", id); diff --git a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISMalfunctionExplosion.java b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISMalfunctionExplosion.java index 06658f1f3..d0bea8e92 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISMalfunctionExplosion.java +++ b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISMalfunctionExplosion.java @@ -59,7 +59,7 @@ public void run() { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 2); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - ResultSetRepeaters rsr = new ResultSetRepeaters(plugin, tardis.getTardis_id(), 0); + ResultSetRepeaters rsr = new ResultSetRepeaters(plugin, tardis.getTardisId(), 0); if (rsr.resultSet()) { locations = rsr.getLocations(); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISRescue.java b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISRescue.java index b64f717c3..db9db4643 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISRescue.java +++ b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISRescue.java @@ -131,8 +131,8 @@ public RescueData tryRescue(Player player, UUID saved, boolean request) { return new RescueData(false, 0); } Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); - if (!tardis.isHandbrake_on() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { + int id = tardis.getTardisId(); + if (!tardis.isHandbrakeOn() && !plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_WHILE_TRAVELLING"); return new RescueData(false, 0); } @@ -148,7 +148,7 @@ public RescueData tryRescue(Player player, UUID saved, boolean request) { plugin.getMessenger().send(player, TardisModule.TARDIS, "CMD_ONLY_TL"); return new RescueData(false, 0); } - int level = tardis.getArtron_level(); + int level = tardis.getArtronLevel(); int travel = plugin.getArtronConfig().getInt("travel"); if (level < travel) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_ENOUGH_ENERGY"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/update/TARDISUpdateListener.java b/src/main/java/me/eccentric_nz/TARDIS/update/TARDISUpdateListener.java index 144db9406..dcca5312e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/update/TARDISUpdateListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/update/TARDISUpdateListener.java @@ -147,7 +147,7 @@ public void onUpdateInteract(PlayerInteractEvent event) { return; } Tardis tardis = rs.getTardis(); - int id = tardis.getTardis_id(); + int id = tardis.getTardisId(); HashMap tid = new HashMap<>(); HashMap set = new HashMap<>(); tid.put("tardis_id", id); @@ -181,10 +181,10 @@ public void onUpdateInteract(PlayerInteractEvent event) { case CHARGING_SENSOR, FLIGHT_SENSOR, HANDBRAKE_SENSOR, MALFUNCTION_SENSOR, POWER_SENSOR -> { String tmp = updateable.toString().toLowerCase(Locale.ROOT); String type = tmp.substring(0, tmp.length() - 7); - plugin.getQueryFactory().insertSensor(tardis.getTardis_id(), type, blockLocStr); + plugin.getQueryFactory().insertSensor(tardis.getTardisId(), type, blockLocStr); // set default state of sensor - OFF - if ((updateable == Updateable.HANDBRAKE_SENSOR && !tardis.isHandbrake_on()) - || (updateable == Updateable.POWER_SENSOR && tardis.isPowered_on())) { + if ((updateable == Updateable.HANDBRAKE_SENSOR && !tardis.isHandbrakeOn()) + || (updateable == Updateable.POWER_SENSOR && tardis.isPoweredOn())) { block.setType(Material.REDSTONE_BLOCK); } else { block.setType(Material.STONE); diff --git a/src/main/java/me/eccentric_nz/TARDIS/update/TARDISUpdateableChecker.java b/src/main/java/me/eccentric_nz/TARDIS/update/TARDISUpdateableChecker.java index 7188a2543..863e9ee10 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/update/TARDISUpdateableChecker.java +++ b/src/main/java/me/eccentric_nz/TARDIS/update/TARDISUpdateableChecker.java @@ -71,7 +71,7 @@ public boolean canUpdate() { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_DISABLED"); return false; } - if (updateable.equals(Updateable.BEACON) && !tardis.isPowered_on()) { + if (updateable.equals(Updateable.BEACON) && !tardis.isPoweredOn()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_BEACON"); return false; } @@ -112,7 +112,7 @@ public boolean canUpdate() { // check ARS for room type if (mustGrowRoom.contains(updateable)) { HashMap wherea = new HashMap<>(); - wherea.put("tardis_id", tardis.getTardis_id()); + wherea.put("tardis_id", tardis.getTardisId()); ResultSetARS rsa = new ResultSetARS(plugin, wherea); if (rsa.resultSet()) { // check for rooms @@ -174,7 +174,7 @@ public boolean canUpdate() { return false; } // must grow a room first - ResultSetFarming rsf = new ResultSetFarming(plugin, tardis.getTardis_id()); + ResultSetFarming rsf = new ResultSetFarming(plugin, tardis.getTardisId()); if (rsf.resultSet()) { Farm farming = rsf.getFarming(); if (updateable.equals(Updateable.FARM) && farming.getFarm().isEmpty() && !hasFarm) { @@ -260,7 +260,7 @@ public boolean canUpdate() { return false; } int thisid = rst.getTardis_id(); - if (thisid != tardis.getTardis_id()) { + if (thisid != tardis.getTardisId()) { plugin.getMessenger().send(player, TardisModule.TARDIS, "CMD_ONLY_TL"); return false; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISJunkPlayerPersister.java b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISJunkPlayerPersister.java index c4733de0a..838160fcb 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISJunkPlayerPersister.java +++ b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISJunkPlayerPersister.java @@ -36,7 +36,7 @@ public void load() { where.put("chameleon_preset", "JUNK_MODE"); ResultSetTardis rs = new ResultSetTardis(plugin, where, "", true, 2); if (rs.resultSet()) { - rs.getData().forEach((t) -> plugin.getTrackerKeeper().getJunkPlayers().put(t.getUuid(), t.getTardis_id())); + rs.getData().forEach((t) -> plugin.getTrackerKeeper().getJunkPlayers().put(t.getUuid(), t.getTardisId())); } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISStaticUtils.java b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISStaticUtils.java index 3312c99b9..eac41079a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISStaticUtils.java +++ b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISStaticUtils.java @@ -106,7 +106,7 @@ public static boolean isOwnerOnline(int id) { ResultSetTardis rst = new ResultSetTardis(TARDIS.plugin, where, "", false, 0); if (rst.resultSet()) { Tardis tardis = rst.getTardis(); - if (!tardis.isTardis_init()) { + if (!tardis.isTardisInit()) { return false; } UUID ownerUUID = tardis.getUuid(); diff --git a/todo.md b/todo.md index b78a942b8..0a0752edf 100644 --- a/todo.md +++ b/todo.md @@ -3,8 +3,9 @@ ## Current version `5.6.0` 1. Fix fifteenth console redstone piston door -2. Fix follower persistence -3. ? +2. Fix follower persistence +3. Update `monsters` count in database +4. ? ## Next version `5.7.0` From 3b726b1a6e8ce9f8ee6a25fb8bb0eb469d18a243 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Thu, 4 Apr 2024 23:00:26 +1300 Subject: [PATCH 14/96] Update RandomiserInteraction.java --- .../interaction/RandomiserInteraction.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java index 33d3f2c09..ca9b2ffd2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java @@ -1,6 +1,15 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.advanced.TARDISCircuitChecker; +import me.eccentric_nz.TARDIS.control.TARDISRandomButton; +import me.eccentric_nz.TARDIS.database.data.Tardis; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; +import me.eccentric_nz.TARDIS.enumeration.Difficulty; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.entity.Player; + +import java.util.HashMap; public class RandomiserInteraction { @@ -10,7 +19,29 @@ public RandomiserInteraction(TARDIS plugin) { this.plugin = plugin; } - public void generateDestination() { - + public void generateDestination(int id, Player player) { + if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); + return; + } + // get circuit checker + TARDISCircuitChecker tcc = null; + if (!plugin.getDifficulty().equals(Difficulty.EASY)) { + tcc = new TARDISCircuitChecker(plugin, id); + tcc.getCircuits(); + } + if (tcc != null && !tcc.hasInput() && !plugin.getUtils().inGracePeriod(player, false)) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "INPUT_MISSING"); + return; + } + // get tardis record + HashMap where = new HashMap<>(); + where.put("tardis_id", id); + ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); + if (!rs.resultSet()) { + return; + } + Tardis tardis = rs.getTardis(); + new TARDISRandomButton(plugin, player, id, tardis.getArtronLevel(), 0, tardis.getCompanions(), tardis.getUuid()).clickButton(); } } From 0d2ffac3385726f58a498f96fcc82bc6a203afb9 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Fri, 5 Apr 2024 17:59:50 +1300 Subject: [PATCH 15/96] Some stuff --- .../TARDIS/console/ConsoleInteraction.java | 2 +- .../console/ConsoleInteractionListener.java | 23 +++++---- .../interaction/FlightModeInteraction.java | 4 ++ .../TARDIS/control/TARDISRandomButton.java | 41 ++++----------- .../TARDIS/control/actions/ExileAction.java | 50 +++++++++++++++++++ .../resultset/ResultSetInteraction.java | 2 +- .../TARDIS/move/TARDISMonsterRunnable.java | 2 +- 7 files changed, 81 insertions(+), 43 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/control/actions/ExileAction.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java index 1860e7965..774903ee5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java @@ -10,7 +10,7 @@ public enum ConsoleInteraction { RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.575d, 1.0d, 1.75d), 0.5f, 0.65f), // section one - WORLD("Dimension Selector", new Vector(-0.525d, 1.0d, 0.95d), 0.15f, 0.65f), + WORLD("Environment Selector", new Vector(-0.525d, 1.0d, 0.95d), 0.15f, 0.65f), MULTIPLIER("Coordinate Increment Modifier", new Vector(-0.4d, 1.0d, 1.2d), 0.15f, 0.65f), X("X Distance", new Vector(-0.75d, 1.0d, 1.1d), 0.15f, 0.4f), Z("Z Distance", new Vector(-0.6d, 1.0d, 1.3d), 0.15f, 0.4f), diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index a24f697ba..2cc03515a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -4,6 +4,7 @@ import me.eccentric_nz.TARDIS.console.interaction.*; import me.eccentric_nz.TARDIS.database.resultset.ResultSetInteraction; import org.bukkit.entity.Interaction; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractAtEntityEvent; @@ -26,11 +27,13 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { ResultSetInteraction rsi = new ResultSetInteraction(plugin, uuid); if (rsi.resultSet()) { ConsoleInteraction ci = rsi.getControl(); + int id = rsi.getTardisId(); + Player player = event.getPlayer(); switch (ci) { // section zero - case HANDBRAKE -> new HandbrakeInteraction(plugin).process(rsi.getTardis_id(), rsi.getState(), event.getPlayer(), interaction.getLocation()); - case THROTTLE -> new ThrottleInteraction(plugin).process(event.getPlayer()); - case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(event.getPlayer()); + case HANDBRAKE -> new HandbrakeInteraction(plugin).process(id, rsi.getState(), player, interaction.getLocation()); + case THROTTLE -> new ThrottleInteraction(plugin).process(player); + case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(player); // section one case WORLD -> new WorldInteraction(plugin).selectWorld(); case MULTIPLIER -> new MultiplierInteraction(plugin).setRange(); @@ -41,12 +44,12 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { new HelmicRegulatorInteraction(plugin).selectWorld(); } // section two - case RANDOMISER -> new RandomiserInteraction(plugin).generateDestination(); + case RANDOMISER -> new RandomiserInteraction(plugin).generateDestination(id, player); case WAYPOINT_SELECTOR -> new WayPointInteraction(plugin).openSaveGUI(); case FAST_RETURN -> new FastReturnInteraction(plugin).setBack(); case TELEPATHIC_CIRCUIT -> new TelepathicCircuitInteraction(plugin).openGUI(); // section three - case SONIC_DOCK -> new SonicDockInteraction(plugin).process(event.getPlayer(), interaction, rsi.getTardis_id()); + case SONIC_DOCK -> new SonicDockInteraction(plugin).process(player, interaction, id); case DIRECTION -> new DirectionInteraction(plugin).rotate(); // section four case LIGHT_SWITCH -> new LightSwitchInteraction(plugin).toggle(); @@ -54,11 +57,11 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { case EXTERIOR_LAMP_LEVEL_SWITCH -> new LampLevelInteraction(plugin).setExterior(); case DOOR_TOGGLE -> new DoorToggleInteraction(plugin).toggle(); // section five - case SCREEN_LEFT, SCREEN_RIGHT -> new ScreenInteraction(plugin).display(rsi.getTardis_id(), interaction.getLocation(), ci == ConsoleInteraction.SCREEN_RIGHT); - case SCANNER -> new ScannerIntraction(plugin).process(rsi.getTardis_id(), event.getPlayer()); - case ARTRON -> plugin.getMessenger().sendArtron(event.getPlayer(), rsi.getTardis_id(), 0); - case REBUILD -> new RebuildInteraction(plugin).process(rsi.getTardis_id(), event.getPlayer()); - default -> plugin.getMessenger().announceRepeater(event.getPlayer(), rsi.getControl().getAlternateName()); + case SCREEN_LEFT, SCREEN_RIGHT -> new ScreenInteraction(plugin).display(id, interaction.getLocation(), ci == ConsoleInteraction.SCREEN_RIGHT); + case SCANNER -> new ScannerIntraction(plugin).process(id, player); + case ARTRON -> plugin.getMessenger().sendArtron(player, id, 0); + case REBUILD -> new RebuildInteraction(plugin).process(id, player); + default -> plugin.getMessenger().announceRepeater(player, rsi.getControl().getAlternateName()); } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java index f3536c40a..985513036 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java @@ -35,6 +35,10 @@ public void process(Player player) { TARDIS.plugin.getQueryFactory().doUpdate("player_prefs", setf, where); plugin.getMessenger().send(player, TardisModule.TARDIS, "FLIGHT_SAVED"); // TODO set custom model data for relativity differentiator item display + // TODO make relativity differentiator standalone control set player_prefs flightmode when toggled - exterior|normal + // TODO then alter `isRelativityDifferentiated()` to check player prefs instead + // should !exterior|normal flight modes even be accessible from this interaction? if so: + // TODO make malfunction / manual / regulator classes? } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISRandomButton.java b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISRandomButton.java index 518da866a..30f57ea8c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISRandomButton.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISRandomButton.java @@ -20,7 +20,11 @@ import me.eccentric_nz.TARDIS.api.event.TARDISTravelEvent; import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; import me.eccentric_nz.TARDIS.builders.TARDISEmergencyRelocation; -import me.eccentric_nz.TARDIS.database.resultset.*; +import me.eccentric_nz.TARDIS.control.actions.ExileAction; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentFromId; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetRepeaters; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTravelledTo; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTravellers; import me.eccentric_nz.TARDIS.enumeration.COMPASS; import me.eccentric_nz.TARDIS.enumeration.TardisModule; import me.eccentric_nz.TARDIS.enumeration.TravelType; @@ -71,40 +75,16 @@ public void clickButton() { new TARDISEmergencyRelocation(plugin).relocate(id, player); return; } - COMPASS dir = rscl.getDirection(); - Location cl = new Location(rscl.getWorld(), rscl.getX(), rscl.getY(), rscl.getZ()); + COMPASS direction = rscl.getDirection(); if (TARDISPermission.hasPermission(player, "tardis.exile") && plugin.getConfig().getBoolean("travel.exile")) { - // get the exile area - String permArea = plugin.getTardisArea().getExileArea(player); - plugin.getMessenger().send(player, TardisModule.TARDIS, "EXILE", permArea); - Location l; - HashMap wherea = new HashMap<>(); - wherea.put("area_name", permArea); - ResultSetAreas rsa = new ResultSetAreas(plugin, wherea, false, false); - rsa.resultSet(); - if (rsa.getArea().isGrid()) { - l = plugin.getTardisArea().getNextSpot(permArea); - } else { - l = plugin.getTardisArea().getSemiRandomLocation(rsa.getArea().getAreaId()); - } - if (l == null) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_MORE_SPOTS"); - } else { - set.put("world", l.getWorld().getName()); - set.put("x", l.getBlockX()); - set.put("y", l.getBlockY()); - set.put("z", l.getBlockZ()); - set.put("direction", dir.toString()); - set.put("submarine", 0); - plugin.getMessenger().send(player, TardisModule.TARDIS, "TRAVEL_APPROVED", permArea); - } + new ExileAction(plugin).getExile(player, id, direction); } else { ResultSetRepeaters rsr = new ResultSetRepeaters(plugin, id, secondary); if (rsr.resultSet()) { + int[] repeaters = rsr.getRepeaters(); String environment = "THIS"; int nether_min = plugin.getArtronConfig().getInt("nether_min"); int the_end_min = plugin.getArtronConfig().getInt("the_end_min"); - int[] repeaters = rsr.getRepeaters(); if (repeaters[0] == -1) { plugin.getMessenger().send(player, TardisModule.TARDIS, "FLIGHT_BAD"); return; @@ -148,9 +128,10 @@ public void clickButton() { environment = "THE_END"; } } + Location current = new Location(rscl.getWorld(), rscl.getX(), rscl.getY(), rscl.getZ()); // create a random destination TARDISTimeTravel tt = new TARDISTimeTravel(plugin); - Location rand = tt.randomDestination(player, repeaters[1], repeaters[2], repeaters[3], dir, environment, rscl.getWorld(), false, cl); + Location rand = tt.randomDestination(player, repeaters[1], repeaters[2], repeaters[3], direction, environment, rscl.getWorld(), false, current); if (rand != null) { // double check TARDIS travel is allowed in this world if (!plugin.getPlanetsConfig().getBoolean("planets." + rand.getWorld().getName() + ".time_travel")) { @@ -161,7 +142,7 @@ public void clickButton() { set.put("x", rand.getBlockX()); set.put("y", rand.getBlockY()); set.put("z", rand.getBlockZ()); - set.put("direction", dir.toString()); + set.put("direction", direction.toString()); set.put("submarine", (plugin.getTrackerKeeper().getSubmarine().contains(id)) ? 1 : 0); plugin.getTrackerKeeper().getSubmarine().remove(id); String worldname; diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/ExileAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/ExileAction.java new file mode 100644 index 000000000..ae9d47525 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/ExileAction.java @@ -0,0 +1,50 @@ +package me.eccentric_nz.TARDIS.control.actions; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetAreas; +import me.eccentric_nz.TARDIS.enumeration.COMPASS; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +import java.util.HashMap; + +public class ExileAction { + + private final TARDIS plugin; + + public ExileAction(TARDIS plugin) { + this.plugin = plugin; + } + + public void getExile(Player player, int id, COMPASS direction) { + // get the exile area + String permArea = plugin.getTardisArea().getExileArea(player); + plugin.getMessenger().send(player, TardisModule.TARDIS, "EXILE", permArea); + Location l; + HashMap wherea = new HashMap<>(); + wherea.put("area_name", permArea); + ResultSetAreas rsa = new ResultSetAreas(plugin, wherea, false, false); + rsa.resultSet(); + if (rsa.getArea().isGrid()) { + l = plugin.getTardisArea().getNextSpot(permArea); + } else { + l = plugin.getTardisArea().getSemiRandomLocation(rsa.getArea().getAreaId()); + } + if (l == null) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_MORE_SPOTS"); + } else { + HashMap set = new HashMap<>(); + set.put("world", l.getWorld().getName()); + set.put("x", l.getBlockX()); + set.put("y", l.getBlockY()); + set.put("z", l.getBlockZ()); + set.put("direction", direction.toString()); + set.put("submarine", 0); + HashMap wherel = new HashMap<>(); + wherel.put("tardis_id", id); + plugin.getQueryFactory().doSyncUpdate("next", set, wherel); + plugin.getMessenger().send(player, TardisModule.TARDIS, "TRAVEL_APPROVED", permArea); + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteraction.java index a8cbb33d1..1282e7e7b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteraction.java @@ -104,7 +104,7 @@ public int getInteraction_id() { return interaction_id; } - public int getTardis_id() { + public int getTardisId() { return tardis_id; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java index 616ddb4f3..ecc86f66a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java @@ -98,7 +98,7 @@ public void run() { List entities = ent.getNearbyEntities(16, 16, 16); ent.remove(); boolean found = false; - if (entities.size() < 1) { + if (entities.isEmpty()) { continue; } // check if a Time Lord or companion is near From d57405f8542b67ba4e3739c89a32d80f6b13e371 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Sat, 6 Apr 2024 16:04:28 +1300 Subject: [PATCH 16/96] Random action --- .../TARDIS/control/TARDISRandomButton.java | 126 +-------------- .../actions/RandomDestinationAction.java | 145 ++++++++++++++++++ 2 files changed, 149 insertions(+), 122 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/control/actions/RandomDestinationAction.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISRandomButton.java b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISRandomButton.java index 30f57ea8c..9a33da26d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISRandomButton.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISRandomButton.java @@ -17,23 +17,14 @@ package me.eccentric_nz.TARDIS.control; import me.eccentric_nz.TARDIS.TARDIS; -import me.eccentric_nz.TARDIS.api.event.TARDISTravelEvent; import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; import me.eccentric_nz.TARDIS.builders.TARDISEmergencyRelocation; import me.eccentric_nz.TARDIS.control.actions.ExileAction; +import me.eccentric_nz.TARDIS.control.actions.RandomDestinationAction; import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentFromId; import me.eccentric_nz.TARDIS.database.resultset.ResultSetRepeaters; -import me.eccentric_nz.TARDIS.database.resultset.ResultSetTravelledTo; -import me.eccentric_nz.TARDIS.database.resultset.ResultSetTravellers; import me.eccentric_nz.TARDIS.enumeration.COMPASS; import me.eccentric_nz.TARDIS.enumeration.TardisModule; -import me.eccentric_nz.TARDIS.enumeration.TravelType; -import me.eccentric_nz.TARDIS.enumeration.WorldManager; -import me.eccentric_nz.TARDIS.flight.TARDISLand; -import me.eccentric_nz.TARDIS.planets.TARDISAliasResolver; -import me.eccentric_nz.TARDIS.travel.TARDISTimeTravel; -import me.eccentric_nz.TARDIS.travel.TravelCostAndType; -import org.bukkit.Location; import org.bukkit.entity.Player; import java.util.HashMap; @@ -82,119 +73,10 @@ public void clickButton() { ResultSetRepeaters rsr = new ResultSetRepeaters(plugin, id, secondary); if (rsr.resultSet()) { int[] repeaters = rsr.getRepeaters(); - String environment = "THIS"; - int nether_min = plugin.getArtronConfig().getInt("nether_min"); - int the_end_min = plugin.getArtronConfig().getInt("the_end_min"); - if (repeaters[0] == -1) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "FLIGHT_BAD"); - return; - } - if (repeaters[0] == 1) { // first position - environment = "THIS"; - // check TARDIS travel is allowed in this world - if (!plugin.getPlanetsConfig().getBoolean("planets." + rscl.getWorld().getName() + ".time_travel")) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_WORLD_TRAVEL"); - return; - } - } - if (repeaters[0] == 2) { // second position - normal - environment = "NORMAL"; - } - if (repeaters[0] == 3) { // third position - nether - environment = "NORMAL"; - if (!plugin.getConfig().getBoolean("travel.nether")) { // nether travel enabled - plugin.getMessenger().send(player, TardisModule.TARDIS, "ANCIENT", "Nether"); - } else if (!TARDISPermission.hasPermission(player, "tardis.nether")) { // nether permission - plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_PERM_TRAVEL", "Nether"); - } else if (plugin.getConfig().getBoolean("travel.allow_nether_after_visit") && !new ResultSetTravelledTo(plugin).resultSet(player.getUniqueId().toString(), "NETHER")) { // check if they need to visit nether first - plugin.getMessenger().send(player, TardisModule.TARDIS, "TRAVEL_NOT_VISITED", "Nether"); - } else if (level < nether_min) { // check if they have enough artron to travel to the nether - plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_ENOUGH_TRAVEL_ENERGY", String.format("%d", nether_min), "Nether"); - } else { // player can go to the nether! yay - environment = "NETHER"; - } - } - if (repeaters[0] == 4) { // last position - the end - environment = "NORMAL"; - if (!plugin.getConfig().getBoolean("travel.the_end")) { // end travel enabled - plugin.getMessenger().send(player, TardisModule.TARDIS, "ANCIENT", "End"); - } else if (!TARDISPermission.hasPermission(player, "tardis.end")) { // end permission - plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_PERM_TRAVEL", "End"); - } else if (plugin.getConfig().getBoolean("travel.allow_end_after_visit") && !new ResultSetTravelledTo(plugin).resultSet(player.getUniqueId().toString(), "THE_END")) { // check if they need to visit the end first - plugin.getMessenger().send(player, TardisModule.TARDIS, "TRAVEL_NOT_VISITED", "End"); - } else if (level < the_end_min) { // check if they have enough artron to travel to the end - plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_ENOUGH_TRAVEL_ENERGY", String.format("%d", the_end_min), "End"); - } else { // player can go to the end! yay - environment = "THE_END"; - } - } - Location current = new Location(rscl.getWorld(), rscl.getX(), rscl.getY(), rscl.getZ()); - // create a random destination - TARDISTimeTravel tt = new TARDISTimeTravel(plugin); - Location rand = tt.randomDestination(player, repeaters[1], repeaters[2], repeaters[3], direction, environment, rscl.getWorld(), false, current); - if (rand != null) { - // double check TARDIS travel is allowed in this world - if (!plugin.getPlanetsConfig().getBoolean("planets." + rand.getWorld().getName() + ".time_travel")) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_WORLD_TRAVEL"); - return; - } - set.put("world", rand.getWorld().getName()); - set.put("x", rand.getBlockX()); - set.put("y", rand.getBlockY()); - set.put("z", rand.getBlockZ()); - set.put("direction", direction.toString()); - set.put("submarine", (plugin.getTrackerKeeper().getSubmarine().contains(id)) ? 1 : 0); - plugin.getTrackerKeeper().getSubmarine().remove(id); - String worldname; - if (!plugin.getPlanetsConfig().getBoolean("planets." + rand.getWorld().getName() + ".enabled") && plugin.getWorldManager().equals(WorldManager.MULTIVERSE)) { - worldname = plugin.getMVHelper().getAlias(rand.getWorld()); - } else { - worldname = TARDISAliasResolver.getWorldAlias(rand.getWorld()); - } - String dchat = worldname + " at x: " + rand.getBlockX() + " y: " + rand.getBlockY() + " z: " + rand.getBlockZ(); - boolean isTL = true; - if (comps != null && !comps.isEmpty()) { - String[] companions = comps.split(":"); - for (String c : companions) { - // are they online - AND are they travelling - UUID cuuid = UUID.fromString(c); - if (plugin.getServer().getPlayer(cuuid) != null && !cuuid.equals(ownerUUID)) { - // are they travelling - HashMap wherec = new HashMap<>(); - wherec.put("tardis_id", id); - wherec.put("uuid", c); - ResultSetTravellers rsv = new ResultSetTravellers(plugin, wherec, false); - if (rsv.resultSet() && !plugin.getConfig().getBoolean("preferences.no_coords")) { - plugin.getMessenger().sendStatus(plugin.getServer().getPlayer(cuuid), "DEST", dchat); - } - } - if (c.equalsIgnoreCase(player.getName())) { - isTL = false; - } - } - } - if (!plugin.getConfig().getBoolean("preferences.no_coords")) { - if (isTL) { - plugin.getMessenger().sendStatus(player, "DEST", dchat); - } else if (plugin.getServer().getPlayer(ownerUUID) != null) { - plugin.getMessenger().sendStatus(plugin.getServer().getPlayer(ownerUUID),"DEST", dchat); - } - } - HashMap wherel = new HashMap<>(); - wherel.put("tardis_id", id); - plugin.getQueryFactory().doSyncUpdate("next", set, wherel); - plugin.getTrackerKeeper().getHasDestination().put(id, new TravelCostAndType(cost, TravelType.RANDOM)); - plugin.getTrackerKeeper().getRescue().remove(id); - if (plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { - new TARDISLand(plugin, id, player).exitVortex(); - plugin.getPM().callEvent(new TARDISTravelEvent(player, null, TravelType.RANDOM, id)); - } - } else if (plugin.getConfig().getBoolean("travel.no_destination_malfunctions")) { - plugin.getTrackerKeeper().getMalfunction().put(id, true); - } else { - plugin.getMessenger().send(player, TardisModule.TARDIS, "PROTECTED"); - } + new RandomDestinationAction(plugin).getRandomDestination(player, id, repeaters, rscl, direction, level, cost); } } } + + } diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/RandomDestinationAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/RandomDestinationAction.java new file mode 100644 index 000000000..8575a3bf6 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/RandomDestinationAction.java @@ -0,0 +1,145 @@ +package me.eccentric_nz.TARDIS.control.actions; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.api.event.TARDISTravelEvent; +import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentFromId; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTravelledTo; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTravellers; +import me.eccentric_nz.TARDIS.enumeration.COMPASS; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import me.eccentric_nz.TARDIS.enumeration.TravelType; +import me.eccentric_nz.TARDIS.enumeration.WorldManager; +import me.eccentric_nz.TARDIS.flight.TARDISLand; +import me.eccentric_nz.TARDIS.planets.TARDISAliasResolver; +import me.eccentric_nz.TARDIS.travel.TARDISTimeTravel; +import me.eccentric_nz.TARDIS.travel.TravelCostAndType; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.UUID; + +public class RandomDestinationAction { + + private final TARDIS plugin; + + public RandomDestinationAction(TARDIS plugin) { + this.plugin = plugin; + } + + public void getRandomDestination(Player player, int id, int[] repeaters, ResultSetCurrentFromId rscl, COMPASS direction, int level, int cost) { + String environment = "THIS"; + int nether_min = plugin.getArtronConfig().getInt("nether_min"); + int the_end_min = plugin.getArtronConfig().getInt("the_end_min"); + if (repeaters[0] == -1) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "FLIGHT_BAD"); + return; + } + if (repeaters[0] == 1) { // first position + environment = "THIS"; + // check TARDIS travel is allowed in this world + if (!plugin.getPlanetsConfig().getBoolean("planets." + rscl.getWorld().getName() + ".time_travel")) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_WORLD_TRAVEL"); + return; + } + } + if (repeaters[0] == 2) { // second position - normal + environment = "NORMAL"; + } + if (repeaters[0] == 3) { // third position - nether + environment = "NORMAL"; + if (!plugin.getConfig().getBoolean("travel.nether")) { // nether travel enabled + plugin.getMessenger().send(player, TardisModule.TARDIS, "ANCIENT", "Nether"); + } else if (!TARDISPermission.hasPermission(player, "tardis.nether")) { // nether permission + plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_PERM_TRAVEL", "Nether"); + } else if (plugin.getConfig().getBoolean("travel.allow_nether_after_visit") && !new ResultSetTravelledTo(plugin).resultSet(player.getUniqueId().toString(), "NETHER")) { // check if they need to visit nether first + plugin.getMessenger().send(player, TardisModule.TARDIS, "TRAVEL_NOT_VISITED", "Nether"); + } else if (level < nether_min) { // check if they have enough artron to travel to the nether + plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_ENOUGH_TRAVEL_ENERGY", String.format("%d", nether_min), "Nether"); + } else { // player can go to the nether! yay + environment = "NETHER"; + } + } + if (repeaters[0] == 4) { // last position - the end + environment = "NORMAL"; + if (!plugin.getConfig().getBoolean("travel.the_end")) { // end travel enabled + plugin.getMessenger().send(player, TardisModule.TARDIS, "ANCIENT", "End"); + } else if (!TARDISPermission.hasPermission(player, "tardis.end")) { // end permission + plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_PERM_TRAVEL", "End"); + } else if (plugin.getConfig().getBoolean("travel.allow_end_after_visit") && !new ResultSetTravelledTo(plugin).resultSet(player.getUniqueId().toString(), "THE_END")) { // check if they need to visit the end first + plugin.getMessenger().send(player, TardisModule.TARDIS, "TRAVEL_NOT_VISITED", "End"); + } else if (level < the_end_min) { // check if they have enough artron to travel to the end + plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_ENOUGH_TRAVEL_ENERGY", String.format("%d", the_end_min), "End"); + } else { // player can go to the end! yay + environment = "THE_END"; + } + } + Location current = new Location(rscl.getWorld(), rscl.getX(), rscl.getY(), rscl.getZ()); + // create a random destination + TARDISTimeTravel tt = new TARDISTimeTravel(plugin); + Location rand = tt.randomDestination(player, repeaters[1], repeaters[2], repeaters[3], direction, environment, rscl.getWorld(), false, current); + if (rand != null) { + // double check TARDIS travel is allowed in this world + if (!plugin.getPlanetsConfig().getBoolean("planets." + rand.getWorld().getName() + ".time_travel")) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_WORLD_TRAVEL"); + return; + } + set.put("world", rand.getWorld().getName()); + set.put("x", rand.getBlockX()); + set.put("y", rand.getBlockY()); + set.put("z", rand.getBlockZ()); + set.put("direction", direction.toString()); + set.put("submarine", (plugin.getTrackerKeeper().getSubmarine().contains(id)) ? 1 : 0); + plugin.getTrackerKeeper().getSubmarine().remove(id); + String worldname; + if (!plugin.getPlanetsConfig().getBoolean("planets." + rand.getWorld().getName() + ".enabled") && plugin.getWorldManager().equals(WorldManager.MULTIVERSE)) { + worldname = plugin.getMVHelper().getAlias(rand.getWorld()); + } else { + worldname = TARDISAliasResolver.getWorldAlias(rand.getWorld()); + } + String dchat = worldname + " at x: " + rand.getBlockX() + " y: " + rand.getBlockY() + " z: " + rand.getBlockZ(); + boolean isTL = true; + if (comps != null && !comps.isEmpty()) { + String[] companions = comps.split(":"); + for (String c : companions) { + // are they online - AND are they travelling + UUID cuuid = UUID.fromString(c); + if (plugin.getServer().getPlayer(cuuid) != null && !cuuid.equals(ownerUUID)) { + // are they travelling + HashMap wherec = new HashMap<>(); + wherec.put("tardis_id", id); + wherec.put("uuid", c); + ResultSetTravellers rsv = new ResultSetTravellers(plugin, wherec, false); + if (rsv.resultSet() && !plugin.getConfig().getBoolean("preferences.no_coords")) { + plugin.getMessenger().sendStatus(plugin.getServer().getPlayer(cuuid), "DEST", dchat); + } + } + if (c.equalsIgnoreCase(player.getName())) { + isTL = false; + } + } + } + if (!plugin.getConfig().getBoolean("preferences.no_coords")) { + if (isTL) { + plugin.getMessenger().sendStatus(player, "DEST", dchat); + } else if (plugin.getServer().getPlayer(ownerUUID) != null) { + plugin.getMessenger().sendStatus(plugin.getServer().getPlayer(ownerUUID),"DEST", dchat); + } + } + HashMap wherel = new HashMap<>(); + wherel.put("tardis_id", id); + plugin.getQueryFactory().doSyncUpdate("next", set, wherel); + plugin.getTrackerKeeper().getHasDestination().put(id, new TravelCostAndType(cost, TravelType.RANDOM)); + plugin.getTrackerKeeper().getRescue().remove(id); + if (plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { + new TARDISLand(plugin, id, player).exitVortex(); + plugin.getPM().callEvent(new TARDISTravelEvent(player, null, TravelType.RANDOM, id)); + } + } else if (plugin.getConfig().getBoolean("travel.no_destination_malfunctions")) { + plugin.getTrackerKeeper().getMalfunction().put(id, true); + } else { + plugin.getMessenger().send(player, TardisModule.TARDIS, "PROTECTED"); + } + } +} From 9e7b6ee5c2e5876c142e01b97b12472ec3afc34e Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sun, 7 Apr 2024 22:11:35 +1200 Subject: [PATCH 17/96] More interactions --- .../java/me/eccentric_nz/TARDIS/TARDIS.java | 11 ++ .../TARDIS/console/ConsoleBuilder.java | 13 ++- .../TARDIS/console/ConsoleInteraction.java | 54 +++++---- .../console/ConsoleInteractionListener.java | 32 ++--- .../TARDIS/console/InteractionResponse.java | 25 ++++ .../interaction/DirectionInteraction.java | 8 +- .../interaction/DoorToggleInteraction.java | 11 +- .../interaction/FastReturnInteraction.java | 33 +++++- .../interaction/FlightModeInteraction.java | 3 +- .../HelmicRegulatorInteraction.java | 29 ++++- .../interaction/LampLevelInteraction.java | 29 ++++- .../interaction/LightLevelInteraction.java | 29 ++++- .../interaction/LightSwitchInteraction.java | 26 ++++- .../interaction/MultiplierInteraction.java | 16 --- .../interaction/MultiplierXZInteraction.java | 24 ++++ .../interaction/RandomiserInteraction.java | 52 ++++++++- .../interaction/ScreenInteraction.java | 1 + .../TelepathicCircuitInteraction.java | 18 ++- .../interaction/ThrottleInteraction.java | 29 ++++- .../interaction/WayPointInteraction.java | 13 ++- .../console/interaction/WorldInteraction.java | 18 ++- .../console/interaction/XInteraction.java | 16 --- .../console/interaction/ZInteraction.java | 16 --- .../telepathic/TARDISTelepathicBiome.java | 25 ++++ .../telepathic/TARDISTelepathicInventory.java | 25 ++++ .../telepathic/TARDISTelepathicStructure.java | 25 ++++ .../telepathic/TelepathicBiomeListener.java | 11 ++ .../telepathic/TelepathicGUIListener.java | 11 ++ .../TelepathicStructureListener.java | 11 ++ .../control/TARDISControlMenuListener.java | 46 ++------ .../TARDIS/control/TARDISRandomButton.java | 4 +- .../control/actions/DirectionAction.java | 58 +++++++++ .../control/actions/LightLevelAction.java | 74 ++++++++++++ .../actions/RandomDestinationAction.java | 3 +- .../database/InteractionStateSaver.java | 43 +++++++ .../TARDIS/database/QueryFactory.java | 41 +++++++ .../ResultSetRandomInteractions.java | 110 ++++++++++++++++++ .../listeners/TARDISEntityDeathListener.java | 28 +++++ .../TARDISLightLevelFrameListener.java | 63 +--------- .../TARDIS/move/TARDISMonsterRunnable.java | 12 +- .../TARDIS/travel/TARDISTimeTravel.java | 103 ++++++++-------- src/main/resources/planets.yml | 5 + todo.md | 3 +- 43 files changed, 928 insertions(+), 279 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/InteractionResponse.java delete mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierXZInteraction.java delete mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/XInteraction.java delete mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/ZInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicBiome.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicInventory.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicStructure.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicBiomeListener.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicStructureListener.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/control/actions/DirectionAction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/control/actions/LightLevelAction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/database/InteractionStateSaver.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetRandomInteractions.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISEntityDeathListener.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java b/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java index 43a17576b..4d9b0b01f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java +++ b/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java @@ -203,6 +203,7 @@ public class TARDIS extends JavaPlugin { private NamespacedKey timeLordUuidKey; private NamespacedKey standUuidKey; private NamespacedKey interactionUuidKey; + private NamespacedKey unaryKey; private NamespacedKey blueprintKey; private NamespacedKey sonicUuidKey; private NamespacedKey sonicChargeKey; @@ -308,6 +309,7 @@ public void onEnable() { timeLordUuidKey = new NamespacedKey(this, "timelord_uuid"); standUuidKey = new NamespacedKey(this, "stand_uuid"); interactionUuidKey = new NamespacedKey(this, "interaction_uuid"); + unaryKey = new NamespacedKey(this, "unary"); blueprintKey = new NamespacedKey(this, "blueprint"); sonicUuidKey = new NamespacedKey(this, "sonic_uuid"); sonicChargeKey = new NamespacedKey(this, "sonic_charge"); @@ -1335,6 +1337,15 @@ public NamespacedKey getInteractionUuidKey() { return interactionUuidKey; } + /** + * Gets the console interaction unary NamespacedKey + * + * @return the console interaction unary NamespacedKey + */ + public NamespacedKey getUnaryKey() { + return unaryKey; + } + /** * Gets the TARDIS Blueprint NamespacedKey * diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index cac9da2cf..9b1db3ae6 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -62,15 +62,24 @@ public void create(Block block, int type, int id) { Location location = block.getLocation().clone().add(x, 1, z); Interaction interaction = (Interaction) location.getWorld().spawnEntity(location, EntityType.INTERACTION); interaction.getPersistentDataContainer().set(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID(), interaction.getUniqueId()); + if (i == ConsoleInteraction.THROTTLE) { + interaction.getPersistentDataContainer().set(plugin.getUnaryKey(), PersistentDataType.INTEGER, -1); + } + if (i == ConsoleInteraction.EXTERIOR_LAMP_LEVEL_SWITCH || i == ConsoleInteraction.INTERIOR_LIGHT_LEVEL_SWITCH) { + interaction.getPersistentDataContainer().set(plugin.getUnaryKey(), PersistentDataType.INTEGER, 1); + // add a control record + int cid = (i == ConsoleInteraction.EXTERIOR_LAMP_LEVEL_SWITCH) ? 49 : 50; + plugin.getQueryFactory().insertControl(id, cid, location.toString(), 0); + } interaction.setInteractionWidth(i.getWidth()); interaction.setInteractionHeight(i.getHeight()); interaction.setPersistent(true); interaction.setInvulnerable(true); - HashMap data = new HashMap<>(); + HashMap data = new HashMap<>(); data.put("tardis_id", id); data.put("uuid", interaction.getUniqueId()); data.put("control", i.toString()); - data.put("state", 0); + data.put("state", i.getDefaultState()); plugin.getQueryFactory().doInsert("interactions", data); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java index 774903ee5..a713bd95d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java @@ -5,50 +5,52 @@ public enum ConsoleInteraction { // section zero - HANDBRAKE("Time Rotor Handbrake", new Vector(0.0d, 1d, 2.25d), 0.5f, 0.4f), - THROTTLE("Flight Speed", new Vector(0.9d, 1.0d, 2.375d), 0.5f, 0.33f), - RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.575d, 1.0d, 1.75d), 0.5f, 0.65f), + HANDBRAKE("Time Rotor Handbrake", new Vector(0.0d, 1d, 2.25d), 0.5f, 0.4f, 1), + THROTTLE("Flight Speed", new Vector(0.9d, 1.0d, 2.375d), 0.5f, 0.33f, 4), + RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.575d, 1.0d, 1.75d), 0.5f, 0.65f, 1), // section one - WORLD("Environment Selector", new Vector(-0.525d, 1.0d, 0.95d), 0.15f, 0.65f), - MULTIPLIER("Coordinate Increment Modifier", new Vector(-0.4d, 1.0d, 1.2d), 0.15f, 0.65f), - X("X Distance", new Vector(-0.75d, 1.0d, 1.1d), 0.15f, 0.4f), - Z("Z Distance", new Vector(-0.6d, 1.0d, 1.3d), 0.15f, 0.4f), - HELMIC_REGULATOR("Dimension Selector", new Vector(-0.85d, 1d, 1.8d), 0.5f, 0.6f), + WORLD("Environment Selector", new Vector(-0.525d, 1.0d, 0.95d), 0.15f, 0.65f, 1), + MULTIPLIER("Coordinate Increment Modifier", new Vector(-0.4d, 1.0d, 1.2d), 0.15f, 0.65f, 1), + X("X Distance", new Vector(-0.75d, 1.0d, 1.1d), 0.15f, 0.4f, 1), + Z("Z Distance", new Vector(-0.6d, 1.0d, 1.3d), 0.15f, 0.4f, 1), + HELMIC_REGULATOR("Dimension Selector", new Vector(-0.85d, 1d, 1.8d), 0.5f, 0.6f, 0), // section two - RANDOMISER("Random Location Finder", new Vector(-0.85d, 1d, -0.8125d), 0.25f, 0.33f), - WAYPOINT_SELECTOR("Saves", new Vector(-1.1d, 1d, -0.4d), 0.25f, 0.33f), - FAST_RETURN("Back Button", new Vector(-1.35d, 1d, 0d), 0.25f, 0.33f), - TELEPATHIC_CIRCUIT("Telepathic Circuit", new Vector(-0.55d, 1d, -0.15d), 0.5f, 0.65f), + RANDOMISER("Random Location Finder", new Vector(-0.85d, 1d, -0.8125d), 0.25f, 0.33f, 0), + WAYPOINT_SELECTOR("Saves", new Vector(-1.1d, 1d, -0.4d), 0.25f, 0.33f, 0), + FAST_RETURN("Back Button", new Vector(-1.35d, 1d, 0d), 0.25f, 0.33f, 0), + TELEPATHIC_CIRCUIT("Telepathic Circuit", new Vector(-0.55d, 1d, -0.15d), 0.5f, 0.65f, 0), // section three - SONIC_DOCK("Sonic Screwdriver Dock", new Vector(0.45d, 1d, -0.65d), 0.5f, 0.65f), - DIRECTION("Exterior Directional Control", new Vector(0.125d, 1d, -1.2d), 0.625f, 0.5f), + SONIC_DOCK("Sonic Screwdriver Dock", new Vector(0.45d, 1d, -0.65d), 0.5f, 0.65f, 0), + DIRECTION("Exterior Directional Control", new Vector(0.125d, 1d, -1.2d), 0.625f, 0.5f, 0), // section four - LIGHT_SWITCH("Interior Light Switch", new Vector(2.475d, 1d, 0.1d), 0.25f, 0.33f), - INTERIOR_LIGHT_LEVEL_SWITCH("Interior Light Level", new Vector(1.8d, 1d, 0.0d), 0.25f, 0.5f), - EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Lamp Level", new Vector(1.5d, 1d, -0.3d), 0.25f, 0.5f), - DOOR_TOGGLE("Toggle Wool Switch", new Vector(1.825d, 1d, -1.0d), 0.25f, 0.33f), + LIGHT_SWITCH("Interior Light Switch", new Vector(2.475d, 1d, 0.1d), 0.25f, 0.33f, 0), + INTERIOR_LIGHT_LEVEL_SWITCH("Interior Light Level", new Vector(1.8d, 1d, 0.0d), 0.25f, 0.5f, 0), + EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Lamp Level", new Vector(1.5d, 1d, -0.3d), 0.25f, 0.5f, 0), + DOOR_TOGGLE("Toggle Wool Switch", new Vector(1.825d, 1d, -1.0d), 0.25f, 0.33f, 0), // section five - SCREEN_RIGHT("Coordinates Display", new Vector(1.825d, 1d, 0.95d), 0.5f, 1.1f), - SCREEN_LEFT("Information Display", new Vector(1.525d, 1d, 1.45d), 0.5f, 1.1f), - SCANNER("Exterior Environment Scanner", new Vector(1.825d, 1d, 1.95d), 0.25f, 0.33f), - ARTRON("Artron Energy Button", new Vector(2.125d, 1d, 1.475d), 0.25f, 0.33f), - REBUILD("Chameleon Circuit Re-initialiser", new Vector(2.4d, 1d, 1.025d), 0.25f, 0.33f); + SCREEN_RIGHT("Coordinates Display", new Vector(1.825d, 1d, 0.95d), 0.5f, 1.1f, 0), + SCREEN_LEFT("Information Display", new Vector(1.525d, 1d, 1.45d), 0.5f, 1.1f, 0), + SCANNER("Exterior Environment Scanner", new Vector(1.825d, 1d, 1.95d), 0.25f, 0.33f, 0), + ARTRON("Artron Energy Button", new Vector(2.125d, 1d, 1.475d), 0.25f, 0.33f, 0), + REBUILD("Chameleon Circuit Re-initialiser", new Vector(2.4d, 1d, 1.025d), 0.25f, 0.33f, 0); private final String alternateName; private final Vector relativePosition; private final float width; private final float height; + private final int defaultState; - ConsoleInteraction(String alternateName, Vector relativePosition, float width, float height) { + ConsoleInteraction(String alternateName, Vector relativePosition, float width, float height, int defaultState) { this.alternateName = alternateName; this.relativePosition = relativePosition; this.width = width; this.height = height; + this.defaultState = defaultState; } public String getAlternateName() { @@ -66,4 +68,8 @@ public float getWidth() { public float getHeight() { return height; } + + public int getDefaultState() { + return defaultState; + } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index 2cc03515a..0186c9d31 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -29,33 +29,33 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { ConsoleInteraction ci = rsi.getControl(); int id = rsi.getTardisId(); Player player = event.getPlayer(); + int state = rsi.getState(); switch (ci) { // section zero - case HANDBRAKE -> new HandbrakeInteraction(plugin).process(id, rsi.getState(), player, interaction.getLocation()); - case THROTTLE -> new ThrottleInteraction(plugin).process(player); + case HANDBRAKE -> + new HandbrakeInteraction(plugin).process(id, state, player, interaction.getLocation()); + case THROTTLE -> new ThrottleInteraction(plugin).process(player, interaction, id); case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(player); // section one - case WORLD -> new WorldInteraction(plugin).selectWorld(); - case MULTIPLIER -> new MultiplierInteraction(plugin).setRange(); - case X -> new XInteraction(plugin).setRange(); - case Z -> new ZInteraction(plugin).setRange(); + case WORLD -> new WorldInteraction(plugin).selectWorld(state, player, id); + case MULTIPLIER, X, Z -> new MultiplierXZInteraction(plugin).setRange(ci, state, id, player); case HELMIC_REGULATOR -> { - // TODO add config options to planets.yml - helmic_regulator: [1-8|-1] - new HelmicRegulatorInteraction(plugin).selectWorld(); + // TODO add config options to planets.yml - helmic_regulator_order: [1-8|-1] + new HelmicRegulatorInteraction(plugin).selectWorld(state, id, player); } // section two case RANDOMISER -> new RandomiserInteraction(plugin).generateDestination(id, player); - case WAYPOINT_SELECTOR -> new WayPointInteraction(plugin).openSaveGUI(); - case FAST_RETURN -> new FastReturnInteraction(plugin).setBack(); - case TELEPATHIC_CIRCUIT -> new TelepathicCircuitInteraction(plugin).openGUI(); + case WAYPOINT_SELECTOR -> new WayPointInteraction(plugin).openSaveGUI(id, player); + case FAST_RETURN -> new FastReturnInteraction(plugin).setBack(id, player); + case TELEPATHIC_CIRCUIT -> new TelepathicCircuitInteraction(plugin).openGUI(player); // section three case SONIC_DOCK -> new SonicDockInteraction(plugin).process(player, interaction, id); - case DIRECTION -> new DirectionInteraction(plugin).rotate(); + case DIRECTION -> new DirectionInteraction(plugin).rotate(id, player); // section four - case LIGHT_SWITCH -> new LightSwitchInteraction(plugin).toggle(); - case INTERIOR_LIGHT_LEVEL_SWITCH -> new LightLevelInteraction(plugin).setInterior(); - case EXTERIOR_LAMP_LEVEL_SWITCH -> new LampLevelInteraction(plugin).setExterior(); - case DOOR_TOGGLE -> new DoorToggleInteraction(plugin).toggle(); + case LIGHT_SWITCH -> new LightSwitchInteraction(plugin).toggle(id, player); + case INTERIOR_LIGHT_LEVEL_SWITCH -> new LightLevelInteraction(plugin).setInterior(state, id, interaction, player); + case EXTERIOR_LAMP_LEVEL_SWITCH -> new LampLevelInteraction(plugin).setExterior(state, id, interaction, player); + case DOOR_TOGGLE -> new DoorToggleInteraction(plugin).toggle(id, player); // section five case SCREEN_LEFT, SCREEN_RIGHT -> new ScreenInteraction(plugin).display(id, interaction.getLocation(), ci == ConsoleInteraction.SCREEN_RIGHT); case SCANNER -> new ScannerIntraction(plugin).process(id, player); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/InteractionResponse.java b/src/main/java/me/eccentric_nz/TARDIS/console/InteractionResponse.java new file mode 100644 index 000000000..f2eea8f16 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/InteractionResponse.java @@ -0,0 +1,25 @@ +package me.eccentric_nz.TARDIS.console; + +import me.eccentric_nz.TARDIS.TARDIS; + +import java.util.HashMap; +import java.util.List; + +public class InteractionResponse { + + public static final HashMap> randomRange = new HashMap<>(); + public static final List environment = List.of("", "Current world", "Overworld", "The Nether", "The End"); + public static final List levels = List.of(15, 13, 12, 11, 9, 7, 5, 3); + private final int quarter; + + public InteractionResponse(TARDIS plugin) { + int max = plugin.getConfig().getInt("travel.tp_radius"); + this.quarter = (max + 4 - 1) / 4; + } + + public void init() { + randomRange.put(ConsoleInteraction.MULTIPLIER, List.of("", "1x", "2x", "3x", "4x")); + randomRange.put(ConsoleInteraction.X, List.of("", "r = " + (quarter), "r = " + (quarter * 2), "r = " + (quarter * 3), "r = " + (quarter * 4))); + randomRange.put(ConsoleInteraction.Z, List.of("", "r = " + (quarter), "r = " + (quarter * 2), "r = " + (quarter * 3), "r = " + (quarter * 4))); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java index 667a0f3ba..d3954d9e1 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java @@ -1,6 +1,8 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.control.actions.DirectionAction; +import org.bukkit.entity.Player; public class DirectionInteraction { @@ -10,7 +12,9 @@ public DirectionInteraction(TARDIS plugin) { this.plugin = plugin; } - public void rotate() { - + public void rotate(int id, Player player) { + String direction = new DirectionAction(plugin).rotate(id, player); + plugin.getMessenger().announceRepeater(player, direction); + // TODO set custom model data for direction item display } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java index 7932b872f..7b2321cbf 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java @@ -1,6 +1,9 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import me.eccentric_nz.TARDIS.move.TARDISBlackWoolToggler; +import org.bukkit.entity.Player; public class DoorToggleInteraction { @@ -10,7 +13,11 @@ public DoorToggleInteraction(TARDIS plugin) { this.plugin = plugin; } - public void toggle() { - + public void toggle(int id, Player player) { + if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); + return; + } + new TARDISBlackWoolToggler(plugin).toggleBlocks(id, player); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java index abbce0078..12f700d65 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java @@ -1,6 +1,15 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.advanced.TARDISCircuitChecker; +import me.eccentric_nz.TARDIS.control.actions.FastReturnAction; +import me.eccentric_nz.TARDIS.database.data.Tardis; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; +import me.eccentric_nz.TARDIS.enumeration.Difficulty; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.entity.Player; + +import java.util.HashMap; public class FastReturnInteraction { @@ -10,7 +19,27 @@ public FastReturnInteraction(TARDIS plugin) { this.plugin = plugin; } - public void setBack() { - + public void setBack(int id, Player player) { + if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); + return; + } + TARDISCircuitChecker tcc = null; + if (!plugin.getDifficulty().equals(Difficulty.EASY)) { + tcc = new TARDISCircuitChecker(plugin, id); + tcc.getCircuits(); + } + if (tcc != null && !tcc.hasInput() && !plugin.getUtils().inGracePeriod(player, false)) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "INPUT_MISSING"); + return; + } + HashMap where = new HashMap<>(); + where.put("tardis_id", id); + ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); + if (!rs.resultSet()) { + return; + } + Tardis tardis = rs.getTardis(); + new FastReturnAction(plugin).clickButton(player, id, tardis); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java index 985513036..fdc5dcc18 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java @@ -3,7 +3,6 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; import me.eccentric_nz.TARDIS.enumeration.FlightMode; -import me.eccentric_nz.TARDIS.enumeration.TardisModule; import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; import org.bukkit.entity.Player; @@ -33,7 +32,7 @@ public void process(Player player) { HashMap where = new HashMap<>(); where.put("uuid", player.getUniqueId().toString()); TARDIS.plugin.getQueryFactory().doUpdate("player_prefs", setf, where); - plugin.getMessenger().send(player, TardisModule.TARDIS, "FLIGHT_SAVED"); +// plugin.getMessenger().send(player, TardisModule.TARDIS, "FLIGHT_SAVED"); // TODO set custom model data for relativity differentiator item display // TODO make relativity differentiator standalone control set player_prefs flightmode when toggled - exterior|normal // TODO then alter `isRelativityDifferentiated()` to check player prefs instead diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java index 9ba9d9759..6f751a516 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java @@ -1,6 +1,8 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.InteractionStateSaver; +import org.bukkit.entity.Player; public class HelmicRegulatorInteraction { @@ -10,7 +12,32 @@ public HelmicRegulatorInteraction(TARDIS plugin) { this.plugin = plugin; } - public void selectWorld() { + public void selectWorld(int state, int id, Player player) { + int next = state + 1; + if (next > 8 || player.isSneaking()) { + next = 0; + } + String which = "OFF"; + if (next > 0) { + // get world name + which = getWorldFromState(next); + } + // show title + plugin.getMessenger().announceRepeater(player, which); + if (which.equals("OFF")) { + next = 0; + } + // save state + new InteractionStateSaver(plugin).write("HELMIC_REGULATOR", next, id); + // TODO set custom model data for helmic regulator item display + } + private String getWorldFromState(int state) { + for (String w : plugin.getPlanetsConfig().getConfigurationSection("planets").getKeys(false)) { + if (plugin.getPlanetsConfig().getInt("planets." + w + ".helmic_regulator_order") == state) { + return w; + } + } + return "OFF"; } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java index 741a186a5..4c01c0cc7 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java @@ -1,6 +1,13 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.InteractionResponse; +import me.eccentric_nz.TARDIS.control.actions.LightLevelAction; +import me.eccentric_nz.TARDIS.database.InteractionStateSaver; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetLightLevel; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.Player; +import org.bukkit.persistence.PersistentDataType; public class LampLevelInteraction { @@ -10,7 +17,25 @@ public LampLevelInteraction(TARDIS plugin) { this.plugin = plugin; } - public void setExterior() { - + public void setExterior(int state, int id, Interaction interaction, Player player) { + int unary = interaction.getPersistentDataContainer().getOrDefault(plugin.getUnaryKey(), PersistentDataType.INTEGER, 1); + int setLevel = state + unary; + if (setLevel > 7) { + setLevel = 6; + unary = -1; + } + if (setLevel < 0) { + setLevel = 1; + unary = 1; + } + interaction.getPersistentDataContainer().set(plugin.getUnaryKey(), PersistentDataType.INTEGER, unary); + // TODO set custom model data for lamp level switch item display + // get light level record + ResultSetLightLevel rs = new ResultSetLightLevel(plugin, interaction.getLocation().toString()); + if (rs.resultSet()) { + new LightLevelAction(plugin).illuminate(setLevel - 1, rs.getControlId(), rs.isPowered(), 49, rs.isPoliceBox(), id, rs.isLightsOn()); + new InteractionStateSaver(plugin).write("EXTERIOR_LAMP_LEVEL_SWITCH", setLevel, id); + plugin.getMessenger().announceRepeater(player, "Lamp level: " + InteractionResponse.levels.get(setLevel)); + } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java index bf77615e8..78949454d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java @@ -1,6 +1,13 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.InteractionResponse; +import me.eccentric_nz.TARDIS.control.actions.LightLevelAction; +import me.eccentric_nz.TARDIS.database.InteractionStateSaver; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetLightLevel; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.Player; +import org.bukkit.persistence.PersistentDataType; public class LightLevelInteraction { @@ -10,7 +17,25 @@ public LightLevelInteraction(TARDIS plugin) { this.plugin = plugin; } - public void setInterior() { - + public void setInterior(int state, int id, Interaction interaction, Player player) { + int unary = interaction.getPersistentDataContainer().getOrDefault(plugin.getUnaryKey(), PersistentDataType.INTEGER, 1); + int setLevel = state + unary; + if (setLevel > 7) { + setLevel = 6; + unary = -1; + } + if (setLevel < 0) { + setLevel = 1; + unary = 1; + } + interaction.getPersistentDataContainer().set(plugin.getUnaryKey(), PersistentDataType.INTEGER, unary); + // TODO set custom model data for light level switch item display + // get light level record + ResultSetLightLevel rs = new ResultSetLightLevel(plugin, interaction.getLocation().toString()); + if (rs.resultSet()) { + new LightLevelAction(plugin).illuminate(setLevel - 1, rs.getControlId(), rs.isPowered(), 50, rs.isPoliceBox(), id, rs.isLightsOn()); + new InteractionStateSaver(plugin).write("INTERIOR_LIGHT_LEVEL_SWITCH", setLevel, id); + plugin.getMessenger().announceRepeater(player, "Light level: " + InteractionResponse.levels.get(setLevel)); + } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java index 40c2336c2..552c22f3f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java @@ -1,6 +1,13 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.control.actions.LightSwitchAction; +import me.eccentric_nz.TARDIS.database.data.Tardis; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.entity.Player; + +import java.util.HashMap; public class LightSwitchInteraction { @@ -10,7 +17,22 @@ public LightSwitchInteraction(TARDIS plugin) { this.plugin = plugin; } - public void toggle() { - + public void toggle(int id, Player player) { + if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); + return; + } + HashMap where = new HashMap<>(); + where.put("tardis_id", id); + ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); + if (!rs.resultSet()) { + return; + } + Tardis tardis = rs.getTardis(); + if (!tardis.isLightsOn() && plugin.getConfig().getBoolean("allow.power_down") && !tardis.isPoweredOn()) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); + return; + } + new LightSwitchAction(plugin, id, tardis.isLightsOn(), player, tardis.getSchematic().getLights()).flickSwitch(); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierInteraction.java deleted file mode 100644 index 6f761ca89..000000000 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierInteraction.java +++ /dev/null @@ -1,16 +0,0 @@ -package me.eccentric_nz.TARDIS.console.interaction; - -import me.eccentric_nz.TARDIS.TARDIS; - -public class MultiplierInteraction { - - private final TARDIS plugin; - - public MultiplierInteraction(TARDIS plugin) { - this.plugin = plugin; - } - - public void setRange() { - - } -} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierXZInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierXZInteraction.java new file mode 100644 index 000000000..2d2b898c6 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierXZInteraction.java @@ -0,0 +1,24 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.ConsoleInteraction; +import me.eccentric_nz.TARDIS.database.InteractionStateSaver; +import org.bukkit.entity.Player; + +public class MultiplierXZInteraction { + + private final TARDIS plugin; + + public MultiplierXZInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void setRange(ConsoleInteraction ci, int state, int id, Player player) { + int next = state + 1; + if (next > 4) { + next = 1; + } + new InteractionStateSaver(plugin).write(ci.toString(), next, id); + plugin.getMessenger().announceRepeater(player, ci + ": " + next); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java index ca9b2ffd2..5b2fb08e1 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java @@ -2,11 +2,21 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.advanced.TARDISCircuitChecker; +import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; +import me.eccentric_nz.TARDIS.builders.TARDISEmergencyRelocation; import me.eccentric_nz.TARDIS.control.TARDISRandomButton; +import me.eccentric_nz.TARDIS.control.actions.ExileAction; +import me.eccentric_nz.TARDIS.control.actions.RandomDestinationAction; import me.eccentric_nz.TARDIS.database.data.Tardis; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentFromId; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetRandomInteractions; import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; +import me.eccentric_nz.TARDIS.enumeration.COMPASS; import me.eccentric_nz.TARDIS.enumeration.Difficulty; import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import me.eccentric_nz.TARDIS.travel.TARDISTimeTravel; +import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.entity.Player; import java.util.HashMap; @@ -42,6 +52,46 @@ public void generateDestination(int id, Player player) { return; } Tardis tardis = rs.getTardis(); - new TARDISRandomButton(plugin, player, id, tardis.getArtronLevel(), 0, tardis.getCompanions(), tardis.getUuid()).clickButton(); + int cost = plugin.getArtronConfig().getInt("random"); + if (tardis.getArtronLevel() < cost) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_ENOUGH_ENERGY"); + return; + } + ResultSetCurrentFromId rscl = new ResultSetCurrentFromId(plugin, id); + if (!rscl.resultSet()) { + // emergency TARDIS relocation + new TARDISEmergencyRelocation(plugin).relocate(id, player); + return; + } + COMPASS direction = rscl.getDirection(); + if (TARDISPermission.hasPermission(player, "tardis.exile") && plugin.getConfig().getBoolean("travel.exile")) { + new ExileAction(plugin).getExile(player, id, direction); + } else { + new TARDISRandomButton(plugin, player, id, tardis.getArtronLevel(), 0, tardis.getCompanions(), tardis.getUuid()).clickButton(); + // get state from WORLD, MULTIPLIER, X, Z and HELMIC_REGULATOR interactions + ResultSetRandomInteractions rsri = new ResultSetRandomInteractions(plugin, id); + if (rsri.resultSet()) { + // get if HELMIC_REGULATOR is active + if (rsri.getStates()[4] != 0) { + // get selected world + World world = getWorldFromState(rsri.getStates()[4]); + if (world != null) { + Location current = new Location(rscl.getWorld(), rscl.getX(), rscl.getY(), rscl.getZ()); + new TARDISTimeTravel(plugin).getDestination(world, rsri.getStates()[1], rsri.getStates()[2], rsri.getStates()[3], direction, world.getEnvironment().toString(), current, player); + } + } else { + new RandomDestinationAction(plugin).getRandomDestination(player, id, rsri.getStates(), rscl, direction, tardis.getArtronLevel(), cost, tardis.getCompanions(), tardis.getUuid()); + } + } + } + } + + private World getWorldFromState(int state) { + for (String w : plugin.getPlanetsConfig().getConfigurationSection("planets").getKeys(false)) { + if (plugin.getPlanetsConfig().getInt("planets." + w + ".helmic_regulator_order") == state) { + return plugin.getServer().getWorld(w); + } + } + return null; } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java index 7b6d81370..eaa26e576 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java @@ -17,6 +17,7 @@ public ScreenInteraction(TARDIS plugin) { } public void display(int id, Location location, boolean coords) { + // TODO if shift-click change display else open Control Menu GUI // get the text display TextDisplay display = getTextDisplay(location, coords); if (display != null) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java index 5332cb9b2..23db4e1b4 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java @@ -1,6 +1,11 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.telepathic.TARDISTelepathicInventory; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; public class TelepathicCircuitInteraction { @@ -10,7 +15,16 @@ public TelepathicCircuitInteraction(TARDIS plugin) { this.plugin = plugin; } - public void openGUI() { - + public void openGUI(Player player) { + // open new GUI for + // toggling telepathic circuit on/off + // cave finder + // structure finder + // biome finder + TARDISTelepathicInventory tti = new TARDISTelepathicInventory(plugin, player); + ItemStack[] gui = tti.getButtons(); + Inventory telepathic = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "TARDIS Telepathic Circuit"); + telepathic.setContents(gui); + player.openInventory(telepathic); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java index 56103ed8f..a95739296 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java @@ -1,29 +1,47 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.InteractionStateSaver; import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; import me.eccentric_nz.TARDIS.enumeration.SpaceTimeThrottle; -import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.entity.Interaction; import org.bukkit.entity.Player; +import org.bukkit.persistence.PersistentDataType; import java.util.HashMap; public class ThrottleInteraction { + private final TARDIS plugin; public ThrottleInteraction(TARDIS plugin) { this.plugin = plugin; } - public void process(Player player) { + public void process(Player player, Interaction interaction, int id) { String uuid = player.getUniqueId().toString(); + int unary = interaction.getPersistentDataContainer().getOrDefault(plugin.getUnaryKey(), PersistentDataType.INTEGER, -1); // get current throttle setting ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, uuid); if (rsp.resultSet()) { - int delay = rsp.getThrottle() - 1; + /* + states should go up to fastest, then back down to slowest, rather than cycling + NORMAL => 4 + FASTER => 3 + RAPID => 2 + WARP => 1 + */ + int delay = rsp.getThrottle() + unary; if (delay < 1) { - delay = 4; + delay = 2; + unary = 1; + } + if (delay > 4) { + delay = 3; + unary = -1; } + // save unary value in the interaction PDC + interaction.getPersistentDataContainer().set(plugin.getUnaryKey(), PersistentDataType.INTEGER, unary); String throttle = SpaceTimeThrottle.getByDelay().get(delay).toString(); // update player prefs HashMap wherer = new HashMap<>(); @@ -31,7 +49,8 @@ public void process(Player player) { HashMap setr = new HashMap<>(); setr.put("throttle", delay); plugin.getQueryFactory().doUpdate("player_prefs", setr, wherer); - plugin.getMessenger().send(player, TardisModule.TARDIS, "THROTTLE", throttle); + new InteractionStateSaver(plugin).write("THROTTLE", delay, id); + plugin.getMessenger().announceRepeater(player, throttle); // TODO set custom model data for throttle item display } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java index 60b7c76a0..dcfedb36b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java @@ -1,6 +1,11 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.travel.save.TARDISSavesPlanetInventory; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; public class WayPointInteraction { @@ -10,7 +15,11 @@ public WayPointInteraction(TARDIS plugin) { this.plugin = plugin; } - public void openSaveGUI() { - + public void openSaveGUI(int id, Player player) { + TARDISSavesPlanetInventory tssi = new TARDISSavesPlanetInventory(plugin, id); + ItemStack[] saves = tssi.getPlanets(); + Inventory saved = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "TARDIS Dimension Map"); + saved.setContents(saves); + player.openInventory(saved); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java index 58180ac82..f56927353 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java @@ -1,6 +1,9 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.InteractionResponse; +import me.eccentric_nz.TARDIS.database.InteractionStateSaver; +import org.bukkit.entity.Player; public class WorldInteraction { @@ -10,7 +13,18 @@ public WorldInteraction(TARDIS plugin) { this.plugin = plugin; } - public void selectWorld() { - + public void selectWorld(int state, Player player, int id) { + /* + THIS => 1, + NORMAL => 2, + NETHER => 3, + THE_END => 4 + */ + int next = state + 1; + if (next > 4) { + next = 1; + } + new InteractionStateSaver(plugin).write("WORLD", next, id); + plugin.getMessenger().announceRepeater(player, InteractionResponse.environment.get(next)); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/XInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/XInteraction.java deleted file mode 100644 index 0fce6fdd1..000000000 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/XInteraction.java +++ /dev/null @@ -1,16 +0,0 @@ -package me.eccentric_nz.TARDIS.console.interaction; - -import me.eccentric_nz.TARDIS.TARDIS; - -public class XInteraction { - - private final TARDIS plugin; - - public XInteraction(TARDIS plugin) { - this.plugin = plugin; - } - - public void setRange() { - - } -} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ZInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ZInteraction.java deleted file mode 100644 index 1a272c215..000000000 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ZInteraction.java +++ /dev/null @@ -1,16 +0,0 @@ -package me.eccentric_nz.TARDIS.console.interaction; - -import me.eccentric_nz.TARDIS.TARDIS; - -public class ZInteraction { - - private final TARDIS plugin; - - public ZInteraction(TARDIS plugin) { - this.plugin = plugin; - } - - public void setRange() { - - } -} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicBiome.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicBiome.java new file mode 100644 index 000000000..b325284ed --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicBiome.java @@ -0,0 +1,25 @@ +package me.eccentric_nz.TARDIS.console.telepathic; + +import me.eccentric_nz.TARDIS.TARDIS; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class TARDISTelepathicBiome { + + private final TARDIS plugin; + private final Player player; + + public TARDISTelepathicBiome(TARDIS plugin, Player player) { + this.plugin = plugin; + this.player = player; + } + + public ItemStack[] getButtons() { + // TODO build buttons + // toggling telepathic circuit on/off + // cave finder + // structure finder + // biome finder + return new ItemStack[54]; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicInventory.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicInventory.java new file mode 100644 index 000000000..1bbff53d0 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicInventory.java @@ -0,0 +1,25 @@ +package me.eccentric_nz.TARDIS.console.telepathic; + +import me.eccentric_nz.TARDIS.TARDIS; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class TARDISTelepathicInventory { + + private final TARDIS plugin; + private final Player player; + + public TARDISTelepathicInventory(TARDIS plugin, Player player) { + this.plugin = plugin; + this.player = player; + } + + public ItemStack[] getButtons() { + // TODO build buttons + // toggling telepathic circuit on/off + // cave finder + // structure finder + // biome finder + return new ItemStack[54]; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicStructure.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicStructure.java new file mode 100644 index 000000000..2825a5ead --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicStructure.java @@ -0,0 +1,25 @@ +package me.eccentric_nz.TARDIS.console.telepathic; + +import me.eccentric_nz.TARDIS.TARDIS; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class TARDISTelepathicStructure { + + private final TARDIS plugin; + private final Player player; + + public TARDISTelepathicStructure(TARDIS plugin, Player player) { + this.plugin = plugin; + this.player = player; + } + + public ItemStack[] getButtons() { + // TODO build buttons + // toggling telepathic circuit on/off + // cave finder + // structure finder + // biome finder + return new ItemStack[54]; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicBiomeListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicBiomeListener.java new file mode 100644 index 000000000..b5a0539e0 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicBiomeListener.java @@ -0,0 +1,11 @@ +package me.eccentric_nz.TARDIS.console.telepathic; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.listeners.TARDISMenuListener; + +public class TelepathicBiomeListener extends TARDISMenuListener { + + public TelepathicBiomeListener(TARDIS plugin) { + super(plugin); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java new file mode 100644 index 000000000..8a122ded3 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java @@ -0,0 +1,11 @@ +package me.eccentric_nz.TARDIS.console.telepathic; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.listeners.TARDISMenuListener; + +public class TelepathicGUIListener extends TARDISMenuListener { + + public TelepathicGUIListener(TARDIS plugin) { + super(plugin); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicStructureListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicStructureListener.java new file mode 100644 index 000000000..767c0a39e --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicStructureListener.java @@ -0,0 +1,11 @@ +package me.eccentric_nz.TARDIS.console.telepathic; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.listeners.TARDISMenuListener; + +public class TelepathicStructureListener extends TARDISMenuListener { + + public TelepathicStructureListener(TARDIS plugin) { + super(plugin); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlMenuListener.java b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlMenuListener.java index 08d3a3a90..2ef3e3c52 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlMenuListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlMenuListener.java @@ -23,16 +23,19 @@ import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; import me.eccentric_nz.TARDIS.chameleon.gui.TARDISChameleonInventory; import me.eccentric_nz.TARDIS.commands.preferences.TARDISPrefsMenuInventory; -import me.eccentric_nz.TARDIS.commands.tardis.TARDISDirectionCommand; import me.eccentric_nz.TARDIS.commands.tardis.TARDISHideCommand; import me.eccentric_nz.TARDIS.commands.tardis.TARDISRebuildCommand; import me.eccentric_nz.TARDIS.companionGUI.TARDISCompanionAddInventory; import me.eccentric_nz.TARDIS.companionGUI.TARDISCompanionInventory; +import me.eccentric_nz.TARDIS.control.actions.DirectionAction; import me.eccentric_nz.TARDIS.control.actions.FastReturnAction; import me.eccentric_nz.TARDIS.control.actions.LightSwitchAction; import me.eccentric_nz.TARDIS.control.actions.SiegeAction; import me.eccentric_nz.TARDIS.database.data.Tardis; -import me.eccentric_nz.TARDIS.database.resultset.*; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardisID; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTravellers; import me.eccentric_nz.TARDIS.enumeration.COMPASS; import me.eccentric_nz.TARDIS.enumeration.Difficulty; import me.eccentric_nz.TARDIS.enumeration.SpaceTimeThrottle; @@ -398,39 +401,14 @@ public void onControlMenuInteract(InventoryClickEvent event) { } case 40 -> { // direction - if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); - return; - } - HashMap whered = new HashMap<>(); - whered.put("tardis_id", id); - ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, whered); - String direction = "EAST"; - if (rsc.resultSet()) { - direction = rsc.getDirection().toString(); - if (!tardis.getPreset().usesArmourStand()) { - // skip the angled rotations - switch (rsc.getDirection()) { - case SOUTH -> direction = "SOUTH_WEST"; - case EAST -> direction = "SOUTH_EAST"; - case NORTH -> direction = "NORTH_EAST"; - case WEST -> direction = "NORTH_WEST"; - default -> {} - } - } - int ordinal = COMPASS.valueOf(direction).ordinal() + 1; - if (ordinal == 8) { - ordinal = 0; - } - direction = COMPASS.values()[ordinal].toString(); + String direction = new DirectionAction(plugin).rotate(id, player); + if (!direction.isEmpty()) { + // update the lore + ItemStack d = view.getItem(40); + ItemMeta im = d.getItemMeta(); + im.setLore(Collections.singletonList(direction)); + d.setItemMeta(im); } - String[] args = new String[]{"direction", direction}; - new TARDISDirectionCommand(plugin).changeDirection(player, args); - // update the lore - ItemStack d = view.getItem(40); - ItemMeta im = d.getItemMeta(); - im.setLore(Collections.singletonList(direction)); - d.setItemMeta(im); } case 45 -> { // destination terminal diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISRandomButton.java b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISRandomButton.java index 9a33da26d..474caf2b6 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISRandomButton.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISRandomButton.java @@ -73,10 +73,8 @@ public void clickButton() { ResultSetRepeaters rsr = new ResultSetRepeaters(plugin, id, secondary); if (rsr.resultSet()) { int[] repeaters = rsr.getRepeaters(); - new RandomDestinationAction(plugin).getRandomDestination(player, id, repeaters, rscl, direction, level, cost); + new RandomDestinationAction(plugin).getRandomDestination(player, id, repeaters, rscl, direction, level, cost, comps, ownerUUID); } } } - - } diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/DirectionAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/DirectionAction.java new file mode 100644 index 000000000..2d3c8d2af --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/DirectionAction.java @@ -0,0 +1,58 @@ +package me.eccentric_nz.TARDIS.control.actions; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.commands.tardis.TARDISDirectionCommand; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentLocation; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; +import me.eccentric_nz.TARDIS.enumeration.COMPASS; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.entity.Player; + +import java.util.HashMap; + +public class DirectionAction { + + private final TARDIS plugin; + + public DirectionAction(TARDIS plugin) { + this.plugin = plugin; + } + + public String rotate(int id, Player player) { + if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); + return ""; + } + HashMap whered = new HashMap<>(); + whered.put("tardis_id", id); + ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, whered); + if (rsc.resultSet()) { + String direction = rsc.getDirection().toString(); + HashMap wheret = new HashMap<>(); + wheret.put("tardis_id", id); + ResultSetTardis rst = new ResultSetTardis(plugin, wheret, "", false, 0); + if (rst.resultSet()) { + if (!rst.getTardis().getPreset().usesArmourStand()) { + // skip the angled rotations + switch (rsc.getDirection()) { + case SOUTH -> direction = "SOUTH_WEST"; + case EAST -> direction = "SOUTH_EAST"; + case NORTH -> direction = "NORTH_EAST"; + case WEST -> direction = "NORTH_WEST"; + default -> { + } + } + } + int ordinal = COMPASS.valueOf(direction).ordinal() + 1; + if (ordinal == 8) { + ordinal = 0; + } + direction = COMPASS.values()[ordinal].toString(); + } + String[] args = new String[]{"direction", direction}; + new TARDISDirectionCommand(plugin).changeDirection(player, args); + return direction; + } + return ""; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/LightLevelAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/LightLevelAction.java new file mode 100644 index 000000000..3eabfba58 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/LightLevelAction.java @@ -0,0 +1,74 @@ +package me.eccentric_nz.TARDIS.control.actions; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.builders.LightLevel; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentFromId; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetLamps; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Levelled; + +import java.util.HashMap; + +public class LightLevelAction { + + private final TARDIS plugin; + + public LightLevelAction(TARDIS plugin) { + this.plugin = plugin; + } + + public void illuminate(int level, int control, boolean powered, int type, boolean policebox, int id, boolean lightsOn) { + // save the level to the database + int setLevel = (level + 1) > 3 ? 0 : level + 1; + HashMap set = new HashMap<>(); + set.put("secondary", setLevel); + HashMap where = new HashMap<>(); + where.put("c_id", control); + plugin.getQueryFactory().doSyncUpdate("controls", set, where); + // alter light levels + if (powered) { + int light_level; + if (type == 49) { + // exterior + if (!policebox) { + return; + } + light_level = LightLevel.exterior_level[setLevel]; + // get current TARDIS location + ResultSetCurrentFromId rsc = new ResultSetCurrentFromId(plugin, id); + if (rsc.resultSet()) { + if (rsc.getWorld() == null) { + return; + } + Location location = new Location(rsc.getWorld(), rsc.getX(), rsc.getY(), rsc.getZ()); + while (!location.getChunk().isLoaded()) { + location.getChunk().load(); + } + Block light = location.getBlock().getRelative(BlockFace.UP, 2); + if (light.getBlockData() instanceof Levelled levelled) { + levelled.setLevel(light_level); + light.setBlockData(levelled); + } + } + } else if (lightsOn) { + // interior + light_level = LightLevel.interior_level[setLevel]; + // get TARDIS lights + HashMap whereLight = new HashMap<>(); + whereLight.put("tardis_id", id); + ResultSetLamps rsl = new ResultSetLamps(plugin, whereLight, true); + if (rsl.resultSet()) { + for (Block block : rsl.getData()) { + if (block.getBlockData() instanceof Levelled levelled) { + levelled.setLevel(light_level); + block.setBlockData(levelled); + } + } + } + } + } + } + +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/RandomDestinationAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/RandomDestinationAction.java index 8575a3bf6..10ae54d9a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/actions/RandomDestinationAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/RandomDestinationAction.java @@ -28,7 +28,7 @@ public RandomDestinationAction(TARDIS plugin) { this.plugin = plugin; } - public void getRandomDestination(Player player, int id, int[] repeaters, ResultSetCurrentFromId rscl, COMPASS direction, int level, int cost) { + public void getRandomDestination(Player player, int id, int[] repeaters, ResultSetCurrentFromId rscl, COMPASS direction, int level, int cost, String comps, UUID ownerUUID) { String environment = "THIS"; int nether_min = plugin.getArtronConfig().getInt("nether_min"); int the_end_min = plugin.getArtronConfig().getInt("the_end_min"); @@ -85,6 +85,7 @@ public void getRandomDestination(Player player, int id, int[] repeaters, ResultS plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_WORLD_TRAVEL"); return; } + HashMap set = new HashMap<>(); set.put("world", rand.getWorld().getName()); set.put("x", rand.getBlockX()); set.put("y", rand.getBlockY()); diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/InteractionStateSaver.java b/src/main/java/me/eccentric_nz/TARDIS/database/InteractionStateSaver.java new file mode 100644 index 000000000..c15ea7c86 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/database/InteractionStateSaver.java @@ -0,0 +1,43 @@ +package me.eccentric_nz.TARDIS.database; + +import me.eccentric_nz.TARDIS.TARDIS; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public class InteractionStateSaver { + + private final TARDISDatabaseConnection service = TARDISDatabaseConnection.getINSTANCE(); + private final Connection connection = service.getConnection(); + private final TARDIS plugin; + private final String prefix; + + public InteractionStateSaver(TARDIS plugin) { + this.plugin = plugin; + prefix = this.plugin.getPrefix(); + } + + public void write(String which, int state, int id) { + PreparedStatement statement = null; + String query = "UPDATE interactions SET state = ? WHERE tardis_id = ? AND control = ?"; + try { + service.testConnection(connection); + statement = connection.prepareStatement(query); + statement.setInt(1, state); + statement.setInt(2, id); + statement.setString(3, which); + statement.executeUpdate(); + } catch (SQLException e) { + plugin.debug("Update error for interactions state! " + e.getMessage()); + } finally { + try { + if (statement != null) { + statement.close(); + } + } catch (SQLException e) { + plugin.debug("Error closing interactions state! " + e.getMessage()); + } + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/QueryFactory.java b/src/main/java/me/eccentric_nz/TARDIS/database/QueryFactory.java index 4d918d130..eaf4d62d2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/QueryFactory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/QueryFactory.java @@ -449,4 +449,45 @@ public void updateFarmingPref(UUID uuid, String room, int onOff) { } } } + + public void doMonsterIncrement(int id) { + PreparedStatement ps = null; + String query = "UPDATE " + prefix + "tardis SET monsters = monsters + 1 WHERE tardis_id = ?"; + try { + service.testConnection(connection); + ps = connection.prepareStatement(query); + ps.setInt(1, id); + ps.executeUpdate(); + } catch (SQLException e) { + plugin.debug("Update error for tardis monsters +1! " + e.getMessage()); + } finally { + try { + if (ps != null) { + ps.close(); + } + } catch (SQLException e) { + plugin.debug("Error closing tardis monsters +1! " + e.getMessage()); + } + } + } + public void doMonsterDecrement(int id) { + PreparedStatement ps = null; + String query = "UPDATE " + prefix + "tardis SET monsters = monsters - 1 WHERE tardis_id = ?"; + try { + service.testConnection(connection); + ps = connection.prepareStatement(query); + ps.setInt(1, id); + ps.executeUpdate(); + } catch (SQLException e) { + plugin.debug("Update error for tardis monsters -1! " + e.getMessage()); + } finally { + try { + if (ps != null) { + ps.close(); + } + } catch (SQLException e) { + plugin.debug("Error closing tardis monsters -1! " + e.getMessage()); + } + } + } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetRandomInteractions.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetRandomInteractions.java new file mode 100644 index 000000000..d67fc20b9 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetRandomInteractions.java @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2024 eccentric_nz + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package me.eccentric_nz.TARDIS.database.resultset; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.TARDISDatabaseConnection; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; + +/** + * The sonic screwdriver is a highly versatile tool used by many, but not all, incarnations of the Doctor. The Doctor + * modified and ostensibly upgraded it over the years, giving it an increasing number of applications. + *

+ * Control types: 2 = environment-repeater 3 = x-repeater 4 = z-repeater 5 = y-repeater + * + * @author eccentric_nz + */ +public class ResultSetRandomInteractions { + + private final TARDISDatabaseConnection service = TARDISDatabaseConnection.getINSTANCE(); + private final Connection connection = service.getConnection(); + private final TARDIS plugin; + private final int id; + private final int[] diodes = new int[5]; + private final String prefix; + private final HashMap map = new HashMap<>(); + + /** + * Creates a class instance that can be used to retrieve an SQL ResultSet from the controls table. + * + * @param plugin an instance of the main class. + * @param id the TARDIS id to search for. + */ + public ResultSetRandomInteractions(TARDIS plugin, int id) { + this.plugin = plugin; + this.id = id; + prefix = this.plugin.getPrefix(); + map.put("WORLD", 0); + map.put("X", 1); + map.put("Z", 2); + map.put("HELMIC_REGULATOR", 4); + map.put("MULTIPLIER", 3); + } + + /** + * Retrieves an SQL ResultSet from the interactions table. This method builds an SQL query string from the + * parameters supplied and then executes the query. Use the getters to retrieve the results. + * + * @return true or false depending on whether any data matches the query + */ + public boolean resultSet() { + PreparedStatement statement = null; + ResultSet rs = null; + String query = "SELECT control, state FROM " + prefix + "interactions WHERE tardis_id = ? AND control IN ('HELMIC_REGULATOR', 'MULTIPLIER', 'WORLD', 'X', 'Z') ORDER BY control"; + try { + service.testConnection(connection); + statement = connection.prepareStatement(query); + statement.setInt(1, id); + rs = statement.executeQuery(); + if (rs.isBeforeFirst()) { + int i = 0; + while (rs.next()) { + // 0 => 'WORLD', 1 => 'X', 2 => 'Z', 3 => 'MULTIPLIER', 4 => HELMIC_REGULATOR + // TODO these interactions should have a default state of 1 + diodes[map.get(rs.getString("control"))] = rs.getInt("state"); + i++; + } + } else { + return false; + } + } catch (SQLException e) { + plugin.debug("ResultSet error for random interactions table! " + e.getMessage()); + return false; + } finally { + try { + if (rs != null) { + rs.close(); + } + if (statement != null) { + statement.close(); + } + } catch (SQLException e) { + plugin.debug("Error closing random interactions table! " + e.getMessage()); + } + } + return true; + } + + public int[] getStates() { + return diodes; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISEntityDeathListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISEntityDeathListener.java new file mode 100644 index 000000000..3adc2bf7b --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISEntityDeathListener.java @@ -0,0 +1,28 @@ +package me.eccentric_nz.TARDIS.listeners; + +import me.eccentric_nz.TARDIS.TARDIS; +import org.bukkit.Location; +import org.bukkit.entity.Monster; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDeathEvent; + +public class TARDISEntityDeathListener implements Listener { + + private final TARDIS plugin; + + public TARDISEntityDeathListener(TARDIS plugin) { + this.plugin = plugin; + } + + @EventHandler + public void onEntityDiedInTARDIS(EntityDeathEvent event) { + if (event.getEntity() instanceof Monster monster) { + Location location = monster.getLocation(); + if (plugin.getUtils().inTARDISWorld(location)) { + // get the TARDIS id the monster was killed in + + } + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/controls/TARDISLightLevelFrameListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/controls/TARDISLightLevelFrameListener.java index 706219922..48ab5f9fd 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/controls/TARDISLightLevelFrameListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/controls/TARDISLightLevelFrameListener.java @@ -17,14 +17,9 @@ package me.eccentric_nz.TARDIS.listeners.controls; import me.eccentric_nz.TARDIS.TARDIS; -import me.eccentric_nz.TARDIS.builders.LightLevel; -import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentFromId; -import me.eccentric_nz.TARDIS.database.resultset.ResultSetLamps; +import me.eccentric_nz.TARDIS.control.actions.LightLevelAction; import me.eccentric_nz.TARDIS.database.resultset.ResultSetLightLevel; import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.data.Levelled; import org.bukkit.entity.ItemFrame; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -32,8 +27,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.HashMap; - /** * @author eccentric_nz */ @@ -49,8 +42,8 @@ public TARDISLightLevelFrameListener(TARDIS plugin) { public void onLightLevelClick(PlayerInteractEntityEvent event) { if (event.getRightClicked() instanceof ItemFrame frame) { // check if it is a light level item frame - Location l = frame.getLocation(); - ResultSetLightLevel rs = new ResultSetLightLevel(plugin, l.toString()); + Location location = frame.getLocation(); + ResultSetLightLevel rs = new ResultSetLightLevel(plugin, location.toString()); if (rs.resultSet()) { // which switch is it? int start = (rs.getType() == 49) ? 1000 : 3000; @@ -76,55 +69,7 @@ public void onLightLevelClick(PlayerInteractEntityEvent event) { im.setCustomModelData(cmd); is.setItemMeta(im); frame.setItem(is); - // save the level to the database - int setLevel = (rs.getLevel() + 1) > 3 ? 0 : rs.getLevel() + 1; - HashMap set = new HashMap<>(); - set.put("secondary", setLevel); - HashMap where = new HashMap<>(); - where.put("c_id", rs.getControlId()); - plugin.getQueryFactory().doSyncUpdate("controls", set, where); - if (rs.isPowered()) { - // alter light levels - int light_level; - if (rs.getType() == 49) { - // exterior - if (!rs.isPoliceBox()) { - return; - } - light_level = LightLevel.exterior_level[setLevel]; - // get current TARDIS location - ResultSetCurrentFromId rsc = new ResultSetCurrentFromId(plugin, rs.getTardis_id()); - if (rsc.resultSet()) { - if (rsc.getWorld() == null) { - return; - } - Location location = new Location(rsc.getWorld(), rsc.getX(), rsc.getY(), rsc.getZ()); - while (!location.getChunk().isLoaded()) { - location.getChunk().load(); - } - Block light = location.getBlock().getRelative(BlockFace.UP, 2); - if (light.getBlockData() instanceof Levelled levelled) { - levelled.setLevel(light_level); - light.setBlockData(levelled); - } - } - } else if (rs.isLightsOn()) { - // interior - light_level = LightLevel.interior_level[setLevel]; - // get TARDIS lights - HashMap whereLight = new HashMap<>(); - whereLight.put("tardis_id", rs.getTardis_id()); - ResultSetLamps rsl = new ResultSetLamps(plugin, whereLight, true); - if (rsl.resultSet()) { - for (Block block : rsl.getData()) { - if (block.getBlockData() instanceof Levelled levelled) { - levelled.setLevel(light_level); - block.setBlockData(levelled); - } - } - } - } - } + new LightLevelAction(plugin).illuminate(rs.getLevel(), rs.getControlId(), rs.isPowered(), rs.getType(), rs.isPoliceBox(), rs.getTardis_id(), rs.isLightsOn()); } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java index ecc86f66a..d9b79b61f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java @@ -45,7 +45,6 @@ public class TARDISMonsterRunnable implements Runnable { private final TARDIS plugin; private final List monsters = new ArrayList<>(); - private final List random_monsters = new ArrayList<>(); public TARDISMonsterRunnable(TARDIS plugin) { this.plugin = plugin; @@ -53,29 +52,23 @@ public TARDISMonsterRunnable(TARDIS plugin) { monsters.add(EntityType.CREEPER); monsters.add(EntityType.ENDERMAN); monsters.add(EntityType.ENDERMITE); - monsters.add(EntityType.HOGLIN); monsters.add(EntityType.HUSK); monsters.add(EntityType.PIGLIN); monsters.add(EntityType.PILLAGER); monsters.add(EntityType.SILVERFISH); monsters.add(EntityType.SKELETON); - monsters.add(EntityType.SLIME); monsters.add(EntityType.SPIDER); monsters.add(EntityType.STRAY); monsters.add(EntityType.VEX); monsters.add(EntityType.VINDICATOR); monsters.add(EntityType.WITCH); - monsters.add(EntityType.WITHER_SKELETON); monsters.add(EntityType.ZOGLIN); monsters.add(EntityType.ZOMBIE); monsters.add(EntityType.ZOMBIE_VILLAGER); monsters.add(EntityType.ZOMBIFIED_PIGLIN); if (this.plugin.getConfig().getBoolean("allow.guardians")) { monsters.add(EntityType.GUARDIAN); - } else { - random_monsters.add(EntityType.GUARDIAN); } - random_monsters.addAll(monsters); } @Override @@ -210,7 +203,7 @@ public void run() { if (rs.resultSet() && rs.getTardis().getMonsters() < plugin.getConfig().getInt("preferences.spawn_limit")) { TARDISMonster rtm = new TARDISMonster(); // choose a random monster - EntityType type = random_monsters.get(TARDISConstants.RANDOM.nextInt(random_monsters.size())); + EntityType type = monsters.get(TARDISConstants.RANDOM.nextInt(monsters.size())); rtm.setType(type); String dn = TARDISStringUtils.uppercaseFirst(type.toString().toLowerCase(Locale.ENGLISH)); if (type.equals(EntityType.ZOMBIE_VILLAGER)) { @@ -325,8 +318,9 @@ private void moveMonster(TARDISTeleportLocation tpl, TARDISMonster m, Entity e, while (!loc.getChunk().isLoaded()) { loc.getChunk().load(); } + // update monsters count in database + plugin.getQueryFactory().doMonsterIncrement(tpl.getTardisId()); // spawn a monster in the TARDIS - // TODO update monsters count in database plugin.setTardisSpawn(true); Entity ent = loc.getWorld().spawnEntity(loc, m.getType()); switch (m.getType()) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTimeTravel.java b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTimeTravel.java index 935b3ced1..a8d5fe716 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTimeTravel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTimeTravel.java @@ -16,11 +16,6 @@ */ package me.eccentric_nz.TARDIS.travel; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISConstants; import me.eccentric_nz.TARDIS.api.Parameters; @@ -48,12 +43,13 @@ import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; +import java.util.*; + /** * All things related to time travel. *

- * All TARDISes built after a certain point, including the Type 40 the Doctor - * uses, have a mathematically modelled duplicate of the Eye of harmony with all - * its attendant features. + * All TARDISes built after a certain point, including the Type 40 the Doctor uses, have a mathematically modelled + * duplicate of the Eye of harmony with all its attendant features. * * @author eccentric_nz */ @@ -70,16 +66,16 @@ public TARDISTimeTravel(TARDIS plugin) { } /** - * Checks if a random location is safe for the TARDIS Police Box to land at. - * The Police Box requires a clear 4 x 3 x 4 (d x w x h) area. + * Checks if a random location is safe for the TARDIS Police Box to land at. The Police Box requires a clear 4 x 3 x + * 4 (d x w x h) area. * * @param startx a starting position in the x direction. * @param starty a starting position in the y direction. * @param startz a starting position in the z direction. * @param resetx a copy of the starting x position to return to. * @param resetz a copy of the starting z position to return to. - * @param w the world the location check will take place in. - * @param d the direction the Police Box is facing. + * @param w the world the location check will take place in. + * @param d the direction the Police Box is facing. * @return the number of unsafe blocks */ public static int safeLocation(int startx, int starty, int startz, int resetx, int resetz, World w, COMPASS d) { @@ -143,7 +139,7 @@ public static int safeLocation(int startx, int starty, int startz, int resetx, i * Gets the starting location for safe location checking. * * @param loc a location object to check. - * @param d the direction the Police Box is facing. + * @param d the direction the Police Box is facing. * @return an array containing x and z coordinates */ public static int[] getStartLocation(Location loc, COMPASS d) { @@ -172,37 +168,25 @@ public static int[] getStartLocation(Location loc, COMPASS d) { } /** - * Retrieves a random location determined from the TARDIS repeater or - * terminal settings. + * Retrieves a random location determined from the TARDIS repeater or terminal settings. * - * @param p a player object used to check permissions against. - * @param rx the delay setting of the x-repeater, this determines the - * distance in the x direction. - * @param rz the delay setting of the z-repeater, this determines the - * distance in the z direction. - * @param ry the delay setting of the y-repeater, this determines the - * multiplier for both the x and z directions. - * @param d the direction the TARDIS Police Box faces. - * @param e the environment(s) the player has chosen (or is allowed) to - * travel to. - * @param this_world the world the Police Box is currently in + * @param player a player object used to check permissions against. + * @param rx the delay setting of the x-repeater, this determines the distance in the x direction. + * @param rz the delay setting of the z-repeater, this determines the distance in the z direction. + * @param ry the delay setting of the y-repeater, this determines the multiplier for both the x and z + * directions. + * @param d the direction the TARDIS Police Box faces. + * @param e the environment(s) the player has chosen (or is allowed) to travel to. + * @param this_world the world the Police Box is currently in * @param malfunction whether there should be a malfunction - * @param current the current location of the TARDIS + * @param current the current location of the TARDIS * @return a random Location */ - public Location randomDestination(Player p, int rx, int rz, int ry, COMPASS d, String e, World this_world, boolean malfunction, Location current) { - int startx, starty, startz, resetx, resetz, listlen; - World randworld; - int count; - // get max_radius from config - int max = plugin.getConfig().getInt("travel.tp_radius"); - int quarter = (max + 4 - 1) / 4; - int range = quarter + 1; - int wherex = 0, highest = 252, wherez = 0; + public Location randomDestination(Player player, int rx, int rz, int ry, COMPASS d, String e, World this_world, boolean malfunction, Location current) { + int listlen; // get worlds Set worldlist = plugin.getPlanetsConfig().getConfigurationSection("planets").getKeys(false); List allowedWorlds = new ArrayList<>(); - if (e.equals("THIS") && plugin.getPlanetsConfig().getBoolean("planets." + this_world.getName() + ".time_travel")) { allowedWorlds.add(this_world); } else { @@ -233,7 +217,7 @@ public Location randomDestination(Player p, int rx, int rz, int ry, COMPASS d, S allowedWorlds.remove(this_world); } // remove the world if the player doesn't have permission - if (allowedWorlds.size() > 1 && plugin.getConfig().getBoolean("travel.per_world_perms") && !TARDISPermission.hasPermission(p, "tardis.travel." + o)) { + if (allowedWorlds.size() > 1 && plugin.getConfig().getBoolean("travel.per_world_perms") && !TARDISPermission.hasPermission(player, "tardis.travel." + o)) { allowedWorlds.remove(ww); } } @@ -241,8 +225,18 @@ public Location randomDestination(Player p, int rx, int rz, int ry, COMPASS d, S } listlen = allowedWorlds.size(); // random world - randworld = allowedWorlds.get(TARDISConstants.RANDOM.nextInt(listlen)); + World randworld = allowedWorlds.get(TARDISConstants.RANDOM.nextInt(listlen)); + return getDestination(randworld, rx, rz, ry, d, e, current, player); + } + public Location getDestination(World randworld, int rx, int rz, int ry, COMPASS d, String e, Location current, Player p) { + int startx, starty, startz, resetx, resetz, listlen; + int count; + // get max_radius from config + int max = plugin.getConfig().getInt("travel.tp_radius"); + int quarter = (max + 4 - 1) / 4; + int range = quarter + 1; + int wherex = 0, highest = 252, wherez = 0; switch (randworld.getEnvironment()) { case NETHER -> { for (int n = 0; n < attempts; n++) { @@ -395,11 +389,10 @@ public Location randomDestination(Player p, int rx, int rz, int ry, COMPASS d, S } /** - * Checks if a location is safe for the TARDIS Police Box to land at. Used - * for debugging purposes only. The Police Box requires a clear 4 x 3 x 4 (d - * x w x h) area. + * Checks if a location is safe for the TARDIS Police Box to land at. Used for debugging purposes only. The Police + * Box requires a clear 4 x 3 x 4 (d x w x h) area. * - * @param location the location to test + * @param location the location to test * @param direction the direction the Police Box is facing. */ public void testSafeLocation(Location location, COMPASS direction, Player player) { @@ -456,8 +449,8 @@ public void testSafeLocation(Location location, COMPASS direction, Player player * @param nether a Nether world to search in. * @param wherex an x co-ordinate. * @param wherez a z co-ordinate. - * @param d the direction the Police Box is facing. - * @param p the player to check permissions for + * @param d the direction the Police Box is facing. + * @param p the player to check permissions for * @return true or false */ public boolean safeNether(World nether, int wherex, int wherez, COMPASS d, Player p) { @@ -500,12 +493,12 @@ public boolean safeNether(World nether, int wherex, int wherez, COMPASS d, Playe /** * Returns a random positive or negative x integer. * - * @param range the maximum the random number can be. + * @param range the maximum the random number can be. * @param quarter one fourth of the max_distance config option. - * @param rx the delay of the x-repeater setting. - * @param ry the delay of the y-repeater setting. - * @param e a string to determine where to start the random search from - * @param l the current TARDIS location + * @param rx the delay of the x-repeater setting. + * @param ry the delay of the y-repeater setting. + * @param e a string to determine where to start the random search from + * @param l the current TARDIS location */ private int randomX(int range, int quarter, int rx, int ry, String e, Location l) { int currentx = (e.equals("THIS")) ? l.getBlockX() : 0; @@ -525,12 +518,12 @@ private int randomX(int range, int quarter, int rx, int ry, String e, Location l /** * Returns a random positive or negative z integer. * - * @param range the maximum the random number can be. + * @param range the maximum the random number can be. * @param quarter one fourth of the max_distance config option. - * @param rz the delay of the x-repeater setting. - * @param ry the delay of the y-repeater setting. - * @param e a string to determine where to start the random search from - * @param l the current TARDIS location + * @param rz the delay of the x-repeater setting. + * @param ry the delay of the y-repeater setting. + * @param e a string to determine where to start the random search from + * @param l the current TARDIS location */ private int randomZ(int range, int quarter, int rz, int ry, String e, Location l) { int currentz = (e.equals("THIS")) ? l.getBlockZ() : 0; diff --git a/src/main/resources/planets.yml b/src/main/resources/planets.yml index b2f1e04c7..0047d20bb 100644 --- a/src/main/resources/planets.yml +++ b/src/main/resources/planets.yml @@ -20,6 +20,7 @@ planets: allow_portals: false alias: TimeVortex icon: CRYING_OBSIDIAN + helmic_regultor_order: -1 TARDIS_Zero_Room: enabled: false resource_pack: default @@ -38,6 +39,7 @@ planets: allow_portals: false alias: ZeroRoom icon: PINK_WOOL + helmic_regultor_order: -1 skaro: enabled: false resource_pack: default @@ -61,6 +63,7 @@ planets: allow_portals: false alias: Skaro icon: FIRE_CORAL_BLOCK + helmic_regultor_order: -1 siluria: enabled: false resource_pack: default @@ -77,6 +80,7 @@ planets: allow_portals: false alias: Siluria icon: BAMBOO_MOSAIC + helmic_regultor_order: -1 gallifrey: enabled: false resource_pack: default @@ -98,3 +102,4 @@ planets: # max usage is 16 uses: 1 chance: 20 + helmic_regultor_order: -1 diff --git a/todo.md b/todo.md index 0a0752edf..4a16601e6 100644 --- a/todo.md +++ b/todo.md @@ -13,7 +13,8 @@ 2. Custom Control models [#703](https://github.com/eccentricdevotion/TARDIS/issues/703) [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) 3. Animated models for player disguises -4. ? +4. Rework difficulty [#754](https://github.com/eccentricdevotion/TARDIS/issues/754) +5. ? ## Future versions From b7dba1884bccd6177ace9ccbc14a4f2ef3e59861 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Mon, 8 Apr 2024 12:28:11 +1200 Subject: [PATCH 18/96] Bukkit.getLogger() should only be used by Minecraft --- .../me/eccentric_nz/TARDIS/utility/RecipeChecker.java | 5 +++-- .../tardischunkgenerator/helpers/GetBlockColours.java | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/utility/RecipeChecker.java b/src/main/java/me/eccentric_nz/TARDIS/utility/RecipeChecker.java index 8d7455c8a..2d0986da5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/utility/RecipeChecker.java +++ b/src/main/java/me/eccentric_nz/TARDIS/utility/RecipeChecker.java @@ -2,6 +2,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectMap; +import me.eccentric_nz.TARDIS.TARDIS; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; @@ -30,13 +31,13 @@ public void run() { String key = r.getKey().getNamespace().toLowerCase(); String path = r.getKey().getPath(); if (key.startsWith("tardis")) { - Bukkit.getLogger().log(Level.INFO, path + " => " + shaped.getResultItem(world.registryAccess()).toString()); + TARDIS.plugin.getLogger().log(Level.INFO, path + " => " + shaped.getResultItem(world.registryAccess()).toString()); } } } } } catch (IllegalArgumentException e) { - Bukkit.getLogger().log(Level.WARNING, "Skipping recipe..."); + TARDIS.plugin.getLogger().log(Level.WARNING, "Skipping recipe..."); } } } diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/GetBlockColours.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/GetBlockColours.java index b5417bced..b6fb71dac 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/GetBlockColours.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/GetBlockColours.java @@ -1,14 +1,14 @@ package me.eccentric_nz.tardischunkgenerator.helpers; -import java.util.logging.Level; - +import me.eccentric_nz.TARDIS.TARDIS; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.material.MapColor; -import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_20_R3.util.CraftMagicNumbers; +import java.util.logging.Level; + public class GetBlockColours { private static Color getColor(Material material) { @@ -22,7 +22,7 @@ public static void list() { for (Material m : Material.values()) { if (m.isBlock()) { Color color = getColor(m); - Bukkit.getLogger().log(Level.INFO, String.format("%s(new Color(%d, %d, %d)),", m, color.getRed(), color.getGreen(), color.getBlue())); + TARDIS.plugin.getLogger().log(Level.INFO, String.format("%s(new Color(%d, %d, %d)),", m, color.getRed(), color.getGreen(), color.getBlue())); } } } From 8b6064846fb24caf1f250f8b72583848de34a2ba Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 8 Apr 2024 22:07:21 +1200 Subject: [PATCH 19/96] Telepathic Circuit GUIs --- .../TARDIS/TARDISListenerRegisterer.java | 7 ++ .../TelepathicCircuitInteraction.java | 2 +- .../console/telepathic/EnvironmentBiomes.java | 90 ++++++++++++++ .../telepathic/TARDISTelepathicBiome.java | 76 ++++++++++-- .../telepathic/TARDISTelepathicInventory.java | 53 +++++++- .../telepathic/TARDISTelepathicStructure.java | 46 +++++-- .../telepathic/TelepathicBiomeListener.java | 117 ++++++++++++++++++ .../telepathic/TelepathicGUIListener.java | 90 ++++++++++++++ .../TelepathicStructureListener.java | 41 ++++++ .../ResultSetRandomInteractions.java | 1 - .../TARDIS/listeners/TARDISMenuListener.java | 3 + .../TARDIS/travel/TARDISStructureTravel.java | 15 ++- 12 files changed, 516 insertions(+), 25 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/telepathic/EnvironmentBiomes.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/TARDISListenerRegisterer.java b/src/main/java/me/eccentric_nz/TARDIS/TARDISListenerRegisterer.java index d334c4a91..b4c593229 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/TARDISListenerRegisterer.java +++ b/src/main/java/me/eccentric_nz/TARDIS/TARDISListenerRegisterer.java @@ -39,6 +39,9 @@ import me.eccentric_nz.TARDIS.companionGUI.TARDISCompanionAddGUIListener; import me.eccentric_nz.TARDIS.companionGUI.TARDISCompanionGUIListener; import me.eccentric_nz.TARDIS.console.ConsoleInteractionListener; +import me.eccentric_nz.TARDIS.console.telepathic.TelepathicBiomeListener; +import me.eccentric_nz.TARDIS.console.telepathic.TelepathicGUIListener; +import me.eccentric_nz.TARDIS.console.telepathic.TelepathicStructureListener; import me.eccentric_nz.TARDIS.control.TARDISControlListener; import me.eccentric_nz.TARDIS.control.TARDISControlMenuListener; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayBlockListener; @@ -321,6 +324,10 @@ TARDISInformationSystemListener registerListeners() { plugin.getPM().registerEvents(new TARDISAntiBuildListener(plugin), plugin); } plugin.getPM().registerEvents(new TARDISPlayerKickListener(plugin), plugin); + // telepathic listeners + plugin.getPM().registerEvents(new TelepathicGUIListener(plugin), plugin); + plugin.getPM().registerEvents(new TelepathicBiomeListener(plugin), plugin); + plugin.getPM().registerEvents(new TelepathicStructureListener(plugin), plugin); if (plugin.getPlanetsConfig().getBoolean("planets.skaro.enabled")) { plugin.debug("Skaro enabled, registering planet event listeners"); if (plugin.getPlanetsConfig().getBoolean("planets.skaro.acid")) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java index 23db4e1b4..f5ed8e60f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java @@ -16,7 +16,7 @@ public TelepathicCircuitInteraction(TARDIS plugin) { } public void openGUI(Player player) { - // open new GUI for + // open GUI for // toggling telepathic circuit on/off // cave finder // structure finder diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/EnvironmentBiomes.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/EnvironmentBiomes.java new file mode 100644 index 000000000..30202ecdb --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/EnvironmentBiomes.java @@ -0,0 +1,90 @@ +package me.eccentric_nz.TARDIS.console.telepathic; + +import org.bukkit.Material; +import org.bukkit.block.Biome; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class EnvironmentBiomes { + + public static final List END = List.of(Biome.THE_END, Biome.END_BARRENS, Biome.END_MIDLANDS, Biome.END_HIGHLANDS, Biome.SMALL_END_ISLANDS); + public static final List NETHER = List.of(Biome.NETHER_WASTES, Biome.BASALT_DELTAS, Biome.CRIMSON_FOREST, Biome.SOUL_SAND_VALLEY, Biome.WARPED_FOREST); + public static List OVERWORLD = new ArrayList<>(); + public static HashMap BIOME_BLOCKS = new HashMap<>() {{ + put(Biome.BADLANDS, Material.RED_SAND); + put(Biome.BAMBOO_JUNGLE, Material.BAMBOO_BLOCK); + put(Biome.BASALT_DELTAS, Material.BASALT); + put(Biome.BEACH, Material.SAND); + put(Biome.BIRCH_FOREST, Material.BIRCH_PLANKS); + put(Biome.CHERRY_GROVE, Material.CHERRY_PLANKS); + put(Biome.COLD_OCEAN, Material.SALMON); + put(Biome.CRIMSON_FOREST, Material.CRIMSON_PLANKS); + put(Biome.CUSTOM, Material.BARRIER); + put(Biome.DARK_FOREST, Material.DARK_OAK_PLANKS); + put(Biome.DEEP_COLD_OCEAN, Material.SEA_PICKLE); + put(Biome.DEEP_DARK, Material.SCULK); + put(Biome.DEEP_FROZEN_OCEAN, Material.SEAGRASS); + put(Biome.DEEP_LUKEWARM_OCEAN, Material.TUBE_CORAL_BLOCK); + put(Biome.DEEP_OCEAN, Material.PRISMARINE); + put(Biome.DESERT, Material.SANDSTONE); + put(Biome.DRIPSTONE_CAVES, Material.DRIPSTONE_BLOCK); + put(Biome.END_BARRENS, Material.END_STONE_BRICKS); + put(Biome.END_HIGHLANDS, Material.CHORUS_PLANT); + put(Biome.END_MIDLANDS, Material.PURPUR_BLOCK); + put(Biome.ERODED_BADLANDS, Material.YELLOW_TERRACOTTA); + put(Biome.FLOWER_FOREST, Material.ORANGE_TULIP); + put(Biome.FOREST, Material.OAK_PLANKS); + put(Biome.FROZEN_OCEAN, Material.BLUE_ICE); + put(Biome.FROZEN_PEAKS, Material.POWDER_SNOW); + put(Biome.FROZEN_RIVER, Material.ICE); + put(Biome.GROVE, Material.STRIPPED_SPRUCE_LOG); + put(Biome.ICE_SPIKES, Material.PACKED_ICE); + put(Biome.JAGGED_PEAKS, Material.GOAT_HORN); + put(Biome.JUNGLE, Material.JUNGLE_PLANKS); + put(Biome.LUKEWARM_OCEAN, Material.FIRE_CORAL_BLOCK); + put(Biome.LUSH_CAVES, Material.MOSS_BLOCK); + put(Biome.MANGROVE_SWAMP, Material.MANGROVE_PLANKS); + put(Biome.MEADOW, Material.RED_TULIP); + put(Biome.MUSHROOM_FIELDS, Material.MYCELIUM); + put(Biome.NETHER_WASTES, Material.NETHERRACK); + put(Biome.OCEAN, Material.KELP); + put(Biome.OLD_GROWTH_BIRCH_FOREST, Material.STRIPPED_BIRCH_WOOD); + put(Biome.OLD_GROWTH_PINE_TAIGA, Material.SPRUCE_LOG); + put(Biome.OLD_GROWTH_SPRUCE_TAIGA, Material.STRIPPED_SPRUCE_WOOD); + put(Biome.PLAINS, Material.GRASS_BLOCK); + put(Biome.RIVER, Material.FISHING_ROD); + put(Biome.SAVANNA, Material.ACACIA_PLANKS); + put(Biome.SAVANNA_PLATEAU, Material.ACACIA_LEAVES); + put(Biome.SMALL_END_ISLANDS, Material.END_STONE); + put(Biome.SNOWY_BEACH, Material.SMOOTH_SANDSTONE); + put(Biome.SNOWY_PLAINS, Material.SNOW_BLOCK); + put(Biome.SNOWY_SLOPES, Material.SNOWBALL); + put(Biome.SNOWY_TAIGA, Material.SPRUCE_LEAVES); + put(Biome.SOUL_SAND_VALLEY, Material.SOUL_SAND); + put(Biome.SPARSE_JUNGLE, Material.COCOA_BEANS); + put(Biome.STONY_PEAKS, Material.CALCITE); + put(Biome.STONY_SHORE, Material.STONE); + put(Biome.SUNFLOWER_PLAINS, Material.SUNFLOWER); + put(Biome.SWAMP, Material.LILY_PAD); + put(Biome.TAIGA, Material.SPRUCE_PLANKS); + put(Biome.THE_END, Material.OBSIDIAN); + put(Biome.THE_VOID, Material.BARRIER); + put(Biome.WARM_OCEAN, Material.BRAIN_CORAL_BLOCK); + put(Biome.WARPED_FOREST, Material.WARPED_PLANKS); + put(Biome.WINDSWEPT_FOREST, Material.OAK_LEAVES); + put(Biome.WINDSWEPT_GRAVELLY_HILLS, Material.GRAVEL); + put(Biome.WINDSWEPT_HILLS, Material.EMERALD_ORE); + put(Biome.WINDSWEPT_SAVANNA, Material.ACACIA_LOG); + put(Biome.WOODED_BADLANDS, Material.COARSE_DIRT); + }}; + + static { + for (Biome biome : Biome.values()) { + if (!END.contains(biome) && !NETHER.contains(biome) && biome != Biome.CUSTOM && biome != Biome.THE_VOID) { + OVERWORLD.add(biome); + } + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicBiome.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicBiome.java index b325284ed..013a7d841 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicBiome.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicBiome.java @@ -1,25 +1,81 @@ package me.eccentric_nz.TARDIS.console.telepathic; import me.eccentric_nz.TARDIS.TARDIS; -import org.bukkit.entity.Player; +import me.eccentric_nz.TARDIS.custommodeldata.GUIMap; +import me.eccentric_nz.TARDIS.custommodeldata.GUIWallFloor; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentFromId; +import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; +import org.bukkit.Material; +import org.bukkit.World.Environment; +import org.bukkit.block.Biome; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.List; public class TARDISTelepathicBiome { private final TARDIS plugin; - private final Player player; + private final int id; - public TARDISTelepathicBiome(TARDIS plugin, Player player) { + public TARDISTelepathicBiome(TARDIS plugin, int id) { this.plugin = plugin; - this.player = player; + this.id = id; } public ItemStack[] getButtons() { - // TODO build buttons - // toggling telepathic circuit on/off - // cave finder - // structure finder - // biome finder - return new ItemStack[54]; + ItemStack[] stack = new ItemStack[54]; + // only show biomes for the environment the TARDIS is currently in + ResultSetCurrentFromId rsc = new ResultSetCurrentFromId(plugin, id); + if (rsc.resultSet()) { + Environment environment = rsc.getWorld().getEnvironment(); + // biome finder + List biomes; + switch (environment) { + case NETHER -> biomes = EnvironmentBiomes.NETHER; + case THE_END -> biomes = EnvironmentBiomes.END; + default -> biomes = EnvironmentBiomes.OVERWORLD; + } + int i = 0; + for (Biome biome : biomes) { + if (i > 52) { + break; + } + ItemStack is = new ItemStack(EnvironmentBiomes.BIOME_BLOCKS.get(biome)); + ItemMeta im = is.getItemMeta(); + im.setDisplayName(TARDISStringUtils.capitalise(biome.toString())); + is.setItemMeta(im); + stack[i] = is; + if (i % 9 == 7) { + i += 2; + } else { + i++; + } + } + if (environment == Environment.NORMAL) { + // scroll up + ItemStack scroll_up = new ItemStack(Material.ARROW, 1); + ItemMeta uim = scroll_up.getItemMeta(); + uim.setDisplayName(plugin.getLanguage().getString("BUTTON_SCROLL_U")); + uim.setCustomModelData(GUIWallFloor.BUTTON_SCROLL_U.getCustomModelData()); + scroll_up.setItemMeta(uim); + stack[8] = scroll_up; + // scroll down + ItemStack scroll_down = new ItemStack(Material.ARROW, 1); + ItemMeta dim = scroll_down.getItemMeta(); + dim.setDisplayName(plugin.getLanguage().getString("BUTTON_SCROLL_D")); + dim.setCustomModelData(GUIWallFloor.BUTTON_SCROLL_D.getCustomModelData()); + scroll_down.setItemMeta(dim); + stack[17] = scroll_down; + } + } + // close + ItemStack close = new ItemStack(Material.BOWL, 1); + ItemMeta gui = close.getItemMeta(); + gui.setDisplayName(plugin.getLanguage().getString("BUTTON_CLOSE")); + gui.setCustomModelData(GUIMap.BUTTON_CLOSE.getCustomModelData()); + close.setItemMeta(gui); + stack[53] = close; + return stack; } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicInventory.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicInventory.java index 1bbff53d0..117017222 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicInventory.java @@ -1,8 +1,15 @@ package me.eccentric_nz.TARDIS.console.telepathic; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.custommodeldata.GUIMap; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; +import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.List; public class TARDISTelepathicInventory { @@ -15,11 +22,53 @@ public TARDISTelepathicInventory(TARDIS plugin, Player player) { } public ItemStack[] getButtons() { - // TODO build buttons + // build buttons + ItemStack[] stack = new ItemStack[9]; + // get current telepathic status + ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, player.getUniqueId().toString()); + String onOff = (rsp.resultSet() && rsp.isTelepathyOn()) ? ChatColor.GREEN + "ON" : ChatColor.RED + "OFF"; // toggling telepathic circuit on/off + ItemStack toggle = new ItemStack(Material.REPEATER); + ItemMeta tim = toggle.getItemMeta(); + tim.setDisplayName("Telepathic Circuit"); + tim.setLore(List.of(onOff)); + tim.setCustomModelData(40); + toggle.setItemMeta(tim); + stack[0] = toggle; // cave finder + if (player.hasPermission("tardis.timetravel.cave")) { + ItemStack cave = new ItemStack(Material.DRIPSTONE_BLOCK); + ItemMeta cim = cave.getItemMeta(); + cim.setDisplayName("Cave Finder"); + cim.setLore(List.of("Search for a cave", "to travel to.")); + cave.setItemMeta(cim); + stack[2] = cave; + } // structure finder + if (player.hasPermission("tardis.timetravel.village")) { + ItemStack structure = new ItemStack(Material.HAY_BLOCK); + ItemMeta sim = structure.getItemMeta(); + sim.setDisplayName("Structure Finder"); + sim.setLore(List.of("Search for a structure", "to travel to.")); + structure.setItemMeta(sim); + stack[4] = structure; + } // biome finder - return new ItemStack[54]; + if (player.hasPermission("tardis.timetravel.biome")) { + ItemStack biome = new ItemStack(Material.BAMBOO_MOSAIC); + ItemMeta bim = biome.getItemMeta(); + bim.setDisplayName("Biome Finder"); + bim.setLore(List.of("Search for a biome", "to travel to.")); + biome.setItemMeta(bim); + stack[6] = biome; + } + // close + ItemStack close = new ItemStack(Material.BOWL, 1); + ItemMeta gui = close.getItemMeta(); + gui.setDisplayName(plugin.getLanguage().getString("BUTTON_CLOSE")); + gui.setCustomModelData(GUIMap.BUTTON_CLOSE.getCustomModelData()); + close.setItemMeta(gui); + stack[8] = close; + return stack; } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicStructure.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicStructure.java index 2825a5ead..991883079 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicStructure.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicStructure.java @@ -1,25 +1,53 @@ package me.eccentric_nz.TARDIS.console.telepathic; import me.eccentric_nz.TARDIS.TARDIS; -import org.bukkit.entity.Player; +import me.eccentric_nz.TARDIS.custommodeldata.GUIMap; +import me.eccentric_nz.TARDIS.travel.TARDISStructureTravel; +import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; +import org.bukkit.Material; +import org.bukkit.generator.structure.Structure; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; public class TARDISTelepathicStructure { private final TARDIS plugin; - private final Player player; - public TARDISTelepathicStructure(TARDIS plugin, Player player) { + public TARDISTelepathicStructure(TARDIS plugin) { this.plugin = plugin; - this.player = player; } public ItemStack[] getButtons() { - // TODO build buttons - // toggling telepathic circuit on/off - // cave finder // structure finder - // biome finder - return new ItemStack[54]; + ItemStack[] stack = new ItemStack[54]; + int i = 0; + for (Structure structure : TARDISStructureTravel.overworldStructures) { + ItemStack is = make(structure, Material.GRASS_BLOCK); + stack[i] = is; + i++; + } + for (Structure structure : TARDISStructureTravel.netherStructures) { + ItemStack is = make(structure, Material.CRIMSON_NYLIUM); + stack[i] = is; + i++; + } + ItemStack end = make(Structure.END_CITY, Material.PURPUR_BLOCK); + stack[i] = end; + // close + ItemStack close = new ItemStack(Material.BOWL, 1); + ItemMeta gui = close.getItemMeta(); + gui.setDisplayName(plugin.getLanguage().getString("BUTTON_CLOSE")); + gui.setCustomModelData(GUIMap.BUTTON_CLOSE.getCustomModelData()); + close.setItemMeta(gui); + stack[53] = close; + return stack; + } + + private ItemStack make(Structure structure, Material material) { + ItemStack is = new ItemStack(material, 1); + ItemMeta im = is.getItemMeta(); + im.setDisplayName(TARDISStringUtils.capitalise(structure.toString())); + is.setItemMeta(im); + return is; } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicBiomeListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicBiomeListener.java index b5a0539e0..945af98b2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicBiomeListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicBiomeListener.java @@ -2,10 +2,127 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.listeners.TARDISMenuListener; +import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.block.Biome; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; public class TelepathicBiomeListener extends TARDISMenuListener { + private final TARDIS plugin; + private final HashMap scroll = new HashMap<>(); + private final List scrolling = new ArrayList<>(); + private final ItemStack[][] biomes; + private final int rows; + public TelepathicBiomeListener(TARDIS plugin) { super(plugin); + this.plugin = plugin; + rows = EnvironmentBiomes.OVERWORLD.size() / 8 + 1; + biomes = getBiomes(); + } + + @EventHandler(ignoreCancelled = true) + public void onBiomeMenuClick(InventoryClickEvent event) { + InventoryView view = event.getView(); + String name = view.getTitle(); + if (!name.equals(ChatColor.DARK_RED + "Telepathic Biome Finder")) { + return; + } + Player player = (Player) event.getWhoClicked(); + UUID uuid = player.getUniqueId(); + int slot = event.getRawSlot(); + if (slot < 0 || slot > 53) { + ClickType click = event.getClick(); + if (click.equals(ClickType.SHIFT_RIGHT) || click.equals(ClickType.SHIFT_LEFT) || click.equals(ClickType.DOUBLE_CLICK)) { + event.setCancelled(true); + } + return; + } + event.setCancelled(true); + switch (slot) { + // scroll up + case 8 -> { + if (view.getItem(8) != null) { + if (!scrolling.contains(uuid)) { + scrolling.add(uuid); + scroll(view, scroll.get(uuid) + 1, true, uuid); + } + } + } + // scroll down + case 17 -> { + if (view.getItem(17) != null) { + if (!scrolling.contains(uuid)) { + scrolling.add(uuid); + scroll(view, scroll.get(uuid) - 1, false, uuid); + } + } + } + // close + case 53 -> close(player); + // run a command + default -> { + ItemStack choice = view.getItem(slot); + if (choice != null) { + // get the biome + ItemMeta im = choice.getItemMeta(); + String enumStr = TARDISStringUtils.toEnumUppercase(im.getDisplayName()); + player.performCommand("tardistravel biome " + enumStr); + close(player); + } + } + } + } + + private void scroll(InventoryView view, int row, boolean up, UUID uuid) { + if ((up && row < (rows - 5)) || (!up && row >= 0)) { + scroll.put(uuid, row); + setSlots(view, row, uuid); + } else { + scrolling.remove(uuid); + } + } + + private void setSlots(InventoryView view, int row, UUID uuid) { + int slot = 0; + for (int r = row; r < row + 6; r++) { + for (int c = 0; c < 8; c++) { + view.setItem(slot, biomes[r][c]); + if (slot % 9 == 7) { + slot += 2; + } else { + slot++; + } + } + } + scrolling.remove(uuid); + } + + private ItemStack[][] getBiomes() { + ItemStack[][] stacks = new ItemStack[rows][8]; + int r = 0; + int c = 0; + for (Biome biome : EnvironmentBiomes.OVERWORLD) { + ItemStack is = new ItemStack(EnvironmentBiomes.BIOME_BLOCKS.get(biome), 1); + stacks[r][c] = is; + c++; + if (c == 8) { + r++; + c = 0; + } + } + return stacks; } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java index 8a122ded3..49332cf9a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java @@ -1,11 +1,101 @@ package me.eccentric_nz.TARDIS.console.telepathic; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTravellers; import me.eccentric_nz.TARDIS.listeners.TARDISMenuListener; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.HashMap; public class TelepathicGUIListener extends TARDISMenuListener { + private final TARDIS plugin; + public TelepathicGUIListener(TARDIS plugin) { super(plugin); + this.plugin = plugin; + } + + @EventHandler(ignoreCancelled = true) + public void onTelepathicMenuClick(InventoryClickEvent event) { + InventoryView view = event.getView(); + String name = view.getTitle(); + if (!name.equals(ChatColor.DARK_RED + "TARDIS Telepathic Circuit")) { + return; + } + Player player = (Player) event.getWhoClicked(); + int slot = event.getRawSlot(); + if (slot < 0 || slot > 53) { + ClickType click = event.getClick(); + if (click.equals(ClickType.SHIFT_RIGHT) || click.equals(ClickType.SHIFT_LEFT) || click.equals(ClickType.DOUBLE_CLICK)) { + event.setCancelled(true); + } + return; + } + event.setCancelled(true); + ItemStack choice = view.getItem(slot); + switch (slot) { + // toggle telepathy on/off + case 0 -> { + ItemMeta im = choice.getItemMeta(); + int b = (im.hasLore() && im.getLore().get(0).endsWith("ON")) ? 0 : 1; + // update database + HashMap set = new HashMap<>(); + HashMap where = new HashMap<>(); + where.put("uuid", player.getUniqueId().toString()); + set.put("telepathy_on", b); + plugin.getQueryFactory().doUpdate("player_prefs", set, where); + // set item model + int cmd = im.getCustomModelData(); + im.setCustomModelData((cmd > 100) ? cmd - 100 : cmd + 100); + choice.setItemMeta(im); + } + // cave finder + case 2 -> { + if (choice != null) { + player.performCommand("tardistravel cave"); + close(player); + } + } + // structure finder + case 4 -> { + if (choice != null) { + TARDISTelepathicStructure tts = new TARDISTelepathicStructure(plugin); + ItemStack[] gui = tts.getButtons(); + Inventory structure = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "Telepathic Structure Finder"); + structure.setContents(gui); + player.openInventory(structure); + } + } + // biome finder + case 6 -> { + if (choice != null) { + // get id of TARDIS player is in + HashMap where = new HashMap<>(); + where.put("uuid", player.getUniqueId().toString()); + ResultSetTravellers rs = new ResultSetTravellers(plugin, where, false); + if (rs.resultSet()) { + TARDISTelepathicBiome ttb = new TARDISTelepathicBiome(plugin, rs.getTardis_id()); + ItemStack[] gui = ttb.getButtons(); + Inventory biome = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "Telepathic Biome Finder"); + biome.setContents(gui); + player.openInventory(biome); + } + } + } + // close + case 8 -> close(player); + // do nothing + default -> { + } + } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicStructureListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicStructureListener.java index 767c0a39e..9f8209e58 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicStructureListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicStructureListener.java @@ -2,10 +2,51 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.listeners.TARDISMenuListener; +import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; public class TelepathicStructureListener extends TARDISMenuListener { + public TelepathicStructureListener(TARDIS plugin) { super(plugin); } + + @EventHandler(ignoreCancelled = true) + public void onBiomeMenuClick(InventoryClickEvent event) { + InventoryView view = event.getView(); + String name = view.getTitle(); + if (!name.equals(ChatColor.DARK_RED + "Telepathic Structure Finder")) { + return; + } + Player player = (Player) event.getWhoClicked(); + int slot = event.getRawSlot(); + if (slot < 0 || slot > 53) { + ClickType click = event.getClick(); + if (click.equals(ClickType.SHIFT_RIGHT) || click.equals(ClickType.SHIFT_LEFT) || click.equals(ClickType.DOUBLE_CLICK)) { + event.setCancelled(true); + } + return; + } + event.setCancelled(true); + if (slot == 53) { + close(player); + } else { + ItemStack choice = view.getItem(slot); + if (choice != null) { + // get the structure + ItemMeta im = choice.getItemMeta(); + String enumStr = TARDISStringUtils.toEnumUppercase(im.getDisplayName()); + player.performCommand("tardistravel structure " + enumStr); + close(player); + } + } + } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetRandomInteractions.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetRandomInteractions.java index d67fc20b9..95c1237c5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetRandomInteractions.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetRandomInteractions.java @@ -79,7 +79,6 @@ public boolean resultSet() { int i = 0; while (rs.next()) { // 0 => 'WORLD', 1 => 'X', 2 => 'Z', 3 => 'MULTIPLIER', 4 => HELMIC_REGULATOR - // TODO these interactions should have a default state of 1 diodes[map.get(rs.getString("control"))] = rs.getInt("state"); i++; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISMenuListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISMenuListener.java index b76b3ac4e..e09debabb 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISMenuListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISMenuListener.java @@ -135,6 +135,7 @@ private HashMap getTitleMap() { map.put(ChatColor.DARK_RED + "TARDIS Seeds Menu", 90); map.put(ChatColor.DARK_RED + "TARDIS Seeds Recipe", 90); map.put(ChatColor.DARK_RED + "TARDIS Shell Loader", 54); + map.put(ChatColor.DARK_RED + "TARDIS Telepathic Circuit", 54); map.put(ChatColor.DARK_RED + "TARDIS Upgrade Menu", 54); map.put(ChatColor.DARK_RED + "TARDIS Wall & Floor Menu", 90); map.put(ChatColor.DARK_RED + "TARDIS Wall Menu", 54); @@ -143,6 +144,8 @@ private HashMap getTitleMap() { map.put(ChatColor.DARK_RED + "TARDIS saves", 90); map.put(ChatColor.DARK_RED + "TARDIS transmats", 90); map.put(ChatColor.DARK_RED + "Temporal Locator", 27); + map.put(ChatColor.DARK_RED + "Telepathic Biome Finder", 54); + map.put(ChatColor.DARK_RED + "Telepathic Structure Finder", 54); // Vortex Manipulator map.put(ChatColor.DARK_RED + "Vortex Manipulator", 81); map.put(ChatColor.DARK_RED + "VM Messages", 81); diff --git a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISStructureTravel.java b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISStructureTravel.java index 4a4b5feaa..92033ebfa 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISStructureTravel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISStructureTravel.java @@ -40,14 +40,16 @@ */ public class TARDISStructureTravel { + public static final List netherStructures = new ArrayList<>(); + public static final List overworldStructures = new ArrayList<>(); private final TARDIS plugin; - private final List netherStructures = new ArrayList<>(); - private final List overworldStructures = new ArrayList<>(); public TARDISStructureTravel(TARDIS plugin) { this.plugin = plugin; netherStructures.add(Structure.BASTION_REMNANT); netherStructures.add(Structure.FORTRESS); + netherStructures.add(Structure.NETHER_FOSSIL); + netherStructures.add(Structure.RUINED_PORTAL_NETHER); overworldStructures.add(Structure.ANCIENT_CITY); overworldStructures.add(Structure.DESERT_PYRAMID); overworldStructures.add(Structure.IGLOO); @@ -56,11 +58,20 @@ public TARDISStructureTravel(TARDIS plugin) { overworldStructures.add(Structure.MINESHAFT); overworldStructures.add(Structure.MINESHAFT_MESA); overworldStructures.add(Structure.MONUMENT); + overworldStructures.add(Structure.OCEAN_RUIN_COLD); + overworldStructures.add(Structure.OCEAN_RUIN_WARM); overworldStructures.add(Structure.PILLAGER_OUTPOST); + overworldStructures.add(Structure.RUINED_PORTAL); + overworldStructures.add(Structure.RUINED_PORTAL_DESERT); + overworldStructures.add(Structure.RUINED_PORTAL_JUNGLE); + overworldStructures.add(Structure.RUINED_PORTAL_SWAMP); + overworldStructures.add(Structure.RUINED_PORTAL_MOUNTAIN); + overworldStructures.add(Structure.RUINED_PORTAL_OCEAN); overworldStructures.add(Structure.SHIPWRECK); overworldStructures.add(Structure.SHIPWRECK_BEACHED); overworldStructures.add(Structure.STRONGHOLD); overworldStructures.add(Structure.SWAMP_HUT); + overworldStructures.add(Structure.TRAIL_RUINS); overworldStructures.add(Structure.VILLAGE_DESERT); overworldStructures.add(Structure.VILLAGE_PLAINS); overworldStructures.add(Structure.VILLAGE_SAVANNA); From 95067bedf122d7405ede39ba985976271fe96351 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Tue, 9 Apr 2024 08:18:58 +1200 Subject: [PATCH 20/96] Add `helmic_regulator_order` to planets.yml --- .../me/eccentric_nz/TARDIS/files/TARDISPlanetsUpdater.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISPlanetsUpdater.java b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISPlanetsUpdater.java index 71221fa6c..765d9cbb6 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISPlanetsUpdater.java +++ b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISPlanetsUpdater.java @@ -144,6 +144,13 @@ public void checkPlanetsConfig() { planets_config.set("planets.TARDIS_Zero_Room.gamerules.announceAdvancements", false); save++; } + if (!planets_config.contains("planets.TARDIS_Zero_Room.helmic_regulator_order")) { + Set worlds = planets_config.getConfigurationSection("planets").getKeys(false); + for (String w : worlds) { + planets_config.set("planets." + w + ".helmic_regulator_order", -1); + } + save++; + } if (planets_config.contains("default_resource_pack") && planets_config.getString("default_resource_pack").equalsIgnoreCase("https://dl.dropboxusercontent.com/u/53758864/rp/Default.zip")) { planets_config.set("default_resource_pack", "https://www.dropbox.com/s/utka3zxmer7f19g/Default.zip?dl=1"); save++; From d6c8dd291d66803783e43797e8831ced31616dba Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Tue, 9 Apr 2024 08:19:41 +1200 Subject: [PATCH 21/96] Shift-click change display else open Control Menu GUI --- .../console/ConsoleInteractionListener.java | 7 ++----- .../interaction/ScreenInteraction.java | 21 ++++++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index 0186c9d31..175fc7de6 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -39,10 +39,7 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { // section one case WORLD -> new WorldInteraction(plugin).selectWorld(state, player, id); case MULTIPLIER, X, Z -> new MultiplierXZInteraction(plugin).setRange(ci, state, id, player); - case HELMIC_REGULATOR -> { - // TODO add config options to planets.yml - helmic_regulator_order: [1-8|-1] - new HelmicRegulatorInteraction(plugin).selectWorld(state, id, player); - } + case HELMIC_REGULATOR -> new HelmicRegulatorInteraction(plugin).selectWorld(state, id, player); // section two case RANDOMISER -> new RandomiserInteraction(plugin).generateDestination(id, player); case WAYPOINT_SELECTOR -> new WayPointInteraction(plugin).openSaveGUI(id, player); @@ -57,7 +54,7 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { case EXTERIOR_LAMP_LEVEL_SWITCH -> new LampLevelInteraction(plugin).setExterior(state, id, interaction, player); case DOOR_TOGGLE -> new DoorToggleInteraction(plugin).toggle(id, player); // section five - case SCREEN_LEFT, SCREEN_RIGHT -> new ScreenInteraction(plugin).display(id, interaction.getLocation(), ci == ConsoleInteraction.SCREEN_RIGHT); + case SCREEN_LEFT, SCREEN_RIGHT -> new ScreenInteraction(plugin).display(id, interaction.getLocation(), ci == ConsoleInteraction.SCREEN_RIGHT, player); case SCANNER -> new ScannerIntraction(plugin).process(id, player); case ARTRON -> plugin.getMessenger().sendArtron(player, id, 0); case REBUILD -> new RebuildInteraction(plugin).process(id, player); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java index eaa26e576..ac783dd6b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java @@ -2,9 +2,11 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.console.ControlMonitor; +import me.eccentric_nz.TARDIS.control.actions.ControlMenuAction; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; import org.bukkit.entity.TextDisplay; import org.bukkit.util.Vector; @@ -16,13 +18,18 @@ public ScreenInteraction(TARDIS plugin) { this.plugin = plugin; } - public void display(int id, Location location, boolean coords) { - // TODO if shift-click change display else open Control Menu GUI - // get the text display - TextDisplay display = getTextDisplay(location, coords); - if (display != null) { - display.setRotation(Location.normalizeYaw(300), -10f); - new ControlMonitor(plugin).update(id, display.getUniqueId(), coords); + public void display(int id, Location location, boolean coords, Player player) { + // if shift-click change display else open Control Menu GUI + if (player.isSneaking()) { + // get the text display + TextDisplay display = getTextDisplay(location, coords); + if (display != null) { + display.setRotation(Location.normalizeYaw(300), -10f); + new ControlMonitor(plugin).update(id, display.getUniqueId(), coords); + } + } else { + // open control menu + new ControlMenuAction(plugin).openGUI(player, id); } } From 0e34d9bcab04071d9ba65be43d18c071f65a4e8b Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Tue, 9 Apr 2024 16:41:00 +1200 Subject: [PATCH 22/96] Update LibsDisguises dependency --- pom.xml | 2 +- .../TARDIS/console/models/HandbrakeModel.java | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/models/HandbrakeModel.java diff --git a/pom.xml b/pom.xml index 3cb758ccb..2b3a83fee 100644 --- a/pom.xml +++ b/pom.xml @@ -453,7 +453,7 @@ LibsDisguises LibsDisguises - 10.0.42-SNAPSHOT + 10.0.43 jar provided diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/HandbrakeModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/HandbrakeModel.java new file mode 100644 index 000000000..143c34e44 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/HandbrakeModel.java @@ -0,0 +1,22 @@ +package me.eccentric_nz.TARDIS.console.models; + +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class HandbrakeModel { + + public void setState(ItemDisplay display, int state) { + ItemStack is = display.getItemStack(); + ItemMeta im = is.getItemMeta(); + int cmd = im.getCustomModelData(); + if (state == 0) { + cmd += 10000; + } else { + cmd -= 10000; + } + im.setCustomModelData(cmd); + is.setItemMeta(im); + display.setItemStack(is); + } +} From 8f33253fd346707b6470632c3d2cb27ebe3740a5 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Wed, 10 Apr 2024 15:47:38 +1200 Subject: [PATCH 23/96] Model changing prep --- .../TARDIS/console/models/DirectionModel.java | 16 ++++++++++++++++ .../TARDIS/console/models/FlightModeModel.java | 16 ++++++++++++++++ .../console/models/HelmicRegulatorModel.java | 17 +++++++++++++++++ .../TARDIS/console/models/LightLevelModel.java | 17 +++++++++++++++++ .../TARDIS/console/models/ThrottleModel.java | 16 ++++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/models/DirectionModel.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/models/FlightModeModel.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/models/HelmicRegulatorModel.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/models/LightLevelModel.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/models/ThrottleModel.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/DirectionModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/DirectionModel.java new file mode 100644 index 000000000..2c33e63c7 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/DirectionModel.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.models; + +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class DirectionModel { + + public void setState(ItemDisplay display, int state) { + ItemStack is = display.getItemStack(); + ItemMeta im = is.getItemMeta(); + im.setCustomModelData(state + 10000); + is.setItemMeta(im); + display.setItemStack(is); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/FlightModeModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/FlightModeModel.java new file mode 100644 index 000000000..155c94750 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/FlightModeModel.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.models; + +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class FlightModeModel { + + public void setState(ItemDisplay display, int state) { + ItemStack is = display.getItemStack(); + ItemMeta im = is.getItemMeta(); + im.setCustomModelData(state + 10000); + is.setItemMeta(im); + display.setItemStack(is); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/HelmicRegulatorModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/HelmicRegulatorModel.java new file mode 100644 index 000000000..4280e3cba --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/HelmicRegulatorModel.java @@ -0,0 +1,17 @@ +package me.eccentric_nz.TARDIS.console.models; + +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class HelmicRegulatorModel { + + public void setState(ItemDisplay display, int state, boolean powered) { + ItemStack is = display.getItemStack(); + ItemMeta im = is.getItemMeta(); + int base = (powered) ? 10000 : 20000; + im.setCustomModelData(state + base); + is.setItemMeta(im); + display.setItemStack(is); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/LightLevelModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/LightLevelModel.java new file mode 100644 index 000000000..549f96830 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/LightLevelModel.java @@ -0,0 +1,17 @@ +package me.eccentric_nz.TARDIS.console.models; + +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class LightLevelModel { + + public void setState(ItemDisplay display, int state, boolean powered) { + ItemStack is = display.getItemStack(); + ItemMeta im = is.getItemMeta(); + int base = (powered) ? 10000 : 20000; + im.setCustomModelData(state + base); + is.setItemMeta(im); + display.setItemStack(is); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/ThrottleModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/ThrottleModel.java new file mode 100644 index 000000000..6d091c187 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/ThrottleModel.java @@ -0,0 +1,16 @@ +package me.eccentric_nz.TARDIS.console.models; + +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class ThrottleModel { + + public void setState(ItemDisplay display, int state) { + ItemStack is = display.getItemStack(); + ItemMeta im = is.getItemMeta(); + im.setCustomModelData(state + 10000); + is.setItemMeta(im); + display.setItemStack(is); + } +} From 498148d9511502f8d7ea4fd8acdc72cb36a5974f Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Thu, 11 Apr 2024 22:18:33 +1200 Subject: [PATCH 24/96] Let's actually try and set the control state --- .../java/me/eccentric_nz/TARDIS/TARDIS.java | 12 ++++ .../TARDIS/console/ConsoleBuilder.java | 57 +++++++++++++++++++ .../TARDIS/console/ConsoleInteraction.java | 29 +++++++--- .../console/ConsoleInteractionListener.java | 2 +- .../interaction/HandbrakeInteraction.java | 21 ++++++- .../TARDIS/console/models/HandbrakeModel.java | 6 +- 6 files changed, 114 insertions(+), 13 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java b/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java index 4d9b0b01f..862fb2732 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java +++ b/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java @@ -203,6 +203,7 @@ public class TARDIS extends JavaPlugin { private NamespacedKey timeLordUuidKey; private NamespacedKey standUuidKey; private NamespacedKey interactionUuidKey; + private NamespacedKey modelUuidKey; private NamespacedKey unaryKey; private NamespacedKey blueprintKey; private NamespacedKey sonicUuidKey; @@ -309,6 +310,7 @@ public void onEnable() { timeLordUuidKey = new NamespacedKey(this, "timelord_uuid"); standUuidKey = new NamespacedKey(this, "stand_uuid"); interactionUuidKey = new NamespacedKey(this, "interaction_uuid"); + modelUuidKey = new NamespacedKey(this, "model_uuid"); unaryKey = new NamespacedKey(this, "unary"); blueprintKey = new NamespacedKey(this, "blueprint"); sonicUuidKey = new NamespacedKey(this, "sonic_uuid"); @@ -1337,6 +1339,15 @@ public NamespacedKey getInteractionUuidKey() { return interactionUuidKey; } + /** + * Gets the console model UUID NamespacedKey + * + * @return the console model UUID NamespacedKey + */ + public NamespacedKey getModelUuidKey() { + return modelUuidKey; + } + /** * Gets the console interaction unary NamespacedKey * @@ -1978,4 +1989,5 @@ private void startRecorderTask() { public String getServerStr() { return serverStr; } + } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index 9b1db3ae6..c946fe109 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -13,6 +13,7 @@ import org.bukkit.persistence.PersistentDataType; import java.util.HashMap; +import java.util.UUID; public class ConsoleBuilder { @@ -57,6 +58,11 @@ public void create(Block block, int type, int id) { } // set interaction entities for console controls for (ConsoleInteraction i : ConsoleInteraction.values()) { + UUID uuid = null; + if (i.hasModel()) { + // spawn a display entity and save it's UUID to the interaction entity + uuid = spawnControl(i, block.getLocation()); + } double x = i.getRelativePosition().getX(); double z = i.getRelativePosition().getZ(); Location location = block.getLocation().clone().add(x, 1, z); @@ -71,6 +77,9 @@ public void create(Block block, int type, int id) { int cid = (i == ConsoleInteraction.EXTERIOR_LAMP_LEVEL_SWITCH) ? 49 : 50; plugin.getQueryFactory().insertControl(id, cid, location.toString(), 0); } + if (uuid != null) { + interaction.getPersistentDataContainer().set(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID(), uuid); + } interaction.setInteractionWidth(i.getWidth()); interaction.setInteractionHeight(i.getHeight()); interaction.setPersistent(true); @@ -83,4 +92,52 @@ public void create(Block block, int type, int id) { plugin.getQueryFactory().doInsert("interactions", data); } } + + private UUID spawnControl(ConsoleInteraction interaction, Location location) { + Material material = Material.LEVER; + int cmd; + switch (interaction) { + case HANDBRAKE -> { + cmd = 5001; + } + case THROTTLE -> { + material = Material.LEVER; + cmd = 5001; + } + case HELMIC_REGULATOR -> { + material = Material.LEVER; + cmd = 5001; + } + case DIRECTION -> { + material = Material.LEVER; + cmd = 5001; + } + case RELATIVITY_DIFFERENTIATOR -> { + material = Material.LEVER; + cmd = 5001; + } + case INTERIOR_LIGHT_LEVEL_SWITCH -> { + material = Material.LEVER; + cmd = 5001; + } + default -> { + material = Material.LEVER; + cmd = 5001; + } + } + // spawn a handbrake + ItemStack is = new ItemStack(material); + ItemMeta im = is.getItemMeta(); + im.setCustomModelData(cmd); + im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, cmd); + is.setItemMeta(im); + ItemDisplay handbrake = (ItemDisplay) location.getWorld().spawnEntity(location.add(0.5d, 0.5d, 0.5d), EntityType.ITEM_DISPLAY); + handbrake.setItemStack(is); + handbrake.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); + handbrake.setPersistent(true); + handbrake.setInvulnerable(true); + UUID uuid = handbrake.getUniqueId(); + handbrake.getPersistentDataContainer().set(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID(), uuid); + return uuid; + } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java index a713bd95d..232ac3e65 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java @@ -5,16 +5,16 @@ public enum ConsoleInteraction { // section zero - HANDBRAKE("Time Rotor Handbrake", new Vector(0.0d, 1d, 2.25d), 0.5f, 0.4f, 1), - THROTTLE("Flight Speed", new Vector(0.9d, 1.0d, 2.375d), 0.5f, 0.33f, 4), - RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.575d, 1.0d, 1.75d), 0.5f, 0.65f, 1), + HANDBRAKE("Time Rotor Handbrake", new Vector(0.0d, 1d, 2.25d), 0.5f, 0.4f, 1, true), + THROTTLE("Flight Speed", new Vector(0.9d, 1.0d, 2.375d), 0.5f, 0.33f, 4, true), + RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.575d, 1.0d, 1.75d), 0.5f, 0.65f, 1, true), // section one WORLD("Environment Selector", new Vector(-0.525d, 1.0d, 0.95d), 0.15f, 0.65f, 1), MULTIPLIER("Coordinate Increment Modifier", new Vector(-0.4d, 1.0d, 1.2d), 0.15f, 0.65f, 1), X("X Distance", new Vector(-0.75d, 1.0d, 1.1d), 0.15f, 0.4f, 1), Z("Z Distance", new Vector(-0.6d, 1.0d, 1.3d), 0.15f, 0.4f, 1), - HELMIC_REGULATOR("Dimension Selector", new Vector(-0.85d, 1d, 1.8d), 0.5f, 0.6f, 0), + HELMIC_REGULATOR("Dimension Selector", new Vector(-0.85d, 1d, 1.8d), 0.5f, 0.6f, 0, true), // section two RANDOMISER("Random Location Finder", new Vector(-0.85d, 1d, -0.8125d), 0.25f, 0.33f, 0), @@ -24,12 +24,12 @@ public enum ConsoleInteraction { // section three SONIC_DOCK("Sonic Screwdriver Dock", new Vector(0.45d, 1d, -0.65d), 0.5f, 0.65f, 0), - DIRECTION("Exterior Directional Control", new Vector(0.125d, 1d, -1.2d), 0.625f, 0.5f, 0), + DIRECTION("Exterior Directional Control", new Vector(0.125d, 1d, -1.2d), 0.625f, 0.5f, 0, true), // section four LIGHT_SWITCH("Interior Light Switch", new Vector(2.475d, 1d, 0.1d), 0.25f, 0.33f, 0), - INTERIOR_LIGHT_LEVEL_SWITCH("Interior Light Level", new Vector(1.8d, 1d, 0.0d), 0.25f, 0.5f, 0), - EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Lamp Level", new Vector(1.5d, 1d, -0.3d), 0.25f, 0.5f, 0), + INTERIOR_LIGHT_LEVEL_SWITCH("Interior Light Level", new Vector(1.8d, 1d, 0.0d), 0.25f, 0.5f, 0, true), + EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Lamp Level", new Vector(1.5d, 1d, -0.3d), 0.25f, 0.5f, 0, true), DOOR_TOGGLE("Toggle Wool Switch", new Vector(1.825d, 1d, -1.0d), 0.25f, 0.33f, 0), // section five @@ -44,6 +44,16 @@ public enum ConsoleInteraction { private final float width; private final float height; private final int defaultState; + private final boolean model; + + ConsoleInteraction(String alternateName, Vector relativePosition, float width, float height, int defaultState, boolean model) { + this.alternateName = alternateName; + this.relativePosition = relativePosition; + this.width = width; + this.height = height; + this.defaultState = defaultState; + this.model = model; + } ConsoleInteraction(String alternateName, Vector relativePosition, float width, float height, int defaultState) { this.alternateName = alternateName; @@ -51,6 +61,7 @@ public enum ConsoleInteraction { this.width = width; this.height = height; this.defaultState = defaultState; + this.model = false; } public String getAlternateName() { @@ -72,4 +83,8 @@ public float getHeight() { public int getDefaultState() { return defaultState; } + + public boolean hasModel() { + return model; + } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index 175fc7de6..d7c5d45d4 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -33,7 +33,7 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { switch (ci) { // section zero case HANDBRAKE -> - new HandbrakeInteraction(plugin).process(id, state, player, interaction.getLocation()); + new HandbrakeInteraction(plugin).process(id, state, player, interaction); case THROTTLE -> new ThrottleInteraction(plugin).process(player, interaction, id); case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(player); // section one diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java index 9997a578c..749535098 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java @@ -8,6 +8,7 @@ import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; import me.eccentric_nz.TARDIS.builders.TARDISSculkShrieker; import me.eccentric_nz.TARDIS.camera.TARDISCameraTracker; +import me.eccentric_nz.TARDIS.console.models.HandbrakeModel; import me.eccentric_nz.TARDIS.database.data.Tardis; import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentFromId; import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; @@ -20,6 +21,8 @@ import me.eccentric_nz.TARDIS.utility.Handbrake; import me.eccentric_nz.TARDIS.utility.TARDISSounds; import org.bukkit.Location; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; @@ -36,8 +39,9 @@ public HandbrakeInteraction(TARDIS plugin) { this.plugin = plugin; } - public void process(int id, int state, Player player, Location handbrake) { + public void process(int id, int state, Player player, Interaction interaction) { UUID uuid = player.getUniqueId(); + Location handbrake = interaction.getLocation(); TARDISCircuitChecker tcc = null; if (!plugin.getDifficulty().equals(Difficulty.EASY) && !plugin.getUtils().inGracePeriod(player, state == 0)) { tcc = new TARDISCircuitChecker(plugin, id); @@ -155,7 +159,13 @@ public void process(int id, int state, Player player, Location handbrake) { whereinteraction.put("tardis_id", id); whereinteraction.put("control", "HANDBRAKE"); plugin.getQueryFactory().doUpdate("interactions", seti, whereinteraction); - + // get the model display item + UUID model = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (model != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(model); + // set the handbrake display + new HandbrakeModel().setState(display, 0); + } } else { plugin.getMessenger().sendStatus(player, "HANDBRAKE_OFF_ERR"); } @@ -186,6 +196,13 @@ public void process(int id, int state, Player player, Location handbrake) { }); TARDISSounds.playTARDISSound(handbrake, "tardis_handbrake_engage"); // TODO change the custom model data so the lever is on + // get the model display item + UUID model = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (model != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(model); + // set the handbrake display + new HandbrakeModel().setState(display, 1); + } // TARDISHandbrake.setLevers(block, true, true, handbrake.toString(), id, plugin); // Check if it's at a recharge point new TARDISArtronLevels(plugin).recharge(id); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/HandbrakeModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/HandbrakeModel.java index 143c34e44..90e04c200 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/models/HandbrakeModel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/HandbrakeModel.java @@ -9,11 +9,11 @@ public class HandbrakeModel { public void setState(ItemDisplay display, int state) { ItemStack is = display.getItemStack(); ItemMeta im = is.getItemMeta(); - int cmd = im.getCustomModelData(); + int cmd; if (state == 0) { - cmd += 10000; + cmd = 5001; } else { - cmd -= 10000; + cmd = 5002; } im.setCustomModelData(cmd); is.setItemMeta(im); From c18657d834e3549ae9c19b97e8673dede49b7832 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Mon, 15 Apr 2024 13:26:06 +1200 Subject: [PATCH 25/96] Update some dependent plugins --- pom.xml | 4 ++-- todo.md | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 2b3a83fee..489c04e2a 100644 --- a/pom.xml +++ b/pom.xml @@ -342,7 +342,7 @@ com.palmergames.bukkit.towny towny - 0.100.1.0 + 0.100.2.0 provided @@ -453,7 +453,7 @@ LibsDisguises LibsDisguises - 10.0.43 + 10.0.44 jar provided diff --git a/todo.md b/todo.md index 4a16601e6..e4c430f8e 100644 --- a/todo.md +++ b/todo.md @@ -18,13 +18,12 @@ ## Future versions -1. Cache TARDIS data to speed lookup and reduce database queries -2. Use the Vortex Manipulator to teleport past force fields -3. Optional world name in `/tardistravel` - [#306](https://github.com/eccentricdevotion/TARDIS/issues/306) -4. Time travel - [#305](https://github.com/eccentricdevotion/TARDIS/issues/305) -5. Charge players a fee (via Vault) for using the Junk TARDIS (buy ticket at the TARDISShop?) -6. Sonic Blaster -7. All the things... +1. Use the Vortex Manipulator to teleport past force fields +2. Optional world name in `/tardistravel` - [#306](https://github.com/eccentricdevotion/TARDIS/issues/306) +3. Time travel - [#305](https://github.com/eccentricdevotion/TARDIS/issues/305) +4. Charge players a fee (via Vault) for using the Junk TARDIS (buy ticket at the TARDISShop?) +5. Sonic Blaster +6. All the things... ## Wiki Documentation From ce51e2f1f2f8318043d419f83bc1df72c3831e91 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 15 Apr 2024 20:21:43 +1200 Subject: [PATCH 26/96] More model setting --- .../TARDIS/builders/LightLevel.java | 4 +- .../TARDIS/console/ConsoleBuilder.java | 74 +++++++++++-------- .../TARDIS/console/ConsoleInteraction.java | 23 ++++-- .../console/ConsoleInteractionListener.java | 6 +- .../interaction/DirectionInteraction.java | 37 +++++++++- .../interaction/FlightModeInteraction.java | 14 +++- .../interaction/HandbrakeInteraction.java | 6 +- .../HelmicRegulatorInteraction.java | 14 +++- .../interaction/LampLevelInteraction.java | 11 ++- .../interaction/LightLevelInteraction.java | 11 ++- .../interaction/RandomiserInteraction.java | 3 +- .../interaction/ThrottleInteraction.java | 10 ++- .../TARDIS/console/models/DirectionModel.java | 3 + .../console/models/FlightModeModel.java | 8 +- .../TARDIS/console/models/HandbrakeModel.java | 3 + .../console/models/HelmicRegulatorModel.java | 5 +- .../console/models/LightLevelModel.java | 7 +- .../TARDIS/console/models/ThrottleModel.java | 5 +- .../telepathic/TARDISTelepathicStructure.java | 2 +- .../telepathic/TelepathicGUIListener.java | 2 + .../control/actions/LightLevelAction.java | 2 +- .../TARDIS/hads/TARDISCloisterBell.java | 3 +- .../TARDIS/travel/TARDISStructureTravel.java | 20 ++--- todo.md | 3 +- 24 files changed, 193 insertions(+), 83 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/builders/LightLevel.java b/src/main/java/me/eccentric_nz/TARDIS/builders/LightLevel.java index 8046963a1..236ac7d23 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/builders/LightLevel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/builders/LightLevel.java @@ -2,6 +2,6 @@ public class LightLevel { - public static final int[] interior_level = new int[]{2, 6, 10, 15}; - public static final int[] exterior_level = new int[]{2, 4, 6, 8}; + public static final int[] interior_level = new int[]{15, 13, 12, 11, 9, 7, 5, 3}; + public static final int[] exterior_level = new int[]{15, 13, 11, 9, 7, 5, 3, 1}; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index c946fe109..1e69f0838 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -1,6 +1,8 @@ package me.eccentric_nz.TARDIS.console; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentLocation; +import me.eccentric_nz.TARDIS.enumeration.COMPASS; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -61,7 +63,7 @@ public void create(Block block, int type, int id) { UUID uuid = null; if (i.hasModel()) { // spawn a display entity and save it's UUID to the interaction entity - uuid = spawnControl(i, block.getLocation()); + uuid = spawnControl(i, block.getLocation(), i.getYaw(), id); } double x = i.getRelativePosition().getX(); double z = i.getRelativePosition().getZ(); @@ -93,51 +95,61 @@ public void create(Block block, int type, int id) { } } - private UUID spawnControl(ConsoleInteraction interaction, Location location) { + private UUID spawnControl(ConsoleInteraction interaction, Location location, float angle, int id) { Material material = Material.LEVER; int cmd; switch (interaction) { - case HANDBRAKE -> { - cmd = 5001; - } + case HANDBRAKE -> cmd = 5002; case THROTTLE -> { - material = Material.LEVER; - cmd = 5001; + material = Material.REPEATER; + cmd = 1004; } case HELMIC_REGULATOR -> { - material = Material.LEVER; - cmd = 5001; + material = Material.REPEATER; + cmd = 2000; } case DIRECTION -> { - material = Material.LEVER; - cmd = 5001; - } - case RELATIVITY_DIFFERENTIATOR -> { - material = Material.LEVER; - cmd = 5001; - } - case INTERIOR_LIGHT_LEVEL_SWITCH -> { - material = Material.LEVER; - cmd = 5001; - } - default -> { - material = Material.LEVER; - cmd = 5001; + material = Material.RAIL; + HashMap wherec = new HashMap<>(); + wherec.put("tardis_id", id); + ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherec); + cmd = (rsc.resultSet()) ? getCmd(rsc.getDirection()) + 10000 : 10000; } + case RELATIVITY_DIFFERENTIATOR -> cmd = 6001; + case INTERIOR_LIGHT_LEVEL_SWITCH -> cmd = 7000; + default -> cmd = 8000; } - // spawn a handbrake + // spawn a control ItemStack is = new ItemStack(material); ItemMeta im = is.getItemMeta(); im.setCustomModelData(cmd); im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, cmd); is.setItemMeta(im); - ItemDisplay handbrake = (ItemDisplay) location.getWorld().spawnEntity(location.add(0.5d, 0.5d, 0.5d), EntityType.ITEM_DISPLAY); - handbrake.setItemStack(is); - handbrake.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); - handbrake.setPersistent(true); - handbrake.setInvulnerable(true); - UUID uuid = handbrake.getUniqueId(); - handbrake.getPersistentDataContainer().set(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID(), uuid); + ItemDisplay display = (ItemDisplay) location.getWorld().spawnEntity(location.add(0.5d, 1.5d, 0.5d), EntityType.ITEM_DISPLAY); + display.setItemStack(is); + display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); + display.setPersistent(true); + display.setInvulnerable(true); + UUID uuid = display.getUniqueId(); + display.getPersistentDataContainer().set(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID(), uuid); + float yaw = Location.normalizeYaw(angle); + // set display rotation + display.setRotation(yaw, 0); return uuid; } + + private int getCmd(COMPASS direction) { + int cmd; + switch (direction) { + case NORTH_EAST -> cmd = 1; + case EAST -> cmd = 2; + case SOUTH_EAST -> cmd = 3; + case SOUTH -> cmd = 4; + case SOUTH_WEST -> cmd = 5; + case WEST -> cmd = 6; + case NORTH_WEST -> cmd = 7; + default -> cmd = 0; + } + return cmd; + } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java index 232ac3e65..1790b9cfd 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java @@ -5,16 +5,16 @@ public enum ConsoleInteraction { // section zero - HANDBRAKE("Time Rotor Handbrake", new Vector(0.0d, 1d, 2.25d), 0.5f, 0.4f, 1, true), - THROTTLE("Flight Speed", new Vector(0.9d, 1.0d, 2.375d), 0.5f, 0.33f, 4, true), - RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.575d, 1.0d, 1.75d), 0.5f, 0.65f, 1, true), + HANDBRAKE("Time Rotor Handbrake", new Vector(0.0d, 1d, 2.25d), 0.5f, 0.4f, 1, true, 0.0f), + THROTTLE("Flight Speed", new Vector(0.9d, 1.0d, 2.375d), 0.5f, 0.33f, 4, true, 0.0f), + RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.575d, 1.0d, 1.75d), 0.5f, 0.65f, 1, true, 0.0f), // section one WORLD("Environment Selector", new Vector(-0.525d, 1.0d, 0.95d), 0.15f, 0.65f, 1), MULTIPLIER("Coordinate Increment Modifier", new Vector(-0.4d, 1.0d, 1.2d), 0.15f, 0.65f, 1), X("X Distance", new Vector(-0.75d, 1.0d, 1.1d), 0.15f, 0.4f, 1), Z("Z Distance", new Vector(-0.6d, 1.0d, 1.3d), 0.15f, 0.4f, 1), - HELMIC_REGULATOR("Dimension Selector", new Vector(-0.85d, 1d, 1.8d), 0.5f, 0.6f, 0, true), + HELMIC_REGULATOR("Dimension Selector", new Vector(-0.85d, 1d, 1.8d), 0.5f, 0.6f, 0, true, 60.0f), // section two RANDOMISER("Random Location Finder", new Vector(-0.85d, 1d, -0.8125d), 0.25f, 0.33f, 0), @@ -24,12 +24,12 @@ public enum ConsoleInteraction { // section three SONIC_DOCK("Sonic Screwdriver Dock", new Vector(0.45d, 1d, -0.65d), 0.5f, 0.65f, 0), - DIRECTION("Exterior Directional Control", new Vector(0.125d, 1d, -1.2d), 0.625f, 0.5f, 0, true), + DIRECTION("Exterior Directional Control", new Vector(0.125d, 1d, -1.2d), 0.625f, 0.5f, 0, true, 180.0f), // section four LIGHT_SWITCH("Interior Light Switch", new Vector(2.475d, 1d, 0.1d), 0.25f, 0.33f, 0), - INTERIOR_LIGHT_LEVEL_SWITCH("Interior Light Level", new Vector(1.8d, 1d, 0.0d), 0.25f, 0.5f, 0, true), - EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Lamp Level", new Vector(1.5d, 1d, -0.3d), 0.25f, 0.5f, 0, true), + INTERIOR_LIGHT_LEVEL_SWITCH("Interior Light Level", new Vector(1.8d, 1d, 0.0d), 0.25f, 0.5f, 0, true, 240.0f), + EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Lamp Level", new Vector(1.5d, 1d, -0.3d), 0.25f, 0.5f, 0, true, 240.0f), DOOR_TOGGLE("Toggle Wool Switch", new Vector(1.825d, 1d, -1.0d), 0.25f, 0.33f, 0), // section five @@ -45,14 +45,16 @@ public enum ConsoleInteraction { private final float height; private final int defaultState; private final boolean model; + private final float yaw; - ConsoleInteraction(String alternateName, Vector relativePosition, float width, float height, int defaultState, boolean model) { + ConsoleInteraction(String alternateName, Vector relativePosition, float width, float height, int defaultState, boolean model, float yaw) { this.alternateName = alternateName; this.relativePosition = relativePosition; this.width = width; this.height = height; this.defaultState = defaultState; this.model = model; + this.yaw = yaw; } ConsoleInteraction(String alternateName, Vector relativePosition, float width, float height, int defaultState) { @@ -62,6 +64,7 @@ public enum ConsoleInteraction { this.height = height; this.defaultState = defaultState; this.model = false; + this.yaw = 0.0f; } public String getAlternateName() { @@ -87,4 +90,8 @@ public int getDefaultState() { public boolean hasModel() { return model; } + + public float getYaw() { + return yaw; + } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index d7c5d45d4..8cf9317c2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -35,11 +35,11 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { case HANDBRAKE -> new HandbrakeInteraction(plugin).process(id, state, player, interaction); case THROTTLE -> new ThrottleInteraction(plugin).process(player, interaction, id); - case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(player); + case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(player, interaction); // section one case WORLD -> new WorldInteraction(plugin).selectWorld(state, player, id); case MULTIPLIER, X, Z -> new MultiplierXZInteraction(plugin).setRange(ci, state, id, player); - case HELMIC_REGULATOR -> new HelmicRegulatorInteraction(plugin).selectWorld(state, id, player); + case HELMIC_REGULATOR -> new HelmicRegulatorInteraction(plugin).selectWorld(state, id, player, interaction); // section two case RANDOMISER -> new RandomiserInteraction(plugin).generateDestination(id, player); case WAYPOINT_SELECTOR -> new WayPointInteraction(plugin).openSaveGUI(id, player); @@ -47,7 +47,7 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { case TELEPATHIC_CIRCUIT -> new TelepathicCircuitInteraction(plugin).openGUI(player); // section three case SONIC_DOCK -> new SonicDockInteraction(plugin).process(player, interaction, id); - case DIRECTION -> new DirectionInteraction(plugin).rotate(id, player); + case DIRECTION -> new DirectionInteraction(plugin).rotate(id, player, interaction); // section four case LIGHT_SWITCH -> new LightSwitchInteraction(plugin).toggle(id, player); case INTERIOR_LIGHT_LEVEL_SWITCH -> new LightLevelInteraction(plugin).setInterior(state, id, interaction, player); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java index d3954d9e1..2f2ad146b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java @@ -1,9 +1,16 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.models.DirectionModel; import me.eccentric_nz.TARDIS.control.actions.DirectionAction; +import me.eccentric_nz.TARDIS.database.InteractionStateSaver; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; +import java.util.UUID; + public class DirectionInteraction { private final TARDIS plugin; @@ -12,9 +19,35 @@ public DirectionInteraction(TARDIS plugin) { this.plugin = plugin; } - public void rotate(int id, Player player) { + public void rotate(int id, Player player, Interaction interaction) { + if (plugin.getTrackerKeeper().getInVortex().contains(id) || plugin.getTrackerKeeper().getMaterialising().contains(id) || plugin.getTrackerKeeper().getDematerialising().contains(id)) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_WHILE_MAT"); + return; + } String direction = new DirectionAction(plugin).rotate(id, player); plugin.getMessenger().announceRepeater(player, direction); - // TODO set custom model data for direction item display + int state = getState(direction); + new InteractionStateSaver(plugin).write("DIRECTION", state, id); + // set custom model data for direction item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + new DirectionModel().setState(display, state); + } + } + + private int getState(String direction) { + int state; + switch (direction) { + case "NORTH_EAST" -> state = 1; + case "EAST" -> state = 2; + case "SOUTH_EAST" -> state = 3; + case "SOUTH" -> state = 4; + case "SOUTH_WEST" -> state = 5; + case "WEST" -> state = 6; + case "NORTH_WEST" -> state = 7; + default -> state = 0; + } + return state; } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java index fdc5dcc18..77d0b3b68 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java @@ -1,12 +1,16 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.models.FlightModeModel; import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; import me.eccentric_nz.TARDIS.enumeration.FlightMode; import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; import java.util.HashMap; +import java.util.UUID; public class FlightModeInteraction { @@ -16,7 +20,7 @@ public FlightModeInteraction(TARDIS plugin) { this.plugin = plugin; } - public void process(Player player) { + public void process(Player player, Interaction interaction) { String uuid = player.getUniqueId().toString(); // get current throttle setting ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, uuid); @@ -32,8 +36,12 @@ public void process(Player player) { HashMap where = new HashMap<>(); where.put("uuid", player.getUniqueId().toString()); TARDIS.plugin.getQueryFactory().doUpdate("player_prefs", setf, where); -// plugin.getMessenger().send(player, TardisModule.TARDIS, "FLIGHT_SAVED"); - // TODO set custom model data for relativity differentiator item display + // set custom model data for relativity differentiator item display + UUID model = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (model != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(model); + new FlightModeModel().setState(display, mode); + } // TODO make relativity differentiator standalone control set player_prefs flightmode when toggled - exterior|normal // TODO then alter `isRelativityDifferentiated()` to check player prefs instead // should !exterior|normal flight modes even be accessible from this interaction? if so: diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java index 749535098..bcc4f9ff5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java @@ -163,7 +163,7 @@ public void process(int id, int state, Player player, Interaction interaction) { UUID model = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); if (model != null) { ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(model); - // set the handbrake display + // change the custom model data so the lever is off new HandbrakeModel().setState(display, 0); } } else { @@ -195,15 +195,13 @@ public void process(int id, int state, Player player, Interaction interaction) { plugin.getTrackerKeeper().getFlyingReturnLocation().remove(uuid); }); TARDISSounds.playTARDISSound(handbrake, "tardis_handbrake_engage"); - // TODO change the custom model data so the lever is on // get the model display item UUID model = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); if (model != null) { ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(model); - // set the handbrake display + // change the custom model data so the lever is on new HandbrakeModel().setState(display, 1); } -// TARDISHandbrake.setLevers(block, true, true, handbrake.toString(), id, plugin); // Check if it's at a recharge point new TARDISArtronLevels(plugin).recharge(id); Handbrake hb = new Handbrake(plugin); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java index 6f751a516..7d9380f7c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java @@ -1,9 +1,14 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.models.HelmicRegulatorModel; import me.eccentric_nz.TARDIS.database.InteractionStateSaver; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; +import java.util.UUID; + public class HelmicRegulatorInteraction { private final TARDIS plugin; @@ -12,7 +17,7 @@ public HelmicRegulatorInteraction(TARDIS plugin) { this.plugin = plugin; } - public void selectWorld(int state, int id, Player player) { + public void selectWorld(int state, int id, Player player, Interaction interaction) { int next = state + 1; if (next > 8 || player.isSneaking()) { next = 0; @@ -29,7 +34,12 @@ public void selectWorld(int state, int id, Player player) { } // save state new InteractionStateSaver(plugin).write("HELMIC_REGULATOR", next, id); - // TODO set custom model data for helmic regulator item display + // set custom model data for helmic regulator item display + UUID model = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (model != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(model); + new HelmicRegulatorModel().setState(display, next); + } } private String getWorldFromState(int state) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java index 4c01c0cc7..372506398 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java @@ -2,13 +2,17 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.console.InteractionResponse; +import me.eccentric_nz.TARDIS.console.models.LightLevelModel; import me.eccentric_nz.TARDIS.control.actions.LightLevelAction; import me.eccentric_nz.TARDIS.database.InteractionStateSaver; import me.eccentric_nz.TARDIS.database.resultset.ResultSetLightLevel; import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; import org.bukkit.persistence.PersistentDataType; +import java.util.UUID; + public class LampLevelInteraction { private final TARDIS plugin; @@ -29,7 +33,12 @@ public void setExterior(int state, int id, Interaction interaction, Player playe unary = 1; } interaction.getPersistentDataContainer().set(plugin.getUnaryKey(), PersistentDataType.INTEGER, unary); - // TODO set custom model data for lamp level switch item display + // set custom model data for lamp level switch item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + new LightLevelModel().setState(display, setLevel, false); + } // get light level record ResultSetLightLevel rs = new ResultSetLightLevel(plugin, interaction.getLocation().toString()); if (rs.resultSet()) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java index 78949454d..46b64e62b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java @@ -2,13 +2,17 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.console.InteractionResponse; +import me.eccentric_nz.TARDIS.console.models.LightLevelModel; import me.eccentric_nz.TARDIS.control.actions.LightLevelAction; import me.eccentric_nz.TARDIS.database.InteractionStateSaver; import me.eccentric_nz.TARDIS.database.resultset.ResultSetLightLevel; import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; import org.bukkit.persistence.PersistentDataType; +import java.util.UUID; + public class LightLevelInteraction { private final TARDIS plugin; @@ -29,7 +33,12 @@ public void setInterior(int state, int id, Interaction interaction, Player playe unary = 1; } interaction.getPersistentDataContainer().set(plugin.getUnaryKey(), PersistentDataType.INTEGER, unary); - // TODO set custom model data for light level switch item display + // set custom model data for light level switch item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + new LightLevelModel().setState(display, setLevel, true); + } // get light level record ResultSetLightLevel rs = new ResultSetLightLevel(plugin, interaction.getLocation().toString()); if (rs.resultSet()) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java index 5b2fb08e1..2b42fa560 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java @@ -4,7 +4,6 @@ import me.eccentric_nz.TARDIS.advanced.TARDISCircuitChecker; import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; import me.eccentric_nz.TARDIS.builders.TARDISEmergencyRelocation; -import me.eccentric_nz.TARDIS.control.TARDISRandomButton; import me.eccentric_nz.TARDIS.control.actions.ExileAction; import me.eccentric_nz.TARDIS.control.actions.RandomDestinationAction; import me.eccentric_nz.TARDIS.database.data.Tardis; @@ -67,7 +66,7 @@ public void generateDestination(int id, Player player) { if (TARDISPermission.hasPermission(player, "tardis.exile") && plugin.getConfig().getBoolean("travel.exile")) { new ExileAction(plugin).getExile(player, id, direction); } else { - new TARDISRandomButton(plugin, player, id, tardis.getArtronLevel(), 0, tardis.getCompanions(), tardis.getUuid()).clickButton(); +// new TARDISRandomButton(plugin, player, id, tardis.getArtronLevel(), 0, tardis.getCompanions(), tardis.getUuid()).clickButton(); // get state from WORLD, MULTIPLIER, X, Z and HELMIC_REGULATOR interactions ResultSetRandomInteractions rsri = new ResultSetRandomInteractions(plugin, id); if (rsri.resultSet()) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java index a95739296..fce1c9498 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java @@ -1,14 +1,17 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.models.ThrottleModel; import me.eccentric_nz.TARDIS.database.InteractionStateSaver; import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; import me.eccentric_nz.TARDIS.enumeration.SpaceTimeThrottle; import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; import org.bukkit.persistence.PersistentDataType; import java.util.HashMap; +import java.util.UUID; public class ThrottleInteraction { @@ -51,7 +54,12 @@ public void process(Player player, Interaction interaction, int id) { plugin.getQueryFactory().doUpdate("player_prefs", setr, wherer); new InteractionStateSaver(plugin).write("THROTTLE", delay, id); plugin.getMessenger().announceRepeater(player, throttle); - // TODO set custom model data for throttle item display + // set custom model data for throttle item display + UUID model = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (model != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(model); + new ThrottleModel().setState(display, delay); + } } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/DirectionModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/DirectionModel.java index 2c33e63c7..8c546d380 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/models/DirectionModel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/DirectionModel.java @@ -7,6 +7,9 @@ public class DirectionModel { public void setState(ItemDisplay display, int state) { + if (display == null) { + return; + } ItemStack is = display.getItemStack(); ItemMeta im = is.getItemMeta(); im.setCustomModelData(state + 10000); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/FlightModeModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/FlightModeModel.java index 155c94750..71a310d29 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/models/FlightModeModel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/FlightModeModel.java @@ -7,9 +7,15 @@ public class FlightModeModel { public void setState(ItemDisplay display, int state) { + if (display == null) { + return; + } + if (state < 4) { + state = 1; + } ItemStack is = display.getItemStack(); ItemMeta im = is.getItemMeta(); - im.setCustomModelData(state + 10000); + im.setCustomModelData(state + 6000); is.setItemMeta(im); display.setItemStack(is); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/HandbrakeModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/HandbrakeModel.java index 90e04c200..ceb6f8feb 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/models/HandbrakeModel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/HandbrakeModel.java @@ -7,6 +7,9 @@ public class HandbrakeModel { public void setState(ItemDisplay display, int state) { + if (display == null) { + return; + } ItemStack is = display.getItemStack(); ItemMeta im = is.getItemMeta(); int cmd; diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/HelmicRegulatorModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/HelmicRegulatorModel.java index 4280e3cba..7e07f1de1 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/models/HelmicRegulatorModel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/HelmicRegulatorModel.java @@ -6,11 +6,10 @@ public class HelmicRegulatorModel { - public void setState(ItemDisplay display, int state, boolean powered) { + public void setState(ItemDisplay display, int state) { ItemStack is = display.getItemStack(); ItemMeta im = is.getItemMeta(); - int base = (powered) ? 10000 : 20000; - im.setCustomModelData(state + base); + im.setCustomModelData(state + 2000); is.setItemMeta(im); display.setItemStack(is); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/LightLevelModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/LightLevelModel.java index 549f96830..d97713a76 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/models/LightLevelModel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/LightLevelModel.java @@ -6,10 +6,13 @@ public class LightLevelModel { - public void setState(ItemDisplay display, int state, boolean powered) { + public void setState(ItemDisplay display, int state, boolean interior) { + if (display == null) { + return; + } ItemStack is = display.getItemStack(); ItemMeta im = is.getItemMeta(); - int base = (powered) ? 10000 : 20000; + int base = (interior) ? 7000 : 8000; im.setCustomModelData(state + base); is.setItemMeta(im); display.setItemStack(is); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/ThrottleModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/ThrottleModel.java index 6d091c187..7f59ff871 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/models/ThrottleModel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/ThrottleModel.java @@ -7,9 +7,12 @@ public class ThrottleModel { public void setState(ItemDisplay display, int state) { + if (display == null) { + return; + } ItemStack is = display.getItemStack(); ItemMeta im = is.getItemMeta(); - im.setCustomModelData(state + 10000); + im.setCustomModelData(state + 1000); is.setItemMeta(im); display.setItemStack(is); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicStructure.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicStructure.java index 991883079..cf341c8fc 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicStructure.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TARDISTelepathicStructure.java @@ -46,7 +46,7 @@ public ItemStack[] getButtons() { private ItemStack make(Structure structure, Material material) { ItemStack is = new ItemStack(material, 1); ItemMeta im = is.getItemMeta(); - im.setDisplayName(TARDISStringUtils.capitalise(structure.toString())); + im.setDisplayName(TARDISStringUtils.capitalise(structure.getKey().getKey())); is.setItemMeta(im); return is; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java index 49332cf9a..89ca81f70 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java @@ -57,6 +57,8 @@ public void onTelepathicMenuClick(InventoryClickEvent event) { int cmd = im.getCustomModelData(); im.setCustomModelData((cmd > 100) ? cmd - 100 : cmd + 100); choice.setItemMeta(im); + plugin.getMessenger().announceRepeater(player, "Telepathic Circuit " + (b == 1 ? "ON" : "OFF")); + close(player); } // cave finder case 2 -> { diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/LightLevelAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/LightLevelAction.java index 3eabfba58..b79eccd37 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/actions/LightLevelAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/LightLevelAction.java @@ -21,7 +21,7 @@ public LightLevelAction(TARDIS plugin) { public void illuminate(int level, int control, boolean powered, int type, boolean policebox, int id, boolean lightsOn) { // save the level to the database - int setLevel = (level + 1) > 3 ? 0 : level + 1; + int setLevel = (level + 1) > 8 ? 0 : level + 1; HashMap set = new HashMap<>(); set.put("secondary", setLevel); HashMap where = new HashMap<>(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/hads/TARDISCloisterBell.java b/src/main/java/me/eccentric_nz/TARDIS/hads/TARDISCloisterBell.java index 116fe1e2c..5d7bc6ac7 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/hads/TARDISCloisterBell.java +++ b/src/main/java/me/eccentric_nz/TARDIS/hads/TARDISCloisterBell.java @@ -130,7 +130,8 @@ public void run() { } i++; } else { - plugin.getServer().getScheduler().cancelTask(plugin.getTrackerKeeper().getCloisterBells().get(id)); +// int taskId = plugin.getTrackerKeeper().getCloisterBells().get(id); + plugin.getServer().getScheduler().cancelTask(task); task = -1; plugin.getTrackerKeeper().getCloisterBells().remove(id); if (messageOff && player != null && player.isOnline()) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISStructureTravel.java b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISStructureTravel.java index 92033ebfa..bef4be642 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISStructureTravel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISStructureTravel.java @@ -42,10 +42,8 @@ public class TARDISStructureTravel { public static final List netherStructures = new ArrayList<>(); public static final List overworldStructures = new ArrayList<>(); - private final TARDIS plugin; - public TARDISStructureTravel(TARDIS plugin) { - this.plugin = plugin; + static { netherStructures.add(Structure.BASTION_REMNANT); netherStructures.add(Structure.FORTRESS); netherStructures.add(Structure.NETHER_FOSSIL); @@ -79,6 +77,12 @@ public TARDISStructureTravel(TARDIS plugin) { overworldStructures.add(Structure.VILLAGE_TAIGA); } + private final TARDIS plugin; + + public TARDISStructureTravel(TARDIS plugin) { + this.plugin = plugin; + } + public TARDISStructureLocation getRandomVillage(Player p, int id, String[] args) { // get world the Police Box is in ResultSetCurrentFromId rs = new ResultSetCurrentFromId(plugin, id); @@ -185,15 +189,7 @@ private Check isThereRoom(World w, int x, int starty, int z) { // check there is enough height for the police box if (yy <= y - 3 && !w.getBlockAt(x - 1, yy - 1, z - 1).getType().equals(Material.STONE)) { // check there is room for the police box - if (w.getBlockAt(x - 1, yy, z - 1).getType().isAir() - && w.getBlockAt(x - 1, yy, z).getType().isAir() - && w.getBlockAt(x - 1, yy, z + 1).getType().isAir() - && w.getBlockAt(x, yy, z - 1).getType().isAir() - && w.getBlockAt(x, yy, z + 1).getType().isAir() - && w.getBlockAt(x + 1, yy, z - 1).getType().isAir() - && w.getBlockAt(x + 1, yy, z).getType().isAir() - && w.getBlockAt(x + 1, yy, z + 1).getType().isAir() - ) { + if (w.getBlockAt(x - 1, yy, z - 1).getType().isAir() && w.getBlockAt(x - 1, yy, z).getType().isAir() && w.getBlockAt(x - 1, yy, z + 1).getType().isAir() && w.getBlockAt(x, yy, z - 1).getType().isAir() && w.getBlockAt(x, yy, z + 1).getType().isAir() && w.getBlockAt(x + 1, yy, z - 1).getType().isAir() && w.getBlockAt(x + 1, yy, z).getType().isAir() && w.getBlockAt(x + 1, yy, z + 1).getType().isAir()) { ret.setSafe(true); ret.setY(yy); } diff --git a/todo.md b/todo.md index e4c430f8e..de643dc36 100644 --- a/todo.md +++ b/todo.md @@ -5,7 +5,8 @@ 1. Fix fifteenth console redstone piston door 2. Fix follower persistence 3. Update `monsters` count in database -4. ? +4. Shift-clicking custom door shouldn't open it +5. ? ## Next version `5.7.0` From 2ea64f6d92656295c8fb2669f33385dd9ac4572f Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Tue, 16 Apr 2024 08:28:07 +1200 Subject: [PATCH 27/96] Add back accidentally removed monsters --- .../TARDIS/console/interaction/HandbrakeInteraction.java | 2 +- .../me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java | 3 +++ todo.md | 5 ++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java index bcc4f9ff5..bf1d174a2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java @@ -209,7 +209,7 @@ public void process(int id, int state, Player player, Interaction interaction) { hb.toggleBeacon(beacon, false); } hb.handleSensor(id); - // Remove energy from TARDIS and sets database + // remove energy from TARDIS and set database plugin.getMessenger().sendStatus(player, "HANDBRAKE_ON"); if (plugin.getTrackerKeeper().getHasDestination().containsKey(id)) { int amount = Math.round(plugin.getTrackerKeeper().getHasDestination().get(id).getCost() * spaceTimeThrottle.getArtronMultiplier()); diff --git a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java index d9b79b61f..90fe99507 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/move/TARDISMonsterRunnable.java @@ -52,16 +52,19 @@ public TARDISMonsterRunnable(TARDIS plugin) { monsters.add(EntityType.CREEPER); monsters.add(EntityType.ENDERMAN); monsters.add(EntityType.ENDERMITE); + monsters.add(EntityType.HOGLIN); monsters.add(EntityType.HUSK); monsters.add(EntityType.PIGLIN); monsters.add(EntityType.PILLAGER); monsters.add(EntityType.SILVERFISH); + monsters.add(EntityType.SLIME); monsters.add(EntityType.SKELETON); monsters.add(EntityType.SPIDER); monsters.add(EntityType.STRAY); monsters.add(EntityType.VEX); monsters.add(EntityType.VINDICATOR); monsters.add(EntityType.WITCH); + monsters.add(EntityType.WITHER_SKELETON); monsters.add(EntityType.ZOGLIN); monsters.add(EntityType.ZOMBIE); monsters.add(EntityType.ZOMBIE_VILLAGER); diff --git a/todo.md b/todo.md index de643dc36..b999dc964 100644 --- a/todo.md +++ b/todo.md @@ -4,9 +4,8 @@ 1. Fix fifteenth console redstone piston door 2. Fix follower persistence -3. Update `monsters` count in database -4. Shift-clicking custom door shouldn't open it -5. ? +3. Shift-clicking custom door shouldn't open it +4. ? ## Next version `5.7.0` From 1ba81526029c1dbaab739dc973e4a3336794596d Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Tue, 16 Apr 2024 11:10:52 +1200 Subject: [PATCH 28/96] Shift-clicking custom door shouldn't open it? --- .../TARDISDisplayBlockListener.java | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java index 347cf0d0c..c5f5acfa2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java @@ -224,6 +224,9 @@ public void onDisplayBlockInteract(PlayerInteractEvent event) { */ @EventHandler public void onInteractionClick(PlayerInteractAtEntityEvent event) { + if (event.getHand() == EquipmentSlot.OFF_HAND) { + return; + } if (event.getRightClicked() instanceof Interaction interaction) { if (interaction.getPersistentDataContainer().has(plugin.getStandUuidKey(), plugin.getPersistentDataTypeUUID())) { Player player = event.getPlayer(); @@ -312,10 +315,15 @@ public void onInteractionClick(PlayerInteractAtEntityEvent event) { if (player.isSneaking()) { if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.CUSTOM_DOOR) { // move to outside + // if custom door only move if door is currently closed + if (tdi == TARDISDisplayItem.CUSTOM_DOOR && !isCustomClosed(interaction)) { + return; + } new DisplayItemDoorMover(plugin).exit(player, block); } - if (tdi == TARDISDisplayItem.DOOR_OPEN || tdi == TARDISDisplayItem.CUSTOM_DOOR) { + if (tdi == TARDISDisplayItem.DOOR_OPEN || (tdi == TARDISDisplayItem.CUSTOM_DOOR && !isCustomClosed(interaction))) { // open right hand door as well + // open right hand / extra state door for custom doors only door is already open ItemStack itemStack = display.getItemStack(); if (itemStack != null) { ItemMeta im = itemStack.getItemMeta(); @@ -372,12 +380,6 @@ public void onInteractionClick(PlayerInteractAtEntityEvent event) { } new DisplayItemDoorToggler(plugin).openClose(player, block, close, TARDISDisplayItem.CUSTOM_DOOR); } - default -> { - // just close doors - im.setCustomModelData(10000); - itemStack.setItemMeta(im); - display.setItemStack(itemStack); - } } } } @@ -439,6 +441,20 @@ public void onInteractionClick(PlayerInteractAtEntityEvent event) { } } + private boolean isCustomClosed(Interaction interaction) { + ItemDisplay display = TARDISDisplayItemUtils.get(interaction); + if (display == null) { + return false; + } + ItemStack is = display.getItemStack(); + if (is == null) { + return false; + } + ItemMeta im = is.getItemMeta(); + int cmd = im.hasCustomModelData()? im.getCustomModelData() : -1; + return cmd == 10000; + } + private boolean isPlaceable(Material material) { return material.isSolid() && !Tag.DOORS.isTagged(material) && !material.hasGravity() && !Tag.PRESSURE_PLATES.isTagged(material); } From cf4d3e9b5beff967e99da929d64b9ce3e6296207 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Tue, 16 Apr 2024 11:48:21 +1200 Subject: [PATCH 29/96] Or this --- .../customblocks/TARDISDisplayBlockListener.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java index c5f5acfa2..1dac40fb5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java @@ -313,17 +313,13 @@ public void onInteractionClick(PlayerInteractAtEntityEvent event) { return; } if (player.isSneaking()) { - if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.CUSTOM_DOOR) { + if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || (tdi == TARDISDisplayItem.CUSTOM_DOOR && isCustomClosed(display))) { // move to outside - // if custom door only move if door is currently closed - if (tdi == TARDISDisplayItem.CUSTOM_DOOR && !isCustomClosed(interaction)) { - return; - } new DisplayItemDoorMover(plugin).exit(player, block); + return; } - if (tdi == TARDISDisplayItem.DOOR_OPEN || (tdi == TARDISDisplayItem.CUSTOM_DOOR && !isCustomClosed(interaction))) { + if (tdi == TARDISDisplayItem.DOOR_OPEN || (tdi == TARDISDisplayItem.CUSTOM_DOOR && !isCustomClosed(display))) { // open right hand door as well - // open right hand / extra state door for custom doors only door is already open ItemStack itemStack = display.getItemStack(); if (itemStack != null) { ItemMeta im = itemStack.getItemMeta(); @@ -441,8 +437,7 @@ public void onInteractionClick(PlayerInteractAtEntityEvent event) { } } - private boolean isCustomClosed(Interaction interaction) { - ItemDisplay display = TARDISDisplayItemUtils.get(interaction); + private boolean isCustomClosed(ItemDisplay display) { if (display == null) { return false; } From 5f5e1d2d966bca75fc7df59ba96eba50864c53ef Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Tue, 16 Apr 2024 21:41:33 +1200 Subject: [PATCH 30/96] Flight mode interaction --- .../preferences/TARDISPrefsTabComplete.java | 2 +- .../preferences/TARDISSetFlightCommand.java | 6 +++-- .../console/ConsoleInteractionListener.java | 2 +- .../interaction/FlightModeInteraction.java | 27 +++++++++++-------- .../interaction/ThrottleInteraction.java | 3 ++- .../console/models/FlightModeModel.java | 3 --- .../TARDIS/control/TARDISControlListener.java | 2 +- .../control/actions/DifferentiatorAction.java | 12 ++++++++- .../control/actions/FlightModeAction.java | 2 +- .../TARDIS/sonic/TARDISSonicDock.java | 6 ++--- .../TARDIS/utility/Handbrake.java | 2 ++ 11 files changed, 42 insertions(+), 25 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsTabComplete.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsTabComplete.java index 7956531ee..f357d5341 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsTabComplete.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsTabComplete.java @@ -40,7 +40,7 @@ public class TARDISPrefsTabComplete extends TARDISCompleter implements TabComple private final ImmutableList ONOFF_SUBS = ImmutableList.of("on", "off"); private final ImmutableList HADS_SUBS = ImmutableList.of("DISPLACEMENT", "DISPERSAL"); private final ImmutableList HUM_SUBS = ImmutableList.of("alien", "atmosphere", "computer", "copper", "coral", "galaxy", "learning", "mind", "neon", "sleeping", "void", "random"); - private final ImmutableList FLIGHT_SUBS = ImmutableList.of("normal", "regulator", "manual"); + private final ImmutableList FLIGHT_SUBS = ImmutableList.of("normal", "regulator", "manual", "exterior"); private final ImmutableList KEY_SUBS; private final List LIGHT_SUBS = new ArrayList<>(); private final ImmutableList MAT_SUBS; diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISSetFlightCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISSetFlightCommand.java index 780b5807e..c57ac09ba 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISSetFlightCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISSetFlightCommand.java @@ -16,13 +16,14 @@ */ package me.eccentric_nz.TARDIS.commands.preferences; -import java.util.HashMap; -import java.util.Locale; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.enumeration.FlightMode; import me.eccentric_nz.TARDIS.enumeration.TardisModule; import org.bukkit.entity.Player; +import java.util.HashMap; +import java.util.Locale; + /** * @author eccentric_nz */ @@ -50,6 +51,7 @@ boolean setMode(Player player, String[] args) { switch (fm) { case REGULATOR -> mode = 2; case MANUAL -> mode = 3; + case EXTERIOR -> mode = 4; default -> { } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index 8cf9317c2..6de2130de 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -35,7 +35,7 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { case HANDBRAKE -> new HandbrakeInteraction(plugin).process(id, state, player, interaction); case THROTTLE -> new ThrottleInteraction(plugin).process(player, interaction, id); - case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(player, interaction); + case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(player, id, interaction); // section one case WORLD -> new WorldInteraction(plugin).selectWorld(state, player, id); case MULTIPLIER, X, Z -> new MultiplierXZInteraction(plugin).setRange(ci, state, id, player); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java index 77d0b3b68..614a2444e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java @@ -20,7 +20,7 @@ public FlightModeInteraction(TARDIS plugin) { this.plugin = plugin; } - public void process(Player player, Interaction interaction) { + public void process(Player player, int id, Interaction interaction) { String uuid = player.getUniqueId().toString(); // get current throttle setting ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, uuid); @@ -29,23 +29,28 @@ public void process(Player player, Interaction interaction) { if (mode > 4) { mode = 1; } - FlightMode fm = FlightMode.getByMode().get(mode); - plugin.getMessenger().announceRepeater(player, TARDISStringUtils.capitalise(fm.toString())); - HashMap setf = new HashMap<>(); - setf.put("flying_mode", mode); + FlightMode flightMode = FlightMode.getByMode().get(mode); + plugin.getMessenger().announceRepeater(player, TARDISStringUtils.capitalise(flightMode.toString())); + // update control record + HashMap set = new HashMap<>(); + set.put("secondary", mode == 4 ? 1 : 0); HashMap where = new HashMap<>(); - where.put("uuid", player.getUniqueId().toString()); - TARDIS.plugin.getQueryFactory().doUpdate("player_prefs", setf, where); + where.put("tardis_id", id); + where.put("type", 47); + plugin.getQueryFactory().doUpdate("controls", set, where); + // also update player prefs + HashMap setp = new HashMap<>(); + setp.put("flying_mode", mode); + HashMap wherep = new HashMap<>(); + wherep.put("uuid", player.getUniqueId().toString()); + plugin.getQueryFactory().doUpdate("player_prefs", setp, wherep); // set custom model data for relativity differentiator item display UUID model = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); if (model != null) { ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(model); new FlightModeModel().setState(display, mode); } - // TODO make relativity differentiator standalone control set player_prefs flightmode when toggled - exterior|normal - // TODO then alter `isRelativityDifferentiated()` to check player prefs instead - // should !exterior|normal flight modes even be accessible from this interaction? if so: - // TODO make malfunction / manual / regulator classes? + // TODO make malfunction / manual classes } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java index fce1c9498..8921ec41f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java @@ -5,6 +5,7 @@ import me.eccentric_nz.TARDIS.database.InteractionStateSaver; import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; import me.eccentric_nz.TARDIS.enumeration.SpaceTimeThrottle; +import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; import org.bukkit.entity.Interaction; import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; @@ -45,7 +46,7 @@ public void process(Player player, Interaction interaction, int id) { } // save unary value in the interaction PDC interaction.getPersistentDataContainer().set(plugin.getUnaryKey(), PersistentDataType.INTEGER, unary); - String throttle = SpaceTimeThrottle.getByDelay().get(delay).toString(); + String throttle = TARDISStringUtils.capitalise(SpaceTimeThrottle.getByDelay().get(delay).toString()); // update player prefs HashMap wherer = new HashMap<>(); wherer.put("uuid", uuid); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/FlightModeModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/FlightModeModel.java index 71a310d29..5ee2100b3 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/models/FlightModeModel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/FlightModeModel.java @@ -10,9 +10,6 @@ public void setState(ItemDisplay display, int state) { if (display == null) { return; } - if (state < 4) { - state = 1; - } ItemStack is = display.getItemStack(); ItemMeta im = is.getItemMeta(); im.setCustomModelData(state + 6000); diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlListener.java b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlListener.java index 0cb3f75f3..34da67d0f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlListener.java @@ -219,7 +219,7 @@ public void onControlInteract(PlayerInteractEvent event) { // space/time throttle case 39 -> new ThrottleAction(plugin).setSpaceTime(block, player); // relativity differentiator - case 47 -> new DifferentiatorAction(plugin).bleep(block); + case 47 -> new DifferentiatorAction(plugin).bleep(block, id); default -> { } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/DifferentiatorAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/DifferentiatorAction.java index d6c0225bb..15803ccf3 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/actions/DifferentiatorAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/DifferentiatorAction.java @@ -21,6 +21,8 @@ import org.bukkit.block.Block; import org.bukkit.block.data.type.Comparator; +import java.util.HashMap; + /** * The relativity differentiator is a component inside the TARDIS that allows it to travel in space. * @@ -33,9 +35,17 @@ public DifferentiatorAction(TARDIS plugin) { this.plugin = plugin; } - public void bleep(Block block) { + public void bleep(Block block, int id) { Comparator comparator = (Comparator) block.getBlockData(); String sound = comparator.getMode().equals(Comparator.Mode.SUBTRACT) ? "differentiator_off" : "differentiator_on"; TARDISSounds.playTARDISSound(block.getLocation(), sound); + // save control state + int mode = comparator.getMode().equals(Comparator.Mode.SUBTRACT) ? 0 : 1; + HashMap set = new HashMap<>(); + set.put("secondary", mode); + HashMap where = new HashMap<>(); + where.put("tardis_id", id); + where.put("type", 47); + plugin.getQueryFactory().doUpdate("controls", set, where); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/FlightModeAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/FlightModeAction.java index be452f309..ff99361e6 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/actions/FlightModeAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/FlightModeAction.java @@ -21,7 +21,7 @@ public void setMode(String uuid, Player player) { ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, uuid); if (rsp.resultSet()) { int mode = rsp.getFlightMode() + 1; - if (mode > 3) { + if (mode > 4) { mode = 1; } // set flight mode diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java index 3a40855b6..2335c9e2c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java @@ -153,9 +153,9 @@ private ItemDisplay doDocking(ItemStack sonic, Location location, Vector vector, plugin.getMessenger().send(player, TardisModule.TARDIS, "NO_MAT_CIRCUIT"); return display; } - COMPASS player_d = COMPASS.valueOf(TARDISStaticUtils.getPlayersDirection(player, false)); - int[] start_loc = TARDISTimeTravel.getStartLocation(dest, player_d); - int count = TARDISTimeTravel.safeLocation(start_loc[0], dest.getBlockY(), start_loc[2], start_loc[1], start_loc[3], dest.getWorld(), player_d); + COMPASS player_direction = COMPASS.valueOf(TARDISStaticUtils.getPlayersDirection(player, false)); + int[] start_loc = TARDISTimeTravel.getStartLocation(dest, player_direction); + int count = TARDISTimeTravel.safeLocation(start_loc[0], dest.getBlockY(), start_loc[2], start_loc[1], start_loc[3], dest.getWorld(), player_direction); Block under = dest.getBlock().getRelative(BlockFace.DOWN); if (plugin.getPM().isPluginEnabled("BlockLocker") && (BlockLockerAPIv2.isProtected(dest.getBlock()) || BlockLockerAPIv2.isProtected(under))) { count = 1; diff --git a/src/main/java/me/eccentric_nz/TARDIS/utility/Handbrake.java b/src/main/java/me/eccentric_nz/TARDIS/utility/Handbrake.java index 683442d1e..dfd535d3e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/utility/Handbrake.java +++ b/src/main/java/me/eccentric_nz/TARDIS/utility/Handbrake.java @@ -36,6 +36,8 @@ public boolean isRelativityDifferentiated(int id) { if (rd.getType() == Material.COMPARATOR) { Comparator comparator = (Comparator) rd.getBlockData(); return comparator.getMode().equals(Comparator.Mode.SUBTRACT); + } else { + return rsc.getSecondary() == 1; } } return false; From e7db93cdf6be5cb43bb1c94655c943cc4636bb25 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Wed, 17 Apr 2024 07:35:40 +1200 Subject: [PATCH 31/96] Update todo.md --- todo.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/todo.md b/todo.md index b999dc964..90d88fd5b 100644 --- a/todo.md +++ b/todo.md @@ -4,8 +4,7 @@ 1. Fix fifteenth console redstone piston door 2. Fix follower persistence -3. Shift-clicking custom door shouldn't open it -4. ? +3. ? ## Next version `5.7.0` From c28e52aa8666c179a20c3ca7afc82febf2ef4734 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Wed, 17 Apr 2024 12:47:28 +1200 Subject: [PATCH 32/96] Update TARDISSonicDock.java --- .../me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java index 2335c9e2c..965e7c009 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java @@ -51,6 +51,7 @@ public void dock(int id, Interaction interaction, Player player, ItemStack sonic } ItemDisplay display = doDocking(sonic, interaction.getLocation(), new Vector(0.05d, 0.75d, -0.05d), player, id); display.setRotation(0.0f, -15.0f); + // start charging if (plugin.getConfig().getBoolean("sonic.charge") || plugin.getDifficulty() == Difficulty.HARD) { long delay = plugin.getConfig().getLong("sonic.charge_level") / plugin.getConfig().getLong("sonic.charge_interval"); SonicConsoleRecharge recharge = new SonicConsoleRecharge(plugin, display.getUniqueId(), interaction, id, player); @@ -90,8 +91,6 @@ private ItemDisplay doDocking(ItemStack sonic, Location location, Vector vector, display.setInvulnerable(true); // remove item from hand player.getInventory().setItemInMainHand(null); -// // change the dock model -// updateModel(frame, 1001, false); if (uuid != null) { // get last scan coordinates ResultSetSonicLocation rssc = new ResultSetSonicLocation(plugin, uuid); @@ -238,13 +237,6 @@ private ItemDisplay doDocking(ItemStack sonic, Location location, Vector vector, } else { plugin.getMessenger().send(player, TardisModule.TARDIS, "DOCK_NOT_SCANNED"); } -// // start charging -// if (plugin.getConfig().getBoolean("sonic.charge") || plugin.getDifficulty() == Difficulty.HARD) { -// long delay = plugin.getConfig().getLong("sonic.charge_level") / plugin.getConfig().getLong("sonic.charge_interval"); -// SonicRecharge recharge = new SonicRecharge(plugin, display.getUniqueId(), frame, id, player); -// int task = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, recharge, 1L, delay); -// recharge.setTask(task); -// } return display; } From 6b1b0381bdf7f058e74caef3c904e88e5aeb1b62 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Wed, 17 Apr 2024 14:57:08 +1200 Subject: [PATCH 33/96] Fix light level interactions --- .../java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java | 5 +++-- .../eccentric_nz/TARDIS/console/models/LightLevelModel.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index 1e69f0838..7821df765 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -116,8 +116,9 @@ private UUID spawnControl(ConsoleInteraction interaction, Location location, flo cmd = (rsc.resultSet()) ? getCmd(rsc.getDirection()) + 10000 : 10000; } case RELATIVITY_DIFFERENTIATOR -> cmd = 6001; - case INTERIOR_LIGHT_LEVEL_SWITCH -> cmd = 7000; - default -> cmd = 8000; + case INTERIOR_LIGHT_LEVEL_SWITCH -> cmd = 8000; + // EXTERIOR_LAMP_LEVEL_SWITCH + default -> cmd = 7000; } // spawn a control ItemStack is = new ItemStack(material); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/LightLevelModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/LightLevelModel.java index d97713a76..12937608a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/models/LightLevelModel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/LightLevelModel.java @@ -12,7 +12,7 @@ public void setState(ItemDisplay display, int state, boolean interior) { } ItemStack is = display.getItemStack(); ItemMeta im = is.getItemMeta(); - int base = (interior) ? 7000 : 8000; + int base = (interior) ? 8000 : 7000; im.setCustomModelData(state + base); is.setItemMeta(im); display.setItemStack(is); From a1e7d0c7bac71a8ebe09675254fc3895062b92a3 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Wed, 17 Apr 2024 15:55:21 +1200 Subject: [PATCH 34/96] Update maven plugins --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 489c04e2a..4d551b6f6 100644 --- a/pom.xml +++ b/pom.xml @@ -144,7 +144,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.13.0 17 17 @@ -192,7 +192,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.3.1-SNAPSHOT + 3.4.0 @@ -207,7 +207,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.5.1 + 3.5.2 Date: Mon, 22 Apr 2024 10:22:52 +1200 Subject: [PATCH 35/96] Make sure a valid shell is selected before trying to use it --- .../TARDIS/builders/TARDISMaterialisePreset.java | 1 + .../TARDIS/chameleon/shell/TARDISPlayerShellListener.java | 8 ++++++-- .../TARDIS/destroyers/TARDISDematerialisePreset.java | 1 + src/main/resources/ru.yml | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISMaterialisePreset.java b/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISMaterialisePreset.java index ca88bcf0f..b68c94939 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISMaterialisePreset.java +++ b/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISMaterialisePreset.java @@ -131,6 +131,7 @@ public void run() { plugin.getTrackerKeeper().getDematerialising().removeAll(Collections.singleton(bd.getTardisID())); plugin.getTrackerKeeper().getInVortex().removeAll(Collections.singleton(bd.getTardisID())); plugin.getTrackerKeeper().getDestinationVortex().remove(bd.getTardisID()); + return; } BlockData[][] datas; // get relative locations diff --git a/src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISPlayerShellListener.java b/src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISPlayerShellListener.java index 7fe94d5e1..b6680e534 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISPlayerShellListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISPlayerShellListener.java @@ -161,6 +161,11 @@ public void onShellLoaderClick(InventoryClickEvent event) { case 45 -> { // set as the active shell if (selected.containsKey(uuid)) { + int cid = getChameleonId(view, selected.get(uuid)); + if (cid == -1) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "SHELL_SELECT"); + return; + } // set other shells as inactive HashMap seti = new HashMap<>(); seti.put("active", 0); @@ -168,7 +173,6 @@ public void onShellLoaderClick(InventoryClickEvent event) { wherei.put("tardis_id", id); plugin.getQueryFactory().doSyncUpdate("chameleon", seti, wherei); // set selected as active - int cid = getChameleonId(view, selected.get(uuid)); HashMap wheresc = new HashMap<>(); wheresc.put("chameleon_id", cid); HashMap seta = new HashMap<>(); @@ -183,12 +187,12 @@ public void onShellLoaderClick(InventoryClickEvent event) { } } default -> { - selected.put(uuid, slot); // get the chameleon_id int cid = getChameleonId(view, slot); if (cid == -1) { return; } + selected.put(uuid, slot); // load selected shell preset = ChameleonPreset.CONSTRUCT; // load saved construct diff --git a/src/main/java/me/eccentric_nz/TARDIS/destroyers/TARDISDematerialisePreset.java b/src/main/java/me/eccentric_nz/TARDIS/destroyers/TARDISDematerialisePreset.java index 4fe74e705..7a605435b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/destroyers/TARDISDematerialisePreset.java +++ b/src/main/java/me/eccentric_nz/TARDIS/destroyers/TARDISDematerialisePreset.java @@ -98,6 +98,7 @@ public void run() { // remove trackers plugin.getTrackerKeeper().getDematerialising().removeAll(Collections.singleton(dd.getTardisID())); plugin.getTrackerKeeper().getInVortex().removeAll(Collections.singleton(dd.getTardisID())); + return; } BlockData[][] data; // get relative locations diff --git a/src/main/resources/ru.yml b/src/main/resources/ru.yml index 561bb91d7..be812b3ca 100644 --- a/src/main/resources/ru.yml +++ b/src/main/resources/ru.yml @@ -559,7 +559,7 @@ ID_NOT_FOUND: "Не удалось получить идентификатор T INPUT_MISSING: "В консоли отсутствует входная цепь!" ВНУТРИ: "В твоей TARDIS никого нет." INSIDE_PLAYERS: "Игроки внутри вашей TARDIS:" -INVALID_CONSTRUCT: "Обнаружен недействительный Chameleon CONSTRUCT, измените предустановку Chamelon!" +INVALID_CONSTRUCT: "Обнаружена неверная конструкция Chameleon CONSTRUCT. Используйте %s, а затем измените предустановку Chamelon!" INVISIBILITY_DISABLED: "Невидимая посадка отключена на этом сервере!" INVISIBILITY_ENGAGED: "Вы не можете этого сделать, пока включена цепь невидимости!" INVISIBILITY_LORE_1: "Нажатие этой кнопки повредит цепь." From 86d3de72f7bed810941996e747990d80f1e4647c Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 22 Apr 2024 10:33:20 +1200 Subject: [PATCH 36/96] Delay setting construct as active, so the builder selects the correct record --- .../shell/TARDISPlayerShellListener.java | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISPlayerShellListener.java b/src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISPlayerShellListener.java index b6680e534..8dd537485 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISPlayerShellListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISPlayerShellListener.java @@ -166,20 +166,26 @@ public void onShellLoaderClick(InventoryClickEvent event) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SHELL_SELECT"); return; } - // set other shells as inactive - HashMap seti = new HashMap<>(); - seti.put("active", 0); - HashMap wherei = new HashMap<>(); - wherei.put("tardis_id", id); - plugin.getQueryFactory().doSyncUpdate("chameleon", seti, wherei); - // set selected as active - HashMap wheresc = new HashMap<>(); - wheresc.put("chameleon_id", cid); - HashMap seta = new HashMap<>(); - seta.put("active", 1); - plugin.getQueryFactory().doUpdate("chameleon", seta, wheresc); - // set chameleon circuit to selected shell - new ConstructBuilder(plugin).build(rs.getTardis().getPreset().toString(), id, player); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { + // set other shells as inactive + HashMap seti = new HashMap<>(); + seti.put("active", 0); + HashMap wherei = new HashMap<>(); + wherei.put("tardis_id", id); + plugin.getQueryFactory().doSyncUpdate("chameleon", seti, wherei); + }, 1L); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { + // set selected as active + HashMap wheresc = new HashMap<>(); + wheresc.put("chameleon_id", cid); + HashMap seta = new HashMap<>(); + seta.put("active", 1); + plugin.getQueryFactory().doSyncUpdate("chameleon", seta, wheresc); + }, 5L); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { + // set chameleon circuit to selected shell + new ConstructBuilder(plugin).build(rs.getTardis().getPreset().toString(), id, player); + }, 10L); // close close(player); } else { From f8c729e2386f785d00b89fd06d116af2cabb1295 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Tue, 23 Apr 2024 15:06:10 +1200 Subject: [PATCH 37/96] All the rest of the interactions --- .../shell/TARDISPlayerShellListener.java | 14 ++-- .../TARDIS/console/ConsoleInteraction.java | 77 +++++++++---------- .../console/ConsoleInteractionListener.java | 23 +++--- .../interaction/ArtronInteraction.java | 28 +++++++ .../interaction/DoorToggleInteraction.java | 13 +++- .../interaction/FastReturnInteraction.java | 12 ++- .../interaction/LightSwitchInteraction.java | 12 ++- .../interaction/MultiplierXZInteraction.java | 18 ++++- .../interaction/RandomiserInteraction.java | 13 +++- .../interaction/RebuildInteraction.java | 13 +++- .../interaction/ScannerInteraction.java | 36 +++++++++ .../interaction/ScannerIntraction.java | 26 ------- .../interaction/ScreenInteraction.java | 44 +++++++++-- .../interaction/SonicDockInteraction.java | 12 +++ .../interaction/WayPointInteraction.java | 13 +++- .../console/interaction/WorldInteraction.java | 13 +++- .../TARDIS/console/models/ButtonModel.java | 29 +++++++ .../TARDIS/console/models/SonicDockModel.java | 22 ++++++ .../TARDIS/console/models/WXYZModel.java | 34 ++++++++ .../telepathic/TelepathicGUIListener.java | 3 + 20 files changed, 353 insertions(+), 102 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerInteraction.java delete mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerIntraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/models/ButtonModel.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/models/SonicDockModel.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/models/WXYZModel.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISPlayerShellListener.java b/src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISPlayerShellListener.java index 8dd537485..b58e72f01 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISPlayerShellListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISPlayerShellListener.java @@ -166,14 +166,12 @@ public void onShellLoaderClick(InventoryClickEvent event) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SHELL_SELECT"); return; } - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { - // set other shells as inactive - HashMap seti = new HashMap<>(); - seti.put("active", 0); - HashMap wherei = new HashMap<>(); - wherei.put("tardis_id", id); - plugin.getQueryFactory().doSyncUpdate("chameleon", seti, wherei); - }, 1L); + // set other shells as inactive + HashMap seti = new HashMap<>(); + seti.put("active", 0); + HashMap wherei = new HashMap<>(); + wherei.put("tardis_id", id); + plugin.getQueryFactory().doSyncUpdate("chameleon", seti, wherei); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { // set selected as active HashMap wheresc = new HashMap<>(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java index 1790b9cfd..47b921c0b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java @@ -1,70 +1,63 @@ package me.eccentric_nz.TARDIS.console; +import org.bukkit.Material; import org.bukkit.util.Vector; public enum ConsoleInteraction { // section zero - HANDBRAKE("Time Rotor Handbrake", new Vector(0.0d, 1d, 2.25d), 0.5f, 0.4f, 1, true, 0.0f), - THROTTLE("Flight Speed", new Vector(0.9d, 1.0d, 2.375d), 0.5f, 0.33f, 4, true, 0.0f), - RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.575d, 1.0d, 1.75d), 0.5f, 0.65f, 1, true, 0.0f), + HANDBRAKE("Time Rotor Handbrake", new Vector(0.0d, 1d, 2.25d), 0.5f, 0.4f, 1, 0.0f, Material.LEVER, 5002), + THROTTLE("Flight Speed", new Vector(0.9d, 1.0d, 2.375d), 0.5f, 0.33f, 4, 0.0f, Material.REPEATER, 1004), + RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.575d, 1.0d, 1.75d), 0.5f, 0.65f, 1, 0.0f, Material.LEVER, 6001), // section one - WORLD("Environment Selector", new Vector(-0.525d, 1.0d, 0.95d), 0.15f, 0.65f, 1), - MULTIPLIER("Coordinate Increment Modifier", new Vector(-0.4d, 1.0d, 1.2d), 0.15f, 0.65f, 1), - X("X Distance", new Vector(-0.75d, 1.0d, 1.1d), 0.15f, 0.4f, 1), - Z("Z Distance", new Vector(-0.6d, 1.0d, 1.3d), 0.15f, 0.4f, 1), - HELMIC_REGULATOR("Dimension Selector", new Vector(-0.85d, 1d, 1.8d), 0.5f, 0.6f, 0, true, 60.0f), + WORLD("Environment Selector", new Vector(-0.525d, 1.0d, 0.95d), 0.15f, 0.65f, 1, 60.0f, Material.BAMBOO_BUTTON, 1009), + MULTIPLIER("Coordinate Increment Modifier", new Vector(-0.4d, 1.0d, 1.2d), 0.15f, 0.65f, 1, 60.0f, Material.BAMBOO_BUTTON, 1009), + X("X Distance", new Vector(-0.75d, 1.0d, 1.1d), 0.15f, 0.4f, 1, 60.0f, Material.BAMBOO_BUTTON, 1009), + Z("Z Distance", new Vector(-0.6d, 1.0d, 1.3d), 0.15f, 0.4f, 1, 60.0f, Material.BAMBOO_BUTTON, 1009), + HELMIC_REGULATOR("Dimension Selector", new Vector(-0.85d, 1d, 1.8d), 0.5f, 0.6f, 0, 60.0f, Material.REPEATER, 2000), // section two - RANDOMISER("Random Location Finder", new Vector(-0.85d, 1d, -0.8125d), 0.25f, 0.33f, 0), - WAYPOINT_SELECTOR("Saves", new Vector(-1.1d, 1d, -0.4d), 0.25f, 0.33f, 0), - FAST_RETURN("Back Button", new Vector(-1.35d, 1d, 0d), 0.25f, 0.33f, 0), - TELEPATHIC_CIRCUIT("Telepathic Circuit", new Vector(-0.55d, 1d, -0.15d), 0.5f, 0.65f, 0), + RANDOMISER("Random Location Finder", new Vector(-0.85d, 1d, -0.8125d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1001), + WAYPOINT_SELECTOR("Saves", new Vector(-1.1d, 1d, -0.4d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1002), + FAST_RETURN("Back Button", new Vector(-1.35d, 1d, 0d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1003), + TELEPATHIC_CIRCUIT("Telepathic Circuit", new Vector(-0.55d, 1d, -0.15d), 0.5f, 0.65f, 0, 120.0f, Material.DAYLIGHT_DETECTOR, 1000), // section three - SONIC_DOCK("Sonic Screwdriver Dock", new Vector(0.45d, 1d, -0.65d), 0.5f, 0.65f, 0), - DIRECTION("Exterior Directional Control", new Vector(0.125d, 1d, -1.2d), 0.625f, 0.5f, 0, true, 180.0f), + SONIC_DOCK("Sonic Screwdriver Dock", new Vector(0.45d, 1d, -0.65d), 0.5f, 0.65f, 0, 180.0f, Material.FLOWER_POT, 2000), + DIRECTION("Exterior Directional Control", new Vector(0.125d, 1d, -1.2d), 0.625f, 0.5f, 0, 180.0f, Material.RAIL, 10000), // section four - LIGHT_SWITCH("Interior Light Switch", new Vector(2.475d, 1d, 0.1d), 0.25f, 0.33f, 0), - INTERIOR_LIGHT_LEVEL_SWITCH("Interior Light Level", new Vector(1.8d, 1d, 0.0d), 0.25f, 0.5f, 0, true, 240.0f), - EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Lamp Level", new Vector(1.5d, 1d, -0.3d), 0.25f, 0.5f, 0, true, 240.0f), - DOOR_TOGGLE("Toggle Wool Switch", new Vector(1.825d, 1d, -1.0d), 0.25f, 0.33f, 0), + LIGHT_SWITCH("Interior Light Switch", new Vector(2.475d, 1d, 0.1d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1004), + INTERIOR_LIGHT_LEVEL_SWITCH("Interior Light Level", new Vector(1.8d, 1d, 0.0d), 0.25f, 0.5f, 0, 240.0f, Material.LEVER, 8000), + EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Lamp Level", new Vector(1.5d, 1d, -0.3d), 0.25f, 0.5f, 0, 240.0f, Material.LEVER, 7000), + DOOR_TOGGLE("Toggle Wool Switch", new Vector(1.825d, 1d, -1.0d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1005), // section five - SCREEN_RIGHT("Coordinates Display", new Vector(1.825d, 1d, 0.95d), 0.5f, 1.1f, 0), - SCREEN_LEFT("Information Display", new Vector(1.525d, 1d, 1.45d), 0.5f, 1.1f, 0), - SCANNER("Exterior Environment Scanner", new Vector(1.825d, 1d, 1.95d), 0.25f, 0.33f, 0), - ARTRON("Artron Energy Button", new Vector(2.125d, 1d, 1.475d), 0.25f, 0.33f, 0), - REBUILD("Chameleon Circuit Re-initialiser", new Vector(2.4d, 1d, 1.025d), 0.25f, 0.33f, 0); + SCREEN_RIGHT("Coordinates Display", new Vector(1.825d, 1d, 0.95d), 0.5f, 1.1f, 0, 300.0f, Material.MAP, 1000), + SCREEN_LEFT("Information Display", new Vector(1.525d, 1d, 1.45d), 0.5f, 1.1f, 0, 300.0f, Material.MAP, 1000), + SCANNER("Exterior Environment Scanner", new Vector(1.825d, 1d, 1.95d), 0.25f, 0.33f, 0, 300.0f, Material.BAMBOO_BUTTON, 1008), + ARTRON("Artron Energy Button", new Vector(2.125d, 1d, 1.475d), 0.25f, 0.33f, 0, 300.0f, Material.BAMBOO_BUTTON, 1006), + REBUILD("Chameleon Circuit Re-initialiser", new Vector(2.4d, 1d, 1.025d), 0.25f, 0.33f, 0, 300.0f, Material.BAMBOO_BUTTON, 1007); private final String alternateName; private final Vector relativePosition; private final float width; private final float height; private final int defaultState; - private final boolean model; private final float yaw; + private final Material material; + private final int customModelData; - ConsoleInteraction(String alternateName, Vector relativePosition, float width, float height, int defaultState, boolean model, float yaw) { + ConsoleInteraction(String alternateName, Vector relativePosition, float width, float height, int defaultState, float yaw, Material material, int customModelData) { this.alternateName = alternateName; this.relativePosition = relativePosition; this.width = width; this.height = height; this.defaultState = defaultState; - this.model = model; this.yaw = yaw; - } - - ConsoleInteraction(String alternateName, Vector relativePosition, float width, float height, int defaultState) { - this.alternateName = alternateName; - this.relativePosition = relativePosition; - this.width = width; - this.height = height; - this.defaultState = defaultState; - this.model = false; - this.yaw = 0.0f; + this.material = material; + this.customModelData = customModelData; } public String getAlternateName() { @@ -87,11 +80,15 @@ public int getDefaultState() { return defaultState; } - public boolean hasModel() { - return model; - } - public float getYaw() { return yaw; } + + public Material getMaterial() { + return material; + } + + public int getCustomModelData() { + return customModelData; + } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index 6de2130de..fa0274cf0 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -37,27 +37,28 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { case THROTTLE -> new ThrottleInteraction(plugin).process(player, interaction, id); case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(player, id, interaction); // section one - case WORLD -> new WorldInteraction(plugin).selectWorld(state, player, id); - case MULTIPLIER, X, Z -> new MultiplierXZInteraction(plugin).setRange(ci, state, id, player); + case WORLD -> new WorldInteraction(plugin).selectWorld(state, player, interaction, id); + case MULTIPLIER, X, Z -> new MultiplierXZInteraction(plugin).setRange(ci, state, interaction, id, player); case HELMIC_REGULATOR -> new HelmicRegulatorInteraction(plugin).selectWorld(state, id, player, interaction); // section two - case RANDOMISER -> new RandomiserInteraction(plugin).generateDestination(id, player); - case WAYPOINT_SELECTOR -> new WayPointInteraction(plugin).openSaveGUI(id, player); - case FAST_RETURN -> new FastReturnInteraction(plugin).setBack(id, player); + case RANDOMISER -> new RandomiserInteraction(plugin).generateDestination(id, player, interaction); + case WAYPOINT_SELECTOR -> new WayPointInteraction(plugin).openSaveGUI(id, player, interaction); + case FAST_RETURN -> new FastReturnInteraction(plugin).setBack(id, player, interaction); case TELEPATHIC_CIRCUIT -> new TelepathicCircuitInteraction(plugin).openGUI(player); // section three case SONIC_DOCK -> new SonicDockInteraction(plugin).process(player, interaction, id); case DIRECTION -> new DirectionInteraction(plugin).rotate(id, player, interaction); // section four - case LIGHT_SWITCH -> new LightSwitchInteraction(plugin).toggle(id, player); + case LIGHT_SWITCH -> new LightSwitchInteraction(plugin).toggle(id, player, interaction); case INTERIOR_LIGHT_LEVEL_SWITCH -> new LightLevelInteraction(plugin).setInterior(state, id, interaction, player); case EXTERIOR_LAMP_LEVEL_SWITCH -> new LampLevelInteraction(plugin).setExterior(state, id, interaction, player); - case DOOR_TOGGLE -> new DoorToggleInteraction(plugin).toggle(id, player); + case DOOR_TOGGLE -> new DoorToggleInteraction(plugin).toggle(id, player, interaction); // section five - case SCREEN_LEFT, SCREEN_RIGHT -> new ScreenInteraction(plugin).display(id, interaction.getLocation(), ci == ConsoleInteraction.SCREEN_RIGHT, player); - case SCANNER -> new ScannerIntraction(plugin).process(id, player); - case ARTRON -> plugin.getMessenger().sendArtron(player, id, 0); - case REBUILD -> new RebuildInteraction(plugin).process(id, player); + case SCREEN_LEFT, SCREEN_RIGHT -> new ScreenInteraction(plugin).display(id, interaction, ci == ConsoleInteraction.SCREEN_RIGHT, player); + case SCANNER -> new ScannerInteraction(plugin).process(id, player, interaction); + case ARTRON -> new ArtronInteraction(plugin).show(id, player, interaction); + case REBUILD -> new RebuildInteraction(plugin).process(id, player, interaction); + // unknown default -> plugin.getMessenger().announceRepeater(player, rsi.getControl().getAlternateName()); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronInteraction.java new file mode 100644 index 000000000..4b98ffef1 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronInteraction.java @@ -0,0 +1,28 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.models.ButtonModel; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; +import org.bukkit.entity.Player; + +import java.util.UUID; + +public class ArtronInteraction { + + private final TARDIS plugin; + + public ArtronInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void show(int id, Player player, Interaction interaction) { + // set custom model data for artron button item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + new ButtonModel().setState(display, plugin); + } + plugin.getMessenger().sendArtron(player, id, 0); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java index 7b2321cbf..c27d210b4 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java @@ -1,10 +1,15 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.models.ButtonModel; import me.eccentric_nz.TARDIS.enumeration.TardisModule; import me.eccentric_nz.TARDIS.move.TARDISBlackWoolToggler; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; +import java.util.UUID; + public class DoorToggleInteraction { private final TARDIS plugin; @@ -13,11 +18,17 @@ public DoorToggleInteraction(TARDIS plugin) { this.plugin = plugin; } - public void toggle(int id, Player player) { + public void toggle(int id, Player player, Interaction interaction) { if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; } + // set custom model data for toggle wool button item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + new ButtonModel().setState(display, plugin); + } new TARDISBlackWoolToggler(plugin).toggleBlocks(id, player); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java index 12f700d65..99b2b4cbb 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java @@ -2,14 +2,18 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.advanced.TARDISCircuitChecker; +import me.eccentric_nz.TARDIS.console.models.ButtonModel; import me.eccentric_nz.TARDIS.control.actions.FastReturnAction; import me.eccentric_nz.TARDIS.database.data.Tardis; import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; import me.eccentric_nz.TARDIS.enumeration.Difficulty; import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; import java.util.HashMap; +import java.util.UUID; public class FastReturnInteraction { @@ -19,7 +23,7 @@ public FastReturnInteraction(TARDIS plugin) { this.plugin = plugin; } - public void setBack(int id, Player player) { + public void setBack(int id, Player player, Interaction interaction) { if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; @@ -40,6 +44,12 @@ public void setBack(int id, Player player) { return; } Tardis tardis = rs.getTardis(); + // set custom model data for random button item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + new ButtonModel().setState(display, plugin); + } new FastReturnAction(plugin).clickButton(player, id, tardis); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java index 552c22f3f..4b397a159 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java @@ -1,13 +1,17 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.models.ButtonModel; import me.eccentric_nz.TARDIS.control.actions.LightSwitchAction; import me.eccentric_nz.TARDIS.database.data.Tardis; import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; import java.util.HashMap; +import java.util.UUID; public class LightSwitchInteraction { @@ -17,7 +21,7 @@ public LightSwitchInteraction(TARDIS plugin) { this.plugin = plugin; } - public void toggle(int id, Player player) { + public void toggle(int id, Player player, Interaction interaction) { if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; @@ -33,6 +37,12 @@ public void toggle(int id, Player player) { plugin.getMessenger().send(player, TardisModule.TARDIS, "POWER_DOWN"); return; } + // set custom model data for light switch item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + new ButtonModel().setState(display, plugin); + } new LightSwitchAction(plugin, id, tardis.isLightsOn(), player, tardis.getSchematic().getLights()).flickSwitch(); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierXZInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierXZInteraction.java index 2d2b898c6..996de2aad 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierXZInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierXZInteraction.java @@ -2,9 +2,14 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.console.ConsoleInteraction; +import me.eccentric_nz.TARDIS.console.models.WXYZModel; import me.eccentric_nz.TARDIS.database.InteractionStateSaver; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; +import java.util.UUID; + public class MultiplierXZInteraction { private final TARDIS plugin; @@ -13,11 +18,22 @@ public MultiplierXZInteraction(TARDIS plugin) { this.plugin = plugin; } - public void setRange(ConsoleInteraction ci, int state, int id, Player player) { + public void setRange(ConsoleInteraction ci, int state, Interaction interaction, int id, Player player) { int next = state + 1; if (next > 4) { next = 1; } + // set custom model data for lamp level switch item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + int which = switch (ci) { + case X -> 3; + case Z -> 4; + default -> 2; + }; + new WXYZModel().setState(display, plugin, which); + } new InteractionStateSaver(plugin).write(ci.toString(), next, id); plugin.getMessenger().announceRepeater(player, ci + ": " + next); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java index 2b42fa560..7c9b66d09 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java @@ -4,6 +4,7 @@ import me.eccentric_nz.TARDIS.advanced.TARDISCircuitChecker; import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; import me.eccentric_nz.TARDIS.builders.TARDISEmergencyRelocation; +import me.eccentric_nz.TARDIS.console.models.ButtonModel; import me.eccentric_nz.TARDIS.control.actions.ExileAction; import me.eccentric_nz.TARDIS.control.actions.RandomDestinationAction; import me.eccentric_nz.TARDIS.database.data.Tardis; @@ -16,9 +17,12 @@ import me.eccentric_nz.TARDIS.travel.TARDISTimeTravel; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; import java.util.HashMap; +import java.util.UUID; public class RandomiserInteraction { @@ -28,7 +32,7 @@ public RandomiserInteraction(TARDIS plugin) { this.plugin = plugin; } - public void generateDestination(int id, Player player) { + public void generateDestination(int id, Player player, Interaction interaction) { if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; @@ -62,11 +66,16 @@ public void generateDestination(int id, Player player) { new TARDISEmergencyRelocation(plugin).relocate(id, player); return; } + // set custom model data for random button item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + new ButtonModel().setState(display, plugin); + } COMPASS direction = rscl.getDirection(); if (TARDISPermission.hasPermission(player, "tardis.exile") && plugin.getConfig().getBoolean("travel.exile")) { new ExileAction(plugin).getExile(player, id, direction); } else { -// new TARDISRandomButton(plugin, player, id, tardis.getArtronLevel(), 0, tardis.getCompanions(), tardis.getUuid()).clickButton(); // get state from WORLD, MULTIPLIER, X, Z and HELMIC_REGULATOR interactions ResultSetRandomInteractions rsri = new ResultSetRandomInteractions(plugin, id); if (rsri.resultSet()) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RebuildInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RebuildInteraction.java index d6d343122..72d82f3d2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RebuildInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RebuildInteraction.java @@ -2,9 +2,14 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.commands.tardis.TARDISRebuildCommand; +import me.eccentric_nz.TARDIS.console.models.ButtonModel; import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; +import java.util.UUID; + public class RebuildInteraction { private final TARDIS plugin; @@ -13,11 +18,17 @@ public RebuildInteraction(TARDIS plugin) { this.plugin = plugin; } - public void process(int id, Player player) { + public void process(int id, Player player, Interaction interaction) { if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; } + // set custom model data for rebuild button item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + new ButtonModel().setState(display, plugin); + } new TARDISRebuildCommand(plugin).rebuildPreset(player); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerInteraction.java new file mode 100644 index 000000000..462ff48b8 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerInteraction.java @@ -0,0 +1,36 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.models.ButtonModel; +import me.eccentric_nz.TARDIS.control.TARDISScanner; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.UUID; + +public class ScannerInteraction { + + private final TARDIS plugin; + + public ScannerInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void process(int id, Player player, Interaction interaction) { + // set custom model data for scanner button item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + new ButtonModel().setState(display, plugin); + } + HashMap where = new HashMap<>(); + where.put("tardis_id", id); + ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); + if (rs.resultSet()) { + new TARDISScanner(plugin).scan(id, player, rs.getTardis().getRenderer(), rs.getTardis().getArtronLevel()); + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerIntraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerIntraction.java deleted file mode 100644 index cc2518d5f..000000000 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerIntraction.java +++ /dev/null @@ -1,26 +0,0 @@ -package me.eccentric_nz.TARDIS.console.interaction; - -import me.eccentric_nz.TARDIS.TARDIS; -import me.eccentric_nz.TARDIS.control.TARDISScanner; -import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; -import org.bukkit.entity.Player; - -import java.util.HashMap; - -public class ScannerIntraction { - - private final TARDIS plugin; - - public ScannerIntraction(TARDIS plugin) { - this.plugin = plugin; - } - - public void process(int id, Player player) { - HashMap where = new HashMap<>(); - where.put("tardis_id", id); - ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0); - if (rs.resultSet()) { - new TARDISScanner(plugin).scan(id, player, rs.getTardis().getRenderer(), rs.getTardis().getArtronLevel()); - } - } -} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java index ac783dd6b..d63daea56 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java @@ -2,12 +2,15 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.console.ControlMonitor; +import me.eccentric_nz.TARDIS.console.models.ColourType; +import me.eccentric_nz.TARDIS.console.models.ConcoleColourChanger; import me.eccentric_nz.TARDIS.control.actions.ControlMenuAction; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.entity.TextDisplay; +import org.bukkit.Tag; +import org.bukkit.entity.*; +import org.bukkit.inventory.ItemStack; +import org.bukkit.persistence.PersistentDataType; import org.bukkit.util.Vector; public class ScreenInteraction { @@ -18,18 +21,43 @@ public ScreenInteraction(TARDIS plugin) { this.plugin = plugin; } - public void display(int id, Location location, boolean coords, Player player) { + public void display(int id, Interaction interaction, boolean coords, Player player) { // if shift-click change display else open Control Menu GUI if (player.isSneaking()) { // get the text display - TextDisplay display = getTextDisplay(location, coords); + TextDisplay display = getTextDisplay(interaction.getLocation(), coords); if (display != null) { display.setRotation(Location.normalizeYaw(300), -10f); new ControlMonitor(plugin).update(id, display.getUniqueId(), coords); } } else { - // open control menu - new ControlMenuAction(plugin).openGUI(player, id); + ItemStack hand = player.getInventory().getItemInMainHand(); + if (Tag.CONCRETE_POWDER.isTagged(hand.getType())) { + int amount = hand.getAmount(); + if (amount < 6) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "CONSOLE_COLOUR_AMOUNT"); + return; + } + // get colour + int colour = ColourType.LOOKUP.getOrDefault(hand.getType(), 1); + // get the UUIDs + String uuids = interaction.getPersistentDataContainer().get(plugin.getUnaryKey(), PersistentDataType.STRING); + if (uuids != null) { + // change the colour of the console + if (new ConcoleColourChanger(plugin, interaction.getLocation(), uuids, colour).paint()) { + // take the concrete powder + if (amount < 7) { + player.getInventory().setItemInMainHand(null); + } else { + hand.setAmount(amount - 6); + player.getInventory().setItemInMainHand(hand); + } + } + } + } else { + // open control menu + new ControlMenuAction(plugin).openGUI(player, id); + } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicDockInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicDockInteraction.java index f7c3a9bf4..c8979ce6e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicDockInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicDockInteraction.java @@ -1,13 +1,17 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.models.SonicDockModel; import me.eccentric_nz.TARDIS.sonic.TARDISSonicDock; import org.bukkit.Material; import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import java.util.UUID; + public class SonicDockInteraction { private final TARDIS plugin; @@ -17,14 +21,22 @@ public SonicDockInteraction(TARDIS plugin) { } public void process(Player player, Interaction interaction, int id) { + boolean activate = false; ItemStack is = player.getInventory().getItemInMainHand(); if (is.getType().equals(Material.BLAZE_ROD) && is.hasItemMeta()) { ItemMeta im = player.getInventory().getItemInMainHand().getItemMeta(); if (im.getDisplayName().endsWith("Sonic Screwdriver")) { new TARDISSonicDock(plugin).dock(id, interaction, player, is); + activate = true; } } else if (is.getType() == Material.AIR) { new TARDISSonicDock(plugin).undock(interaction, player); } + // set custom model data for lamp level switch item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + new SonicDockModel().setState(display, activate); + } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java index dcfedb36b..d1d3a0b6d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java @@ -1,12 +1,17 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.models.ButtonModel; import me.eccentric_nz.TARDIS.travel.save.TARDISSavesPlanetInventory; import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import java.util.UUID; + public class WayPointInteraction { private final TARDIS plugin; @@ -15,7 +20,13 @@ public WayPointInteraction(TARDIS plugin) { this.plugin = plugin; } - public void openSaveGUI(int id, Player player) { + public void openSaveGUI(int id, Player player, Interaction interaction) { + // set custom model data for saves button item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + new ButtonModel().setState(display, plugin); + } TARDISSavesPlanetInventory tssi = new TARDISSavesPlanetInventory(plugin, id); ItemStack[] saves = tssi.getPlanets(); Inventory saved = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "TARDIS Dimension Map"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java index f56927353..715aaf601 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java @@ -2,9 +2,14 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.console.InteractionResponse; +import me.eccentric_nz.TARDIS.console.models.WXYZModel; import me.eccentric_nz.TARDIS.database.InteractionStateSaver; +import org.bukkit.entity.Interaction; +import org.bukkit.entity.ItemDisplay; import org.bukkit.entity.Player; +import java.util.UUID; + public class WorldInteraction { private final TARDIS plugin; @@ -13,7 +18,7 @@ public WorldInteraction(TARDIS plugin) { this.plugin = plugin; } - public void selectWorld(int state, Player player, int id) { + public void selectWorld(int state, Player player, Interaction interaction, int id) { /* THIS => 1, NORMAL => 2, @@ -24,6 +29,12 @@ public void selectWorld(int state, Player player, int id) { if (next > 4) { next = 1; } + // set custom model data for lamp level switch item display + UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + new WXYZModel().setState(display, plugin, 1); + } new InteractionStateSaver(plugin).write("WORLD", next, id); plugin.getMessenger().announceRepeater(player, InteractionResponse.environment.get(next)); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/ButtonModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/ButtonModel.java new file mode 100644 index 000000000..8b31db837 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/ButtonModel.java @@ -0,0 +1,29 @@ +package me.eccentric_nz.TARDIS.console.models; + +import me.eccentric_nz.TARDIS.TARDIS; +import org.bukkit.Sound; +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class ButtonModel { + + public void setState(ItemDisplay display, TARDIS plugin) { + if (display == null) { + return; + } + display.getWorld().playSound(display, Sound.BLOCK_BAMBOO_WOOD_BUTTON_CLICK_ON, 1, 1); + ItemStack is = display.getItemStack(); + ItemMeta im = is.getItemMeta(); + int cmd = im.getCustomModelData(); + im.setCustomModelData(cmd + 1000); + is.setItemMeta(im); + display.setItemStack(is); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { + display.getWorld().playSound(display, Sound.BLOCK_BAMBOO_WOOD_BUTTON_CLICK_OFF, 1, 1); + im.setCustomModelData(cmd); + is.setItemMeta(im); + display.setItemStack(is); + }, 10); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/SonicDockModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/SonicDockModel.java new file mode 100644 index 000000000..ffaf625f0 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/SonicDockModel.java @@ -0,0 +1,22 @@ +package me.eccentric_nz.TARDIS.console.models; + +import org.bukkit.Sound; +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class SonicDockModel { + + public void setState(ItemDisplay display, boolean activate) { + if (display == null) { + return; + } + display.getWorld().playSound(display, Sound.BLOCK_BAMBOO_WOOD_BUTTON_CLICK_ON, 1, 1); + ItemStack is = display.getItemStack(); + ItemMeta im = is.getItemMeta(); + int cmd = im.getCustomModelData(); + im.setCustomModelData(activate?2001:2000); + is.setItemMeta(im); + display.setItemStack(is); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/WXYZModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/WXYZModel.java new file mode 100644 index 000000000..dcb01ae49 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/WXYZModel.java @@ -0,0 +1,34 @@ +package me.eccentric_nz.TARDIS.console.models; + +import me.eccentric_nz.TARDIS.TARDIS; +import org.bukkit.Sound; +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class WXYZModel { + + /* + W => 1 + X => 3 + Y => 2 + Z => 4 + */ + public void setState(ItemDisplay display, TARDIS plugin, int which) { + if (display == null) { + return; + } + display.getWorld().playSound(display, Sound.BLOCK_BAMBOO_WOOD_BUTTON_CLICK_ON, 1, 1); + ItemStack is = display.getItemStack(); + ItemMeta im = is.getItemMeta(); + im.setCustomModelData(1009 + which); + is.setItemMeta(im); + display.setItemStack(is); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { + display.getWorld().playSound(display, Sound.BLOCK_BAMBOO_WOOD_BUTTON_CLICK_OFF, 1, 1); + im.setCustomModelData(1009); + is.setItemMeta(im); + display.setItemStack(is); + }, 10); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java index 89ca81f70..1f9d434c9 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicGUIListener.java @@ -70,6 +70,9 @@ public void onTelepathicMenuClick(InventoryClickEvent event) { // structure finder case 4 -> { if (choice != null) { + if (!plugin.getUtils().inTARDISWorld(player)) { + return; + } TARDISTelepathicStructure tts = new TARDISTelepathicStructure(plugin); ItemStack[] gui = tts.getButtons(); Inventory structure = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "Telepathic Structure Finder"); From 94663c036ceeb8049d8234b6c27f7179e847fbda Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Tue, 23 Apr 2024 15:06:33 +1200 Subject: [PATCH 38/96] Change the console colour with concrete powder in hand --- .../dev/TARDISDisplayItemCommand.java | 11 +++- .../TARDIS/console/ConsoleBuilder.java | 58 +++++++++---------- .../TARDIS/console/models/ColourType.java | 29 ++++++++++ .../console/models/ConcoleColourChanger.java | 52 +++++++++++++++++ src/main/resources/en.yml | 1 + todo.md | 16 +++-- 6 files changed, 128 insertions(+), 39 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/models/ColourType.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/models/ConcoleColourChanger.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java index 2fd1fdd6d..2d6887b23 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java @@ -233,10 +233,19 @@ public boolean display(Player player, String[] args) { return true; } case "console" -> { + if (args.length < 3) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "TOO_FEW_ARGS"); + return true; + } + int colour = TARDISNumberParsers.parseInt(args[2]); + if (colour < 1 || colour > 16) { + plugin.getMessenger().message(player, "Number must be between 1-16!"); + return true; + } // get TARDIS id ResultSetTardisID rs = new ResultSetTardisID(plugin); if (rs.fromUUID(player.getUniqueId().toString())) { - new ConsoleBuilder(plugin).create(block, 1, rs.getTardis_id()); + new ConsoleBuilder(plugin).create(block, colour, rs.getTardis_id()); } return true; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index 7821df765..56f0ccd2d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -26,16 +26,22 @@ public ConsoleBuilder(TARDIS plugin) { } public void create(Block block, int type, int id) { + StringBuilder builder = new StringBuilder(); + String prefix = ""; Block up = block.getRelative(BlockFace.UP); for (int i = 0; i < 6; i++) { ItemStack shard = new ItemStack(Material.AMETHYST_SHARD); ItemMeta im = shard.getItemMeta(); - im.setCustomModelData((1000 * type) + (i + 1)); + im.setCustomModelData(1000 + type); im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, i); shard.setItemMeta(im); ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(up.getLocation().add(0.5d, 0.5d, 0.5d), EntityType.ITEM_DISPLAY); display.setItemStack(shard); display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); + UUID uuid = display.getUniqueId(); + builder.append(prefix).append(uuid); + prefix = "~"; + display.getPersistentDataContainer().set(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID(), uuid); display.setPersistent(true); display.setInvulnerable(true); float yaw = i * 60.0f; @@ -46,12 +52,15 @@ public void create(Block block, int type, int id) { for (int i = 30; i < 360; i += 60) { ItemStack shard = new ItemStack(Material.AMETHYST_SHARD); ItemMeta im = shard.getItemMeta(); - im.setCustomModelData((1000 * type) + 7); + im.setCustomModelData(2000 + type); im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, i); shard.setItemMeta(im); ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(up.getLocation().add(0.5d, 0.5d, 0.5d), EntityType.ITEM_DISPLAY); display.setItemStack(shard); display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); + UUID uuid = display.getUniqueId(); + builder.append(prefix).append(uuid); + display.getPersistentDataContainer().set(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID(), uuid); display.setPersistent(true); display.setInvulnerable(true); float yaw = Location.normalizeYaw(i); @@ -60,11 +69,8 @@ public void create(Block block, int type, int id) { } // set interaction entities for console controls for (ConsoleInteraction i : ConsoleInteraction.values()) { - UUID uuid = null; - if (i.hasModel()) { - // spawn a display entity and save it's UUID to the interaction entity - uuid = spawnControl(i, block.getLocation(), i.getYaw(), id); - } + // spawn a display entity and save it's UUID to the interaction entity + UUID uuid = spawnControl(i, block.getLocation(), i.getYaw(), id); double x = i.getRelativePosition().getX(); double z = i.getRelativePosition().getZ(); Location location = block.getLocation().clone().add(x, 1, z); @@ -79,9 +85,10 @@ public void create(Block block, int type, int id) { int cid = (i == ConsoleInteraction.EXTERIOR_LAMP_LEVEL_SWITCH) ? 49 : 50; plugin.getQueryFactory().insertControl(id, cid, location.toString(), 0); } - if (uuid != null) { - interaction.getPersistentDataContainer().set(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID(), uuid); + if (i == ConsoleInteraction.SCREEN_RIGHT || i == ConsoleInteraction.SCREEN_LEFT) { + interaction.getPersistentDataContainer().set(plugin.getUnaryKey(), PersistentDataType.STRING, builder.toString()); } + interaction.getPersistentDataContainer().set(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID(), uuid); interaction.setInteractionWidth(i.getWidth()); interaction.setInteractionHeight(i.getHeight()); interaction.setPersistent(true); @@ -96,29 +103,16 @@ public void create(Block block, int type, int id) { } private UUID spawnControl(ConsoleInteraction interaction, Location location, float angle, int id) { - Material material = Material.LEVER; - int cmd; - switch (interaction) { - case HANDBRAKE -> cmd = 5002; - case THROTTLE -> { - material = Material.REPEATER; - cmd = 1004; - } - case HELMIC_REGULATOR -> { - material = Material.REPEATER; - cmd = 2000; - } - case DIRECTION -> { - material = Material.RAIL; - HashMap wherec = new HashMap<>(); - wherec.put("tardis_id", id); - ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherec); - cmd = (rsc.resultSet()) ? getCmd(rsc.getDirection()) + 10000 : 10000; - } - case RELATIVITY_DIFFERENTIATOR -> cmd = 6001; - case INTERIOR_LIGHT_LEVEL_SWITCH -> cmd = 8000; - // EXTERIOR_LAMP_LEVEL_SWITCH - default -> cmd = 7000; + if (interaction == ConsoleInteraction.SCREEN_LEFT) { + return null; + } + Material material = interaction.getMaterial(); + int cmd = interaction.getCustomModelData(); + if (interaction == ConsoleInteraction.DIRECTION) { + HashMap wherec = new HashMap<>(); + wherec.put("tardis_id", id); + ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherec); + cmd = (rsc.resultSet()) ? getCmd(rsc.getDirection()) + 10000 : 10000; } // spawn a control ItemStack is = new ItemStack(material); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/ColourType.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/ColourType.java new file mode 100644 index 000000000..30ccc16f3 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/ColourType.java @@ -0,0 +1,29 @@ +package me.eccentric_nz.TARDIS.console.models; + +import org.bukkit.Material; + +import java.util.HashMap; + +public class ColourType { + + public static final HashMap LOOKUP = new HashMap<>(); + + static { + LOOKUP.put(Material.LIGHT_GRAY_CONCRETE_POWDER, 1); + LOOKUP.put(Material.GRAY_CONCRETE_POWDER, 2); + LOOKUP.put(Material.BLACK_CONCRETE_POWDER, 3); + LOOKUP.put(Material.WHITE_CONCRETE_POWDER, 4); + LOOKUP.put(Material.RED_CONCRETE_POWDER, 5); + LOOKUP.put(Material.ORANGE_CONCRETE_POWDER, 6); + LOOKUP.put(Material.YELLOW_CONCRETE_POWDER, 7); + LOOKUP.put(Material.LIME_CONCRETE_POWDER, 8); + LOOKUP.put(Material.GREEN_CONCRETE_POWDER, 9); + LOOKUP.put(Material.CYAN_CONCRETE_POWDER, 10); + LOOKUP.put(Material.LIGHT_BLUE_CONCRETE_POWDER, 11); + LOOKUP.put(Material.BLUE_CONCRETE_POWDER, 12); + LOOKUP.put(Material.PURPLE_CONCRETE_POWDER, 13); + LOOKUP.put(Material.MAGENTA_CONCRETE_POWDER, 14); + LOOKUP.put(Material.PINK_CONCRETE_POWDER, 15); + LOOKUP.put(Material.BROWN_CONCRETE_POWDER, 16); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/ConcoleColourChanger.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/ConcoleColourChanger.java new file mode 100644 index 000000000..135a13782 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/ConcoleColourChanger.java @@ -0,0 +1,52 @@ +package me.eccentric_nz.TARDIS.console.models; + +import me.eccentric_nz.TARDIS.TARDIS; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.UUID; + +public class ConcoleColourChanger { + + private final TARDIS plugin; + private final Location location; + private final String uuids; + private final int type; + + public ConcoleColourChanger(TARDIS plugin, Location location, String uuids, int type) { + this.plugin = plugin; + this.location = location; + this.uuids = uuids; + this.type = type; + } + + public boolean paint() { + String[] split = uuids.split("~"); + for (String s : split) { + try { + UUID uuid = UUID.fromString(s); + for (Entity e : location.getWorld().getNearbyEntities(location, 5, 5, 5, (d) -> d.getType() == EntityType.ITEM_DISPLAY)) { + UUID p = e.getPersistentDataContainer().get(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid.equals(p) && e instanceof ItemDisplay display) { + // get the item stack + ItemStack is = display.getItemStack(); + if (is != null) { + ItemMeta im = is.getItemMeta(); + int cmd = im.getCustomModelData() > 2000 ? 2000 : 1000; + im.setCustomModelData(cmd + type); + is.setItemMeta(im); + display.setItemStack(is); + } + } + } + } catch (IllegalArgumentException ignored) { + return false; + } + } + return true; + } +} diff --git a/src/main/resources/en.yml b/src/main/resources/en.yml index a09823ce2..9c8872280 100644 --- a/src/main/resources/en.yml +++ b/src/main/resources/en.yml @@ -357,6 +357,7 @@ CONFIG_OPTION: "The config option [%s] is set to %s" CONFIG_OPTION_ARTRON: "The Artron config option [%s] is set to %s" CONFIG_OPTION_SET: "To set a config option, supply a valid value e.g. '/tconfig %s [value]'" CONFIG_UPDATED: "The config option [%s] was updated!" +CONSOLE_COLOUR_AMOUNT: "You need 6 concrete powder to change the console color!" CONSTRUCT_LINE_LEN: "That text is too long for the CONSTRUCT sign!" CONSTRUCT_LINE_NUM: "You need to specify the line number of the CONSTRUCT sign!" CONSTRUCT_LINE_SAVED: "The CONSTRUCT sign text was saved successfully." diff --git a/todo.md b/todo.md index 90d88fd5b..66f819a3f 100644 --- a/todo.md +++ b/todo.md @@ -4,16 +4,20 @@ 1. Fix fifteenth console redstone piston door 2. Fix follower persistence -3. ? +3. Custom Control models [#703](https://github.com/eccentricdevotion/TARDIS/issues/703) + [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) + * New interior with console + * Remove interaction records when removing console + * Crafting + * Placing +4. ? ## Next version `5.7.0` 1. Allow 3D Police Boxes to land on slabs [#777](https://github.com/eccentricdevotion/TARDIS/issues/777) -2. Custom Control models [#703](https://github.com/eccentricdevotion/TARDIS/issues/703) - [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) -3. Animated models for player disguises -4. Rework difficulty [#754](https://github.com/eccentricdevotion/TARDIS/issues/754) -5. ? +2. Animated models for player disguises +3. Rework difficulty [#754](https://github.com/eccentricdevotion/TARDIS/issues/754) +4. ? ## Future versions From f3a78fb163749cd60a67fde700f1129b59177db1 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Tue, 23 Apr 2024 16:37:49 +1200 Subject: [PATCH 39/96] Add console recipes --- .../give/TARDISDisplayBlockCommand.java | 8 +- .../TARDIS/enumeration/RecipeCategory.java | 3 +- .../TARDIS/enumeration/RecipeItem.java | 19 +++++ .../recipes/TARDISRecipeCategoryListener.java | 2 +- .../TARDIS/recipes/TARDISShapedRecipe.java | 1 + .../TARDIS/recipes/shaped/ConsoleRecipe.java | 73 +++++++++++++++++++ 6 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/ConsoleRecipe.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISDisplayBlockCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISDisplayBlockCommand.java index 8f8e7c353..b0d1d921b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISDisplayBlockCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISDisplayBlockCommand.java @@ -37,10 +37,10 @@ public TARDISDisplayBlockCommand(TARDIS plugin) { public ItemStack getStack(String arg) { String display = TARDISStringUtils.toEnumUppercase(arg); if (display.startsWith("DOOR_")) { - plugin.debug(display); - for (String d : Door.byName.keySet()) { - plugin.debug(d); - } +// plugin.debug(display); +// for (String d : Door.byName.keySet()) { +// plugin.debug(d); +// } Door door = Door.byName.get(display); ItemStack is = new ItemStack(door.getMaterial(), 1); ItemMeta im = is.getItemMeta(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeCategory.java b/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeCategory.java index c078933a8..76562f86e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeCategory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeCategory.java @@ -21,12 +21,13 @@ public enum RecipeCategory { - SEED_BLOCKS(Material.LAPIS_BLOCK, 1, 4, ""), + SEED_BLOCKS(Material.LAPIS_BLOCK, 1, 2, ""), CHEMISTRY(Material.BREWING_STAND, 1, -1, "#AA0000"), CUSTOM_BLOCKS(Material.ANVIL, 1, 8, "#AA0000"), ACCESSORIES(Material.LEATHER_HELMET, 10000037, 9, "#55FF55"), // CONTROLS(Material.LEVER, 1000, 10, "#AAFF00"), PLANETS(Material.SLIME_BALL, 12, 6, "#AAFF00"), + CONSOLES(Material.LIGHT_GRAY_CONCRETE, 1001, 4, "#FF55FF"), CONSOLE_CIRCUITS(Material.GLOWSTONE_DUST, 10001977, 11, "#FF55FF"), FOOD(Material.MELON_SLICE, 10000002, 13, "#AAAAAA"), ITEM_CIRCUITS(Material.GLOWSTONE_DUST, 10001967, 15, "#FF5555"), diff --git a/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeItem.java b/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeItem.java index 68c8a8c15..81dc82235 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeItem.java +++ b/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeItem.java @@ -73,6 +73,7 @@ public enum RecipeItem { TARDIS_STATTENHEIM_CIRCUIT(10001963, RecipeCategory.ITEM_CIRCUITS), TARDIS_TELEPATHIC_CIRCUIT(10000001, RecipeCategory.CONSOLE_CIRCUITS), TARDIS_TEMPORAL_CIRCUIT(10001974, RecipeCategory.CONSOLE_CIRCUITS), + // rotors TIME_ROTOR_DELTA(10000006, RecipeCategory.ROTORS), TIME_ROTOR_EARLY(10000002, RecipeCategory.ROTORS), TIME_ENGINE(10000007, RecipeCategory.ROTORS), @@ -81,6 +82,24 @@ public enum RecipeItem { TIME_ROTOR_TENTH(10000003, RecipeCategory.ROTORS), TIME_ROTOR_ELEVENTH(10000004, RecipeCategory.ROTORS), TIME_ROTOR_TWELFTH(10000005, RecipeCategory.ROTORS), + // consoles + LIGHT_GRAY_CONSOLE(1001, RecipeCategory.CONSOLES), + GRAY_CONSOLE(1002, RecipeCategory.CONSOLES), + WHITE_CONSOLE(1003, RecipeCategory.CONSOLES), + BLACK_CONSOLE(1004, RecipeCategory.CONSOLES), + RED_CONSOLE(1005, RecipeCategory.CONSOLES), + ORANGE_CONSOLE(1006, RecipeCategory.CONSOLES), + YELLOW_CONSOLE(1007, RecipeCategory.CONSOLES), + LIME_CONSOLE(1008, RecipeCategory.CONSOLES), + GREEN_CONSOLE(1009, RecipeCategory.CONSOLES), + CYAN_CONSOLE(1010, RecipeCategory.CONSOLES), + LIGHT_BLUE_CONSOLE(1011, RecipeCategory.CONSOLES), + BLUE_CONSOLE(1012, RecipeCategory.CONSOLES), + PURPLE_CONSOLE(1013, RecipeCategory.CONSOLES), + MAGENTA_CONSOLE(1014, RecipeCategory.CONSOLES), + PINK_CONSOLE(1015, RecipeCategory.CONSOLES), + BROWN_CONSOLE(1016, RecipeCategory.CONSOLES), + // bow ties WHITE_BOW_TIE(10000023), ORANGE_BOW_TIE(10000024), MAGENTA_BOW_TIE(10000025), diff --git a/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISRecipeCategoryListener.java b/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISRecipeCategoryListener.java index 23d6a8c5b..0a32649d5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISRecipeCategoryListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISRecipeCategoryListener.java @@ -48,7 +48,7 @@ public void onRecipeCategoryClick(InventoryClickEvent event) { event.setCancelled(true); int slot = event.getRawSlot(); Player player = (Player) event.getWhoClicked(); - if (slot < 4 || slot > 26) { + if (slot < 2 || slot > 26) { return; } ItemStack is = view.getItem(slot); diff --git a/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISShapedRecipe.java b/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISShapedRecipe.java index fb5c5023d..b81514c33 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISShapedRecipe.java +++ b/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISShapedRecipe.java @@ -45,6 +45,7 @@ public void addShapedRecipes() { new BlueBowTieRecipe(plugin).addRecipe(); new BrownBowTieRecipe(plugin).addRecipe(); new BrushCircuitRecipe(plugin).addRecipe(); + new ConsoleRecipe(plugin).addRecipes(); new ConversionCircuitRecipe(plugin).addRecipe(); new CustardCreamRecipe(plugin).addRecipe(); new CyanBowTieRecipe(plugin).addRecipe(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/ConsoleRecipe.java b/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/ConsoleRecipe.java new file mode 100644 index 000000000..f7c1753c6 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/ConsoleRecipe.java @@ -0,0 +1,73 @@ +package me.eccentric_nz.TARDIS.recipes.shaped; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.models.ColourType; +import me.eccentric_nz.TARDIS.enumeration.Difficulty; +import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.Tag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.RecipeChoice; +import org.bukkit.inventory.ShapedRecipe; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.Map; + +/* +easy_shape:CBC,LWL,CBC +easy_ingredients.C:CONCRETE_POWDER +easy_ingredients.B:BAMBOO_BUTTON +easy_ingredients.L:LEVER +easy_ingredients.W:REDSTONE +hard_shape:CBC,ORO,CBC +hard_ingredients.C:CONCRETE_POWDER +hard_ingredients.B:BAMBOO_BUTTON +hard_ingredients.O:COMPARATOR +hard_ingredients.R:REDSTONE_BLOCK +result:GLOWSTONE_DUST +amount:1 +*/ + +public class ConsoleRecipe { + + private final TARDIS plugin; + private final RecipeChoice.MaterialChoice choices; + + public ConsoleRecipe(TARDIS plugin) { + this.plugin = plugin; + this.choices = new RecipeChoice.MaterialChoice(Tag.CONCRETE_POWDER.getValues().toArray(new Material[0])); + } + + public void addRecipes() { + for (Map.Entry colour : ColourType.LOOKUP.entrySet()) { + // get colour name + String name = colour.getKey().toString().replace("_CONCRETE_POWDER", ""); + ItemStack is = new ItemStack(Material.LIGHT_GRAY_CONCRETE, 1); + ItemMeta im = is.getItemMeta(); + String dn = TARDISStringUtils.capitalise(name) + " Console"; + plugin.debug("dn " + dn); + im.setDisplayName(dn); + im.setCustomModelData(1000 + colour.getValue()); + is.setItemMeta(im); + NamespacedKey key = new NamespacedKey(plugin, name.toLowerCase() + "_console"); + plugin.debug("key " + key); + ShapedRecipe r = new ShapedRecipe(key, is); + if (plugin.getDifficulty() == Difficulty.HARD) { + r.shape("CBC", "LRL", "CBC"); + r.setIngredient('C', colour.getKey()); + r.setIngredient('B', Material.BAMBOO_BUTTON); + r.setIngredient('L', Material.LEVER); + r.setIngredient('R', Material.COMPARATOR); + } else { + r.shape("CBC", "ORO", "CBC"); + r.setIngredient('C', colour.getKey()); + r.setIngredient('B', Material.BAMBOO_BUTTON); + r.setIngredient('O', Material.COMPARATOR); + r.setIngredient('R', Material.REDSTONE_BLOCK); + } + plugin.getServer().addRecipe(r); + plugin.getFigura().getShapedRecipes().put(dn, r); + } + } +} From 8b240d65fe7e4a19e4b804f96f7d23a3b53a3183 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Tue, 23 Apr 2024 18:39:40 +1200 Subject: [PATCH 40/96] Placing console blocks --- .../TARDISDisplayBlockListener.java | 2 +- .../resultset/ResultSetInteractionCheck.java | 91 +++++++++++++++++++ .../listeners/TARDISSeedBlockListener.java | 31 ++++++- .../TARDIS/recipes/shaped/ConsoleRecipe.java | 16 ++-- .../block/ChemistryBlockListener.java | 9 -- src/main/resources/en.yml | 1 + todo.md | 7 +- 7 files changed, 132 insertions(+), 25 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteractionCheck.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java index 1dac40fb5..c606dc6ba 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java @@ -85,7 +85,7 @@ public void onDisplayBlockPlace(BlockPlaceEvent event) { if (!im.hasDisplayName() || !im.getPersistentDataContainer().has(plugin.getCustomBlockKey(), PersistentDataType.INTEGER)) { return; } - if (im.getDisplayName().equals(ChatColor.GOLD + "TARDIS Seed Block")) { + if (im.getDisplayName().equals(ChatColor.GOLD + "TARDIS Seed Block") || im.getDisplayName().endsWith("Console")) { return; } int cmd = im.getPersistentDataContainer().get(plugin.getCustomBlockKey(), PersistentDataType.INTEGER); diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteractionCheck.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteractionCheck.java new file mode 100644 index 000000000..cc09ac169 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteractionCheck.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2024 eccentric_nz + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package me.eccentric_nz.TARDIS.database.resultset; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.TARDISDatabaseConnection; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.UUID; + +/** + * A TARDIS control room, also referred to as a console room, is any place on a TARDIS that contains a functioning + * control console. This flight deck also functions as a point of exit. A control room's look can be changed over time, + * to suit one's tastes and personality. The process by which an operator can transform a control room is fairly simple, + * once compared by the Fifth Doctor to changing a "desktop theme". + * + * @author eccentric_nz + */ +public class ResultSetInteractionCheck { + + private final TARDISDatabaseConnection service = TARDISDatabaseConnection.getINSTANCE(); + private final Connection connection = service.getConnection(); + private final TARDIS plugin; + private final String prefix; + private final UUID uuid; + + /** + * Creates a class instance that can be used to retrieve an SQL ResultSet from the interactions table. + * + * @param plugin an instance of the main class. + */ + public ResultSetInteractionCheck(TARDIS plugin, UUID uuid) { + this.plugin = plugin; + this.uuid = uuid; + prefix = this.plugin.getPrefix(); + } + + /** + * Retrieves an SQL ResultSet from the interactions table. This method builds an SQL query string from the + * parameters supplied and then executes the query. Use the getters to retrieve the results. + * + * @return true or false depending on whether any data matches the query + */ + public boolean resultSet() { + PreparedStatement statement = null; + ResultSet rs = null; + String query = "SELECT " + prefix + "interactions.i_id FROM " + prefix + "interactions, " + prefix + "tardis WHERE " + prefix + "tardis.uuid = ? AND " + prefix + "interactions.tardis_id = " + prefix + "tardis.tardis_id"; + try { + service.testConnection(connection); + statement = connection.prepareStatement(query); + statement.setString(1, uuid.toString()); + rs = statement.executeQuery(); + if (rs.isBeforeFirst()) { + return true; + } else { + return false; + } + } catch (SQLException e) { + plugin.debug("ResultSet error for interactions check table! " + e.getMessage()); + return false; + } finally { + try { + if (rs != null) { + rs.close(); + } + if (statement != null) { + statement.close(); + } + } catch (SQLException e) { + plugin.debug("Error closing interactions check table! " + e.getMessage()); + } + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISSeedBlockListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISSeedBlockListener.java index 5cb0a8d97..b795cd252 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISSeedBlockListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISSeedBlockListener.java @@ -20,9 +20,12 @@ import me.eccentric_nz.TARDIS.TARDISConstants; import me.eccentric_nz.TARDIS.builders.TARDISBuildData; import me.eccentric_nz.TARDIS.builders.TARDISSeedBlockProcessor; +import me.eccentric_nz.TARDIS.console.ConsoleBuilder; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItem; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItemUtils; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetInteractionCheck; import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardisID; import me.eccentric_nz.TARDIS.enumeration.Consoles; import me.eccentric_nz.TARDIS.enumeration.Schematic; import me.eccentric_nz.TARDIS.enumeration.TardisModule; @@ -58,8 +61,8 @@ public TARDISSeedBlockListener(TARDIS plugin) { } /** - * Store the TARDIS Seed block's values for use when clicked with the TARDIS - * key to activate growing, or to return the block if broken. + * Store the TARDIS Seed block's values for use when clicked with the TARDIS key to activate growing, or to return + * the block if broken. * * @param event The TARDIS Seed block placement event */ @@ -74,7 +77,8 @@ public void onSeedBlockPlace(BlockPlaceEvent event) { if (!im.hasDisplayName() || !im.hasLore()) { return; } - if (im.getDisplayName().equals(ChatColor.GOLD + "TARDIS Seed Block")) { + String dn = im.getDisplayName(); + if (dn.equals(ChatColor.GOLD + "TARDIS Seed Block")) { Block block = event.getBlockPlaced(); if (im.getPersistentDataContainer().has(plugin.getCustomBlockKey(), PersistentDataType.INTEGER)) { int which = im.getPersistentDataContainer().get(plugin.getCustomBlockKey(), PersistentDataType.INTEGER); @@ -103,6 +107,27 @@ public void onSeedBlockPlace(BlockPlaceEvent event) { }, 3L); } // now the player has to click the block with the TARDIS key + } else if (dn.endsWith(" Console") && is.getType().toString().endsWith("_CONCRETE")) { + // must be in TARDIS world + if (!plugin.getUtils().inTARDISWorld(player)) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_IN_WORLD"); + event.setCancelled(true); + return; + } + // must not have a console already + ResultSetInteractionCheck rsi = new ResultSetInteractionCheck(plugin, player.getUniqueId()); + if (rsi.resultSet()) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "CONSOLE_HAS"); + event.setCancelled(true); + return; + } + // build a console of the correct colour + int colour = im.getPersistentDataContainer().getOrDefault(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, 1); + // get TARDIS id + ResultSetTardisID rs = new ResultSetTardisID(plugin); + if (rs.fromUUID(player.getUniqueId().toString())) { + new ConsoleBuilder(plugin).create(event.getBlockPlaced(), colour, rs.getTardis_id()); + } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/ConsoleRecipe.java b/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/ConsoleRecipe.java index f7c1753c6..77d4be13b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/ConsoleRecipe.java +++ b/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/ConsoleRecipe.java @@ -6,12 +6,12 @@ import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; import org.bukkit.Material; import org.bukkit.NamespacedKey; -import org.bukkit.Tag; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.RecipeChoice; import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataType; +import java.util.List; import java.util.Map; /* @@ -32,26 +32,26 @@ public class ConsoleRecipe { private final TARDIS plugin; - private final RecipeChoice.MaterialChoice choices; public ConsoleRecipe(TARDIS plugin) { this.plugin = plugin; - this.choices = new RecipeChoice.MaterialChoice(Tag.CONCRETE_POWDER.getValues().toArray(new Material[0])); } public void addRecipes() { for (Map.Entry colour : ColourType.LOOKUP.entrySet()) { // get colour name String name = colour.getKey().toString().replace("_CONCRETE_POWDER", ""); - ItemStack is = new ItemStack(Material.LIGHT_GRAY_CONCRETE, 1); + Material material = Material.valueOf(name + "_CONCRETE"); + ItemStack is = new ItemStack(material, 1); ItemMeta im = is.getItemMeta(); String dn = TARDISStringUtils.capitalise(name) + " Console"; - plugin.debug("dn " + dn); im.setDisplayName(dn); - im.setCustomModelData(1000 + colour.getValue()); + im.setLore(List.of("Integration with interaction")); + im.setCustomModelData(1001); + im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, colour.getValue() + ); is.setItemMeta(im); NamespacedKey key = new NamespacedKey(plugin, name.toLowerCase() + "_console"); - plugin.debug("key " + key); ShapedRecipe r = new ShapedRecipe(key, is); if (plugin.getDifficulty() == Difficulty.HARD) { r.shape("CBC", "LRL", "CBC"); diff --git a/src/main/java/me/eccentric_nz/tardischemistry/block/ChemistryBlockListener.java b/src/main/java/me/eccentric_nz/tardischemistry/block/ChemistryBlockListener.java index d50d3d233..ff61314c5 100755 --- a/src/main/java/me/eccentric_nz/tardischemistry/block/ChemistryBlockListener.java +++ b/src/main/java/me/eccentric_nz/tardischemistry/block/ChemistryBlockListener.java @@ -173,13 +173,4 @@ public void onChemistryBlockBreak(BlockBreakEvent event) { } } } - -// @EventHandler(ignoreCancelled = true) -// public void onChemistryBlockPlace(BlockPlaceEvent event) { -// ItemStack is = event.getItemInHand(); -// Material material = event.getBlock().getType(); -// if (is.hasItemMeta() && is.getItemMeta().getPersistentDataContainer().has(plugin.getCustomBlockKey(), PersistentDataType.INTEGER) && !isMushroomBlock(material)) { -// event.setCancelled(true); -// } -// } } diff --git a/src/main/resources/en.yml b/src/main/resources/en.yml index 9c8872280..feea21120 100644 --- a/src/main/resources/en.yml +++ b/src/main/resources/en.yml @@ -358,6 +358,7 @@ CONFIG_OPTION_ARTRON: "The Artron config option [%s] is set to %s" CONFIG_OPTION_SET: "To set a config option, supply a valid value e.g. '/tconfig %s [value]'" CONFIG_UPDATED: "The config option [%s] was updated!" CONSOLE_COLOUR_AMOUNT: "You need 6 concrete powder to change the console color!" +CONSOLE_HAS: "You already have an integrated console!" CONSTRUCT_LINE_LEN: "That text is too long for the CONSTRUCT sign!" CONSTRUCT_LINE_NUM: "You need to specify the line number of the CONSTRUCT sign!" CONSTRUCT_LINE_SAVED: "The CONSTRUCT sign text was saved successfully." diff --git a/todo.md b/todo.md index 66f819a3f..befdbc31f 100644 --- a/todo.md +++ b/todo.md @@ -7,10 +7,9 @@ 3. Custom Control models [#703](https://github.com/eccentricdevotion/TARDIS/issues/703) [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) * New interior with console - * Remove interaction records when removing console - * Crafting - * Placing -4. ? + * Malfunction & manual flight classes +4. Update old light level controls +5. ? ## Next version `5.7.0` From 4943237a6e01204f63b2470280cddbcd6eb9d931 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Tue, 23 Apr 2024 18:39:55 +1200 Subject: [PATCH 41/96] Removing console --- .../TARDIS/console/ConsoleDestroyer.java | 81 ++++++++++++++ .../interaction/ScreenInteraction.java | 11 ++ .../TARDIS/console/models/ColourType.java | 17 +++ .../TARDIS/database/ClearInteractions.java | 39 +++++++ .../ResultSetInteractionsFromId.java | 105 ++++++++++++++++++ 5 files changed, 253 insertions(+) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/database/ClearInteractions.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteractionsFromId.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java new file mode 100644 index 000000000..e2c8262ba --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java @@ -0,0 +1,81 @@ +package me.eccentric_nz.TARDIS.console; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.models.ColourType; +import me.eccentric_nz.TARDIS.database.ClearInteractions; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetInteractionsFromId; +import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.ItemDisplay; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataType; + +import java.util.List; +import java.util.UUID; + +public class ConsoleDestroyer { + + private final TARDIS plugin; + + public ConsoleDestroyer(TARDIS plugin) { + this.plugin = plugin; + } + + public ItemStack returnStack(String uuids, int id) { + String colour = ""; + int cmd = 1; + ResultSetInteractionsFromId rs = new ResultSetInteractionsFromId(plugin, id); + if (rs.resultSet()) { + // interactions + for (UUID u : rs.getUuids()) { + Entity e = plugin.getServer().getEntity(u); + if (e != null) { + // item displays + UUID uuid = e.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (uuid != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); + if (display != null) { + display.remove(); + } + } + // remove + e.remove(); + } + } + String[] split = uuids.split("~"); + for (String u : split) { + try { + UUID uuid = UUID.fromString(u); + Entity e = plugin.getServer().getEntity(uuid); + if (e instanceof ItemDisplay display) { + // get colour + ItemStack is = display.getItemStack(); + if (colour.isEmpty() && is != null && is.hasItemMeta()) { + cmd = is.getItemMeta().getCustomModelData() % 1000; + colour = ColourType.COLOURS.getOrDefault(cmd, "LIGHT_GRAY"); + } + // remove + display.remove(); + } + } catch (IllegalArgumentException ignored) { + } + } + // remove database records + new ClearInteractions(plugin).removeRecords(id); + // build item stack + Material material = Material.valueOf(colour + "_CONCRETE"); + ItemStack console = new ItemStack(material, 1); + ItemMeta im = console.getItemMeta(); + String dn = TARDISStringUtils.capitalise(colour) + " Console"; + im.setDisplayName(dn); + im.setLore(List.of("Integration with interaction")); + im.setCustomModelData(1001); + im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, cmd); + console.setItemMeta(im); + return console; + } + return null; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java index d63daea56..c194fba4c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java @@ -1,6 +1,7 @@ package me.eccentric_nz.TARDIS.console.interaction; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.ConsoleDestroyer; import me.eccentric_nz.TARDIS.console.ControlMonitor; import me.eccentric_nz.TARDIS.console.models.ColourType; import me.eccentric_nz.TARDIS.console.models.ConcoleColourChanger; @@ -54,6 +55,16 @@ public void display(int id, Interaction interaction, boolean coords, Player play } } } + } else if (Tag.ITEMS_PICKAXES.isTagged(hand.getType())) { + String uuids = interaction.getPersistentDataContainer().get(plugin.getUnaryKey(), PersistentDataType.STRING); + if (uuids != null) { + // remove the console + ItemStack console = new ConsoleDestroyer(plugin).returnStack(uuids, id); + // return a console block of the correct colour + if (console != null) { + interaction.getWorld().dropItemNaturally(interaction.getLocation(), console); + } + } } else { // open control menu new ControlMenuAction(plugin).openGUI(player, id); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/ColourType.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/ColourType.java index 30ccc16f3..700772161 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/models/ColourType.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/ColourType.java @@ -7,6 +7,7 @@ public class ColourType { public static final HashMap LOOKUP = new HashMap<>(); + public static final HashMap COLOURS = new HashMap<>(); static { LOOKUP.put(Material.LIGHT_GRAY_CONCRETE_POWDER, 1); @@ -25,5 +26,21 @@ public class ColourType { LOOKUP.put(Material.MAGENTA_CONCRETE_POWDER, 14); LOOKUP.put(Material.PINK_CONCRETE_POWDER, 15); LOOKUP.put(Material.BROWN_CONCRETE_POWDER, 16); + COLOURS.put(1, "LIGHT_GRAY"); + COLOURS.put(2, "GRAY"); + COLOURS.put(3, "BLACK"); + COLOURS.put(4, "WHITE"); + COLOURS.put(5, "RED"); + COLOURS.put(6, "ORANGE"); + COLOURS.put(7, "YELLOW"); + COLOURS.put(8, "LIME"); + COLOURS.put(9, "GREEN"); + COLOURS.put(10, "CYAN"); + COLOURS.put(11, "LIGHT_BLUE"); + COLOURS.put(12, "BLUE"); + COLOURS.put(13, "PURPLE"); + COLOURS.put(14, "MAGENTA"); + COLOURS.put(15, "PINK"); + COLOURS.put(16, "BROWN"); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/ClearInteractions.java b/src/main/java/me/eccentric_nz/TARDIS/database/ClearInteractions.java new file mode 100644 index 000000000..87bb475c9 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/database/ClearInteractions.java @@ -0,0 +1,39 @@ +package me.eccentric_nz.TARDIS.database; + +import me.eccentric_nz.TARDIS.TARDIS; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public class ClearInteractions { + + private final TARDIS plugin; + private final TARDISDatabaseConnection service = TARDISDatabaseConnection.getINSTANCE(); + private final Connection connection = service.getConnection(); + private final String prefix; + + public ClearInteractions(TARDIS plugin) { + this.plugin = plugin; + prefix = this.plugin.getPrefix(); + } + + public void removeRecords(int id) { + PreparedStatement ps = null; + try { + ps = connection.prepareStatement("DELETE FROM " + prefix + "interactions WHERE tardis_id = ?"); + ps.setInt(1, id); + ps.executeUpdate(); + } catch (SQLException e) { + plugin.debug("Error clearing interactions [" + id + "] table: " + e.getMessage()); + } finally { + try { + if (ps != null) { + ps.close(); + } + } catch (SQLException ex) { + plugin.debug("Error clearing interactions [" + id + "] statement: " + ex.getMessage()); + } + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteractionsFromId.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteractionsFromId.java new file mode 100644 index 000000000..2ddc46651 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteractionsFromId.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2024 eccentric_nz + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package me.eccentric_nz.TARDIS.database.resultset; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.TARDISDatabaseConnection; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + * A TARDIS control room, also referred to as a console room, is any place on a TARDIS that contains a functioning + * control console. This flight deck also functions as a point of exit. A control room's look can be changed over time, + * to suit one's tastes and personality. The process by which an operator can transform a control room is fairly simple, + * once compared by the Fifth Doctor to changing a "desktop theme". + * + * @author eccentric_nz + */ +public class ResultSetInteractionsFromId { + + private final TARDISDatabaseConnection service = TARDISDatabaseConnection.getINSTANCE(); + private final Connection connection = service.getConnection(); + private final TARDIS plugin; + private final int id; + private final String prefix; + private final List uuids = new ArrayList<>(); + + /** + * Creates a class instance that can be used to retrieve an SQL ResultSet from the interactions table. + * + * @param plugin an instance of the main class. + */ + public ResultSetInteractionsFromId(TARDIS plugin, int id) { + this.plugin = plugin; + this.id = id; + prefix = this.plugin.getPrefix(); + } + + /** + * Retrieves an SQL ResultSet from the interactions table. This method builds an SQL query string from the + * parameters supplied and then executes the query. Use the getters to retrieve the results. + * + * @return true or false depending on whether any data matches the query + */ + public boolean resultSet() { + PreparedStatement statement = null; + ResultSet rs = null; + String query = "SELECT * FROM " + prefix + "interactions WHERE tardis_id = ?"; + try { + service.testConnection(connection); + statement = connection.prepareStatement(query); + statement.setInt(1, id); + rs = statement.executeQuery(); + if (rs.isBeforeFirst()) { + while (rs.next()) { + try { + UUID uuid = UUID.fromString(rs.getString("uuid")); + uuids.add(uuid); + } catch (IllegalArgumentException ignored) { + } + } + } else { + return false; + } + } catch (SQLException e) { + plugin.debug("ResultSet error for interactions table! " + e.getMessage()); + return false; + } finally { + try { + if (rs != null) { + rs.close(); + } + if (statement != null) { + statement.close(); + } + } catch (SQLException e) { + plugin.debug("Error closing interactions table! " + e.getMessage()); + } + } + return true; + } + + public List getUuids() { + return uuids; + } +} From c179aef8677fea770c380f9f53d4566d976e919c Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Tue, 23 Apr 2024 20:11:46 +1200 Subject: [PATCH 42/96] All Artron button interactions --- .../TARDIS/artron/ArtronAbandoned.java | 64 +++++ .../TARDIS/artron/ArtronChargeAction.java | 90 +++++++ .../TARDIS/artron/ArtronInitAction.java | 61 +++++ .../TARDIS/artron/ArtronTransferAction.java | 49 ++++ .../artron/TARDISArtronCapacitorListener.java | 249 +----------------- .../interaction/ArtronInteraction.java | 2 +- .../console/interaction/ArtronRightClick.java | 93 +++++++ 7 files changed, 360 insertions(+), 248 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/artron/ArtronAbandoned.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/artron/ArtronChargeAction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/artron/ArtronInitAction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/artron/ArtronTransferAction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronRightClick.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/artron/ArtronAbandoned.java b/src/main/java/me/eccentric_nz/TARDIS/artron/ArtronAbandoned.java new file mode 100644 index 000000000..4c64f4c99 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/artron/ArtronAbandoned.java @@ -0,0 +1,64 @@ +package me.eccentric_nz.TARDIS.artron; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.api.event.TARDISClaimEvent; +import me.eccentric_nz.TARDIS.commands.tardis.TARDISAbandonCommand; +import me.eccentric_nz.TARDIS.database.data.Tardis; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentFromId; +import me.eccentric_nz.TARDIS.doors.DoorCloserAction; +import me.eccentric_nz.TARDIS.enumeration.ChameleonPreset; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import me.eccentric_nz.TARDIS.utility.TARDISStaticUtils; +import org.bukkit.Location; +import org.bukkit.block.Sign; +import org.bukkit.block.sign.Side; +import org.bukkit.block.sign.SignSide; +import org.bukkit.entity.Player; + +public class ArtronAbandoned { + + private final TARDIS plugin; + + public ArtronAbandoned(TARDIS plugin) { + this.plugin = plugin; + } + + public boolean claim(Player player, int id, Location location, Tardis tardis) { + // transfer ownership to the player who clicked + boolean pu = plugin.getQueryFactory().claimTARDIS(player, id); + // make sure player is added as owner of interior WorldGuard region + if (plugin.isWorldGuardOnServer() && plugin.getConfig().getBoolean("preferences.use_worldguard")) { + plugin.getWorldGuardUtils().updateRegionForClaim(location, player.getUniqueId()); + } + ResultSetCurrentFromId rscl = new ResultSetCurrentFromId(plugin, id); + if (rscl.resultSet()) { + Location current = new Location(rscl.getWorld(), rscl.getX(), rscl.getY(), rscl.getZ()); + if (pu) { + new DoorCloserAction(plugin, player.getUniqueId(), id).closeDoors(); + plugin.getMessenger().send(player, TardisModule.TARDIS, "ABANDON_CLAIMED"); + plugin.getPM().callEvent(new TARDISClaimEvent(player, tardis, current)); + } + if (plugin.getConfig().getBoolean("police_box.name_tardis")) { + ChameleonPreset preset = tardis.getPreset(); + Sign sign = TARDISAbandonCommand.getSign(current, rscl.getDirection(), preset); + if (sign != null) { + SignSide front = sign.getSide(Side.FRONT); + String player_name = TARDISStaticUtils.getNick(player); + String owner; + if (preset.equals(ChameleonPreset.GRAVESTONE) || preset.equals(ChameleonPreset.PUNKED) || preset.equals(ChameleonPreset.ROBOT)) { + owner = (player_name.length() > 14) ? player_name.substring(0, 14) : player_name; + } else { + owner = (player_name.length() > 14) ? player_name.substring(0, 12) + "'s" : player_name + "'s"; + } + switch (preset) { + case GRAVESTONE -> front.setLine(3, owner); + case ANGEL, JAIL -> front.setLine(2, owner); + default -> front.setLine(0, owner); + } + sign.update(); + } + } + } + return pu; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/artron/ArtronChargeAction.java b/src/main/java/me/eccentric_nz/TARDIS/artron/ArtronChargeAction.java new file mode 100644 index 000000000..900156b06 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/artron/ArtronChargeAction.java @@ -0,0 +1,90 @@ +package me.eccentric_nz.TARDIS.artron; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import me.eccentric_nz.TARDIS.utility.TARDISNumberParsers; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.HashMap; +import java.util.List; + +public class ArtronChargeAction { + + private final TARDIS plugin; + + public ArtronChargeAction(TARDIS plugin) { + this.plugin = plugin; + } + + public void add(Player player, Material item, Material full, Location location, int current_level, int id) { + int amount = 0; + int fc = plugin.getArtronConfig().getInt("full_charge"); + if (item.equals(full)) { + if (plugin.getConfig().getBoolean("preferences.no_creative_condense")) { + switch (plugin.getWorldManager()) { + case MULTIVERSE -> { + if (!plugin.getMVHelper().isWorldSurvival(location.getWorld())) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "ARTRON_FULL_CREATIVE"); + return; + } + } + case NONE -> { + if (plugin.getPlanetsConfig().getString("planets." + location.getWorld().getName() + ".gamemode").equalsIgnoreCase("CREATIVE")) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "ARTRON_FULL_CREATIVE"); + return; + } + } + } + } + // remove the NETHER_STAR! (if appropriate) + int a = player.getInventory().getItemInMainHand().getAmount(); + int a2 = a - 1; + if (current_level < fc) { + // There's room in the tank! + amount = fc; + if (a2 > 0) { + player.getInventory().getItemInMainHand().setAmount(a2); + } else { + player.getInventory().removeItem(new ItemStack(full, 1)); + } + plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_AT_MAX"); + } else { + // We're either full or exceeding maximum, so don't do anything! + amount = current_level; + plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_MAX"); + } + } else { + ItemStack is = player.getInventory().getItemInMainHand(); + if (is.hasItemMeta()) { + ItemMeta im = is.getItemMeta(); + String name = im.getDisplayName(); + if (!name.equals("Artron Storage Cell")) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "CELL_NOT_VALID"); + return; + } + List lore = im.getLore(); + int charge = TARDISNumberParsers.parseInt(lore.get(1)) * is.getAmount(); + if (charge <= 0) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "CELL_NOT_CHARGED"); + return; + } + amount = current_level + charge; + lore.set(1, "0"); + im.setLore(lore); + is.setItemMeta(im); + is.getEnchantments().keySet().forEach(is::removeEnchantment); + plugin.getMessenger().send(player, TardisModule.TARDIS, "CELL_TRANSFER"); + } + } + // update charge + HashMap set = new HashMap<>(); + set.put("artron_level", amount); + HashMap whereid = new HashMap<>(); + whereid.put("tardis_id", id); + plugin.getQueryFactory().doUpdate("tardis", set, whereid); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/artron/ArtronInitAction.java b/src/main/java/me/eccentric_nz/TARDIS/artron/ArtronInitAction.java new file mode 100644 index 000000000..ef2367b76 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/artron/ArtronInitAction.java @@ -0,0 +1,61 @@ +package me.eccentric_nz.TARDIS.artron; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.TARDISConstants; +import me.eccentric_nz.TARDIS.database.data.Tardis; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import me.eccentric_nz.TARDIS.utility.TARDISSounds; +import me.eccentric_nz.TARDIS.utility.TARDISStaticLocationGetters; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +import java.util.HashMap; + +public class ArtronInitAction { + + private final TARDIS plugin; + + public ArtronInitAction(TARDIS plugin) { + this.plugin = plugin; + } + + public void powerUp(Location location, Tardis tardis, Player player, int id) { + // kickstart the TARDIS Artron Energy Capacitor + TARDISSounds.playTARDISSound(location, "power_up"); + if (tardis.isAbandoned()) { + // transfer ownership to the player who clicked + new ArtronAbandoned(plugin).claim(player, id, location, tardis); + } + // get locations from database + String creeper = tardis.getCreeper(); + if (!creeper.isEmpty() && !creeper.equals(":")) { + World w = location.getWorld(); + Location cl = TARDISStaticLocationGetters.getLocationFromDB(creeper); + plugin.setTardisSpawn(true); + Entity e = w.spawnEntity(cl.add(0.0d, 1.0d, 0.0d), EntityType.CREEPER); + Creeper c = (Creeper) e; + c.setPowered(true); + c.setRemoveWhenFarAway(false); + if (tardis.getSchematic().hasBeacon()) { + String beacon = tardis.getBeacon(); + Block bl = TARDISStaticLocationGetters.getLocationFromDB(beacon).getBlock(); + bl.setBlockData(TARDISConstants.GLASS); + } + } + // set the capacitor to 50% charge + HashMap set = new HashMap<>(); + int half = Math.round(plugin.getArtronConfig().getInt("full_charge") / 2.0F); + set.put("artron_level", half); + set.put("tardis_init", 1); + set.put("powered_on", 1); + HashMap whereid = new HashMap<>(); + whereid.put("tardis_id", id); + plugin.getQueryFactory().doUpdate("tardis", set, whereid); + plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_INIT"); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/artron/ArtronTransferAction.java b/src/main/java/me/eccentric_nz/TARDIS/artron/ArtronTransferAction.java new file mode 100644 index 000000000..90d117f23 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/artron/ArtronTransferAction.java @@ -0,0 +1,49 @@ +package me.eccentric_nz.TARDIS.artron; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.entity.Player; + +import java.util.HashMap; + +public class ArtronTransferAction { + + private final TARDIS plugin; + + public ArtronTransferAction(TARDIS plugin) { + this.plugin = plugin; + } + + public void add(int current_level, int level, Player player, int id, boolean hasPrefs) { + // transfer player artron energy into the capacitor + int fc = plugin.getArtronConfig().getInt("full_charge"); + int ten_percent = Math.round(fc * 0.1F); + if (current_level >= ten_percent && plugin.getConfig().getBoolean("creation.create_worlds")) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_UNDER_10"); + return; + } + if (hasPrefs) { + if (level < 1) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NONE"); + return; + } + int new_level = current_level + level; + // set player level to 0 + HashMap set = new HashMap<>(); + set.put("artron_level", 0); + HashMap wherel = new HashMap<>(); + wherel.put("uuid", player.getUniqueId().toString()); + plugin.getQueryFactory().doUpdate("player_prefs", set, wherel); + // add player level to TARDIS level + HashMap sett = new HashMap<>(); + sett.put("artron_level", new_level); + HashMap whereid = new HashMap<>(); + whereid.put("tardis_id", id); + plugin.getQueryFactory().doUpdate("tardis", sett, whereid); + int percent = Math.round((new_level * 100F) / fc); + plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_CHARGED", String.format("%d", percent)); + } else { + plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NONE"); + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronCapacitorListener.java b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronCapacitorListener.java index 289fa20c8..a8623723e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronCapacitorListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronCapacitorListener.java @@ -17,33 +17,11 @@ package me.eccentric_nz.TARDIS.artron; import me.eccentric_nz.TARDIS.TARDIS; -import me.eccentric_nz.TARDIS.TARDISConstants; -import me.eccentric_nz.TARDIS.api.event.TARDISClaimEvent; -import me.eccentric_nz.TARDIS.commands.tardis.TARDISAbandonCommand; -import me.eccentric_nz.TARDIS.control.TARDISPowerButton; -import me.eccentric_nz.TARDIS.database.data.Tardis; +import me.eccentric_nz.TARDIS.console.interaction.ArtronRightClick; import me.eccentric_nz.TARDIS.database.resultset.ResultSetControls; -import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentFromId; -import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; -import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; -import me.eccentric_nz.TARDIS.doors.DoorCloserAction; -import me.eccentric_nz.TARDIS.enumeration.ChameleonPreset; -import me.eccentric_nz.TARDIS.enumeration.TardisModule; -import me.eccentric_nz.TARDIS.utility.TARDISNumberParsers; -import me.eccentric_nz.TARDIS.utility.TARDISSounds; -import me.eccentric_nz.TARDIS.utility.TARDISStaticLocationGetters; -import me.eccentric_nz.TARDIS.utility.TARDISStaticUtils; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Tag; -import org.bukkit.World; import org.bukkit.block.Block; -import org.bukkit.block.Sign; -import org.bukkit.block.sign.Side; -import org.bukkit.block.sign.SignSide; -import org.bukkit.entity.Creeper; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -51,8 +29,6 @@ import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; import java.util.HashMap; @@ -106,189 +82,7 @@ public void onCapacitorInteract(PlayerInteractEvent event) { if (rsc.resultSet()) { int id = rsc.getTardis_id(); if (action == Action.RIGHT_CLICK_BLOCK) { - // get tardis data - HashMap wheret = new HashMap<>(); - wheret.put("tardis_id", id); - ResultSetTardis rs = new ResultSetTardis(plugin, wheret, "", false, 2); - if (rs.resultSet()) { - Tardis tardis = rs.getTardis(); - if (tardis.getPreset().equals(ChameleonPreset.JUNK)) { - return; - } - boolean abandoned = tardis.isAbandoned(); - HashMap whereid = new HashMap<>(); - whereid.put("tardis_id", id); - int current_level = tardis.getArtronLevel(); - boolean init = tardis.isTardisInit(); - boolean lights = tardis.isLightsOn(); - int fc = plugin.getArtronConfig().getInt("full_charge"); - Material item = player.getInventory().getItemInMainHand().getType(); - Material full = Material.valueOf(plugin.getArtronConfig().getString("full_charge_item")); - Material cell = plugin.getFigura().getShapedRecipes().get("Artron Storage Cell").getResult().getType(); - // determine key item - ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, player.getUniqueId().toString()); - String key; - boolean hasPrefs = false; - if (rsp.resultSet()) { - hasPrefs = true; - key = (!rsp.getKey().isEmpty()) ? rsp.getKey() : plugin.getConfig().getString("preferences.key"); - } else { - key = plugin.getConfig().getString("preferences.key"); - } - if (item.equals(full) || item.equals(cell)) { - if (!init) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NO_INIT"); - return; - } - int amount = 0; - if (item.equals(full)) { - if (plugin.getConfig().getBoolean("preferences.no_creative_condense")) { - switch (plugin.getWorldManager()) { - case MULTIVERSE -> { - if (!plugin.getMVHelper().isWorldSurvival(block.getLocation().getWorld())) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "ARTRON_FULL_CREATIVE"); - return; - } - } - case NONE -> { - if (plugin.getPlanetsConfig().getString("planets." + block.getLocation().getWorld().getName() + ".gamemode").equalsIgnoreCase("CREATIVE")) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "ARTRON_FULL_CREATIVE"); - return; - } - } - } - } - // remove the NETHER_STAR! (if appropriate) - int a = player.getInventory().getItemInMainHand().getAmount(); - int a2 = a - 1; - if (current_level < fc) { - // There's room in the tank! - amount = fc; - if (a2 > 0) { - player.getInventory().getItemInMainHand().setAmount(a2); - } else { - player.getInventory().removeItem(new ItemStack(full, 1)); - } - plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_AT_MAX"); - } else { - // We're either full or exceeding maximum, so don't do anything! - amount = current_level; - plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_MAX"); - } - } else { - ItemStack is = player.getInventory().getItemInMainHand(); - if (is.hasItemMeta()) { - ItemMeta im = is.getItemMeta(); - String name = im.getDisplayName(); - if (!name.equals("Artron Storage Cell")) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "CELL_NOT_VALID"); - return; - } - List lore = im.getLore(); - int charge = TARDISNumberParsers.parseInt(lore.get(1)) * is.getAmount(); - if (charge <= 0) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "CELL_NOT_CHARGED"); - return; - } - amount = current_level + charge; - lore.set(1, "0"); - im.setLore(lore); - is.setItemMeta(im); - is.getEnchantments().keySet().forEach(is::removeEnchantment); - plugin.getMessenger().send(player, TardisModule.TARDIS, "CELL_TRANSFER"); - } - } - // update charge - HashMap set = new HashMap<>(); - set.put("artron_level", amount); - plugin.getQueryFactory().doUpdate("tardis", set, whereid); - } else if (item.equals(Material.getMaterial(key))) { - // has the TARDIS been initialised? - if (!init) { - // kickstart the TARDIS Artron Energy Capacitor - TARDISSounds.playTARDISSound(block.getLocation(), "power_up"); - if (abandoned) { - // transfer ownership to the player who clicked - claimAbandoned(player, id, block, tardis); - } - // get locations from database - String creeper = tardis.getCreeper(); - if (!creeper.isEmpty() && !creeper.equals(":")) { - World w = block.getLocation().getWorld(); - Location cl = TARDISStaticLocationGetters.getLocationFromDB(creeper); - plugin.setTardisSpawn(true); - Entity e = w.spawnEntity(cl.add(0.0d, 1.0d, 0.0d), EntityType.CREEPER); - Creeper c = (Creeper) e; - c.setPowered(true); - c.setRemoveWhenFarAway(false); - if (tardis.getSchematic().hasBeacon()) { - String beacon = tardis.getBeacon(); - Block bl = TARDISStaticLocationGetters.getLocationFromDB(beacon).getBlock(); - bl.setBlockData(TARDISConstants.GLASS); - } - } - // set the capacitor to 50% charge - HashMap set = new HashMap<>(); - int half = Math.round(fc / 2.0F); - set.put("artron_level", half); - set.put("tardis_init", 1); - set.put("powered_on", 1); - plugin.getQueryFactory().doUpdate("tardis", set, whereid); - plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_INIT"); - } else { // toggle power - if (plugin.getConfig().getBoolean("allow.power_down")) { - boolean pu = true; - if (abandoned) { - // transfer ownership to the player who clicked - pu = claimAbandoned(player, id, block, tardis); - } - if (pu) { - new TARDISPowerButton(plugin, id, player, tardis.getPreset(), tardis.isPoweredOn(), tardis.isHidden(), lights, player.getLocation(), current_level, tardis.getSchematic().getLights()).clickButton(); - } - } - } - } else if (player.isSneaking()) { - if (!init) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NO_INIT"); - return; - } - // transfer player artron energy into the capacitor - int ten_percent = Math.round(fc * 0.1F); - if (current_level >= ten_percent && plugin.getConfig().getBoolean("creation.create_worlds")) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_UNDER_10"); - return; - } - if (hasPrefs) { - int level = rsp.getArtronLevel(); - if (level < 1) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NONE"); - return; - } - int new_level = current_level + level; - // set player level to 0 - HashMap set = new HashMap<>(); - set.put("artron_level", 0); - HashMap wherel = new HashMap<>(); - wherel.put("uuid", player.getUniqueId().toString()); - plugin.getQueryFactory().doUpdate("player_prefs", set, wherel); - // add player level to TARDIS level - HashMap sett = new HashMap<>(); - sett.put("artron_level", new_level); - plugin.getQueryFactory().doUpdate("tardis", sett, whereid); - int percent = Math.round((new_level * 100F) / fc); - plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_CHARGED", String.format("%d", percent)); - } else { - plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NONE"); - } - } else { - if (!init) { - plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NO_INIT"); - return; - } - // just tell us how much energy we have - plugin.getMessenger().sendArtron(player, id, 0); - } - } + new ArtronRightClick(plugin).process(id, player, block.getLocation()); } else if (action == Action.LEFT_CLICK_BLOCK && player.isSneaking()) { event.setCancelled(true); // check if the charged creeper in the TARDIS Artron Energy Capacitor is still there @@ -298,43 +92,4 @@ public void onCapacitorInteract(PlayerInteractEvent event) { } } } - - private boolean claimAbandoned(Player player, int id, Block block, Tardis tardis) { - // transfer ownership to the player who clicked - boolean pu = plugin.getQueryFactory().claimTARDIS(player, id); - // make sure player is added as owner of interior WorldGuard region - if (plugin.isWorldGuardOnServer() && plugin.getConfig().getBoolean("preferences.use_worldguard")) { - plugin.getWorldGuardUtils().updateRegionForClaim(block.getLocation(), player.getUniqueId()); - } - ResultSetCurrentFromId rscl = new ResultSetCurrentFromId(plugin, id); - if (rscl.resultSet()) { - Location current = new Location(rscl.getWorld(), rscl.getX(), rscl.getY(), rscl.getZ()); - if (pu) { - new DoorCloserAction(plugin, player.getUniqueId(), id).closeDoors(); - plugin.getMessenger().send(player, TardisModule.TARDIS, "ABANDON_CLAIMED"); - plugin.getPM().callEvent(new TARDISClaimEvent(player, tardis, current)); - } - if (plugin.getConfig().getBoolean("police_box.name_tardis")) { - ChameleonPreset preset = tardis.getPreset(); - Sign sign = TARDISAbandonCommand.getSign(current, rscl.getDirection(), preset); - if (sign != null) { - SignSide front = sign.getSide(Side.FRONT); - String player_name = TARDISStaticUtils.getNick(player); - String owner; - if (preset.equals(ChameleonPreset.GRAVESTONE) || preset.equals(ChameleonPreset.PUNKED) || preset.equals(ChameleonPreset.ROBOT)) { - owner = (player_name.length() > 14) ? player_name.substring(0, 14) : player_name; - } else { - owner = (player_name.length() > 14) ? player_name.substring(0, 12) + "'s" : player_name + "'s"; - } - switch (preset) { - case GRAVESTONE -> front.setLine(3, owner); - case ANGEL, JAIL -> front.setLine(2, owner); - default -> front.setLine(0, owner); - } - sign.update(); - } - } - } - return pu; - } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronInteraction.java index 4b98ffef1..3ab4e4ce3 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronInteraction.java @@ -23,6 +23,6 @@ public void show(int id, Player player, Interaction interaction) { ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(uuid); new ButtonModel().setState(display, plugin); } - plugin.getMessenger().sendArtron(player, id, 0); + new ArtronRightClick(plugin).process(id, player, interaction.getLocation()); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronRightClick.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronRightClick.java new file mode 100644 index 000000000..6c5aa2e90 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronRightClick.java @@ -0,0 +1,93 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.artron.ArtronAbandoned; +import me.eccentric_nz.TARDIS.artron.ArtronChargeAction; +import me.eccentric_nz.TARDIS.artron.ArtronInitAction; +import me.eccentric_nz.TARDIS.artron.ArtronTransferAction; +import me.eccentric_nz.TARDIS.control.TARDISPowerButton; +import me.eccentric_nz.TARDIS.database.data.Tardis; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; +import me.eccentric_nz.TARDIS.enumeration.ChameleonPreset; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.util.HashMap; + +public class ArtronRightClick { + + private final TARDIS plugin; + + public ArtronRightClick(TARDIS plugin) { + this.plugin = plugin; + } + + public void process(int id, Player player, Location location) { + // get tardis data + HashMap wheret = new HashMap<>(); + wheret.put("tardis_id", id); + ResultSetTardis rs = new ResultSetTardis(plugin, wheret, "", false, 2); + if (rs.resultSet()) { + Tardis tardis = rs.getTardis(); + if (tardis.getPreset().equals(ChameleonPreset.JUNK)) { + return; + } + boolean abandoned = tardis.isAbandoned(); + int current_level = tardis.getArtronLevel(); + boolean init = tardis.isTardisInit(); + boolean lights = tardis.isLightsOn(); + Material item = player.getInventory().getItemInMainHand().getType(); + Material full = Material.valueOf(plugin.getArtronConfig().getString("full_charge_item")); + Material cell = plugin.getFigura().getShapedRecipes().get("Artron Storage Cell").getResult().getType(); + // determine key item + ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, player.getUniqueId().toString()); + String key; + boolean hasPrefs = false; + if (rsp.resultSet()) { + hasPrefs = true; + key = (!rsp.getKey().isEmpty()) ? rsp.getKey() : plugin.getConfig().getString("preferences.key"); + } else { + key = plugin.getConfig().getString("preferences.key"); + } + if (item.equals(full) || item.equals(cell)) { + if (!init) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NO_INIT"); + return; + } + new ArtronChargeAction(plugin).add(player, item, full, location, current_level, id); + } else if (item.equals(Material.getMaterial(key))) { + // has the TARDIS been initialised? + if (!init) { + new ArtronInitAction(plugin).powerUp(location, tardis, player, id); + } else { // toggle power + if (plugin.getConfig().getBoolean("allow.power_down")) { + boolean pu = true; + if (abandoned) { + // transfer ownership to the player who clicked + pu = new ArtronAbandoned(plugin).claim(player, id, location, tardis); + } + if (pu) { + new TARDISPowerButton(plugin, id, player, tardis.getPreset(), tardis.isPoweredOn(), tardis.isHidden(), lights, player.getLocation(), current_level, tardis.getSchematic().getLights()).clickButton(); + } + } + } + } else if (player.isSneaking()) { + if (!init) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NO_INIT"); + return; + } + new ArtronTransferAction(plugin).add(current_level, rsp.getArtronLevel(), player, id, hasPrefs); + } else { + if (!init) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "ENERGY_NO_INIT"); + return; + } + // just tell us how much energy we have + plugin.getMessenger().sendArtron(player, id, 0); + } + } + } +} From 18e2564de658154b6baee352f96f914805049787 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Wed, 24 Apr 2024 14:43:40 +1200 Subject: [PATCH 43/96] Initial update for 1.20.5 --- pom.xml | 22 ++++----- .../eccentric_nz/TARDIS/TARDISConstants.java | 4 +- .../me/eccentric_nz/TARDIS/api/TARDII.java | 46 +++++++++---------- .../artron/TARDISArtronFurnaceListener.java | 2 +- .../artron/TARDISArtronFurnaceParticle.java | 2 +- .../artron/TARDISArtronStorageCommand.java | 2 +- .../TARDIS/builders/TARDISBuildAbandoned.java | 2 +- .../TARDIS/builders/TARDISBuilderInner.java | 2 +- .../TARDIS/camera/TARDISDismountListener.java | 2 +- .../utils/TARDISStainedGlassLookup.java | 4 +- .../commands/give/TARDISGiveCommand.java | 2 +- .../handles/TARDISHandlesScanCommand.java | 31 +++++++------ .../control/TARDISAtmosphericExcitation.java | 5 +- .../TARDIS/control/TARDISScanner.java | 24 +++++----- .../desktop/TARDISFullThemeRunnable.java | 6 +-- .../desktop/TARDISThemeRepairRunnable.java | 4 +- .../TARDIS/flight/FlightVisibility.java | 6 +-- .../flight/TARDISMaterialseFromVortex.java | 2 +- .../FloodgateGeneticManipulatorForm.java | 9 ++-- .../TARDISForceFieldVisualiser.java | 16 +++---- .../lazarus/TARDISLazarusGUIListener.java | 4 +- .../TARDIS/listeners/TARDISCraftListener.java | 2 +- .../TARDIS/listeners/TARDISEjectListener.java | 4 +- .../TARDIS/messaging/SpigotMessage.java | 2 +- .../TARDIS/mobfarming/TARDISFarmer.java | 4 +- .../TARDIS/planets/TARDISAcidWater.java | 9 ++-- .../TARDISInvisibilityCircuitRecipe.java | 4 +- .../shaped/TARDISTelepathicCircuitRecipe.java | 4 +- .../rooms/library/EnchantmentShelf.java | 38 +++++++-------- .../TARDIS/sonic/TARDISSonicDock.java | 2 +- .../sonic/actions/TARDISSonicIgnite.java | 2 +- .../sonic/actions/TARDISSonicScanner.java | 31 +++++++------ .../sonic/actions/TARDISSonicSound.java | 2 +- .../TARDIS/utility/RecipeChecker.java | 43 ----------------- .../TARDIS/utility/TARDISEntityTracker.java | 11 +++-- .../TARDIS/utility/TARDISParticles.java | 2 +- .../lab/CureBrewingListener.java | 28 ++++++----- .../product/BalloonListener.java | 12 ++--- .../product/SparklerRunnable.java | 2 +- .../tardischunkgenerator/TARDISHelper.java | 11 +++-- .../custombiome/BiomeHelper.java | 12 ++--- .../custombiome/CustomBiome.java | 14 +++--- .../disguise/TARDISArmourStandDisguiser.java | 2 +- .../TARDISChameleonArchDisguiser.java | 2 +- .../disguise/TARDISDisguise.java | 19 ++++---- .../disguise/TARDISDisguiser.java | 2 +- .../disguise/TARDISEPSDisguiser.java | 8 ++-- .../disguise/TARDISPlayerDisguiser.java | 2 +- .../helpers/GetBlockColours.java | 2 +- .../helpers/Shrieker.java | 4 +- .../helpers/TARDISItemFrameFaker.java | 6 +-- .../helpers/TARDISMapUpdater.java | 4 +- .../helpers/TARDISPacketListener.java | 6 +-- .../worldgen/feature/CustomTree.java | 4 +- .../worldgen/feature/TreePlacer.java | 2 +- .../populators/GallifreyGrassPopulator.java | 2 +- .../commands/FollowCommand.java | 2 +- .../commands/StayCommand.java | 2 +- .../tardisweepingangels/death/Death.java | 7 ++- .../monsters/daleks/DalekEquipment.java | 2 +- .../empty_child/EmptyChildEquipment.java | 2 +- .../monsters/judoon/JudoonGuardRunnable.java | 2 +- .../monsters/judoon/JudoonListener.java | 2 +- .../monsters/ood/OodEquipment.java | 2 +- .../monsters/ood/OodListener.java | 2 +- .../monsters/toclafane/ToclafaneListener.java | 2 +- .../monsters/weeping_angels/Blink.java | 7 +-- .../monsters/weeping_angels/Damage.java | 2 +- .../nms/FollowPathFinder.java | 14 +++--- .../nms/FollowerSaver.java | 2 +- .../nms/MonsterSpawner.java | 2 +- .../tardisweepingangels/nms/TWADrowned.java | 13 ++++-- .../tardisweepingangels/nms/TWAFollower.java | 9 ++-- .../tardisweepingangels/nms/TWAJudoon.java | 13 ++++-- .../tardisweepingangels/nms/TWAK9.java | 13 ++++-- .../tardisweepingangels/nms/TWAOod.java | 12 +++-- .../nms/TWAPiglinBrute.java | 13 ++++-- .../tardisweepingangels/nms/TWASkeleton.java | 13 ++++-- .../tardisweepingangels/nms/TWAZombie.java | 13 ++++-- .../nms/TWAZombifiedPiglin.java | 13 ++++-- .../utils/ChunkListener.java | 2 +- .../tardisweepingangels/utils/Follow.java | 2 +- .../utils/FollowerChecker.java | 2 +- .../utils/MonsterInteractListener.java | 4 +- .../utils/MonsterLoadUnloadListener.java | 2 +- .../utils/ResetMonster.java | 2 +- src/main/resources/plugin.yml | 2 +- 87 files changed, 344 insertions(+), 337 deletions(-) delete mode 100644 src/main/java/me/eccentric_nz/TARDIS/utility/RecipeChecker.java diff --git a/pom.xml b/pom.xml index 4d551b6f6..bffbfe209 100644 --- a/pom.xml +++ b/pom.xml @@ -163,9 +163,9 @@ remap-obf - org.spigotmc:minecraft-server:1.20.4-R0.1-SNAPSHOT:txt:maps-mojang + org.spigotmc:minecraft-server:1.20.5-R0.1-SNAPSHOT:txt:maps-mojang true - org.spigotmc:spigot:1.20.4-R0.1-SNAPSHOT:jar:remapped-mojang + org.spigotmc:spigot:1.20.5-R0.1-SNAPSHOT:jar:remapped-mojang true remapped-obf @@ -181,8 +181,8 @@ ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.20.4-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.20.4-R0.1-SNAPSHOT:jar:remapped-obf + org.spigotmc:minecraft-server:1.20.5-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.20.5-R0.1-SNAPSHOT:jar:remapped-obf @@ -246,6 +246,13 @@ + + org.spigotmc + spigot + 1.20.5-R0.1-SNAPSHOT + remapped-mojang + provided + io.papermc.paper paper-api @@ -270,13 +277,6 @@ - - org.spigotmc - spigot - 1.20.4-R0.1-SNAPSHOT - remapped-mojang - provided - io.papermc paperlib diff --git a/src/main/java/me/eccentric_nz/TARDIS/TARDISConstants.java b/src/main/java/me/eccentric_nz/TARDIS/TARDISConstants.java index 356ecd0b6..94ba967bc 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/TARDISConstants.java +++ b/src/main/java/me/eccentric_nz/TARDIS/TARDISConstants.java @@ -124,10 +124,10 @@ public class TARDISConstants { EntityType.DROWNED, EntityType.ELDER_GUARDIAN, EntityType.ENDERMAN, EntityType.ENDERMITE, EntityType.EVOKER, EntityType.FOX, EntityType.FROG, EntityType.GHAST, EntityType.GIANT, EntityType.GLOW_SQUID, EntityType.GOAT, EntityType.GUARDIAN, EntityType.HOGLIN, EntityType.HORSE, EntityType.HUSK, EntityType.ILLUSIONER, EntityType.IRON_GOLEM, EntityType.LLAMA, EntityType.MAGMA_CUBE, EntityType.MULE, - EntityType.MUSHROOM_COW, EntityType.OCELOT, EntityType.PANDA, EntityType.PARROT, EntityType.PHANTOM, EntityType.PIG, EntityType.PIGLIN, + EntityType.MOOSHROOM, EntityType.OCELOT, EntityType.PANDA, EntityType.PARROT, EntityType.PHANTOM, EntityType.PIG, EntityType.PIGLIN, EntityType.PIGLIN_BRUTE, EntityType.PILLAGER, EntityType.PLAYER, EntityType.POLAR_BEAR, EntityType.PUFFERFISH, EntityType.RABBIT, EntityType.RAVAGER, EntityType.SALMON, EntityType.SHEEP, EntityType.SHULKER, EntityType.SILVERFISH, EntityType.SKELETON, - EntityType.SKELETON_HORSE, EntityType.SLIME, EntityType.SNIFFER, EntityType.SNOWMAN, EntityType.SPIDER, EntityType.SQUID, EntityType.STRAY, + EntityType.SKELETON_HORSE, EntityType.SLIME, EntityType.SNIFFER, EntityType.SNOW_GOLEM, EntityType.SPIDER, EntityType.SQUID, EntityType.STRAY, EntityType.STRIDER, EntityType.TADPOLE, EntityType.TRADER_LLAMA, EntityType.TROPICAL_FISH, EntityType.TURTLE, EntityType.VEX, EntityType.VILLAGER, EntityType.VINDICATOR, EntityType.WANDERING_TRADER, EntityType.WARDEN, EntityType.WITCH, EntityType.WITHER, EntityType.WITHER_SKELETON, EntityType.WOLF, EntityType.ZOGLIN, EntityType.ZOMBIE, EntityType.ZOMBIE_HORSE, EntityType.ZOMBIE_VILLAGER, EntityType.ZOMBIFIED_PIGLIN diff --git a/src/main/java/me/eccentric_nz/TARDIS/api/TARDII.java b/src/main/java/me/eccentric_nz/TARDIS/api/TARDII.java index 625e0ee05..8152d3865 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/api/TARDII.java +++ b/src/main/java/me/eccentric_nz/TARDIS/api/TARDII.java @@ -56,7 +56,7 @@ import me.eccentric_nz.tardisweepingangels.utils.Monster; import org.bukkit.*; import org.bukkit.World.Environment; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -181,28 +181,6 @@ public TARDISData getTARDISMapData(int id) { return data; } - @Override - public Location getRandomLocation(List worlds, Environment environment, Parameters param) { - if (environment == null) { - // choose random environment - weighted towards normal! - environment = weightedChoice.next(); - // check if environment is enabled - if ((environment.equals(Environment.NETHER) && !TARDIS.plugin.getConfig().getBoolean("travel.nether")) || (environment.equals(Environment.THE_END) && !TARDIS.plugin.getConfig().getBoolean("travel.the_end"))) { - environment = Environment.NORMAL; - } - } - return switch (environment) { - case NETHER -> new TARDISRandomNether(TARDIS.plugin, worlds, param).getlocation(); - case THE_END -> new TARDISRandomTheEnd(TARDIS.plugin, worlds, param).getlocation(); - default -> new TARDISRandomOverworld(TARDIS.plugin, worlds, param).getlocation(); - }; - } - - @Override - public Location getRandomLocation(List worlds, Environment environment, Player p) { - return getRandomLocation(getWorlds(), null, new Parameters(p, Flag.getAPIFlags())); - } - @Override public Location getRandomLocation(List worlds, Player p) { return getRandomLocation(getWorlds(), null, new Parameters(p, Flag.getAPIFlags())); @@ -1024,4 +1002,26 @@ public ItemStack getHead(Monster monster) { public ItemStack getK9() { return HeadBuilder.getK9(); } + + @Override + public Location getRandomLocation(List worlds, Environment environment, Parameters param) { + if (environment == null) { + // choose random environment - weighted towards normal! + environment = weightedChoice.next(); + // check if environment is enabled + if ((environment.equals(Environment.NETHER) && !TARDIS.plugin.getConfig().getBoolean("travel.nether")) || (environment.equals(Environment.THE_END) && !TARDIS.plugin.getConfig().getBoolean("travel.the_end"))) { + environment = Environment.NORMAL; + } + } + return switch (environment) { + case NETHER -> new TARDISRandomNether(TARDIS.plugin, worlds, param).getlocation(); + case THE_END -> new TARDISRandomTheEnd(TARDIS.plugin, worlds, param).getlocation(); + default -> new TARDISRandomOverworld(TARDIS.plugin, worlds, param).getlocation(); + }; + } + + @Override + public Location getRandomLocation(List worlds, Environment environment, Player p) { + return getRandomLocation(getWorlds(), null, new Parameters(p, Flag.getAPIFlags())); + } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronFurnaceListener.java b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronFurnaceListener.java index ebe9c32b9..2479643ff 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronFurnaceListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronFurnaceListener.java @@ -87,7 +87,7 @@ public void onArtronFurnaceBurn(FurnaceBurnEvent event) { lore.set(1, "0"); im.setLore(lore); is.setItemMeta(im); - is.removeEnchantment(Enchantment.DURABILITY); + is.removeEnchantment(Enchantment.UNBREAKING); furnace.getInventory().setItem(1, is); }, 2L); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronFurnaceParticle.java b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronFurnaceParticle.java index 0f7f3c142..258a97a08 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronFurnaceParticle.java +++ b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronFurnaceParticle.java @@ -44,7 +44,7 @@ public void addParticles() { for (int z = 0; z < 16; z++) { Block block = world.getBlockAt(sx + x, sy + y, sz + z); if (isArtronFurnace(block)) { - player.spawnParticle(Particle.WATER_SPLASH, block.getLocation().add(0.5d, 1.0d, 0.5d), 10); + player.spawnParticle(Particle.SPLASH, block.getLocation().add(0.5d, 1.0d, 0.5d), 10); } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronStorageCommand.java b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronStorageCommand.java index 29f43cb20..3638e0c04 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronStorageCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/artron/TARDISArtronStorageCommand.java @@ -139,7 +139,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String } lore.set(1, "" + new_amount); im.setLore(lore); - im.addEnchant(Enchantment.DURABILITY, 1, true); + im.addEnchant(Enchantment.UNBREAKING, 1, true); im.addItemFlags(ItemFlag.values()); is.setItemMeta(im); // remove the energy from the tardis/timelord diff --git a/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuildAbandoned.java b/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuildAbandoned.java index e1f014264..54ba2abc7 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuildAbandoned.java +++ b/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuildAbandoned.java @@ -235,7 +235,7 @@ public void run() { plugin.getWorldGuardUtils().addWGProtection(randomUUID, randomUUID.toString(), pos, world); } if (ender != null) { - Entity ender_crystal = world.spawnEntity(ender, EntityType.ENDER_CRYSTAL); + Entity ender_crystal = world.spawnEntity(ender, EntityType.END_CRYSTAL); ((EnderCrystal) ender_crystal).setShowingBottom(false); } if (obj.has("paintings")) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuilderInner.java b/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuilderInner.java index 014c79d9a..a1d5b1f31 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuilderInner.java +++ b/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuilderInner.java @@ -283,7 +283,7 @@ public void run() { } } if (ender != null) { - Entity ender_crystal = world.spawnEntity(ender, EntityType.ENDER_CRYSTAL); + Entity ender_crystal = world.spawnEntity(ender, EntityType.END_CRYSTAL); ((EnderCrystal) ender_crystal).setShowingBottom(false); } if (obj.has("paintings")) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/camera/TARDISDismountListener.java b/src/main/java/me/eccentric_nz/TARDIS/camera/TARDISDismountListener.java index 8683b4103..9c047f6e2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/camera/TARDISDismountListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/camera/TARDISDismountListener.java @@ -8,8 +8,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDismountEvent; import org.bukkit.persistence.PersistentDataType; -import org.spigotmc.event.entity.EntityDismountEvent; public class TARDISDismountListener implements Listener { diff --git a/src/main/java/me/eccentric_nz/TARDIS/chameleon/utils/TARDISStainedGlassLookup.java b/src/main/java/me/eccentric_nz/TARDIS/chameleon/utils/TARDISStainedGlassLookup.java index 60012818b..a39f54539 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/chameleon/utils/TARDISStainedGlassLookup.java +++ b/src/main/java/me/eccentric_nz/TARDIS/chameleon/utils/TARDISStainedGlassLookup.java @@ -21,8 +21,8 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.material.MapColor; import org.bukkit.*; -import org.bukkit.craftbukkit.v1_20_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_20_R3.util.CraftMagicNumbers; +import org.bukkit.craftbukkit.v1_20_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R4.util.CraftMagicNumbers; /** * Lookup for Chameleon preset block materialisation. diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISGiveCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISGiveCommand.java index b54811faf..c1a445fe8 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISGiveCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISGiveCommand.java @@ -512,7 +512,7 @@ private void giveFullCell(CommandSender sender, int amount, Player player) { int max = plugin.getArtronConfig().getInt("full_charge"); lore.set(1, "" + max); im.setLore(lore); - im.addEnchant(Enchantment.DURABILITY, 1, true); + im.addEnchant(Enchantment.UNBREAKING, 1, true); im.addItemFlags(ItemFlag.values()); result.setItemMeta(im); player.getInventory().addItem(result); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesScanCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesScanCommand.java index 2643dd373..328dcf197 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesScanCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/handles/TARDISHandlesScanCommand.java @@ -16,9 +16,6 @@ */ package me.eccentric_nz.TARDIS.commands.handles; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISConstants; import me.eccentric_nz.TARDIS.advanced.TARDISCircuitChecker; @@ -38,6 +35,10 @@ import org.bukkit.inventory.EntityEquipment; import org.bukkit.scheduler.BukkitScheduler; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + /** * @author eccentric_nz */ @@ -108,15 +109,15 @@ boolean sayScan() { if (ee.getHelmet() != null) { switch (ee.getHelmet().getType()) { case BAKED_POTATO -> et = EntityType.EGG; // Strax - case BOOK -> et = EntityType.ENDER_CRYSTAL; // Vashta Nerada + case BOOK -> et = EntityType.END_CRYSTAL; // Vashta Nerada case CRIMSON_BUTTON -> et = EntityType.BLOCK_DISPLAY; // davros case FEATHER -> et = EntityType.BOAT; // Silurian case IRON_INGOT -> et = EntityType.AREA_EFFECT_CLOUD; // Cyberman - case KELP -> et = EntityType.THROWN_EXP_BOTTLE; // sea devil + case KELP -> et = EntityType.EXPERIENCE_BOTTLE; // sea devil case MANGROVE_PROPAGULE -> et = EntityType.SMALL_FIREBALL; // dalek sec case NETHERITE_SCRAP -> et = EntityType.GLOW_ITEM_FRAME; // mire - case PAINTING -> et = EntityType.FISHING_HOOK; // Zygon - case POTATO -> et = EntityType.FIREWORK; // Sontaran + case PAINTING -> et = EntityType.FISHING_BOBBER; // Zygon + case POTATO -> et = EntityType.FIREWORK_ROCKET; // Sontaran case PUFFERFISH -> et = EntityType.INTERACTION; // hath case RED_CANDLE -> et = EntityType.TEXT_DISPLAY; // headless monk case SLIME_BALL -> et = EntityType.LLAMA_SPIT; // dalek @@ -131,7 +132,7 @@ boolean sayScan() { } if (et.equals(EntityType.ENDERMAN) && !k.getPassengers().isEmpty() && k.getPassengers().get(0) != null && k.getPassengers().get(0).getType().equals(EntityType.GUARDIAN)) { // silent - et = EntityType.SPLASH_POTION; + et = EntityType.POTION; } if (et.equals(EntityType.ARMOR_STAND)) { EntityEquipment ee = ((ArmorStand) k).getEquipment(); @@ -140,7 +141,7 @@ boolean sayScan() { case YELLOW_DYE -> et = EntityType.SHULKER_BULLET; // Judoon case BONE -> et = EntityType.EVOKER_FANGS; // K9 case ROTTEN_FLESH -> et = EntityType.ITEM_FRAME; // Ood - case GUNPOWDER -> et = EntityType.DROPPED_ITEM; // Toclafane + case GUNPOWDER -> et = EntityType.ITEM; // Toclafane default -> { } } } @@ -202,13 +203,13 @@ boolean sayScan() { case BLOCK_DISPLAY -> player.sendMessage(" Davros: " + value); case BOAT -> player.sendMessage(" Silurian: " + value); case DRAGON_FIREBALL -> player.sendMessage(" Weeping Angel: " + value); - case DROPPED_ITEM -> player.sendMessage(" Toclafane: " + value); + case ITEM -> player.sendMessage(" Toclafane: " + value); case EGG -> player.sendMessage(" Strax: " + value); - case ENDER_CRYSTAL -> player.sendMessage(" Vashta Nerada: " + value); + case END_CRYSTAL -> player.sendMessage(" Vashta Nerada: " + value); case EVOKER_FANGS -> player.sendMessage(" K9: " + value); case FALLING_BLOCK -> player.sendMessage(" Empty Child: " + value); - case FIREWORK -> player.sendMessage(" Sontaran: " + value); - case FISHING_HOOK -> player.sendMessage(" Zygon: " + value); + case FIREWORK_ROCKET -> player.sendMessage(" Sontaran: " + value); + case FISHING_BOBBER -> player.sendMessage(" Zygon: " + value); case GLOW_ITEM_FRAME -> player.sendMessage(" Mire: " + value); case INTERACTION -> player.sendMessage(" Hath: " + value); case ITEM_DISPLAY -> player.sendMessage(" Racnoss: " + value); @@ -217,9 +218,9 @@ boolean sayScan() { case SHULKER_BULLET -> player.sendMessage(" Judoon: " + value); case SMALL_FIREBALL -> player.sendMessage(" Dalek Sec: " + value); case SNOWBALL -> player.sendMessage(" Ice Warrior: " + value); - case SPLASH_POTION -> player.sendMessage(" Silent: " + value); + case POTION -> player.sendMessage(" Silent: " + value); case TEXT_DISPLAY -> player.sendMessage(" Headless Monk: " + value); - case THROWN_EXP_BOTTLE -> player.sendMessage(" Sea Devil: " + value); + case EXPERIENCE_BOTTLE -> player.sendMessage(" Sea Devil: " + value); default -> player.sendMessage(" " + ent + ": " + value + m); } }, 3L); diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISAtmosphericExcitation.java b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISAtmosphericExcitation.java index c88dd9dd2..a89c452b1 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISAtmosphericExcitation.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISAtmosphericExcitation.java @@ -16,7 +16,6 @@ */ package me.eccentric_nz.TARDIS.control; -import java.util.HashMap; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentLocation; import org.bukkit.Color; @@ -28,6 +27,8 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.meta.FireworkMeta; +import java.util.HashMap; + /** * @author eccentric_nz *

@@ -59,7 +60,7 @@ public void excite(int tid, Player p) { // get lamp block location l.add(0, 18, 0); // construct a firework effect and shoot it from lamp block location - Firework firework = (Firework) l.getWorld().spawnEntity(l, EntityType.FIREWORK); + Firework firework = (Firework) l.getWorld().spawnEntity(l, EntityType.FIREWORK_ROCKET); FireworkMeta fireworkMeta = firework.getFireworkMeta(); fireworkMeta.addEffect(FireworkEffect.builder() .flicker(false) diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISScanner.java b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISScanner.java index 9587ddd24..4607d5a0d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISScanner.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISScanner.java @@ -123,15 +123,15 @@ public TARDISScannerData getScannerData(Player player, int id, BukkitScheduler b if (ee.getHelmet() != null) { switch (ee.getHelmet().getType()) { case BAKED_POTATO -> et = EntityType.EGG; // Strax - case BOOK -> et = EntityType.ENDER_CRYSTAL; // Vashta Nerada + case BOOK -> et = EntityType.END_CRYSTAL; // Vashta Nerada case CRIMSON_BUTTON -> et = EntityType.BLOCK_DISPLAY; // davros case FEATHER -> et = EntityType.BOAT; // Silurian case IRON_INGOT -> et = EntityType.AREA_EFFECT_CLOUD; // Cyberman - case KELP -> et = EntityType.THROWN_EXP_BOTTLE; // sea devil + case KELP -> et = EntityType.EXPERIENCE_BOTTLE; // sea devil case MANGROVE_PROPAGULE -> et = EntityType.SMALL_FIREBALL; // dalek sec case NETHERITE_SCRAP -> et = EntityType.GLOW_ITEM_FRAME; // mire - case PAINTING -> et = EntityType.FISHING_HOOK; // Zygon - case POTATO -> et = EntityType.FIREWORK; // Sontaran + case PAINTING -> et = EntityType.FISHING_BOBBER; // Zygon + case POTATO -> et = EntityType.FIREWORK_ROCKET; // Sontaran case PUFFERFISH -> et = EntityType.INTERACTION; // hath case RED_CANDLE -> et = EntityType.TEXT_DISPLAY; // headless monk case SLIME_BALL -> et = EntityType.LLAMA_SPIT; // dalek @@ -147,7 +147,7 @@ public TARDISScannerData getScannerData(Player player, int id, BukkitScheduler b } if (et.equals(EntityType.ENDERMAN) && !k.getPassengers().isEmpty() && k.getPassengers().get(0) != null && k.getPassengers().get(0).getType().equals(EntityType.GUARDIAN)) { // silent - et = EntityType.SPLASH_POTION; + et = EntityType.POTION; } if (et.equals(EntityType.ARMOR_STAND)) { EntityEquipment ee = ((ArmorStand) k).getEquipment(); @@ -156,7 +156,7 @@ public TARDISScannerData getScannerData(Player player, int id, BukkitScheduler b case YELLOW_DYE -> et = EntityType.SHULKER_BULLET; // Judoon case BONE -> et = EntityType.EVOKER_FANGS; // K9 case ROTTEN_FLESH -> et = EntityType.ITEM_FRAME; // Ood - case GUNPOWDER -> et = EntityType.DROPPED_ITEM; // Toclafane + case GUNPOWDER -> et = EntityType.ITEM; // Toclafane default -> { } } @@ -245,13 +245,13 @@ public TARDISScannerData getScannerData(Player player, int id, BukkitScheduler b case BLOCK_DISPLAY -> player.sendMessage(" Davros: " + value); case BOAT -> player.sendMessage(" Silurian: " + value); case DRAGON_FIREBALL -> player.sendMessage(" Weeping Angel: " + value); - case DROPPED_ITEM -> player.sendMessage(" Toclafane: " + value); + case ITEM -> player.sendMessage(" Toclafane: " + value); case EGG -> player.sendMessage(" Strax: " + value); - case ENDER_CRYSTAL -> player.sendMessage(" Vashta Nerada: " + value); + case END_CRYSTAL -> player.sendMessage(" Vashta Nerada: " + value); case EVOKER_FANGS -> player.sendMessage(" K9: " + value); case FALLING_BLOCK -> player.sendMessage(" Empty Child: " + value); - case FIREWORK -> player.sendMessage(" Sontaran: " + value); - case FISHING_HOOK -> player.sendMessage(" Zygon: " + value); + case FIREWORK_ROCKET -> player.sendMessage(" Sontaran: " + value); + case FISHING_BOBBER -> player.sendMessage(" Zygon: " + value); case GLOW_ITEM_FRAME -> player.sendMessage(" Mire: " + value); case INTERACTION -> player.sendMessage(" Hath: " + value); case ITEM_DISPLAY -> player.sendMessage(" Racnoss: " + value); @@ -260,9 +260,9 @@ public TARDISScannerData getScannerData(Player player, int id, BukkitScheduler b case SHULKER_BULLET -> player.sendMessage(" Judoon: " + value); case SMALL_FIREBALL -> player.sendMessage(" Dalek Sec: " + value); case SNOWBALL -> player.sendMessage(" Ice Warrior: " + value); - case SPLASH_POTION -> player.sendMessage(" Silent: " + value); + case POTION -> player.sendMessage(" Silent: " + value); case TEXT_DISPLAY -> player.sendMessage(" Headless Monk: " + value); - case THROWN_EXP_BOTTLE -> player.sendMessage(" Sea Devil: " + value); + case EXPERIENCE_BOTTLE -> player.sendMessage(" Sea Devil: " + value); default -> { if (ent != EntityType.ARMOR_STAND) { player.sendMessage(" " + ent + ": " + value + message); diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java index 30296d984..a79f1e7d2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java @@ -26,7 +26,6 @@ import me.eccentric_nz.TARDIS.builders.FractalFence; import me.eccentric_nz.TARDIS.builders.TARDISInteriorPostioning; import me.eccentric_nz.TARDIS.builders.TARDISTIPSData; -import me.eccentric_nz.TARDIS.rotors.TARDISTimeRotor; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItem; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItemUtils; import me.eccentric_nz.TARDIS.database.data.Archive; @@ -40,6 +39,7 @@ import me.eccentric_nz.TARDIS.floodgate.TARDISFloodgateDisplaySetter; import me.eccentric_nz.TARDIS.mobfarming.TARDISFollowerSpawner; import me.eccentric_nz.TARDIS.rooms.TARDISPainting; +import me.eccentric_nz.TARDIS.rotors.TARDISTimeRotor; import me.eccentric_nz.TARDIS.schematic.ArchiveReset; import me.eccentric_nz.TARDIS.schematic.ResultSetArchive; import me.eccentric_nz.TARDIS.schematic.TARDISSchematicGZip; @@ -218,7 +218,7 @@ public void run() { if (tud.getPrevious().getPermission().equals("ender")) { // remove ender crystal for (Entity entity : chunk.getEntities()) { - if (entity.getType().equals(EntityType.ENDER_CRYSTAL)) { + if (entity.getType().equals(EntityType.END_CRYSTAL)) { entity.remove(); } } @@ -410,7 +410,7 @@ public void run() { } } if (ender != null) { - Entity ender_crystal = world.spawnEntity(ender, EntityType.ENDER_CRYSTAL); + Entity ender_crystal = world.spawnEntity(ender, EntityType.END_CRYSTAL); ((EnderCrystal) ender_crystal).setShowingBottom(false); } if (obj.has("paintings")) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java index 9eae7cf05..592276ba7 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java @@ -163,7 +163,7 @@ public void run() { if (tud.getPrevious().getPermission().equals("ender")) { // remove ender crystal for (Entity entity : chunk.getEntities()) { - if (entity.getType().equals(EntityType.ENDER_CRYSTAL)) { + if (entity.getType().equals(EntityType.END_CRYSTAL)) { entity.remove(); } } @@ -312,7 +312,7 @@ public void run() { } } if (ender != null) { - Entity ender_crystal = world.spawnEntity(ender, EntityType.ENDER_CRYSTAL); + Entity ender_crystal = world.spawnEntity(ender, EntityType.END_CRYSTAL); ((EnderCrystal) ender_crystal).setShowingBottom(false); } if (obj.has("paintings")) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/FlightVisibility.java b/src/main/java/me/eccentric_nz/TARDIS/flight/FlightVisibility.java index 1b0d7cc0f..a4fe72dea 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/FlightVisibility.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/FlightVisibility.java @@ -8,8 +8,8 @@ import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.world.entity.EquipmentSlot; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -82,4 +82,4 @@ public void show(Player player) { } } } -} \ No newline at end of file +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISMaterialseFromVortex.java b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISMaterialseFromVortex.java index 7b50cf7c0..2d917e65b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISMaterialseFromVortex.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISMaterialseFromVortex.java @@ -120,7 +120,7 @@ public void run() { TARDISSounds.playTARDISSound(handbrake, "tardis_malfunction"); } // add a potion effect to the player - player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 150, 5)); + player.addPotionEffect(new PotionEffect(PotionEffectType.NAUSEA, 150, 5)); long cloister_delay = (plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) ? 262L : 360L; Location location = exit; scheduler.scheduleSyncDelayedTask(plugin, () -> { diff --git a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateGeneticManipulatorForm.java b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateGeneticManipulatorForm.java index 624255adf..04dafeb18 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateGeneticManipulatorForm.java +++ b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateGeneticManipulatorForm.java @@ -1,7 +1,5 @@ package me.eccentric_nz.TARDIS.floodgate; -import java.util.Locale; -import java.util.UUID; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.api.event.TARDISGeneticManipulatorDisguiseEvent; import me.eccentric_nz.TARDIS.api.event.TARDISGeneticManipulatorUndisguiseEvent; @@ -24,6 +22,9 @@ import org.geysermc.floodgate.api.FloodgateApi; import org.geysermc.floodgate.api.player.FloodgatePlayer; +import java.util.Locale; +import java.util.UUID; + public class FloodgateGeneticManipulatorForm { private final TARDIS plugin; @@ -202,7 +203,7 @@ private void handleResponse(SimpleFormResponse response) { options = new Object[]{AGE.ADULT}; } } - case SNOWMAN -> { + case SNOW_GOLEM -> { if (plugin.isDisguisesOnServer()) { new TARDISLazarusLibs(player, label, true, false, false).createDisguise(); } else { @@ -216,7 +217,7 @@ private void handleResponse(SimpleFormResponse response) { options = new Object[]{TropicalFish.Pattern.values()[0]}; } } - case MUSHROOM_COW -> { + case MOOSHROOM -> { if (plugin.isDisguisesOnServer()) { new TARDISLazarusLibs(player, label, MushroomCow.Variant.RED, false, false).createDisguise(); } else { diff --git a/src/main/java/me/eccentric_nz/TARDIS/forcefield/TARDISForceFieldVisualiser.java b/src/main/java/me/eccentric_nz/TARDIS/forcefield/TARDISForceFieldVisualiser.java index ed3651a01..491299e6f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/forcefield/TARDISForceFieldVisualiser.java +++ b/src/main/java/me/eccentric_nz/TARDIS/forcefield/TARDISForceFieldVisualiser.java @@ -38,21 +38,21 @@ void showBorder(Location location, int d) { for (int i = 0; i < 14; i++) { // topLeft double space = 1.0d; - world.spawnParticle(Particle.REDSTONE, tffl.getTopFrontLeft().add(0, 0, space), 1, TARDISConstants.DUSTOPTIONS.get(d)); + world.spawnParticle(Particle.DUST, tffl.getTopFrontLeft().add(0, 0, space), 1, TARDISConstants.DUSTOPTIONS.get(d)); // topBack - world.spawnParticle(Particle.REDSTONE, tffl.getTopBackLeft().add(space, 0, 0), 1, TARDISConstants.DUSTOPTIONS.get(d)); + world.spawnParticle(Particle.DUST, tffl.getTopBackLeft().add(space, 0, 0), 1, TARDISConstants.DUSTOPTIONS.get(d)); // topRight - world.spawnParticle(Particle.REDSTONE, tffl.getTopBackRight().add(0, 0, -space), 1, TARDISConstants.DUSTOPTIONS.get(d)); + world.spawnParticle(Particle.DUST, tffl.getTopBackRight().add(0, 0, -space), 1, TARDISConstants.DUSTOPTIONS.get(d)); // topFront - world.spawnParticle(Particle.REDSTONE, tffl.getTopFrontRight().add(-space, 0, 0), 1, TARDISConstants.DUSTOPTIONS.get(d)); + world.spawnParticle(Particle.DUST, tffl.getTopFrontRight().add(-space, 0, 0), 1, TARDISConstants.DUSTOPTIONS.get(d)); // bottomLeft - world.spawnParticle(Particle.REDSTONE, tffl.getBottomFrontLeft().add(0, 0, space), 1, TARDISConstants.DUSTOPTIONS.get(d)); + world.spawnParticle(Particle.DUST, tffl.getBottomFrontLeft().add(0, 0, space), 1, TARDISConstants.DUSTOPTIONS.get(d)); // bottomBack - world.spawnParticle(Particle.REDSTONE, tffl.getBottomBackLeft().add(space, 0, 0), 1, TARDISConstants.DUSTOPTIONS.get(d)); + world.spawnParticle(Particle.DUST, tffl.getBottomBackLeft().add(space, 0, 0), 1, TARDISConstants.DUSTOPTIONS.get(d)); // bottomRight - world.spawnParticle(Particle.REDSTONE, tffl.getBottomBackRight().add(0, 0, -space), 1, TARDISConstants.DUSTOPTIONS.get(d)); + world.spawnParticle(Particle.DUST, tffl.getBottomBackRight().add(0, 0, -space), 1, TARDISConstants.DUSTOPTIONS.get(d)); // bottomFront - world.spawnParticle(Particle.REDSTONE, tffl.getBottomFrontRight().add(-space, 0, 0), 1, TARDISConstants.DUSTOPTIONS.get(d)); + world.spawnParticle(Particle.DUST, tffl.getBottomFrontRight().add(-space, 0, 0), 1, TARDISConstants.DUSTOPTIONS.get(d)); } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusGUIListener.java b/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusGUIListener.java index b084a450d..7842201ad 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusGUIListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusGUIListener.java @@ -378,7 +378,7 @@ public void onLazarusClick(InventoryClickEvent event) { options = new Object[]{AGE.getFromBoolean(getBaby(view))}; } } - case SNOWMAN -> { + case SNOW_GOLEM -> { if (plugin.isDisguisesOnServer()) { new TARDISLazarusLibs(player, disguise, snowmen.get(uuid), false, false).createDisguise(); } else { @@ -399,7 +399,7 @@ public void onLazarusClick(InventoryClickEvent event) { options = new Object[]{TropicalFish.Pattern.values()[tropics.get(uuid)]}; } } - case MUSHROOM_COW -> { + case MOOSHROOM -> { if (plugin.isDisguisesOnServer()) { new TARDISLazarusLibs(player, disguise, getCowVariant(view), false, getBaby(view)).createDisguise(); } else { diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISCraftListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISCraftListener.java index 620898cfd..d72f29c00 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISCraftListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISCraftListener.java @@ -153,7 +153,7 @@ public void onCraftTARDISItem(PrepareItemCraftEvent event) { } } else if (is.getType().equals(Material.IRON_SWORD) && dn.equals("Rust Plague Sword")) { // enchant the result - is.addEnchantment(Enchantment.DAMAGE_UNDEAD, 2); + is.addEnchantment(Enchantment.SMITE, 2); ci.setResult(is); } else if (is.getType().equals(Material.LEATHER_HELMET) && dn.equals("3-D Glasses") || dn.equals("TARDIS Communicator")) { LeatherArmorMeta lam = (LeatherArmorMeta) im; diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISEjectListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISEjectListener.java index 277be9cf4..f586b3901 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISEjectListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISEjectListener.java @@ -249,9 +249,9 @@ public void onInteract(PlayerInteractEntityEvent event) { llama.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(tmlla.getSpeed()); ent.remove(); } - case MUSHROOM_COW -> { + case MOOSHROOM -> { MushroomCow m = (MushroomCow) ent; - MushroomCow mush = (MushroomCow) l.getWorld().spawnEntity(l, EntityType.MUSHROOM_COW); + MushroomCow mush = (MushroomCow) l.getWorld().spawnEntity(l, EntityType.MOOSHROOM); mush.setTicksLived(m.getTicksLived()); if ((!m.isAdult())) { mush.setBaby(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/messaging/SpigotMessage.java b/src/main/java/me/eccentric_nz/TARDIS/messaging/SpigotMessage.java index 3f1faa6ed..97732aedb 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/messaging/SpigotMessage.java +++ b/src/main/java/me/eccentric_nz/TARDIS/messaging/SpigotMessage.java @@ -129,7 +129,7 @@ public void broadcast(TardisModule module, String message) { TextComponent textComponent = SpigotComponents.getModule(module); TextComponent m = new TextComponent(message); textComponent.addExtra(m); - TARDIS.plugin.getServer().broadcast(textComponent); + TARDIS.plugin.getServer().spigot().broadcast(textComponent); } @Override diff --git a/src/main/java/me/eccentric_nz/TARDIS/mobfarming/TARDISFarmer.java b/src/main/java/me/eccentric_nz/TARDIS/mobfarming/TARDISFarmer.java index a30b0e6a0..3ff07e07e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/mobfarming/TARDISFarmer.java +++ b/src/main/java/me/eccentric_nz/TARDIS/mobfarming/TARDISFarmer.java @@ -517,7 +517,7 @@ public TARDISPetsAndFollowers farmAnimals(Location l, COMPASS d, int id, Player } } } - case MUSHROOM_COW -> { + case MOOSHROOM -> { if (farmPrefs.shouldFarmLivestock() && (!farm.isEmpty() || spawnEggs)) { MushroomCow mushroomCow = (MushroomCow) entity; TARDISMooshroom tmshr = new TARDISMooshroom(); @@ -821,7 +821,7 @@ public TARDISPetsAndFollowers farmAnimals(Location l, COMPASS d, int id, Player } mooshrooms.forEach((e) -> { plugin.setTardisSpawn(true); - MushroomCow fungi = (MushroomCow) world.spawnEntity(cow_pen, EntityType.MUSHROOM_COW); + MushroomCow fungi = (MushroomCow) world.spawnEntity(cow_pen, EntityType.MOOSHROOM); fungi.setAge(e.getAge()); if (e.isBaby()) { fungi.setBaby(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/planets/TARDISAcidWater.java b/src/main/java/me/eccentric_nz/TARDIS/planets/TARDISAcidWater.java index d7bf5d2d8..19162d8e5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/planets/TARDISAcidWater.java +++ b/src/main/java/me/eccentric_nz/TARDIS/planets/TARDISAcidWater.java @@ -16,9 +16,6 @@ */ package me.eccentric_nz.TARDIS.planets; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; import me.eccentric_nz.TARDIS.move.TARDISMoveSession; @@ -43,6 +40,10 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitRunnable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + /** * @author eccentric_nz */ @@ -138,7 +139,7 @@ public void run() { plugin.getPlanetsConfig().getStringList("planets.skaro.acid_potions").forEach((t) -> { PotionEffectType pet = PotionEffectType.getByName(t); if (pet != null) { - if (pet.equals(PotionEffectType.BLINDNESS) || pet.equals(PotionEffectType.CONFUSION) || pet.equals(PotionEffectType.HUNGER) || pet.equals(PotionEffectType.SLOW) || pet.equals(PotionEffectType.SLOW_DIGGING) || pet.equals(PotionEffectType.WEAKNESS)) { + if (pet.equals(PotionEffectType.BLINDNESS) || pet.equals(PotionEffectType.NAUSEA) || pet.equals(PotionEffectType.HUNGER) || pet.equals(PotionEffectType.SLOWNESS) || pet.equals(PotionEffectType.MINING_FATIGUE) || pet.equals(PotionEffectType.WEAKNESS)) { player.addPotionEffect(new PotionEffect(pet, 200, 1)); } else { // Poison diff --git a/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/TARDISInvisibilityCircuitRecipe.java b/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/TARDISInvisibilityCircuitRecipe.java index 47a69fcdb..b3b74b0af 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/TARDISInvisibilityCircuitRecipe.java +++ b/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/TARDISInvisibilityCircuitRecipe.java @@ -10,7 +10,6 @@ import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionType; import java.util.List; @@ -55,8 +54,7 @@ public void addRecipe() { exact.setItemMeta(em); ItemStack potion = new ItemStack(Material.POTION, 1); PotionMeta pm = (PotionMeta) potion.getItemMeta(); - PotionData potionData = new PotionData(PotionType.INVISIBILITY); - pm.setBasePotionData(potionData); + pm.setBasePotionType(PotionType.INVISIBILITY); potion.setItemMeta(pm); if (plugin.getDifficulty() == Difficulty.HARD) { r.shape(" D ", "P E", " W "); diff --git a/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/TARDISTelepathicCircuitRecipe.java b/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/TARDISTelepathicCircuitRecipe.java index f4efee92d..5a6838686 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/TARDISTelepathicCircuitRecipe.java +++ b/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/TARDISTelepathicCircuitRecipe.java @@ -9,7 +9,6 @@ import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionType; import java.util.List; @@ -49,8 +48,7 @@ public void addRecipe() { r.setIngredient('S', Material.SLIME_BALL); ItemStack potion = new ItemStack(Material.POTION, 1); PotionMeta pm = (PotionMeta) potion.getItemMeta(); - PotionData potionData = new PotionData(PotionType.AWKWARD); - pm.setBasePotionData(potionData); + pm.setBasePotionType(PotionType.AWKWARD); potion.setItemMeta(pm); r.setIngredient('P', new RecipeChoice.ExactChoice(potion)); r.setIngredient('E', Material.EMERALD); diff --git a/src/main/java/me/eccentric_nz/TARDIS/rooms/library/EnchantmentShelf.java b/src/main/java/me/eccentric_nz/TARDIS/rooms/library/EnchantmentShelf.java index 1433be52d..708b0bd4d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/rooms/library/EnchantmentShelf.java +++ b/src/main/java/me/eccentric_nz/TARDIS/rooms/library/EnchantmentShelf.java @@ -12,48 +12,48 @@ public enum EnchantmentShelf { // all-purpose CURSE_OF_VANISHING(Enchantment.VANISHING_CURSE, "Curse of Vanishing", 1, EnchantmentCategory.ALL_PURPOSE, new Vector(3, 3, 2), BlockFace.SOUTH), MENDING(Enchantment.MENDING, "Mending", 1, EnchantmentCategory.ALL_PURPOSE, new Vector(4, 3, 2), BlockFace.SOUTH), - UNBREAKING(Enchantment.DURABILITY, "Unbreaking", 3, EnchantmentCategory.ALL_PURPOSE, new Vector(5, 3, 2), BlockFace.SOUTH), + UNBREAKING(Enchantment.UNBREAKING, "Unbreaking", 3, EnchantmentCategory.ALL_PURPOSE, new Vector(5, 3, 2), BlockFace.SOUTH), // armour - AQUA_AFFINITY(Enchantment.WATER_WORKER, "Aqua Affinity", 1, EnchantmentCategory.ARMOUR, new Vector(6, 3, 2), BlockFace.SOUTH), - BLAST_PROTECTION(Enchantment.PROTECTION_EXPLOSIONS, "Blast Protection", 4, EnchantmentCategory.ARMOUR, new Vector(7, 3, 2), BlockFace.SOUTH), + AQUA_AFFINITY(Enchantment.AQUA_AFFINITY, "Aqua Affinity", 1, EnchantmentCategory.ARMOUR, new Vector(6, 3, 2), BlockFace.SOUTH), + BLAST_PROTECTION(Enchantment.BLAST_PROTECTION, "Blast Protection", 4, EnchantmentCategory.ARMOUR, new Vector(7, 3, 2), BlockFace.SOUTH), CURSE_OF_BINDING(Enchantment.BINDING_CURSE, "Curse of Binding", 1, EnchantmentCategory.ARMOUR, new Vector(9, 3, 2), BlockFace.SOUTH), DEPTH_STRIDER(Enchantment.DEPTH_STRIDER, "Depth Strider", 3, EnchantmentCategory.ARMOUR, new Vector(10, 3, 2), BlockFace.SOUTH), - FEATHER_FALLING(Enchantment.PROTECTION_FALL, "Feather Falling", 4, EnchantmentCategory.ARMOUR, new Vector(11, 3, 2), BlockFace.SOUTH), - FIRE_PROTECTION(Enchantment.PROTECTION_FIRE, "Fire Protection", 4, EnchantmentCategory.ARMOUR, new Vector(12, 3, 2), BlockFace.SOUTH), + FEATHER_FALLING(Enchantment.FEATHER_FALLING, "Feather Falling", 4, EnchantmentCategory.ARMOUR, new Vector(11, 3, 2), BlockFace.SOUTH), + FIRE_PROTECTION(Enchantment.FIRE_PROTECTION, "Fire Protection", 4, EnchantmentCategory.ARMOUR, new Vector(12, 3, 2), BlockFace.SOUTH), FROST_WALKER(Enchantment.FROST_WALKER, "Frost Walker", 2, EnchantmentCategory.ARMOUR, new Vector(13, 3, 2), BlockFace.SOUTH), // left - PROJECTILE_PROTECTION(Enchantment.PROTECTION_PROJECTILE, "Projectile Protection", 4, EnchantmentCategory.ARMOUR, new Vector(14, 3, 3), BlockFace.WEST), - PROTECTION(Enchantment.PROTECTION_ENVIRONMENTAL, "Protection", 4, EnchantmentCategory.ARMOUR, new Vector(14, 3, 4), BlockFace.WEST), - RESPIRATION(Enchantment.OXYGEN, "Respiration", 3, EnchantmentCategory.ARMOUR, new Vector(14, 3, 5), BlockFace.WEST), + PROJECTILE_PROTECTION(Enchantment.PROJECTILE_PROTECTION, "Projectile Protection", 4, EnchantmentCategory.ARMOUR, new Vector(14, 3, 3), BlockFace.WEST), + PROTECTION(Enchantment.PROTECTION, "Protection", 4, EnchantmentCategory.ARMOUR, new Vector(14, 3, 4), BlockFace.WEST), + RESPIRATION(Enchantment.RESPIRATION, "Respiration", 3, EnchantmentCategory.ARMOUR, new Vector(14, 3, 5), BlockFace.WEST), RIPTIDE(Enchantment.RIPTIDE, "Riptide", 3, EnchantmentCategory.ARMOUR, new Vector(14, 3, 6), BlockFace.WEST), SOUL_SPEED(Enchantment.SOUL_SPEED, "Soul Speed", 3, EnchantmentCategory.ARMOUR, new Vector(14, 3, 7), BlockFace.WEST), SWIFT_SNEAK(Enchantment.SWIFT_SNEAK, "Swift Sneak", 3, EnchantmentCategory.ARMOUR, new Vector(14, 3, 9), BlockFace.WEST), THORNS(Enchantment.THORNS, "Thorns", 3, EnchantmentCategory.ARMOUR, new Vector(14, 3, 10), BlockFace.WEST), // melee weapons - BANE_OF_ARTHROPODS(Enchantment.DAMAGE_ARTHROPODS, "Bane of Arthropods", 5, EnchantmentCategory.MELEE_WEAPONS, new Vector(14, 3, 11), BlockFace.WEST), - EFFICIENCY(Enchantment.DIG_SPEED, "Efficiency", 5, EnchantmentCategory.MELEE_WEAPONS, new Vector(14, 3, 12), BlockFace.WEST), + BANE_OF_ARTHROPODS(Enchantment.BANE_OF_ARTHROPODS, "Bane of Arthropods", 5, EnchantmentCategory.MELEE_WEAPONS, new Vector(14, 3, 11), BlockFace.WEST), + EFFICIENCY(Enchantment.EFFICIENCY, "Efficiency", 5, EnchantmentCategory.MELEE_WEAPONS, new Vector(14, 3, 12), BlockFace.WEST), FIRE_ASPECT(Enchantment.FIRE_ASPECT, "Fire Aspect", 2, EnchantmentCategory.MELEE_WEAPONS, new Vector(14, 3, 13), BlockFace.WEST), // top IMPALING(Enchantment.IMPALING, "Impaling", 5, EnchantmentCategory.MELEE_WEAPONS, new Vector(13, 3, 14), BlockFace.NORTH), KNOCKBACK(Enchantment.KNOCKBACK, "Knockback", 2, EnchantmentCategory.MELEE_WEAPONS, new Vector(12, 3, 14), BlockFace.NORTH), - LOOTING(Enchantment.LOOT_BONUS_MOBS, "Looting", 3, EnchantmentCategory.MELEE_WEAPONS, new Vector(11, 3, 14), BlockFace.NORTH), - SHARPNESS(Enchantment.DAMAGE_ALL, "Sharpness", 5, EnchantmentCategory.MELEE_WEAPONS, new Vector(10, 3, 14), BlockFace.NORTH), - SMITE(Enchantment.DAMAGE_UNDEAD, "Smite", 5, EnchantmentCategory.MELEE_WEAPONS, new Vector(9, 3, 14), BlockFace.NORTH), + LOOTING(Enchantment.LOOTING, "Looting", 3, EnchantmentCategory.MELEE_WEAPONS, new Vector(11, 3, 14), BlockFace.NORTH), + SHARPNESS(Enchantment.SHARPNESS, "Sharpness", 5, EnchantmentCategory.MELEE_WEAPONS, new Vector(10, 3, 14), BlockFace.NORTH), + SMITE(Enchantment.SMITE, "Smite", 5, EnchantmentCategory.MELEE_WEAPONS, new Vector(9, 3, 14), BlockFace.NORTH), SWEEPING_EDGE(Enchantment.SWEEPING_EDGE, "Sweeping Edge", 3, EnchantmentCategory.MELEE_WEAPONS, new Vector(7, 3, 14), BlockFace.NORTH), // ranged weapons CHANNELING(Enchantment.CHANNELING, "Channeling", 1, EnchantmentCategory.RANGED_WEAPONS, new Vector(6, 3, 14), BlockFace.NORTH), - FLAME(Enchantment.ARROW_FIRE, "Flame", 1, EnchantmentCategory.RANGED_WEAPONS, new Vector(5, 3, 14), BlockFace.NORTH), - INFINITY(Enchantment.ARROW_INFINITE, "Infinity", 1, EnchantmentCategory.RANGED_WEAPONS, new Vector(4, 3, 14), BlockFace.NORTH), + FLAME(Enchantment.FLAME, "Flame", 1, EnchantmentCategory.RANGED_WEAPONS, new Vector(5, 3, 14), BlockFace.NORTH), + INFINITY(Enchantment.INFINITY, "Infinity", 1, EnchantmentCategory.RANGED_WEAPONS, new Vector(4, 3, 14), BlockFace.NORTH), LOYALTY(Enchantment.LOYALTY, "Loyalty", 3, EnchantmentCategory.RANGED_WEAPONS, new Vector(3, 3, 14), BlockFace.NORTH), // right MULTISHOT(Enchantment.MULTISHOT, "Multishot", 1, EnchantmentCategory.RANGED_WEAPONS, new Vector(2, 3, 13), BlockFace.EAST), PIERCING(Enchantment.PIERCING, "Piercing", 4, EnchantmentCategory.RANGED_WEAPONS, new Vector(2, 3, 12), BlockFace.EAST), - POWER(Enchantment.ARROW_DAMAGE, "Power", 5, EnchantmentCategory.RANGED_WEAPONS, new Vector(2, 3, 11), BlockFace.EAST), - PUNCH(Enchantment.ARROW_KNOCKBACK, "Punch", 2, EnchantmentCategory.RANGED_WEAPONS, new Vector(2, 3, 10), BlockFace.EAST), + POWER(Enchantment.POWER, "Power", 5, EnchantmentCategory.RANGED_WEAPONS, new Vector(2, 3, 11), BlockFace.EAST), + PUNCH(Enchantment.PUNCH, "Punch", 2, EnchantmentCategory.RANGED_WEAPONS, new Vector(2, 3, 10), BlockFace.EAST), QUICK_CHARGE(Enchantment.QUICK_CHARGE, "Quick Charge", 3, EnchantmentCategory.RANGED_WEAPONS, new Vector(2, 3, 9), BlockFace.EAST), // tools - FORTUNE(Enchantment.LOOT_BONUS_BLOCKS, "Fortune", 3, EnchantmentCategory.TOOLS, new Vector(2, 3, 7), BlockFace.EAST), - LUCK_OF_THE_SEA(Enchantment.LUCK, "Luck of the Sea", 3, EnchantmentCategory.TOOLS, new Vector(2, 3, 6), BlockFace.EAST), + FORTUNE(Enchantment.FORTUNE, "Fortune", 3, EnchantmentCategory.TOOLS, new Vector(2, 3, 7), BlockFace.EAST), + LUCK_OF_THE_SEA(Enchantment.LUCK_OF_THE_SEA, "Luck of the Sea", 3, EnchantmentCategory.TOOLS, new Vector(2, 3, 6), BlockFace.EAST), LURE(Enchantment.LURE, "Lure", 3, EnchantmentCategory.TOOLS, new Vector(2, 3, 5), BlockFace.EAST), SILK_TOUCH(Enchantment.SILK_TOUCH, "Silk Touch", 1, EnchantmentCategory.TOOLS, new Vector(2, 3, 4), BlockFace.EAST), LEFTOVER(null, "Leftovers", 5, EnchantmentCategory.BOOKS, new Vector(2, 3, 3), BlockFace.EAST), diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java index 965e7c009..0315629a7 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java @@ -80,7 +80,7 @@ public void dock(int id, ItemFrame frame, Player player, ItemStack sonic) { private ItemDisplay doDocking(ItemStack sonic, Location location, Vector vector, Player player, int id) { // remove enchantments if any - sonic.removeEnchantment(Enchantment.DURABILITY); + sonic.removeEnchantment(Enchantment.UNBREAKING); // get sonic uuid UUID uuid = sonic.getItemMeta().getPersistentDataContainer().get(plugin.getSonicUuidKey(), plugin.getPersistentDataTypeUUID()); // set item display diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicIgnite.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicIgnite.java index 590565a72..3030bc9ea 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicIgnite.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicIgnite.java @@ -41,7 +41,7 @@ public static void ignite(TARDIS plugin, Block b, Player p) { Block above = b.getRelative(BlockFace.UP); if (b.getType().equals(Material.TNT)) { b.setBlockData(TARDISConstants.AIR); - b.getWorld().spawnEntity(b.getLocation().add(0.5d, 0.5d, 0.5d), EntityType.PRIMED_TNT); + b.getWorld().spawnEntity(b.getLocation().add(0.5d, 0.5d, 0.5d), EntityType.TNT); plugin.getPM().callEvent(new BlockIgniteEvent(b, BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, p)); return; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicScanner.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicScanner.java index 8f53d687d..7df41a693 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicScanner.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicScanner.java @@ -16,9 +16,6 @@ */ package me.eccentric_nz.TARDIS.sonic.actions; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISConstants; import me.eccentric_nz.TARDIS.control.TARDISScanner; @@ -34,6 +31,10 @@ import org.bukkit.inventory.EntityEquipment; import org.bukkit.scheduler.BukkitScheduler; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + public class TARDISSonicScanner { public static void scan(TARDIS plugin, Location scan_loc, Player player) { @@ -58,15 +59,15 @@ public static void scan(TARDIS plugin, Location scan_loc, Player player) { if (ee.getHelmet() != null) { switch (ee.getHelmet().getType()) { case BAKED_POTATO -> et = EntityType.EGG; // Strax - case BOOK -> et = EntityType.ENDER_CRYSTAL; // Vashta Nerada + case BOOK -> et = EntityType.END_CRYSTAL; // Vashta Nerada case CRIMSON_BUTTON -> et = EntityType.BLOCK_DISPLAY; // davros case FEATHER -> et = EntityType.BOAT; // Silurian case IRON_INGOT -> et = EntityType.AREA_EFFECT_CLOUD; // Cyberman - case KELP -> et = EntityType.THROWN_EXP_BOTTLE; // sea devil + case KELP -> et = EntityType.EXPERIENCE_BOTTLE; // sea devil case MANGROVE_PROPAGULE -> et = EntityType.SMALL_FIREBALL; // dalek sec case NETHERITE_SCRAP -> et = EntityType.GLOW_ITEM_FRAME; // mire - case PAINTING -> et = EntityType.FISHING_HOOK; // Zygon - case POTATO -> et = EntityType.FIREWORK; // Sontaran + case PAINTING -> et = EntityType.FISHING_BOBBER; // Zygon + case POTATO -> et = EntityType.FIREWORK_ROCKET; // Sontaran case PUFFERFISH -> et = EntityType.INTERACTION; // hath case RED_CANDLE -> et = EntityType.TEXT_DISPLAY; // headless monk case SLIME_BALL -> et = EntityType.LLAMA_SPIT; // dalek @@ -82,7 +83,7 @@ public static void scan(TARDIS plugin, Location scan_loc, Player player) { } if (et.equals(EntityType.SKELETON) && !k.getPassengers().isEmpty() && k.getPassengers().get(0) != null && k.getPassengers().get(0).getType().equals(EntityType.GUARDIAN)) { // silent - et = EntityType.SPLASH_POTION; + et = EntityType.POTION; } if (et.equals(EntityType.ARMOR_STAND)) { EntityEquipment ee = ((ArmorStand) k).getEquipment(); @@ -91,7 +92,7 @@ public static void scan(TARDIS plugin, Location scan_loc, Player player) { case YELLOW_DYE -> et = EntityType.SHULKER_BULLET; // Judoon case BONE -> et = EntityType.EVOKER_FANGS; // K9 case ROTTEN_FLESH -> et = EntityType.ITEM_FRAME; // Ood - case GUNPOWDER -> et = EntityType.DROPPED_ITEM; // Toclafane + case GUNPOWDER -> et = EntityType.ITEM; // Toclafane default -> { } } @@ -149,13 +150,13 @@ public static void scan(TARDIS plugin, Location scan_loc, Player player) { case BLOCK_DISPLAY -> player.sendMessage(" Davros: " + value); case BOAT -> player.sendMessage(" Silurian: " + value); case DRAGON_FIREBALL -> player.sendMessage(" Weeping Angel: " + value); - case DROPPED_ITEM -> player.sendMessage(" Toclafane: " + value); + case ITEM -> player.sendMessage(" Toclafane: " + value); case EGG -> player.sendMessage(" Strax: " + value); - case ENDER_CRYSTAL -> player.sendMessage(" Vashta Nerada: " + value); + case END_CRYSTAL -> player.sendMessage(" Vashta Nerada: " + value); case EVOKER_FANGS -> player.sendMessage(" K9: " + value); case FALLING_BLOCK -> player.sendMessage(" Empty Child: " + value); - case FIREWORK -> player.sendMessage(" Sontaran: " + value); - case FISHING_HOOK -> player.sendMessage(" Zygon: " + value); + case FIREWORK_ROCKET -> player.sendMessage(" Sontaran: " + value); + case FISHING_BOBBER -> player.sendMessage(" Zygon: " + value); case GLOW_ITEM_FRAME -> player.sendMessage(" Mire: " + value); case INTERACTION -> player.sendMessage(" Hath: " + value); case ITEM_DISPLAY -> player.sendMessage(" Racnoss: " + value); @@ -164,9 +165,9 @@ public static void scan(TARDIS plugin, Location scan_loc, Player player) { case SHULKER_BULLET -> player.sendMessage(" Judoon: " + value); case SMALL_FIREBALL -> player.sendMessage(" Dalek Sec: " + value); case SNOWBALL -> player.sendMessage(" Ice Warrior: " + value); - case SPLASH_POTION -> player.sendMessage(" Silent: " + value); + case POTION -> player.sendMessage(" Silent: " + value); case TEXT_DISPLAY -> player.sendMessage(" Headless Monk: " + value); - case THROWN_EXP_BOTTLE -> player.sendMessage(" Sea Devil: " + value); + case EXPERIENCE_BOTTLE -> player.sendMessage(" Sea Devil: " + value); default -> { if (ent != EntityType.ARMOR_STAND) { player.sendMessage(" " + ent + ": " + value + message); diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicSound.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicSound.java index 679363b01..a7e83f2b8 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicSound.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicSound.java @@ -73,7 +73,7 @@ private static void revertSonic(PlayerInventory inv) { int cmd = meta.getCustomModelData(); meta.setCustomModelData(cmd - 2000000); stack.setItemMeta(meta); - if (stack.containsEnchantment(Enchantment.DURABILITY)) { + if (stack.containsEnchantment(Enchantment.UNBREAKING)) { stack.getEnchantments().keySet().forEach(stack::removeEnchantment); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/utility/RecipeChecker.java b/src/main/java/me/eccentric_nz/TARDIS/utility/RecipeChecker.java deleted file mode 100644 index 2d0986da5..000000000 --- a/src/main/java/me/eccentric_nz/TARDIS/utility/RecipeChecker.java +++ /dev/null @@ -1,43 +0,0 @@ -package me.eccentric_nz.TARDIS.utility; - -import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; -import it.unimi.dsi.fastutil.objects.Object2ObjectMap; -import me.eccentric_nz.TARDIS.TARDIS; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.item.crafting.RecipeHolder; -import net.minecraft.world.item.crafting.RecipeType; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_20_R3.CraftWorld; - -import java.util.Map; -import java.util.Set; -import java.util.logging.Level; - -public class RecipeChecker implements Runnable { - - @Override - public void run() { - ServerLevel world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle(); - // check recipes - try { - Set, Object2ObjectLinkedOpenHashMap>>> recipes = MinecraftServer.getServer().getRecipeManager().recipes.entrySet(); - for (Map.Entry, Object2ObjectLinkedOpenHashMap>> recipe : recipes) { - Object2ObjectLinkedOpenHashMap> map = recipe.getValue(); - for (Object2ObjectMap.Entry> r : map.object2ObjectEntrySet()) { - Object obj = r.getValue().value(); - if (obj instanceof net.minecraft.world.item.crafting.ShapedRecipe shaped) { - String key = r.getKey().getNamespace().toLowerCase(); - String path = r.getKey().getPath(); - if (key.startsWith("tardis")) { - TARDIS.plugin.getLogger().log(Level.INFO, path + " => " + shaped.getResultItem(world.registryAccess()).toString()); - } - } - } - } - } catch (IllegalArgumentException e) { - TARDIS.plugin.getLogger().log(Level.WARNING, "Skipping recipe..."); - } - } -} diff --git a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISEntityTracker.java b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISEntityTracker.java index 48fe5d549..b7431e373 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISEntityTracker.java +++ b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISEntityTracker.java @@ -16,9 +16,6 @@ */ package me.eccentric_nz.TARDIS.utility; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.control.TARDISScanner; import me.eccentric_nz.tardischunkgenerator.disguise.*; @@ -26,6 +23,10 @@ import org.bukkit.Location; import org.bukkit.entity.*; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * @author eccentric_nz */ @@ -76,10 +77,10 @@ public void addNPCs(Location exterior, Location interior, UUID uuid) { case ZOMBIE_VILLAGER -> options = new Object[]{PROFESSION.getFromVillagerProfession(((ZombieVillager) e).getVillagerProfession()), AGE.getFromBoolean(!((Ageable) e).isAdult())}; case SLIME, MAGMA_CUBE -> options = new Object[]{((Slime) e).getSize()}; case COW, TURTLE, ZOMBIE, BEE -> options = new Object[]{AGE.getFromBoolean(!((Ageable) e).isAdult())}; - case SNOWMAN -> options = new Object[]{((Snowman) e).isDerp()}; + case SNOW_GOLEM -> options = new Object[]{((Snowman) e).isDerp()}; case PUFFERFISH -> options = new Object[]{((PufferFish) e).getPuffState()}; case TROPICAL_FISH -> options = new Object[]{((TropicalFish) e).getPattern()}; - case MUSHROOM_COW -> options = new Object[]{MUSHROOM_COW.getFromMushroomCowType(((MushroomCow) e).getVariant()), AGE.getFromBoolean(!((Ageable) e).isAdult())}; + case MOOSHROOM -> options = new Object[]{MUSHROOM_COW.getFromMushroomCowType(((MushroomCow) e).getVariant()), AGE.getFromBoolean(!((Ageable) e).isAdult())}; case FOX -> options = new Object[]{FOX.getFromFoxType(((Fox) e).getFoxType()), AGE.getFromBoolean(!((Ageable) e).isAdult())}; default -> { } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISParticles.java b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISParticles.java index fa8621750..5b622f562 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISParticles.java +++ b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISParticles.java @@ -37,7 +37,7 @@ public static void sendVortexParticles(Location l, Player p) { v = rotateAroundAxisX(v, l.getPitch() * 0.017453292F); v = rotateAroundAxisY(v, -l.getYaw() * 0.017453292F); l.add(v); - p.spawnParticle(Particle.SPELL, l, 10); + p.spawnParticle(Particle.ENTITY_EFFECT, l, 10); l.subtract(v); } step += 1; diff --git a/src/main/java/me/eccentric_nz/tardischemistry/lab/CureBrewingListener.java b/src/main/java/me/eccentric_nz/tardischemistry/lab/CureBrewingListener.java index 91ef359d2..0db223c86 100644 --- a/src/main/java/me/eccentric_nz/tardischemistry/lab/CureBrewingListener.java +++ b/src/main/java/me/eccentric_nz/tardischemistry/lab/CureBrewingListener.java @@ -36,7 +36,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionType; import java.util.*; @@ -45,25 +44,25 @@ public class CureBrewingListener implements Listener { private final TARDIS plugin; private final List elements = Arrays.asList("Silver", "Bismuth", "Calcium", "Cobalt"); - private final List cures = Arrays.asList(PotionType.AWKWARD, PotionType.MUNDANE, PotionType.THICK, PotionType.UNCRAFTABLE); + private final List cures = Arrays.asList(PotionType.AWKWARD, PotionType.MUNDANE, PotionType.THICK, PotionType.WATER); private final HashMap> potions = new HashMap<>(); private final Set noPickUps = new HashSet<>(); public CureBrewingListener(TARDIS plugin) { this.plugin = plugin; potions.put(PotionType.FIRE_RESISTANCE, Arrays.asList("BLAZE_POWDER", "GLASS_BOTTLE", "MAGMA_CREAM", "NETHER_WART")); - potions.put(PotionType.INSTANT_HEAL, Arrays.asList("BLAZE_POWDER", "GLASS_BOTTLE", "GLISTERING_MELON", "NETHER_WART")); + potions.put(PotionType.HEALING, Arrays.asList("BLAZE_POWDER", "GLASS_BOTTLE", "GLISTERING_MELON", "NETHER_WART")); potions.put(PotionType.INVISIBILITY, Arrays.asList("BLAZE_POWDER", "FERMENTED_SPIDER_EYE", "GLASS_BOTTLE", "GOLDEN_CARROT", "NETHER_WART")); - potions.put(PotionType.JUMP, Arrays.asList("BLAZE_POWDER", "GLASS_BOTTLE", "NETHER_WART", "RABBIT_FOOT")); + potions.put(PotionType.LEAPING, Arrays.asList("BLAZE_POWDER", "GLASS_BOTTLE", "NETHER_WART", "RABBIT_FOOT")); potions.put(PotionType.NIGHT_VISION, Arrays.asList("BLAZE_POWDER", "CARROT", "GLASS_BOTTLE", "GOLDEN_CARROT", "NETHER_WART")); - potions.put(PotionType.REGEN, Arrays.asList("BLAZE_POWDER", "GHAST_TEAR", "GLASS_BOTTLE", "NETHER_WART")); - potions.put(PotionType.SPEED, Arrays.asList("BLAZE_POWDER", "GLASS_BOTTLE", "NETHER_WART", "SUGAR")); + potions.put(PotionType.REGENERATION, Arrays.asList("BLAZE_POWDER", "GHAST_TEAR", "GLASS_BOTTLE", "NETHER_WART")); + potions.put(PotionType.SWIFTNESS, Arrays.asList("BLAZE_POWDER", "GLASS_BOTTLE", "NETHER_WART", "SUGAR")); potions.put(PotionType.STRENGTH, Arrays.asList("BLAZE_POWDER", "GLASS_BOTTLE", "IRON_INGOT", "NETHER_WART")); potions.put(PotionType.WATER_BREATHING, Arrays.asList("BLAZE_POWDER", "GLASS_BOTTLE", "NETHER_WART", "PUFFERFISH")); potions.put(PotionType.AWKWARD, Arrays.asList("BLAZE_POWDER", "FEATHER:Silver", "GLASS_BOTTLE", "NETHER_WART")); potions.put(PotionType.MUNDANE, Arrays.asList("BLAZE_POWDER", "FEATHER:Cobalt", "GLASS_BOTTLE", "NETHER_WART")); potions.put(PotionType.THICK, Arrays.asList("BLAZE_POWDER", "FEATHER:Calcium", "GLASS_BOTTLE", "NETHER_WART")); - potions.put(PotionType.UNCRAFTABLE, Arrays.asList("BLAZE_POWDER", "FEATHER:Bismuth", "GLASS_BOTTLE", "NETHER_WART")); + potions.put(PotionType.WATER, Arrays.asList("BLAZE_POWDER", "FEATHER:Bismuth", "GLASS_BOTTLE", "NETHER_WART")); } @EventHandler(priority = EventPriority.NORMAL) @@ -88,7 +87,7 @@ public void onItemDrop(PlayerDropItemEvent event) { } noPickUps.add(player.getUniqueId()); Location particles = cauldron.getLocation().add(0.5, 1.25, 0.5); - location.getWorld().spawnParticle(Particle.WATER_SPLASH, particles, 5); + location.getWorld().spawnParticle(Particle.SPLASH, particles, 5); player.playSound(player.getLocation(), Sound.BLOCK_BUBBLE_COLUMN_BUBBLE_POP, 1.0F, 1.0F); List items = new ArrayList<>(); // add the current item @@ -144,7 +143,7 @@ public void onItemDrop(PlayerDropItemEvent event) { item.remove(); // start bubble particles int task = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> { - location.getWorld().spawnParticle(Particle.WATER_SPLASH, particles, 5); + location.getWorld().spawnParticle(Particle.SPLASH, particles, 5); player.playSound(player.getLocation(), Sound.BLOCK_BUBBLE_COLUMN_BUBBLE_POP, 1.0F, 1.0F); }, 1L, 20L); // wait 20 seconds then give potion @@ -195,8 +194,15 @@ public void onItemDrop(PlayerDropItemEvent event) { is.setItemMeta(im); } else { PotionMeta pm = (PotionMeta) is.getItemMeta(); - PotionData potionData = new PotionData(map.getKey(), extend, upgrade); - pm.setBasePotionData(potionData); + PotionType potionName; + if (extend && upgrade) { + potionName = PotionType.valueOf("STRONG_" + map.getKey().toString()); + } else if (extend) { + potionName = PotionType.valueOf("LONG_" + map.getKey().toString()); + } else { + potionName = potionType; + } + pm.setBasePotionType(potionName); is.setItemMeta(pm); } location.getWorld().dropItem(location.add(0, 1.0d, 0), is); diff --git a/src/main/java/me/eccentric_nz/tardischemistry/product/BalloonListener.java b/src/main/java/me/eccentric_nz/tardischemistry/product/BalloonListener.java index 6a0b484fb..b5b211fb1 100644 --- a/src/main/java/me/eccentric_nz/tardischemistry/product/BalloonListener.java +++ b/src/main/java/me/eccentric_nz/tardischemistry/product/BalloonListener.java @@ -51,7 +51,7 @@ public void onPlayerHoldBalloon(PlayerItemHeldEvent event) { } removeJumpBoost(player); if (factor > -1) { - PotionEffect potionEffect = new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, factor); + PotionEffect potionEffect = new PotionEffect(PotionEffectType.JUMP_BOOST, Integer.MAX_VALUE, factor); player.addPotionEffect(potionEffect); } }, 1L); @@ -83,7 +83,7 @@ public void onPlayerPickupBalloon(EntityPickupItemEvent event) { } removeJumpBoost(player); if (factor > -1) { - PotionEffect potionEffect = new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, factor); + PotionEffect potionEffect = new PotionEffect(PotionEffectType.JUMP_BOOST, Integer.MAX_VALUE, factor); player.addPotionEffect(potionEffect); } } @@ -104,7 +104,7 @@ public void onPlayerMoveBalloon(InventoryClickEvent event) { factor -= 1; } if (factor > -1) { - PotionEffect potionEffect = new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, factor); + PotionEffect potionEffect = new PotionEffect(PotionEffectType.JUMP_BOOST, Integer.MAX_VALUE, factor); player.addPotionEffect(potionEffect); } else { removeJumpBoost(player); @@ -122,10 +122,10 @@ private boolean isInDataRange(int custom) { } private void removeJumpBoost(Player player) { - if (player.hasPotionEffect(PotionEffectType.JUMP)) { - PotionEffect potionEffect = player.getPotionEffect(PotionEffectType.JUMP); + if (player.hasPotionEffect(PotionEffectType.JUMP_BOOST)) { + PotionEffect potionEffect = player.getPotionEffect(PotionEffectType.JUMP_BOOST); if (potionEffect.getDuration() > 150000000) { - player.removePotionEffect(PotionEffectType.JUMP); + player.removePotionEffect(PotionEffectType.JUMP_BOOST); } } } diff --git a/src/main/java/me/eccentric_nz/tardischemistry/product/SparklerRunnable.java b/src/main/java/me/eccentric_nz/tardischemistry/product/SparklerRunnable.java index 2b81ddf08..c8f8028ff 100644 --- a/src/main/java/me/eccentric_nz/tardischemistry/product/SparklerRunnable.java +++ b/src/main/java/me/eccentric_nz/tardischemistry/product/SparklerRunnable.java @@ -52,7 +52,7 @@ public void run() { if (isSparkler(mainHand)) { if (System.currentTimeMillis() < startTime + 30000) { Location rightHand = getHandLocation(); - player.spawnParticle(Particle.BLOCK_DUST, rightHand, 5, colour); + player.spawnParticle(Particle.DUST, rightHand, 5, colour); } else { ItemStack sparkler = inventory.getItemInMainHand(); int amount = sparkler.getAmount(); diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/TARDISHelper.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/TARDISHelper.java index 3bb666a93..20eac21d8 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/TARDISHelper.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/TARDISHelper.java @@ -48,9 +48,9 @@ import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.data.Directional; -import org.bukkit.craftbukkit.v1_20_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_20_R3.block.CraftBlock; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftVillager; +import org.bukkit.craftbukkit.v1_20_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R4.block.CraftBlock; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftVillager; import org.bukkit.entity.*; import org.bukkit.map.MapView; import org.bukkit.util.Vector; @@ -106,7 +106,8 @@ public void nameFurnaceGUI(Block block, String name) { BlockPos bp = new BlockPos(block.getX(), block.getY(), block.getZ()); BlockEntity tile = ws.getBlockEntity(bp); if (tile instanceof FurnaceBlockEntity furnace) { - furnace.setCustomName(Component.literal(name)); +// furnace.setCustomName(Component.literal(name)); + furnace.name = Component.literal(name); } } } @@ -336,7 +337,7 @@ public void setPowerableBlockInteract(Block block) { BlockState data = ((CraftBlock) block).getNMS(); net.minecraft.world.level.Level world = ((CraftWorld) block.getWorld()).getHandle(); BlockPos position = ((CraftBlock) block).getPosition(); - data.use(world, null, null, BlockHitResult.miss(data.getOffset(world, position), direction, position)); + data.useWithoutItem(world, null, BlockHitResult.miss(data.getOffset(world, position), direction, position)); } public void growTree(String tree, Location location) { diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/custombiome/BiomeHelper.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/custombiome/BiomeHelper.java index 1916aaa4a..474ca1c1f 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/custombiome/BiomeHelper.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/custombiome/BiomeHelper.java @@ -1,7 +1,5 @@ package me.eccentric_nz.tardischunkgenerator.custombiome; -import java.util.List; - import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.WritableRegistry; @@ -13,13 +11,15 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.chunk.ChunkAccess; -import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.status.ChunkStatus; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_20_R3.CraftChunk; -import org.bukkit.craftbukkit.v1_20_R3.CraftServer; -import org.bukkit.craftbukkit.v1_20_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R4.CraftChunk; +import org.bukkit.craftbukkit.v1_20_R4.CraftServer; +import org.bukkit.craftbukkit.v1_20_R4.CraftWorld; + +import java.util.List; public class BiomeHelper { diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/custombiome/CustomBiome.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/custombiome/CustomBiome.java index 76ebef74c..22941f1b8 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/custombiome/CustomBiome.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/custombiome/CustomBiome.java @@ -1,14 +1,10 @@ package me.eccentric_nz.tardischunkgenerator.custombiome; -import com.mojang.serialization.Lifecycle; - -import java.lang.reflect.Field; -import java.util.IdentityHashMap; - import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.enumeration.TardisModule; import me.eccentric_nz.tardischunkgenerator.TARDISHelper; import net.minecraft.core.MappedRegistry; +import net.minecraft.core.RegistrationInfo; import net.minecraft.core.WritableRegistry; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; @@ -19,7 +15,10 @@ import net.minecraft.world.level.biome.BiomeSpecialEffects; import net.minecraft.world.level.biome.MobSpawnSettings; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_20_R3.CraftServer; +import org.bukkit.craftbukkit.v1_20_R4.CraftServer; + +import java.lang.reflect.Field; +import java.util.IdentityHashMap; public class CustomBiome { @@ -60,7 +59,8 @@ public static void addCustomBiome(CustomBiomeData data) { unregisteredIntrusiveHolders.setAccessible(true); unregisteredIntrusiveHolders.set(registrywritable, new IdentityHashMap<>()); registrywritable.createIntrusiveHolder(biome); - registrywritable.register(customKey, biome, Lifecycle.stable()); +// registrywritable.register(customKey, biome, Lifecycle.stable()); + registrywritable.register(customKey, biome, RegistrationInfo.BUILT_IN); // make unregisteredIntrusiveHolders null again to remove potential for undefined behaviour unregisteredIntrusiveHolders.set(registrywritable, null); // refreeze biome registry diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISArmourStandDisguiser.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISArmourStandDisguiser.java index 81df8f42d..58187003e 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISArmourStandDisguiser.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISArmourStandDisguiser.java @@ -30,7 +30,7 @@ import net.minecraft.world.entity.Mob; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISChameleonArchDisguiser.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISChameleonArchDisguiser.java index 2646a4ba4..0fe2d1b64 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISChameleonArchDisguiser.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISChameleonArchDisguiser.java @@ -28,7 +28,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer; import java.lang.reflect.Field; import java.util.Arrays; diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISDisguise.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISDisguise.java index 3c8519b77..d0fcd2bc5 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISDisguise.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISDisguise.java @@ -19,6 +19,7 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISConstants; import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.AgeableMob; @@ -35,9 +36,9 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import org.bukkit.World; -import org.bukkit.craftbukkit.v1_20_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack; -import org.bukkit.craftbukkit.v1_20_R3.util.CraftNamespacedKey; +import org.bukkit.craftbukkit.v1_20_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_20_R4.util.CraftNamespacedKey; import org.bukkit.entity.Axolotl; import org.bukkit.entity.EntityType; import org.bukkit.entity.Frog; @@ -197,7 +198,7 @@ public static Entity createMobDisguise(TARDISDisguise disguise, World w) { } case WOLF -> { Wolf wolf = (Wolf) entity; - wolf.setTame(true); + wolf.setTame(true, false); wolf.setCollarColor(DyeColor.valueOf(o.toString())); } default -> { @@ -212,7 +213,7 @@ public static Entity createMobDisguise(TARDISDisguise disguise, World w) { if (disguise.getEntityType().equals(EntityType.FROG) && o instanceof Frog.Variant fv) { net.minecraft.world.entity.animal.frog.Frog frog = (net.minecraft.world.entity.animal.frog.Frog) entity; net.minecraft.world.entity.animal.FrogVariant variant = BuiltInRegistries.FROG_VARIANT.byId(fv.ordinal()); - frog.setVariant(variant); + frog.setVariant(Holder.direct(variant)); } if (disguise.getEntityType().equals(EntityType.RABBIT) && o instanceof org.bukkit.entity.Rabbit.Type rt) { Rabbit rabbit = (Rabbit) entity; @@ -237,13 +238,13 @@ public static Entity createMobDisguise(TARDISDisguise disguise, World w) { Parrot parrot = (Parrot) entity; parrot.setVariant(Parrot.Variant.byId(pv.ordinal())); } - if (disguise.getEntityType().equals(EntityType.MUSHROOM_COW) && o instanceof MUSHROOM_COW mc) { + if (disguise.getEntityType().equals(EntityType.MOOSHROOM) && o instanceof MUSHROOM_COW mc) { MushroomCow cow = (MushroomCow) entity; cow.setVariant(mc.getNmsType()); } if (disguise.getEntityType().equals(EntityType.CAT) && o instanceof org.bukkit.entity.Cat.Type c) { Cat cat = (Cat) entity; - cat.setVariant(BuiltInRegistries.CAT_VARIANT.byId(c.ordinal())); + cat.setVariant(Holder.direct(BuiltInRegistries.CAT_VARIANT.byId(c.ordinal()))); } if (disguise.getEntityType().equals(EntityType.FOX) && o instanceof FOX f) { Fox fox = (Fox) entity; @@ -263,7 +264,7 @@ public static Entity createMobDisguise(TARDISDisguise disguise, World w) { switch (disguise.getEntityType()) { case FOX, WOLF, CAT -> { TamableAnimal tameable = (TamableAnimal) entity; - tameable.setTame(bool); + tameable.setTame(bool, false); } case DONKEY, MULE -> { AbstractChestedHorse chesty = (AbstractChestedHorse) entity; @@ -290,7 +291,7 @@ public static Entity createMobDisguise(TARDISDisguise disguise, World w) { Bat bat = (Bat) entity; bat.setResting(bool); } - case SNOWMAN -> { + case SNOW_GOLEM -> { SnowGolem snowman = (SnowGolem) entity; snowman.setPumpkin(!bool); } diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISDisguiser.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISDisguiser.java index db042f0f1..b4cd911c8 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISDisguiser.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISDisguiser.java @@ -26,7 +26,7 @@ import net.minecraft.world.entity.Mob; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISEPSDisguiser.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISEPSDisguiser.java index aa7f215fc..462bb2832 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISEPSDisguiser.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISEPSDisguiser.java @@ -28,10 +28,10 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.craftbukkit.v1_20_R3.CraftServer; -import org.bukkit.craftbukkit.v1_20_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_20_R4.CraftServer; +import org.bukkit.craftbukkit.v1_20_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.entity.Player; import java.util.Map; diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISPlayerDisguiser.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISPlayerDisguiser.java index 0949def9d..d76d55665 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISPlayerDisguiser.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISPlayerDisguiser.java @@ -26,7 +26,7 @@ import me.eccentric_nz.TARDIS.enumeration.TardisModule; import net.minecraft.server.level.ServerPlayer; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer; import org.bukkit.entity.Player; import javax.net.ssl.HttpsURLConnection; diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/GetBlockColours.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/GetBlockColours.java index b6fb71dac..c4de33b7a 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/GetBlockColours.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/GetBlockColours.java @@ -5,7 +5,7 @@ import net.minecraft.world.level.material.MapColor; import org.bukkit.Color; import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_20_R3.util.CraftMagicNumbers; +import org.bukkit.craftbukkit.v1_20_R4.util.CraftMagicNumbers; import java.util.logging.Level; diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/Shrieker.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/Shrieker.java index af56cf626..6dad0ce92 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/Shrieker.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/Shrieker.java @@ -7,8 +7,8 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.gameevent.GameEvent; import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_20_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_20_R3.block.CraftBlockState; +import org.bukkit.craftbukkit.v1_20_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R4.block.CraftBlockState; public class Shrieker { diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISItemFrameFaker.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISItemFrameFaker.java index 6f15163b4..c2bed3492 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISItemFrameFaker.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISItemFrameFaker.java @@ -8,9 +8,9 @@ import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.world.entity.decoration.ItemFrame; import net.minecraft.world.level.Level; -import org.bukkit.craftbukkit.v1_20_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftItemFrame; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftItemFrame; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.util.Vector; diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISMapUpdater.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISMapUpdater.java index dfe95a985..b694534ac 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISMapUpdater.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISMapUpdater.java @@ -11,8 +11,8 @@ import net.minecraft.world.item.MapItem; import net.minecraft.world.level.saveddata.maps.MapItemSavedData; import org.bukkit.World; -import org.bukkit.craftbukkit.v1_20_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_20_R3.map.CraftMapView; +import org.bukkit.craftbukkit.v1_20_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R4.map.CraftMapView; import org.bukkit.map.MapView; public final class TARDISMapUpdater extends Player { diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISPacketListener.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISPacketListener.java index e639ddd47..948876c70 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISPacketListener.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISPacketListener.java @@ -31,15 +31,15 @@ import net.minecraft.server.network.ServerCommonPacketListenerImpl; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.chunk.status.ChunkStatus; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.ticks.LevelChunkTicks; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_20_R3.CraftChunk; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R4.CraftChunk; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/worldgen/feature/CustomTree.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/worldgen/feature/CustomTree.java index 5f09c7b99..7c90aa7f4 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/worldgen/feature/CustomTree.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/worldgen/feature/CustomTree.java @@ -6,8 +6,8 @@ import net.minecraft.world.level.chunk.ChunkGenerator; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor; -import org.bukkit.craftbukkit.v1_20_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R4.CraftRegionAccessor; +import org.bukkit.craftbukkit.v1_20_R4.CraftWorld; import org.bukkit.generator.LimitedRegion; public class CustomTree { diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/worldgen/feature/TreePlacer.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/worldgen/feature/TreePlacer.java index 82bc08977..c70bd9804 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/worldgen/feature/TreePlacer.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/worldgen/feature/TreePlacer.java @@ -13,7 +13,7 @@ import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate; import net.minecraft.world.level.levelgen.feature.WeepingVinesFeature; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_20_R3.block.data.CraftBlockData; +import org.bukkit.craftbukkit.v1_20_R4.block.data.CraftBlockData; public class TreePlacer { diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/worldgen/populators/GallifreyGrassPopulator.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/worldgen/populators/GallifreyGrassPopulator.java index 846b3c20d..a0319643a 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/worldgen/populators/GallifreyGrassPopulator.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/worldgen/populators/GallifreyGrassPopulator.java @@ -7,7 +7,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.level.WorldGenLevel; import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor; +import org.bukkit.craftbukkit.v1_20_R4.CraftRegionAccessor; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.LimitedRegion; import org.bukkit.generator.WorldInfo; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/commands/FollowCommand.java b/src/main/java/me/eccentric_nz/tardisweepingangels/commands/FollowCommand.java index 83ea797bd..5a2f7d886 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/commands/FollowCommand.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/commands/FollowCommand.java @@ -23,7 +23,7 @@ import me.eccentric_nz.tardisweepingangels.utils.Follow; import me.eccentric_nz.tardisweepingangels.utils.FollowerFinder; import org.bukkit.command.CommandSender; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Husk; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/commands/StayCommand.java b/src/main/java/me/eccentric_nz/tardisweepingangels/commands/StayCommand.java index 6a81a9169..669407d05 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/commands/StayCommand.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/commands/StayCommand.java @@ -23,7 +23,7 @@ import me.eccentric_nz.tardisweepingangels.utils.Follow; import me.eccentric_nz.tardisweepingangels.utils.FollowerFinder; import org.bukkit.command.CommandSender; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/death/Death.java b/src/main/java/me/eccentric_nz/tardisweepingangels/death/Death.java index 3dc20faf4..36487fdbc 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/death/Death.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/death/Death.java @@ -28,7 +28,7 @@ import net.citizensnpcs.api.CitizensAPI; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -41,7 +41,6 @@ import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; -import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionType; import java.util.ArrayList; @@ -144,7 +143,7 @@ public void onEntityDeath(EntityDeathEvent event) { if (stack.getType() == Material.POTION) { // make it a strength potion PotionMeta potionMeta = (PotionMeta) stack.getItemMeta(); - potionMeta.setBasePotionData(new PotionData(PotionType.STRENGTH)); + potionMeta.setBasePotionType(PotionType.STRENGTH); stack.setItemMeta(potionMeta); } } @@ -269,7 +268,7 @@ public void onEntityDeath(EntityDeathEvent event) { } else if (TARDISConstants.RANDOM.nextInt(100) < 6) { stack = new ItemStack(Material.POTION); PotionMeta potionMeta = (PotionMeta) stack.getItemMeta(); - potionMeta.setBasePotionData(new PotionData(PotionType.REGEN)); + potionMeta.setBasePotionType(PotionType.REGENERATION); stack.setItemMeta(potionMeta); } else { stack = new ItemStack(empty_drops.get(TARDISConstants.RANDOM.nextInt(empty_drops.size())), TARDISConstants.RANDOM.nextInt(1) + 1); diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/daleks/DalekEquipment.java b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/daleks/DalekEquipment.java index 15ea28061..1551a94df 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/daleks/DalekEquipment.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/daleks/DalekEquipment.java @@ -62,7 +62,7 @@ public static void set(LivingEntity le, boolean disguise) { ee.setItemInMainHand(bow); ee.setItemInMainHandDropChance(0); Bukkit.getScheduler().scheduleSyncDelayedTask(TARDIS.plugin, () -> { - PotionEffect resistance = new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 360000, 1, true, false); + PotionEffect resistance = new PotionEffect(PotionEffectType.RESISTANCE, 360000, 1, true, false); le.addPotionEffect(resistance); AttributeInstance attribute = le.getAttribute(Attribute.GENERIC_MAX_HEALTH); attribute.setBaseValue(30.0d); diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/empty_child/EmptyChildEquipment.java b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/empty_child/EmptyChildEquipment.java index ea08e7f6f..b8e875a24 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/empty_child/EmptyChildEquipment.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/empty_child/EmptyChildEquipment.java @@ -23,7 +23,7 @@ public class EmptyChildEquipment { public static void setSpeed(LivingEntity le) { - PotionEffect p = new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 1, true, false); + PotionEffect p = new PotionEffect(PotionEffectType.SLOWNESS, Integer.MAX_VALUE, 1, true, false); le.removePotionEffect(PotionEffectType.SPEED); le.addPotionEffect(p); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/judoon/JudoonGuardRunnable.java b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/judoon/JudoonGuardRunnable.java index f5734ac48..a35a42b79 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/judoon/JudoonGuardRunnable.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/judoon/JudoonGuardRunnable.java @@ -22,7 +22,7 @@ import me.eccentric_nz.tardisweepingangels.nms.TWAJudoon; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.*; import org.bukkit.util.BlockIterator; import org.bukkit.util.Vector; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/judoon/JudoonListener.java b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/judoon/JudoonListener.java index c6c500d67..d845f6573 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/judoon/JudoonListener.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/judoon/JudoonListener.java @@ -26,7 +26,7 @@ import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.block.ShulkerBox; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.Husk; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/ood/OodEquipment.java b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/ood/OodEquipment.java index 45ffc747e..c43e692f4 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/ood/OodEquipment.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/ood/OodEquipment.java @@ -23,7 +23,7 @@ import me.eccentric_nz.tardisweepingangels.utils.Monster; import org.bukkit.Material; import org.bukkit.OfflinePlayer; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.Entity; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/ood/OodListener.java b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/ood/OodListener.java index deb8f45c6..4c16437b8 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/ood/OodListener.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/ood/OodListener.java @@ -21,7 +21,7 @@ import me.eccentric_nz.TARDIS.enumeration.TardisModule; import me.eccentric_nz.tardisweepingangels.TARDISWeepingAngels; import me.eccentric_nz.tardisweepingangels.nms.TWAOod; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/toclafane/ToclafaneListener.java b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/toclafane/ToclafaneListener.java index 7fcf49e33..27a5fe617 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/toclafane/ToclafaneListener.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/toclafane/ToclafaneListener.java @@ -24,7 +24,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.attribute.Attribute; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/weeping_angels/Blink.java b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/weeping_angels/Blink.java index 082939f78..6746c6ced 100755 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/weeping_angels/Blink.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/weeping_angels/Blink.java @@ -16,8 +16,6 @@ */ package me.eccentric_nz.tardisweepingangels.monsters.weeping_angels; -import java.util.ArrayList; -import java.util.List; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISConstants; import me.eccentric_nz.TARDIS.enumeration.TardisModule; @@ -34,6 +32,9 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import java.util.ArrayList; +import java.util.List; + public class Blink implements Listener { private final TARDIS plugin; @@ -98,7 +99,7 @@ public void onToggleSneak(PlayerToggleSneakEvent event) { } // freeze the closest skeleton if (skeleton != null) { - skeleton.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, plugin.getMonstersConfig().getInt("angels.freeze_time"), 30, true, false)); + skeleton.addPotionEffect(new PotionEffect(PotionEffectType.SLOWNESS, plugin.getMonstersConfig().getInt("angels.freeze_time"), 30, true, false)); if (!player.isSneaking()) { plugin.getMessenger().message(player, TardisModule.MONSTERS, message.get(TARDISConstants.RANDOM.nextInt(4))); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/weeping_angels/Damage.java b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/weeping_angels/Damage.java index 920413b00..1ff96837f 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/weeping_angels/Damage.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/weeping_angels/Damage.java @@ -100,7 +100,7 @@ public void onBeatUpAngel(EntityDamageByEntityEvent event) { final Location tpLoc = l; plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> p.teleport(tpLoc), 1L); } - p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 300, 5, true, false)); + p.addPotionEffect(new PotionEffect(PotionEffectType.NAUSEA, 300, 5, true, false)); if (TARDISWeepingAngels.angelsCanSteal()) { stealKey(p); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/FollowPathFinder.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/FollowPathFinder.java index 9ddb9a31b..951c50def 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/FollowPathFinder.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/FollowPathFinder.java @@ -6,10 +6,10 @@ import net.minecraft.world.entity.ai.navigation.PathNavigation; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.pathfinder.BlockPathTypes; +import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.level.pathfinder.WalkNodeEvaluator; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_20_R3.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_20_R4.event.CraftEventFactory; import org.bukkit.event.entity.EntityTeleportEvent; import java.util.EnumSet; @@ -62,14 +62,14 @@ public boolean canContinueToUse() { public void start() { this.timeToRecalcPath = 0; - this.oldWaterCost = this.follower.getPathfindingMalus(BlockPathTypes.WATER); - this.follower.setPathfindingMalus(BlockPathTypes.WATER, 0.0F); + this.oldWaterCost = this.follower.getPathfindingMalus(PathType.WATER); + this.follower.setPathfindingMalus(PathType.WATER, 0.0F); } public void stop() { this.owner = null; this.navigation.stop(); - this.follower.setPathfindingMalus(BlockPathTypes.WATER, this.oldWaterCost); + this.follower.setPathfindingMalus(PathType.WATER, this.oldWaterCost); } public void tick() { @@ -119,8 +119,8 @@ private boolean maybeTeleportTo(int x, int y, int z) { } private boolean canTeleportTo(BlockPos pos) { - BlockPathTypes pathType = WalkNodeEvaluator.getBlockPathTypeStatic(this.level, pos.mutable()); - if (pathType != BlockPathTypes.WALKABLE) { + PathType pathType = WalkNodeEvaluator.getPathTypeStatic(this.follower, pos.mutable()); + if (pathType != PathType.WALKABLE) { return false; } BlockState state = this.level.getBlockState(pos.below()); diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/FollowerSaver.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/FollowerSaver.java index eb7d7ff97..866029f61 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/FollowerSaver.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/FollowerSaver.java @@ -2,7 +2,7 @@ import me.eccentric_nz.TARDIS.TARDIS; import org.bukkit.World; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.Husk; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/MonsterSpawner.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/MonsterSpawner.java index a98e950e2..869f112e5 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/MonsterSpawner.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/MonsterSpawner.java @@ -8,7 +8,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.EntityType; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_20_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R4.CraftWorld; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.CreatureSpawnEvent; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWADrowned.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWADrowned.java index b9d76cae9..0497f9a0f 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWADrowned.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWADrowned.java @@ -17,13 +17,14 @@ package me.eccentric_nz.tardisweepingangels.nms; import me.eccentric_nz.TARDIS.TARDIS; -import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.monster.Drowned; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; +import org.bukkit.inventory.meta.ItemMeta; /** * Custom entity class for Sea Devils @@ -45,10 +46,12 @@ public TWADrowned(EntityType type, Level level) { public void aiStep() { if (hasItemInSlot(EquipmentSlot.HEAD)) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); - CompoundTag nbt = is.getTag(); + org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); + ItemMeta im = bukkit.getItemMeta(); if (!isPathFinding()) { Bukkit.getScheduler().cancelTask(task); - nbt.putInt("CustomModelData", 405); + im.setCustomModelData(405); + bukkit.setItemMeta(im); isAnimating = false; } else if (!isAnimating) { // play move animation @@ -59,7 +62,8 @@ public void aiStep() { } else if (getTarget() != null) { cmd = 406; } - nbt.putInt("CustomModelData", cmd + frames[i]); + im.setCustomModelData(cmd + frames[i]); + bukkit.setItemMeta(im); i++; if (i == frames.length) { i = 0; @@ -67,6 +71,7 @@ public void aiStep() { }, 1L, 3L); isAnimating = true; } + setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java index 07ea84562..2ef9873fd 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java @@ -16,7 +16,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer; import org.jetbrains.annotations.Nullable; import java.lang.reflect.Field; @@ -58,10 +58,11 @@ protected void registerGoals() { this.goalSelector.addGoal(10, new RandomLookAroundGoal(this)); } + @Override - protected void defineSynchedData() { - super.defineSynchedData(); - this.entityData.define(DATA_OWNER_UUID_ID, Optional.empty()); + protected void defineSynchedData(SynchedEntityData.Builder datawatcher) { + super.defineSynchedData(datawatcher); + this.entityData.set(DATA_OWNER_UUID_ID, Optional.empty()); } @Nullable diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAJudoon.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAJudoon.java index 9c78c7908..e10d6c7ee 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAJudoon.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAJudoon.java @@ -6,7 +6,6 @@ import net.minecraft.SharedConstants; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.datafix.DataFixers; import net.minecraft.util.datafix.fixes.References; @@ -16,6 +15,8 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; +import org.bukkit.inventory.meta.ItemMeta; import java.util.Map; import java.util.UUID; @@ -51,15 +52,18 @@ public TWAJudoon(Level world, UUID owner) { public void aiStep() { if (hasItemInSlot(EquipmentSlot.HEAD)) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); - CompoundTag nbt = is.getTag(); + org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); + ItemMeta im = bukkit.getItemMeta(); if (!isPathFinding()) { Bukkit.getScheduler().cancelTask(task); - nbt.putInt("CustomModelData", 405 + (this.guard ? 6 : 0)); + im.setCustomModelData(405 + (this.guard ? 6 : 0)); + bukkit.setItemMeta(im); isAnimating = false; } else if (!isAnimating) { // play move animation task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { - nbt.putInt("CustomModelData", 400 + frames[i] + (this.guard ? 6 : 0)); + im.setCustomModelData(400 + frames[i] + (this.guard ? 6 : 0)); + bukkit.setItemMeta(im); i++; if (i == frames.length) { i = 0; @@ -67,6 +71,7 @@ public void aiStep() { }, 1L, 3L); isAnimating = true; } + setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAK9.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAK9.java index 29f83e7c2..f8993722c 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAK9.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAK9.java @@ -6,7 +6,6 @@ import net.minecraft.SharedConstants; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.datafix.DataFixers; import net.minecraft.util.datafix.fixes.References; @@ -16,6 +15,8 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; +import org.bukkit.inventory.meta.ItemMeta; import java.util.Map; import java.util.UUID; @@ -47,15 +48,18 @@ public TWAK9(Level world, UUID owner) { public void aiStep() { if (hasItemInSlot(EquipmentSlot.HEAD)) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); - CompoundTag nbt = is.getTag(); + org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); + ItemMeta im = bukkit.getItemMeta(); if (!isPathFinding()) { Bukkit.getScheduler().cancelTask(task); - nbt.putInt("CustomModelData", 400); + im.setCustomModelData(400); + bukkit.setItemMeta(im); isAnimating = false; } else if (!isAnimating) { // play move animation task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { - nbt.putInt("CustomModelData", 400 + frames[i]); + im.setCustomModelData(400 + frames[i]); + bukkit.setItemMeta(im); i++; if (i == frames.length) { i = 0; @@ -63,6 +67,7 @@ public void aiStep() { }, 1L, 3L); isAnimating = true; } + setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAOod.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAOod.java index 75d6ffa05..9338a5c5b 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAOod.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAOod.java @@ -7,7 +7,6 @@ import net.minecraft.SharedConstants; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.datafix.DataFixers; import net.minecraft.util.datafix.fixes.References; @@ -17,6 +16,8 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; +import org.bukkit.inventory.meta.ItemMeta; import java.util.Map; import java.util.UUID; @@ -53,14 +54,16 @@ public TWAOod(Level world, UUID owner) { public void aiStep() { if (hasItemInSlot(EquipmentSlot.HEAD)) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); - CompoundTag nbt = is.getTag(); + org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); + ItemMeta im = bukkit.getItemMeta(); if (!isPathFinding()) { Bukkit.getScheduler().cancelTask(task); int cmd = 405 + colour.getStep(); if (redeye) { cmd += 18; } - nbt.putInt("CustomModelData", cmd); + im.setCustomModelData(cmd); + bukkit.setItemMeta(im); isAnimating = false; } else if (!isAnimating) { // play move animation @@ -69,7 +72,7 @@ public void aiStep() { if (redeye) { cmd += 18; } - nbt.putInt("CustomModelData", cmd + frames[i]); + im.setCustomModelData(cmd + frames[i]); i++; if (i == frames.length) { i = 0; @@ -77,6 +80,7 @@ public void aiStep() { }, 1L, 3L); isAnimating = true; } + setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAPiglinBrute.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAPiglinBrute.java index aa2d29034..114d2c522 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAPiglinBrute.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAPiglinBrute.java @@ -17,13 +17,14 @@ package me.eccentric_nz.tardisweepingangels.nms; import me.eccentric_nz.TARDIS.TARDIS; -import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.monster.piglin.PiglinBrute; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; +import org.bukkit.inventory.meta.ItemMeta; /** * Custom entity class for Racnoss @@ -45,15 +46,18 @@ public TWAPiglinBrute(EntityType type, Level level) { public void aiStep() { if (hasItemInSlot(EquipmentSlot.HEAD)) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); - CompoundTag nbt = is.getTag(); + org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); + ItemMeta im = bukkit.getItemMeta(); if (!isPathFinding()) { Bukkit.getScheduler().cancelTask(task); - nbt.putInt("CustomModelData", 405); + im.setCustomModelData(405); + bukkit.setItemMeta(im); isAnimating = false; } else if (!isAnimating) { // play move animation task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { - nbt.putInt("CustomModelData", 400 + frames[i]); + im.setCustomModelData(400 + frames[i]); + bukkit.setItemMeta(im); i++; if (i == frames.length) { i = 0; @@ -61,6 +65,7 @@ public void aiStep() { }, 1L, 3L); isAnimating = true; } + setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWASkeleton.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWASkeleton.java index cdf1360b9..1039870b9 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWASkeleton.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWASkeleton.java @@ -17,7 +17,6 @@ package me.eccentric_nz.tardisweepingangels.nms; import me.eccentric_nz.TARDIS.TARDIS; -import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; @@ -26,6 +25,8 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; +import org.bukkit.inventory.meta.ItemMeta; /** * Custom entity class for Headless Monks, Mire, Silent, Silurians, and Weeping Angels @@ -48,20 +49,23 @@ public TWASkeleton(EntityType type, Level level) { public void aiStep() { if (hasItemInSlot(EquipmentSlot.HEAD)) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); - CompoundTag nbt = is.getTag(); + org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); + ItemMeta im = bukkit.getItemMeta(); Entity passenger = getFirstPassenger(); if (passenger instanceof Guardian guardian) { beaming = guardian.hasActiveAttackTarget(); } if (!isPathFinding() || beaming) { Bukkit.getScheduler().cancelTask(task); - nbt.putInt("CustomModelData", beaming ? 11 : 405); + im.setCustomModelData(beaming ? 11 : 405); + bukkit.setItemMeta(im); isAnimating = false; } else if (!isAnimating) { // play move animation task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { int cmd = getTarget() != null ? 406 : 400; - nbt.putInt("CustomModelData", cmd + frames[i]); + im.setCustomModelData(cmd + frames[i]); + bukkit.setItemMeta(im); i++; if (i == frames.length) { i = 0; @@ -69,6 +73,7 @@ public void aiStep() { }, 1L, 3L); isAnimating = true; } + setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombie.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombie.java index 3955b6161..57e9c54da 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombie.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombie.java @@ -17,13 +17,14 @@ package me.eccentric_nz.tardisweepingangels.nms; import me.eccentric_nz.TARDIS.TARDIS; -import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.monster.Zombie; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; +import org.bukkit.inventory.meta.ItemMeta; /** * Custom entity class for Cybermen, Empty Children, Slitheen, Sontarans, Vashata Nerada, and Zygons @@ -45,16 +46,19 @@ public TWAZombie(EntityType type, Level level) { public void aiStep() { if (hasItemInSlot(EquipmentSlot.HEAD)) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); - CompoundTag nbt = is.getTag(); + org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); + ItemMeta im = bukkit.getItemMeta(); if (!isPathFinding()) { Bukkit.getScheduler().cancelTask(task); - nbt.putInt("CustomModelData", 405); + im.setCustomModelData(405); + bukkit.setItemMeta(im); isAnimating = false; } else if (!isAnimating) { // play move animation task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { int cmd = getTarget() != null ? 406 : 400; - nbt.putInt("CustomModelData", cmd + frames[i]); + im.setCustomModelData(cmd + frames[i]); + bukkit.setItemMeta(im); i++; if (i == frames.length) { i = 0; @@ -62,6 +66,7 @@ public void aiStep() { }, 1L, 3L); isAnimating = true; } + setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombifiedPiglin.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombifiedPiglin.java index b97c34681..4b55f671e 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombifiedPiglin.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombifiedPiglin.java @@ -17,13 +17,14 @@ package me.eccentric_nz.tardisweepingangels.nms; import me.eccentric_nz.TARDIS.TARDIS; -import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.monster.ZombifiedPiglin; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; +import org.bukkit.inventory.meta.ItemMeta; /** * Custom entity class for Dalek Sec, Hath, Ice Warrior, and Strax @@ -45,16 +46,19 @@ public TWAZombifiedPiglin(EntityType type, Level leve public void aiStep() { if (hasItemInSlot(EquipmentSlot.HEAD)) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); - CompoundTag nbt = is.getTag(); + org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); + ItemMeta im = bukkit.getItemMeta(); if (!isPathFinding()) { Bukkit.getScheduler().cancelTask(task); - nbt.putInt("CustomModelData", 405); + im.setCustomModelData(405); + bukkit.setItemMeta(im); isAnimating = false; } else if (!isAnimating) { // play move animation task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { int cmd = getTarget() != null ? 406 : 400; - nbt.putInt("CustomModelData", cmd + frames[i]); + im.setCustomModelData(cmd + frames[i]); + bukkit.setItemMeta(im); i++; if (i == frames.length) { i = 0; @@ -62,6 +66,7 @@ public void aiStep() { }, 1L, 3L); isAnimating = true; } + setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/ChunkListener.java b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/ChunkListener.java index 7d3b1b1b3..a97e3a03b 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/ChunkListener.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/ChunkListener.java @@ -25,7 +25,7 @@ import me.eccentric_nz.tardisweepingangels.nms.FollowerPersister; import me.eccentric_nz.tardisweepingangels.nms.TWAFollower; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftZombie; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftZombie; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/Follow.java b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/Follow.java index 4b40fcf14..21d8cf680 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/Follow.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/Follow.java @@ -21,7 +21,7 @@ import me.eccentric_nz.TARDIS.enumeration.TardisModule; import me.eccentric_nz.tardisweepingangels.TARDISWeepingAngels; import me.eccentric_nz.tardisweepingangels.nms.TWAFollower; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/FollowerChecker.java b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/FollowerChecker.java index 15a4f8d1c..f73ead785 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/FollowerChecker.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/FollowerChecker.java @@ -22,7 +22,7 @@ import me.eccentric_nz.tardisweepingangels.nms.TWAFollower; import me.eccentric_nz.tardisweepingangels.nms.TWAJudoon; import me.eccentric_nz.tardisweepingangels.nms.TWAOod; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.persistence.PersistentDataContainer; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/MonsterInteractListener.java b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/MonsterInteractListener.java index 4ce1b3465..280d6877f 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/MonsterInteractListener.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/MonsterInteractListener.java @@ -25,7 +25,7 @@ import me.eccentric_nz.tardisweepingangels.nms.TWAFollower; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -81,7 +81,7 @@ public void onMonsterInteract(PlayerInteractEntityEvent event) { ItemStack is = p.getInventory().getItemInMainHand(); if (is.getType().equals(Material.POTION)) { PotionMeta potionMeta = (PotionMeta) is.getItemMeta(); - if (potionMeta != null && potionMeta.getBasePotionData().getType().equals(PotionType.WEAKNESS)) { + if (potionMeta != null && potionMeta.getBasePotionType() != null && potionMeta.getBasePotionType().equals(PotionType.WEAKNESS)) { // remove the potion int a = p.getInventory().getItemInMainHand().getAmount(); int a2 = a - 1; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/MonsterLoadUnloadListener.java b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/MonsterLoadUnloadListener.java index 6c7053ae9..5960311ef 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/MonsterLoadUnloadListener.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/MonsterLoadUnloadListener.java @@ -21,7 +21,7 @@ import me.eccentric_nz.tardisweepingangels.equip.MonsterEquipment; import me.eccentric_nz.tardisweepingangels.nms.FollowerPersister; import me.eccentric_nz.tardisweepingangels.nms.TWAFollower; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftZombie; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftZombie; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/ResetMonster.java b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/ResetMonster.java index d82c6e88f..2d57c596e 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/ResetMonster.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/ResetMonster.java @@ -17,7 +17,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.OfflinePlayer; -import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 5b4a85c43..a8f7e9cf9 100755 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -9,7 +9,7 @@ dev-url: http://github.com/eccentricdevotion/TARDIS/ url: http://tardis.pages.dev/ version: ${project.version}-b${project.build.number} build-number: ${project.build.number} -api-version: '1.20' +api-version: '1.20.5' libraries: - org.jsoup:jsoup:1.16.1 permissions: From 15dcf29a55ddd9d2032bd6e98115a34422fb047e Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Wed, 24 Apr 2024 14:48:14 +1200 Subject: [PATCH 44/96] Waiting for Paper to update --- .../chatGUI/TARDISUpdateChatGUIAdventure.java | 13 ++- .../TARDIS/messaging/AdventureMessage.java | 84 +++++++++---------- 2 files changed, 48 insertions(+), 49 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/chatGUI/TARDISUpdateChatGUIAdventure.java b/src/main/java/me/eccentric_nz/TARDIS/chatGUI/TARDISUpdateChatGUIAdventure.java index 7979966ea..c680e7465 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/chatGUI/TARDISUpdateChatGUIAdventure.java +++ b/src/main/java/me/eccentric_nz/TARDIS/chatGUI/TARDISUpdateChatGUIAdventure.java @@ -18,7 +18,6 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.enumeration.TardisModule; -import net.kyori.adventure.text.TextComponent; import org.bukkit.entity.Player; public class TARDISUpdateChatGUIAdventure implements TARDISUpdateChatGUI { @@ -34,42 +33,42 @@ public boolean showInterface(Player player, String[] args) { if (args.length == 1) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_SECTION"); player.sendMessage("------"); - plugin.getJsonKeeper().getSections().forEach((s) -> player.sendMessage((TextComponent) s)); +// plugin.getJsonKeeper().getSections().forEach((s) -> player.sendMessage((TextComponent) s)); player.sendMessage("------"); return true; } if (args[1].equalsIgnoreCase("controls")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_CONTROL"); player.sendMessage("------"); - plugin.getJsonKeeper().getControls().forEach((c) -> player.sendMessage((TextComponent) c)); +// plugin.getJsonKeeper().getControls().forEach((c) -> player.sendMessage((TextComponent) c)); player.sendMessage("------"); return true; } if (args[1].equalsIgnoreCase("interfaces")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_INTERFACE"); player.sendMessage("------"); - plugin.getJsonKeeper().getInterfaces().forEach((i) -> player.sendMessage((TextComponent) i)); +// plugin.getJsonKeeper().getInterfaces().forEach((i) -> player.sendMessage((TextComponent) i)); player.sendMessage("------"); return true; } if (args[1].equalsIgnoreCase("locations")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_LOCATION"); player.sendMessage("------"); - plugin.getJsonKeeper().getLocations().forEach((l) -> player.sendMessage((TextComponent) l)); +// plugin.getJsonKeeper().getLocations().forEach((l) -> player.sendMessage((TextComponent) l)); player.sendMessage("------"); return true; } if (args[1].equalsIgnoreCase("sensors")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_SENSOR"); player.sendMessage("------"); - plugin.getJsonKeeper().getSensors().forEach((s) -> player.sendMessage((TextComponent) s)); +// plugin.getJsonKeeper().getSensors().forEach((s) -> player.sendMessage((TextComponent) s)); player.sendMessage("------"); return true; } if (args[1].equalsIgnoreCase("others")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_OTHER"); player.sendMessage("------"); - plugin.getJsonKeeper().getOthers().forEach((o) -> player.sendMessage((TextComponent) o)); +// plugin.getJsonKeeper().getOthers().forEach((o) -> player.sendMessage((TextComponent) o)); player.sendMessage("------"); return true; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/messaging/AdventureMessage.java b/src/main/java/me/eccentric_nz/TARDIS/messaging/AdventureMessage.java index b1897c46b..025472f94 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/messaging/AdventureMessage.java +++ b/src/main/java/me/eccentric_nz/TARDIS/messaging/AdventureMessage.java @@ -45,24 +45,24 @@ public class AdventureMessage implements TARDISMessage { @Override public void sendJenkinsUpdateReady(CommandSender cs, int current, int latest) { - cs.sendMessage(AdventureComponents.getJenkinsUpdateReady(current, latest)); +// cs.sendMessage(AdventureComponents.getJenkinsUpdateReady(current, latest)); } @Override public void sendUpdateCommand(CommandSender cs) { - cs.sendMessage(AdventureComponents.getUpdateCommand()); +// cs.sendMessage(AdventureComponents.getUpdateCommand()); } @Override public void sendBuildsBehind(CommandSender cs, int behind) { - cs.sendMessage(AdventureComponents.getBuildsBehind(behind)); +// cs.sendMessage(AdventureComponents.getBuildsBehind(behind)); } @Override public void message(CommandSender cs, TardisModule module, String message) { if (cs != null) { TextComponent textComponent = AdventureComponents.getModule(module).append(Component.text(message, NamedTextColor.WHITE)); - cs.sendMessage(textComponent); +// cs.sendMessage(textComponent); } } @@ -119,210 +119,210 @@ public void sendJoined(Player player, String key, String sub, boolean handbrake) String local = TARDIS.plugin.getLanguage().getString(key); String other = (handbrake) ? TARDIS.plugin.getLanguage().getString("HANDBRAKE_RELEASE") : TARDIS.plugin.getLanguage().getString("LEAVING_VORTEX"); TextComponent actionBar = AdventureComponents.getModule(TardisModule.TARDIS).append(Component.text(String.format(local, sub) + " " + other, NamedTextColor.WHITE)); - player.sendActionBar(actionBar); +// player.sendActionBar(actionBar); } @Override public void broadcast(TardisModule module, String message) { - message(TARDIS.plugin.getServer(), module, message); +// message(TARDIS.plugin.getServer(), module, message); } @Override public void sendWithColour(CommandSender cs, TardisModule module, String message, String hex) { TextColor colour = TextColor.fromHexString(hex); TextComponent textComponent = AdventureComponents.getModule(module).append(Component.text(message, colour)); - cs.sendMessage(textComponent); +// cs.sendMessage(textComponent); } @Override public void messageWithColour(CommandSender cs, String message, String hex) { TextColor colour = TextColor.fromHexString(hex); TextComponent textComponent = Component.text(message, colour); - cs.sendMessage(textComponent); +// cs.sendMessage(textComponent); } @Override public void sendRequestComehereAccept(CommandSender cs, String key, String command) { - cs.sendMessage(AdventureComponents.getRequestComehereAccept(key, command)); +// cs.sendMessage(AdventureComponents.getRequestComehereAccept(key, command)); } @Override public void sendAbandoned(CommandSender cs, int i, String owner, String location, int id) { - cs.sendMessage(AdventureComponents.getAbandoned(i, owner, location, id)); +// cs.sendMessage(AdventureComponents.getAbandoned(i, owner, location, id)); } @Override public void sendTransmat(CommandSender cs, Transmat t) { - cs.sendMessage(AdventureComponents.getTransmat(t)); +// cs.sendMessage(AdventureComponents.getTransmat(t)); } @Override public void sendTARDISForList(CommandSender cs, Tardis t, String world, int x, int y, int z) { - cs.sendMessage(AdventureComponents.getTARDISForList(t, world, x, y, z)); +// cs.sendMessage(AdventureComponents.getTARDISForList(t, world, x, y, z)); } @Override public void sendExterminate(CommandSender cs, TARDIS plugin) { - cs.sendMessage(AdventureComponents.getExterminate(plugin)); +// cs.sendMessage(AdventureComponents.getExterminate(plugin)); } @Override public void sendRescue(CommandSender cs, TARDIS plugin) { - cs.sendMessage(AdventureComponents.getRescue(plugin)); +// cs.sendMessage(AdventureComponents.getRescue(plugin)); } @Override public void sendSuggestCommand(CommandSender cs, String item, String hover, String colour) { - cs.sendMessage(AdventureComponents.getSuggestCommand(item, hover, colour)); +// cs.sendMessage(AdventureComponents.getSuggestCommand(item, hover, colour)); } @Override public void sendRunCommand(CommandSender cs, String item, String hover, String colour) { - cs.sendMessage(AdventureComponents.getRunCommand(item, hover, colour)); +// cs.sendMessage(AdventureComponents.getRunCommand(item, hover, colour)); } @Override public void sendShowMore(CommandSender cs, String command) { - cs.sendMessage(AdventureComponents.getShowMore(command)); +// cs.sendMessage(AdventureComponents.getShowMore(command)); } @Override public void sendRecharger(CommandSender cs, String recharger, String world, String x, String y, String z, boolean hasPerm) { - cs.sendMessage(AdventureComponents.getRecharger(recharger, world, x, y, z, hasPerm)); +// cs.sendMessage(AdventureComponents.getRecharger(recharger, world, x, y, z, hasPerm)); } @Override public void sendHome(CommandSender cs, TARDIS plugin, String world, int x, int y, int z) { - cs.sendMessage(AdventureComponents.getHome(plugin, world, x, y, z)); +// cs.sendMessage(AdventureComponents.getHome(plugin, world, x, y, z)); } @Override public void sendSave(CommandSender cs, HashMap map, String world) { - cs.sendMessage(AdventureComponents.getSave(map, world)); +// cs.sendMessage(AdventureComponents.getSave(map, world)); } @Override public void sendArea(CommandSender cs, Area a, int n, boolean hasPerm) { - cs.sendMessage(AdventureComponents.getArea(a, n, hasPerm)); +// cs.sendMessage(AdventureComponents.getArea(a, n, hasPerm)); } @Override public void sendRoom(CommandSender cs, String room, boolean hasPerm) { - cs.sendMessage(AdventureComponents.getRoom(room, hasPerm)); +// cs.sendMessage(AdventureComponents.getRoom(room, hasPerm)); } @Override public void sendRoomGallery(CommandSender cs) { - cs.sendMessage(AdventureComponents.getRoomGallery()); +// cs.sendMessage(AdventureComponents.getRoomGallery()); } @Override public void sendEyebrows(CommandSender cs) { - cs.sendMessage(AdventureComponents.getEyebrows()); +// cs.sendMessage(AdventureComponents.getEyebrows()); } @Override public void sendSign(CommandSender cs) { - cs.sendMessage(AdventureComponents.getSign()); +// cs.sendMessage(AdventureComponents.getSign()); } @Override public void sendInfo(CommandSender cs, String first, String value, String split) { - cs.sendMessage(AdventureComponents.getUpdate(first, value, split)); +// cs.sendMessage(AdventureComponents.getUpdate(first, value, split)); } @Override public void sendHADS(CommandSender cs, TARDIS plugin) { - cs.sendMessage(AdventureComponents.getHADS(plugin)); +// cs.sendMessage(AdventureComponents.getHADS(plugin)); } @Override public void sendColouredCommand(CommandSender cs, String which, String command, TARDIS plugin) { - cs.sendMessage(AdventureComponents.getColouredCommand(which, command, plugin)); +// cs.sendMessage(AdventureComponents.getColouredCommand(which, command, plugin)); } @Override public void sendInsertedColour(CommandSender cs, String local, String which, TARDIS plugin) { - cs.sendMessage(AdventureComponents.getInsertColour(local, which, plugin)); +// cs.sendMessage(AdventureComponents.getInsertColour(local, which, plugin)); } @Override public void sendWithColours(CommandSender cs, String first, String colour, String last, String hue) { - cs.sendMessage(AdventureComponents.getWithColours(first, colour, last, hue)); +// cs.sendMessage(AdventureComponents.getWithColours(first, colour, last, hue)); } @Override public void sendWithColours(CommandSender cs, TardisModule module, String first, String colour, String last, String hue) { - cs.sendMessage(AdventureComponents.getWithColours(module, first, colour, last, hue)); +// cs.sendMessage(AdventureComponents.getWithColours(module, first, colour, last, hue)); } @Override public void sendCommand(CommandSender cs, String root, String command) { - cs.sendMessage(AdventureComponents.getCommand(root, command)); +// cs.sendMessage(AdventureComponents.getCommand(root, command)); } @Override public void sendHeadsUpDisplay(Player player, TARDIS plugin) { TextComponent actionBar = LegacyComponentSerializer.legacyAmpersand().deserialize(plugin.getUtils().actionBarFormat(player)); - player.sendActionBar(actionBar); +// player.sendActionBar(actionBar); } @Override public void sendWikiLink(Player player, WikiLink wikiLink) { - player.sendMessage(AdventureComponents.getWikiLink(wikiLink)); +// player.sendMessage(AdventureComponents.getWikiLink(wikiLink)); } @Override public void sendStartBanner(CommandSender cs) { for (Component c : AdventureComponents.getStartupBanner()) { - cs.sendMessage(c); +// cs.sendMessage(c); } } @Override public void sendProtected(CommandSender cs, String xyz, String location, int id) { - cs.sendMessage(AdventureComponents.getRemoveProtected(xyz, location, id)); +// cs.sendMessage(AdventureComponents.getRemoveProtected(xyz, location, id)); } @Override public void announceRepeater(Player player, String value) { Title.Times times = Title.Times.times(Duration.ofMillis(250), Duration.ofMillis(1000), Duration.ofMillis(250)); Title title = Title.title(Component.empty(), Component.text(value), times); - player.showTitle(title); +// player.showTitle(title); } @Override public void sendStatus(Player player, String key) { String local = TARDIS.plugin.getLanguage().getString(key); TextComponent actionBar = AdventureComponents.getModule(TardisModule.TARDIS).append(Component.text(local, NamedTextColor.WHITE)); - player.sendActionBar(actionBar); +// player.sendActionBar(actionBar); } @Override public void sendStatus(Player player, String key, Object... subs) { String local = String.format(TARDIS.plugin.getLanguage().getString(key), subs); TextComponent actionBar = AdventureComponents.getModule(TardisModule.TARDIS).append(Component.text(local, NamedTextColor.WHITE)); - player.sendActionBar(actionBar); +// player.sendActionBar(actionBar); } @Override public void sendArtron(Player player, int id, int used) { ArtronIndicatorData data = new TARDISArtronIndicator(TARDIS.plugin).getLevels(player, id, used); TextComponent actionBar = AdventureComponents.getArtronIndicator(data); - player.sendActionBar(actionBar); +// player.sendActionBar(actionBar); } @Override public void sendFind(Player player, String world, int x, int y, int z) { String local = TARDIS.plugin.getLanguage().getString("TARDIS_FIND"); - player.sendMessage(AdventureComponents.getFind(local.substring(0, local.length() - 2), world, x, y, z)); +// player.sendMessage(AdventureComponents.getFind(local.substring(0, local.length() - 2), world, x, y, z)); } public void sendJoinedStatus(Player player, String key, String otherKey) { String local = TARDIS.plugin.getLanguage().getString(key); String other = TARDIS.plugin.getLanguage().getString(otherKey); TextComponent actionBar = AdventureComponents.getModule(TardisModule.TARDIS).append(Component.text(local + " " + other, NamedTextColor.WHITE)); - player.sendActionBar(actionBar); +// player.sendActionBar(actionBar); } public void message(Audience audience, TardisModule module, String message) { From ee840ef96b1c213ab19376c932e58f534e6121b0 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Wed, 24 Apr 2024 15:18:45 +1200 Subject: [PATCH 45/96] Update obfuscated field names --- .../disguise/TARDISChameleonArchDisguiser.java | 4 ++-- .../tardischunkgenerator/helpers/TARDISPacketListener.java | 2 +- .../eccentric_nz/tardisweepingangels/nms/TWAFollower.java | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISChameleonArchDisguiser.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISChameleonArchDisguiser.java index 0fe2d1b64..b96fc2105 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISChameleonArchDisguiser.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISChameleonArchDisguiser.java @@ -59,7 +59,7 @@ public void changeSkin(String name) { GameProfile arch = new GameProfile(player.getUniqueId(), name); arch.getProperties().removeAll("textures"); arch.getProperties().put("textures", new Property("textures", archSkin, archSignature)); - Field gpField = Player.class.getDeclaredField("cq"); // cr = GameProfile + Field gpField = Player.class.getDeclaredField("cC"); // cC = GameProfile gpField.setAccessible(true); gpField.set(entityPlayer, arch); gpField.setAccessible(false); @@ -103,7 +103,7 @@ public void resetSkin() { nameField.set(arch, oldName); nameField.setAccessible(false); arch.getProperties().putAll(properties); - Field gpField = Player.class.getDeclaredField("cq"); // cr = GameProfile + Field gpField = Player.class.getDeclaredField("cC"); // cC = GameProfile gpField.setAccessible(true); gpField.set(entityPlayer, arch); gpField.setAccessible(false); diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISPacketListener.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISPacketListener.java index 948876c70..3360af897 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISPacketListener.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/helpers/TARDISPacketListener.java @@ -65,7 +65,7 @@ public static void removePlayer(Player player) { private static Connection getConnection(final ServerCommonPacketListenerImpl playerConnection) { try { if (connectionField == null) { - connectionField = ServerCommonPacketListenerImpl.class.getDeclaredField("c"); + connectionField = ServerCommonPacketListenerImpl.class.getDeclaredField("e"); connectionField.setAccessible(true); } return (Connection) connectionField.get(playerConnection); diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java index 2ef9873fd..b347744f1 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java @@ -41,9 +41,9 @@ public TWAFollower(Level world, UUID owner) { } public static void unfreezeEntityRegistry() throws NoSuchFieldException, IllegalAccessException { - Field intrusiveHolderCache = MappedRegistry.class.getDeclaredField("m"); - intrusiveHolderCache.setAccessible(true); - intrusiveHolderCache.set(BuiltInRegistries.ENTITY_TYPE, new IdentityHashMap, Holder.Reference>>()); + Field unregisteredIntrusiveHolders = MappedRegistry.class.getDeclaredField("m"); + unregisteredIntrusiveHolders.setAccessible(true); + unregisteredIntrusiveHolders.set(BuiltInRegistries.ENTITY_TYPE, new IdentityHashMap, Holder.Reference>>()); Field frozenField = MappedRegistry.class.getDeclaredField("l"); frozenField.setAccessible(true); frozenField.set(BuiltInRegistries.ENTITY_TYPE, false); From c0c4074b6bb2d3014f088f93ec7953c789fb621f Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Wed, 24 Apr 2024 16:50:45 +1200 Subject: [PATCH 46/96] Update TARDIS advancement files --- .../TARDIS/utility/TARDISChecker.java | 47 ++++++++++--------- src/main/resources/craft.json | 3 +- src/main/resources/defender.json | 3 +- src/main/resources/energy.json | 3 +- src/main/resources/farm.json | 3 +- src/main/resources/friends.json | 3 +- src/main/resources/kill.json | 3 +- src/main/resources/pack.mcmeta | 2 +- src/main/resources/rooms.json | 3 +- src/main/resources/root.json | 5 +- src/main/resources/tardis.json | 3 +- src/main/resources/travel.json | 3 +- todo.md | 4 +- 13 files changed, 50 insertions(+), 35 deletions(-) mode change 100755 => 100644 src/main/resources/root.json diff --git a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISChecker.java b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISChecker.java index f1ac135d3..d5cf4e19d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISChecker.java +++ b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISChecker.java @@ -18,13 +18,14 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import java.io.*; -import java.util.HashMap; -import java.util.Map; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.enumeration.Advancement; import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import java.io.*; +import java.util.HashMap; +import java.util.Map; + /** * @author eccentric_nz */ @@ -71,7 +72,7 @@ public static void copy(String filename, File file) { public void checkAdvancements() { // get server's main world folder - // is there a worlds container? + // is there a world container? File container = plugin.getServer().getWorldContainer(); String s_world = plugin.getServer().getWorlds().get(0).getName(); // check if directories exist @@ -81,28 +82,15 @@ public void checkAdvancements() { TARDIS.plugin.getMessenger().message(TARDIS.plugin.getConsole(), TardisModule.WARNING, plugin.getLanguage().getString("ADVANCEMENT_DIRECTORIES")); tardisDir.mkdirs(); } - // update root advancement - File root = new File(dataPacksRoot, "root.json"); - if (root.exists()) { - copy("root.json", root); - } - for (Advancement advancement : Advancement.values()) { - String json = advancement.getConfigName() + ".json"; - File jfile = new File(dataPacksRoot, json); - if (!jfile.exists()) { - TARDIS.plugin.getMessenger().message(TARDIS.plugin.getConsole(), TardisModule.WARNING, String.format(plugin.getLanguage().getString("ADVANCEMENT_NOT_FOUND"), json)); - TARDIS.plugin.getMessenger().message(TARDIS.plugin.getConsole(), TardisModule.WARNING, String.format(plugin.getLanguage().getString("ADVANCEMENT_COPYING"), json)); - copy(json, jfile); - } - } String dataPacksMeta = container.getAbsolutePath() + File.separator + s_world + File.separator + "datapacks" + File.separator + "tardis"; File mcmeta = new File(dataPacksMeta, "pack.mcmeta"); if (!mcmeta.exists()) { TARDIS.plugin.getMessenger().message(TARDIS.plugin.getConsole(), TardisModule.WARNING, String.format(plugin.getLanguage().getString("ADVANCEMENT_NOT_FOUND"), "pack.mcmeta")); TARDIS.plugin.getMessenger().message(TARDIS.plugin.getConsole(), TardisModule.WARNING, String.format(plugin.getLanguage().getString("ADVANCEMENT_COPYING"), "pack.mcmeta")); copy("pack.mcmeta", mcmeta); + write(dataPacksRoot, false); } else { - // update the format - 15 is the latest for 1.20 + // update the format - 41 is the latest for 1.20.5 // it's a json file, so load it and check the value Gson gson = new GsonBuilder().create(); try { @@ -114,22 +102,37 @@ public void checkAdvancements() { for (Map.Entry data : values.entrySet()) { if (data.getKey().equals("pack_format")) { Double d = (Double) data.getValue(); - if (d < 15.0D) { + if (d < 41.0D) { Map> mcmap = new HashMap<>(); Map pack = new HashMap<>(); pack.put("description", "Data pack for the TARDIS plugin"); - pack.put("pack_format", 15); + pack.put("pack_format", 41); mcmap.put("pack", pack); FileWriter writer = new FileWriter(mcmeta); gson.toJson(mcmap, writer); writer.close(); + // update json files + write(dataPacksRoot, true); } } } } } - } catch (IOException e) { + } catch (IOException ignored) { + } + } + } + private void write(String dataPacksRoot, boolean overwrite) { + for (Advancement advancement : Advancement.values()) { + String json = advancement.getConfigName() + ".json"; + File jfile = new File(dataPacksRoot, json); + if (!jfile.exists() || overwrite) { + if (!overwrite) { + TARDIS.plugin.getMessenger().message(TARDIS.plugin.getConsole(), TardisModule.WARNING, String.format(plugin.getLanguage().getString("ADVANCEMENT_NOT_FOUND"), json)); + } + TARDIS.plugin.getMessenger().message(TARDIS.plugin.getConsole(), TardisModule.WARNING, String.format(plugin.getLanguage().getString("ADVANCEMENT_COPYING"), json)); + copy(json, jfile); } } } diff --git a/src/main/resources/craft.json b/src/main/resources/craft.json index 13bc44276..3838834a8 100644 --- a/src/main/resources/craft.json +++ b/src/main/resources/craft.json @@ -1,7 +1,8 @@ { "display": { "icon": { - "item": "minecraft:lapis_block" + "count": 1, + "id": "minecraft:lapis_block" }, "title": "Craft a TARDIS Seed Block", "description": "One step closer to stealing a TARDIS", diff --git a/src/main/resources/defender.json b/src/main/resources/defender.json index 7e1027d6a..6541987df 100644 --- a/src/main/resources/defender.json +++ b/src/main/resources/defender.json @@ -1,7 +1,8 @@ { "display": { "icon": { - "item": "minecraft:bow" + "count": 1, + "id": "minecraft:bow" }, "title": "Defender of the universe", "description": "Kill one of every Whovian monster" diff --git a/src/main/resources/energy.json b/src/main/resources/energy.json index 367c89c60..1291c490d 100644 --- a/src/main/resources/energy.json +++ b/src/main/resources/energy.json @@ -1,7 +1,8 @@ { "display": { "icon": { - "item": "minecraft:redstone_block" + "count": 1, + "id": "minecraft:redstone_block" }, "title": "Power hungry", "description": "Overcharge the Artron Energy Capacitor" diff --git a/src/main/resources/farm.json b/src/main/resources/farm.json index ec2126583..dbc4eb82c 100644 --- a/src/main/resources/farm.json +++ b/src/main/resources/farm.json @@ -1,7 +1,8 @@ { "display": { "icon": { - "item": "minecraft:wheat" + "count": 1, + "id": "minecraft:wheat" }, "title": "Old MacDonald had a farm", "description": "Farm all allowed animal types" diff --git a/src/main/resources/friends.json b/src/main/resources/friends.json index d7342cd6b..4ebf0ccc3 100644 --- a/src/main/resources/friends.json +++ b/src/main/resources/friends.json @@ -1,7 +1,8 @@ { "display": { "icon": { - "item": "minecraft:red_tulip" + "count": 1, + "id": "minecraft:red_tulip" }, "title": "The host with the most", "description": "Add companions to your TARDIS" diff --git a/src/main/resources/kill.json b/src/main/resources/kill.json index 1f4d116ad..7dbd824c2 100644 --- a/src/main/resources/kill.json +++ b/src/main/resources/kill.json @@ -1,7 +1,8 @@ { "display": { "icon": { - "item": "minecraft:creeper_head" + "count": 1, + "id": "minecraft:creeper_head" }, "title": "Lucky hunter", "description": "Kill a charged creeper", diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index b5f887106..fcdcd7f88 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "Data pack for the TARDIS plugin", - "pack_format": 12 + "pack_format": 41 } } diff --git a/src/main/resources/rooms.json b/src/main/resources/rooms.json index 6915b0fa6..ecdec4992 100644 --- a/src/main/resources/rooms.json +++ b/src/main/resources/rooms.json @@ -1,7 +1,8 @@ { "display": { "icon": { - "item": "minecraft:bookshelf" + "count": 1, + "id": "minecraft:bookshelf" }, "title": "Room freak", "description": "Grow all room types" diff --git a/src/main/resources/root.json b/src/main/resources/root.json old mode 100755 new mode 100644 index 799de5b36..eba7affdc --- a/src/main/resources/root.json +++ b/src/main/resources/root.json @@ -1,7 +1,8 @@ { "display": { "icon": { - "item": "minecraft:compass", + "count": 1, + "id": "minecraft:compass", "nbt": "{ \"CustomModelData\": 1001 }" }, "title": "Doctor Who", @@ -28,4 +29,4 @@ "place_block" ] ] -} \ No newline at end of file +} diff --git a/src/main/resources/tardis.json b/src/main/resources/tardis.json index 7f9d2eea7..49b65ac98 100644 --- a/src/main/resources/tardis.json +++ b/src/main/resources/tardis.json @@ -1,7 +1,8 @@ { "display": { "icon": { - "item": "minecraft:minecart" + "count": 1, + "id": "minecraft:minecart" }, "title": "Create a TARDIS", "description": "The time vortex awaits!" diff --git a/src/main/resources/travel.json b/src/main/resources/travel.json index c90cc3fc1..88ccf3131 100644 --- a/src/main/resources/travel.json +++ b/src/main/resources/travel.json @@ -1,7 +1,8 @@ { "display": { "icon": { - "item": "minecraft:diamond" + "count": 1, + "id": "minecraft:diamond" }, "title": "Got the travel bug", "description": "Travel in your TARDIS" diff --git a/todo.md b/todo.md index befdbc31f..bf0ab4da9 100644 --- a/todo.md +++ b/todo.md @@ -9,7 +9,9 @@ * New interior with console * Malfunction & manual flight classes 4. Update old light level controls -5. ? +5. Add Armadillo +6. Wolf armour and variants +7. ? ## Next version `5.7.0` From c7c34878a7bfdbb1077a6723a657efb36e165b17 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Thu, 25 Apr 2024 12:59:42 +1200 Subject: [PATCH 47/96] Fix Biome GUI scrolling --- .../console/telepathic/EnvironmentBiomes.java | 2 ++ .../console/telepathic/TelepathicBiomeListener.java | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/EnvironmentBiomes.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/EnvironmentBiomes.java index 30202ecdb..6a6583553 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/EnvironmentBiomes.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/EnvironmentBiomes.java @@ -4,6 +4,7 @@ import org.bukkit.block.Biome; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -86,5 +87,6 @@ public class EnvironmentBiomes { OVERWORLD.add(biome); } } + Collections.sort(OVERWORLD); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicBiomeListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicBiomeListener.java index 945af98b2..cf6a3082c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicBiomeListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicBiomeListener.java @@ -9,6 +9,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -33,6 +34,15 @@ public TelepathicBiomeListener(TARDIS plugin) { biomes = getBiomes(); } + @EventHandler + public void onWallMenuOpen(InventoryOpenEvent event) { + String name = event.getView().getTitle(); + if (name.equals(ChatColor.DARK_RED + "Telepathic Biome Finder")) { + Player p = (Player) event.getPlayer(); + scroll.put(p.getUniqueId(), 0); + } + } + @EventHandler(ignoreCancelled = true) public void onBiomeMenuClick(InventoryClickEvent event) { InventoryView view = event.getView(); @@ -116,6 +126,9 @@ private ItemStack[][] getBiomes() { int c = 0; for (Biome biome : EnvironmentBiomes.OVERWORLD) { ItemStack is = new ItemStack(EnvironmentBiomes.BIOME_BLOCKS.get(biome), 1); + ItemMeta im = is.getItemMeta(); + im.setDisplayName(TARDISStringUtils.capitalise(biome.toString())); + is.setItemMeta(im); stacks[r][c] = is; c++; if (c == 8) { From 89fa78a6a3f5a94bdb36010e90e6a53259e33b48 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Thu, 25 Apr 2024 13:00:12 +1200 Subject: [PATCH 48/96] Fix building console --- .../me/eccentric_nz/TARDIS/console/ConsoleBuilder.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index 56f0ccd2d..37e132dc2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -20,6 +20,7 @@ public class ConsoleBuilder { private final TARDIS plugin; + private UUID right; public ConsoleBuilder(TARDIS plugin) { this.plugin = plugin; @@ -103,8 +104,8 @@ public void create(Block block, int type, int id) { } private UUID spawnControl(ConsoleInteraction interaction, Location location, float angle, int id) { - if (interaction == ConsoleInteraction.SCREEN_LEFT) { - return null; + if (interaction == ConsoleInteraction.SCREEN_LEFT && right != null) { + return right; } Material material = interaction.getMaterial(); int cmd = interaction.getCustomModelData(); @@ -130,6 +131,9 @@ private UUID spawnControl(ConsoleInteraction interaction, Location location, flo float yaw = Location.normalizeYaw(angle); // set display rotation display.setRotation(yaw, 0); + if (interaction == ConsoleInteraction.SCREEN_RIGHT) { + right = uuid; + } return uuid; } From ce806c7d6ce04d85c2b05071b135f2ee413afc1d Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Fri, 26 Apr 2024 19:10:01 +1200 Subject: [PATCH 49/96] Be able to resume exterior flight if the TARDIS is floating in the air --- .../commands/travel/TARDISTravelStop.java | 35 ++++++++++++++++--- .../database/TARDISMySQLDatabaseUpdater.java | 21 ++++++----- .../TARDIS/database/TARDISSQLiteDatabase.java | 2 +- .../database/TARDISSQLiteDatabaseUpdater.java | 25 +++++++------ .../TARDIS/database/tool/Converter.java | 2 +- .../TARDIS/database/tool/Main.java | 2 +- .../TARDIS/database/tool/SQL.java | 6 ++-- .../TARDIS/flight/FlightPersister.java | 13 +++++-- .../TARDIS/flight/FlightReturnData.java | 9 +++-- .../TARDIS/flight/FlightVisibility.java | 2 +- .../TARDIS/flight/TARDISExteriorFlight.java | 15 ++++++-- .../TARDIS/listeners/TARDISJoinListener.java | 2 +- todo.md | 1 + 13 files changed, 98 insertions(+), 37 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/travel/TARDISTravelStop.java b/src/main/java/me/eccentric_nz/TARDIS/commands/travel/TARDISTravelStop.java index 5cba9b2d6..f21031952 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/travel/TARDISTravelStop.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/travel/TARDISTravelStop.java @@ -19,7 +19,6 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.api.event.TARDISTravelEvent; import me.eccentric_nz.TARDIS.builders.BuildData; -import me.eccentric_nz.TARDIS.rotors.TARDISTimeRotor; import me.eccentric_nz.TARDIS.database.data.Tardis; import me.eccentric_nz.TARDIS.database.resultset.ResultSetHomeLocation; import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; @@ -28,6 +27,7 @@ import me.eccentric_nz.TARDIS.enumeration.TravelType; import me.eccentric_nz.TARDIS.flight.FlightReturnData; import me.eccentric_nz.TARDIS.flight.TARDISExteriorFlight; +import me.eccentric_nz.TARDIS.rotors.TARDISTimeRotor; import org.bukkit.Location; import org.bukkit.entity.*; import org.bukkit.util.Vector; @@ -69,20 +69,27 @@ public boolean action(Player player, int id) { // land TARDIS FlightReturnData frd = plugin.getTrackerKeeper().getFlyingReturnLocation().get(player.getUniqueId()); Entity chicken = plugin.getServer().getEntity(frd.getChicken()); + Entity stand = plugin.getServer().getEntity(frd.getStand()); if (chicken != null) { chicken.setVelocity(new Vector(0, 0, 0)); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { + Entity as = stand; + if (as == null) { + // attempt to find stand + as = findStand(chicken); + } + if (as != null) { + chicken.removePassenger(as); + } // kill chicken - Entity stand = chicken.getPassengers().get(0); - chicken.removePassenger(stand); chicken.remove(); // teleport player back to the TARDIS interior - new TARDISExteriorFlight(plugin).stopFlying(player, (ArmorStand) stand); + new TARDISExteriorFlight(plugin).stopFlying(player, (ArmorStand) as); }); } else { // scan for nearby chickens in case player teleport fails due to lag for (Entity e : player.getLocation().getWorld().getNearbyEntities(player.getLocation(), 4, 4, 4, (s) -> s.getType() == EntityType.CHICKEN)) { - if (!e.getPassengers().isEmpty() && e.getPassengers().get(0) instanceof ArmorStand armorStand) { + if (!e.getPassengers().isEmpty() && e.getPassengers().getFirst() instanceof ArmorStand armorStand) { e.setVelocity(new Vector(0, 0, 0)); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { // kill chicken @@ -141,6 +148,13 @@ public boolean action(Player player, int id) { HashMap whereh = new HashMap<>(); whereh.put("tardis_id", id); plugin.getQueryFactory().doSyncUpdate("tardis", seth, whereh); + // also set the console handbrake state if there is one + HashMap setc = new HashMap<>(); + setc.put("state", 1); + HashMap wherec = new HashMap<>(); + wherec.put("tardis_id", id); + wherec.put("control", "HANDBRAKE"); + plugin.getQueryFactory().doSyncUpdate("interactions", setc, wherec); plugin.getPM().callEvent(new TARDISTravelEvent(player, null, TravelType.STOP, id)); } // stop time rotor? @@ -161,4 +175,15 @@ public boolean action(Player player, int id) { } return true; } + + private Entity findStand(Entity other) { + Entity stand = null; + for (Entity e : other.getNearbyEntities(3, 3, 3)) { + if (e instanceof ArmorStand as) { + stand = as; + break; + } + } + return stand; + } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/TARDISMySQLDatabaseUpdater.java b/src/main/java/me/eccentric_nz/TARDIS/database/TARDISMySQLDatabaseUpdater.java index 6fffe326a..a93418921 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/TARDISMySQLDatabaseUpdater.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/TARDISMySQLDatabaseUpdater.java @@ -46,6 +46,7 @@ class TARDISMySQLDatabaseUpdater { private final List chameleonupdates = new ArrayList<>(); private final List farmingupdates = new ArrayList<>(); private final List sonicupdates = new ArrayList<>(); + private final List flightupdates = new ArrayList<>(); private final HashMap uuidUpdates = new HashMap<>(); private final Statement statement; private final TARDIS plugin; @@ -130,6 +131,8 @@ class TARDISMySQLDatabaseUpdater { sonicupdates.add("sonic_uuid varchar(48) DEFAULT ''"); sonicupdates.add("last_scanned varchar(512) DEFAULT ''"); sonicupdates.add("scan_type int(1) DEFAULT '0'"); + flightupdates.add("chicken varchar(48) DEFAULT ''"); + flightupdates.add("stand varchar(48) DEFAULT ''"); } /** @@ -247,6 +250,16 @@ void updateTables() { statement.executeUpdate(s_alter); } } + for (String f : flightupdates) { + String[] ssplit = f.split(" "); + String f_query = "SHOW COLUMNS FROM " + prefix + "flight LIKE '" + ssplit[0] + "'"; + ResultSet fa = statement.executeQuery(f_query); + if (!fa.next()) { + i++; + String f_alter = "ALTER TABLE " + prefix + "flight ADD " + f; + statement.executeUpdate(f_alter); + } + } // update data type for `data` in blocks String blockdata_check = "SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '" + prefix + "blocks' AND COLUMN_NAME = 'data'"; ResultSet rsbdc = statement.executeQuery(blockdata_check); @@ -269,14 +282,6 @@ void updateTables() { String bio_alter = "ALTER TABLE " + prefix + "current ADD biome varchar(64) DEFAULT ''"; statement.executeUpdate(bio_alter); } - // add chicken to flight persistence - String chi_query = "SHOW COLUMNS FROM " + prefix + "flight LIKE 'chicken'"; - ResultSet rschi = statement.executeQuery(chi_query); - if (!rschi.next()) { - i++; - String chi_alter = "ALTER TABLE " + prefix + "flight ADD chicken varchar(48) DEFAULT ''"; - statement.executeUpdate(chi_alter); - } // add preset to homes String preset_query = "SHOW COLUMNS FROM " + prefix + "homes LIKE 'preset'"; ResultSet rspreset = statement.executeQuery(preset_query); diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/TARDISSQLiteDatabase.java b/src/main/java/me/eccentric_nz/TARDIS/database/TARDISSQLiteDatabase.java index 727017936..ec6677199 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/TARDISSQLiteDatabase.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/TARDISSQLiteDatabase.java @@ -141,7 +141,7 @@ public void createTables() { statement.executeUpdate(queryFarmingPrefs); // Table structure for table 'flight' - String queryFlight = "CREATE TABLE IF NOT EXISTS " + prefix + "flight (f_id INTEGER PRIMARY KEY NOT NULL, uuid TEXT DEFAULT '', tardis_id INTEGER, location TEXT DEFAULT '')"; + String queryFlight = "CREATE TABLE IF NOT EXISTS " + prefix + "flight (f_id INTEGER PRIMARY KEY NOT NULL, uuid TEXT DEFAULT '', tardis_id INTEGER, location TEXT DEFAULT '', chicken TEXT DEFAULT '', stand TEXT DEFAULT '')"; statement.executeUpdate(queryFlight); // Table structure for table 'forcefield' diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/TARDISSQLiteDatabaseUpdater.java b/src/main/java/me/eccentric_nz/TARDIS/database/TARDISSQLiteDatabaseUpdater.java index 0bfcebd73..67e84c2d2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/TARDISSQLiteDatabaseUpdater.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/TARDISSQLiteDatabaseUpdater.java @@ -48,6 +48,7 @@ class TARDISSQLiteDatabaseUpdater { private final List chameleonupdates = new ArrayList<>(); private final List farmingupdates = new ArrayList<>(); private final List sonicupdates = new ArrayList<>(); + private final List flightupdates = new ArrayList<>(); private final List uuidUpdates = Arrays.asList("achievements", "ars", "player_prefs", "storage", "t_count", "tardis", "travellers"); private final Statement statement; private final TARDIS plugin; @@ -160,6 +161,8 @@ class TARDISSQLiteDatabaseUpdater { sonicupdates.add("sonic_uuid TEXT DEFAULT ''"); sonicupdates.add("last_scanned TEXT DEFAULT ''"); sonicupdates.add("scan_type INTEGER DEFAULT 0"); + flightupdates.add("chicken TEXT DEFAULT ''"); + flightupdates.add("stand TEXT DEFAULT ''"); } /** @@ -301,8 +304,8 @@ void updateTables() { } } for (String s : sonicupdates) { - String[] fsplit = s.split(" "); - String s_query = "SELECT sql FROM sqlite_master WHERE tbl_name = '" + prefix + "sonic' AND sql LIKE '%" + fsplit[0] + "%'"; + String[] ssplit = s.split(" "); + String s_query = "SELECT sql FROM sqlite_master WHERE tbl_name = '" + prefix + "sonic' AND sql LIKE '%" + ssplit[0] + "%'"; ResultSet rss = statement.executeQuery(s_query); if (!rss.next()) { i++; @@ -310,6 +313,16 @@ void updateTables() { statement.executeUpdate(s_alter); } } + for (String f : flightupdates) { + String[] fsplit = f.split(" "); + String f_query = "SELECT sql FROM sqlite_master WHERE tbl_name = '" + prefix + "flight' AND sql LIKE '%" + fsplit[0] + "%'"; + ResultSet rsf = statement.executeQuery(f_query); + if (!rsf.next()) { + i++; + String f_alter = "ALTER TABLE " + prefix + "flight ADD " + f; + statement.executeUpdate(f_alter); + } + } // add biome to current location String bio_query = "SELECT sql FROM sqlite_master WHERE tbl_name = '" + prefix + "current' AND sql LIKE '%biome%'"; ResultSet rsbio = statement.executeQuery(bio_query); @@ -318,14 +331,6 @@ void updateTables() { String bio_alter = "ALTER TABLE " + prefix + "current ADD biome TEXT DEFAULT ''"; statement.executeUpdate(bio_alter); } - // add chicken to flight persistence - String chi_query = "SELECT sql FROM sqlite_master WHERE tbl_name = '" + prefix + "flight' AND sql LIKE '%chicken%'"; - ResultSet rschi = statement.executeQuery(chi_query); - if (!rschi.next()) { - i++; - String chi_alter = "ALTER TABLE " + prefix + "flight ADD chicken TEXT DEFAULT ''"; - statement.executeUpdate(chi_alter); - } // add preset to homes String preset_query = "SELECT sql FROM sqlite_master WHERE tbl_name = '" + prefix + "homes' AND sql LIKE '%preset%'"; ResultSet rspreset = statement.executeQuery(preset_query); diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/tool/Converter.java b/src/main/java/me/eccentric_nz/TARDIS/database/tool/Converter.java index 176382f3c..cd11420fb 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/tool/Converter.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/tool/Converter.java @@ -182,7 +182,7 @@ public void run() { sb.append(str); } case flight -> { - str = String.format(SQL.VALUES.get(i), rs.getInt("f_id"), rs.getString("uuid"), rs.getInt("tardis_id"), rs.getString("location"), rs.getString("chicken")) + end; + str = String.format(SQL.VALUES.get(i), rs.getInt("f_id"), rs.getString("uuid"), rs.getInt("tardis_id"), rs.getString("location"), rs.getString("chicken"), rs.getString("stand")) + end; sb.append(str); } case forcefield -> { diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/tool/Main.java b/src/main/java/me/eccentric_nz/TARDIS/database/tool/Main.java index 2016e9cf7..108546b76 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/tool/Main.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/tool/Main.java @@ -219,7 +219,7 @@ public static void process(PrintWriter console, File sqlite, File mysql, String bw.write(str); } case flight -> { - str = String.format(SQL.VALUES.get(i), rs.getInt("f_id"), rs.getString("uuid"), rs.getInt("tardis_id"), rs.getString("location"), rs.getString("chicken")) + end; + str = String.format(SQL.VALUES.get(i), rs.getInt("f_id"), rs.getString("uuid"), rs.getInt("tardis_id"), rs.getString("location"), rs.getString("chicken"), rs.getString("stand")) + end; bw.write(str); } case forcefield -> { diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/tool/SQL.java b/src/main/java/me/eccentric_nz/TARDIS/database/tool/SQL.java index c0e0fab4a..d0c6980de 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/tool/SQL.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/tool/SQL.java @@ -70,7 +70,7 @@ public class SQL { "CREATE TABLE IF NOT EXISTS %sfarming_prefs (farm_id int(11) NOT NULL AUTO_INCREMENT, uuid varchar(48) DEFAULT '', allay int(1) DEFAULT '1', apiary int(1) DEFAULT '1', aquarium int(1) DEFAULT '1', bamboo int(1) DEFAULT '1', birdcage int(1) DEFAULT '1', farm int(1) DEFAULT '1', geode int(1) DEFAULT '1', hutch int(1) DEFAULT '1', igloo int(1) DEFAULT '1', iistubil int(1) DEFAULT '1', lava int(1) DEFAULT '1', mangrove int(1) DEFAULT '1', pen int(1) DEFAULT '1', stable int(1) DEFAULT '1', stall int(1) DEFAULT '1', village int(1) DEFAULT '1', PRIMARY KEY (farm_id)) DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;", - "CREATE TABLE IF NOT EXISTS %sflight (f_id int(11) NOT NULL AUTO_INCREMENT, uuid varchar(48) DEFAULT '', tardis_id int(11) DEFAULT '0', location varchar(512) DEFAULT '', chicken varchar(48) DEFAULT '', PRIMARY KEY (f_id)) DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;", + "CREATE TABLE IF NOT EXISTS %sflight (f_id int(11) NOT NULL AUTO_INCREMENT, uuid varchar(48) DEFAULT '', tardis_id int(11) DEFAULT '0', location varchar(512) DEFAULT '', chicken varchar(48) DEFAULT '', stand varchar(48) DEFAULT '', PRIMARY KEY (f_id)) DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;", "CREATE TABLE IF NOT EXISTS %sforcefield (uuid varchar(48) NOT NULL DEFAULT '', location varchar(512) DEFAULT '', PRIMARY KEY (uuid)) DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;", @@ -194,7 +194,7 @@ public class SQL { "(%s, '%s', %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", - "(%s, '%s', %s, '%s', '%s')", + "(%s, '%s', %s, '%s', '%s', '%s')", "('%s', '%s')", @@ -318,7 +318,7 @@ public class SQL { "INSERT INTO `%sfarming_prefs` (`farm_id`, `uuid`, `allay`, `apiary`, `aquarium`, `bamboo`, `birdcage`, `farm`, `geode`, `hutch`, `igloo`, `iistubil`, `lava`, `mangrove`, `pen`, `stable`, `stall`, `village`) VALUES ", - "INSERT INTO `%sflight` (`f_id`, `uuid`, `tardis_id`, `location`, `chicken`) VALUES ", + "INSERT INTO `%sflight` (`f_id`, `uuid`, `tardis_id`, `location`, `chicken`, `stand`) VALUES ", "INSERT INTO `%sforcefield` (`uuid`, `location`) VALUES ", diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/FlightPersister.java b/src/main/java/me/eccentric_nz/TARDIS/flight/FlightPersister.java index 0f6d3e546..280a32887 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/FlightPersister.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/FlightPersister.java @@ -17,6 +17,7 @@ package me.eccentric_nz.TARDIS.flight; import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.TARDISConstants; import me.eccentric_nz.TARDIS.database.TARDISDatabaseConnection; import me.eccentric_nz.TARDIS.enumeration.TardisModule; import me.eccentric_nz.TARDIS.utility.TARDISStaticLocationGetters; @@ -51,12 +52,13 @@ public FlightPersister(TARDIS plugin) { public void save() { try { // save flying TARDISes - ps = connection.prepareStatement("INSERT INTO " + prefix + "flight (uuid, tardis_id, location, chicken) VALUES (?, ?, ?, ?)"); + ps = connection.prepareStatement("INSERT INTO " + prefix + "flight (uuid, tardis_id, location, chicken, stand) VALUES (?, ?, ?, ?, ?)"); for (Map.Entry map : plugin.getTrackerKeeper().getFlyingReturnLocation().entrySet()) { ps.setString(1, map.getKey().toString()); ps.setInt(2, map.getValue().getId()); ps.setString(3, map.getValue().getLocation().toString()); ps.setString(4, map.getValue().getChicken().toString()); + ps.setString(5, map.getValue().getStand().toString()); count += ps.executeUpdate(); } if (count > 0) { @@ -88,7 +90,14 @@ public void load() { int id = rs.getInt("tardis_id"); Location location = TARDISStaticLocationGetters.getLocationFromBukkitString(rs.getString("location")); UUID chicken = UUID.fromString(rs.getString("chicken")); - plugin.getTrackerKeeper().getFlyingReturnLocation().put(uuid, new FlightReturnData(id, location, -1, -1, chicken)); + String standTmp = rs.getString("stand"); + UUID stand; + if (!standTmp.isEmpty()) { + stand = UUID.fromString(standTmp); + } else { + stand = TARDISConstants.UUID_ZERO; + } + plugin.getTrackerKeeper().getFlyingReturnLocation().put(uuid, new FlightReturnData(id, location, -1, -1, chicken, stand)); count++; } if (count > 0) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/FlightReturnData.java b/src/main/java/me/eccentric_nz/TARDIS/flight/FlightReturnData.java index c1b6f9b06..5c883b196 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/FlightReturnData.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/FlightReturnData.java @@ -21,7 +21,6 @@ import java.util.UUID; /** - * * @author eccentric_nz */ public class FlightReturnData { @@ -31,13 +30,15 @@ public class FlightReturnData { private final int sound; private final int animation; private final UUID chicken; + private final UUID stand; - public FlightReturnData(int id, Location location, int sound, int animation, UUID chicken) { + public FlightReturnData(int id, Location location, int sound, int animation, UUID chicken, UUID stand) { this.id = id; this.location = location; this.sound = sound; this.animation = animation; this.chicken = chicken; + this.stand = stand; } public int getId() { @@ -59,4 +60,8 @@ public int getAnimation() { public UUID getChicken() { return chicken; } + + public UUID getStand() { + return stand; + } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/FlightVisibility.java b/src/main/java/me/eccentric_nz/TARDIS/flight/FlightVisibility.java index a4fe72dea..07b82d671 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/FlightVisibility.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/FlightVisibility.java @@ -74,7 +74,7 @@ public void show(Player player) { // restart animation int animation = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new FlyingAnimation(plugin, stand, player, tardis.getPreset().equals(ChameleonPreset.PANDORICA)), 5L, 3L); // save flight data - plugin.getTrackerKeeper().getFlyingReturnLocation().put(player.getUniqueId(), new FlightReturnData(frd.getId(), frd.getLocation(), frd.getSound(), animation, chicken.getUniqueId())); + plugin.getTrackerKeeper().getFlyingReturnLocation().put(player.getUniqueId(), new FlightReturnData(frd.getId(), frd.getLocation(), frd.getSound(), animation, chicken.getUniqueId(), stand.getUniqueId())); // remove tracker plugin.getTrackerKeeper().getHiddenFlight().remove(player.getUniqueId()); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISExteriorFlight.java b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISExteriorFlight.java index bdfb4803a..1c2c2389d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISExteriorFlight.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISExteriorFlight.java @@ -90,6 +90,11 @@ public void stopFlying(Player player, ArmorStand stand) { plugin.getQueryFactory().doUpdate("current", set, where); // update door location TARDISBuilderUtility.saveDoorLocation(location, data.getId(), direction); + Block under = location.getBlock().getRelative(BlockFace.DOWN); + if (under.getType().isAir()) { + // if location is in the air, set under door block + TARDISBlockSetters.setUnderDoorBlock(location.getWorld(), under.getX(), under.getY(), under.getZ(), data.getId(), false); + } // set the light Levelled light = TARDISConstants.LIGHT; light.setLevel(7); @@ -152,7 +157,8 @@ public void startFlying(Player player, int id, Block block, Location current, bo plugin.getTrackerKeeper().getInVortex().add(id); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { // teleport player to exterior - player.teleport(current); + player.setGravity(false); + player.teleport(current.clone().add(0.5, 0.25, 0.5)); // get the armour stand for (Entity e : current.getWorld().getNearbyEntities(current, 1, 1, 1, (s) -> s.getType() == EntityType.ARMOR_STAND)) { if (e instanceof ArmorStand stand) { @@ -162,6 +168,7 @@ public void startFlying(Player player, int id, Block block, Location current, bo player.getPersistentDataContainer().set(plugin.getLoopKey(), PersistentDataType.INTEGER, sound); // spawn a chicken LivingEntity chicken = new MonsterSpawner().create(stand.getLocation(), Monster.FLYER); + chicken.setGravity(false); stand.addPassenger(player); stand.setGravity(false); chicken.addPassenger(stand); @@ -173,7 +180,11 @@ public void startFlying(Player player, int id, Block block, Location current, bo // remove the light current.getBlock().getRelative(BlockFace.UP, 2).setBlockData(TARDISConstants.AIR); // save player's current location, so we can teleport them back to it when they finish flying - plugin.getTrackerKeeper().getFlyingReturnLocation().put(player.getUniqueId(), new FlightReturnData(id, interior, sound, animation, chicken.getUniqueId())); + plugin.getTrackerKeeper().getFlyingReturnLocation().put(player.getUniqueId(), new FlightReturnData(id, interior, sound, animation, chicken.getUniqueId(), stand.getUniqueId())); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { + player.setGravity(true); + chicken.setGravity(true); + }, 1L); }, 2L); break; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISJoinListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISJoinListener.java index 89079f2b6..190373194 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISJoinListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISJoinListener.java @@ -229,7 +229,7 @@ public void onJoin(PlayerJoinEvent event) { chicken.setNoDamageTicks(Integer.MAX_VALUE); chicken.setFireTicks(0); // re-save flight data - plugin.getTrackerKeeper().getFlyingReturnLocation().put(player.getUniqueId(), new FlightReturnData(data.getId(), data.getLocation(), sound, animation, chicken.getUniqueId())); + plugin.getTrackerKeeper().getFlyingReturnLocation().put(player.getUniqueId(), new FlightReturnData(data.getId(), data.getLocation(), sound, animation, chicken.getUniqueId(), stand.getUniqueId())); } } } diff --git a/todo.md b/todo.md index bf0ab4da9..ef7330ff4 100644 --- a/todo.md +++ b/todo.md @@ -8,6 +8,7 @@ [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) * New interior with console * Malfunction & manual flight classes + * Regular handbrake needs to check console filght mode 4. Update old light level controls 5. Add Armadillo 6. Wolf armour and variants From 4d1419accedfdce6d097f67a0acf2435c588b1df Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Fri, 26 Apr 2024 19:10:15 +1200 Subject: [PATCH 50/96] Java 21 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index bffbfe209..f8e4c33b9 100644 --- a/pom.xml +++ b/pom.xml @@ -146,8 +146,8 @@ maven-compiler-plugin 3.13.0 - 17 - 17 + 21 + 21 ${project.build.sourceEncoding} From 6e5c13c60e9865ffc6479acb52d0c25b11209ecd Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Fri, 26 Apr 2024 19:11:11 +1200 Subject: [PATCH 51/96] It's not a left click on the console handbrake model --- src/main/resources/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/en.yml b/src/main/resources/en.yml index feea21120..62fad3bc4 100644 --- a/src/main/resources/en.yml +++ b/src/main/resources/en.yml @@ -545,7 +545,7 @@ HADS_SAVED: "HADS type preference saved." HADS_WARNING: "WARNING - HADS initiating in %s" HANDBRAKE_ENGAGE: "You need to engage the handbrake!" HANDBRAKE_IN_VORTEX: "You cannot change the handbrake while the TARDIS is in the time vortex!" -HANDBRAKE_LEFT_CLICK: "LEFT-click the handbrake to exit!" +HANDBRAKE_LEFT_CLICK: "Click the handbrake to exit!" HANDBRAKE_OFF: "Handbrake OFF! Entering the time vortex..." HANDBRAKE_OFF_ERR: "The handbrake is already off!" HANDBRAKE_ON: "Handbrake ON! Nice parking..." From 73babbc503f950f9606f851e55f9695e4b22e5f6 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Fri, 26 Apr 2024 19:11:48 +1200 Subject: [PATCH 52/96] Fix some potential nulls --- .../TARDIS/camera/TARDISDismountListener.java | 3 ++- .../TARDIS/travel/TARDISStructureTravel.java | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/camera/TARDISDismountListener.java b/src/main/java/me/eccentric_nz/TARDIS/camera/TARDISDismountListener.java index 9c047f6e2..8f8e8702c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/camera/TARDISDismountListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/camera/TARDISDismountListener.java @@ -1,5 +1,6 @@ package me.eccentric_nz.TARDIS.camera; +import io.papermc.lib.PaperLib; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.tardisweepingangels.TARDISWeepingAngels; import org.bukkit.entity.ArmorStand; @@ -23,7 +24,7 @@ public TARDISDismountListener(TARDIS plugin) { public void onDismount(EntityDismountEvent event) { EntityType riding = event.getEntity().getType(); EntityType ridden = event.getDismounted().getType(); - if (plugin.getConfig().getBoolean("modules.weeping_angels") && ridden == EntityType.SKELETON && riding == EntityType.GUARDIAN) { + if ((PaperLib.isPaper() && plugin.getConfig().getBoolean("modules.weeping_angels")) && ridden == EntityType.SKELETON && riding == EntityType.GUARDIAN) { if (event.getEntity().getPersistentDataContainer().has(TARDISWeepingAngels.SILENT, PersistentDataType.INTEGER)) { event.setCancelled(true); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISStructureTravel.java b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISStructureTravel.java index bef4be642..283406879 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISStructureTravel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISStructureTravel.java @@ -145,13 +145,15 @@ public TARDISStructureLocation getRandomVillage(Player p, int id, String[] args) StructureSearchResult normalResult = world.locateNearestStructure(location, structure, 64, false); loc = (normalResult != null) ? normalResult.getLocation() : null; // if ANCIENT_CITY, get underground location - if (loc != null && structure.equals(Structure.ANCIENT_CITY)) { - Check check = isThereRoom(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); - if (check.isSafe()) { - loc.setY(check.getY()); + if (loc != null) { + if (structure.equals(Structure.ANCIENT_CITY)) { + Check check = isThereRoom(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + if (check.isSafe()) { + loc.setY(check.getY()); + } + } else { + loc.setY(world.getHighestBlockYAt(loc)); } - } else { - loc.setY(world.getHighestBlockYAt(loc)); } } } From 28e3bb05cf9b47c6772b5590796479e7c8b48e34 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Fri, 26 Apr 2024 19:12:19 +1200 Subject: [PATCH 53/96] Fix wxyz model changing --- .../me/eccentric_nz/TARDIS/console/ConsoleBuilder.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index 37e132dc2..9b15fa189 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -21,6 +21,7 @@ public class ConsoleBuilder { private final TARDIS plugin; private UUID right; + private UUID wxyz; public ConsoleBuilder(TARDIS plugin) { this.plugin = plugin; @@ -107,6 +108,9 @@ private UUID spawnControl(ConsoleInteraction interaction, Location location, flo if (interaction == ConsoleInteraction.SCREEN_LEFT && right != null) { return right; } + if ((interaction == ConsoleInteraction.X||interaction == ConsoleInteraction.Z||interaction == ConsoleInteraction.MULTIPLIER) && wxyz != null) { + return wxyz; + } Material material = interaction.getMaterial(); int cmd = interaction.getCustomModelData(); if (interaction == ConsoleInteraction.DIRECTION) { @@ -134,6 +138,9 @@ private UUID spawnControl(ConsoleInteraction interaction, Location location, flo if (interaction == ConsoleInteraction.SCREEN_RIGHT) { right = uuid; } + if (interaction == ConsoleInteraction.WORLD) { + wxyz = uuid; + } return uuid; } From 52fc4bef8c1722134f1fc8c56e9682d5d4f48fc7 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Fri, 26 Apr 2024 19:12:44 +1200 Subject: [PATCH 54/96] Fix Spigot messaging for biome searches --- .../java/me/eccentric_nz/TARDIS/messaging/SpigotMessage.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/messaging/SpigotMessage.java b/src/main/java/me/eccentric_nz/TARDIS/messaging/SpigotMessage.java index 97732aedb..6cac11efd 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/messaging/SpigotMessage.java +++ b/src/main/java/me/eccentric_nz/TARDIS/messaging/SpigotMessage.java @@ -105,11 +105,10 @@ public void send(CommandSender cs, TardisModule module, String key, Object... su @Override public void send(Player player, String key, boolean handbrake) { - String local = TARDIS.plugin.getLanguage().getString(key); if (handbrake) { - sendJoinedStatus(player, local, "HANDBRAKE_RELEASE"); + sendJoinedStatus(player, key, "HANDBRAKE_RELEASE"); } else { - sendJoinedStatus(player, local, "LEAVING_VORTEX"); + sendJoinedStatus(player, key, "LEAVING_VORTEX"); } } From d112e9d81f48ef402cc24b7b71b6034e833ae2dd Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Fri, 26 Apr 2024 19:13:05 +1200 Subject: [PATCH 55/96] Sort the biomes in the Biome GUI --- .../TARDIS/console/ConsoleInteractionListener.java | 3 +-- .../TARDIS/console/telepathic/EnvironmentBiomes.java | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index fa0274cf0..62955c8fe 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -32,8 +32,7 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { int state = rsi.getState(); switch (ci) { // section zero - case HANDBRAKE -> - new HandbrakeInteraction(plugin).process(id, state, player, interaction); + case HANDBRAKE -> new HandbrakeInteraction(plugin).process(id, state, player, interaction); case THROTTLE -> new ThrottleInteraction(plugin).process(player, interaction, id); case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(player, id, interaction); // section one diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/EnvironmentBiomes.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/EnvironmentBiomes.java index 6a6583553..5031351b3 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/EnvironmentBiomes.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/EnvironmentBiomes.java @@ -4,7 +4,7 @@ import org.bukkit.block.Biome; import java.util.ArrayList; -import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.List; @@ -38,7 +38,7 @@ public class EnvironmentBiomes { put(Biome.FLOWER_FOREST, Material.ORANGE_TULIP); put(Biome.FOREST, Material.OAK_PLANKS); put(Biome.FROZEN_OCEAN, Material.BLUE_ICE); - put(Biome.FROZEN_PEAKS, Material.POWDER_SNOW); + put(Biome.FROZEN_PEAKS, Material.POWDER_SNOW_BUCKET); put(Biome.FROZEN_RIVER, Material.ICE); put(Biome.GROVE, Material.STRIPPED_SPRUCE_LOG); put(Biome.ICE_SPIKES, Material.PACKED_ICE); @@ -87,6 +87,6 @@ public class EnvironmentBiomes { OVERWORLD.add(biome); } } - Collections.sort(OVERWORLD); + OVERWORLD.sort(Comparator.comparing(Enum::toString)); } } From cb252914f08d10c270fa88007260c045f6a22050 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Sat, 27 Apr 2024 09:43:10 +1200 Subject: [PATCH 56/96] Console labels --- .../preferences/TARDISLabelsCommand.java | 49 +++++++++++++ .../preferences/TARDISPrefsCommands.java | 5 +- .../TARDIS/console/ConsoleBuilder.java | 8 +++ .../TARDIS/console/ConsoleDestroyer.java | 21 ++++++ .../console/interaction/LabelAction.java | 70 +++++++++++++++++++ .../interaction/ScreenInteraction.java | 1 + .../resultset/ResultSetConsoleLabel.java | 63 +++++++++++++++++ todo.md | 2 + 8 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISLabelsCommand.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/LabelAction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetConsoleLabel.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISLabelsCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISLabelsCommand.java new file mode 100644 index 000000000..e5c78f973 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISLabelsCommand.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024 eccentric_nz + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package me.eccentric_nz.TARDIS.commands.preferences; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.console.interaction.LabelAction; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardisID; +import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import org.bukkit.entity.Player; + +/** + * @author eccentric_nz + */ +class TARDISLabelsCommand { + + private final TARDIS plugin; + + TARDISLabelsCommand(TARDIS plugin) { + this.plugin = plugin; + } + + boolean toggle(Player player, String[] args) { + if (args.length < 2 || (!args[1].equalsIgnoreCase("on") && !args[1].equalsIgnoreCase("off"))) { + plugin.getMessenger().send(player, TardisModule.TARDIS, "PREF_ON_OFF", "console_labels"); + return false; + } + ResultSetTardisID rs = new ResultSetTardisID(plugin); + if (rs.fromUUID(player.getUniqueId().toString())) { + int id = rs.getTardis_id(); + boolean on = args[1].equalsIgnoreCase("on"); + new LabelAction(plugin).toggle(id, on); + } + return true; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsCommands.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsCommands.java index 60ea1b75c..e31ab2437 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsCommands.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsCommands.java @@ -51,7 +51,7 @@ public class TARDISPrefsCommands implements CommandExecutor { private static final ImmutableList firstArgs = ImmutableList.of( "announce_repeaters", "auto", "auto_powerup", "auto_rescue", "auto_siege", "beacon", "build", - "close_gui", + "close_gui", "console_labels", "difficulty", "dnd", "dynamic_lamps", "eps", "eps_message", "farm", "flight", "floor", "forcefield", @@ -128,6 +128,9 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String plugin.getQueryFactory().doInsert("player_prefs", set); } switch (pref) { + case "console_labels" -> { + return new TARDISLabelsCommand(plugin).toggle(player, args); + } case "difficulty" -> { return new TARDISSetDifficultyCommand(plugin).setDiff(player, args); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index 9b15fa189..ed2dbedb9 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -3,6 +3,7 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentLocation; import me.eccentric_nz.TARDIS.enumeration.COMPASS; +import me.eccentric_nz.TARDIS.utility.TARDISStaticLocationGetters; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -31,6 +32,13 @@ public void create(Block block, int type, int id) { StringBuilder builder = new StringBuilder(); String prefix = ""; Block up = block.getRelative(BlockFace.UP); + // save the block location + HashMap setb = new HashMap<>(); + setb.put("tardis_id", id); + setb.put("uuid", TARDISStaticLocationGetters.makeLocationStr(block.getLocation())); + setb.put("control", "CENTRE"); + setb.put("state", 0); + plugin.getQueryFactory().doInsert("interactions", setb); for (int i = 0; i < 6; i++) { ItemStack shard = new ItemStack(Material.AMETHYST_SHARD); ItemMeta im = shard.getItemMeta(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java index e2c8262ba..52955ba33 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java @@ -3,11 +3,16 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.console.models.ColourType; import me.eccentric_nz.TARDIS.database.ClearInteractions; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetConsoleLabel; import me.eccentric_nz.TARDIS.database.resultset.ResultSetInteractionsFromId; import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; +import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.ItemDisplay; +import org.bukkit.entity.TextDisplay; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataType; @@ -44,6 +49,13 @@ public ItemStack returnStack(String uuids, int id) { e.remove(); } } + // remove the centre block + ResultSetConsoleLabel rsc = new ResultSetConsoleLabel(plugin, id); + if (rsc.resultSet()) { + Block centre = rsc.getLocation().getBlock(); + centre.setType(Material.AIR); + removeTextDisplays(rsc.getLocation()); + } String[] split = uuids.split("~"); for (String u : split) { try { @@ -78,4 +90,13 @@ public ItemStack returnStack(String uuids, int id) { } return null; } + + private void removeTextDisplays(Location centre) { + Location spawn = centre.clone().add(0.5f, 0, 0.5f); + for (Entity e : spawn.getWorld().getNearbyEntities(spawn, 3.5, 2, 3.5, (t) -> t.getType() == EntityType.TEXT_DISPLAY)) { + if (e instanceof TextDisplay) { + e.remove(); + } + } + } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LabelAction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LabelAction.java new file mode 100644 index 000000000..0be2eb786 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LabelAction.java @@ -0,0 +1,70 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.TARDISConstants; +import me.eccentric_nz.TARDIS.console.ConsoleInteraction; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetConsoleLabel; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.entity.Display; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.TextDisplay; +import org.bukkit.persistence.PersistentDataType; +import org.bukkit.util.Transformation; +import org.joml.Vector3f; + +public class LabelAction { + + private final TARDIS plugin; + private final Transformation transformation = new Transformation(TARDISConstants.VECTOR_ZERO, TARDISConstants.AXIS_ANGLE_ZERO, new Vector3f(0.125f, 0.125f, 0.125f), TARDISConstants.AXIS_ANGLE_ZERO); + + public LabelAction(TARDIS plugin) { + this.plugin = plugin; + } + + public void toggle(int id, boolean on) { + // get the centre block + ResultSetConsoleLabel rs = new ResultSetConsoleLabel(plugin, id); + if (!rs.resultSet()) { + return; + } + Location centre = rs.getLocation(); + if (centre == null) { + return; + } + if (on) { + for (ConsoleInteraction ci : ConsoleInteraction.values()) { + if (ci == ConsoleInteraction.SCREEN_LEFT || ci == ConsoleInteraction.SCREEN_RIGHT) { + continue; + } + // spawn a text display + spawnTextDisplay(centre, ci); + } + } else { + // off + removeTextDisplay(centre); + } + } + + private void spawnTextDisplay(Location centre, ConsoleInteraction ci) { + double half = ci.getWidth() / 2.0d; + Location spawn = centre.clone().add(ci.getRelativePosition().getX() - half, ci.getRelativePosition().getY() + ci.getHeight(), ci.getRelativePosition().getZ() - half); + TextDisplay display = (TextDisplay) centre.getWorld().spawnEntity(spawn, EntityType.TEXT_DISPLAY); + display.setText(ci.getAlternateName()); + display.setBackgroundColor(Color.BLACK); + display.setRotation(Location.normalizeYaw(ci.getYaw()), 0.0f); + display.setTransformation(transformation); + display.setBillboard(Display.Billboard.FIXED); + display.setSeeThrough(true); + } + + private void removeTextDisplay(Location centre) { + Location spawn = centre.clone().add(0.5f, 0, 0.5f); + for (Entity e : spawn.getWorld().getNearbyEntities(spawn, 3.5, 2, 3.5, (t) -> t.getType() == EntityType.TEXT_DISPLAY)) { + if (e instanceof TextDisplay && !e.getPersistentDataContainer().has(plugin.getInteractionUuidKey(), PersistentDataType.BOOLEAN)) { + e.remove(); + } + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java index c194fba4c..d6c7091f9 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java @@ -83,6 +83,7 @@ private TextDisplay getTextDisplay(Location location, boolean coords) { Vector vector = coords ? new Vector(0.0d, 0.5d, 0.35d) : new Vector(0.32d, 0.5d, -0.225d); adjusted.add(vector); textDisplay = (TextDisplay) location.getWorld().spawnEntity(adjusted, EntityType.TEXT_DISPLAY); + textDisplay.getPersistentDataContainer().set(plugin.getInteractionUuidKey(), PersistentDataType.BOOLEAN, true); } return textDisplay; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetConsoleLabel.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetConsoleLabel.java new file mode 100644 index 000000000..16559a9e9 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetConsoleLabel.java @@ -0,0 +1,63 @@ +package me.eccentric_nz.TARDIS.database.resultset; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.TARDISDatabaseConnection; +import me.eccentric_nz.TARDIS.utility.TARDISStaticLocationGetters; +import org.bukkit.Location; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ResultSetConsoleLabel { + + private final TARDISDatabaseConnection service = TARDISDatabaseConnection.getINSTANCE(); + private final Connection connection = service.getConnection(); + private final TARDIS plugin; + private final String prefix; + private final int id; + private Location location; + + public ResultSetConsoleLabel(TARDIS plugin, int id) { + this.plugin = plugin; + this.id = id; + prefix = this.plugin.getPrefix(); + } + + public boolean resultSet() { + PreparedStatement statement = null; + ResultSet rs = null; + String query = "SELECT uuid FROM " + prefix + "interactions WHERE tardis_id = ? AND control = 'CENTRE'"; + try { + service.testConnection(connection); + statement = connection.prepareStatement(query); + statement.setInt(1, id); + rs = statement.executeQuery(); + if (rs.isBeforeFirst()) { + location = TARDISStaticLocationGetters.getLocationFromDB(rs.getString("uuid")); + return true; + } else { + return false; + } + } catch (SQLException e) { + plugin.debug("ResultSet error for interactions centre location! " + e.getMessage()); + return false; + } finally { + try { + if (rs != null) { + rs.close(); + } + if (statement != null) { + statement.close(); + } + } catch (SQLException e) { + plugin.debug("Error closing interactions centre location! " + e.getMessage()); + } + } + } + + public Location getLocation() { + return location; + } +} diff --git a/todo.md b/todo.md index ef7330ff4..232248540 100644 --- a/todo.md +++ b/todo.md @@ -9,6 +9,8 @@ * New interior with console * Malfunction & manual flight classes * Regular handbrake needs to check console filght mode + * Remove sonic screwdriver when breaking console + * Alter console side model inner edge / make new time rotor for console 4. Update old light level controls 5. Add Armadillo 6. Wolf armour and variants From 7cfd5fa73a4de1fffd8f3dd2a89b798fbe864e38 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sat, 27 Apr 2024 21:31:15 +1200 Subject: [PATCH 57/96] Replace `keep_spawn_in_memory` with game rule `spawnChunkRadius` --- .../commands/utils/TARDISWorldCommand.java | 2 +- .../TARDIS/files/TARDISPlanetsUpdater.java | 19 +++++++++++-------- .../TARDIS/planets/TARDISWorlds.java | 7 +++++-- todo.md | 2 ++ 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/utils/TARDISWorldCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/utils/TARDISWorldCommand.java index 061f8d3e9..7ef301209 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/utils/TARDISWorldCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/utils/TARDISWorldCommand.java @@ -95,7 +95,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String plugin.getMessenger().message(player, " " + s + " -> " + world.getGameRuleValue(rule)); } } - plugin.getMessenger().message(player, "Keep spawn in memory -> " + world.getKeepSpawnInMemory()); + plugin.getMessenger().message(player, "Spawn chunk radius -> " + plugin.getPlanetsConfig().getInt("planets." + world.getName() + ".spawn_chunk_radius")); plugin.getMessenger().message(player, "Time travel -> " + plugin.getPlanetsConfig().getString("planets." + world.getName() + ".time_travel")); return true; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISPlanetsUpdater.java b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISPlanetsUpdater.java index 765d9cbb6..6740c6443 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISPlanetsUpdater.java +++ b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISPlanetsUpdater.java @@ -92,13 +92,20 @@ public void checkPlanetsConfig() { planets_config.set("planets." + dn + ".void", true); planets_config.set("planets." + dn + ".gamerules.doWeatherCycle", false); planets_config.set("planets." + dn + ".gamerules.doDaylightCycle", false); - planets_config.set("planets." + dn + ".keep_spawn_in_memory", false); + planets_config.set("planets." + dn + ".spawn_chunk_radius", 0); save++; } if (!planets_config.contains("colour_skies")) { planets_config.set("colour_skies", true); save++; } + if (!planets_config.contains("planets.TARDIS_Zero_Room.spawn_chunk_radius")) { + Set worlds = planets_config.getConfigurationSection("planets").getKeys(false); + for (String w : worlds) { + planets_config.set("planets." + w + ".spawn_chunk_radius", planets_config.getBoolean("planets." + dn + ".keep_spawn_in_memory") ? 2 : 0); + planets_config.set("planets." + w + ".keep_spawn_in_memory", null); + } + } if (!planets_config.contains("planets.TARDIS_Zero_Room.alias")) { Set worlds = planets_config.getConfigurationSection("planets").getKeys(false); for (String w : worlds) { @@ -156,10 +163,6 @@ public void checkPlanetsConfig() { save++; } for (String p : planets_config.getConfigurationSection("planets").getKeys(false)) { - if (!planets_config.contains("planets." + p + ".keep_spawn_in_memory")) { - planets_config.set("planets." + p + ".keep_spawn_in_memory", false); - save++; - } if (!planets_config.contains("planets." + p + ".allow_portals")) { planets_config.set("planets." + p + ".allow_portals", true); save++; @@ -179,7 +182,7 @@ public void checkPlanetsConfig() { planets_config.set("planets.skaro.world_type", "NORMAL"); planets_config.set("planets.skaro.environment", "NORMAL"); planets_config.set("planets.skaro.generator", "TARDIS:skaro"); - planets_config.set("planets.skaro.keep_spawn_in_memory", false); + planets_config.set("planets.skaro.spawn_chunk_radius", 0); planets_config.set("planets.skaro.spawn_other_mobs", true); planets_config.set("planets.skaro.gamerules.doTraderSpawning", false); planets_config.set("planets.skaro.gamerules.doPatrolSpawning", false); @@ -193,7 +196,7 @@ public void checkPlanetsConfig() { planets_config.set("planets.siluria.world_type", "NORMAL"); planets_config.set("planets.siluria.environment", "NORMAL"); planets_config.set("planets.siluria.generator", "TARDIS:siluria"); - planets_config.set("planets.siluria.keep_spawn_in_memory", false); + planets_config.set("planets.siluria.spawn_chunk_radius", 0); planets_config.set("planets.siluria.spawn_other_mobs", true); planets_config.set("planets.siluria.gamerules.doTraderSpawning", false); planets_config.set("planets.siluria.gamerules.doPatrolSpawning", false); @@ -207,7 +210,7 @@ public void checkPlanetsConfig() { planets_config.set("planets.gallifrey.world_type", "NORMAL"); planets_config.set("planets.gallifrey.environment", "NORMAL"); planets_config.set("planets.gallifrey.generator", "TARDIS:gallifrey"); - planets_config.set("planets.gallifrey.keep_spawn_in_memory", false); + planets_config.set("planets.gallifrey.spawn_chunk_radius", 0); planets_config.set("planets.gallifrey.spawn_other_mobs", true); planets_config.set("planets.gallifrey.gamerules.doTraderSpawning", false); planets_config.set("planets.gallifrey.gamerules.doPatrolSpawning", false); diff --git a/src/main/java/me/eccentric_nz/TARDIS/planets/TARDISWorlds.java b/src/main/java/me/eccentric_nz/TARDIS/planets/TARDISWorlds.java index e2f964f07..1beba2315 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/planets/TARDISWorlds.java +++ b/src/main/java/me/eccentric_nz/TARDIS/planets/TARDISWorlds.java @@ -78,8 +78,11 @@ public static void loadWorld(String world) { } } } - boolean keepSpawnInMemory = TARDIS.plugin.getPlanetsConfig().getBoolean("planets." + world + ".keep_spawn_in_memory"); - w.setKeepSpawnInMemory(keepSpawnInMemory); + // spawn chunk radius (replaces deprecated `keep_spawn_in_memory` setting) + // 0 is the equivalent of keep_spawn_in_memory: false + // 10 is the equivalent of keep_spawn_in_memory: true (pre-1.20.5) + // the new default in 1.20.5+ is 2 + w.setGameRule(GameRule.SPAWN_CHUNK_RADIUS, Math.clamp(TARDIS.plugin.getPlanetsConfig().getInt("planets." + world + ".spawn_chunk_radius", 0), 0, 32)); String d = TARDIS.plugin.getPlanetsConfig().getString("planets." + world + ".difficulty"); if (d != null) { try { diff --git a/todo.md b/todo.md index 232248540..dd0aa10a5 100644 --- a/todo.md +++ b/todo.md @@ -11,6 +11,8 @@ * Regular handbrake needs to check console filght mode * Remove sonic screwdriver when breaking console * Alter console side model inner edge / make new time rotor for console + * Change order of console panels so handbrake is near door + * Make sneak-clicking a control show the label + alter the position based on the angle of the panel the control is on 4. Update old light level controls 5. Add Armadillo 6. Wolf armour and variants From 101c102ecd03ad1714a91a5f45e82c7bf188fa20 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sun, 28 Apr 2024 11:36:48 +1200 Subject: [PATCH 58/96] Use `List.of()` --- .../TARDIS/ARS/TARDISARSMapListener.java | 4 ++-- .../TARDIS/ARS/TARDISARSMethods.java | 2 +- .../advanced/TARDISDiskCraftListener.java | 2 +- .../advanced/TARDISDiskWriterCommand.java | 4 ++-- .../me/eccentric_nz/TARDIS/api/TARDII.java | 6 ++--- .../TARDIS/bStats/ARSRoomCounts.java | 2 +- .../chameleon/gui/TARDISChameleonHelpGUI.java | 20 ++++++++--------- .../gui/TARDISChameleonTemplateGUI.java | 18 +++++++-------- .../TARDIS/commands/TARDISRecipeCommands.java | 4 ++-- .../areas/TARDISEditAreasInventory.java | 2 +- .../config/TARDISConfigMenuInventory.java | 2 +- .../config/TARDISConfigMenuListener.java | 2 +- .../config/TARDISConfigPageTwoInventory.java | 2 +- .../preferences/TARDISHumInventory.java | 2 +- .../preferences/TARDISHumListener.java | 4 ++-- .../preferences/TARDISPrefsMenuInventory.java | 10 ++++----- .../preferences/TARDISPrefsMenuListener.java | 2 +- .../commands/tardis/TARDISTabComplete.java | 2 +- .../commands/travel/TARDISTravelCoords.java | 2 +- .../control/TARDISControlInventory.java | 12 +++++----- .../control/TARDISControlMenuListener.java | 6 ++--- .../TARDIS/files/TARDISConfiguration.java | 4 ++-- .../TARDIS/files/TARDISSignsUpdater.java | 4 ++-- .../TARDIS/floodgate/FloodgateMapForm.java | 2 +- .../TARDIS/handles/TARDISHandlesBlock.java | 22 +++++++++---------- .../TARDIS/recipes/TARDISRecipeInventory.java | 4 ++-- .../sonic/TARDISSonicGeneratorInventory.java | 4 ++-- .../sonic/TARDISSonicMenuInventory.java | 2 +- .../TARDISTemporalLocatorInventory.java | 7 +++--- .../travel/TARDISTerminalInventory.java | 9 ++++---- .../TARDIS/travel/TARDISTerminalListener.java | 20 ++++++++--------- .../compound/CompoundBuilder.java | 4 ++-- .../commands/TabComplete.java | 2 +- 33 files changed, 98 insertions(+), 96 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSMapListener.java b/src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSMapListener.java index d2e4f0568..9fee647d9 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSMapListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSMapListener.java @@ -37,8 +37,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.UUID; /** @@ -192,7 +192,7 @@ private void findPlayer(Player player, InventoryView view) { ItemStack is = view.getItem(slot); is.setType(Material.ARROW); ItemMeta im = is.getItemMeta(); - im.setLore(Collections.singletonList(plugin.getLanguage().getString("ARS_MAP_HERE"))); + im.setLore(List.of(plugin.getLanguage().getString("ARS_MAP_HERE"))); im.setCustomModelData(6); is.setItemMeta(im); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSMethods.java b/src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSMethods.java index 84ee1cdd0..5a1b20395 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSMethods.java +++ b/src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSMethods.java @@ -264,7 +264,7 @@ private void updateGrid(UUID playerUUID, int slot, String material) { * @param str the lore to set */ void setLore(InventoryView view, int slot, String str) { - List lore = (str != null) ? Collections.singletonList(str) : null; + List lore = (str != null) ? List.of(str) : null; ItemStack is = view.getItem(slot); ItemMeta im = is.getItemMeta(); im.setLore(lore); diff --git a/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISDiskCraftListener.java b/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISDiskCraftListener.java index d17443e82..9b58b9093 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISDiskCraftListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISDiskCraftListener.java @@ -127,7 +127,7 @@ public void onCraftBiomePresetDisk(InventoryClickEvent event) { if (preset.isEmpty()) { return; } - List disk_lore = Collections.singletonList(preset); + List disk_lore = List.of(preset); disk = new ItemStack(Material.MUSIC_DISC_MALL, 1); ItemMeta dim = disk.getItemMeta(); dim.setDisplayName("Preset Storage Disk"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISDiskWriterCommand.java b/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISDiskWriterCommand.java index c7e05f49b..73d1b169b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISDiskWriterCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/advanced/TARDISDiskWriterCommand.java @@ -53,7 +53,7 @@ public boolean writeSave(Player player, String[] args) { is = new ItemStack(Material.MUSIC_DISC_CHIRP, 1); ItemMeta im = is.getItemMeta(); im.setDisplayName("Save Storage Disk"); - im.setLore(Collections.singletonList("Blank")); + im.setLore(List.of("Blank")); im.setCustomModelData(10000001); is.setItemMeta(im); } else { @@ -228,7 +228,7 @@ public boolean eraseDisk(Player player) { ItemStack is = player.getInventory().getItemInMainHand(); if (is.hasItemMeta() && disks.contains(is.getItemMeta().getDisplayName())) { ItemMeta im = is.getItemMeta(); - List lore = Collections.singletonList("Blank"); + List lore = List.of("Blank"); im.setLore(lore); is.setItemMeta(im); plugin.getMessenger().send(player, TardisModule.TARDIS, "DISK_ERASE"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/api/TARDII.java b/src/main/java/me/eccentric_nz/TARDIS/api/TARDII.java index 8152d3865..dcc804e82 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/api/TARDII.java +++ b/src/main/java/me/eccentric_nz/TARDIS/api/TARDII.java @@ -193,7 +193,7 @@ public Location getRandomOverworldLocation(Player p) { @Override public Location getRandomOverworldLocation(String world, Player p) { - return getRandomLocation(Collections.singletonList(world), Environment.NORMAL, p); + return getRandomLocation(List.of(world), Environment.NORMAL, p); } @Override @@ -203,7 +203,7 @@ public Location getRandomNetherLocation(Player p) { @Override public Location getRandomNetherLocation(String world, Player p) { - return getRandomLocation(Collections.singletonList(world), Environment.NETHER, p); + return getRandomLocation(List.of(world), Environment.NETHER, p); } @Override @@ -213,7 +213,7 @@ public Location getRandomEndLocation(Player p) { @Override public Location getRandomEndLocation(String world, Player p) { - return getRandomLocation(Collections.singletonList(world), Environment.THE_END, p); + return getRandomLocation(List.of(world), Environment.THE_END, p); } @Override diff --git a/src/main/java/me/eccentric_nz/TARDIS/bStats/ARSRoomCounts.java b/src/main/java/me/eccentric_nz/TARDIS/bStats/ARSRoomCounts.java index 231b343be..c4c50284f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/bStats/ARSRoomCounts.java +++ b/src/main/java/me/eccentric_nz/TARDIS/bStats/ARSRoomCounts.java @@ -34,7 +34,7 @@ public class ARSRoomCounts { private final Connection connection = service.getConnection(); private final TARDIS plugin; private final String prefix; - private final List STONE = Collections.singletonList("STONE"); + private final List STONE = List.of("STONE"); private final List numberOfRoomsPerTARDIS = new ArrayList<>(); public ARSRoomCounts(TARDIS plugin) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/chameleon/gui/TARDISChameleonHelpGUI.java b/src/main/java/me/eccentric_nz/TARDIS/chameleon/gui/TARDISChameleonHelpGUI.java index 583a19722..f37f0cdfa 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/chameleon/gui/TARDISChameleonHelpGUI.java +++ b/src/main/java/me/eccentric_nz/TARDIS/chameleon/gui/TARDISChameleonHelpGUI.java @@ -22,7 +22,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.Collections; +import java.util.List; /** * @author eccentric_nz @@ -63,63 +63,63 @@ private ItemStack[] getItemStack() { ItemStack one = new ItemStack(Material.BOWL, 1); ItemMeta oe = one.getItemMeta(); oe.setDisplayName("1"); - oe.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_L_FRONT"))); + oe.setLore(List.of(plugin.getChameleonGuis().getString("COL_L_FRONT"))); oe.setCustomModelData(GUIChameleonHelp.COL_L_FRONT.getCustomModelData()); one.setItemMeta(oe); // two ItemStack two = new ItemStack(Material.BOWL, 1); ItemMeta to = two.getItemMeta(); to.setDisplayName("2"); - to.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_L_MIDDLE"))); + to.setLore(List.of(plugin.getChameleonGuis().getString("COL_L_MIDDLE"))); to.setCustomModelData(GUIChameleonHelp.COL_L_MIDDLE.getCustomModelData()); two.setItemMeta(to); // three ItemStack three = new ItemStack(Material.BOWL, 1); ItemMeta te = three.getItemMeta(); te.setDisplayName("3"); - te.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_L_BACK"))); + te.setLore(List.of(plugin.getChameleonGuis().getString("COL_L_BACK"))); te.setCustomModelData(GUIChameleonHelp.COL_L_BACK.getCustomModelData()); three.setItemMeta(te); // four ItemStack four = new ItemStack(Material.BOWL, 1); ItemMeta fr = four.getItemMeta(); fr.setDisplayName("4"); - fr.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_B_MIDDLE"))); + fr.setLore(List.of(plugin.getChameleonGuis().getString("COL_B_MIDDLE"))); fr.setCustomModelData(GUIChameleonHelp.COL_B_MIDDLE.getCustomModelData()); four.setItemMeta(fr); // five ItemStack five = new ItemStack(Material.BOWL, 1); ItemMeta fe = five.getItemMeta(); fe.setDisplayName("5"); - fe.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_R_BACK"))); + fe.setLore(List.of(plugin.getChameleonGuis().getString("COL_R_BACK"))); fe.setCustomModelData(GUIChameleonHelp.COL_R_BACK.getCustomModelData()); five.setItemMeta(fe); // six ItemStack six = new ItemStack(Material.BOWL, 1); ItemMeta sx = six.getItemMeta(); sx.setDisplayName("6"); - sx.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_R_MIDDLE"))); + sx.setLore(List.of(plugin.getChameleonGuis().getString("COL_R_MIDDLE"))); sx.setCustomModelData(GUIChameleonHelp.COL_R_MIDDLE.getCustomModelData()); six.setItemMeta(sx); // seven ItemStack seven = new ItemStack(Material.BOWL, 1); ItemMeta sn = seven.getItemMeta(); sn.setDisplayName("7"); - sn.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_R_FRONT"))); + sn.setLore(List.of(plugin.getChameleonGuis().getString("COL_R_FRONT"))); sn.setCustomModelData(GUIChameleonHelp.COL_R_FRONT.getCustomModelData()); seven.setItemMeta(sn); // eight ItemStack eight = new ItemStack(Material.BOWL, 1); ItemMeta et = eight.getItemMeta(); et.setDisplayName("8"); - et.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_F_MIDDLE"))); + et.setLore(List.of(plugin.getChameleonGuis().getString("COL_F_MIDDLE"))); et.setCustomModelData(GUIChameleonHelp.COL_F_MIDDLE.getCustomModelData()); eight.setItemMeta(et); // nine ItemStack nine = new ItemStack(Material.BOWL, 1); ItemMeta ne = nine.getItemMeta(); ne.setDisplayName("9"); - ne.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_C_LAMP"))); + ne.setLore(List.of(plugin.getChameleonGuis().getString("COL_C_LAMP"))); ne.setCustomModelData(GUIChameleonHelp.COL_C_LAMP.getCustomModelData()); nine.setItemMeta(ne); // grid diff --git a/src/main/java/me/eccentric_nz/TARDIS/chameleon/gui/TARDISChameleonTemplateGUI.java b/src/main/java/me/eccentric_nz/TARDIS/chameleon/gui/TARDISChameleonTemplateGUI.java index 9d26a5702..53bac7a7e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/chameleon/gui/TARDISChameleonTemplateGUI.java +++ b/src/main/java/me/eccentric_nz/TARDIS/chameleon/gui/TARDISChameleonTemplateGUI.java @@ -64,63 +64,63 @@ private ItemStack[] getItemStack() { ItemStack one = new ItemStack(Material.BOWL, 1); ItemMeta oe = one.getItemMeta(); oe.setDisplayName("1"); - oe.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_L_FRONT"))); + oe.setLore(List.of(plugin.getChameleonGuis().getString("COL_L_FRONT"))); oe.setCustomModelData(GUIChameleonTemplate.COL_L_FRONT.getCustomModelData()); one.setItemMeta(oe); // two ItemStack two = new ItemStack(Material.BOWL, 1); ItemMeta to = two.getItemMeta(); to.setDisplayName("2"); - to.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_L_MIDDLE"))); + to.setLore(List.of(plugin.getChameleonGuis().getString("COL_L_MIDDLE"))); to.setCustomModelData(GUIChameleonTemplate.COL_L_MIDDLE.getCustomModelData()); two.setItemMeta(to); // three ItemStack three = new ItemStack(Material.BOWL, 1); ItemMeta te = three.getItemMeta(); te.setDisplayName("3"); - te.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_L_BACK"))); + te.setLore(List.of(plugin.getChameleonGuis().getString("COL_L_BACK"))); te.setCustomModelData(GUIChameleonTemplate.COL_L_BACK.getCustomModelData()); three.setItemMeta(te); // four ItemStack four = new ItemStack(Material.BOWL, 1); ItemMeta fr = four.getItemMeta(); fr.setDisplayName("4"); - fr.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_B_MIDDLE"))); + fr.setLore(List.of(plugin.getChameleonGuis().getString("COL_B_MIDDLE"))); fr.setCustomModelData(GUIChameleonTemplate.COL_B_MIDDLE.getCustomModelData()); four.setItemMeta(fr); // five ItemStack five = new ItemStack(Material.BOWL, 1); ItemMeta fe = five.getItemMeta(); fe.setDisplayName("5"); - fe.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_R_BACK"))); + fe.setLore(List.of(plugin.getChameleonGuis().getString("COL_R_BACK"))); fe.setCustomModelData(GUIChameleonTemplate.COL_R_BACK.getCustomModelData()); five.setItemMeta(fe); // six ItemStack six = new ItemStack(Material.BOWL, 1); ItemMeta sx = six.getItemMeta(); sx.setDisplayName("6"); - sx.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_R_MIDDLE"))); + sx.setLore(List.of(plugin.getChameleonGuis().getString("COL_R_MIDDLE"))); sx.setCustomModelData(GUIChameleonTemplate.COL_R_MIDDLE.getCustomModelData()); six.setItemMeta(sx); // seven ItemStack seven = new ItemStack(Material.BOWL, 1); ItemMeta sn = seven.getItemMeta(); sn.setDisplayName("7"); - sn.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_R_FRONT"))); + sn.setLore(List.of(plugin.getChameleonGuis().getString("COL_R_FRONT"))); sn.setCustomModelData(GUIChameleonTemplate.COL_R_FRONT.getCustomModelData()); seven.setItemMeta(sn); // eight ItemStack eight = new ItemStack(Material.BOWL, 1); ItemMeta et = eight.getItemMeta(); et.setDisplayName("8"); - et.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_F_MIDDLE"))); + et.setLore(List.of(plugin.getChameleonGuis().getString("COL_F_MIDDLE"))); et.setCustomModelData(GUIChameleonTemplate.COL_F_MIDDLE.getCustomModelData()); eight.setItemMeta(et); // nine ItemStack nine = new ItemStack(Material.BOWL, 1); ItemMeta ne = nine.getItemMeta(); ne.setDisplayName("9"); - ne.setLore(Collections.singletonList(plugin.getChameleonGuis().getString("COL_C_LAMP"))); + ne.setLore(List.of(plugin.getChameleonGuis().getString("COL_C_LAMP"))); ne.setCustomModelData(GUIChameleonTemplate.COL_C_LAMP.getCustomModelData()); nine.setItemMeta(ne); // redstone lamp diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeCommands.java b/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeCommands.java index 507deaba1..89d78d09f 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeCommands.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeCommands.java @@ -320,13 +320,13 @@ private void showTARDISRecipe(Player player, String type) { ItemStack in_wall = new ItemStack(Material.ORANGE_WOOL, 1); ItemMeta in_meta = in_wall.getItemMeta(); in_meta.setDisplayName("Interior walls"); - in_meta.setLore(Collections.singletonList("Any valid Wall/Floor block")); + in_meta.setLore(List.of("Any valid Wall/Floor block")); in_wall.setItemMeta(in_meta); // interior floor ItemStack in_floor = new ItemStack(Material.LIGHT_GRAY_WOOL, 1); ItemMeta fl_meta = in_floor.getItemMeta(); fl_meta.setDisplayName("Interior floors"); - fl_meta.setLore(Collections.singletonList("Any valid Wall/Floor block")); + fl_meta.setLore(List.of("Any valid Wall/Floor block")); in_floor.setItemMeta(fl_meta); // seed block ItemStack block = new ItemStack(t.get(type), 1); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/areas/TARDISEditAreasInventory.java b/src/main/java/me/eccentric_nz/TARDIS/commands/areas/TARDISEditAreasInventory.java index 0834f7b87..bd9dd5454 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/areas/TARDISEditAreasInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/areas/TARDISEditAreasInventory.java @@ -64,7 +64,7 @@ public ItemStack[] getLocations() { ItemStack add = new ItemStack(Material.NETHER_STAR, 1); ItemMeta er = add.getItemMeta(); er.setDisplayName("Add"); - er.setLore(Collections.singletonList("area_id: " + area_id)); + er.setLore(List.of("area_id: " + area_id)); add.setItemMeta(er); stacks[48] = add; // remove diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/config/TARDISConfigMenuInventory.java b/src/main/java/me/eccentric_nz/TARDIS/commands/config/TARDISConfigMenuInventory.java index f332d9d55..a0d378ca1 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/config/TARDISConfigMenuInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/config/TARDISConfigMenuInventory.java @@ -77,7 +77,7 @@ private ItemStack[] getItemStack() { cmd += 100; // xx -> 1xx } im.setCustomModelData(cmd); - im.setLore(Collections.singletonList(value)); + im.setLore(List.of(value)); is.setItemMeta(im); options.add(is); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/config/TARDISConfigMenuListener.java b/src/main/java/me/eccentric_nz/TARDIS/commands/config/TARDISConfigMenuListener.java index 71a390a15..fdcf81265 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/config/TARDISConfigMenuListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/config/TARDISConfigMenuListener.java @@ -112,7 +112,7 @@ private String getDisplay(InventoryView view, int slot) { } private void setLore(InventoryView view, int slot, String str) { - List lore = (str != null) ? Collections.singletonList(str) : null; + List lore = (str != null) ? List.of(str) : null; ItemStack is = view.getItem(slot); ItemMeta im = is.getItemMeta(); im.setLore(lore); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/config/TARDISConfigPageTwoInventory.java b/src/main/java/me/eccentric_nz/TARDIS/commands/config/TARDISConfigPageTwoInventory.java index f9e38f9b8..aa551de30 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/config/TARDISConfigPageTwoInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/config/TARDISConfigPageTwoInventory.java @@ -70,7 +70,7 @@ private ItemStack[] getItemStack() { cmd += 100; // xx -> 1xx } im.setCustomModelData(cmd); - im.setLore(Collections.singletonList(value)); + im.setLore(List.of(value)); is.setItemMeta(im); options.add(is); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISHumInventory.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISHumInventory.java index aaf3983ed..710866ba3 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISHumInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISHumInventory.java @@ -71,7 +71,7 @@ private ItemStack[] getItemStack() { ItemStack play = new ItemStack(Material.BOWL, 1); ItemMeta save = play.getItemMeta(); save.setDisplayName("Action"); - save.setLore(Collections.singletonList("PLAY")); + save.setLore(List.of("PLAY")); save.setCustomModelData(GUIInteriorSounds.ACTION.getCustomModelData()); play.setItemMeta(save); stack[15] = play; diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISHumListener.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISHumListener.java index 42f31b102..a43dc572a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISHumListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISHumListener.java @@ -28,8 +28,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Locale; import java.util.UUID; @@ -125,7 +125,7 @@ public void onPrefsMenuClick(InventoryClickEvent event) { private void setPlay(InventoryView view, String str) { ItemStack play = view.getItem(15); ItemMeta save = play.getItemMeta(); - save.setLore(Collections.singletonList(str)); + save.setLore(List.of(str)); play.setItemMeta(save); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuInventory.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuInventory.java index ce48e3018..5b609f0bb 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuInventory.java @@ -128,9 +128,9 @@ private ItemStack[] getItemStack() { } im.setCustomModelData(v ? cmd : cmd + 100); if (pref == GUIPlayerPreferences.HADS_TYPE) { - im.setLore(Collections.singletonList(v ? "DISPERSAL" : "DISPLACEMENT")); + im.setLore(List.of(v ? "DISPERSAL" : "DISPLACEMENT")); } else { - im.setLore(Collections.singletonList(v ? plugin.getLanguage().getString("SET_ON") : plugin.getLanguage().getString("SET_OFF"))); + im.setLore(List.of(v ? plugin.getLanguage().getString("SET_ON") : plugin.getLanguage().getString("SET_OFF"))); } is.setItemMeta(im); stack[pref.getSlot()] = is; @@ -144,7 +144,7 @@ private ItemStack[] getItemStack() { ItemMeta ght_im = fli.getItemMeta(); ght_im.setDisplayName("Flight Mode"); String mode_value = FlightMode.getByMode().get(rsp.getFlightMode()).toString(); - ght_im.setLore(Collections.singletonList(mode_value)); + ght_im.setLore(List.of(mode_value)); ght_im.setCustomModelData(GUIPlayerPreferences.FLIGHT_MODE.getCustomModelData()); fli.setItemMeta(ght_im); stack[GUIPlayerPreferences.FLIGHT_MODE.getSlot()] = fli; @@ -153,7 +153,7 @@ private ItemStack[] getItemStack() { ItemMeta hum_im = hum.getItemMeta(); hum_im.setDisplayName("Interior Hum Sound"); String hum_value = (rsp.getHum().isEmpty()) ? "random" : rsp.getHum(); - hum_im.setLore(Collections.singletonList(hum_value)); + hum_im.setLore(List.of(hum_value)); hum_im.setCustomModelData(GUIPlayerPreferences.INTERIOR_HUM_SOUND.getCustomModelData()); hum.setItemMeta(hum_im); stack[GUIPlayerPreferences.INTERIOR_HUM_SOUND.getSlot()] = hum; @@ -161,7 +161,7 @@ private ItemStack[] getItemStack() { ItemStack hand = new ItemStack(Material.LEVER, 1); ItemMeta brake = hand.getItemMeta(); brake.setDisplayName("Handbrake"); - brake.setLore(Collections.singletonList((tardis != null && tardis.isHandbrakeOn()) ? plugin.getLanguage().getString("SET_ON") : plugin.getLanguage().getString("SET_OFF"))); + brake.setLore(List.of((tardis != null && tardis.isHandbrakeOn()) ? plugin.getLanguage().getString("SET_ON") : plugin.getLanguage().getString("SET_OFF"))); brake.setCustomModelData(GUIPlayerPreferences.HANDBRAKE.getCustomModelData()); hand.setItemMeta(brake); stack[GUIPlayerPreferences.HANDBRAKE.getSlot()] = hand; diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuListener.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuListener.java index 99d976317..97645ded7 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISPrefsMenuListener.java @@ -183,7 +183,7 @@ public void onPrefsMenuClick(InventoryClickEvent event) { HashMap set = new HashMap<>(); set.put("handbrake_on", 1); plugin.getQueryFactory().doUpdate("tardis", set, wheret); - im.setLore(Collections.singletonList(plugin.getLanguage().getString("SET_ON"))); + im.setLore(List.of(plugin.getLanguage().getString("SET_ON"))); is.setItemMeta(im); // Check if it's at a recharge point TARDISArtronLevels tal = new TARDISArtronLevels(plugin); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISTabComplete.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISTabComplete.java index 3c6a7061d..1af7c1a80 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISTabComplete.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISTabComplete.java @@ -115,7 +115,7 @@ public List onTabComplete(CommandSender sender, Command command, String return partial(lastArg, THEME_SUBS); } case "home" -> { - return partial(lastArg, Collections.singletonList("set")); + return partial(lastArg, List.of("set")); } case "item" -> { return partial(lastArg, ITEM_SUBS); diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/travel/TARDISTravelCoords.java b/src/main/java/me/eccentric_nz/TARDIS/commands/travel/TARDISTravelCoords.java index a37c325ca..cc716c6db 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/travel/TARDISTravelCoords.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/travel/TARDISTravelCoords.java @@ -75,7 +75,7 @@ public boolean action(Player player, String[] args, int id) { return true; } // only world specified - List worlds = Collections.singletonList(world.getName()); + List worlds = List.of(world.getName()); // get current location HashMap wherec = new HashMap<>(); wherec.put("tardis_id", id); diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlInventory.java b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlInventory.java index cd56a6d38..940565e53 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlInventory.java @@ -133,7 +133,7 @@ private ItemStack[] getItemStack() { ItemMeta ttle = thro.getItemMeta(); ttle.setDisplayName(plugin.getLanguage().getString("BUTTON_THROTTLE")); String throttle = SpaceTimeThrottle.getByDelay().get(delay).toString(); - ttle.setLore(Collections.singletonList(throttle)); + ttle.setLore(List.of(throttle)); ttle.setCustomModelData(GUIControlCentre.BUTTON_THROTTLE.getCustomModelData()); thro.setItemMeta(ttle); /* @@ -155,7 +155,7 @@ private ItemStack[] getItemStack() { ItemStack pow = new ItemStack(Material.REPEATER, 1); ItemMeta dwn = pow.getItemMeta(); dwn.setDisplayName(plugin.getLanguage().getString("BUTTON_POWER")); - dwn.setLore(Collections.singletonList(power_onoff)); + dwn.setLore(List.of(power_onoff)); int pcmd = GUIControlCentre.BUTTON_POWER.getCustomModelData(); if (power_onoff.equals(off)) { pcmd += 100; @@ -166,7 +166,7 @@ private ItemStack[] getItemStack() { ItemStack lig = new ItemStack(Material.REPEATER, 1); ItemMeta swi = lig.getItemMeta(); swi.setDisplayName(plugin.getLanguage().getString("BUTTON_LIGHTS")); - swi.setLore(Collections.singletonList(lights_onoff)); + swi.setLore(List.of(lights_onoff)); int lcmd = GUIControlCentre.BUTTON_LIGHTS.getCustomModelData(); if (lights_onoff.equals(off)) { lcmd += 100; @@ -177,7 +177,7 @@ private ItemStack[] getItemStack() { ItemStack tog = new ItemStack(Material.REPEATER, 1); ItemMeta gle = tog.getItemMeta(); gle.setDisplayName(plugin.getLanguage().getString("BUTTON_TOGGLE")); - gle.setLore(Collections.singletonList(toggle_openclosed)); + gle.setLore(List.of(toggle_openclosed)); int tcmd = GUIControlCentre.BUTTON_TOGGLE.getCustomModelData(); if (!open) { tcmd += 100; @@ -203,7 +203,7 @@ private ItemStack[] getItemStack() { ItemStack siege = new ItemStack(Material.REPEATER, 1); ItemMeta mode = siege.getItemMeta(); mode.setDisplayName(plugin.getLanguage().getString("BUTTON_SIEGE")); - mode.setLore(Collections.singletonList(siege_onoff)); + mode.setLore(List.of(siege_onoff)); int scmd = GUIControlCentre.BUTTON_SIEGE.getCustomModelData(); if (siege_onoff.equals(off)) { scmd += 100; @@ -227,7 +227,7 @@ private ItemStack[] getItemStack() { ItemMeta ection = dir.getItemMeta(); ection.setDisplayName(plugin.getLanguage().getString("BUTTON_DIRECTION")); ection.setCustomModelData(GUIControlCentre.BUTTON_DIRECTION.getCustomModelData()); - ection.setLore(Collections.singletonList(direction)); + ection.setLore(List.of(direction)); dir.setItemMeta(ection); // temporal ItemStack temp = new ItemStack(Material.BOWL, 1); diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlMenuListener.java b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlMenuListener.java index 2ef3e3c52..dea152440 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlMenuListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlMenuListener.java @@ -59,8 +59,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.UUID; /** @@ -406,7 +406,7 @@ public void onControlMenuInteract(InventoryClickEvent event) { // update the lore ItemStack d = view.getItem(40); ItemMeta im = d.getItemMeta(); - im.setLore(Collections.singletonList(direction)); + im.setLore(List.of(direction)); d.setItemMeta(im); } } @@ -462,7 +462,7 @@ public void onControlMenuInteract(InventoryClickEvent event) { delay = 4; } String throttle = SpaceTimeThrottle.getByDelay().get(delay).toString(); - im.setLore(Collections.singletonList(throttle)); + im.setLore(List.of(throttle)); spt.setItemMeta(im); // update player prefs HashMap wherer = new HashMap<>(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISConfiguration.java b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISConfiguration.java index b5cd332d2..abbe45429 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISConfiguration.java +++ b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISConfiguration.java @@ -248,7 +248,7 @@ public TARDISConfiguration(TARDIS plugin) { comments.put("circuits", Arrays.asList("circuits", "https://tardis.pages.dev/circuit-use#configuration-options")); comments.put("creation", Arrays.asList("inner TARDIS", "https://tardis.pages.dev/configuration/creation")); comments.put("desktop", Arrays.asList("desktop theme", "https://tardis.pages.dev/desktop-theme#config-options")); - comments.put("display", Collections.singletonList("HUD display")); + comments.put("display", List.of("HUD display")); comments.put("growth", Arrays.asList("room related", "https://tardis.pages.dev/configuration/growth")); comments.put("junk", Arrays.asList("junk TARDIS", "https://tardis.pages.dev/junk-tardis#configuration-options")); comments.put("mapping", Arrays.asList("mapping", "https://tardis.pages.dev/modules/mapping#configuration-options")); @@ -259,7 +259,7 @@ public TARDISConfiguration(TARDIS plugin) { comments.put("sonic", Arrays.asList("sonic screwdriver preferences", "https://tardis.pages.dev/sonic-dock#configuration")); comments.put("storage", Arrays.asList("how the plugin persists data", "https://tardis.pages.dev/configuration/storage")); comments.put("travel", Arrays.asList("travel settings", "https://tardis.pages.dev/configuration/travel")); - comments.put("conversions", Collections.singletonList("don't touch!")); + comments.put("conversions", List.of("don't touch!")); } /** diff --git a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISSignsUpdater.java b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISSignsUpdater.java index 485df61f2..c84c3c674 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISSignsUpdater.java +++ b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISSignsUpdater.java @@ -42,8 +42,8 @@ public TARDISSignsUpdater(TARDIS plugin, FileConfiguration signs_config) { strings.put("terminal", Arrays.asList("Destination", "Terminal")); strings.put("saves", Arrays.asList("Saved", "Locations")); strings.put("control", Arrays.asList("Control", "Centre")); - strings.put("keyboard", Collections.singletonList("Keyboard")); - strings.put("junk", Collections.singletonList("Destination")); + strings.put("keyboard", List.of("Keyboard")); + strings.put("junk", List.of("Destination")); } public void checkSignsConfig() { diff --git a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateMapForm.java b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateMapForm.java index 0e9765c1e..51668a31e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateMapForm.java +++ b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateMapForm.java @@ -34,7 +34,7 @@ public class FloodgateMapForm { private final Connection connection = service.getConnection(); private final TARDIS plugin; private final String prefix; - private final List STONE = Collections.singletonList("STONE"); + private final List STONE = List.of("STONE"); private final UUID uuid; private final int id; private final String path = "https://github.com/eccentricdevotion/TARDIS-Resource-Pack/raw/master/assets/tardis/textures/item/gui/room/%s.png"; diff --git a/src/main/java/me/eccentric_nz/TARDIS/handles/TARDISHandlesBlock.java b/src/main/java/me/eccentric_nz/TARDIS/handles/TARDISHandlesBlock.java index a0326b1ad..84e4b6339 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/handles/TARDISHandlesBlock.java +++ b/src/main/java/me/eccentric_nz/TARDIS/handles/TARDISHandlesBlock.java @@ -39,7 +39,7 @@ public enum TARDISHandlesBlock { END(TARDISHandlesCategory.CONTROL, "END", Arrays.asList("Use to finish", "a conditional or", "loop statement"), 11), IF(TARDISHandlesCategory.CONTROL, "IF", Arrays.asList("Check whether a", "condition is", "true or false"), 12), ELSE(TARDISHandlesCategory.CONTROL, "ELSE", Arrays.asList("Use to run actions", "if an IF is false"), 13), - ELSE_IF(TARDISHandlesCategory.CONTROL, "ELSE IF", Collections.singletonList("Check another condition"), 14), + ELSE_IF(TARDISHandlesCategory.CONTROL, "ELSE IF", List.of("Check another condition"), 14), BREAK(TARDISHandlesCategory.CONTROL, "BREAK", Arrays.asList("Use to break", "out of a loop"), 15), // event MATERIALISE(TARDISHandlesCategory.EVENT, "TARDIS materialisation event", null, 16), @@ -53,16 +53,16 @@ public enum TARDISHandlesBlock { SIEGE_OFF(TARDISHandlesCategory.EVENT, "Siege Mode Off event", null, 24), LOG_OUT(TARDISHandlesCategory.EVENT, "Player log out event", null, 25), // number - ZERO(TARDISHandlesCategory.NUMBER, "0", Collections.singletonList("The number zero"), 26), - ONE(TARDISHandlesCategory.NUMBER, "1", Collections.singletonList("The number one"), 27), - TWO(TARDISHandlesCategory.NUMBER, "2", Collections.singletonList("The number two"), 28), - THREE(TARDISHandlesCategory.NUMBER, "3", Collections.singletonList("The number three"), 29), - FOUR(TARDISHandlesCategory.NUMBER, "4", Collections.singletonList("The number four"), 30), - FIVE(TARDISHandlesCategory.NUMBER, "5", Collections.singletonList("The number five"), 31), - SIX(TARDISHandlesCategory.NUMBER, "6", Collections.singletonList("The number six"), 32), - SEVEN(TARDISHandlesCategory.NUMBER, "7", Collections.singletonList("The number seven"), 33), - EIGHT(TARDISHandlesCategory.NUMBER, "8", Collections.singletonList("The number eight"), 34), - NINE(TARDISHandlesCategory.NUMBER, "9", Collections.singletonList("The number nine"), 35), + ZERO(TARDISHandlesCategory.NUMBER, "0", List.of("The number zero"), 26), + ONE(TARDISHandlesCategory.NUMBER, "1", List.of("The number one"), 27), + TWO(TARDISHandlesCategory.NUMBER, "2", List.of("The number two"), 28), + THREE(TARDISHandlesCategory.NUMBER, "3", List.of("The number three"), 29), + FOUR(TARDISHandlesCategory.NUMBER, "4", List.of("The number four"), 30), + FIVE(TARDISHandlesCategory.NUMBER, "5", List.of("The number five"), 31), + SIX(TARDISHandlesCategory.NUMBER, "6", List.of("The number six"), 32), + SEVEN(TARDISHandlesCategory.NUMBER, "7", List.of("The number seven"), 33), + EIGHT(TARDISHandlesCategory.NUMBER, "8", List.of("The number eight"), 34), + NINE(TARDISHandlesCategory.NUMBER, "9", List.of("The number nine"), 35), COIN(TARDISHandlesCategory.NUMBER, "Flip a coin", Arrays.asList("Returns a true", "or false value"), 36), RANDOM(TARDISHandlesCategory.NUMBER, "Random number", Arrays.asList("Generate a random number", "between 0 and the", "number that follows"), 37), // operator diff --git a/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISRecipeInventory.java b/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISRecipeInventory.java index c21e9fa5b..74470f2a6 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISRecipeInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISRecipeInventory.java @@ -30,8 +30,8 @@ import org.bukkit.inventory.meta.ItemMeta; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; +import java.util.List; public class TARDISRecipeInventory { @@ -102,7 +102,7 @@ private ItemStack[] getItemStack() { } ItemMeta im = result.getItemMeta(); im.setDisplayName(str); - im.setLore(Collections.singletonList("/trecipe " + arg)); + im.setLore(List.of("/trecipe " + arg)); im.setCustomModelData(item.getCustomModelData()); im.addItemFlags(ItemFlag.values()); result.setItemMeta(im); diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorInventory.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorInventory.java index 1021645d7..0535e5710 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorInventory.java @@ -59,7 +59,7 @@ private ItemStack[] getItemStack() { ItemStack is = new ItemStack(Material.BLAZE_ROD, 1); ItemMeta im = is.getItemMeta(); im.setDisplayName("Sonic Screwdriver"); - im.setLore(Collections.singletonList(sonic.getName())); + im.setLore(List.of(sonic.getName())); im.setCustomModelData(sonic.getCustomModelData()); is.setItemMeta(im); stack[sonic.getSlot()] = is; @@ -155,7 +155,7 @@ private ItemStack[] getItemStack() { ItemStack cost = new ItemStack(Material.BOWL, 1); ItemMeta cost_im = cost.getItemMeta(); cost_im.setDisplayName("Artron cost"); - cost_im.setLore(Collections.singletonList("" + artron)); + cost_im.setLore(List.of("" + artron)); cost_im.setCustomModelData(GUISonicGenerator.ARTRON_COST.getCustomModelData()); cost.setItemMeta(cost_im); stack[45] = cost; diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicMenuInventory.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicMenuInventory.java index 9f7be5a61..1869de09a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicMenuInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicMenuInventory.java @@ -56,7 +56,7 @@ private ItemStack[] getItemStack() { ItemStack is = new ItemStack(sonic.getMaterial(), 1); ItemMeta im = is.getItemMeta(); im.setDisplayName("Sonic Screwdriver"); - im.setLore(Collections.singletonList(sonic.getName())); + im.setLore(List.of(sonic.getName())); im.setCustomModelData(sonic.getCustomModelData()); is.setItemMeta(im); stack[sonic.getSlot()] = is; diff --git a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTemporalLocatorInventory.java b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTemporalLocatorInventory.java index 951611305..a2bb30ecc 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTemporalLocatorInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTemporalLocatorInventory.java @@ -16,13 +16,14 @@ */ package me.eccentric_nz.TARDIS.travel; -import java.util.Arrays; -import java.util.Collections; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.custommodeldata.GUITemporalLocator; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import java.util.Arrays; +import java.util.List; + /** * Time travel is, as the name suggests, the (usually controlled) process of travelling through time, even in a * non-linear direction. In the 26th century individuals who time travel are sometimes known as persons of meta-temporal @@ -58,7 +59,7 @@ private ItemStack[] getItemStack() { if (clock.getLore().contains("~")) { im.setLore(Arrays.asList(clock.getLore().split("~"))); } else { - im.setLore(Collections.singletonList(clock.getLore())); + im.setLore(List.of(clock.getLore())); } im.setCustomModelData(clock.getCustomModelData()); is.setItemMeta(im); diff --git a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTerminalInventory.java b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTerminalInventory.java index cfe3f31b1..93c06b3f5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTerminalInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTerminalInventory.java @@ -16,12 +16,13 @@ */ package me.eccentric_nz.TARDIS.travel; -import java.util.Collections; import me.eccentric_nz.TARDIS.TARDIS; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import java.util.List; + /** * John Lumic was a business tycoon, owner of Cybus Industries and the creator of the Cybermen. Though he publicly * denied rumours of ill health, Lumic suffered from a terminal illness and used a motorized wheelchair as transport. @@ -80,19 +81,19 @@ private ItemStack[] getItemStack() { ItemStack x = new ItemStack(Material.LIGHT_BLUE_WOOL, 1); ItemMeta xim = x.getItemMeta(); xim.setDisplayName("X"); - xim.setLore(Collections.singletonList("0")); + xim.setLore(List.of("0")); x.setItemMeta(xim); // z ItemStack z = new ItemStack(Material.YELLOW_WOOL, 1); ItemMeta zim = z.getItemMeta(); zim.setDisplayName("Z"); - zim.setLore(Collections.singletonList("0")); + zim.setLore(List.of("0")); z.setItemMeta(zim); // multiplier ItemStack m = new ItemStack(Material.PURPLE_WOOL, 1); ItemMeta mim = m.getItemMeta(); mim.setDisplayName(plugin.getLanguage().getString("BUTTON_MULTI")); - mim.setLore(Collections.singletonList("x1")); + mim.setLore(List.of("x1")); m.setItemMeta(mim); // environments // current diff --git a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTerminalListener.java b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTerminalListener.java index bacbc8dcd..110db63b7 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTerminalListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISTerminalListener.java @@ -168,7 +168,7 @@ public void onDestTerminalClick(InventoryClickEvent event) { // set lore ItemStack is = view.getItem(49); ItemMeta im = is.getItemMeta(); - List lore = Collections.singletonList("No valid destination has been set!"); + List lore = List.of("No valid destination has been set!"); im.setLore(lore); is.setItemMeta(im); } @@ -209,7 +209,7 @@ public void onOpenTerminal(InventoryOpenEvent event) { String sub = (rsp.isSubmarineOn()) ? "true" : "false"; ItemStack is = inv.getItem(44); ItemMeta im = is.getItemMeta(); - im.setLore(Collections.singletonList(sub)); + im.setLore(List.of(sub)); is.setItemMeta(im); } } @@ -244,7 +244,7 @@ private List getLoreValue(int max, int slot, boolean signed, UUID uuid) case 6 -> (signed) ? "-" + (3 * step) : "x" + 1; default -> (signed) ? "0" : "x" + 4; }; - return Collections.singletonList(str); + return List.of(str); } private int getValue(int max, int slot, boolean signed, UUID uuid) { @@ -295,24 +295,24 @@ private void setCurrent(InventoryView view, Player p, int slot) { switch (slot) { case 38 -> // get a normal world - lore = Collections.singletonList(getWorld("NORMAL", current, p)); + lore = List.of(getWorld("NORMAL", current, p)); case 40 -> { // get a nether world if (plugin.getConfig().getBoolean("travel.nether") || !plugin.getConfig().getBoolean("travel.terminal.redefine")) { - lore = Collections.singletonList(getWorld("NETHER", current, p)); + lore = List.of(getWorld("NETHER", current, p)); } else { - lore = Collections.singletonList(getWorld(plugin.getConfig().getString("travel.terminal.nether"), current, p)); + lore = List.of(getWorld(plugin.getConfig().getString("travel.terminal.nether"), current, p)); } } case 42 -> { // get an end world if (plugin.getConfig().getBoolean("travel.the_end") || !plugin.getConfig().getBoolean("travel.terminal.redefine")) { - lore = Collections.singletonList(getWorld("THE_END", current, p)); + lore = List.of(getWorld("THE_END", current, p)); } else { - lore = Collections.singletonList(getWorld(plugin.getConfig().getString("travel.terminal.the_end"), current, p)); + lore = List.of(getWorld(plugin.getConfig().getString("travel.terminal.the_end"), current, p)); } } - default -> lore = Collections.singletonList(current); + default -> lore = List.of(current); } } im.setLore(lore); @@ -326,7 +326,7 @@ private void toggleSubmarine(InventoryView view, Player p) { String bool = (rsp.isSubmarineOn()) ? "false" : "true"; ItemStack is = view.getItem(44); ItemMeta im = is.getItemMeta(); - im.setLore(Collections.singletonList(bool)); + im.setLore(List.of(bool)); is.setItemMeta(im); int tf = (rsp.isSubmarineOn()) ? 0 : 1; HashMap set = new HashMap<>(); diff --git a/src/main/java/me/eccentric_nz/tardischemistry/compound/CompoundBuilder.java b/src/main/java/me/eccentric_nz/tardischemistry/compound/CompoundBuilder.java index 92ce07349..0d6113fea 100644 --- a/src/main/java/me/eccentric_nz/tardischemistry/compound/CompoundBuilder.java +++ b/src/main/java/me/eccentric_nz/tardischemistry/compound/CompoundBuilder.java @@ -20,7 +20,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.Collections; +import java.util.List; public class CompoundBuilder { @@ -48,7 +48,7 @@ public static ItemStack getCompound(Compound compound) { is = new ItemStack(Material.GLASS_BOTTLE, 1); ItemMeta im = is.getItemMeta(); im.setDisplayName(compound.toString().replace("_", " ")); - im.setLore(Collections.singletonList(compound.getSymbol())); + im.setLore(List.of(compound.getSymbol())); im.setCustomModelData(10000001 + compound.ordinal()); is.setItemMeta(im); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/commands/TabComplete.java b/src/main/java/me/eccentric_nz/tardisweepingangels/commands/TabComplete.java index 287544f76..45db7cb29 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/commands/TabComplete.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/commands/TabComplete.java @@ -71,7 +71,7 @@ public List onTabComplete(CommandSender sender, Command command, String return switch (args[0]) { case "disguise" -> partial(args[2], ONOFF_SUBS); case "give" -> partial(args[2], MONSTER_SUBS); - case "follow" -> Collections.singletonList("15"); + case "follow" -> List.of("15"); default -> partial(args[2], WORLD_SUBS); }; } From 15a24c44f68fdda94bfd69f7b4b5c4ebd26cefbc Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sun, 28 Apr 2024 11:39:46 +1200 Subject: [PATCH 59/96] WeepingAngels module should run on Spigot too --- src/main/java/me/eccentric_nz/TARDIS/TARDIS.java | 4 ---- .../me/eccentric_nz/TARDIS/camera/TARDISDismountListener.java | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java b/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java index 862fb2732..c4054f671 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java +++ b/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java @@ -458,7 +458,6 @@ public void onEnable() { tardisMapper.enable(); } if (getConfig().getBoolean("modules.weeping_angels")) { - if (PaperLib.isPaper()) { getMessenger().message(console, TardisModule.TARDIS, "Loading Weeping Angels Module"); new TARDISWeepingAngels(this).enable(); if (!getConfig().getBoolean("conversions.all_in_one.weeping_angels")) { @@ -467,9 +466,6 @@ public void onEnable() { conversions++; } } - } else { - getLogger().log(Level.WARNING, "The Weeping Angels Module requires Paper server or a suitable variant!"); - } } if (getConfig().getBoolean("modules.vortex_manipulator")) { getMessenger().message(console, TardisModule.TARDIS, "Loading Vortex Manipulator Module"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/camera/TARDISDismountListener.java b/src/main/java/me/eccentric_nz/TARDIS/camera/TARDISDismountListener.java index 8f8e8702c..9c047f6e2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/camera/TARDISDismountListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/camera/TARDISDismountListener.java @@ -1,6 +1,5 @@ package me.eccentric_nz.TARDIS.camera; -import io.papermc.lib.PaperLib; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.tardisweepingangels.TARDISWeepingAngels; import org.bukkit.entity.ArmorStand; @@ -24,7 +23,7 @@ public TARDISDismountListener(TARDIS plugin) { public void onDismount(EntityDismountEvent event) { EntityType riding = event.getEntity().getType(); EntityType ridden = event.getDismounted().getType(); - if ((PaperLib.isPaper() && plugin.getConfig().getBoolean("modules.weeping_angels")) && ridden == EntityType.SKELETON && riding == EntityType.GUARDIAN) { + if (plugin.getConfig().getBoolean("modules.weeping_angels") && ridden == EntityType.SKELETON && riding == EntityType.GUARDIAN) { if (event.getEntity().getPersistentDataContainer().has(TARDISWeepingAngels.SILENT, PersistentDataType.INTEGER)) { event.setCancelled(true); } From bbee160f1a0c6c8bed8e592faf43686657a7127a Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sun, 28 Apr 2024 11:40:51 +1200 Subject: [PATCH 60/96] Add Armadillo & Wolf variants to Lazarus GUI --- .../TARDIS/lazarus/LazarusWolf.java | 23 +++++ .../lazarus/TARDISLazarusGUIListener.java | 83 ++++++++++++------- .../lazarus/TARDISLazarusInventory.java | 8 +- .../TARDIS/lazarus/TARDISLazarusLibs.java | 3 +- .../TARDISLazarusPageTwoInventory.java | 14 ++-- .../TARDISWeepingAngelsMonstersInventory.java | 23 ++--- .../disguise/TARDISDisguise.java | 31 +++---- todo.md | 4 +- 8 files changed, 122 insertions(+), 67 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/lazarus/LazarusWolf.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/lazarus/LazarusWolf.java b/src/main/java/me/eccentric_nz/TARDIS/lazarus/LazarusWolf.java new file mode 100644 index 000000000..35b3ad844 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/lazarus/LazarusWolf.java @@ -0,0 +1,23 @@ +package me.eccentric_nz.TARDIS.lazarus; + +import org.bukkit.entity.Wolf; + +import java.util.HashMap; +import java.util.List; + +public class LazarusWolf { + + public static final HashMap VARIANTS = new HashMap<>() {{ + put("PALE", Wolf.Variant.PALE); + put("ASHEN", Wolf.Variant.ASHEN); + put("BLACK", Wolf.Variant.BLACK); + put("CHESTNUT", Wolf.Variant.CHESTNUT); + put("RUSTY", Wolf.Variant.RUSTY); + put("SNOWY", Wolf.Variant.SNOWY); + put("SPOTTED", Wolf.Variant.SPOTTED); + put("STRIPED", Wolf.Variant.STRIPED); + put("WOODS", Wolf.Variant.WOODS); + }}; + + public static final List NAMES = List.of("PALE", "ASHEN", "BLACK", "CHESTNUT", "RUSTY", "SNOWY", "SPOTTED", "STRIPED", "WOODS"); +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusGUIListener.java b/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusGUIListener.java index 7842201ad..15c442024 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusGUIListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusGUIListener.java @@ -65,6 +65,7 @@ public class TARDISLazarusGUIListener extends TARDISMenuListener { private final HashMap sheep = new HashMap<>(); private final HashMap slimes = new HashMap<>(); private final HashMap tropics = new HashMap<>(); + private final HashMap wolves = new HashMap<>(); private final HashMap disguises = new HashMap<>(); private final List slimeSizes = Arrays.asList(1, 2, 4); private final List pufferStates = Arrays.asList(0, 1, 2); @@ -119,7 +120,7 @@ public void onLazarusClick(InventoryClickEvent event) { // remember selection String display = im.getDisplayName(); if (twaMonsters.contains(display) && !plugin.getConfig().getBoolean("modules.weeping_angels")) { - im.setLore(Collections.singletonList("Genetic modification not available!")); + im.setLore(List.of("Genetic modification not available!")); is.setItemMeta(im); } else { if (display.equals("HEROBRINE")) { @@ -135,11 +136,11 @@ public void onLazarusClick(InventoryClickEvent event) { switch (slot) { case 43 -> { pagers.add(uuid); - ItemStack is = view.getItem(slot); - ItemMeta im = is.getItemMeta(); + ItemStack pageButton = view.getItem(slot); + ItemMeta pageMeta = pageButton.getItemMeta(); // go to page one or two Inventory inv = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "Genetic Manipulator"); - if (im.getDisplayName().equals(plugin.getLanguage().getString("BUTTON_PAGE_1"))) { + if (pageMeta.getDisplayName().equals(plugin.getLanguage().getString("BUTTON_PAGE_1"))) { inv.setContents(new TARDISLazarusInventory(plugin).getPageOne()); } else { inv.setContents(new TARDISLazarusPageTwoInventory(plugin).getPageTwo()); @@ -149,11 +150,11 @@ public void onLazarusClick(InventoryClickEvent event) { case 44 -> { if (plugin.getConfig().getBoolean("modules.weeping_angels")) { pagers.add(uuid); - ItemStack is = view.getItem(slot); - ItemMeta im = is.getItemMeta(); + ItemStack monstersButton = view.getItem(slot); + ItemMeta monstersMeta = monstersButton.getItemMeta(); // go to monsters or page two Inventory inv = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "Genetic Manipulator"); - if (im.getDisplayName().equals(plugin.getLanguage().getString("BUTTON_PAGE_2"))) { + if (monstersMeta.getDisplayName().equals(plugin.getLanguage().getString("BUTTON_PAGE_2"))) { inv.setContents(new TARDISLazarusPageTwoInventory(plugin).getPageTwo()); } else { inv.setContents(new TARDISWeepingAngelsMonstersInventory(plugin).getMonsters()); @@ -162,29 +163,29 @@ public void onLazarusClick(InventoryClickEvent event) { } } case 45 -> { // The Master Switch : ON | OFF - ItemStack is = view.getItem(slot); - ItemMeta im = is.getItemMeta(); + ItemStack masterButton = view.getItem(slot); + ItemMeta masterMeta = masterButton.getItemMeta(); if (TARDISPermission.hasPermission(player, "tardis.themaster")) { if (plugin.getTrackerKeeper().getImmortalityGate().equals("")) { - boolean isOff = im.getLore().get(0).equals(plugin.getLanguage().getString("SET_OFF")); + boolean isOff = masterMeta.getLore().get(0).equals(plugin.getLanguage().getString("SET_OFF")); String onoff = isOff ? plugin.getLanguage().getString("SET_ON") : plugin.getLanguage().getString("SET_OFF"); - im.setLore(Collections.singletonList(onoff)); + masterMeta.setLore(List.of(onoff)); int cmd = isOff ? 2 : 3; - im.setCustomModelData(cmd); + masterMeta.setCustomModelData(cmd); } else { - im.setLore(Arrays.asList("The Master Race is already", " set to " + plugin.getTrackerKeeper().getImmortalityGate() + "!", "Try again later.")); + masterMeta.setLore(Arrays.asList("The Master Race is already", " set to " + plugin.getTrackerKeeper().getImmortalityGate() + "!", "Try again later.")); } } else { - im.setLore(Arrays.asList("You do not have permission", "to be The Master!")); + masterMeta.setLore(Arrays.asList("You do not have permission", "to be The Master!")); } - is.setItemMeta(im); + masterButton.setItemMeta(masterMeta); } case 47 -> { // adult / baby - ItemStack is = view.getItem(slot); - ItemMeta im = is.getItemMeta(); - String onoff = (im.getLore().get(0).equals("ADULT")) ? "BABY" : "ADULT"; - im.setLore(Collections.singletonList(onoff)); - is.setItemMeta(im); + ItemStack ageButton = view.getItem(slot); + ItemMeta ageMeta = ageButton.getItemMeta(); + String onoff = (ChatColor.stripColor(ageMeta.getLore().get(0)).equals("ADULT")) ? "BABY" : "ADULT"; + ageMeta.setLore(List.of(onoff)); + ageButton.setItemMeta(ageMeta); } case 48 -> { // type / colour if (disguises.containsKey(uuid)) { @@ -192,14 +193,14 @@ public void onLazarusClick(InventoryClickEvent event) { } } case 49 -> { // Tamed / Flying / Blazing / Powered / Beaming / Aggressive / Decorated / Chest carrying : TRUE | FALSE - ItemStack is = view.getItem(slot); - ItemMeta im = is.getItemMeta(); - List lore = im.getLore(); + ItemStack optionsButton = view.getItem(slot); + ItemMeta optionsMeta = optionsButton.getItemMeta(); + List lore = optionsMeta.getLore(); int pos = lore.size() - 1; String truefalse = (ChatColor.stripColor(lore.get(pos)).equals("FALSE")) ? ChatColor.GREEN + "TRUE" : ChatColor.RED + "FALSE"; lore.set(pos, truefalse); - im.setLore(lore); - is.setItemMeta(im); + optionsMeta.setLore(lore); + optionsButton.setItemMeta(optionsMeta); } case 51 -> { // remove disguise pagers.remove(uuid); @@ -315,13 +316,20 @@ public void onLazarusClick(InventoryClickEvent event) { options = new Object[]{getBoolean(view)}; } } - case SHEEP, WOLF -> { + case SHEEP -> { if (plugin.isDisguisesOnServer()) { new TARDISLazarusLibs(player, disguise, getColor(view), getBoolean(view), getBaby(view)).createDisguise(); } else { options = new Object[]{getColor(view), getBoolean(view), AGE.getFromBoolean(getBaby(view))}; } } + case WOLF -> { + if (plugin.isDisguisesOnServer()) { + new TARDISLazarusLibs(player, disguise, getWolfVariant(view), getBoolean(view), getBaby(view)).createDisguise(); + } else { + options = new Object[]{getWolfVariant(view), getBoolean(view), AGE.getFromBoolean(getBaby(view))}; + } + } case HORSE -> { if (plugin.isDisguisesOnServer()) { new TARDISLazarusLibs(player, disguise, getHorseColor(view), false, getBaby(view)).createDisguise(); @@ -514,7 +522,7 @@ private void setSlotFortyEight(InventoryView i, String d, UUID uuid) { snowmen.put(uuid, derp); t = (derp) ? "Pumpkin head" : "Derp face"; } - case "SHEEP", "WOLF" -> { + case "SHEEP" -> { if (sheep.containsKey(uuid)) { o = (sheep.get(uuid) + 1 < 16) ? sheep.get(uuid) + 1 : 0; } else { @@ -523,6 +531,15 @@ private void setSlotFortyEight(InventoryView i, String d, UUID uuid) { t = DyeColor.values()[o].toString(); sheep.put(uuid, o); } + case "WOLF" -> { + if (wolves.containsKey(uuid)) { + o = (wolves.get(uuid) + 1 < 9) ? wolves.get(uuid) + 1 : 0; + } else { + o = 0; + } + t = LazarusWolf.NAMES.get(o); + wolves.put(uuid, o); + } case "HORSE" -> { if (horses.containsKey(uuid)) { o = (horses.get(uuid) + 1 < 7) ? horses.get(uuid) + 1 : 0; @@ -637,7 +654,7 @@ private void setSlotFortyEight(InventoryView i, String d, UUID uuid) { if (t != null) { ItemStack is = i.getItem(48); ItemMeta im = is.getItemMeta(); - im.setLore(Collections.singletonList(t)); + im.setLore(List.of(t)); is.setItemMeta(im); } } @@ -758,6 +775,16 @@ private Rabbit.Type getRabbitType(InventoryView i) { } } + private Wolf.Variant getWolfVariant(InventoryView i) { + ItemStack is = i.getItem(48); + ItemMeta im = is.getItemMeta(); + try { + return LazarusWolf.VARIANTS.get(im.getLore().get(0)); + } catch (IllegalArgumentException e) { + return Wolf.Variant.PALE; + } + } + private Profession getProfession(InventoryView i) { ItemStack is = i.getItem(48); ItemMeta im = is.getItemMeta(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusInventory.java b/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusInventory.java index edaffb7f7..9f9bfed97 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusInventory.java @@ -47,6 +47,7 @@ class TARDISLazarusInventory { // maximum number of eggs is 45 // passive disguises.add(Material.ALLAY_SPAWN_EGG); + disguises.add(Material.ARMADILLO_SPAWN_EGG); disguises.add(Material.AXOLOTL_SPAWN_EGG); disguises.add(Material.BAT_SPAWN_EGG); disguises.add(Material.CAMEL_SPAWN_EGG); @@ -77,7 +78,6 @@ class TARDISLazarusInventory { disguises.add(Material.TROPICAL_FISH_SPAWN_EGG); disguises.add(Material.TURTLE_SPAWN_EGG); disguises.add(Material.VILLAGER_SPAWN_EGG); - disguises.add(Material.WANDERING_TRADER_SPAWN_EGG); // neutral disguises.add(Material.BEE_SPAWN_EGG); disguises.add(Material.CAVE_SPIDER_SPAWN_EGG); @@ -131,21 +131,21 @@ private ItemStack[] getItemStack() { ItemStack the = new ItemStack(Material.COMPARATOR, 1); ItemMeta master = the.getItemMeta(); master.setDisplayName(plugin.getLanguage().getString("BUTTON_MASTER")); - master.setLore(Collections.singletonList(plugin.getLanguage().getString("SET_OFF"))); + master.setLore(List.of(plugin.getLanguage().getString("SET_OFF"))); master.setCustomModelData(GUIGeneticManipulator.BUTTON_MASTER.getCustomModelData()); the.setItemMeta(master); stacks[45] = the; ItemStack adult = new ItemStack(Material.HOPPER, 1); ItemMeta baby = adult.getItemMeta(); baby.setDisplayName(plugin.getLanguage().getString("BUTTON_AGE")); - baby.setLore(Collections.singletonList("ADULT")); + baby.setLore(List.of("ADULT")); baby.setCustomModelData(GUIGeneticManipulator.BUTTON_AGE.getCustomModelData()); adult.setItemMeta(baby); stacks[47] = adult; ItemStack typ = new ItemStack(Material.CYAN_DYE, 1); ItemMeta col = typ.getItemMeta(); col.setDisplayName(plugin.getLanguage().getString("BUTTON_TYPE")); - col.setLore(Collections.singletonList("WHITE")); + col.setLore(List.of("WHITE")); col.setCustomModelData(GUIGeneticManipulator.BUTTON_TYPE.getCustomModelData()); typ.setItemMeta(col); stacks[48] = typ; diff --git a/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusLibs.java b/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusLibs.java index 15c0d95c9..553662b48 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusLibs.java +++ b/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusLibs.java @@ -146,8 +146,9 @@ public void createDisguise() { WolfWatcher wolfWatcher = (WolfWatcher) livingWatcher; if (hasOption) { wolfWatcher.setTamed(true); - wolfWatcher.setCollarColor((DyeColor) choice); +// wolfWatcher.setCollarColor((DyeColor) choice); } +// wolfWatcher.setVariant((Wolf.Variant) choice); wolfWatcher.setBaby(isBaby); } case SLIME, MAGMA_CUBE -> { diff --git a/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusPageTwoInventory.java b/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusPageTwoInventory.java index 20a3f00a7..8922d5e30 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusPageTwoInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISLazarusPageTwoInventory.java @@ -16,9 +16,6 @@ */ package me.eccentric_nz.TARDIS.lazarus; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.custommodeldata.GUIChameleonPoliceBoxes; import me.eccentric_nz.TARDIS.custommodeldata.GUIGeneticManipulator; @@ -27,6 +24,10 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + /** * The Genetic Manipulation Device was invented by Professor Richard Lazarus. The machine would turn anyone inside * decades younger, but the process contained one side effect: genes that evolution rejected and left dormant would be @@ -47,6 +48,7 @@ class TARDISLazarusPageTwoInventory { disguises.add(Material.POLAR_BEAR_SPAWN_EGG); disguises.add(Material.SPIDER_SPAWN_EGG); disguises.add(Material.TRADER_LLAMA_SPAWN_EGG); + disguises.add(Material.WANDERING_TRADER_SPAWN_EGG); disguises.add(Material.WOLF_SPAWN_EGG); disguises.add(Material.ZOMBIFIED_PIGLIN_SPAWN_EGG); // hostile @@ -137,21 +139,21 @@ private ItemStack[] getItemStack() { ItemStack the = new ItemStack(Material.COMPARATOR, 1); ItemMeta master = the.getItemMeta(); master.setDisplayName(plugin.getLanguage().getString("BUTTON_MASTER")); - master.setLore(Collections.singletonList(plugin.getLanguage().getString("SET_OFF"))); + master.setLore(List.of(plugin.getLanguage().getString("SET_OFF"))); master.setCustomModelData(GUIGeneticManipulator.BUTTON_MASTER.getCustomModelData()); the.setItemMeta(master); stacks[45] = the; ItemStack adult = new ItemStack(Material.HOPPER, 1); ItemMeta baby = adult.getItemMeta(); baby.setDisplayName(plugin.getLanguage().getString("BUTTON_AGE")); - baby.setLore(Collections.singletonList("ADULT")); + baby.setLore(List.of("ADULT")); baby.setCustomModelData(GUIGeneticManipulator.BUTTON_AGE.getCustomModelData()); adult.setItemMeta(baby); stacks[47] = adult; ItemStack typ = new ItemStack(Material.CYAN_DYE, 1); ItemMeta col = typ.getItemMeta(); col.setDisplayName(plugin.getLanguage().getString("BUTTON_TYPE")); - col.setLore(Collections.singletonList("WHITE")); + col.setLore(List.of("WHITE")); col.setCustomModelData(GUIGeneticManipulator.BUTTON_TYPE.getCustomModelData()); typ.setItemMeta(col); stacks[48] = typ; diff --git a/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISWeepingAngelsMonstersInventory.java b/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISWeepingAngelsMonstersInventory.java index 0e704e445..7f6b8ba35 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISWeepingAngelsMonstersInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISWeepingAngelsMonstersInventory.java @@ -1,6 +1,5 @@ package me.eccentric_nz.TARDIS.lazarus; -import java.util.Collections; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.custommodeldata.GUIChameleonPoliceBoxes; import me.eccentric_nz.TARDIS.custommodeldata.GUIChameleonPresets; @@ -10,6 +9,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import java.util.List; + public class TARDISWeepingAngelsMonstersInventory { private final ItemStack[] monsters; @@ -29,14 +30,16 @@ private ItemStack[] getItemStack() { ItemStack[] stacks = new ItemStack[54]; int i = 0; for (Monster monster : Monster.values()) { - ItemStack mon = new ItemStack(monster.getMaterial(), 1); - ItemMeta ster = mon.getItemMeta(); - ster.setDisplayName(monster.toString()); - GUIGeneticManipulator gui = GUIGeneticManipulator.valueOf(monster.toString()); - ster.setCustomModelData(gui.getCustomModelData()); - mon.setItemMeta(ster); - stacks[i] = mon; - i++; + if (monster != Monster.FLYER) { + ItemStack mon = new ItemStack(monster.getMaterial(), 1); + ItemMeta ster = mon.getItemMeta(); + ster.setDisplayName(monster.toString()); + GUIGeneticManipulator gui = GUIGeneticManipulator.valueOf(monster.toString()); + ster.setCustomModelData(gui.getCustomModelData()); + mon.setItemMeta(ster); + stacks[i] = mon; + i++; + } } // page one ItemStack page1 = new ItemStack(Material.ARROW, 1); @@ -56,7 +59,7 @@ private ItemStack[] getItemStack() { ItemStack the = new ItemStack(Material.COMPARATOR, 1); ItemMeta master = the.getItemMeta(); master.setDisplayName(plugin.getLanguage().getString("BUTTON_MASTER")); - master.setLore(Collections.singletonList(plugin.getLanguage().getString("SET_OFF"))); + master.setLore(List.of(plugin.getLanguage().getString("SET_OFF"))); master.setCustomModelData(GUIGeneticManipulator.BUTTON_MASTER.getCustomModelData()); the.setItemMeta(master); stacks[45] = the; diff --git a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISDisguise.java b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISDisguise.java index d0fcd2bc5..2f7a31ea9 100644 --- a/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISDisguise.java +++ b/src/main/java/me/eccentric_nz/tardischunkgenerator/disguise/TARDISDisguise.java @@ -37,6 +37,7 @@ import net.minecraft.world.level.block.state.BlockState; import org.bukkit.World; import org.bukkit.craftbukkit.v1_20_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_20_R4.entity.CraftWolf; import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_20_R4.util.CraftNamespacedKey; import org.bukkit.entity.Axolotl; @@ -47,8 +48,6 @@ import java.lang.reflect.InvocationTargetException; import java.util.concurrent.ThreadLocalRandom; -; - public class TARDISDisguise { private final EntityType entityType; @@ -64,6 +63,11 @@ public static Entity createMobDisguise(TARDISDisguise disguise, World w) { String packagePath = "net.minecraft.world.entity."; boolean hasEntityStr = true; switch (disguise.getEntityType()) { + case ARMADILLO -> { + str = "Armadillo"; + packagePath += "animal.armadillo."; + hasEntityStr = false; + } case AXOLOTL -> { str = "Axolotl"; packagePath += "animal.axolotl."; @@ -146,7 +150,9 @@ public static Entity createMobDisguise(TARDISDisguise disguise, World w) { str = "PigZombie"; packagePath += "monster."; } - case BLAZE, CAVE_SPIDER, CREEPER, DROWNED, ENDERMAN, ENDERMITE, EVOKER, GHAST, GUARDIAN, MAGMA_CUBE, PHANTOM, PILLAGER, RAVAGER, SHULKER, SILVERFISH, SKELETON, SLIME, SPIDER, STRIDER, VEX, VINDICATOR, WITCH, ZOGLIN, ZOMBIE, ZOMBIE_VILLAGER -> { + case BLAZE, CAVE_SPIDER, CREEPER, DROWNED, ENDERMAN, ENDERMITE, EVOKER, GHAST, GUARDIAN, MAGMA_CUBE, + PHANTOM, PILLAGER, RAVAGER, SHULKER, SILVERFISH, SKELETON, SLIME, SPIDER, STRIDER, VEX, VINDICATOR, + WITCH, ZOGLIN, ZOMBIE, ZOMBIE_VILLAGER -> { str = capitalise(disguise.getEntityType().toString()); packagePath += "monster."; } @@ -191,18 +197,9 @@ public static Entity createMobDisguise(TARDISDisguise disguise, World w) { for (Object o : disguise.getOptions()) { if (o instanceof org.bukkit.DyeColor) { // colour a sheep / wolf collar - switch (disguise.getEntityType()) { - case SHEEP -> { - Sheep sheep = (Sheep) entity; - sheep.setColor(DyeColor.valueOf(o.toString())); - } - case WOLF -> { - Wolf wolf = (Wolf) entity; - wolf.setTame(true, false); - wolf.setCollarColor(DyeColor.valueOf(o.toString())); - } - default -> { - } + if (disguise.getEntityType() == EntityType.SHEEP) { + Sheep sheep = (Sheep) entity; + sheep.setColor(DyeColor.valueOf(o.toString())); } } if (disguise.getEntityType().equals(EntityType.AXOLOTL) && o instanceof Axolotl.Variant av) { @@ -242,6 +239,10 @@ public static Entity createMobDisguise(TARDISDisguise disguise, World w) { MushroomCow cow = (MushroomCow) entity; cow.setVariant(mc.getNmsType()); } + if (disguise.getEntityType().equals(EntityType.WOLF) && o instanceof org.bukkit.entity.Wolf.Variant wv) { + Wolf wolf = (Wolf) entity; + wolf.setVariant(CraftWolf.CraftVariant.bukkitToMinecraftHolder(wv)); + } if (disguise.getEntityType().equals(EntityType.CAT) && o instanceof org.bukkit.entity.Cat.Type c) { Cat cat = (Cat) entity; cat.setVariant(Holder.direct(BuiltInRegistries.CAT_VARIANT.byId(c.ordinal()))); diff --git a/todo.md b/todo.md index dd0aa10a5..011157e48 100644 --- a/todo.md +++ b/todo.md @@ -14,9 +14,7 @@ * Change order of console panels so handbrake is near door * Make sneak-clicking a control show the label + alter the position based on the angle of the panel the control is on 4. Update old light level controls -5. Add Armadillo -6. Wolf armour and variants -7. ? +5. ? ## Next version `5.7.0` From 627685c5deae3be8082ea4cb09010d078038285f Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 29 Apr 2024 09:34:30 +1200 Subject: [PATCH 61/96] Change order of console panels so handbrake is near door --- .../TARDIS/console/ConsoleBuilder.java | 2 +- .../TARDIS/console/ConsoleDestroyer.java | 2 +- .../TARDIS/console/ConsoleInteraction.java | 50 +++++++++---------- .../interaction/HandbrakeInteraction.java | 2 +- .../interaction/ScreenInteraction.java | 5 +- .../TARDIS/sonic/TARDISSonicDock.java | 4 +- todo.md | 7 ++- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index ed2dbedb9..266ca876e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -116,7 +116,7 @@ private UUID spawnControl(ConsoleInteraction interaction, Location location, flo if (interaction == ConsoleInteraction.SCREEN_LEFT && right != null) { return right; } - if ((interaction == ConsoleInteraction.X||interaction == ConsoleInteraction.Z||interaction == ConsoleInteraction.MULTIPLIER) && wxyz != null) { + if ((interaction == ConsoleInteraction.X || interaction == ConsoleInteraction.Z || interaction == ConsoleInteraction.MULTIPLIER) && wxyz != null) { return wxyz; } Material material = interaction.getMaterial(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java index 52955ba33..222844c1e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java @@ -93,7 +93,7 @@ public ItemStack returnStack(String uuids, int id) { private void removeTextDisplays(Location centre) { Location spawn = centre.clone().add(0.5f, 0, 0.5f); - for (Entity e : spawn.getWorld().getNearbyEntities(spawn, 3.5, 2, 3.5, (t) -> t.getType() == EntityType.TEXT_DISPLAY)) { + for (Entity e : spawn.getWorld().getNearbyEntities(spawn, 4, 3, 4, (t) -> t.getType() == EntityType.TEXT_DISPLAY)) { if (e instanceof TextDisplay) { e.remove(); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java index 47b921c0b..57d0ad6f8 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java @@ -6,39 +6,39 @@ public enum ConsoleInteraction { // section zero - HANDBRAKE("Time Rotor Handbrake", new Vector(0.0d, 1d, 2.25d), 0.5f, 0.4f, 1, 0.0f, Material.LEVER, 5002), - THROTTLE("Flight Speed", new Vector(0.9d, 1.0d, 2.375d), 0.5f, 0.33f, 4, 0.0f, Material.REPEATER, 1004), - RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.575d, 1.0d, 1.75d), 0.5f, 0.65f, 1, 0.0f, Material.LEVER, 6001), + SONIC_DOCK("Sonic Screwdriver Dock", new Vector(0.5d, 1d, 1.625d), 0.5f, 0.65f, 0, 0.0f, Material.FLOWER_POT, 2000), + DIRECTION("Exterior Directional Control", new Vector(0.75d, 1d, 2.25d), 0.625f, 0.5f, 0, 0.0f, Material.RAIL, 10000), // section one - WORLD("Environment Selector", new Vector(-0.525d, 1.0d, 0.95d), 0.15f, 0.65f, 1, 60.0f, Material.BAMBOO_BUTTON, 1009), - MULTIPLIER("Coordinate Increment Modifier", new Vector(-0.4d, 1.0d, 1.2d), 0.15f, 0.65f, 1, 60.0f, Material.BAMBOO_BUTTON, 1009), - X("X Distance", new Vector(-0.75d, 1.0d, 1.1d), 0.15f, 0.4f, 1, 60.0f, Material.BAMBOO_BUTTON, 1009), - Z("Z Distance", new Vector(-0.6d, 1.0d, 1.3d), 0.15f, 0.4f, 1, 60.0f, Material.BAMBOO_BUTTON, 1009), - HELMIC_REGULATOR("Dimension Selector", new Vector(-0.85d, 1d, 1.8d), 0.5f, 0.6f, 0, 60.0f, Material.REPEATER, 2000), + LIGHT_SWITCH("Interior Light Switch", new Vector(-1.45d, 1d, 0.9d), 0.25f, 0.33f, 0, 60.0f, Material.BAMBOO_BUTTON, 1004), + INTERIOR_LIGHT_LEVEL_SWITCH("Interior Light Level", new Vector(-0.85d, 1d, 1.05d), 0.25f, 0.5f, 0, 60.0f, Material.LEVER, 8000), + EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Lamp Level", new Vector(-0.65d, 1d, 1.45d), 0.25f, 0.5f, 0, 60.0f, Material.LEVER, 7000), + DOOR_TOGGLE("Toggle Wool Switch", new Vector(-0.775d, 1d, 2.0d), 0.25f, 0.33f, 0, 60.0f, Material.BAMBOO_BUTTON, 1005), // section two - RANDOMISER("Random Location Finder", new Vector(-0.85d, 1d, -0.8125d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1001), - WAYPOINT_SELECTOR("Saves", new Vector(-1.1d, 1d, -0.4d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1002), - FAST_RETURN("Back Button", new Vector(-1.35d, 1d, 0d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1003), - TELEPATHIC_CIRCUIT("Telepathic Circuit", new Vector(-0.55d, 1d, -0.15d), 0.5f, 0.65f, 0, 120.0f, Material.DAYLIGHT_DETECTOR, 1000), + SCREEN_RIGHT("Coordinates Display", new Vector(-0.85d, 1d, 0.1d), 0.5f, 1.1f, 0, 120.0f, Material.MAP, 1000), + SCREEN_LEFT("Information Display", new Vector(-0.6d, 1d, -0.4d), 0.5f, 1.1f, 0, 120.0f, Material.MAP, 1000), + SCANNER("Exterior Environment Scanner", new Vector(-0.875d, 1d, -0.875d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1008), + ARTRON("Artron Energy Button", new Vector(-1.15d, 1d, -0.4d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1006), + REBUILD("Chameleon Circuit Re-initialiser", new Vector(-1.45d, 1d, 0.05d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1007), // section three - SONIC_DOCK("Sonic Screwdriver Dock", new Vector(0.45d, 1d, -0.65d), 0.5f, 0.65f, 0, 180.0f, Material.FLOWER_POT, 2000), - DIRECTION("Exterior Directional Control", new Vector(0.125d, 1d, -1.2d), 0.625f, 0.5f, 0, 180.0f, Material.RAIL, 10000), + HANDBRAKE("Time Rotor Handbrake", new Vector(0.95d, 1d, -1.2d), 0.5f, 0.4f, 1, 180.0f, Material.LEVER, 5002), + THROTTLE("Flight Speed", new Vector(-0.0d, 1.0d, -1.35d), 0.5f, 0.33f, 4, 180.0f, Material.REPEATER, 1004), + RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.45d, 1.0d, -0.75d), 0.5f, 0.65f, 1, 180.0f, Material.LEVER, 6001), // section four - LIGHT_SWITCH("Interior Light Switch", new Vector(2.475d, 1d, 0.1d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1004), - INTERIOR_LIGHT_LEVEL_SWITCH("Interior Light Level", new Vector(1.8d, 1d, 0.0d), 0.25f, 0.5f, 0, 240.0f, Material.LEVER, 8000), - EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Lamp Level", new Vector(1.5d, 1d, -0.3d), 0.25f, 0.5f, 0, 240.0f, Material.LEVER, 7000), - DOOR_TOGGLE("Toggle Wool Switch", new Vector(1.825d, 1d, -1.0d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1005), - - // section five - SCREEN_RIGHT("Coordinates Display", new Vector(1.825d, 1d, 0.95d), 0.5f, 1.1f, 0, 300.0f, Material.MAP, 1000), - SCREEN_LEFT("Information Display", new Vector(1.525d, 1d, 1.45d), 0.5f, 1.1f, 0, 300.0f, Material.MAP, 1000), - SCANNER("Exterior Environment Scanner", new Vector(1.825d, 1d, 1.95d), 0.25f, 0.33f, 0, 300.0f, Material.BAMBOO_BUTTON, 1008), - ARTRON("Artron Energy Button", new Vector(2.125d, 1d, 1.475d), 0.25f, 0.33f, 0, 300.0f, Material.BAMBOO_BUTTON, 1006), - REBUILD("Chameleon Circuit Re-initialiser", new Vector(2.4d, 1d, 1.025d), 0.25f, 0.33f, 0, 300.0f, Material.BAMBOO_BUTTON, 1007); + RANDOMISER("Random Location Finder", new Vector(2.35d, 1d, 0.025d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1001), + WAYPOINT_SELECTOR("Saves", new Vector(2.1d, 1d, -0.45d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1002), + FAST_RETURN("Back Button", new Vector(1.8d, 1d, -0.9d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1003), + TELEPATHIC_CIRCUIT("Telepathic Circuit", new Vector(1.575d, 1d, -0.05d), 0.5f, 0.65f, 0, 240.0f, Material.DAYLIGHT_DETECTOR, 1000), + + // section five HELMIC_REGULATOR x=-1.134, z=-1.636 + WORLD("Environment Selector", new Vector(1.425d, 1.0d, 1.15d), 0.15f, 0.65f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), + MULTIPLIER("Coordinate Increment Modifier", new Vector(1.55d, 1.0d, 0.925d), 0.15f, 0.65f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), + X("X Distance", new Vector(1.625d, 1.0d, 1.275d), 0.15f, 0.4f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), + Z("Z Distance", new Vector(1.75d, 1.0d, 1.05), 0.15f, 0.4f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), + HELMIC_REGULATOR("Dimension Selector", new Vector(2.25d, 1d, 1.075d), 0.5f, 0.6f, 0, 300.0f, Material.REPEATER, 2000); private final String alternateName; private final Vector relativePosition; diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java index bf1d174a2..85dece2f7 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java @@ -114,7 +114,7 @@ public void process(int id, int state, Player player, Interaction interaction) { return; } // check the state of the Relativity Differentiator - if (check.isFlightModeExterior(uuid.toString()) && TARDISPermission.hasPermission(player, "tardis.fly") && preset.usesArmourStand() && !player.isSneaking()) { + if (check.isFlightModeExterior(uuid.toString()) && TARDISPermission.hasPermission(player, "tardis.fly") && preset.usesArmourStand()) { ResultSetCurrentFromId rsc = new ResultSetCurrentFromId(plugin, id); if (!rsc.resultSet()) { plugin.debug("No current location"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java index d6c7091f9..148925576 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java @@ -28,7 +28,7 @@ public void display(int id, Interaction interaction, boolean coords, Player play // get the text display TextDisplay display = getTextDisplay(interaction.getLocation(), coords); if (display != null) { - display.setRotation(Location.normalizeYaw(300), -10f); + display.setRotation(Location.normalizeYaw(120), -10f); new ControlMonitor(plugin).update(id, display.getUniqueId(), coords); } } else { @@ -80,7 +80,8 @@ private TextDisplay getTextDisplay(Location location, boolean coords) { } if (textDisplay == null) { Location adjusted = location.clone(); - Vector vector = coords ? new Vector(0.0d, 0.5d, 0.35d) : new Vector(0.32d, 0.5d, -0.225d); + // from middle of interaction! + Vector vector = coords ? new Vector(0d, 0.5d, -0.35d) : new Vector(-0.2d, 0.5d, 0.175d); adjusted.add(vector); textDisplay = (TextDisplay) location.getWorld().spawnEntity(adjusted, EntityType.TEXT_DISPLAY); textDisplay.getPersistentDataContainer().set(plugin.getInteractionUuidKey(), PersistentDataType.BOOLEAN, true); diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java index 0315629a7..af34d656e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicDock.java @@ -49,8 +49,8 @@ public void dock(int id, Interaction interaction, Player player, ItemStack sonic if (TARDISDisplayItemUtils.getSonic(interaction) != null) { return; } - ItemDisplay display = doDocking(sonic, interaction.getLocation(), new Vector(0.05d, 0.75d, -0.05d), player, id); - display.setRotation(0.0f, -15.0f); + ItemDisplay display = doDocking(sonic, interaction.getLocation(), new Vector(0, 0.75d, 0.1d), player, id); + display.setRotation(0.0f, 15.0f); // start charging if (plugin.getConfig().getBoolean("sonic.charge") || plugin.getDifficulty() == Difficulty.HARD) { long delay = plugin.getConfig().getLong("sonic.charge_level") / plugin.getConfig().getLong("sonic.charge_interval"); diff --git a/todo.md b/todo.md index 011157e48..d4f7ab96d 100644 --- a/todo.md +++ b/todo.md @@ -8,12 +8,11 @@ [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) * New interior with console * Malfunction & manual flight classes - * Regular handbrake needs to check console filght mode + * Regular handbrake needs to check console flight mode * Remove sonic screwdriver when breaking console * Alter console side model inner edge / make new time rotor for console - * Change order of console panels so handbrake is near door - * Make sneak-clicking a control show the label + alter the position based on the angle of the panel the control is on -4. Update old light level controls + * Alter the position of the control label based on the angle of the panel the control is on +4. Update old light level controls, and light switch shoulf return to correct level 5. ? ## Next version `5.7.0` From 6013183e61c22d22b1ecf2d732c7d94735bcb6e5 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 29 Apr 2024 09:35:12 +1200 Subject: [PATCH 62/96] If sneak-clicking a control interaction - show its name --- .../TARDIS/console/ConsoleInteractionListener.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index 62955c8fe..57ef8aed2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -27,8 +27,12 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { ResultSetInteraction rsi = new ResultSetInteraction(plugin, uuid); if (rsi.resultSet()) { ConsoleInteraction ci = rsi.getControl(); - int id = rsi.getTardisId(); Player player = event.getPlayer(); + if (player.isSneaking() && ci != ConsoleInteraction.SCREEN_LEFT && ci != ConsoleInteraction.SCREEN_RIGHT&& ci != ConsoleInteraction.ARTRON) { + plugin.getMessenger().announceRepeater(player, rsi.getControl().getAlternateName()); + return; + } + int id = rsi.getTardisId(); int state = rsi.getState(); switch (ci) { // section zero From bf0b16dc7906108a3e9f8783803ff1ab926930c8 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 29 Apr 2024 09:35:33 +1200 Subject: [PATCH 63/96] Require 1.20.5 --- src/main/java/me/eccentric_nz/TARDIS/TARDIS.java | 3 +-- .../me/eccentric_nz/TARDIS/utility/TARDISUpdateChecker.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java b/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java index c4054f671..35131b789 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java +++ b/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java @@ -140,7 +140,7 @@ public class TARDIS extends JavaPlugin { private final HashMap versions = new HashMap<>(); private final String versionRegex = "(\\d+[.])+\\d+"; private final Pattern versionPattern = Pattern.compile(versionRegex); - private final String serverStr = "1.20.4"; + private final String serverStr = "1.20.5"; private TARDISChatGUI jsonKeeper; private TARDISUpdateChatGUI updateChatGUI; // public TARDISFurnaceRecipe fornacis; @@ -1985,5 +1985,4 @@ private void startRecorderTask() { public String getServerStr() { return serverStr; } - } diff --git a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISUpdateChecker.java b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISUpdateChecker.java index 2410529e4..b72c3c9f5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISUpdateChecker.java +++ b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISUpdateChecker.java @@ -161,7 +161,7 @@ private String getLastestServerVersion() { org.spigotmc spigot - 1.20.4-R0.1-SNAPSHOT + 1.20.5-R0.1-SNAPSHOT */ NodeList list = doc.getElementsByTagName("dependencies"); Node root = list.item(0); // there's only one node From c2ead6eebc0686f23f851a90d658aa4e724a4c8e Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 29 Apr 2024 10:06:37 +1200 Subject: [PATCH 64/96] #840 Fix messaging error when making a construct --- pom.xml | 16 ++++---- .../TARDISChameleonConstructorListener.java | 41 +++++++++---------- .../construct/TARDISConstructColumn.java | 4 +- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/pom.xml b/pom.xml index f8e4c33b9..e50eefe56 100644 --- a/pom.xml +++ b/pom.xml @@ -246,17 +246,10 @@ - - org.spigotmc - spigot - 1.20.5-R0.1-SNAPSHOT - remapped-mojang - provided - io.papermc.paper paper-api - 1.20.4-R0.1-SNAPSHOT + 1.20.5-R0.1-SNAPSHOT provided @@ -277,6 +270,13 @@ + + org.spigotmc + spigot + 1.20.5-R0.1-SNAPSHOT + remapped-mojang + provided + io.papermc paperlib diff --git a/src/main/java/me/eccentric_nz/TARDIS/chameleon/construct/TARDISChameleonConstructorListener.java b/src/main/java/me/eccentric_nz/TARDIS/chameleon/construct/TARDISChameleonConstructorListener.java index 935f55569..5fcdf2b9f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/chameleon/construct/TARDISChameleonConstructorListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/chameleon/construct/TARDISChameleonConstructorListener.java @@ -239,25 +239,26 @@ public void onChameleonConstructorClick(InventoryClickEvent event) { String jsonBlue = gson.toJson(blue); String jsonStain = gson.toJson(stain); String jsonGlass = gson.toJson(glass); - // save chameleon construct - HashMap wherec = new HashMap<>(); - wherec.put("tardis_id", id); - ResultSetChameleon rsc = new ResultSetChameleon(plugin, wherec); - HashMap set = new HashMap<>(); - set.put("blueprintData", jsonBlue); - set.put("stainData", jsonStain); - set.put("glassData", jsonGlass); - if (rsc.resultSet()) { - // update - HashMap whereu = new HashMap<>(); - whereu.put("tardis_id", id); - plugin.getQueryFactory().doUpdate("chameleon", set, whereu); - } else { - // insert - set.put("tardis_id", id); - plugin.getQueryFactory().doInsert("chameleon", set); - } - new ConstructBuilder(plugin).build(tardis.getPreset().toString(), id, player); + // set other shells as inactive + HashMap seti = new HashMap<>(); + seti.put("active", 0); + HashMap wherei = new HashMap<>(); + wherei.put("tardis_id", id); + plugin.getQueryFactory().doSyncUpdate("chameleon", seti, wherei); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { + // save chameleon construct + HashMap wherec = new HashMap<>(); + ResultSetChameleon rsc = new ResultSetChameleon(plugin, wherec); + HashMap setc = new HashMap<>(); + setc.put("tardis_id", id); + setc.put("blueprintData", jsonBlue); + setc.put("stainData", jsonStain); + setc.put("glassData", jsonGlass); + setc.put("active", 1); + // always insert as you can now have multiple shell constructs + plugin.getQueryFactory().doSyncInsert("chameleon", setc); + new ConstructBuilder(plugin).build(tardis.getPreset().toString(), id, player); + }, 5L); } case 26 -> { // set lamp @@ -306,6 +307,4 @@ private void nextDoor(UUID uuid, InventoryView view) { view.setItem(52, new ItemStack(doors.get(d))); currentDoor.put(uuid, d); } - - } diff --git a/src/main/java/me/eccentric_nz/TARDIS/chameleon/construct/TARDISConstructColumn.java b/src/main/java/me/eccentric_nz/TARDIS/chameleon/construct/TARDISConstructColumn.java index af9deb724..87fd9f4f4 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/chameleon/construct/TARDISConstructColumn.java +++ b/src/main/java/me/eccentric_nz/TARDIS/chameleon/construct/TARDISConstructColumn.java @@ -18,13 +18,14 @@ import com.google.gson.JsonArray; import com.google.gson.JsonParser; -import java.util.HashMap; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.chameleon.TARDISChameleonPreset; import me.eccentric_nz.TARDIS.chameleon.utils.TARDISChameleonColumn; import me.eccentric_nz.TARDIS.database.resultset.ResultSetChameleon; import me.eccentric_nz.TARDIS.enumeration.COMPASS; +import java.util.HashMap; + /** * @author eccentric_nz */ @@ -46,6 +47,7 @@ public TARDISChameleonColumn getColumn() { // get the json data HashMap where = new HashMap<>(); where.put("tardis_id", id); + where.put("active", 1); ResultSetChameleon rs = new ResultSetChameleon(plugin, where); if (rs.resultSet()) { // convert to String[][] array From 8c1c673e9cadaca4a3014ed6147fb4ada8e623d0 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 29 Apr 2024 16:37:40 +1200 Subject: [PATCH 65/96] Paper has updated to 1.20.5 --- pom.xml | 5 ++ .../chatGUI/TARDISUpdateChatGUIAdventure.java | 13 +-- .../TARDIS/messaging/AdventureMessage.java | 84 +++++++++---------- 3 files changed, 54 insertions(+), 48 deletions(-) diff --git a/pom.xml b/pom.xml index e50eefe56..a03d918b6 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,11 @@ http://eccentricdevotion.github.com/TARDIS/ + + + sonatype-oss-snapshots1 + https://s01.oss.sonatype.org/content/repositories/snapshots/ + jitpack.io diff --git a/src/main/java/me/eccentric_nz/TARDIS/chatGUI/TARDISUpdateChatGUIAdventure.java b/src/main/java/me/eccentric_nz/TARDIS/chatGUI/TARDISUpdateChatGUIAdventure.java index c680e7465..7979966ea 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/chatGUI/TARDISUpdateChatGUIAdventure.java +++ b/src/main/java/me/eccentric_nz/TARDIS/chatGUI/TARDISUpdateChatGUIAdventure.java @@ -18,6 +18,7 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.enumeration.TardisModule; +import net.kyori.adventure.text.TextComponent; import org.bukkit.entity.Player; public class TARDISUpdateChatGUIAdventure implements TARDISUpdateChatGUI { @@ -33,42 +34,42 @@ public boolean showInterface(Player player, String[] args) { if (args.length == 1) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_SECTION"); player.sendMessage("------"); -// plugin.getJsonKeeper().getSections().forEach((s) -> player.sendMessage((TextComponent) s)); + plugin.getJsonKeeper().getSections().forEach((s) -> player.sendMessage((TextComponent) s)); player.sendMessage("------"); return true; } if (args[1].equalsIgnoreCase("controls")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_CONTROL"); player.sendMessage("------"); -// plugin.getJsonKeeper().getControls().forEach((c) -> player.sendMessage((TextComponent) c)); + plugin.getJsonKeeper().getControls().forEach((c) -> player.sendMessage((TextComponent) c)); player.sendMessage("------"); return true; } if (args[1].equalsIgnoreCase("interfaces")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_INTERFACE"); player.sendMessage("------"); -// plugin.getJsonKeeper().getInterfaces().forEach((i) -> player.sendMessage((TextComponent) i)); + plugin.getJsonKeeper().getInterfaces().forEach((i) -> player.sendMessage((TextComponent) i)); player.sendMessage("------"); return true; } if (args[1].equalsIgnoreCase("locations")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_LOCATION"); player.sendMessage("------"); -// plugin.getJsonKeeper().getLocations().forEach((l) -> player.sendMessage((TextComponent) l)); + plugin.getJsonKeeper().getLocations().forEach((l) -> player.sendMessage((TextComponent) l)); player.sendMessage("------"); return true; } if (args[1].equalsIgnoreCase("sensors")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_SENSOR"); player.sendMessage("------"); -// plugin.getJsonKeeper().getSensors().forEach((s) -> player.sendMessage((TextComponent) s)); + plugin.getJsonKeeper().getSensors().forEach((s) -> player.sendMessage((TextComponent) s)); player.sendMessage("------"); return true; } if (args[1].equalsIgnoreCase("others")) { plugin.getMessenger().send(player, TardisModule.TARDIS, "UPDATE_OTHER"); player.sendMessage("------"); -// plugin.getJsonKeeper().getOthers().forEach((o) -> player.sendMessage((TextComponent) o)); + plugin.getJsonKeeper().getOthers().forEach((o) -> player.sendMessage((TextComponent) o)); player.sendMessage("------"); return true; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/messaging/AdventureMessage.java b/src/main/java/me/eccentric_nz/TARDIS/messaging/AdventureMessage.java index 025472f94..b1897c46b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/messaging/AdventureMessage.java +++ b/src/main/java/me/eccentric_nz/TARDIS/messaging/AdventureMessage.java @@ -45,24 +45,24 @@ public class AdventureMessage implements TARDISMessage { @Override public void sendJenkinsUpdateReady(CommandSender cs, int current, int latest) { -// cs.sendMessage(AdventureComponents.getJenkinsUpdateReady(current, latest)); + cs.sendMessage(AdventureComponents.getJenkinsUpdateReady(current, latest)); } @Override public void sendUpdateCommand(CommandSender cs) { -// cs.sendMessage(AdventureComponents.getUpdateCommand()); + cs.sendMessage(AdventureComponents.getUpdateCommand()); } @Override public void sendBuildsBehind(CommandSender cs, int behind) { -// cs.sendMessage(AdventureComponents.getBuildsBehind(behind)); + cs.sendMessage(AdventureComponents.getBuildsBehind(behind)); } @Override public void message(CommandSender cs, TardisModule module, String message) { if (cs != null) { TextComponent textComponent = AdventureComponents.getModule(module).append(Component.text(message, NamedTextColor.WHITE)); -// cs.sendMessage(textComponent); + cs.sendMessage(textComponent); } } @@ -119,210 +119,210 @@ public void sendJoined(Player player, String key, String sub, boolean handbrake) String local = TARDIS.plugin.getLanguage().getString(key); String other = (handbrake) ? TARDIS.plugin.getLanguage().getString("HANDBRAKE_RELEASE") : TARDIS.plugin.getLanguage().getString("LEAVING_VORTEX"); TextComponent actionBar = AdventureComponents.getModule(TardisModule.TARDIS).append(Component.text(String.format(local, sub) + " " + other, NamedTextColor.WHITE)); -// player.sendActionBar(actionBar); + player.sendActionBar(actionBar); } @Override public void broadcast(TardisModule module, String message) { -// message(TARDIS.plugin.getServer(), module, message); + message(TARDIS.plugin.getServer(), module, message); } @Override public void sendWithColour(CommandSender cs, TardisModule module, String message, String hex) { TextColor colour = TextColor.fromHexString(hex); TextComponent textComponent = AdventureComponents.getModule(module).append(Component.text(message, colour)); -// cs.sendMessage(textComponent); + cs.sendMessage(textComponent); } @Override public void messageWithColour(CommandSender cs, String message, String hex) { TextColor colour = TextColor.fromHexString(hex); TextComponent textComponent = Component.text(message, colour); -// cs.sendMessage(textComponent); + cs.sendMessage(textComponent); } @Override public void sendRequestComehereAccept(CommandSender cs, String key, String command) { -// cs.sendMessage(AdventureComponents.getRequestComehereAccept(key, command)); + cs.sendMessage(AdventureComponents.getRequestComehereAccept(key, command)); } @Override public void sendAbandoned(CommandSender cs, int i, String owner, String location, int id) { -// cs.sendMessage(AdventureComponents.getAbandoned(i, owner, location, id)); + cs.sendMessage(AdventureComponents.getAbandoned(i, owner, location, id)); } @Override public void sendTransmat(CommandSender cs, Transmat t) { -// cs.sendMessage(AdventureComponents.getTransmat(t)); + cs.sendMessage(AdventureComponents.getTransmat(t)); } @Override public void sendTARDISForList(CommandSender cs, Tardis t, String world, int x, int y, int z) { -// cs.sendMessage(AdventureComponents.getTARDISForList(t, world, x, y, z)); + cs.sendMessage(AdventureComponents.getTARDISForList(t, world, x, y, z)); } @Override public void sendExterminate(CommandSender cs, TARDIS plugin) { -// cs.sendMessage(AdventureComponents.getExterminate(plugin)); + cs.sendMessage(AdventureComponents.getExterminate(plugin)); } @Override public void sendRescue(CommandSender cs, TARDIS plugin) { -// cs.sendMessage(AdventureComponents.getRescue(plugin)); + cs.sendMessage(AdventureComponents.getRescue(plugin)); } @Override public void sendSuggestCommand(CommandSender cs, String item, String hover, String colour) { -// cs.sendMessage(AdventureComponents.getSuggestCommand(item, hover, colour)); + cs.sendMessage(AdventureComponents.getSuggestCommand(item, hover, colour)); } @Override public void sendRunCommand(CommandSender cs, String item, String hover, String colour) { -// cs.sendMessage(AdventureComponents.getRunCommand(item, hover, colour)); + cs.sendMessage(AdventureComponents.getRunCommand(item, hover, colour)); } @Override public void sendShowMore(CommandSender cs, String command) { -// cs.sendMessage(AdventureComponents.getShowMore(command)); + cs.sendMessage(AdventureComponents.getShowMore(command)); } @Override public void sendRecharger(CommandSender cs, String recharger, String world, String x, String y, String z, boolean hasPerm) { -// cs.sendMessage(AdventureComponents.getRecharger(recharger, world, x, y, z, hasPerm)); + cs.sendMessage(AdventureComponents.getRecharger(recharger, world, x, y, z, hasPerm)); } @Override public void sendHome(CommandSender cs, TARDIS plugin, String world, int x, int y, int z) { -// cs.sendMessage(AdventureComponents.getHome(plugin, world, x, y, z)); + cs.sendMessage(AdventureComponents.getHome(plugin, world, x, y, z)); } @Override public void sendSave(CommandSender cs, HashMap map, String world) { -// cs.sendMessage(AdventureComponents.getSave(map, world)); + cs.sendMessage(AdventureComponents.getSave(map, world)); } @Override public void sendArea(CommandSender cs, Area a, int n, boolean hasPerm) { -// cs.sendMessage(AdventureComponents.getArea(a, n, hasPerm)); + cs.sendMessage(AdventureComponents.getArea(a, n, hasPerm)); } @Override public void sendRoom(CommandSender cs, String room, boolean hasPerm) { -// cs.sendMessage(AdventureComponents.getRoom(room, hasPerm)); + cs.sendMessage(AdventureComponents.getRoom(room, hasPerm)); } @Override public void sendRoomGallery(CommandSender cs) { -// cs.sendMessage(AdventureComponents.getRoomGallery()); + cs.sendMessage(AdventureComponents.getRoomGallery()); } @Override public void sendEyebrows(CommandSender cs) { -// cs.sendMessage(AdventureComponents.getEyebrows()); + cs.sendMessage(AdventureComponents.getEyebrows()); } @Override public void sendSign(CommandSender cs) { -// cs.sendMessage(AdventureComponents.getSign()); + cs.sendMessage(AdventureComponents.getSign()); } @Override public void sendInfo(CommandSender cs, String first, String value, String split) { -// cs.sendMessage(AdventureComponents.getUpdate(first, value, split)); + cs.sendMessage(AdventureComponents.getUpdate(first, value, split)); } @Override public void sendHADS(CommandSender cs, TARDIS plugin) { -// cs.sendMessage(AdventureComponents.getHADS(plugin)); + cs.sendMessage(AdventureComponents.getHADS(plugin)); } @Override public void sendColouredCommand(CommandSender cs, String which, String command, TARDIS plugin) { -// cs.sendMessage(AdventureComponents.getColouredCommand(which, command, plugin)); + cs.sendMessage(AdventureComponents.getColouredCommand(which, command, plugin)); } @Override public void sendInsertedColour(CommandSender cs, String local, String which, TARDIS plugin) { -// cs.sendMessage(AdventureComponents.getInsertColour(local, which, plugin)); + cs.sendMessage(AdventureComponents.getInsertColour(local, which, plugin)); } @Override public void sendWithColours(CommandSender cs, String first, String colour, String last, String hue) { -// cs.sendMessage(AdventureComponents.getWithColours(first, colour, last, hue)); + cs.sendMessage(AdventureComponents.getWithColours(first, colour, last, hue)); } @Override public void sendWithColours(CommandSender cs, TardisModule module, String first, String colour, String last, String hue) { -// cs.sendMessage(AdventureComponents.getWithColours(module, first, colour, last, hue)); + cs.sendMessage(AdventureComponents.getWithColours(module, first, colour, last, hue)); } @Override public void sendCommand(CommandSender cs, String root, String command) { -// cs.sendMessage(AdventureComponents.getCommand(root, command)); + cs.sendMessage(AdventureComponents.getCommand(root, command)); } @Override public void sendHeadsUpDisplay(Player player, TARDIS plugin) { TextComponent actionBar = LegacyComponentSerializer.legacyAmpersand().deserialize(plugin.getUtils().actionBarFormat(player)); -// player.sendActionBar(actionBar); + player.sendActionBar(actionBar); } @Override public void sendWikiLink(Player player, WikiLink wikiLink) { -// player.sendMessage(AdventureComponents.getWikiLink(wikiLink)); + player.sendMessage(AdventureComponents.getWikiLink(wikiLink)); } @Override public void sendStartBanner(CommandSender cs) { for (Component c : AdventureComponents.getStartupBanner()) { -// cs.sendMessage(c); + cs.sendMessage(c); } } @Override public void sendProtected(CommandSender cs, String xyz, String location, int id) { -// cs.sendMessage(AdventureComponents.getRemoveProtected(xyz, location, id)); + cs.sendMessage(AdventureComponents.getRemoveProtected(xyz, location, id)); } @Override public void announceRepeater(Player player, String value) { Title.Times times = Title.Times.times(Duration.ofMillis(250), Duration.ofMillis(1000), Duration.ofMillis(250)); Title title = Title.title(Component.empty(), Component.text(value), times); -// player.showTitle(title); + player.showTitle(title); } @Override public void sendStatus(Player player, String key) { String local = TARDIS.plugin.getLanguage().getString(key); TextComponent actionBar = AdventureComponents.getModule(TardisModule.TARDIS).append(Component.text(local, NamedTextColor.WHITE)); -// player.sendActionBar(actionBar); + player.sendActionBar(actionBar); } @Override public void sendStatus(Player player, String key, Object... subs) { String local = String.format(TARDIS.plugin.getLanguage().getString(key), subs); TextComponent actionBar = AdventureComponents.getModule(TardisModule.TARDIS).append(Component.text(local, NamedTextColor.WHITE)); -// player.sendActionBar(actionBar); + player.sendActionBar(actionBar); } @Override public void sendArtron(Player player, int id, int used) { ArtronIndicatorData data = new TARDISArtronIndicator(TARDIS.plugin).getLevels(player, id, used); TextComponent actionBar = AdventureComponents.getArtronIndicator(data); -// player.sendActionBar(actionBar); + player.sendActionBar(actionBar); } @Override public void sendFind(Player player, String world, int x, int y, int z) { String local = TARDIS.plugin.getLanguage().getString("TARDIS_FIND"); -// player.sendMessage(AdventureComponents.getFind(local.substring(0, local.length() - 2), world, x, y, z)); + player.sendMessage(AdventureComponents.getFind(local.substring(0, local.length() - 2), world, x, y, z)); } public void sendJoinedStatus(Player player, String key, String otherKey) { String local = TARDIS.plugin.getLanguage().getString(key); String other = TARDIS.plugin.getLanguage().getString(otherKey); TextComponent actionBar = AdventureComponents.getModule(TardisModule.TARDIS).append(Component.text(local + " " + other, NamedTextColor.WHITE)); -// player.sendActionBar(actionBar); + player.sendActionBar(actionBar); } public void message(Audience audience, TardisModule module, String message) { From 8e81ac715fc2e6f9ab3fcac9a301bfe3536dc40d Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 29 Apr 2024 16:55:55 +1200 Subject: [PATCH 66/96] Manual flight for the console --- .../TARDIS/TARDISTrackerInstanceKeeper.java | 8 +- .../TARDIS/console/ConsoleInteraction.java | 11 ++- .../console/ConsoleInteractionListener.java | 26 +++++-- .../interaction/ArtronInteraction.java | 3 + .../interaction/DirectionInteraction.java | 3 + .../interaction/DoorToggleInteraction.java | 3 + .../interaction/FastReturnInteraction.java | 3 + .../interaction/FlightModeInteraction.java | 3 + .../interaction/HandbrakeInteraction.java | 3 + .../HelmicRegulatorInteraction.java | 58 +++++++++----- .../interaction/LampLevelInteraction.java | 3 + .../interaction/LightLevelInteraction.java | 3 + .../interaction/LightSwitchInteraction.java | 3 + .../interaction/ManualFlightInteraction.java | 34 +++++++++ .../interaction/MultiplierXZInteraction.java | 3 + .../interaction/RandomiserInteraction.java | 3 + .../interaction/RebuildInteraction.java | 3 + .../interaction/ScannerInteraction.java | 3 + .../interaction/ScreenInteraction.java | 3 + .../interaction/SonicDockInteraction.java | 3 + .../TelepathicCircuitInteraction.java | 3 + .../interaction/ThrottleInteraction.java | 3 + .../interaction/WayPointInteraction.java | 3 + .../console/interaction/WorldInteraction.java | 3 + .../resultset/ResultSetFlightControls.java | 76 +++++++++++++++++++ .../flight/TARDISManualFlightListener.java | 9 ++- .../flight/TARDISManualFlightRunnable.java | 33 +++++--- .../flight/TARDISManualFlightStarter.java | 6 +- .../flight/TARDISMaterialseFromVortex.java | 13 ++-- .../TARDISWeepingAngels.java | 2 +- .../monsters/judoon/JudoonGuardRunnable.java | 2 - 31 files changed, 275 insertions(+), 60 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/console/interaction/ManualFlightInteraction.java create mode 100644 src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetFlightControls.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/TARDISTrackerInstanceKeeper.java b/src/main/java/me/eccentric_nz/TARDIS/TARDISTrackerInstanceKeeper.java index 99c1029ca..e31f5f4c8 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/TARDISTrackerInstanceKeeper.java +++ b/src/main/java/me/eccentric_nz/TARDIS/TARDISTrackerInstanceKeeper.java @@ -84,7 +84,7 @@ public class TARDISTrackerInstanceKeeper { private final HashMap secondaryRemovers = new HashMap<>(); private final HashMap siegeCarrying = new HashMap<>(); private final HashMap pastes = new HashMap<>(); - private final HashMap> repeaters = new HashMap<>(); + private final HashMap> manualFlightLocations = new HashMap<>(); private final HashMap> renderedNPCs = new HashMap<>(); private final HashMap activeForceFields = new HashMap<>(); private final HashMap dispersed = new HashMap<>(); @@ -464,10 +464,10 @@ public HashMap getPastes() { /** * Another tracker for TARDIS Manual flight mode * - * @return a Map of player UUIDs and their TARDIS repeater control locations + * @return a Map of player UUIDs and their TARDIS control locations */ - public HashMap> getRepeaters() { - return repeaters; + public HashMap> getManualFlightLocations() { + return manualFlightLocations; } /** diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java index 57d0ad6f8..a7c237a7d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java @@ -33,12 +33,19 @@ public enum ConsoleInteraction { FAST_RETURN("Back Button", new Vector(1.8d, 1d, -0.9d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1003), TELEPATHIC_CIRCUIT("Telepathic Circuit", new Vector(1.575d, 1d, -0.05d), 0.5f, 0.65f, 0, 240.0f, Material.DAYLIGHT_DETECTOR, 1000), - // section five HELMIC_REGULATOR x=-1.134, z=-1.636 + // section five + WORLD("Environment Selector", new Vector(1.425d, 1.0d, 1.15d), 0.15f, 0.65f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), MULTIPLIER("Coordinate Increment Modifier", new Vector(1.55d, 1.0d, 0.925d), 0.15f, 0.65f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), X("X Distance", new Vector(1.625d, 1.0d, 1.275d), 0.15f, 0.4f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), Z("Z Distance", new Vector(1.75d, 1.0d, 1.05), 0.15f, 0.4f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), - HELMIC_REGULATOR("Dimension Selector", new Vector(2.25d, 1d, 1.075d), 0.5f, 0.6f, 0, 300.0f, Material.REPEATER, 2000); + HELMIC_REGULATOR("Helmic Regulator", new Vector(2.25d, 1d, 1.075d), 0.5f, 0.6f, 0, 300.0f, Material.ARMADILLO_SCUTE, 2000), + + // manual flight (includes helmic regulator above) + ASTROSEXTANT_RECTIFIER("Astrosextant Rectifier", new Vector(0.55d, 1d, -1.35d), 0.15f, 0.35f, 0, 180.0f, Material.ARMADILLO_SCUTE, 1000), + GRAVITIC_ANOMALISER("Gravitic Anomaliser", new Vector(0.125d, 1d, 1.8d), 0.15f, 0.5f, 0, 0.0f, Material.ARMADILLO_SCUTE, 1001), + ABSOLUTE_TESSERACTULATOR("Absolute Tesseractulator", new Vector(-1.15d, 1d, 0.825d), 0.15f, 0.5f, 0, 60.0f, Material.ARMADILLO_SCUTE, 1002); + private final String alternateName; private final Vector relativePosition; diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java index 57ef8aed2..d9845b274 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteractionListener.java @@ -28,7 +28,7 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { if (rsi.resultSet()) { ConsoleInteraction ci = rsi.getControl(); Player player = event.getPlayer(); - if (player.isSneaking() && ci != ConsoleInteraction.SCREEN_LEFT && ci != ConsoleInteraction.SCREEN_RIGHT&& ci != ConsoleInteraction.ARTRON) { + if (player.isSneaking() && ci != ConsoleInteraction.SCREEN_LEFT && ci != ConsoleInteraction.SCREEN_RIGHT && ci != ConsoleInteraction.ARTRON) { plugin.getMessenger().announceRepeater(player, rsi.getControl().getAlternateName()); return; } @@ -38,13 +38,17 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { // section zero case HANDBRAKE -> new HandbrakeInteraction(plugin).process(id, state, player, interaction); case THROTTLE -> new ThrottleInteraction(plugin).process(player, interaction, id); - case RELATIVITY_DIFFERENTIATOR -> new FlightModeInteraction(plugin).process(player, id, interaction); + case RELATIVITY_DIFFERENTIATOR -> + new FlightModeInteraction(plugin).process(player, id, interaction); // section one case WORLD -> new WorldInteraction(plugin).selectWorld(state, player, interaction, id); - case MULTIPLIER, X, Z -> new MultiplierXZInteraction(plugin).setRange(ci, state, interaction, id, player); - case HELMIC_REGULATOR -> new HelmicRegulatorInteraction(plugin).selectWorld(state, id, player, interaction); + case MULTIPLIER, X, Z -> + new MultiplierXZInteraction(plugin).setRange(ci, state, interaction, id, player); + case HELMIC_REGULATOR -> + new HelmicRegulatorInteraction(plugin).selectWorld(state, id, player, interaction); // section two - case RANDOMISER -> new RandomiserInteraction(plugin).generateDestination(id, player, interaction); + case RANDOMISER -> + new RandomiserInteraction(plugin).generateDestination(id, player, interaction); case WAYPOINT_SELECTOR -> new WayPointInteraction(plugin).openSaveGUI(id, player, interaction); case FAST_RETURN -> new FastReturnInteraction(plugin).setBack(id, player, interaction); case TELEPATHIC_CIRCUIT -> new TelepathicCircuitInteraction(plugin).openGUI(player); @@ -53,14 +57,20 @@ public void onConsoleInteractionClick(PlayerInteractAtEntityEvent event) { case DIRECTION -> new DirectionInteraction(plugin).rotate(id, player, interaction); // section four case LIGHT_SWITCH -> new LightSwitchInteraction(plugin).toggle(id, player, interaction); - case INTERIOR_LIGHT_LEVEL_SWITCH -> new LightLevelInteraction(plugin).setInterior(state, id, interaction, player); - case EXTERIOR_LAMP_LEVEL_SWITCH -> new LampLevelInteraction(plugin).setExterior(state, id, interaction, player); + case INTERIOR_LIGHT_LEVEL_SWITCH -> + new LightLevelInteraction(plugin).setInterior(state, id, interaction, player); + case EXTERIOR_LAMP_LEVEL_SWITCH -> + new LampLevelInteraction(plugin).setExterior(state, id, interaction, player); case DOOR_TOGGLE -> new DoorToggleInteraction(plugin).toggle(id, player, interaction); // section five - case SCREEN_LEFT, SCREEN_RIGHT -> new ScreenInteraction(plugin).display(id, interaction, ci == ConsoleInteraction.SCREEN_RIGHT, player); + case SCREEN_LEFT, SCREEN_RIGHT -> + new ScreenInteraction(plugin).display(id, interaction, ci == ConsoleInteraction.SCREEN_RIGHT, player); case SCANNER -> new ScannerInteraction(plugin).process(id, player, interaction); case ARTRON -> new ArtronInteraction(plugin).show(id, player, interaction); case REBUILD -> new RebuildInteraction(plugin).process(id, player, interaction); + // manual flight + case ASTROSEXTANT_RECTIFIER, ABSOLUTE_TESSERACTULATOR, GRAVITIC_ANOMALISER -> + new ManualFlightInteraction(plugin).receiveInput(id, player.getUniqueId(), interaction); // unknown default -> plugin.getMessenger().announceRepeater(player, rsi.getControl().getAlternateName()); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronInteraction.java index 3ab4e4ce3..42af927fe 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ArtronInteraction.java @@ -17,6 +17,9 @@ public ArtronInteraction(TARDIS plugin) { } public void show(int id, Player player, Interaction interaction) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } // set custom model data for artron button item display UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); if (uuid != null) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java index 2f2ad146b..5b07f440a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DirectionInteraction.java @@ -20,6 +20,9 @@ public DirectionInteraction(TARDIS plugin) { } public void rotate(int id, Player player, Interaction interaction) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } if (plugin.getTrackerKeeper().getInVortex().contains(id) || plugin.getTrackerKeeper().getMaterialising().contains(id) || plugin.getTrackerKeeper().getDematerialising().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "NOT_WHILE_MAT"); return; diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java index c27d210b4..a48a9575f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/DoorToggleInteraction.java @@ -19,6 +19,9 @@ public DoorToggleInteraction(TARDIS plugin) { } public void toggle(int id, Player player, Interaction interaction) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java index 99b2b4cbb..c3588c9a1 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FastReturnInteraction.java @@ -24,6 +24,9 @@ public FastReturnInteraction(TARDIS plugin) { } public void setBack(int id, Player player, Interaction interaction) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java index 614a2444e..9e6af154b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java @@ -21,6 +21,9 @@ public FlightModeInteraction(TARDIS plugin) { } public void process(Player player, int id, Interaction interaction) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } String uuid = player.getUniqueId().toString(); // get current throttle setting ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, uuid); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java index 85dece2f7..211d4c9a4 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HandbrakeInteraction.java @@ -40,6 +40,9 @@ public HandbrakeInteraction(TARDIS plugin) { } public void process(int id, int state, Player player, Interaction interaction) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } UUID uuid = player.getUniqueId(); Location handbrake = interaction.getLocation(); TARDISCircuitChecker tcc = null; diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java index 7d9380f7c..616dc67a3 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/HelmicRegulatorInteraction.java @@ -9,6 +9,14 @@ import java.util.UUID; +/** + * A TARDIS leaves temporary wakes and time ripples in the Vortex during travel. To ensure safe travel the TARDIS uses + * the helmic regulator to set up the proper Boolean constraints to regulate the Planck-Collapse within the Vortex, and + * stabilize the chronon beam to avoid complete overload of the Time Spiral's polyhelixes on the macrotransablative + * level. While the regulator normally works automatically there is a manual control on the console which can override + * the navigational instruments. This control is quite sensitive and rotating it will change the timeship's course + * through the Vortex, sending it thousands of years off course. + */ public class HelmicRegulatorInteraction { private final TARDIS plugin; @@ -18,27 +26,35 @@ public HelmicRegulatorInteraction(TARDIS plugin) { } public void selectWorld(int state, int id, Player player, Interaction interaction) { - int next = state + 1; - if (next > 8 || player.isSneaking()) { - next = 0; - } - String which = "OFF"; - if (next > 0) { - // get world name - which = getWorldFromState(next); - } - // show title - plugin.getMessenger().announceRepeater(player, which); - if (which.equals("OFF")) { - next = 0; - } - // save state - new InteractionStateSaver(plugin).write("HELMIC_REGULATOR", next, id); - // set custom model data for helmic regulator item display - UUID model = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); - if (model != null) { - ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(model); - new HelmicRegulatorModel().setState(display, next); + UUID uuid = player.getUniqueId(); + if (plugin.getTrackerKeeper().getFlight().containsKey(uuid)) { + if (interaction.getLocation().toString().equals(plugin.getTrackerKeeper().getFlight().get(uuid))) { + plugin.getTrackerKeeper().getCount().put(uuid, plugin.getTrackerKeeper().getCount().getOrDefault(uuid, 0) + 1); + } + plugin.getTrackerKeeper().getFlight().remove(uuid); + } else { + int next = state + 1; + if (next > 8 || player.isSneaking()) { + next = 0; + } + String which = "OFF"; + if (next > 0) { + // get world name + which = getWorldFromState(next); + } + // show title + plugin.getMessenger().announceRepeater(player, which); + if (which.equals("OFF")) { + next = 0; + } + // save state + new InteractionStateSaver(plugin).write("HELMIC_REGULATOR", next, id); + // set custom model data for helmic regulator item display + UUID model = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); + if (model != null) { + ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(model); + new HelmicRegulatorModel().setState(display, next); + } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java index 372506398..46f74055f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LampLevelInteraction.java @@ -22,6 +22,9 @@ public LampLevelInteraction(TARDIS plugin) { } public void setExterior(int state, int id, Interaction interaction, Player player) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } int unary = interaction.getPersistentDataContainer().getOrDefault(plugin.getUnaryKey(), PersistentDataType.INTEGER, 1); int setLevel = state + unary; if (setLevel > 7) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java index 46b64e62b..c5303188b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java @@ -22,6 +22,9 @@ public LightLevelInteraction(TARDIS plugin) { } public void setInterior(int state, int id, Interaction interaction, Player player) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } int unary = interaction.getPersistentDataContainer().getOrDefault(plugin.getUnaryKey(), PersistentDataType.INTEGER, 1); int setLevel = state + unary; if (setLevel > 7) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java index 4b397a159..3e5b964c2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightSwitchInteraction.java @@ -22,6 +22,9 @@ public LightSwitchInteraction(TARDIS plugin) { } public void toggle(int id, Player player, Interaction interaction) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ManualFlightInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ManualFlightInteraction.java new file mode 100644 index 000000000..7be1b2bb2 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ManualFlightInteraction.java @@ -0,0 +1,34 @@ +package me.eccentric_nz.TARDIS.console.interaction; + +import me.eccentric_nz.TARDIS.TARDIS; +import org.bukkit.entity.Interaction; + +import java.util.UUID; + +/** + *

The Astrosextant Rectifier will attempt to confirm that a TARDIS has arrived at the correct space-time + * coordinates.

The Gravitic Anomaliser is a component of the TARDIS. It generates a localised field of artificial + * gravity around the outside of the vessel.

The Absolute Tesseractulator is responsible for keeping track of a + * TARDIS's dimensional location. It uses the Interstitial Antenna to collect data from the Vortex. A TARDIS knows where + * it's going by using digitally-modelled time-cone isometry parallel-bussed into the image translator, with local + * motion being mapped over every refresh-cycle. This information is displayed on the Gyro-Series Dials. It will detect + * time travel induced by exterior forces (even if the TARDIS's drive is not activated). It is possible that a TARDIS + * occasionally materializes in space to "get its bearings."

+ */ +public class ManualFlightInteraction { + + private final TARDIS plugin; + + public ManualFlightInteraction(TARDIS plugin) { + this.plugin = plugin; + } + + public void receiveInput(int id, UUID uuid, Interaction interaction) { + if (plugin.getTrackerKeeper().getFlight().containsKey(uuid)) { + if (interaction.getLocation().toString().equals(plugin.getTrackerKeeper().getFlight().get(uuid))) { + plugin.getTrackerKeeper().getCount().put(uuid, plugin.getTrackerKeeper().getCount().getOrDefault(uuid, 0) + 1); + } + plugin.getTrackerKeeper().getFlight().remove(uuid); + } + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierXZInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierXZInteraction.java index 996de2aad..10bb47014 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierXZInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/MultiplierXZInteraction.java @@ -19,6 +19,9 @@ public MultiplierXZInteraction(TARDIS plugin) { } public void setRange(ConsoleInteraction ci, int state, Interaction interaction, int id, Player player) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } int next = state + 1; if (next > 4) { next = 1; diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java index 7c9b66d09..3770bfc86 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RandomiserInteraction.java @@ -33,6 +33,9 @@ public RandomiserInteraction(TARDIS plugin) { } public void generateDestination(int id, Player player, Interaction interaction) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RebuildInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RebuildInteraction.java index 72d82f3d2..ce524b1ad 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RebuildInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/RebuildInteraction.java @@ -19,6 +19,9 @@ public RebuildInteraction(TARDIS plugin) { } public void process(int id, Player player, Interaction interaction) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } if (plugin.getTrackerKeeper().getInSiegeMode().contains(id)) { plugin.getMessenger().send(player, TardisModule.TARDIS, "SIEGE_NO_CONTROL"); return; diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerInteraction.java index 462ff48b8..05e3c922e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScannerInteraction.java @@ -20,6 +20,9 @@ public ScannerInteraction(TARDIS plugin) { } public void process(int id, Player player, Interaction interaction) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } // set custom model data for scanner button item display UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); if (uuid != null) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java index 148925576..4ac137dcc 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java @@ -23,6 +23,9 @@ public ScreenInteraction(TARDIS plugin) { } public void display(int id, Interaction interaction, boolean coords, Player player) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } // if shift-click change display else open Control Menu GUI if (player.isSneaking()) { // get the text display diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicDockInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicDockInteraction.java index c8979ce6e..6c7abde4d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicDockInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/SonicDockInteraction.java @@ -21,6 +21,9 @@ public SonicDockInteraction(TARDIS plugin) { } public void process(Player player, Interaction interaction, int id) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } boolean activate = false; ItemStack is = player.getInventory().getItemInMainHand(); if (is.getType().equals(Material.BLAZE_ROD) && is.hasItemMeta()) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java index f5ed8e60f..0daf4780d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/TelepathicCircuitInteraction.java @@ -16,6 +16,9 @@ public TelepathicCircuitInteraction(TARDIS plugin) { } public void openGUI(Player player) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } // open GUI for // toggling telepathic circuit on/off // cave finder diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java index 8921ec41f..b4cbc29df 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ThrottleInteraction.java @@ -23,6 +23,9 @@ public ThrottleInteraction(TARDIS plugin) { } public void process(Player player, Interaction interaction, int id) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } String uuid = player.getUniqueId().toString(); int unary = interaction.getPersistentDataContainer().getOrDefault(plugin.getUnaryKey(), PersistentDataType.INTEGER, -1); // get current throttle setting diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java index d1d3a0b6d..988d66cc3 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WayPointInteraction.java @@ -21,6 +21,9 @@ public WayPointInteraction(TARDIS plugin) { } public void openSaveGUI(int id, Player player, Interaction interaction) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } // set custom model data for saves button item display UUID uuid = interaction.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); if (uuid != null) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java index 715aaf601..d618e208f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/WorldInteraction.java @@ -19,6 +19,9 @@ public WorldInteraction(TARDIS plugin) { } public void selectWorld(int state, Player player, Interaction interaction, int id) { + if (plugin.getTrackerKeeper().getFlight().containsKey(player.getUniqueId())) { + return; + } /* THIS => 1, NORMAL => 2, diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetFlightControls.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetFlightControls.java new file mode 100644 index 000000000..93bfaf223 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetFlightControls.java @@ -0,0 +1,76 @@ +package me.eccentric_nz.TARDIS.database.resultset; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.TARDISDatabaseConnection; +import org.bukkit.Location; +import org.bukkit.entity.Entity; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class ResultSetFlightControls { + + private final TARDISDatabaseConnection service = TARDISDatabaseConnection.getINSTANCE(); + private final Connection connection = service.getConnection(); + private final TARDIS plugin; + private final int id; + private final int[] diodes = new int[4]; + private final List locations = new ArrayList<>(); + private final String prefix; + + public ResultSetFlightControls(TARDIS plugin, int id) { + this.plugin = plugin; + this.id = id; + prefix = this.plugin.getPrefix(); + } + + public boolean resultSet() { + PreparedStatement statement = null; + ResultSet rs = null; + String query = "SELECT uuid FROM " + prefix + "interactions WHERE tardis_id = ? AND control IN ('HELMIC_REGULATOR', 'ASTROSEXTANT_RECTIFIER', 'GRAVITIC_ANOMALISER', 'ABSOLUTE_TESSERACTULATOR')"; + try { + service.testConnection(connection); + statement = connection.prepareStatement(query); + statement.setInt(1, id); + rs = statement.executeQuery(); + if (rs.isBeforeFirst()) { + while (rs.next()) { + try { + UUID uuid = UUID.fromString(rs.getString("uuid")); + Entity entity = plugin.getServer().getEntity(uuid); + if (entity != null) { + locations.add(entity.getLocation()); + } + } catch (IllegalArgumentException ignored) { + } + } + } else { + return false; + } + } catch (SQLException e) { + plugin.debug("ResultSet error for flight interactions table! " + e.getMessage()); + return false; + } finally { + try { + if (rs != null) { + rs.close(); + } + if (statement != null) { + statement.close(); + } + } catch (SQLException e) { + plugin.debug("Error closing flight interactions table! " + e.getMessage()); + } + } + return true; + } + + public List getLocations() { + return locations; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISManualFlightListener.java b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISManualFlightListener.java index 9051ed849..9b270e9c6 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISManualFlightListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISManualFlightListener.java @@ -16,7 +16,6 @@ */ package me.eccentric_nz.TARDIS.flight; -import java.util.UUID; import me.eccentric_nz.TARDIS.TARDIS; import org.bukkit.Location; import org.bukkit.Material; @@ -28,6 +27,8 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; +import java.util.UUID; + /** * The Absolute Tesseractulator is responsible for keeping track of a TARDIS's dimensional location. It uses the * Interstitial Antenna to collect data from the Vortex. A TARDIS knows where it's going by using digitally-modeled @@ -65,9 +66,9 @@ public void onInteract(PlayerInteractEvent event) { event.setCancelled(true); } plugin.getTrackerKeeper().getFlight().remove(uuid); - } else // if it is a TARDIS repeater cancel the event - { - if (plugin.getTrackerKeeper().getRepeaters().containsKey(uuid) && plugin.getTrackerKeeper().getRepeaters().get(uuid).contains(loc)) { + } else { + // if it is a TARDIS repeater cancel the event + if (plugin.getTrackerKeeper().getManualFlightLocations().containsKey(uuid) && plugin.getTrackerKeeper().getManualFlightLocations().get(uuid).contains(loc)) { event.setCancelled(true); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISManualFlightRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISManualFlightRunnable.java index ea90f5c84..996623a4f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISManualFlightRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISManualFlightRunnable.java @@ -16,17 +16,19 @@ */ package me.eccentric_nz.TARDIS.flight; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISConstants; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetFlightControls; import me.eccentric_nz.TARDIS.database.resultset.ResultSetRepeaters; import me.eccentric_nz.TARDIS.enumeration.TardisModule; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.entity.Player; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + /** * After materialization, the Astrosextant Rectifier will attempt to confirm that a TARDIS has arrived at the correct * coordinates. A damaged Sterometer will reduce the accuracy of the Rectifier to within a few thousand light years. @@ -41,15 +43,17 @@ class TARDISManualFlightRunnable implements Runnable { private final List controls = Arrays.asList("Helmic Regulator", "Astrosextant Rectifier", "Gravitic Anomaliser", "Absolute Tesseractulator"); private final Player player; private final UUID uuid; + private final boolean console; private int taskID; private int i = 0; - TARDISManualFlightRunnable(TARDIS plugin, Player player, int id) { + TARDISManualFlightRunnable(TARDIS plugin, Player player, int id, boolean console) { this.plugin = plugin; this.player = player; - target = getRepeaterList(id); + target = getLocationList(id); uuid = player.getUniqueId(); - plugin.getTrackerKeeper().getRepeaters().put(uuid, target); + this.console = console; + plugin.getTrackerKeeper().getManualFlightLocations().put(uuid, target); } @Override @@ -78,14 +82,21 @@ public void run() { Location adjusted = new TARDISFlightAdjustment(plugin).getLocation(plugin.getTrackerKeeper().getFlightData().get(uuid), blocks); plugin.getTrackerKeeper().getFlightData().get(uuid).setLocation(adjusted); } - plugin.getTrackerKeeper().getRepeaters().remove(uuid); + plugin.getTrackerKeeper().getManualFlightLocations().remove(uuid); } } - private List getRepeaterList(int id) { - ResultSetRepeaters rsr = new ResultSetRepeaters(plugin, id, 0); - if (rsr.resultSet()) { - return rsr.getLocations(); + private List getLocationList(int id) { + if (console) { + ResultSetFlightControls rsfc = new ResultSetFlightControls(plugin, id); + if (rsfc.resultSet()) { + return rsfc.getLocations(); + } + } else { + ResultSetRepeaters rsr = new ResultSetRepeaters(plugin, id, 0); + if (rsr.resultSet()) { + return rsr.getLocations(); + } } return null; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISManualFlightStarter.java b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISManualFlightStarter.java index 0147d6982..544adfa2b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISManualFlightStarter.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISManualFlightStarter.java @@ -32,11 +32,13 @@ class TARDISManualFlightStarter implements Runnable { private final TARDIS plugin; private final Player player; private final int id; + private final boolean console; - TARDISManualFlightStarter(TARDIS plugin, Player player, int id) { + TARDISManualFlightStarter(TARDIS plugin, Player player, int id, boolean console) { this.plugin = plugin; this.player = player; this.id = id; + this.console = console; } @Override @@ -44,7 +46,7 @@ public void run() { long delay = plugin.getConfig().getLong("travel.manual_flight_delay"); // start a manual flight session plugin.getMessenger().send(player, TardisModule.TARDIS, "FLIGHT_ENGAGED"); - TARDISManualFlightRunnable mfr = new TARDISManualFlightRunnable(plugin, player, id); + TARDISManualFlightRunnable mfr = new TARDISManualFlightRunnable(plugin, player, id, console); int taskid = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, mfr, 10L, delay); mfr.setTaskID(taskid); // play inflight sound diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISMaterialseFromVortex.java b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISMaterialseFromVortex.java index 2d917e65b..e12773ffb 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISMaterialseFromVortex.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISMaterialseFromVortex.java @@ -23,10 +23,7 @@ import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; import me.eccentric_nz.TARDIS.builders.BuildData; import me.eccentric_nz.TARDIS.database.data.Tardis; -import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentFromId; -import me.eccentric_nz.TARDIS.database.resultset.ResultSetNextLocation; -import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; -import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; +import me.eccentric_nz.TARDIS.database.resultset.*; import me.eccentric_nz.TARDIS.enumeration.*; import me.eccentric_nz.TARDIS.hads.TARDISCloisterBell; import me.eccentric_nz.TARDIS.travel.TARDISMalfunction; @@ -201,7 +198,13 @@ public void run() { if (flight_mode == 2 || flight_mode == 3) { materialisation_delay += 650L; travel_time += 650L; - Runnable runner = (flight_mode == 2) ? new TARDISRegulatorStarter(plugin, player, id) : new TARDISManualFlightStarter(plugin, player, id); + Runnable runner; + if (flight_mode == 2) { + runner = new TARDISRegulatorStarter(plugin, player, id); + } else { + ResultSetInteractionCheck rsic = new ResultSetInteractionCheck(plugin, uuid); + runner = new TARDISManualFlightStarter(plugin, player, id, rsic.resultSet()); + } // start the flying mode (after demat if not in vortex already) scheduler.scheduleSyncDelayedTask(plugin, runner, flight_mode_delay); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/TARDISWeepingAngels.java b/src/main/java/me/eccentric_nz/tardisweepingangels/TARDISWeepingAngels.java index 6dccaff24..804d36bd2 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/TARDISWeepingAngels.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/TARDISWeepingAngels.java @@ -135,7 +135,7 @@ public static List getPlayersWithGuards() { public void enable() { citizensEnabled = plugin.getPM().isPluginEnabled("Citizens"); - // TODO add TWA apin to TARDIS API + // TODO add TWA api to TARDIS API api = new MonsterEquipment(); // update the config new MonstersConfig(plugin).updateConfig(); diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/judoon/JudoonGuardRunnable.java b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/judoon/JudoonGuardRunnable.java index a35a42b79..eaaa4b97d 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/judoon/JudoonGuardRunnable.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/judoon/JudoonGuardRunnable.java @@ -33,7 +33,6 @@ public class JudoonGuardRunnable implements Runnable { private final TARDIS plugin; - // TODO - delete public JudoonGuardRunnable(TARDIS plugin) { this.plugin = plugin; } @@ -70,7 +69,6 @@ public void run() { // set judoon yaw origin.setDirection(direction.subtract(start)); //set the origin's direction to be the direction vector between point A and B. float yaw = origin.getYaw(); - plugin.debug("yaw = " + yaw); entity.setRotation(yaw,0); ammo -= 1; if (ammo >= 0) { From 446067157374a3240093cf3c59c0188808d9824c Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 29 Apr 2024 17:21:30 +1200 Subject: [PATCH 67/96] Malfunctions for the console --- .../resultset/ResultSetInteractionCheck.java | 41 ++++++++++++++++--- .../flight/TARDISMaterialseFromVortex.java | 4 +- .../listeners/TARDISSeedBlockListener.java | 4 +- .../TARDIS/travel/TARDISMalfunction.java | 3 +- .../travel/TARDISMalfunctionExplosion.java | 18 ++++++-- todo.md | 1 - 6 files changed, 55 insertions(+), 16 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteractionCheck.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteractionCheck.java index cc09ac169..d27a079e9 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteractionCheck.java +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetInteractionCheck.java @@ -39,16 +39,14 @@ public class ResultSetInteractionCheck { private final Connection connection = service.getConnection(); private final TARDIS plugin; private final String prefix; - private final UUID uuid; /** * Creates a class instance that can be used to retrieve an SQL ResultSet from the interactions table. * * @param plugin an instance of the main class. */ - public ResultSetInteractionCheck(TARDIS plugin, UUID uuid) { + public ResultSetInteractionCheck(TARDIS plugin) { this.plugin = plugin; - this.uuid = uuid; prefix = this.plugin.getPrefix(); } @@ -58,7 +56,7 @@ public ResultSetInteractionCheck(TARDIS plugin, UUID uuid) { * * @return true or false depending on whether any data matches the query */ - public boolean resultSet() { + public boolean resultSetFromUUID(UUID uuid) { PreparedStatement statement = null; ResultSet rs = null; String query = "SELECT " + prefix + "interactions.i_id FROM " + prefix + "interactions, " + prefix + "tardis WHERE " + prefix + "tardis.uuid = ? AND " + prefix + "interactions.tardis_id = " + prefix + "tardis.tardis_id"; @@ -73,7 +71,7 @@ public boolean resultSet() { return false; } } catch (SQLException e) { - plugin.debug("ResultSet error for interactions check table! " + e.getMessage()); + plugin.debug("ResultSet error for interactions UUID check! " + e.getMessage()); return false; } finally { try { @@ -84,7 +82,38 @@ public boolean resultSet() { statement.close(); } } catch (SQLException e) { - plugin.debug("Error closing interactions check table! " + e.getMessage()); + plugin.debug("Error closing interactions UUID check! " + e.getMessage()); + } + } + } + + public boolean resultSetFromId(int id) { + PreparedStatement statement = null; + ResultSet rs = null; + String query = "SELECT " + prefix + "interactions.i_id FROM " + prefix + "interactions, " + prefix + "tardis WHERE " + prefix + "tardis.tardis_id = ? AND " + prefix + "interactions.tardis_id = " + prefix + "tardis.tardis_id"; + try { + service.testConnection(connection); + statement = connection.prepareStatement(query); + statement.setInt(1, id); + rs = statement.executeQuery(); + if (rs.isBeforeFirst()) { + return true; + } else { + return false; + } + } catch (SQLException e) { + plugin.debug("ResultSet error for interactions id check! " + e.getMessage()); + return false; + } finally { + try { + if (rs != null) { + rs.close(); + } + if (statement != null) { + statement.close(); + } + } catch (SQLException e) { + plugin.debug("Error closing interactions id check! " + e.getMessage()); } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISMaterialseFromVortex.java b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISMaterialseFromVortex.java index e12773ffb..025c54a0a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISMaterialseFromVortex.java +++ b/src/main/java/me/eccentric_nz/TARDIS/flight/TARDISMaterialseFromVortex.java @@ -202,8 +202,8 @@ public void run() { if (flight_mode == 2) { runner = new TARDISRegulatorStarter(plugin, player, id); } else { - ResultSetInteractionCheck rsic = new ResultSetInteractionCheck(plugin, uuid); - runner = new TARDISManualFlightStarter(plugin, player, id, rsic.resultSet()); + ResultSetInteractionCheck rsic = new ResultSetInteractionCheck(plugin); + runner = new TARDISManualFlightStarter(plugin, player, id, rsic.resultSetFromId(id)); } // start the flying mode (after demat if not in vortex already) scheduler.scheduleSyncDelayedTask(plugin, runner, flight_mode_delay); diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISSeedBlockListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISSeedBlockListener.java index b795cd252..dfad5de52 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISSeedBlockListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISSeedBlockListener.java @@ -115,8 +115,8 @@ public void onSeedBlockPlace(BlockPlaceEvent event) { return; } // must not have a console already - ResultSetInteractionCheck rsi = new ResultSetInteractionCheck(plugin, player.getUniqueId()); - if (rsi.resultSet()) { + ResultSetInteractionCheck rsi = new ResultSetInteractionCheck(plugin); + if (rsi.resultSetFromUUID(player.getUniqueId())) { plugin.getMessenger().send(player, TardisModule.TARDIS, "CONSOLE_HAS"); event.setCancelled(true); return; diff --git a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISMalfunction.java b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISMalfunction.java index ea1b36737..f5375bff3 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISMalfunction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISMalfunction.java @@ -227,7 +227,8 @@ private void doMalfunction(int id, Player p, String eps, String creeper, Locatio int taskID = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, runnable, 10L, 10L); runnable.setTask(taskID); // add fireworks - TARDISMalfunctionExplosion explodeable = new TARDISMalfunctionExplosion(plugin, id, end); + ResultSetInteractionCheck rsic = new ResultSetInteractionCheck(plugin); + TARDISMalfunctionExplosion explodeable = new TARDISMalfunctionExplosion(plugin, id, end, rsic.resultSetFromId(id)); int taskEx = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, explodeable, 10L, 30L); explodeable.setTask(taskEx); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISMalfunctionExplosion.java b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISMalfunctionExplosion.java index d0bea8e92..b2b623814 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISMalfunctionExplosion.java +++ b/src/main/java/me/eccentric_nz/TARDIS/travel/TARDISMalfunctionExplosion.java @@ -19,6 +19,7 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISConstants; import me.eccentric_nz.TARDIS.database.data.Tardis; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetFlightControls; import me.eccentric_nz.TARDIS.database.resultset.ResultSetRepeaters; import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; import me.eccentric_nz.TARDIS.utility.TARDISFirework; @@ -41,14 +42,16 @@ public class TARDISMalfunctionExplosion implements Runnable { private final TARDIS plugin; private final int id; private final long end; + private final boolean console; private boolean started = false; private List locations; private int task; - public TARDISMalfunctionExplosion(TARDIS plugin, int id, long end) { + public TARDISMalfunctionExplosion(TARDIS plugin, int id, long end, boolean console) { this.plugin = plugin; this.id = id; this.end = end; + this.console = console; } @Override @@ -59,9 +62,16 @@ public void run() { ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 2); if (rs.resultSet()) { Tardis tardis = rs.getTardis(); - ResultSetRepeaters rsr = new ResultSetRepeaters(plugin, tardis.getTardisId(), 0); - if (rsr.resultSet()) { - locations = rsr.getLocations(); + if (console) { + ResultSetFlightControls rsfc = new ResultSetFlightControls(plugin, id); + if (rsfc.resultSet()) { + locations = rsfc.getLocations(); + } + } else { + ResultSetRepeaters rsr = new ResultSetRepeaters(plugin, tardis.getTardisId(), 0); + if (rsr.resultSet()) { + locations = rsr.getLocations(); + } } started = true; } diff --git a/todo.md b/todo.md index d4f7ab96d..a1df7e748 100644 --- a/todo.md +++ b/todo.md @@ -7,7 +7,6 @@ 3. Custom Control models [#703](https://github.com/eccentricdevotion/TARDIS/issues/703) [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) * New interior with console - * Malfunction & manual flight classes * Regular handbrake needs to check console flight mode * Remove sonic screwdriver when breaking console * Alter console side model inner edge / make new time rotor for console From 8a701bf61d3b5bca892c36b087d1d2060bb3be22 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 29 Apr 2024 18:56:35 +1200 Subject: [PATCH 68/96] Remove sonic screwdriver when breaking console --- .../TARDIS/console/ConsoleChanger.java | 2 +- .../TARDIS/console/ConsoleDestroyer.java | 16 ++++++++++++---- .../TARDIS/console/models/SonicDockModel.java | 2 +- .../telepathic/TelepathicStructureListener.java | 1 - todo.md | 3 +-- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleChanger.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleChanger.java index 08ebf218c..cf9da86e3 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleChanger.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleChanger.java @@ -18,7 +18,7 @@ public ConsoleChanger(TARDIS plugin) { public void setType(Block block, int type) { // get item displays around the block - for (Entity entity : block.getWorld().getNearbyEntities(block.getLocation(), 2,2,2)) { + for (Entity entity : block.getWorld().getNearbyEntities(block.getLocation(), 2, 2, 2)) { if (entity instanceof ItemDisplay display) { // get the item stack ItemStack is = display.getItemStack(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java index 222844c1e..a9f5072f2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleDestroyer.java @@ -2,17 +2,16 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.console.models.ColourType; +import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItemUtils; import me.eccentric_nz.TARDIS.database.ClearInteractions; import me.eccentric_nz.TARDIS.database.resultset.ResultSetConsoleLabel; import me.eccentric_nz.TARDIS.database.resultset.ResultSetInteractionsFromId; +import me.eccentric_nz.TARDIS.sonic.SonicLore; import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.ItemDisplay; -import org.bukkit.entity.TextDisplay; +import org.bukkit.entity.*; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataType; @@ -37,6 +36,15 @@ public ItemStack returnStack(String uuids, int id) { for (UUID u : rs.getUuids()) { Entity e = plugin.getServer().getEntity(u); if (e != null) { + // check for sonic + ItemDisplay docked = TARDISDisplayItemUtils.getSonic((Interaction) e); + if (docked != null) { + ItemStack sonic = docked.getItemStack(); + // set the charge level in lore + SonicLore.setChargeLevel(sonic); + e.getWorld().dropItemNaturally(e.getLocation(), sonic); + docked.remove(); + } // item displays UUID uuid = e.getPersistentDataContainer().get(plugin.getModelUuidKey(), plugin.getPersistentDataTypeUUID()); if (uuid != null) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/SonicDockModel.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/SonicDockModel.java index ffaf625f0..5cb7d1136 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/models/SonicDockModel.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/SonicDockModel.java @@ -15,7 +15,7 @@ public void setState(ItemDisplay display, boolean activate) { ItemStack is = display.getItemStack(); ItemMeta im = is.getItemMeta(); int cmd = im.getCustomModelData(); - im.setCustomModelData(activate?2001:2000); + im.setCustomModelData(activate ? 2001 : 2000); is.setItemMeta(im); display.setItemStack(is); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicStructureListener.java b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicStructureListener.java index 9f8209e58..2631547ba 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicStructureListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/telepathic/TelepathicStructureListener.java @@ -14,7 +14,6 @@ public class TelepathicStructureListener extends TARDISMenuListener { - public TelepathicStructureListener(TARDIS plugin) { super(plugin); } diff --git a/todo.md b/todo.md index a1df7e748..6467b4457 100644 --- a/todo.md +++ b/todo.md @@ -8,10 +8,9 @@ [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) * New interior with console * Regular handbrake needs to check console flight mode - * Remove sonic screwdriver when breaking console * Alter console side model inner edge / make new time rotor for console * Alter the position of the control label based on the angle of the panel the control is on -4. Update old light level controls, and light switch shoulf return to correct level +4. Update old light level controls, and light switch should return to correct level 5. ? ## Next version `5.7.0` From e2f6848435dd9321d819008036736137b3d15c53 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 29 Apr 2024 18:57:44 +1200 Subject: [PATCH 69/96] Refactor misspelled class name --- .../TARDIS/console/interaction/ScreenInteraction.java | 4 ++-- .../{ConcoleColourChanger.java => ConsoleColourChanger.java} | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/main/java/me/eccentric_nz/TARDIS/console/models/{ConcoleColourChanger.java => ConsoleColourChanger.java} (94%) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java index 4ac137dcc..2129ed299 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java @@ -4,7 +4,7 @@ import me.eccentric_nz.TARDIS.console.ConsoleDestroyer; import me.eccentric_nz.TARDIS.console.ControlMonitor; import me.eccentric_nz.TARDIS.console.models.ColourType; -import me.eccentric_nz.TARDIS.console.models.ConcoleColourChanger; +import me.eccentric_nz.TARDIS.console.models.ConsoleColourChanger; import me.eccentric_nz.TARDIS.control.actions.ControlMenuAction; import me.eccentric_nz.TARDIS.enumeration.TardisModule; import org.bukkit.Location; @@ -48,7 +48,7 @@ public void display(int id, Interaction interaction, boolean coords, Player play String uuids = interaction.getPersistentDataContainer().get(plugin.getUnaryKey(), PersistentDataType.STRING); if (uuids != null) { // change the colour of the console - if (new ConcoleColourChanger(plugin, interaction.getLocation(), uuids, colour).paint()) { + if (new ConsoleColourChanger(plugin, interaction.getLocation(), uuids, colour).paint()) { // take the concrete powder if (amount < 7) { player.getInventory().setItemInMainHand(null); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/ConcoleColourChanger.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/ConsoleColourChanger.java similarity index 94% rename from src/main/java/me/eccentric_nz/TARDIS/console/models/ConcoleColourChanger.java rename to src/main/java/me/eccentric_nz/TARDIS/console/models/ConsoleColourChanger.java index 135a13782..dc37c0c19 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/models/ConcoleColourChanger.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/ConsoleColourChanger.java @@ -10,14 +10,14 @@ import java.util.UUID; -public class ConcoleColourChanger { +public class ConsoleColourChanger { private final TARDIS plugin; private final Location location; private final String uuids; private final int type; - public ConcoleColourChanger(TARDIS plugin, Location location, String uuids, int type) { + public ConsoleColourChanger(TARDIS plugin, Location location, String uuids, int type) { this.plugin = plugin; this.location = location; this.uuids = uuids; From a30a8ee76666f4c5df9a5487c3f6420999eae847 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 29 Apr 2024 18:59:28 +1200 Subject: [PATCH 70/96] =?UTF-8?q?Lower=20the=20console=20=C2=BC=20of=20a?= =?UTF-8?q?=20block?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TARDIS/console/ConsoleBuilder.java | 8 +-- .../TARDIS/console/ConsoleInteraction.java | 53 +++++++++---------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index 266ca876e..0d52db75f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -45,7 +45,7 @@ public void create(Block block, int type, int id) { im.setCustomModelData(1000 + type); im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, i); shard.setItemMeta(im); - ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(up.getLocation().add(0.5d, 0.5d, 0.5d), EntityType.ITEM_DISPLAY); + ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(up.getLocation().add(0.5d, 0.25d, 0.5d), EntityType.ITEM_DISPLAY); display.setItemStack(shard); display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); UUID uuid = display.getUniqueId(); @@ -65,7 +65,7 @@ public void create(Block block, int type, int id) { im.setCustomModelData(2000 + type); im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, i); shard.setItemMeta(im); - ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(up.getLocation().add(0.5d, 0.5d, 0.5d), EntityType.ITEM_DISPLAY); + ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(up.getLocation().add(0.5d, 0.25d, 0.5d), EntityType.ITEM_DISPLAY); display.setItemStack(shard); display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); UUID uuid = display.getUniqueId(); @@ -83,7 +83,7 @@ public void create(Block block, int type, int id) { UUID uuid = spawnControl(i, block.getLocation(), i.getYaw(), id); double x = i.getRelativePosition().getX(); double z = i.getRelativePosition().getZ(); - Location location = block.getLocation().clone().add(x, 1, z); + Location location = block.getLocation().clone().add(x, 0.75, z); Interaction interaction = (Interaction) location.getWorld().spawnEntity(location, EntityType.INTERACTION); interaction.getPersistentDataContainer().set(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID(), interaction.getUniqueId()); if (i == ConsoleInteraction.THROTTLE) { @@ -133,7 +133,7 @@ private UUID spawnControl(ConsoleInteraction interaction, Location location, flo im.setCustomModelData(cmd); im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, cmd); is.setItemMeta(im); - ItemDisplay display = (ItemDisplay) location.getWorld().spawnEntity(location.add(0.5d, 1.5d, 0.5d), EntityType.ITEM_DISPLAY); + ItemDisplay display = (ItemDisplay) location.getWorld().spawnEntity(location.add(0.5d, 1.25d, 0.5d), EntityType.ITEM_DISPLAY); display.setItemStack(is); display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); display.setPersistent(true); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java index a7c237a7d..2d54a489d 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleInteraction.java @@ -6,46 +6,45 @@ public enum ConsoleInteraction { // section zero - SONIC_DOCK("Sonic Screwdriver Dock", new Vector(0.5d, 1d, 1.625d), 0.5f, 0.65f, 0, 0.0f, Material.FLOWER_POT, 2000), - DIRECTION("Exterior Directional Control", new Vector(0.75d, 1d, 2.25d), 0.625f, 0.5f, 0, 0.0f, Material.RAIL, 10000), + SONIC_DOCK("Sonic Screwdriver Dock", new Vector(0.5d, 0.75d, 1.625d), 0.5f, 0.65f, 0, 0.0f, Material.FLOWER_POT, 2000), + DIRECTION("Exterior Directional Control", new Vector(0.75d, 0.75d, 2.25d), 0.625f, 0.5f, 0, 0.0f, Material.RAIL, 10000), // section one - LIGHT_SWITCH("Interior Light Switch", new Vector(-1.45d, 1d, 0.9d), 0.25f, 0.33f, 0, 60.0f, Material.BAMBOO_BUTTON, 1004), - INTERIOR_LIGHT_LEVEL_SWITCH("Interior Light Level", new Vector(-0.85d, 1d, 1.05d), 0.25f, 0.5f, 0, 60.0f, Material.LEVER, 8000), - EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Lamp Level", new Vector(-0.65d, 1d, 1.45d), 0.25f, 0.5f, 0, 60.0f, Material.LEVER, 7000), - DOOR_TOGGLE("Toggle Wool Switch", new Vector(-0.775d, 1d, 2.0d), 0.25f, 0.33f, 0, 60.0f, Material.BAMBOO_BUTTON, 1005), + LIGHT_SWITCH("Interior Light Switch", new Vector(-1.45d, 0.75d, 0.9d), 0.25f, 0.33f, 0, 60.0f, Material.BAMBOO_BUTTON, 1004), + INTERIOR_LIGHT_LEVEL_SWITCH("Interior Light Level", new Vector(-0.85d, 0.75d, 1.05d), 0.25f, 0.5f, 0, 60.0f, Material.LEVER, 8000), + EXTERIOR_LAMP_LEVEL_SWITCH("Exterior Lamp Level", new Vector(-0.65d, 0.75d, 1.45d), 0.25f, 0.5f, 0, 60.0f, Material.LEVER, 7000), + DOOR_TOGGLE("Toggle Wool Switch", new Vector(-0.775d, 0.75d, 2.0d), 0.25f, 0.33f, 0, 60.0f, Material.BAMBOO_BUTTON, 1005), // section two - SCREEN_RIGHT("Coordinates Display", new Vector(-0.85d, 1d, 0.1d), 0.5f, 1.1f, 0, 120.0f, Material.MAP, 1000), - SCREEN_LEFT("Information Display", new Vector(-0.6d, 1d, -0.4d), 0.5f, 1.1f, 0, 120.0f, Material.MAP, 1000), - SCANNER("Exterior Environment Scanner", new Vector(-0.875d, 1d, -0.875d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1008), - ARTRON("Artron Energy Button", new Vector(-1.15d, 1d, -0.4d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1006), - REBUILD("Chameleon Circuit Re-initialiser", new Vector(-1.45d, 1d, 0.05d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1007), + SCREEN_RIGHT("Coordinates Display", new Vector(-0.85d, 0.75d, 0.1d), 0.5f, 1.1f, 0, 120.0f, Material.MAP, 1000), + SCREEN_LEFT("Information Display", new Vector(-0.6d, 0.75d, -0.4d), 0.5f, 1.1f, 0, 120.0f, Material.MAP, 1000), + SCANNER("Exterior Environment Scanner", new Vector(-0.875d, 0.75d, -0.875d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1008), + ARTRON("Artron Energy Button", new Vector(-1.15d, 0.75d, -0.4d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1006), + REBUILD("Chameleon Circuit Re-initialiser", new Vector(-1.45d, 0.75d, 0.05d), 0.25f, 0.33f, 0, 120.0f, Material.BAMBOO_BUTTON, 1007), // section three - HANDBRAKE("Time Rotor Handbrake", new Vector(0.95d, 1d, -1.2d), 0.5f, 0.4f, 1, 180.0f, Material.LEVER, 5002), - THROTTLE("Flight Speed", new Vector(-0.0d, 1.0d, -1.35d), 0.5f, 0.33f, 4, 180.0f, Material.REPEATER, 1004), - RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.45d, 1.0d, -0.75d), 0.5f, 0.65f, 1, 180.0f, Material.LEVER, 6001), + HANDBRAKE("Time Rotor Handbrake", new Vector(0.95d, 0.75d, -1.2d), 0.5f, 0.4f, 1, 180.0f, Material.LEVER, 5002), + THROTTLE("Flight Speed", new Vector(-0.0d, 0.75d, -1.35d), 0.5f, 0.33f, 4, 180.0f, Material.REPEATER, 1004), + RELATIVITY_DIFFERENTIATOR("Flight Mode Selector", new Vector(0.45d, 0.75d, -0.75d), 0.5f, 0.65f, 1, 180.0f, Material.LEVER, 6001), // section four - RANDOMISER("Random Location Finder", new Vector(2.35d, 1d, 0.025d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1001), - WAYPOINT_SELECTOR("Saves", new Vector(2.1d, 1d, -0.45d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1002), - FAST_RETURN("Back Button", new Vector(1.8d, 1d, -0.9d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1003), - TELEPATHIC_CIRCUIT("Telepathic Circuit", new Vector(1.575d, 1d, -0.05d), 0.5f, 0.65f, 0, 240.0f, Material.DAYLIGHT_DETECTOR, 1000), + RANDOMISER("Random Location Finder", new Vector(2.35d, 0.75d, 0.025d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1001), + WAYPOINT_SELECTOR("Saves", new Vector(2.1d, 0.75d, -0.45d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1002), + FAST_RETURN("Back Button", new Vector(1.8d, 0.75d, -0.9d), 0.25f, 0.33f, 0, 240.0f, Material.BAMBOO_BUTTON, 1003), + TELEPATHIC_CIRCUIT("Telepathic Circuit", new Vector(1.575d, 0.75d, -0.05d), 0.5f, 0.65f, 0, 240.0f, Material.DAYLIGHT_DETECTOR, 1000), // section five - WORLD("Environment Selector", new Vector(1.425d, 1.0d, 1.15d), 0.15f, 0.65f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), - MULTIPLIER("Coordinate Increment Modifier", new Vector(1.55d, 1.0d, 0.925d), 0.15f, 0.65f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), - X("X Distance", new Vector(1.625d, 1.0d, 1.275d), 0.15f, 0.4f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), - Z("Z Distance", new Vector(1.75d, 1.0d, 1.05), 0.15f, 0.4f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), - HELMIC_REGULATOR("Helmic Regulator", new Vector(2.25d, 1d, 1.075d), 0.5f, 0.6f, 0, 300.0f, Material.ARMADILLO_SCUTE, 2000), + WORLD("Environment Selector", new Vector(1.425d, 0.75d, 1.15d), 0.15f, 0.65f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), + MULTIPLIER("Coordinate Increment Modifier", new Vector(1.55d, 0.75d, 0.925d), 0.15f, 0.65f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), + X("X Distance", new Vector(1.625d, 0.75d, 1.275d), 0.15f, 0.4f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), + Z("Z Distance", new Vector(1.75d, 0.75d, 1.05), 0.15f, 0.4f, 1, 300.0f, Material.BAMBOO_BUTTON, 1009), + HELMIC_REGULATOR("Helmic Regulator", new Vector(2.25d, 0.75d, 1.075d), 0.5f, 0.6f, 0, 300.0f, Material.ARMADILLO_SCUTE, 2000), // manual flight (includes helmic regulator above) - ASTROSEXTANT_RECTIFIER("Astrosextant Rectifier", new Vector(0.55d, 1d, -1.35d), 0.15f, 0.35f, 0, 180.0f, Material.ARMADILLO_SCUTE, 1000), - GRAVITIC_ANOMALISER("Gravitic Anomaliser", new Vector(0.125d, 1d, 1.8d), 0.15f, 0.5f, 0, 0.0f, Material.ARMADILLO_SCUTE, 1001), - ABSOLUTE_TESSERACTULATOR("Absolute Tesseractulator", new Vector(-1.15d, 1d, 0.825d), 0.15f, 0.5f, 0, 60.0f, Material.ARMADILLO_SCUTE, 1002); - + ASTROSEXTANT_RECTIFIER("Astrosextant Rectifier", new Vector(0.55d, 0.75d, -1.35d), 0.15f, 0.35f, 0, 180.0f, Material.ARMADILLO_SCUTE, 1000), + GRAVITIC_ANOMALISER("Gravitic Anomaliser", new Vector(0.125d, 0.75d, 1.8d), 0.15f, 0.5f, 0, 0.0f, Material.ARMADILLO_SCUTE, 1001), + ABSOLUTE_TESSERACTULATOR("Absolute Tesseractulator", new Vector(-1.15d, 0.75d, 0.825d), 0.15f, 0.5f, 0, 60.0f, Material.ARMADILLO_SCUTE, 1002); private final String alternateName; private final Vector relativePosition; From f82a3a9bc3f31c5f1c80811204b9c582a5138f7b Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 29 Apr 2024 20:51:19 +1200 Subject: [PATCH 71/96] Fix some light level issues --- .../TARDIS/console/interaction/LightLevelInteraction.java | 8 ++++++++ .../listeners/controls/TARDISLightLevelFrameListener.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java index c5303188b..8761684ee 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LightLevelInteraction.java @@ -11,6 +11,7 @@ import org.bukkit.entity.Player; import org.bukkit.persistence.PersistentDataType; +import java.util.HashMap; import java.util.UUID; public class LightLevelInteraction { @@ -48,6 +49,13 @@ public void setInterior(int state, int id, Interaction interaction, Player playe new LightLevelAction(plugin).illuminate(setLevel - 1, rs.getControlId(), rs.isPowered(), 50, rs.isPoliceBox(), id, rs.isLightsOn()); new InteractionStateSaver(plugin).write("INTERIOR_LIGHT_LEVEL_SWITCH", setLevel, id); plugin.getMessenger().announceRepeater(player, "Light level: " + InteractionResponse.levels.get(setLevel)); + // set control record + HashMap set = new HashMap<>(); + set.put("secondary", setLevel); + HashMap where = new HashMap<>(); + where.put("tardis_id", id); + where.put("type", 50); + plugin.getQueryFactory().doSyncUpdate("controls", set, where); } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/controls/TARDISLightLevelFrameListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/controls/TARDISLightLevelFrameListener.java index 48ab5f9fd..f66290a43 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/controls/TARDISLightLevelFrameListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/controls/TARDISLightLevelFrameListener.java @@ -51,7 +51,7 @@ public void onLightLevelClick(PlayerInteractEntityEvent event) { if (!rs.isPowered()) { start += 1000; } - int limit = start + 3; + int limit = start + 7; ItemStack is = frame.getItem(); ItemMeta im = is.getItemMeta(); if (im.hasCustomModelData()) { From 2e48fe3fe43eddddfa31526d9db9059b8f86915a Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Tue, 30 Apr 2024 10:57:52 +1200 Subject: [PATCH 72/96] Fix Sonic Dock and Preset Storage Disk `/trecipe` display --- .../me/eccentric_nz/TARDIS/commands/TARDISRecipeCommands.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeCommands.java b/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeCommands.java index 89d78d09f..50cccc6d8 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeCommands.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeCommands.java @@ -380,10 +380,10 @@ private String getDisplayName(String recipe, int quartzCount) { case "TARDIS Invisibility Circuit", "Perception Filter" -> { return "Perception Circuit"; // 1978 } - case "Sonic Screwdriver", "Server Admin Circuit" -> { + case "Sonic Screwdriver", "Server Admin Circuit", "Sonic Dock" -> { return "Sonic Oscillator"; // 1967 } - case "Fob Watch" -> { + case "Fob Watch", "Preset Storage Disk" -> { return "TARDIS Chameleon Circuit"; // 1966 } case "TARDIS Biome Reader", "Emerald Upgrade" -> { From a43323b88d24d15f6a57f93fe178d2c80492f049 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Tue, 30 Apr 2024 11:26:32 +1200 Subject: [PATCH 73/96] Update BlockLocker dependency --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a03d918b6..f2d9d6afd 100644 --- a/pom.xml +++ b/pom.xml @@ -418,7 +418,7 @@ nl.rutgerkok blocklocker - 1.10.5-SNAPSHOT + 1.12.2 jar provided From 2bb330b5441ee0b43d82abcc2bd41753e96cadf6 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Tue, 30 Apr 2024 13:00:58 +1200 Subject: [PATCH 74/96] Update to 1.20.6 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f2d9d6afd..bf8041f91 100644 --- a/pom.xml +++ b/pom.xml @@ -254,7 +254,7 @@ io.papermc.paper paper-api - 1.20.5-R0.1-SNAPSHOT + 1.20.6-R0.1-SNAPSHOT provided @@ -278,7 +278,7 @@ org.spigotmc spigot - 1.20.5-R0.1-SNAPSHOT + 1.20.6-R0.1-SNAPSHOT remapped-mojang provided From 7cb5238b6cfaa82d4a7143b613f915c4089b8ef6 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Thu, 2 May 2024 19:09:21 +1200 Subject: [PATCH 75/96] Set centre of console --- .../TARDIS/console/ConsoleBuilder.java | 23 +++++++++++++++++-- .../interaction/FlightModeInteraction.java | 1 - .../console/models/ConsoleColourChanger.java | 7 +++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index 0d52db75f..470e5a3b2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -30,7 +30,7 @@ public ConsoleBuilder(TARDIS plugin) { public void create(Block block, int type, int id) { StringBuilder builder = new StringBuilder(); - String prefix = ""; + String prefix = "~"; Block up = block.getRelative(BlockFace.UP); // save the block location HashMap setb = new HashMap<>(); @@ -39,6 +39,9 @@ public void create(Block block, int type, int id) { setb.put("control", "CENTRE"); setb.put("state", 0); plugin.getQueryFactory().doInsert("interactions", setb); + // spawn a centre display item + UUID centre = spawnCentreDisplay(up.getLocation(), type); + builder.append(centre); for (int i = 0; i < 6; i++) { ItemStack shard = new ItemStack(Material.AMETHYST_SHARD); ItemMeta im = shard.getItemMeta(); @@ -50,7 +53,6 @@ public void create(Block block, int type, int id) { display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); UUID uuid = display.getUniqueId(); builder.append(prefix).append(uuid); - prefix = "~"; display.getPersistentDataContainer().set(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID(), uuid); display.setPersistent(true); display.setInvulnerable(true); @@ -166,4 +168,21 @@ private int getCmd(COMPASS direction) { } return cmd; } + + private UUID spawnCentreDisplay(Location up, int type) { + ItemStack shard = new ItemStack(Material.AMETHYST_SHARD); + ItemMeta im = shard.getItemMeta(); + int cmd = 3000 + type; + im.setCustomModelData(cmd); + im.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, cmd); + shard.setItemMeta(im); + ItemDisplay display = (ItemDisplay) up.getWorld().spawnEntity(up.add(0.5d, 0.25d, 0.5d), EntityType.ITEM_DISPLAY); + display.setItemStack(shard); + display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.HEAD); + UUID uuid = display.getUniqueId(); + display.getPersistentDataContainer().set(plugin.getInteractionUuidKey(), plugin.getPersistentDataTypeUUID(), uuid); + display.setPersistent(true); + display.setInvulnerable(true); + return uuid; + } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java index 9e6af154b..7cd4a5217 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/FlightModeInteraction.java @@ -53,7 +53,6 @@ public void process(Player player, int id, Interaction interaction) { ItemDisplay display = (ItemDisplay) plugin.getServer().getEntity(model); new FlightModeModel().setState(display, mode); } - // TODO make malfunction / manual classes } } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/models/ConsoleColourChanger.java b/src/main/java/me/eccentric_nz/TARDIS/console/models/ConsoleColourChanger.java index dc37c0c19..ce570a692 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/models/ConsoleColourChanger.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/models/ConsoleColourChanger.java @@ -36,7 +36,12 @@ public boolean paint() { ItemStack is = display.getItemStack(); if (is != null) { ItemMeta im = is.getItemMeta(); - int cmd = im.getCustomModelData() > 2000 ? 2000 : 1000; + int cmd = 1000; + if (im.getCustomModelData() > 3000) { + cmd = 3000; + } else if (im.getCustomModelData() > 2000) { + cmd = 2000; + } im.setCustomModelData(cmd + type); is.setItemMeta(im); display.setItemStack(is); From 7a6e99721f4dbab0876d98ee38a901de2c4a5c8f Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Fri, 3 May 2024 15:15:33 +1200 Subject: [PATCH 76/96] Time Rotor Console --- .../TARDIS/enumeration/RecipeItem.java | 1 + .../TARDIS/recipes/TARDISShapedRecipe.java | 1 + .../shaped/TimeRotorConsoleRecipe.java | 58 +++++++++++++++++++ .../rotors/TARDISCustomRotorLoader.java | 4 ++ todo.md | 2 - 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/TimeRotorConsoleRecipe.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeItem.java b/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeItem.java index 81dc82235..0ca8ee056 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeItem.java +++ b/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeItem.java @@ -74,6 +74,7 @@ public enum RecipeItem { TARDIS_TELEPATHIC_CIRCUIT(10000001, RecipeCategory.CONSOLE_CIRCUITS), TARDIS_TEMPORAL_CIRCUIT(10001974, RecipeCategory.CONSOLE_CIRCUITS), // rotors + TIME_ROTOR_CONSOLE(10000100, RecipeCategory.ROTORS), TIME_ROTOR_DELTA(10000006, RecipeCategory.ROTORS), TIME_ROTOR_EARLY(10000002, RecipeCategory.ROTORS), TIME_ENGINE(10000007, RecipeCategory.ROTORS), diff --git a/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISShapedRecipe.java b/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISShapedRecipe.java index b81514c33..193b030c5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISShapedRecipe.java +++ b/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISShapedRecipe.java @@ -106,6 +106,7 @@ public void addShapedRecipes() { new TARDISTemporalCircuitRecipe(plugin).addRecipe(); new ThreeDGlassesRecipe(plugin).addRecipe(); new TimeEngineRecipe(plugin).addRecipe(); + new TimeRotorConsoleRecipe(plugin).addRecipe(); new TimeRotorDeltaRecipe(plugin).addRecipe(); new TimeRotorEarlyRecipe(plugin).addRecipe(); new TimeRotorEleventhRecipe(plugin).addRecipe(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/TimeRotorConsoleRecipe.java b/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/TimeRotorConsoleRecipe.java new file mode 100644 index 000000000..4fb17c27a --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/recipes/shaped/TimeRotorConsoleRecipe.java @@ -0,0 +1,58 @@ +package me.eccentric_nz.TARDIS.recipes.shaped; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.enumeration.Difficulty; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ShapedRecipe; +import org.bukkit.inventory.meta.ItemMeta; + +/* +easy_shape:CRC,GWG,GRG +easy_ingredients.C:RED_DYE +easy_ingredients.R:REDSTONE +easy_ingredients.W:CLOCK +easy_ingredients.G:GLASS_PANE +hard_shape:CRC,GWG,GRG +hard_ingredients.C:RED_DYE +hard_ingredients.R:REDSTONE_BLOCK +hard_ingredients.W:CLOCK +hard_ingredients.G:GLASS_PANE +result:LIGHT_GRAY_DYE +amount:1 +*/ + +public class TimeRotorConsoleRecipe { + + private final TARDIS plugin; + + public TimeRotorConsoleRecipe(TARDIS plugin) { + this.plugin = plugin; + } + + public void addRecipe() { + ItemStack is = new ItemStack(Material.LIGHT_GRAY_DYE, 1); + ItemMeta im = is.getItemMeta(); + im.setDisplayName("Time Rotor Console"); + im.setCustomModelData(10000100); + is.setItemMeta(im); + NamespacedKey key = new NamespacedKey(plugin, "time_rotor_console"); + ShapedRecipe r = new ShapedRecipe(key, is); + if (plugin.getDifficulty() == Difficulty.HARD) { + r.shape("CRC", "GWG", "GRG"); + r.setIngredient('C', Material.RED_DYE); + r.setIngredient('R', Material.REDSTONE_BLOCK); + r.setIngredient('W', Material.CLOCK); + r.setIngredient('G', Material.GLASS_PANE); + } else { + r.shape("CRC", "GWG", "GRG"); + r.setIngredient('C', Material.RED_DYE); + r.setIngredient('R', Material.REDSTONE); + r.setIngredient('W', Material.CLOCK); + r.setIngredient('G', Material.GLASS_PANE); + } + plugin.getServer().addRecipe(r); + plugin.getFigura().getShapedRecipes().put("Time Rotor Console", r); + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/rotors/TARDISCustomRotorLoader.java b/src/main/java/me/eccentric_nz/TARDIS/rotors/TARDISCustomRotorLoader.java index c72ff1495..5f5573b48 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/rotors/TARDISCustomRotorLoader.java +++ b/src/main/java/me/eccentric_nz/TARDIS/rotors/TARDISCustomRotorLoader.java @@ -36,6 +36,7 @@ public void addRotors() { // create plugin rotors Rotor early = new Rotor("early", 10000002, Material.BLACK_DYE, new int[]{0, 1, 2, 3, 4, 5, 6, 7}, 6, false); Rotor rotor = new Rotor("rotor", 10000003, Material.ORANGE_DYE, new int[]{0, 0, 1, 2, 3, 4, 3, 2, 1}, 3, false); + Rotor console = new Rotor("console", 10000100, Material.RED_DYE, new int[]{0, 0, 1, 2, 3, 4, 3, 2, 1}, 2, false); Rotor copper = new Rotor("copper", 10000004, Material.BROWN_DYE, new int[]{0, 0, 1, 2, 3, 4, 3, 2, 1}, 2, false); Rotor round = new Rotor("round", 10000005, Material.GRAY_DYE, new int[]{0}, 1, false); Rotor delta = new Rotor("delta", 10000006, Material.CYAN_DYE, new int[]{0, 1, 2, 3, 4, 5}, 4, false); @@ -49,6 +50,9 @@ public void addRotors() { Rotor.byMaterial.put(Material.ORANGE_DYE, rotor); Rotor.byCustomModelData.put(10000003, rotor); Rotor.byName.put("TIME_ROTOR_ROTOR", rotor); + Rotor.byMaterial.put(Material.RED_DYE, console); + Rotor.byCustomModelData.put(10000100, console); + Rotor.byName.put("TIME_ROTOR_CONSOLE", console); Rotor.byMaterial.put(Material.BROWN_DYE, copper); Rotor.byCustomModelData.put(10000004, copper); Rotor.byName.put("TIME_ROTOR_COPPER", copper); diff --git a/todo.md b/todo.md index 6467b4457..d857ed494 100644 --- a/todo.md +++ b/todo.md @@ -7,8 +7,6 @@ 3. Custom Control models [#703](https://github.com/eccentricdevotion/TARDIS/issues/703) [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) * New interior with console - * Regular handbrake needs to check console flight mode - * Alter console side model inner edge / make new time rotor for console * Alter the position of the control label based on the angle of the panel the control is on 4. Update old light level controls, and light switch should return to correct level 5. ? From 455effcc61ca8a64b76bcc4a6fda98512b5df1a0 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Fri, 3 May 2024 16:35:08 +1200 Subject: [PATCH 77/96] Fix saving sonic configuration in the generator --- .../commands/tardis/TARDISUpdateCommand.java | 4 +- .../sonic/TARDISSonicActivatorListener.java | 2 +- .../sonic/TARDISSonicGeneratorInventory.java | 3 +- .../sonic/TARDISSonicGeneratorListener.java | 72 +++++++++---------- .../TARDISSonicGeneratorMenuListener.java | 12 +--- todo.md | 2 + 6 files changed, 41 insertions(+), 54 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISUpdateCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISUpdateCommand.java index 175c3c19d..c3e97017a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISUpdateCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/tardis/TARDISUpdateCommand.java @@ -21,7 +21,6 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISConstants; import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; -import me.eccentric_nz.TARDIS.rotors.TARDISTimeRotor; import me.eccentric_nz.TARDIS.commands.sudo.TARDISSudoTracker; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayBlockConverter; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayBlockRoomConverter; @@ -36,6 +35,7 @@ import me.eccentric_nz.TARDIS.enumeration.Updateable; import me.eccentric_nz.TARDIS.messaging.TARDISUpdateLister; import me.eccentric_nz.TARDIS.monitor.MonitorUtils; +import me.eccentric_nz.TARDIS.rotors.TARDISTimeRotor; import me.eccentric_nz.TARDIS.update.TARDISUpdateBlocks; import me.eccentric_nz.TARDIS.update.TARDISUpdateableChecker; import me.eccentric_nz.TARDIS.utility.TARDISStringUtils; @@ -188,8 +188,6 @@ boolean startUpdate(Player player, String[] args) { im.setDisplayName("Monitor Frame"); glass.setItemMeta(im); } - default -> { - } } if (itemFrame != null) { TARDISTimeRotor.unlockItemFrame(itemFrame); diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicActivatorListener.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicActivatorListener.java index 34bb46918..c071e9452 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicActivatorListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicActivatorListener.java @@ -103,7 +103,7 @@ private void save(Player p, InventoryView view) { } close(p); if (count == stacks.size()) { - // actvate Sonic Generator + // activate Sonic Generator String uuid = p.getUniqueId().toString(); // do they have a sonic record? HashMap wheres = new HashMap<>(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorInventory.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorInventory.java index 0535e5710..f9bfa0d71 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorInventory.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorInventory.java @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; /** @@ -80,7 +79,7 @@ private ItemStack[] getItemStack() { ItemStack info = new ItemStack(Material.BOOK, 1); ItemMeta info_im = info.getItemMeta(); info_im.setDisplayName("Instructions (1/3)"); - List lore = Arrays.asList("Select your Sonic Screwdriver", "type from the top three rows.", "Click on the upgrades you", "want to add to the sonic."); + List lore = Arrays.asList("Select your Sonic Screwdriver", "type from the top two rows.", "Click on the upgrades you", "want to add to the sonic."); info_im.setLore(lore); info_im.setCustomModelData(GUISonicGenerator.INSTRUCTIONS_1_OF_3.getCustomModelData()); info.setItemMeta(info_im); diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorListener.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorListener.java index 1d0af3a6d..068ec8974 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorListener.java @@ -76,34 +76,32 @@ public void onInteract(PlayerInteractEvent event) { where.put("type", 24); where.put("location", location); ResultSetControls rsc = new ResultSetControls(plugin, where, false); - if (rsc.resultSet()) { - if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { - Player player = event.getPlayer(); - UUID uuid = player.getUniqueId(); - // check if the generator is activated - HashMap wheres = new HashMap<>(); - wheres.put("uuid", uuid.toString()); - ResultSetSonic rss = new ResultSetSonic(plugin, wheres); - if (rss.resultSet()) { - Sonic s = rss.getSonic(); - if (s.isActivated()) { - if (player.isSneaking()) { - // generate sonic - generate(player, block.getLocation(), s); - } else { - // open GUI - ItemStack[] items = new TARDISSonicGeneratorInventory(plugin, s, player).getGenerator(); - Inventory sgc = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "Sonic Generator"); - sgc.setContents(items); - plugin.getTrackerKeeper().getSonicGenerators().put(uuid, block.getLocation()); - player.openInventory(sgc); - } + if (rsc.resultSet() && event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { + Player player = event.getPlayer(); + UUID uuid = player.getUniqueId(); + // check if the generator is activated + HashMap wheres = new HashMap<>(); + wheres.put("uuid", uuid.toString()); + ResultSetSonic rss = new ResultSetSonic(plugin, wheres); + if (rss.resultSet()) { + Sonic s = rss.getSonic(); + if (s.isActivated()) { + if (player.isSneaking()) { + // generate sonic + generate(player, block.getLocation(), s); } else { - openActivate(player); + // open GUI + ItemStack[] items = new TARDISSonicGeneratorInventory(plugin, s, player).getGenerator(); + Inventory sgc = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "Sonic Generator"); + sgc.setContents(items); + plugin.getTrackerKeeper().getSonicGenerators().put(uuid, block.getLocation()); + player.openInventory(sgc); } } else { openActivate(player); } + } else { + openActivate(player); } } } @@ -208,21 +206,19 @@ public void onSonicGeneratorBreak(BlockBreakEvent event) { HashMap wheres = new HashMap<>(); wheres.put("uuid", event.getPlayer().getUniqueId().toString()); ResultSetSonic rss = new ResultSetSonic(plugin, wheres); - if (rss.resultSet()) { - if (rss.getSonic().isActivated()) { - event.setCancelled(true); - // remove Item Display - TARDISDisplayItemUtils.remove(b); - // set block to AIR - b.setBlockData(TARDISConstants.AIR); - // drop a custom FLOWER_POT_ITEM - ItemStack is = new ItemStack(Material.FLOWER_POT, 1); - ItemMeta im = is.getItemMeta(); - im.setDisplayName("Sonic Generator"); - im.setCustomModelData(10000001); - is.setItemMeta(im); - b.getWorld().dropItemNaturally(b.getLocation(), is); - } + if (rss.resultSet() && rss.getSonic().isActivated()) { + event.setCancelled(true); + // remove Item Display + TARDISDisplayItemUtils.remove(b); + // set block to AIR + b.setBlockData(TARDISConstants.AIR); + // drop a custom FLOWER_POT_ITEM + ItemStack is = new ItemStack(Material.FLOWER_POT, 1); + ItemMeta im = is.getItemMeta(); + im.setDisplayName("Sonic Generator"); + im.setCustomModelData(10000001); + is.setItemMeta(im); + b.getWorld().dropItemNaturally(b.getLocation(), is); } } diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorMenuListener.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorMenuListener.java index 050b95f5c..23312269f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorMenuListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/TARDISSonicGeneratorMenuListener.java @@ -119,12 +119,10 @@ public void onGeneratorMenuClick(InventoryClickEvent event) { sonic = new ItemStack(Material.BLAZE_ROD, 1); slotWasNull = true; } - // get Display name of selected sonic + // get custom model data of selected sonic ItemStack choice = view.getItem(slot); ItemMeta choice_im = choice.getItemMeta(); - String choice_name = choice_im.getDisplayName(); sonic_im = sonic.getItemMeta(); - sonic_im.setDisplayName(choice_name); sonic_im.setCustomModelData(choice_im.getCustomModelData()); sonic.setItemMeta(sonic_im); if (slotWasNull) { @@ -209,14 +207,8 @@ private void save(Player p, ItemStack is, boolean close) { HashMap set = new HashMap<>(); HashMap where = new HashMap<>(); where.put("uuid", p.getUniqueId().toString()); + where.put("activated", 1); ItemMeta im = is.getItemMeta(); - String dn = im.getDisplayName(); - // get ChatColor from display name - String colour = ""; - if (!dn.startsWith("Sonic")) { - colour = ChatColor.getByChar(dn.substring(1, 2)).name(); - } - set.put("sonic_type", colour); set.put("model", im.getCustomModelData()); if (im.hasLore()) { List lore = im.getLore(); diff --git a/todo.md b/todo.md index d857ed494..f43cfbe65 100644 --- a/todo.md +++ b/todo.md @@ -8,6 +8,8 @@ [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) * New interior with console * Alter the position of the control label based on the angle of the panel the control is on + * Fix monitor text display position? + * Set throttle/flight mode/direction position when building console 4. Update old light level controls, and light switch should return to correct level 5. ? From 660377637d93140af16034dd32f6281f5e8c3d54 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Fri, 3 May 2024 21:01:49 +1200 Subject: [PATCH 78/96] Fix console labels --- .../eccentric_nz/TARDIS/console/interaction/LabelAction.java | 5 ++--- todo.md | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LabelAction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LabelAction.java index 0be2eb786..e2bbfd1d8 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LabelAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/LabelAction.java @@ -48,15 +48,14 @@ public void toggle(int id, boolean on) { } private void spawnTextDisplay(Location centre, ConsoleInteraction ci) { - double half = ci.getWidth() / 2.0d; - Location spawn = centre.clone().add(ci.getRelativePosition().getX() - half, ci.getRelativePosition().getY() + ci.getHeight(), ci.getRelativePosition().getZ() - half); + float h = (ci == ConsoleInteraction.WORLD) ? 0.15f : 0; + Location spawn = centre.clone().add(ci.getRelativePosition().getX(), ci.getRelativePosition().getY() + ci.getHeight() + h, ci.getRelativePosition().getZ()); TextDisplay display = (TextDisplay) centre.getWorld().spawnEntity(spawn, EntityType.TEXT_DISPLAY); display.setText(ci.getAlternateName()); display.setBackgroundColor(Color.BLACK); display.setRotation(Location.normalizeYaw(ci.getYaw()), 0.0f); display.setTransformation(transformation); display.setBillboard(Display.Billboard.FIXED); - display.setSeeThrough(true); } private void removeTextDisplay(Location centre) { diff --git a/todo.md b/todo.md index f43cfbe65..fab5a4172 100644 --- a/todo.md +++ b/todo.md @@ -7,7 +7,6 @@ 3. Custom Control models [#703](https://github.com/eccentricdevotion/TARDIS/issues/703) [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) * New interior with console - * Alter the position of the control label based on the angle of the panel the control is on * Fix monitor text display position? * Set throttle/flight mode/direction position when building console 4. Update old light level controls, and light switch should return to correct level From 6bd39b20a55ed7aad1e9cbecb9e67acce9b5df56 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Fri, 3 May 2024 21:57:54 +1200 Subject: [PATCH 79/96] Fix screen text display --- .../java/me/eccentric_nz/TARDIS/console/ControlMonitor.java | 4 +++- .../TARDIS/console/interaction/ScreenInteraction.java | 2 +- todo.md | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java b/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java index 30bf46823..8b6b4d90c 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ControlMonitor.java @@ -9,6 +9,7 @@ import me.eccentric_nz.TARDIS.planets.TARDISAliasResolver; import me.eccentric_nz.TARDIS.utility.TARDISStaticUtils; import net.md_5.bungee.api.ChatColor; +import org.bukkit.Color; import org.bukkit.entity.Display; import org.bukkit.entity.Entity; import org.bukkit.entity.TextDisplay; @@ -48,7 +49,8 @@ public void update(int id, UUID uuid, boolean coords) { } textDisplay.setTransformation(transformation); textDisplay.setBillboard(Display.Billboard.FIXED); - textDisplay.setSeeThrough(true); + textDisplay.setBackgroundColor(Color.fromRGB(8, 10, 15)); + textDisplay.setSeeThrough(false); // get text ResultSetConsole rsc = new ResultSetConsole(plugin, id); StringBuilder builder = new StringBuilder(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java index 2129ed299..72b7c6132 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/interaction/ScreenInteraction.java @@ -31,7 +31,7 @@ public void display(int id, Interaction interaction, boolean coords, Player play // get the text display TextDisplay display = getTextDisplay(interaction.getLocation(), coords); if (display != null) { - display.setRotation(Location.normalizeYaw(120), -10f); + display.setRotation(Location.normalizeYaw(120), -7.5f); new ControlMonitor(plugin).update(id, display.getUniqueId(), coords); } } else { diff --git a/todo.md b/todo.md index fab5a4172..9ac19dd75 100644 --- a/todo.md +++ b/todo.md @@ -7,7 +7,6 @@ 3. Custom Control models [#703](https://github.com/eccentricdevotion/TARDIS/issues/703) [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) * New interior with console - * Fix monitor text display position? * Set throttle/flight mode/direction position when building console 4. Update old light level controls, and light switch should return to correct level 5. ? From 73fd264d789377530f9230ff08441a229dce7acf Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sat, 4 May 2024 21:17:03 +1200 Subject: [PATCH 80/96] Stop using deprecated WorldEdit methods --- .../preferences/TARDISBuildCommand.java | 7 ++++--- .../TARDIS/files/TARDISBlockLoader.java | 17 +++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISBuildCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISBuildCommand.java index 3081c3854..d90c36bab 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISBuildCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/preferences/TARDISBuildCommand.java @@ -17,7 +17,6 @@ package me.eccentric_nz.TARDIS.commands.preferences; import com.sk89q.worldguard.protection.regions.ProtectedRegion; -import java.util.HashMap; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.database.data.Tardis; import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; @@ -26,6 +25,8 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import java.util.HashMap; + /** * @author eccentric_nz */ @@ -71,8 +72,8 @@ boolean toggleCompanionBuilding(Player player, String[] args) { plugin.getMessenger().send(player, TardisModule.TARDIS, "WG_NOT_FOUND"); return true; } - Vector min = new Vector(pr.getMinimumPoint().getBlockX(), pr.getMinimumPoint().getBlockY(), pr.getMinimumPoint().getBlockZ()); - Vector max = new Vector(pr.getMaximumPoint().getBlockX(), pr.getMaximumPoint().getBlockY(), pr.getMaximumPoint().getBlockZ()); + Vector min = new Vector(pr.getMinimumPoint().x(), pr.getMinimumPoint().y(), pr.getMinimumPoint().z()); + Vector max = new Vector(pr.getMaximumPoint().x(), pr.getMaximumPoint().y(), pr.getMaximumPoint().z()); tab.setMin(min); tab.setMax(max); tab.setTimelord(playerNameStr); diff --git a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISBlockLoader.java b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISBlockLoader.java index e3bfe0e87..f32589a39 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISBlockLoader.java +++ b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISBlockLoader.java @@ -17,12 +17,6 @@ package me.eccentric_nz.TARDIS.files; import com.sk89q.worldguard.protection.regions.ProtectedRegion; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.HashMap; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.database.TARDISDatabaseConnection; import me.eccentric_nz.TARDIS.database.resultset.ResultSetBlocks; @@ -31,6 +25,13 @@ import me.eccentric_nz.TARDIS.utility.TARDISNumberParsers; import org.bukkit.util.Vector; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.HashMap; + /** * An anti-gravity spiral is a projectable beam used for removing gravity from an object. The Seventh Doctor used his * TARDIS to project a beam around a bus in space after it crashed. He manoeuvred it down to Earth and dropped it @@ -123,8 +124,8 @@ public void loadAntiBuild() { String[] split = rs.getString("chunk").split(":"); ProtectedRegion pr = plugin.getWorldGuardUtils().getRegion(split[0], tl); if (pr != null) { - Vector min = new Vector(pr.getMinimumPoint().getBlockX(), pr.getMinimumPoint().getBlockY(), pr.getMinimumPoint().getBlockZ()); - Vector max = new Vector(pr.getMaximumPoint().getBlockX(), pr.getMaximumPoint().getBlockY(), pr.getMaximumPoint().getBlockZ()); + Vector min = new Vector(pr.getMinimumPoint().x(), pr.getMinimumPoint().y(), pr.getMinimumPoint().z()); + Vector max = new Vector(pr.getMaximumPoint().x(), pr.getMaximumPoint().y(), pr.getMaximumPoint().z()); tab.setMin(min); tab.setMax(max); tab.setTimelord(tl); From ee80355c25944384cb6d06002319228c0172caf9 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sat, 4 May 2024 21:24:01 +1200 Subject: [PATCH 81/96] Compile using release 21 --- pom.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index bf8041f91..48acb2160 100644 --- a/pom.xml +++ b/pom.xml @@ -151,15 +151,14 @@ maven-compiler-plugin 3.13.0 - 21 - 21 + 21 ${project.build.sourceEncoding} net.md-5 specialsource-maven-plugin - 2.0.2 + 2.0.3 package From 411b694aba84ab655dc9be4f6af1252b96a03b13 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sat, 4 May 2024 21:32:29 +1200 Subject: [PATCH 82/96] Remapping should use 1.20.6 --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 48acb2160..bcab6c53a 100644 --- a/pom.xml +++ b/pom.xml @@ -167,9 +167,9 @@ remap-obf - org.spigotmc:minecraft-server:1.20.5-R0.1-SNAPSHOT:txt:maps-mojang + org.spigotmc:minecraft-server:1.20.6-R0.1-SNAPSHOT:txt:maps-mojang true - org.spigotmc:spigot:1.20.5-R0.1-SNAPSHOT:jar:remapped-mojang + org.spigotmc:spigot:1.20.6-R0.1-SNAPSHOT:jar:remapped-mojang true remapped-obf @@ -185,8 +185,8 @@ ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.20.5-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.20.5-R0.1-SNAPSHOT:jar:remapped-obf + org.spigotmc:minecraft-server:1.20.6-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.20.6-R0.1-SNAPSHOT:jar:remapped-obf From 75d1518347785e320f9cdf4564d762a4a4a4483d Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sat, 4 May 2024 21:33:50 +1200 Subject: [PATCH 83/96] Require 1.20.6 --- src/main/java/me/eccentric_nz/TARDIS/TARDIS.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java b/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java index 35131b789..d53bda916 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java +++ b/src/main/java/me/eccentric_nz/TARDIS/TARDIS.java @@ -140,7 +140,7 @@ public class TARDIS extends JavaPlugin { private final HashMap versions = new HashMap<>(); private final String versionRegex = "(\\d+[.])+\\d+"; private final Pattern versionPattern = Pattern.compile(versionRegex); - private final String serverStr = "1.20.5"; + private final String serverStr = "1.20.6"; private TARDISChatGUI jsonKeeper; private TARDISUpdateChatGUI updateChatGUI; // public TARDISFurnaceRecipe fornacis; From 17dba79ea59611cce7434f495f27be29399738bf Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sat, 4 May 2024 21:36:56 +1200 Subject: [PATCH 84/96] More 1.20.6 --- src/main/java/me/eccentric_nz/TARDIS/utility/TARDISChecker.java | 2 +- .../me/eccentric_nz/TARDIS/utility/TARDISUpdateChecker.java | 2 +- src/main/resources/plugin.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISChecker.java b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISChecker.java index d5cf4e19d..efa73d46e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISChecker.java +++ b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISChecker.java @@ -90,7 +90,7 @@ public void checkAdvancements() { copy("pack.mcmeta", mcmeta); write(dataPacksRoot, false); } else { - // update the format - 41 is the latest for 1.20.5 + // update the format - 41 is the latest for 1.20.6 // it's a json file, so load it and check the value Gson gson = new GsonBuilder().create(); try { diff --git a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISUpdateChecker.java b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISUpdateChecker.java index b72c3c9f5..711b558d3 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISUpdateChecker.java +++ b/src/main/java/me/eccentric_nz/TARDIS/utility/TARDISUpdateChecker.java @@ -161,7 +161,7 @@ private String getLastestServerVersion() { org.spigotmc spigot - 1.20.5-R0.1-SNAPSHOT + 1.20.6-R0.1-SNAPSHOT */ NodeList list = doc.getElementsByTagName("dependencies"); Node root = list.item(0); // there's only one node diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a8f7e9cf9..93e809f62 100755 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -9,7 +9,7 @@ dev-url: http://github.com/eccentricdevotion/TARDIS/ url: http://tardis.pages.dev/ version: ${project.version}-b${project.build.number} build-number: ${project.build.number} -api-version: '1.20.5' +api-version: '1.20.6' libraries: - org.jsoup:jsoup:1.16.1 permissions: From ea725f7b2e894617c44bf03c3d56269ad88d9cd8 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Sat, 4 May 2024 21:38:19 +1200 Subject: [PATCH 85/96] Update TWAFollower.java --- .../me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java index b347744f1..eec9493e0 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java @@ -62,7 +62,8 @@ protected void registerGoals() { @Override protected void defineSynchedData(SynchedEntityData.Builder datawatcher) { super.defineSynchedData(datawatcher); - this.entityData.set(DATA_OWNER_UUID_ID, Optional.empty()); + datawatcher.define(DATA_OWNER_UUID_ID, Optional.empty()); +// this.entityData.set(DATA_OWNER_UUID_ID, Optional.empty()); } @Nullable From 360e716086bc3175a734c5b2cbbe464ca89a38cb Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Sun, 5 May 2024 12:29:28 +1200 Subject: [PATCH 86/96] Try to fix custom TWA followers --- .../tardisweepingangels/nms/TWAFollower.java | 58 ++++++++++++++++--- src/main/resources/plugin.yml | 2 +- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java index eec9493e0..120e165fb 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java @@ -3,9 +3,11 @@ import net.minecraft.core.Holder; import net.minecraft.core.MappedRegistry; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.players.OldUsersConverter; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.OwnableEntity; @@ -26,7 +28,8 @@ public class TWAFollower extends Husk implements OwnableEntity { - protected static final EntityDataAccessor> DATA_OWNER_UUID_ID = SynchedEntityData.defineId(TWAFollower.class, EntityDataSerializers.OPTIONAL_UUID); + protected static final EntityDataAccessor DATA_FLAGS_ID = SynchedEntityData.defineId(TWAFollower.class, EntityDataSerializers.BYTE); + protected static final EntityDataAccessor> DATA_OWNERUUID_ID = SynchedEntityData.defineId(TWAFollower.class, EntityDataSerializers.OPTIONAL_UUID); protected final int[] frames = new int[]{0, 1, 2, 1, 0, 3, 4, 3}; protected UUID uuid; protected boolean isAnimating = false; @@ -58,23 +61,23 @@ protected void registerGoals() { this.goalSelector.addGoal(10, new RandomLookAroundGoal(this)); } - @Override protected void defineSynchedData(SynchedEntityData.Builder datawatcher) { super.defineSynchedData(datawatcher); - datawatcher.define(DATA_OWNER_UUID_ID, Optional.empty()); -// this.entityData.set(DATA_OWNER_UUID_ID, Optional.empty()); + datawatcher.define(TWAFollower.DATA_FLAGS_ID, (byte) 0); + datawatcher.define(TWAFollower.DATA_OWNERUUID_ID, Optional.empty()); } @Nullable @Override + @SuppressWarnings("unchecked") public UUID getOwnerUUID() { - return (UUID) ((Optional) this.entityData.get(DATA_OWNER_UUID_ID)).orElse(null); + return (UUID) ((Optional) this.entityData.get(DATA_OWNERUUID_ID)).orElse(null); } public void setOwnerUUID(@Nullable UUID uuid) { - this.uuid = uuid; - this.entityData.set(DATA_OWNER_UUID_ID, Optional.ofNullable(uuid)); + this.setTame(true); + this.entityData.set(DATA_OWNERUUID_ID, Optional.ofNullable(uuid)); } @Nullable @@ -87,6 +90,47 @@ public LivingEntity getOwner() { return (player != null) ? ((CraftPlayer) player).getHandle() : null; } + @Override + public void addAdditionalSaveData(CompoundTag tag) { + super.addAdditionalSaveData(tag); + if (this.getOwnerUUID() != null) { + tag.putUUID("Owner", this.getOwnerUUID()); + } + } + + @Override + public void readAdditionalSaveData(CompoundTag tag) { + super.readAdditionalSaveData(tag); + UUID uuid; + if (tag.hasUUID("Owner")) { + uuid = tag.getUUID("Owner"); + } else { + String s = tag.getString("Owner"); + uuid = OldUsersConverter.convertMobOwnerIfNecessary(this.getServer(), s); + } + if (uuid != null) { + try { + this.setOwnerUUID(uuid); + this.setTame(true); + } catch (Throwable throwable) { + this.setTame(false); + } + } + } + + public boolean isTame() { + return (this.entityData.get(TWAFollower.DATA_FLAGS_ID) & 4) != 0; + } + + public void setTame(boolean tame) { + byte b0 = this.entityData.get(TWAFollower.DATA_FLAGS_ID); + if (tame) { + this.entityData.set(TWAFollower.DATA_FLAGS_ID, (byte) (b0 | 4)); + } else { + this.entityData.set(TWAFollower.DATA_FLAGS_ID, (byte) (b0 & -5)); + } + } + public boolean isFollowing() { return following; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 93e809f62..a8f7e9cf9 100755 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -9,7 +9,7 @@ dev-url: http://github.com/eccentricdevotion/TARDIS/ url: http://tardis.pages.dev/ version: ${project.version}-b${project.build.number} build-number: ${project.build.number} -api-version: '1.20.6' +api-version: '1.20.5' libraries: - org.jsoup:jsoup:1.16.1 permissions: From 4429e1c780318e0fbc6fd3aa2594d8b8dc2934fd Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sun, 5 May 2024 22:24:20 +1200 Subject: [PATCH 87/96] Weeping Angel followers --- .../TARDISWeepingAngels.java | 2 + .../monsters/ood/OodListener.java | 9 +-- .../nms/EntityRegistry.java | 64 +++++++++++++++++++ .../tardisweepingangels/nms/TWAFollower.java | 63 +++++------------- .../tardisweepingangels/nms/TWAJudoon.java | 28 -------- .../tardisweepingangels/nms/TWAK9.java | 28 -------- .../tardisweepingangels/nms/TWAOod.java | 28 -------- .../utils/ChunkListener.java | 32 +++++----- 8 files changed, 105 insertions(+), 149 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/tardisweepingangels/nms/EntityRegistry.java diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/TARDISWeepingAngels.java b/src/main/java/me/eccentric_nz/tardisweepingangels/TARDISWeepingAngels.java index 804d36bd2..7667a256c 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/TARDISWeepingAngels.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/TARDISWeepingAngels.java @@ -55,6 +55,7 @@ import me.eccentric_nz.tardisweepingangels.monsters.vashta_nerada.VashtaNeradaListener; import me.eccentric_nz.tardisweepingangels.monsters.weeping_angels.*; import me.eccentric_nz.tardisweepingangels.monsters.zygons.ZygonRunnable; +import me.eccentric_nz.tardisweepingangels.nms.EntityRegistry; import me.eccentric_nz.tardisweepingangels.utils.*; import org.bukkit.NamespacedKey; import org.bukkit.persistence.PersistentDataType; @@ -134,6 +135,7 @@ public static List getPlayersWithGuards() { } public void enable() { + new EntityRegistry().init(); citizensEnabled = plugin.getPM().isPluginEnabled("Citizens"); // TODO add TWA api to TARDIS API api = new MonsterEquipment(); diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/ood/OodListener.java b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/ood/OodListener.java index 4c16437b8..f5eea2ff5 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/ood/OodListener.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/monsters/ood/OodListener.java @@ -53,17 +53,18 @@ public void onDamageOod(EntityDamageByEntityEvent event) { if (player.getUniqueId().equals(oodId)) { // set redeye ood.setRedeye(!ood.isRedeye()); - ood.getOwnerUUID(); +// ood.getOwnerUUID(); } else if (TARDISWeepingAngels.UNCLAIMED.equals(oodId)) { // claim the Ood UUID pid = player.getUniqueId(); entity.getPersistentDataContainer().set(TARDISWeepingAngels.OWNER_UUID, TARDISWeepingAngels.PersistentDataTypeUUID, pid); plugin.getMessenger().send(player, TardisModule.MONSTERS, "WA_CLAIMED", "Ood"); ood.setOwnerUUID(pid); - ood.getOwnerUUID(); - } else { - ood.getOwnerUUID(); +// ood.getOwnerUUID(); } +// else { +// ood.getOwnerUUID(); +// } } } } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/EntityRegistry.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/EntityRegistry.java new file mode 100644 index 000000000..6a617509b --- /dev/null +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/EntityRegistry.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2024 eccentric_nz + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with plugin program. If not, see . + */ +package me.eccentric_nz.tardisweepingangels.nms; + +import com.mojang.datafixers.DataFixUtils; +import com.mojang.datafixers.types.Type; +import net.minecraft.SharedConstants; +import net.minecraft.core.Holder; +import net.minecraft.core.MappedRegistry; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.datafix.DataFixers; +import net.minecraft.util.datafix.fixes.References; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.MobCategory; + +import java.lang.reflect.Field; +import java.util.IdentityHashMap; +import java.util.Map; + +public class EntityRegistry { + + private final String[] all = new String[]{"judoon", "ood", "k9"}; + + public static void unfreezeEntityRegistry() throws NoSuchFieldException, IllegalAccessException { + Field unregisteredIntrusiveHolders = MappedRegistry.class.getDeclaredField("m"); + unregisteredIntrusiveHolders.setAccessible(true); + unregisteredIntrusiveHolders.set(BuiltInRegistries.ENTITY_TYPE, new IdentityHashMap, Holder.Reference>>()); + Field frozen = MappedRegistry.class.getDeclaredField("l"); + frozen.setAccessible(true); + frozen.set(BuiltInRegistries.ENTITY_TYPE, false); + } + + public void init() { + try { + unfreezeEntityRegistry(); + for (String ENTITY_ID : all) { + ResourceLocation mcKey = new ResourceLocation(ENTITY_ID); + if (BuiltInRegistries.ENTITY_TYPE.getOptional(mcKey).isEmpty()) { + @SuppressWarnings("unchecked") Map> types = (Map>) DataFixers.getDataFixer().getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().getDataVersion().getVersion())).findChoiceType(References.ENTITY).types(); + types.put(mcKey.toString(), types.get(BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.HUSK).toString())); + Registry.register(BuiltInRegistries.ENTITY_TYPE, ENTITY_ID, EntityType.Builder.of(EntityType::create, MobCategory.MONSTER).noSummon().build(ENTITY_ID)); + } + } + BuiltInRegistries.ENTITY_TYPE.freeze(); + } catch (NoSuchFieldException | IllegalAccessException ignore) { + } + } +} diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java index 120e165fb..d2a61c934 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java @@ -1,8 +1,6 @@ package me.eccentric_nz.tardisweepingangels.nms; -import net.minecraft.core.Holder; -import net.minecraft.core.MappedRegistry; -import net.minecraft.core.registries.BuiltInRegistries; +import me.eccentric_nz.tardisweepingangels.TARDISWeepingAngels; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; @@ -21,8 +19,6 @@ import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer; import org.jetbrains.annotations.Nullable; -import java.lang.reflect.Field; -import java.util.IdentityHashMap; import java.util.Optional; import java.util.UUID; @@ -43,15 +39,6 @@ public TWAFollower(Level world, UUID owner) { setOwnerUUID(this.uuid); } - public static void unfreezeEntityRegistry() throws NoSuchFieldException, IllegalAccessException { - Field unregisteredIntrusiveHolders = MappedRegistry.class.getDeclaredField("m"); - unregisteredIntrusiveHolders.setAccessible(true); - unregisteredIntrusiveHolders.set(BuiltInRegistries.ENTITY_TYPE, new IdentityHashMap, Holder.Reference>>()); - Field frozenField = MappedRegistry.class.getDeclaredField("l"); - frozenField.setAccessible(true); - frozenField.set(BuiltInRegistries.ENTITY_TYPE, false); - } - @Override protected void registerGoals() { this.goalSelector.addGoal(1, new FloatGoal(this)); @@ -68,28 +55,6 @@ protected void defineSynchedData(SynchedEntityData.Builder datawatcher) { datawatcher.define(TWAFollower.DATA_OWNERUUID_ID, Optional.empty()); } - @Nullable - @Override - @SuppressWarnings("unchecked") - public UUID getOwnerUUID() { - return (UUID) ((Optional) this.entityData.get(DATA_OWNERUUID_ID)).orElse(null); - } - - public void setOwnerUUID(@Nullable UUID uuid) { - this.setTame(true); - this.entityData.set(DATA_OWNERUUID_ID, Optional.ofNullable(uuid)); - } - - @Nullable - @Override - public LivingEntity getOwner() { - if (uuid == null) { - return null; - } - org.bukkit.entity.Player player = Bukkit.getPlayer(uuid); - return (player != null) ? ((CraftPlayer) player).getHandle() : null; - } - @Override public void addAdditionalSaveData(CompoundTag tag) { super.addAdditionalSaveData(tag); @@ -111,24 +76,30 @@ public void readAdditionalSaveData(CompoundTag tag) { if (uuid != null) { try { this.setOwnerUUID(uuid); - this.setTame(true); } catch (Throwable throwable) { - this.setTame(false); } } } - public boolean isTame() { - return (this.entityData.get(TWAFollower.DATA_FLAGS_ID) & 4) != 0; + @Nullable + @Override + @SuppressWarnings("unchecked") + public UUID getOwnerUUID() { + return this.getBukkitEntity().getPersistentDataContainer().get(TARDISWeepingAngels.OWNER_UUID, TARDISWeepingAngels.PersistentDataTypeUUID); } - public void setTame(boolean tame) { - byte b0 = this.entityData.get(TWAFollower.DATA_FLAGS_ID); - if (tame) { - this.entityData.set(TWAFollower.DATA_FLAGS_ID, (byte) (b0 | 4)); - } else { - this.entityData.set(TWAFollower.DATA_FLAGS_ID, (byte) (b0 & -5)); + public void setOwnerUUID(UUID uuid) { + this.getBukkitEntity().getPersistentDataContainer().set(TARDISWeepingAngels.OWNER_UUID, TARDISWeepingAngels.PersistentDataTypeUUID, uuid); + } + + @Nullable + @Override + public LivingEntity getOwner() { + if (uuid == null) { + return null; } + org.bukkit.entity.Player player = Bukkit.getPlayer(uuid); + return (player != null) ? ((CraftPlayer) player).getHandle() : null; } public boolean isFollowing() { diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAJudoon.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAJudoon.java index e10d6c7ee..c2995ad2b 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAJudoon.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAJudoon.java @@ -1,45 +1,17 @@ package me.eccentric_nz.tardisweepingangels.nms; -import com.mojang.datafixers.DataFixUtils; -import com.mojang.datafixers.types.Type; import me.eccentric_nz.TARDIS.TARDIS; -import net.minecraft.SharedConstants; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.datafix.DataFixers; -import net.minecraft.util.datafix.fixes.References; -import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.MobCategory; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.Map; import java.util.UUID; public class TWAJudoon extends TWAFollower { - private static final String ENTITY_ID = "judoon"; - - static { - ResourceLocation mcKey = new ResourceLocation(ENTITY_ID); - try { - if (BuiltInRegistries.ENTITY_TYPE.getOptional(mcKey).isEmpty()) { - unfreezeEntityRegistry(); - @SuppressWarnings("unchecked") - Map> types = (Map>) DataFixers.getDataFixer().getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().getDataVersion().getVersion())).findChoiceType(References.ENTITY).types(); - types.put(mcKey.toString(), types.get(BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.HUSK).toString())); - Registry.register(BuiltInRegistries.ENTITY_TYPE, ENTITY_ID, EntityType.Builder.of(EntityType::create, MobCategory.MONSTER).noSummon().build(ENTITY_ID)); - BuiltInRegistries.ENTITY_TYPE.freeze(); - } - } catch (NoSuchFieldException | IllegalAccessException ignore) { - } - } - private int ammo; private boolean guard; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAK9.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAK9.java index f8993722c..5ca86c2fa 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAK9.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAK9.java @@ -1,45 +1,17 @@ package me.eccentric_nz.tardisweepingangels.nms; -import com.mojang.datafixers.DataFixUtils; -import com.mojang.datafixers.types.Type; import me.eccentric_nz.TARDIS.TARDIS; -import net.minecraft.SharedConstants; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.datafix.DataFixers; -import net.minecraft.util.datafix.fixes.References; -import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.MobCategory; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.Map; import java.util.UUID; public class TWAK9 extends TWAFollower { - private static final String ENTITY_ID = "k9"; - - static { - ResourceLocation mcKey = new ResourceLocation(ENTITY_ID); - try { - if (BuiltInRegistries.ENTITY_TYPE.getOptional(mcKey).isEmpty()) { - unfreezeEntityRegistry(); - @SuppressWarnings("unchecked") - Map> types = (Map>) DataFixers.getDataFixer().getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().getDataVersion().getVersion())).findChoiceType(References.ENTITY).types(); - types.put(mcKey.toString(), types.get(BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.HUSK).toString())); - Registry.register(BuiltInRegistries.ENTITY_TYPE, ENTITY_ID, EntityType.Builder.of(EntityType::create, MobCategory.MONSTER).noSummon().build(ENTITY_ID)); - BuiltInRegistries.ENTITY_TYPE.freeze(); - } - } catch (NoSuchFieldException | IllegalAccessException ignore) { - } - } - public TWAK9(Level world, UUID owner) { super(world, owner); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAOod.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAOod.java index 9338a5c5b..17efaefd4 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAOod.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAOod.java @@ -1,46 +1,18 @@ package me.eccentric_nz.tardisweepingangels.nms; -import com.mojang.datafixers.DataFixUtils; -import com.mojang.datafixers.types.Type; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.tardisweepingangels.monsters.ood.OodColour; -import net.minecraft.SharedConstants; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.datafix.DataFixers; -import net.minecraft.util.datafix.fixes.References; -import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.MobCategory; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.Map; import java.util.UUID; public class TWAOod extends TWAFollower { - private static final String ENTITY_ID = "ood"; - - static { - ResourceLocation mcKey = new ResourceLocation(ENTITY_ID); - try { - if (BuiltInRegistries.ENTITY_TYPE.getOptional(mcKey).isEmpty()) { - unfreezeEntityRegistry(); - @SuppressWarnings("unchecked") - Map> types = (Map>) DataFixers.getDataFixer().getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().getDataVersion().getVersion())).findChoiceType(References.ENTITY).types(); - types.put(mcKey.toString(), types.get(BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.HUSK).toString())); - Registry.register(BuiltInRegistries.ENTITY_TYPE, ENTITY_ID, EntityType.Builder.of(EntityType::create, MobCategory.MONSTER).noSummon().build(ENTITY_ID)); - BuiltInRegistries.ENTITY_TYPE.freeze(); - } - } catch (NoSuchFieldException | IllegalAccessException ignore) { - } - } - private boolean redeye; private OodColour colour; diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/ChunkListener.java b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/ChunkListener.java index a97e3a03b..c549de4d8 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/utils/ChunkListener.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/utils/ChunkListener.java @@ -85,26 +85,28 @@ public void onChunkLoad(ChunkLoadEvent event) { } } } else if (d instanceof Zombie zombie) { - if (pdc.has(TARDISWeepingAngels.CYBERMAN, PersistentDataType.INTEGER)) { - new Equipper(Monster.CYBERMAN, zombie, false, false).setHelmetAndInvisibilty(); - } else if (pdc.has(TARDISWeepingAngels.EMPTY, PersistentDataType.INTEGER)) { - new Equipper(Monster.EMPTY_CHILD, zombie, false, false).setHelmetAndInvisibilty(); - EmptyChildEquipment.setSpeed(zombie); - } else if (zombie.getPersistentDataContainer().has(TARDISWeepingAngels.SLITHEEN, PersistentDataType.INTEGER)) { - new Equipper(Monster.SLITHEEN, zombie, false).setHelmetAndInvisibilty(); - } else if (pdc.has(TARDISWeepingAngels.SONTARAN, PersistentDataType.INTEGER)) { - new Equipper(Monster.SONTARAN, zombie, false, false).setHelmetAndInvisibilty(); - } else if (pdc.has(TARDISWeepingAngels.VASHTA, PersistentDataType.INTEGER)) { - new Equipper(Monster.VASHTA_NERADA, zombie, false, false).setHelmetAndInvisibilty(); - } else if (pdc.has(TARDISWeepingAngels.ZYGON, PersistentDataType.INTEGER)) { - new Equipper(Monster.ZYGON, zombie, false, false).setHelmetAndInvisibilty(); + if (d instanceof Husk husk) { + new ResetMonster(plugin, husk).reset(); + } else { + if (pdc.has(TARDISWeepingAngels.CYBERMAN, PersistentDataType.INTEGER)) { + new Equipper(Monster.CYBERMAN, zombie, false, false).setHelmetAndInvisibilty(); + } else if (pdc.has(TARDISWeepingAngels.EMPTY, PersistentDataType.INTEGER)) { + new Equipper(Monster.EMPTY_CHILD, zombie, false, false).setHelmetAndInvisibilty(); + EmptyChildEquipment.setSpeed(zombie); + } else if (zombie.getPersistentDataContainer().has(TARDISWeepingAngels.SLITHEEN, PersistentDataType.INTEGER)) { + new Equipper(Monster.SLITHEEN, zombie, false).setHelmetAndInvisibilty(); + } else if (pdc.has(TARDISWeepingAngels.SONTARAN, PersistentDataType.INTEGER)) { + new Equipper(Monster.SONTARAN, zombie, false, false).setHelmetAndInvisibilty(); + } else if (pdc.has(TARDISWeepingAngels.VASHTA, PersistentDataType.INTEGER)) { + new Equipper(Monster.VASHTA_NERADA, zombie, false, false).setHelmetAndInvisibilty(); + } else if (pdc.has(TARDISWeepingAngels.ZYGON, PersistentDataType.INTEGER)) { + new Equipper(Monster.ZYGON, zombie, false, false).setHelmetAndInvisibilty(); + } } } else if (d instanceof ArmorStand stand && stand.getPersistentDataContainer().has(TARDISWeepingAngels.FLAME_TASK, PersistentDataType.INTEGER)) { // restart flame runnable int flameID = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new HeadlessFlameRunnable(stand), 1, 20); pdc.set(TARDISWeepingAngels.FLAME_TASK, PersistentDataType.INTEGER, flameID); - } else if (d instanceof Husk husk) { - new ResetMonster(plugin, husk).reset(); } } } From 95c69aa1c3adba998a3b08cb99dabdc05ea3b343 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Mon, 6 May 2024 22:45:36 +1200 Subject: [PATCH 88/96] Fix reverting sonic changing other item stacks --- .../TARDIS/sonic/actions/TARDISSonicSound.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicSound.java b/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicSound.java index a7e83f2b8..3bfaedfe4 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicSound.java +++ b/src/main/java/me/eccentric_nz/TARDIS/sonic/actions/TARDISSonicSound.java @@ -45,8 +45,6 @@ public static void playSonicSound(TARDIS plugin, Player player, long now, long c ItemStack is = player.getInventory().getItemInMainHand(); if (is.hasItemMeta()) { ItemMeta meta = is.getItemMeta(); - meta.setCustomModelData(cmd); - is.setItemMeta(meta); if (meta.hasDisplayName() && meta.getDisplayName().endsWith("Sonic Screwdriver")) { player.getInventory().getItemInMainHand().getEnchantments().keySet().forEach((e) -> player.getInventory().getItemInMainHand().removeEnchantment(e)); meta.setCustomModelData(cmd); @@ -69,12 +67,17 @@ private static void revertSonic(PlayerInventory inv) { return; } ItemStack stack = inv.getItem(first); + if (stack == null) { + return; + } ItemMeta meta = stack.getItemMeta(); - int cmd = meta.getCustomModelData(); - meta.setCustomModelData(cmd - 2000000); - stack.setItemMeta(meta); - if (stack.containsEnchantment(Enchantment.UNBREAKING)) { - stack.getEnchantments().keySet().forEach(stack::removeEnchantment); + if (meta.hasDisplayName() && meta.getDisplayName().endsWith("Sonic Screwdriver")) { + int cmd = meta.getCustomModelData(); + meta.setCustomModelData(cmd - 2000000); + stack.setItemMeta(meta); + if (stack.containsEnchantment(Enchantment.UNBREAKING)) { + stack.getEnchantments().keySet().forEach(stack::removeEnchantment); + } } } } From aca370761993dbc9a8d511d5151387178edfb53e Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Tue, 7 May 2024 08:34:46 +1200 Subject: [PATCH 89/96] Fix TWA monster walk animations --- .../tardisweepingangels/nms/TWADrowned.java | 45 +++++++++---------- .../tardisweepingangels/nms/TWAFollower.java | 4 +- .../tardisweepingangels/nms/TWAJudoon.java | 29 +++++------- .../tardisweepingangels/nms/TWAK9.java | 29 +++++------- .../tardisweepingangels/nms/TWAOod.java | 36 +++++++-------- .../nms/TWAPiglinBrute.java | 33 ++++++-------- .../tardisweepingangels/nms/TWASkeleton.java | 35 +++++++-------- .../tardisweepingangels/nms/TWAZombie.java | 35 +++++++-------- .../nms/TWAZombifiedPiglin.java | 35 +++++++-------- 9 files changed, 121 insertions(+), 160 deletions(-) diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWADrowned.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWADrowned.java index 0497f9a0f..76ffb7993 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWADrowned.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWADrowned.java @@ -16,13 +16,11 @@ */ package me.eccentric_nz.tardisweepingangels.nms; -import me.eccentric_nz.TARDIS.TARDIS; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.monster.Drowned; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -34,9 +32,9 @@ public class TWADrowned extends Drowned { private final int[] frames = new int[]{0, 1, 2, 1, 0, 3, 4, 3}; - private boolean isAnimating = false; - private int task = -1; private int i = 0; + private double oldX; + private double oldZ; public TWADrowned(EntityType type, Level level) { super(type, level); @@ -44,34 +42,31 @@ public TWADrowned(EntityType type, Level level) { @Override public void aiStep() { - if (hasItemInSlot(EquipmentSlot.HEAD)) { + if (hasItemInSlot(EquipmentSlot.HEAD) && tickCount % 3 == 0) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); ItemMeta im = bukkit.getItemMeta(); - if (!isPathFinding()) { - Bukkit.getScheduler().cancelTask(task); + if (oldX == getX() && oldZ == getZ()) { im.setCustomModelData(405); - bukkit.setItemMeta(im); - isAnimating = false; - } else if (!isAnimating) { + i = 0; + } else { // play move animation - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { - int cmd = 400; - if (isSwimming()) { - cmd = 411; - } else if (getTarget() != null) { - cmd = 406; - } - im.setCustomModelData(cmd + frames[i]); - bukkit.setItemMeta(im); - i++; - if (i == frames.length) { - i = 0; - } - }, 1L, 3L); - isAnimating = true; + int cmd = 400; + if (isSwimming()) { + cmd = 411; + } else if (getTarget() != null) { + cmd = 406; + } + im.setCustomModelData(cmd + frames[i]); + i++; + if (i == frames.length) { + i = 0; + } } + bukkit.setItemMeta(im); setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); + oldX = getX(); + oldZ = getZ(); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java index d2a61c934..221c16186 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAFollower.java @@ -28,10 +28,10 @@ public class TWAFollower extends Husk implements OwnableEntity { protected static final EntityDataAccessor> DATA_OWNERUUID_ID = SynchedEntityData.defineId(TWAFollower.class, EntityDataSerializers.OPTIONAL_UUID); protected final int[] frames = new int[]{0, 1, 2, 1, 0, 3, 4, 3}; protected UUID uuid; - protected boolean isAnimating = false; protected boolean following = false; - protected int task = -1; protected int i = 0; + protected double oldX; + protected double oldZ; public TWAFollower(Level world, UUID owner) { super(EntityType.HUSK, world); diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAJudoon.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAJudoon.java index c2995ad2b..4d57cb17a 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAJudoon.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAJudoon.java @@ -1,10 +1,8 @@ package me.eccentric_nz.tardisweepingangels.nms; -import me.eccentric_nz.TARDIS.TARDIS; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -22,28 +20,25 @@ public TWAJudoon(Level world, UUID owner) { @Override public void aiStep() { - if (hasItemInSlot(EquipmentSlot.HEAD)) { + if (hasItemInSlot(EquipmentSlot.HEAD) && tickCount % 3 == 0) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); ItemMeta im = bukkit.getItemMeta(); - if (!isPathFinding()) { - Bukkit.getScheduler().cancelTask(task); + if (oldX == getX() && oldZ == getZ()) { im.setCustomModelData(405 + (this.guard ? 6 : 0)); - bukkit.setItemMeta(im); - isAnimating = false; - } else if (!isAnimating) { + i = 0; + } else { // play move animation - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { - im.setCustomModelData(400 + frames[i] + (this.guard ? 6 : 0)); - bukkit.setItemMeta(im); - i++; - if (i == frames.length) { - i = 0; - } - }, 1L, 3L); - isAnimating = true; + im.setCustomModelData(400 + frames[i] + (this.guard ? 6 : 0)); + i++; + if (i == frames.length) { + i = 0; + } } + bukkit.setItemMeta(im); setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); + oldX = getX(); + oldZ = getZ(); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAK9.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAK9.java index 5ca86c2fa..7c9cba903 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAK9.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAK9.java @@ -1,10 +1,8 @@ package me.eccentric_nz.tardisweepingangels.nms; -import me.eccentric_nz.TARDIS.TARDIS; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -18,28 +16,25 @@ public TWAK9(Level world, UUID owner) { @Override public void aiStep() { - if (hasItemInSlot(EquipmentSlot.HEAD)) { + if (hasItemInSlot(EquipmentSlot.HEAD) && tickCount % 3 == 0) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); ItemMeta im = bukkit.getItemMeta(); - if (!isPathFinding()) { - Bukkit.getScheduler().cancelTask(task); + if (oldX == getX() && oldZ == getZ()) { im.setCustomModelData(400); - bukkit.setItemMeta(im); - isAnimating = false; - } else if (!isAnimating) { + i = 0; + } else { // play move animation - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { - im.setCustomModelData(400 + frames[i]); - bukkit.setItemMeta(im); - i++; - if (i == frames.length) { - i = 0; - } - }, 1L, 3L); - isAnimating = true; + im.setCustomModelData(400 + frames[i]); + i++; + if (i == frames.length) { + i = 0; + } } + bukkit.setItemMeta(im); setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); + oldX = getX(); + oldZ = getZ(); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAOod.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAOod.java index 17efaefd4..1972215b1 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAOod.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAOod.java @@ -1,11 +1,9 @@ package me.eccentric_nz.tardisweepingangels.nms; -import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.tardisweepingangels.monsters.ood.OodColour; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -24,35 +22,33 @@ public TWAOod(Level world, UUID owner) { @Override public void aiStep() { - if (hasItemInSlot(EquipmentSlot.HEAD)) { + if (hasItemInSlot(EquipmentSlot.HEAD) && tickCount % 3 == 0) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); ItemMeta im = bukkit.getItemMeta(); - if (!isPathFinding()) { - Bukkit.getScheduler().cancelTask(task); + if (oldX == getX() && oldZ == getZ()) { int cmd = 405 + colour.getStep(); if (redeye) { cmd += 18; } im.setCustomModelData(cmd); - bukkit.setItemMeta(im); - isAnimating = false; - } else if (!isAnimating) { + i = 0; + } else { // play move animation - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { - int cmd = 400 + colour.getStep(); - if (redeye) { - cmd += 18; - } - im.setCustomModelData(cmd + frames[i]); - i++; - if (i == frames.length) { - i = 0; - } - }, 1L, 3L); - isAnimating = true; + int cmd = 400 + colour.getStep(); + if (redeye) { + cmd += 18; + } + im.setCustomModelData(cmd + frames[i]); + i++; + if (i == frames.length) { + i = 0; + } } + bukkit.setItemMeta(im); setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); + oldX = getX(); + oldZ = getZ(); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAPiglinBrute.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAPiglinBrute.java index 114d2c522..8258f4870 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAPiglinBrute.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAPiglinBrute.java @@ -16,13 +16,11 @@ */ package me.eccentric_nz.tardisweepingangels.nms; -import me.eccentric_nz.TARDIS.TARDIS; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.monster.piglin.PiglinBrute; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -34,8 +32,8 @@ public class TWAPiglinBrute extends PiglinBrute { private final int[] frames = new int[]{0, 1, 0, 2}; - private boolean isAnimating = false; - private int task = -1; + private double oldX; + private double oldZ; private int i = 0; public TWAPiglinBrute(EntityType type, Level level) { @@ -44,28 +42,25 @@ public TWAPiglinBrute(EntityType type, Level level) { @Override public void aiStep() { - if (hasItemInSlot(EquipmentSlot.HEAD)) { + if (hasItemInSlot(EquipmentSlot.HEAD) && tickCount % 3 == 0) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); ItemMeta im = bukkit.getItemMeta(); - if (!isPathFinding()) { - Bukkit.getScheduler().cancelTask(task); + if (oldX == getX() && oldZ == getZ()) { im.setCustomModelData(405); - bukkit.setItemMeta(im); - isAnimating = false; - } else if (!isAnimating) { + i = 0; + } else { // play move animation - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { - im.setCustomModelData(400 + frames[i]); - bukkit.setItemMeta(im); - i++; - if (i == frames.length) { - i = 0; - } - }, 1L, 3L); - isAnimating = true; + im.setCustomModelData(400 + frames[i]); + i++; + if (i == frames.length) { + i = 0; + } } + bukkit.setItemMeta(im); setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); + oldX = getX(); + oldZ = getZ(); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWASkeleton.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWASkeleton.java index 1039870b9..222c66d2c 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWASkeleton.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWASkeleton.java @@ -16,7 +16,6 @@ */ package me.eccentric_nz.tardisweepingangels.nms; -import me.eccentric_nz.TARDIS.TARDIS; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; @@ -24,7 +23,6 @@ import net.minecraft.world.entity.monster.Skeleton; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -36,8 +34,8 @@ public class TWASkeleton extends Skeleton { private final int[] frames = new int[]{0, 1, 2, 1, 0, 3, 4, 3}; - private boolean isAnimating = false; - private int task = -1; + private double oldX; + private double oldZ; private int i = 0; private boolean beaming = false; @@ -47,7 +45,7 @@ public TWASkeleton(EntityType type, Level level) { @Override public void aiStep() { - if (hasItemInSlot(EquipmentSlot.HEAD)) { + if (hasItemInSlot(EquipmentSlot.HEAD) && tickCount % 3 == 0) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); ItemMeta im = bukkit.getItemMeta(); @@ -55,25 +53,22 @@ public void aiStep() { if (passenger instanceof Guardian guardian) { beaming = guardian.hasActiveAttackTarget(); } - if (!isPathFinding() || beaming) { - Bukkit.getScheduler().cancelTask(task); + if ((oldX == getX() && oldZ == getZ()) || beaming) { im.setCustomModelData(beaming ? 11 : 405); - bukkit.setItemMeta(im); - isAnimating = false; - } else if (!isAnimating) { + i = 0; + } else { // play move animation - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { - int cmd = getTarget() != null ? 406 : 400; - im.setCustomModelData(cmd + frames[i]); - bukkit.setItemMeta(im); - i++; - if (i == frames.length) { - i = 0; - } - }, 1L, 3L); - isAnimating = true; + int cmd = getTarget() != null ? 406 : 400; + im.setCustomModelData(cmd + frames[i]); + i++; + if (i == frames.length) { + i = 0; + } } + bukkit.setItemMeta(im); setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); + oldX = getX(); + oldZ = getZ(); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombie.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombie.java index 57e9c54da..ceab742b0 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombie.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombie.java @@ -16,13 +16,11 @@ */ package me.eccentric_nz.tardisweepingangels.nms; -import me.eccentric_nz.TARDIS.TARDIS; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.monster.Zombie; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -34,8 +32,8 @@ public class TWAZombie extends Zombie { private final int[] frames = new int[]{0, 1, 2, 1, 0, 3, 4, 3}; - private boolean isAnimating = false; - private int task = -1; + private double oldX; + private double oldZ; private int i = 0; public TWAZombie(EntityType type, Level level) { @@ -44,29 +42,26 @@ public TWAZombie(EntityType type, Level level) { @Override public void aiStep() { - if (hasItemInSlot(EquipmentSlot.HEAD)) { + if (hasItemInSlot(EquipmentSlot.HEAD) && tickCount % 3 == 0) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); ItemMeta im = bukkit.getItemMeta(); - if (!isPathFinding()) { - Bukkit.getScheduler().cancelTask(task); + if (oldX == getX() && oldZ == getZ()) { im.setCustomModelData(405); - bukkit.setItemMeta(im); - isAnimating = false; - } else if (!isAnimating) { + i = 0; + } else { // play move animation - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { - int cmd = getTarget() != null ? 406 : 400; - im.setCustomModelData(cmd + frames[i]); - bukkit.setItemMeta(im); - i++; - if (i == frames.length) { - i = 0; - } - }, 1L, 3L); - isAnimating = true; + int cmd = getTarget() != null ? 406 : 400; + im.setCustomModelData(cmd + frames[i]); + i++; + if (i == frames.length) { + i = 0; + } } + bukkit.setItemMeta(im); setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); + oldX = getX(); + oldZ = getZ(); } super.aiStep(); } diff --git a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombifiedPiglin.java b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombifiedPiglin.java index 4b55f671e..dc47999c2 100644 --- a/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombifiedPiglin.java +++ b/src/main/java/me/eccentric_nz/tardisweepingangels/nms/TWAZombifiedPiglin.java @@ -16,13 +16,11 @@ */ package me.eccentric_nz.tardisweepingangels.nms; -import me.eccentric_nz.TARDIS.TARDIS; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.monster.ZombifiedPiglin; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -34,8 +32,8 @@ public class TWAZombifiedPiglin extends ZombifiedPiglin { private final int[] frames = new int[]{0, 1, 2, 1, 0, 3, 4, 3}; - private boolean isAnimating = false; - private int task = -1; + private double oldX; + private double oldZ; private int i = 0; public TWAZombifiedPiglin(EntityType type, Level level) { @@ -44,29 +42,26 @@ public TWAZombifiedPiglin(EntityType type, Level leve @Override public void aiStep() { - if (hasItemInSlot(EquipmentSlot.HEAD)) { + if (hasItemInSlot(EquipmentSlot.HEAD) && tickCount % 3 == 0) { ItemStack is = getItemBySlot(EquipmentSlot.HEAD); org.bukkit.inventory.ItemStack bukkit = CraftItemStack.asBukkitCopy(is); ItemMeta im = bukkit.getItemMeta(); - if (!isPathFinding()) { - Bukkit.getScheduler().cancelTask(task); + if (oldX == getX() && oldZ == getZ()) { im.setCustomModelData(405); - bukkit.setItemMeta(im); - isAnimating = false; - } else if (!isAnimating) { + i = 0; + } else { // play move animation - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(TARDIS.plugin, () -> { - int cmd = getTarget() != null ? 406 : 400; - im.setCustomModelData(cmd + frames[i]); - bukkit.setItemMeta(im); - i++; - if (i == frames.length) { - i = 0; - } - }, 1L, 3L); - isAnimating = true; + int cmd = getTarget() != null ? 406 : 400; + im.setCustomModelData(cmd + frames[i]); + i++; + if (i == frames.length) { + i = 0; + } } + bukkit.setItemMeta(im); setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(bukkit)); + oldX = getX(); + oldZ = getZ(); } super.aiStep(); } From 3677f4d5f6c17728032bd389744dcba4803c0158 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Fri, 10 May 2024 08:52:11 +1200 Subject: [PATCH 90/96] Update pom.xml --- pom.xml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index bcab6c53a..67e8e322c 100644 --- a/pom.xml +++ b/pom.xml @@ -11,11 +11,6 @@ http://eccentricdevotion.github.com/TARDIS/ - - - sonatype-oss-snapshots1 - https://s01.oss.sonatype.org/content/repositories/snapshots/ - jitpack.io @@ -522,7 +517,7 @@ net.coreprotect coreprotect - 22.2 + 22.3 jar provided From a3d02ac3c9cfead0bf1dcb1bf3e6eed6a3c82931 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Sat, 11 May 2024 18:06:11 +1200 Subject: [PATCH 91/96] Set throttle/flight mode/direction position when building console --- .../commands/dev/TARDISDisplayItemCommand.java | 5 +++-- .../eccentric_nz/TARDIS/console/ConsoleBuilder.java | 13 ++++++++++--- .../TARDIS/listeners/TARDISSeedBlockListener.java | 5 +++-- todo.md | 1 - 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java index 2d6887b23..dd587b57a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java @@ -244,8 +244,9 @@ public boolean display(Player player, String[] args) { } // get TARDIS id ResultSetTardisID rs = new ResultSetTardisID(plugin); - if (rs.fromUUID(player.getUniqueId().toString())) { - new ConsoleBuilder(plugin).create(block, colour, rs.getTardis_id()); + String uuid = player.getUniqueId().toString(); + if (rs.fromUUID(uuid)) { + new ConsoleBuilder(plugin).create(block, colour, rs.getTardis_id(), uuid); } return true; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java index 470e5a3b2..50ebac8ba 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java +++ b/src/main/java/me/eccentric_nz/TARDIS/console/ConsoleBuilder.java @@ -2,6 +2,7 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentLocation; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetPlayerPrefs; import me.eccentric_nz.TARDIS.enumeration.COMPASS; import me.eccentric_nz.TARDIS.utility.TARDISStaticLocationGetters; import org.bukkit.Location; @@ -28,7 +29,7 @@ public ConsoleBuilder(TARDIS plugin) { this.plugin = plugin; } - public void create(Block block, int type, int id) { + public void create(Block block, int type, int id, String playerUuid) { StringBuilder builder = new StringBuilder(); String prefix = "~"; Block up = block.getRelative(BlockFace.UP); @@ -82,7 +83,7 @@ public void create(Block block, int type, int id) { // set interaction entities for console controls for (ConsoleInteraction i : ConsoleInteraction.values()) { // spawn a display entity and save it's UUID to the interaction entity - UUID uuid = spawnControl(i, block.getLocation(), i.getYaw(), id); + UUID uuid = spawnControl(i, block.getLocation(), i.getYaw(), id, playerUuid); double x = i.getRelativePosition().getX(); double z = i.getRelativePosition().getZ(); Location location = block.getLocation().clone().add(x, 0.75, z); @@ -114,7 +115,7 @@ public void create(Block block, int type, int id) { } } - private UUID spawnControl(ConsoleInteraction interaction, Location location, float angle, int id) { + private UUID spawnControl(ConsoleInteraction interaction, Location location, float angle, int id, String playerUuid) { if (interaction == ConsoleInteraction.SCREEN_LEFT && right != null) { return right; } @@ -129,6 +130,12 @@ private UUID spawnControl(ConsoleInteraction interaction, Location location, flo ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherec); cmd = (rsc.resultSet()) ? getCmd(rsc.getDirection()) + 10000 : 10000; } + if (interaction == ConsoleInteraction.THROTTLE || interaction == ConsoleInteraction.RELATIVITY_DIFFERENTIATOR) { + ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, playerUuid); + if (rsp.resultSet()) { + cmd = (interaction == ConsoleInteraction.THROTTLE) ? 1000 + rsp.getThrottle() : 6000 + rsp.getFlightMode(); + } + } // spawn a control ItemStack is = new ItemStack(material); ItemMeta im = is.getItemMeta(); diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISSeedBlockListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISSeedBlockListener.java index dfad5de52..6508008a5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISSeedBlockListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISSeedBlockListener.java @@ -125,8 +125,9 @@ public void onSeedBlockPlace(BlockPlaceEvent event) { int colour = im.getPersistentDataContainer().getOrDefault(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, 1); // get TARDIS id ResultSetTardisID rs = new ResultSetTardisID(plugin); - if (rs.fromUUID(player.getUniqueId().toString())) { - new ConsoleBuilder(plugin).create(event.getBlockPlaced(), colour, rs.getTardis_id()); + String uuid = player.getUniqueId().toString(); + if (rs.fromUUID(uuid)) { + new ConsoleBuilder(plugin).create(event.getBlockPlaced(), colour, rs.getTardis_id(), uuid); } } } diff --git a/todo.md b/todo.md index 9ac19dd75..bb374cd3c 100644 --- a/todo.md +++ b/todo.md @@ -7,7 +7,6 @@ 3. Custom Control models [#703](https://github.com/eccentricdevotion/TARDIS/issues/703) [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) * New interior with console - * Set throttle/flight mode/direction position when building console 4. Update old light level controls, and light switch should return to correct level 5. ? From cc376fc899f753dd8a7f66da3788933b4e1743c5 Mon Sep 17 00:00:00 2001 From: Eccentric Devotion Date: Sat, 11 May 2024 18:54:34 +1200 Subject: [PATCH 92/96] Update LightLevelAction.java --- .../eccentric_nz/TARDIS/control/actions/LightLevelAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/control/actions/LightLevelAction.java b/src/main/java/me/eccentric_nz/TARDIS/control/actions/LightLevelAction.java index b79eccd37..e78efec13 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/control/actions/LightLevelAction.java +++ b/src/main/java/me/eccentric_nz/TARDIS/control/actions/LightLevelAction.java @@ -21,7 +21,7 @@ public LightLevelAction(TARDIS plugin) { public void illuminate(int level, int control, boolean powered, int type, boolean policebox, int id, boolean lightsOn) { // save the level to the database - int setLevel = (level + 1) > 8 ? 0 : level + 1; + int setLevel = (level + 1) > 7 ? 0 : level + 1; HashMap set = new HashMap<>(); set.put("secondary", setLevel); HashMap where = new HashMap<>(); From c50c67c10face50586a99c577cc8afa5a549589b Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sun, 12 May 2024 22:21:30 +1200 Subject: [PATCH 93/96] Add bone door --- .../dev/TARDISDisplayItemCommand.java | 8 ++++---- .../give/TARDISDisplayBlockCommand.java | 2 +- .../TARDISDisplayBlockListener.java | 20 +++++++++---------- .../customblocks/TARDISDisplayItem.java | 5 ++++- .../customblocks/TARDISDisplayItemUtils.java | 10 +++++----- .../TARDIS/doors/DisplayItemDoorToggler.java | 2 +- .../TARDIS/doors/TARDISCustomDoorLoader.java | 6 +++++- .../TARDIS/enumeration/RecipeItem.java | 1 + .../recipes/TARDISDisplayItemRecipe.java | 2 +- .../schematic/actions/SchematicSave.java | 2 +- todo.md | 2 +- 11 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java index dd587b57a..a4d63a1a4 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDisplayItemCommand.java @@ -136,7 +136,7 @@ public boolean display(Player player, String[] args) { im.setDisplayName(TARDISStringUtils.capitalise(args[2])); is.setItemMeta(im); Block up = block.getRelative(BlockFace.UP); - if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi.isLight()) { + if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR || tdi.isLight()) { // also set an interaction entity Interaction interaction = (Interaction) block.getWorld().spawnEntity(up.getLocation().clone().add(0.5d, 0, 0.5d), EntityType.INTERACTION); interaction.setResponsive(true); @@ -148,7 +148,7 @@ public boolean display(Player player, String[] args) { light.setLevel(level); up.setBlockData(light); } - if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR) { + if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR) { // set size interaction.setInteractionHeight(2.0f); interaction.setInteractionWidth(1.0f); @@ -156,12 +156,12 @@ public boolean display(Player player, String[] args) { } else { up.setType((tdi == TARDISDisplayItem.ARTRON_FURNACE) ? Material.FURNACE : Material.BARRIER); } - double ay = (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR) ? 0.0d : 0.5d; + double ay = (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR) ? 0.0d : 0.5d; ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(up.getLocation().add(0.5d, ay, 0.5d), EntityType.ITEM_DISPLAY); display.setItemStack(is); display.setPersistent(true); display.setInvulnerable(true); - if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR) { + if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR) { display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.FIXED); } if (tdi.getMaterial() == Material.AMETHYST_SHARD) { diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISDisplayBlockCommand.java b/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISDisplayBlockCommand.java index b0d1d921b..be42876e2 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISDisplayBlockCommand.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/give/TARDISDisplayBlockCommand.java @@ -36,7 +36,7 @@ public TARDISDisplayBlockCommand(TARDIS plugin) { public ItemStack getStack(String arg) { String display = TARDISStringUtils.toEnumUppercase(arg); - if (display.startsWith("DOOR_")) { + if (display.startsWith("DOOR_") || display.endsWith("_DOOR")) { // plugin.debug(display); // for (String d : Door.byName.keySet()) { // plugin.debug(d); diff --git a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java index c606dc6ba..8da62ff5f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayBlockListener.java @@ -96,7 +96,7 @@ public void onDisplayBlockPlace(BlockPlaceEvent event) { Location location = event.getBlock().getLocation(); event.setCancelled(true); BlockData data; - if (which.isLight() || which == TARDISDisplayItem.DOOR || which == TARDISDisplayItem.CLASSIC_DOOR) { + if (which.isLight() || which == TARDISDisplayItem.DOOR || which == TARDISDisplayItem.CLASSIC_DOOR || which == TARDISDisplayItem.BONE_DOOR) { if (which.isLight()) { Levelled light = TARDISConstants.LIGHT; light.setLevel((which.isLit() ? 15 : 0)); @@ -105,21 +105,21 @@ public void onDisplayBlockPlace(BlockPlaceEvent event) { data = null; } // set an Interaction entity - TARDISDisplayItemUtils.set(location, cmd, which == TARDISDisplayItem.DOOR || which == TARDISDisplayItem.CLASSIC_DOOR); + TARDISDisplayItemUtils.set(location, cmd, which == TARDISDisplayItem.DOOR || which == TARDISDisplayItem.CLASSIC_DOOR || which == TARDISDisplayItem.BONE_DOOR); } else { data = TARDISConstants.BARRIER; } if (data != null) { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> location.getBlock().setBlockData(data), 1L); } - double ay = (which == TARDISDisplayItem.DOOR || which == TARDISDisplayItem.CLASSIC_DOOR) ? 0.0d : 0.5d; + double ay = (which == TARDISDisplayItem.DOOR || which == TARDISDisplayItem.CLASSIC_DOOR || which == TARDISDisplayItem.BONE_DOOR) ? 0.0d : 0.5d; // set an ItemDisplay entity ItemDisplay display = (ItemDisplay) location.getWorld().spawnEntity(location.add(0.5d, ay, 0.5d), EntityType.ITEM_DISPLAY); display.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, which.getCustomModelData()); display.setItemStack(single); display.setPersistent(true); display.setInvulnerable(true); - if (which == TARDISDisplayItem.DOOR || which == TARDISDisplayItem.CLASSIC_DOOR) { + if (which == TARDISDisplayItem.DOOR || which == TARDISDisplayItem.CLASSIC_DOOR || which == TARDISDisplayItem.BONE_DOOR) { display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.FIXED); float yaw = DoorUtility.getLookAtYaw(player); // set display rotation @@ -288,7 +288,7 @@ public void onInteractionClick(PlayerInteractAtEntityEvent event) { } else { TARDISDisplayItem tdi = TARDISDisplayItemUtils.get(display); if (tdi != null) { - if (tdi == TARDISDisplayItem.CUSTOM_DOOR || tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.DOOR_OPEN || tdi == TARDISDisplayItem.DOOR_BOTH_OPEN || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR_OPEN) { + if (tdi == TARDISDisplayItem.CUSTOM_DOOR || tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.DOOR_OPEN || tdi == TARDISDisplayItem.DOOR_BOTH_OPEN || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR_OPEN || tdi == TARDISDisplayItem.BONE_DOOR || tdi == TARDISDisplayItem.BONE_DOOR_OPEN) { if (!player.isOp() && !plugin.getUtils().inTARDISWorld(player)) { return; } @@ -313,7 +313,7 @@ public void onInteractionClick(PlayerInteractAtEntityEvent event) { return; } if (player.isSneaking()) { - if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || (tdi == TARDISDisplayItem.CUSTOM_DOOR && isCustomClosed(display))) { + if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR || (tdi == TARDISDisplayItem.CUSTOM_DOOR && isCustomClosed(display))) { // move to outside new DisplayItemDoorMover(plugin).exit(player, block); return; @@ -355,15 +355,15 @@ public void onInteractionClick(PlayerInteractAtEntityEvent event) { new DoorAnimator(plugin, display).close(); new DisplayItemDoorToggler(plugin).openClose(player, block, true, TARDISDisplayItem.DOOR_OPEN); } - case CLASSIC_DOOR -> { + case CLASSIC_DOOR, BONE_DOOR -> { // open doors / activate portal new DoorAnimator(plugin, display).open(); - new DisplayItemDoorToggler(plugin).openClose(player, block, false, TARDISDisplayItem.CLASSIC_DOOR); + new DisplayItemDoorToggler(plugin).openClose(player, block, false, tdi); } - case CLASSIC_DOOR_OPEN -> { + case CLASSIC_DOOR_OPEN, BONE_DOOR_OPEN -> { // close doors / deactivate portal new DoorAnimator(plugin, display).close(); - new DisplayItemDoorToggler(plugin).openClose(player, block, true, TARDISDisplayItem.CLASSIC_DOOR_OPEN); + new DisplayItemDoorToggler(plugin).openClose(player, block, true, tdi); } case CUSTOM_DOOR -> { // get if door is open diff --git a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayItem.java b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayItem.java index 3dd971f41..cf9bf9fca 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayItem.java +++ b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayItem.java @@ -34,6 +34,7 @@ public enum TARDISDisplayItem { ANCIENT(Material.SCULK), ARS(Material.QUARTZ_BLOCK), BIGGER(Material.GOLD_BLOCK), + BONE(Material.WAXED_OXIDIZED_CUT_COPPER), BUDGET(Material.IRON_BLOCK), CAVE(Material.DRIPSTONE_BLOCK), COPPER(10001, Material.COPPER_BLOCK, null), @@ -88,6 +89,8 @@ public enum TARDISDisplayItem { DOOR(10000, Material.IRON_DOOR, Material.IRON_DOOR), DOOR_OPEN(10004, Material.IRON_DOOR, null), DOOR_BOTH_OPEN(10005, Material.IRON_DOOR, null), + BONE_DOOR(10000, Material.IRON_DOOR, Material.BIRCH_DOOR), + BONE_DOOR_OPEN(10006, Material.BIRCH_DOOR, null), CLASSIC_DOOR(10000, Material.IRON_DOOR, Material.CHERRY_DOOR), CLASSIC_DOOR_OPEN(10006, Material.CHERRY_DOOR, null), CUSTOM_DOOR(-1, Material.IRON_DOOR, null), @@ -205,7 +208,7 @@ public enum TARDISDisplayItem { public static TARDISDisplayItem getByMaterialAndData(Material m, int cmd) { for (TARDISDisplayItem tdi : values()) { - if (tdi == TARDISDisplayItem.CLASSIC_DOOR) { + if (tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR) { if (tdi.getCraftMaterial() == m && tdi.getCustomModelData() == cmd) { return tdi; } diff --git a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayItemUtils.java b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayItemUtils.java index 5891bc296..c56fb34d5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayItemUtils.java +++ b/src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayItemUtils.java @@ -195,7 +195,7 @@ public static void set(TARDISDisplayItem tdi, World world, int x, int y, int z) */ public static void set(TARDISDisplayItem tdi, Block block, int id) { // spawn an item display entity - if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi.isLight()) { + if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR || tdi.isLight()) { // also set an interaction entity Interaction interaction = (Interaction) block.getWorld().spawnEntity(block.getLocation().clone().add(0.5d, 0, 0.5d), EntityType.INTERACTION); interaction.setResponsive(true); @@ -207,7 +207,7 @@ public static void set(TARDISDisplayItem tdi, Block block, int id) { interaction.setInteractionWidth(1.0f); interaction.getPersistentDataContainer().set(TARDIS.plugin.getTardisIdKey(), PersistentDataType.INTEGER, id); } - if (tdi == TARDISDisplayItem.CLASSIC_DOOR) { + if (tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR) { // set size interaction.setInteractionHeight(3.0f); interaction.setInteractionWidth(1.0f); @@ -222,7 +222,7 @@ public static void set(TARDISDisplayItem tdi, Block block, int id) { } else if (tdi != TARDISDisplayItem.ARTRON_FURNACE && tdi != TARDISDisplayItem.SONIC_GENERATOR) { block.setBlockData(TARDISConstants.BARRIER); } - Material material = (tdi == TARDISDisplayItem.CLASSIC_DOOR) ? tdi.getCraftMaterial() : tdi.getMaterial(); + Material material = (tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR) ? tdi.getCraftMaterial() : tdi.getMaterial(); ItemStack is = new ItemStack(material, 1); ItemMeta im = is.getItemMeta(); im.setDisplayName(tdi.getDisplayName()); @@ -231,10 +231,10 @@ public static void set(TARDISDisplayItem tdi, Block block, int id) { } im.getPersistentDataContainer().set(TARDIS.plugin.getCustomBlockKey(), PersistentDataType.INTEGER, tdi.getCustomModelData()); is.setItemMeta(im); - double ay = (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR) ? 0.0d : 0.5d; + double ay = (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR) ? 0.0d : 0.5d; ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(block.getLocation().add(0.5d, ay, 0.5d), EntityType.ITEM_DISPLAY); display.setItemStack(is); - if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR) { + if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR) { display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.FIXED); } display.setPersistent(true); diff --git a/src/main/java/me/eccentric_nz/TARDIS/doors/DisplayItemDoorToggler.java b/src/main/java/me/eccentric_nz/TARDIS/doors/DisplayItemDoorToggler.java index 2ef0a1493..9f72e3705 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/doors/DisplayItemDoorToggler.java +++ b/src/main/java/me/eccentric_nz/TARDIS/doors/DisplayItemDoorToggler.java @@ -85,7 +85,7 @@ public void openClose(Player player, Block block, boolean close, TARDISDisplayIt if (rsp.resultSet()) { minecart = rsp.isMinecartOn(); } - new TARDISDoorToggler(plugin, block, player, minecart, close, id).toggleDoorsWithoutSound(tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR_OPEN || tdi == TARDISDisplayItem.CUSTOM_DOOR); + new TARDISDoorToggler(plugin, block, player, minecart, close, id).toggleDoorsWithoutSound(tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR_OPEN || tdi == TARDISDisplayItem.BONE_DOOR || tdi == TARDISDisplayItem.BONE_DOOR_OPEN || tdi == TARDISDisplayItem.CUSTOM_DOOR); } else if (!rs.getTardis().getUuid().equals(playerUUID)) { plugin.getMessenger().sendStatus(player, "DOOR_DEADLOCKED"); } else { diff --git a/src/main/java/me/eccentric_nz/TARDIS/doors/TARDISCustomDoorLoader.java b/src/main/java/me/eccentric_nz/TARDIS/doors/TARDISCustomDoorLoader.java index 094e8bac5..dffefabaa 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/doors/TARDISCustomDoorLoader.java +++ b/src/main/java/me/eccentric_nz/TARDIS/doors/TARDISCustomDoorLoader.java @@ -17,9 +17,13 @@ public void addDoors() { // create plugin doors Door police_box = new Door("Police Box", Material.IRON_DOOR, new int[]{0,1,2,3,4}, 6, true, "tardis_door_open", "tardis_door_close", false); Door classic = new Door("Classic", Material.CHERRY_DOOR, new int[]{0,1,2,3,4,5,6}, 4, false, "classic_door", "classic_door", false); + Door bone = new Door("Bone", Material.BIRCH_DOOR, new int[]{0,1,2,3,4,5,6}, 4, false, "classic_door", "classic_door", false); Door.byMaterial.put(Material.IRON_DOOR, police_box); - Door.byName.put("DOOR_POLICE_BOX", police_box); + Door.byName.put("DOOR", police_box); Door.byMaterial.put(Material.CHERRY_DOOR, classic); + Door.byName.put("CLASSIC_DOOR", classic); + Door.byMaterial.put(Material.BIRCH_DOOR, bone); + Door.byName.put("BONE_DOOR", bone); for (String r : plugin.getCustomDoorsConfig().getKeys(false)) { try { Material material = Material.valueOf(plugin.getCustomDoorsConfig().getString(r + ".material")); diff --git a/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeItem.java b/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeItem.java index 0ca8ee056..cdd1d820a 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeItem.java +++ b/src/main/java/me/eccentric_nz/TARDIS/enumeration/RecipeItem.java @@ -140,6 +140,7 @@ public enum RecipeItem { LIGHT_TWELFTH(10008, RecipeCategory.CUSTOM_BLOCKS), LIGHT_THIRTEENTH(10009, RecipeCategory.CUSTOM_BLOCKS), DOOR(10001, RecipeCategory.CUSTOM_BLOCKS), + BONE_DOOR(10004, RecipeCategory.CUSTOM_BLOCKS), CLASSIC_DOOR(10004, RecipeCategory.CUSTOM_BLOCKS), // HANDBRAKE(1001, RecipeCategory.CUSTOM_BLOCKS), // THROTTLE(1001, RecipeCategory.CUSTOM_BLOCKS), diff --git a/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISDisplayItemRecipe.java b/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISDisplayItemRecipe.java index d10e9ba3a..a6509935f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISDisplayItemRecipe.java +++ b/src/main/java/me/eccentric_nz/TARDIS/recipes/TARDISDisplayItemRecipe.java @@ -41,7 +41,7 @@ public void addDisplayItemRecipes() { for (TARDISDisplayItem tdi : TARDISDisplayItem.values()) { if (tdi.getCraftMaterial() != null) { ItemStack is; - if (tdi == TARDISDisplayItem.CLASSIC_DOOR) { + if (tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR) { is = new ItemStack(tdi.getCraftMaterial(), 1); } else { is = new ItemStack(tdi.getMaterial(), 1); diff --git a/src/main/java/me/eccentric_nz/TARDIS/schematic/actions/SchematicSave.java b/src/main/java/me/eccentric_nz/TARDIS/schematic/actions/SchematicSave.java index fd634c497..d7485661b 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/schematic/actions/SchematicSave.java +++ b/src/main/java/me/eccentric_nz/TARDIS/schematic/actions/SchematicSave.java @@ -219,7 +219,7 @@ public boolean act(TARDIS plugin, Player player, String which) { if (tdi != null) { stack.addProperty("light", tdi.isLight()); stack.addProperty("lit", tdi.isLit()); - if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR) { + if (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR) { stack.addProperty("door", true); } } diff --git a/todo.md b/todo.md index bb374cd3c..07fa6f282 100644 --- a/todo.md +++ b/todo.md @@ -7,7 +7,7 @@ 3. Custom Control models [#703](https://github.com/eccentricdevotion/TARDIS/issues/703) [#355](https://github.com/eccentricdevotion/TARDIS/issues/355) * New interior with console -4. Update old light level controls, and light switch should return to correct level +4. Add doors to shop item 5. ? ## Next version `5.7.0` From 1e2d2cd85cb5655816408c84f1d00bee2bf4aeb3 Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sun, 12 May 2024 22:21:44 +1200 Subject: [PATCH 94/96] Add BONE console --- .../TARDIS/blueprints/BlueprintConsole.java | 1 + .../TARDIS/builders/TARDISBuildAbandoned.java | 11 +++++++++-- .../TARDIS/builders/TARDISBuilderInner.java | 11 +++++++++-- .../TARDIS/commands/TARDISRecipeCommands.java | 1 + .../TARDIS/commands/TARDISRecipeTabComplete.java | 2 +- .../TARDIS/desktop/TARDISFullThemeRunnable.java | 9 ++++++++- .../desktop/TARDISThemeRepairRunnable.java | 9 ++++++++- .../TARDIS/files/TARDISArtronUpdater.java | 1 + .../TARDIS/files/TARDISConsoleLoader.java | 3 +++ .../floodgate/FloodgateDesktopThemeForm.java | 1 + .../TARDIS/info/TARDISDescription.java | 1 + .../eccentric_nz/TARDIS/info/TARDISInfoMenu.java | 3 ++- .../info/TARDISInformationSystemListener.java | 3 +++ .../TARDIS/listeners/TARDISCraftListener.java | 1 + .../me/eccentric_nz/tardisshop/ShopItem.java | 4 ++++ src/main/resources/artron.yml | 1 + src/main/resources/consoles/bone.tschm | Bin 0 -> 2646 bytes src/main/resources/items.yml | 1 + src/main/resources/plugin.yml | 1 + 19 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/consoles/bone.tschm diff --git a/src/main/java/me/eccentric_nz/TARDIS/blueprints/BlueprintConsole.java b/src/main/java/me/eccentric_nz/TARDIS/blueprints/BlueprintConsole.java index 388e7e235..882b5de9a 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/blueprints/BlueprintConsole.java +++ b/src/main/java/me/eccentric_nz/TARDIS/blueprints/BlueprintConsole.java @@ -21,6 +21,7 @@ public enum BlueprintConsole { ANCIENT("tardis.ancient"), ARS("tardis.ars"), BIGGER("tardis.bigger"), + BONE("tardis.bone"), CAVE("tardis.cave"), COPPER("tardis.copper"), CORAL("tardis.coral"), diff --git a/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuildAbandoned.java b/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuildAbandoned.java index 54ba2abc7..264d4477e 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuildAbandoned.java +++ b/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuildAbandoned.java @@ -20,6 +20,7 @@ import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.TARDISBuilderInstanceKeeper; import me.eccentric_nz.TARDIS.TARDISConstants; +import me.eccentric_nz.TARDIS.console.ConsoleBuilder; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItem; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItemUtils; import me.eccentric_nz.TARDIS.desktop.TARDISChunkUtils; @@ -106,7 +107,7 @@ class TARDISBuildAbandoned implements Runnable { * Builds the interior of an abandoned TARDIS. * * @param plugin an instance of the TARDIS plugin main class. - * @param schm the name of the schematic file to use can be ANCIENT, ARS, BIGGER, BUDGET, CAVE, COPPER, CORAL, + * @param schm the name of the schematic file to use can be ANCIENT, ARS, BIGGER, BONE, BUDGET, CAVE, COPPER, CORAL, * CURSED, CUSTOM, DELTA, DELUXE, DIVISION, ELEVENTH, ENDER, FACTORY, FIFTEENTH, FUGITIVE, HOSPITAL, * MASTER, MECHANICAL, ORIGINAL, PLANK, PYRAMID, REDSTONE, ROTOR, STEAMPUNK, THIRTEENTH, TOM, TWELFTH, * WAR, WEATHERED, WOOD, LEGACY_BIGGER, LEGACY_DELUXE, LEGACY_ELEVENTH, LEGACY_REDSTONE or a CUSTOM @@ -292,6 +293,12 @@ public void run() { int z = startz + col; BlockData data = plugin.getServer().createBlockData(c.get("data").getAsString()); Material type = data.getMaterial(); + if (type.equals(Material.LIGHT_GRAY_CONCRETE) && schm.getPermission().equals("bone")) { + // get the block + Block block = new Location(world, x, y, z).getBlock(); + // build a console + new ConsoleBuilder(plugin).create(block, 1, dbID, TARDISConstants.UUID_ZERO.toString()); + } if (type.equals(Material.SCULK_SHRIEKER)) { // remember the location, so we can make it shriek when flying String shrieker = new Location(world, x, y, z).toString(); @@ -521,7 +528,7 @@ public void run() { data = switch (schm.getPermission()) { case "ender" -> Material.END_STONE_BRICKS.createBlockData(); case "delta", "cursed" -> Material.BLACKSTONE.createBlockData(); - case "ancient", "fugitive" -> Material.GRAY_WOOL.createBlockData(); + case "ancient", "bone", "fugitive" -> Material.GRAY_WOOL.createBlockData(); case "hospital" -> Material.LIGHT_GRAY_WOOL.createBlockData(); default -> Material.STONE_BRICKS.createBlockData(); }; diff --git a/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuilderInner.java b/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuilderInner.java index a1d5b1f31..e2f3b9910 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuilderInner.java +++ b/src/main/java/me/eccentric_nz/TARDIS/builders/TARDISBuilderInner.java @@ -21,6 +21,7 @@ import me.eccentric_nz.TARDIS.TARDISBuilderInstanceKeeper; import me.eccentric_nz.TARDIS.TARDISConstants; import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; +import me.eccentric_nz.TARDIS.console.ConsoleBuilder; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItem; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItemUtils; import me.eccentric_nz.TARDIS.database.resultset.ResultSetAchievements; @@ -112,7 +113,7 @@ public class TARDISBuilderInner implements Runnable { * Builds the inside of the TARDIS. * * @param plugin an instance of the main TARDIS plugin class - * @param schm the name of the schematic file to use can be ANCIENT, ARS, BIGGER, BUDGET, CAVE, COPPER, CORAL, + * @param schm the name of the schematic file to use can be ANCIENT, ARS, BIGGER, BONE, BUDGET, CAVE, COPPER, CORAL, * CURSED, CUSTOM, DELTA, DELUXE, DIVISION, ELEVENTH, ENDER, FACTORY, FIFTEENTH, FUGITIVE, * HOSPITAL, MASTER, MECHANICAL, ORIGINAL, PLANK, PYRAMID, REDSTONE, ROTOR, STEAMPUNK, THIRTEENTH, * TOM, TWELFTH, WAR, WEATHERED, WOOD, LEGACY_BIGGER, LEGACY_DELUXE, LEGACY_ELEVENTH, @@ -371,6 +372,12 @@ public void run() { int z = startz + col; BlockData data = plugin.getServer().createBlockData(c.get("data").getAsString()); Material type = data.getMaterial(); + if (type.equals(Material.LIGHT_GRAY_CONCRETE) && schm.getPermission().equals("bone")) { + // get the block + Block block = new Location(world, x, y, z).getBlock(); + // build a console + new ConsoleBuilder(plugin).create(block, 1, dbID, playerUUID); + } if (type.equals(Material.SCULK_SHRIEKER)) { // remember the location, so we can make it shriek when flying String shrieker = new Location(world, x, y, z).toString(); @@ -618,7 +625,7 @@ public void run() { data = switch (schm.getPermission()) { case "ender" -> Material.END_STONE_BRICKS.createBlockData(); case "delta", "cursed" -> Material.BLACKSTONE.createBlockData(); - case "ancient", "fugitive" -> Material.GRAY_WOOL.createBlockData(); + case "ancient", "bone", "fugitive" -> Material.GRAY_WOOL.createBlockData(); case "hospital" -> Material.LIGHT_GRAY_WOOL.createBlockData(); default -> Material.STONE_BRICKS.createBlockData(); }; diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeCommands.java b/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeCommands.java index 50cccc6d8..4345a58f9 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeCommands.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeCommands.java @@ -83,6 +83,7 @@ public TARDISRecipeCommands(TARDIS plugin) { t.put("ANCIENT", Material.SCULK); // ancient t.put("ARS", Material.QUARTZ_BLOCK); // ARS t.put("BIGGER", Material.GOLD_BLOCK); // bigger + t.put("BONE", Material.WAXED_OXIDIZED_CUT_COPPER); // bone loosely based on a console by DT10 - https://www.youtube.com/watch?v=Ux4qt0qYm80 t.put("BUDGET", Material.IRON_BLOCK); // budget t.put("CAVE", Material.DRIPSTONE_BLOCK); // dripstone cave t.put("COPPER", Material.WARPED_PLANKS); // copper schematic designed by vistaero diff --git a/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeTabComplete.java b/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeTabComplete.java index 1a04abf3d..c8114bd63 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeTabComplete.java +++ b/src/main/java/me/eccentric_nz/TARDIS/commands/TARDISRecipeTabComplete.java @@ -36,7 +36,7 @@ public class TARDISRecipeTabComplete extends TARDISCompleter implements TabCompl public static final Set ROOT_SUBS = new HashSet<>(); public static final List TARDIS_TYPES = ImmutableList.of( "ancient", "ars", - "bigger", "budget", + "bigger", "bone", "budget", "cave", "copper", "coral", "cursed", "custom", "delta", "deluxe", "division", "eleventh", "ender", diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java index a79f1e7d2..055ade76f 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java @@ -26,6 +26,7 @@ import me.eccentric_nz.TARDIS.builders.FractalFence; import me.eccentric_nz.TARDIS.builders.TARDISInteriorPostioning; import me.eccentric_nz.TARDIS.builders.TARDISTIPSData; +import me.eccentric_nz.TARDIS.console.ConsoleBuilder; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItem; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItemUtils; import me.eccentric_nz.TARDIS.database.data.Archive; @@ -562,6 +563,12 @@ public void run() { set.put("beacon", bedrocloc); postBedrock = b; } + if (type.equals(Material.LIGHT_GRAY_CONCRETE) && tud.getSchematic().getPermission().equals("bone")) { + // get the block + Block block = new Location(world, x, y, z).getBlock(); + // build a console + new ConsoleBuilder(plugin).create(block, 1, id, uuid.toString()); + } if (type.equals(Material.SCULK_SHRIEKER)) { // remember the location, so we can make it shriek when flying String shrieker = new Location(world, x, y, z).toString(); @@ -800,7 +807,7 @@ public void run() { data = switch (tud.getSchematic().getPermission()) { case "ender" -> Material.END_STONE_BRICKS.createBlockData(); case "delta", "cursed" -> Material.BLACKSTONE.createBlockData(); - case "ancient", "fugitive" -> Material.GRAY_WOOL.createBlockData(); + case "ancient", "bone", "fugitive" -> Material.GRAY_WOOL.createBlockData(); case "hospital" -> Material.LIGHT_GRAY_WOOL.createBlockData(); default -> Material.STONE_BRICKS.createBlockData(); }; diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java index 592276ba7..b3199e8aa 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java @@ -25,6 +25,7 @@ import me.eccentric_nz.TARDIS.builders.FractalFence; import me.eccentric_nz.TARDIS.builders.TARDISInteriorPostioning; import me.eccentric_nz.TARDIS.builders.TARDISTIPSData; +import me.eccentric_nz.TARDIS.console.ConsoleBuilder; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItem; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItemUtils; import me.eccentric_nz.TARDIS.database.data.Archive; @@ -418,6 +419,12 @@ public void run() { set.put("beacon", bedrocloc); postBedrock = world.getBlockAt(x, y, z); } + if (type.equals(Material.LIGHT_GRAY_CONCRETE) && tud.getSchematic().getPermission().equals("bone")) { + // get the block + Block block = new Location(world, x, y, z).getBlock(); + // build a console + new ConsoleBuilder(plugin).create(block, 1, id, uuid.toString()); + } if (type.equals(Material.SCULK_SHRIEKER)) { // remember the location, so we can make it shriek when flying String shrieker = new Location(world, x, y, z).toString(); @@ -538,7 +545,7 @@ public void run() { data = switch (tud.getSchematic().getPermission()) { case "ender" -> Material.END_STONE_BRICKS.createBlockData(); case "delta", "cursed" -> Material.BLACKSTONE.createBlockData(); - case "ancient", "fugitive" -> Material.GRAY_WOOL.createBlockData(); + case "ancient", "bone", "fugitive" -> Material.GRAY_WOOL.createBlockData(); case "hospital" -> Material.LIGHT_GRAY_WOOL.createBlockData(); default -> Material.STONE_BRICKS.createBlockData(); }; diff --git a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISArtronUpdater.java b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISArtronUpdater.java index 4e3b08a61..235fe5be3 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISArtronUpdater.java +++ b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISArtronUpdater.java @@ -86,6 +86,7 @@ public TARDISArtronUpdater(TARDIS plugin) { integerOptions.put("upgrades.ancient", 5000); integerOptions.put("upgrades.ars", 5000); integerOptions.put("upgrades.bigger", 7500); + integerOptions.put("upgrades.bone", 5000); integerOptions.put("upgrades.budget", 5000); integerOptions.put("upgrades.cave", 5000); integerOptions.put("upgrades.copper", 20000); diff --git a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISConsoleLoader.java b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISConsoleLoader.java index 041250a64..e9071549d 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/files/TARDISConsoleLoader.java +++ b/src/main/java/me/eccentric_nz/TARDIS/files/TARDISConsoleLoader.java @@ -36,6 +36,7 @@ public class TARDISConsoleLoader { private final TARDIS plugin; private boolean save = false; +// Material material = Material.WAXED_OXIDIZED_CUT_COPPER; public TARDISConsoleLoader(TARDIS plugin) { this.plugin = plugin; @@ -47,6 +48,8 @@ public void addSchematics() { // DELUXE, ELEVENTH, TWELFTH, ARS & REDSTONE schematics designed by Lord_Rahl and killeratnight at mcnovus.net Consoles.getBY_NAMES().put("ARS", new Schematic("QUARTZ_BLOCK", "ars", "ARS Console", ConsoleSize.SMALL, true, TardisLight.TENTH, false)); Consoles.getBY_NAMES().put("BIGGER", new Schematic("GOLD_BLOCK", "bigger", "A Bigger Console", ConsoleSize.MEDIUM, true, TardisLight.TENTH, false)); + // BONE loosely based on a console by DT10 - https://www.youtube.com/watch?v=Ux4qt0qYm80 + Consoles.getBY_NAMES().put("BONE", new Schematic("WAXED_OXIDIZED_CUT_COPPER", "bone", "An Early Style Console", ConsoleSize.SMALL, true, TardisLight.CLASSIC, false)); Consoles.getBY_NAMES().put("BUDGET", new Schematic("IRON_BLOCK", "budget", "Default Console", ConsoleSize.SMALL, true, TardisLight.TENTH, false)); Consoles.getBY_NAMES().put("CAVE", new Schematic("DRIPSTONE_BLOCK", "cave", "Cave Console", ConsoleSize.SMALL, false, TardisLight.LAMP, false)); // COPPER & CORAL schematics designed by vistaero diff --git a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateDesktopThemeForm.java b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateDesktopThemeForm.java index 7841e185d..9fbc299ba 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateDesktopThemeForm.java +++ b/src/main/java/me/eccentric_nz/TARDIS/floodgate/FloodgateDesktopThemeForm.java @@ -32,6 +32,7 @@ public FloodgateDesktopThemeForm(TARDIS plugin, UUID uuid) { blocks.put("ANCIENT", "sculk"); blocks.put("ARS", "quartz"); blocks.put("BIGGER", "gold"); + blocks.put("BONE", "waxed_oxidized_cut_copper"); blocks.put("BUDGET", "iron"); blocks.put("CAVE", "cave"); blocks.put("COPPER", "warped_planks"); diff --git a/src/main/java/me/eccentric_nz/TARDIS/info/TARDISDescription.java b/src/main/java/me/eccentric_nz/TARDIS/info/TARDISDescription.java index 3e64db98f..50227d9c5 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/info/TARDISDescription.java +++ b/src/main/java/me/eccentric_nz/TARDIS/info/TARDISDescription.java @@ -176,6 +176,7 @@ public enum TARDISDescription { WEATHERED("A weathered copper TARDIS."), ORIGINAL("The original v1.0 TARDIS."), ANCIENT("An ancient deep dark TARDIS."), + BONE("An early era styled TARDIS."), CUSTOM("A custom designed server TARDIS"), ALLAY("An allay house, bring your friends."), ANTIGRAVITY("Going up..."), diff --git a/src/main/java/me/eccentric_nz/TARDIS/info/TARDISInfoMenu.java b/src/main/java/me/eccentric_nz/TARDIS/info/TARDISInfoMenu.java index 2ef876995..c355b9ac1 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/info/TARDISInfoMenu.java +++ b/src/main/java/me/eccentric_nz/TARDIS/info/TARDISInfoMenu.java @@ -206,6 +206,7 @@ public enum TARDISInfoMenu { TYPES("TIS|TARDIS Types", "TIS", "T"), ARS("TIS|TARDIS Types|ARS", "TYPES", "A"), BIGGER("TIS|TARDIS Types|Bigger", "TYPES", "i"), + BONE("TIS|TARDIS Types|Bone!", "TYPES", "!"), BUDGET("TIS|TARDIS Types|Budget", "TYPES", "B"), CAVE("TIS|TARDIS Types|Cave", "TYPES", "v"), COPPER_11TH("TIS|TARDIS Types|Copper 11th", "TYPES", "1"), @@ -645,7 +646,7 @@ public boolean isDisk() { public boolean isConsole() { switch (this) { - case ARS, BIGGER, BUDGET, CAVE, COPPER_11TH, CORAL, CURSED, DELTA, DELUXE, DIVISION, ELEVENTH, ENDER, + case ARS, BIGGER, BONE, BUDGET, CAVE, COPPER_11TH, CORAL, CURSED, DELTA, DELUXE, DIVISION, ELEVENTH, ENDER, FACTORY, FIFTEENTH, FUGITIVE, HOSPITAL, MASTER, MECHANICAL, PLANK, PYRAMID, REDSTONE, STEAMPUNK, THIRTEENTH, TOM, TWELFTH, WAR, WEATHERED, ORIGINAL, ANCIENT, CUSTOM -> { return true; diff --git a/src/main/java/me/eccentric_nz/TARDIS/info/TARDISInformationSystemListener.java b/src/main/java/me/eccentric_nz/TARDIS/info/TARDISInformationSystemListener.java index 52e39d883..0358ebd6a 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/info/TARDISInformationSystemListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/info/TARDISInformationSystemListener.java @@ -842,6 +842,9 @@ private void processInput(Player p, UUID uuid, String chat) { if (chat.equals("*")) { new TISInfo(plugin).show(p, TARDISInfoMenu.ANCIENT); } + if (chat.equals("!")) { + new TISInfo(plugin).show(p, TARDISInfoMenu.BONE); + } exit(p); } case FOOD_ACCESSORIES -> { diff --git a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISCraftListener.java b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISCraftListener.java index d72f29c00..4833acde9 100755 --- a/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISCraftListener.java +++ b/src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISCraftListener.java @@ -77,6 +77,7 @@ public TARDISCraftListener(TARDIS plugin) { t.put(Material.REDSTONE_BLOCK, "REDSTONE"); // redstone t.put(Material.SANDSTONE_STAIRS, "PYRAMID"); // pyramid schematic designed by airomis (player at thatsnotacreeper.com) t.put(Material.SCULK, "ANCIENT"); // ancient city + t.put(Material.WAXED_OXIDIZED_CUT_COPPER, "BONE"); // bone loosely based on a console by DT10 - https://www.youtube.com/watch?v=Ux4qt0qYm80 t.put(Material.WARPED_PLANKS, "COPPER"); // copper schematic designed by vistaero t.put(Material.WEATHERED_COPPER, "WEATHERED"); // weathered copper t.put(Material.WHITE_CONCRETE, "HOSPITAL"); // hospital diff --git a/src/main/java/me/eccentric_nz/tardisshop/ShopItem.java b/src/main/java/me/eccentric_nz/tardisshop/ShopItem.java index 583245ddd..2d43cb4de 100644 --- a/src/main/java/me/eccentric_nz/tardisshop/ShopItem.java +++ b/src/main/java/me/eccentric_nz/tardisshop/ShopItem.java @@ -18,6 +18,7 @@ public enum ShopItem { BLANK_STORAGE_DISK("Blank Storage Disk", Material.MUSIC_DISC_STRAD, 10000001), BLUE_BOW_TIE("Blue Bow Tie", Material.LEATHER_HELMET, 10000034), BLUEBERRY_JELLY_BABY("Blueberry Jelly Baby", Material.MELON_SLICE, 10000012, ShopItemRecipe.SHAPELESS), + BONE_SEED("Bone Seed", Material.WAXED_OXIDIZED_CUT_COPPER, 1, ShopItemRecipe.SEED), BOWL_OF_CUSTARD("Bowl of Custard", Material.MUSHROOM_STEW, 10000001, ShopItemRecipe.SHAPELESS), BROWN_BOW_TIE("Brown Bow Tie", Material.LEATHER_HELMET, 10000035), BRUSH_CIRCUIT("Brush Circuit", Material.GLOWSTONE_DUST, 10001987), @@ -173,9 +174,11 @@ public enum ShopItem { BLUEPRINT_CONSOLE_ANCIENT("Blueprint Ancient", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), BLUEPRINT_CONSOLE_ARS("Blueprint Ars", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), BLUEPRINT_CONSOLE_BIGGER("Blueprint Bigger", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), + BLUEPRINT_CONSOLE_BONE("Blueprint Bone", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), BLUEPRINT_CONSOLE_CAVE("Blueprint Cave", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), BLUEPRINT_CONSOLE_COPPER("Blueprint Copper", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), BLUEPRINT_CONSOLE_CORAL("Blueprint Coral", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), + BLUEPRINT_CONSOLE_CURSED("Blueprint Cursed", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), BLUEPRINT_CONSOLE_CUSTOM("Blueprint Custom", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), BLUEPRINT_CONSOLE_DELTA("Blueprint Delta", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), BLUEPRINT_CONSOLE_DELUXE("Blueprint Deluxe", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), @@ -183,6 +186,7 @@ public enum ShopItem { BLUEPRINT_CONSOLE_ELEVENTH("Blueprint Eleventh", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), BLUEPRINT_CONSOLE_ENDER("Blueprint Ender", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), BLUEPRINT_CONSOLE_FACTORY("Blueprint Factory", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), + BLUEPRINT_CONSOLE_FIFTEENTH("Blueprint Fifteenth", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), BLUEPRINT_CONSOLE_FUGITIVE("Blueprint Fugutive", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), BLUEPRINT_CONSOLE_HOSPITAL("Blueprint Hospital", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), BLUEPRINT_CONSOLE_LEGACY_BIGGER("Blueprint Legacy Bigger", Material.MUSIC_DISC_MELLOHI, 10000001, ShopItemRecipe.BLUEPRINT), diff --git a/src/main/resources/artron.yml b/src/main/resources/artron.yml index 01a442988..88241fa1e 100755 --- a/src/main/resources/artron.yml +++ b/src/main/resources/artron.yml @@ -35,6 +35,7 @@ upgrades: ancient: 5000 ars: 5000 bigger: 7500 + bone: 5000 budget: 5000 cave: 5000 copper: 20000 diff --git a/src/main/resources/consoles/bone.tschm b/src/main/resources/consoles/bone.tschm new file mode 100644 index 0000000000000000000000000000000000000000..efa85bedcce10292785cce75c33068085b354d0e GIT binary patch literal 2646 zcmV-c3aRxUiwFP!00000|Lt8}Z=*OA{VOY;S*hKf*;z%(L#ORdtL?O-PFJf@R3QhP z1eIdeIFo*;|9x#pzXO3l@U^+~&`ENPF+S&B?CXoUcQ}oR2!B#%aPQnWgWZp=bL$L# z-F2Ni`R&1Vg7BKgX~^PK6K6ia93a?l@6>h}*D;f+ZBuc59um$Ch-!73-q!a=4rwHIk5hwtVk@fZ_`FyYkH?3c zjwngRFqU84m~k;1reUxY!*KVbn^lWG!H>77@&pf^AMy{2c541n7h?iB#}lyK)Ek1_0T0& zS=&Ru^ZTd;XaF(-4FJf5*y*2et^)J12R9aH2ewA4*zb(bOq25)23JKzZ zZz0g$QhUB2>&++$Mo;UoZaR~6F1?w!P3SORzHPGbufHP!`U;)Q8>xA5&x=*>ep2O z@uEA|jqX-$O&+>&h<%2_X~S(bXZyAYgKeS%a7bQK|3B^HS!?Mh~rzRfXBe zazt*zba>NIIRHYi!F=C#cTxUI;|dy|s0Z|Q)|a^(NH|T?Ij3saEa<4_{v|%)2^D4W z0H4J^r=sB9!MX&ob>2H;u_75z(lgr>h1R=HTMBA!0Y33V;!SAmFKNot5p$mM&pAQ) z=Y>knj@Weil!l#gRiTNc9c?^IK$zar9lE z#e*UGlk#=)Dmh~%b%75~=mOr#p=cbE$)vs<%Bs(*tf01yMj*A^30TdncPo|V7^Nfk zZJfMCVB;BYb)wC__2}>t1viZ{Cs9U~$zH;y!F8t=4{jhLc$lccnKxrhawY`vXHTc= zc+gu}RrRCn??MlobbPzk2FQhJotI@>yHwuIr9;&ijK(dg>URa;SSqFuVrEO_En0Rz)O**0sxytq zc$974Ay`s*y{g9wvC+UW<;4Ipw%3<=d{(^(W=!HZALu>}Z!aC!$$xeR_wrLpJ)cEv zF26co&i8&uIFVC)%Hz}-$j)7Uk?8k}^W$%a-pS!#7te*B5B_|zxBqw6pm&GtAD&(u zp4U9+{P@dJ-4lI1J~%izTy@aDN5>b3Zx8yqcXHz8hkjpmP}U!>kNJFdez5vd^1_!7 zWdS5iAKGpbSiCRuV& zp-Gk;Q*4qe?bu9{v|YB@pIX9Da)?D*$xz1viwpm~W zEyUSUAxor%&NiKqY%4)dRM@AokHridKmaaDp-K!?Nwd`;0BJ5T0Zfg8oEp_%027-! z_vM(_gyJz^AOK-9QCT*axr8#aGF7QX!1&~(*Flr)xg$%0COSrXCP=ndv1B9EVU@i4 zN1w4Q71IYXU8xYL{M7mG@5?*!JXxE?RB79v6|XM}*doRk7=Z=aP65!LWMdDTfcp~D zW?=H7mq{x|$Sv)aw4mxg8m!F9AMQYu0;W%F3g9|*D*(8-Arg*+*B~7Hlm!aUn3#Z? zfdJsza_7Dr6BAH81`Gs1FW9xTH-&*yRC5Gm+)frIuG-wvC}Imwl7A;Aojwjo-_2 z0!H*k&^TCbjO@Nh4gkw;zpNG){_W*vgXt7*i(vD%2*%lvev2^0hH$qZ-8KYz-UrD* zS_FEQx>C2uhPw|!2!i7h$r?hJ4<=RRba{LdMiJrVJ^&?T8PJl1wp>jed1+o{L1h{3 zoFJ{rpp=@AZ8SKbs+WOk=#yhXRT!ZP`~67cAO%eR(T`wq5P+eF-P2|rD_th&%I*NM zRdO&k2I{cH8Z!Wyrl%b=d!LaA^inPkR!y{tx!PFK4NwPZwv4ip_|X9Kn8eeiLhrgNZH zSwY%YFbv=qutV6M0L&JOiP07vQ9~2hH$Bp672zfd$R0MW0&t}q9)MN?4X}cdO3zbw zSfV&mdT z#28<_xmP#uHrEfB#9TiBeT+b|3`lLUhhYTFXT)a9u$#Gl0LTb502zS>AS2KKWCRe9 zCM=#(wTN@+I-#J~-h`8Dn!h5B)5wdMPejOK^;WqXXYi-%+&Y7gu5;%MK0UZjJ|dD; z{`1YrE0CX0)aw*I^^!vG;D>tgoPQlSgWVnZPyTV8Se`)^y9lr8FXv1!{>wg#Qx;KK zl&kN~AlqxfnS?hqc>MA+OvAA(GsySuP$icwb574r)oG>?TV$=tN~r5Cyn;{J73}W3 zyoA%U^NXYBtJpvL`fcyKdbi!O8O!rNwIgp Date: Sun, 12 May 2024 23:55:29 +1200 Subject: [PATCH 95/96] Remove console if present when changing desktop --- .../resultset/ResultSetScreenInteraction.java | 101 ++++++++++++++++++ .../desktop/TARDISFullThemeRunnable.java | 21 +++- .../desktop/TARDISThemeRepairRunnable.java | 15 +++ 3 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetScreenInteraction.java diff --git a/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetScreenInteraction.java b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetScreenInteraction.java new file mode 100644 index 000000000..a324a36a3 --- /dev/null +++ b/src/main/java/me/eccentric_nz/TARDIS/database/resultset/ResultSetScreenInteraction.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2024 eccentric_nz + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package me.eccentric_nz.TARDIS.database.resultset; + +import me.eccentric_nz.TARDIS.TARDIS; +import me.eccentric_nz.TARDIS.database.TARDISDatabaseConnection; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.UUID; + +/** + * A TARDIS control room, also referred to as a console room, is any place on a TARDIS that contains a functioning + * control console. This flight deck also functions as a point of exit. A control room's look can be changed over time, + * to suit one's tastes and personality. The process by which an operator can transform a control room is fairly simple, + * once compared by the Fifth Doctor to changing a "desktop theme". + * + * @author eccentric_nz + */ +public class ResultSetScreenInteraction { + + private final TARDISDatabaseConnection service = TARDISDatabaseConnection.getINSTANCE(); + private final Connection connection = service.getConnection(); + private final TARDIS plugin; + private final int id; + private final String prefix; + private UUID uuid; + + /** + * Creates a class instance that can be used to retrieve an SQL ResultSet from the interactions table. + * + * @param plugin an instance of the main class. + */ + public ResultSetScreenInteraction(TARDIS plugin, int id) { + this.plugin = plugin; + this.id = id; + prefix = this.plugin.getPrefix(); + } + + /** + * Retrieves an SQL ResultSet from the interactions table. This method builds an SQL query string from the + * parameters supplied and then executes the query. Use the getters to retrieve the results. + * + * @return true or false depending on whether any data matches the query + */ + public boolean resultSet() { + PreparedStatement statement = null; + ResultSet rs = null; + String query = "SELECT * FROM " + prefix + "interactions WHERE tardis_id = ? AND control = 'SCREEN_LEFT'"; + try { + service.testConnection(connection); + statement = connection.prepareStatement(query); + statement.setInt(1, id); + rs = statement.executeQuery(); + if (rs.isBeforeFirst()) { + rs.next(); + try { + uuid = UUID.fromString(rs.getString("uuid")); + } catch (IllegalArgumentException ignored) { + } + } else { + return false; + } + } catch (SQLException e) { + plugin.debug("ResultSet error for screen interaction! " + e.getMessage()); + return false; + } finally { + try { + if (rs != null) { + rs.close(); + } + if (statement != null) { + statement.close(); + } + } catch (SQLException e) { + plugin.debug("Error closing screen interaction! " + e.getMessage()); + } + } + return true; + } + + public UUID getUuid() { + return uuid; + } +} diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java index 055ade76f..d37d724d5 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISFullThemeRunnable.java @@ -27,11 +27,13 @@ import me.eccentric_nz.TARDIS.builders.TARDISInteriorPostioning; import me.eccentric_nz.TARDIS.builders.TARDISTIPSData; import me.eccentric_nz.TARDIS.console.ConsoleBuilder; +import me.eccentric_nz.TARDIS.console.ConsoleDestroyer; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItem; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItemUtils; import me.eccentric_nz.TARDIS.database.data.Archive; import me.eccentric_nz.TARDIS.database.data.Tardis; import me.eccentric_nz.TARDIS.database.resultset.ResultSetARS; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetScreenInteraction; import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; import me.eccentric_nz.TARDIS.database.resultset.ResultSetTravellers; import me.eccentric_nz.TARDIS.enumeration.ConsoleSize; @@ -56,6 +58,7 @@ import org.bukkit.block.data.Directional; import org.bukkit.block.data.Levelled; import org.bukkit.entity.*; +import org.bukkit.persistence.PersistentDataType; import java.util.ArrayList; import java.util.HashMap; @@ -63,9 +66,8 @@ import java.util.UUID; /** - * There was also a safety mechanism for when TARDIS rooms were deleted, - * automatically relocating any living beings in the deleted room, depositing - * them in the control room. + * There was also a safety mechanism for when TARDIS rooms were deleted, automatically relocating any living beings in + * the deleted room, depositing them in the control room. * * @author eccentric_nz */ @@ -248,6 +250,18 @@ public void run() { TARDISTimeRotor.updateRotorRecord(id, ""); plugin.getGeneralKeeper().getTimeRotors().add(tardis.getRotor()); } + // remove console if present + ResultSetScreenInteraction rssi = new ResultSetScreenInteraction(plugin, id); + if (rssi.resultSet() && rssi.getUuid() != null) { + Entity screen = chunk.getWorld().getEntity(rssi.getUuid()); + if (screen != null && screen.getPersistentDataContainer().has(plugin.getUnaryKey(), PersistentDataType.STRING)) { + String uuids = screen.getPersistentDataContainer().get(plugin.getUnaryKey(), PersistentDataType.STRING); + if (uuids != null) { + // remove the console + new ConsoleDestroyer(plugin).returnStack(uuids, id); + } + } + } chunks = TARDISChunkUtils.getConsoleChunks(chunk, tud.getSchematic()); previousChunks = TARDISChunkUtils.getConsoleChunks(chunk, tud.getPrevious()); if (!tardis.getCreeper().isEmpty()) { @@ -347,7 +361,6 @@ public void run() { previousChunks.forEach((c) -> { // remove any item display or interactions TARDISDisplayItemUtils.removeDisplaysInChunk(c, 62, 64 + ph); - }); plugin.getPM().callEvent(new TARDISDesktopThemeEvent(player, tardis, tud)); } diff --git a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java index b3199e8aa..18cfb6868 100644 --- a/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java +++ b/src/main/java/me/eccentric_nz/TARDIS/desktop/TARDISThemeRepairRunnable.java @@ -26,10 +26,12 @@ import me.eccentric_nz.TARDIS.builders.TARDISInteriorPostioning; import me.eccentric_nz.TARDIS.builders.TARDISTIPSData; import me.eccentric_nz.TARDIS.console.ConsoleBuilder; +import me.eccentric_nz.TARDIS.console.ConsoleDestroyer; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItem; import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItemUtils; import me.eccentric_nz.TARDIS.database.data.Archive; import me.eccentric_nz.TARDIS.database.data.Tardis; +import me.eccentric_nz.TARDIS.database.resultset.ResultSetScreenInteraction; import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardis; import me.eccentric_nz.TARDIS.enumeration.ConsoleSize; import me.eccentric_nz.TARDIS.enumeration.TardisModule; @@ -52,6 +54,7 @@ import org.bukkit.block.data.Directional; import org.bukkit.block.data.Levelled; import org.bukkit.entity.*; +import org.bukkit.persistence.PersistentDataType; import java.util.*; @@ -188,6 +191,18 @@ public void run() { plugin.getGeneralKeeper().getTimeRotors().add(tardis.getRotor()); } } + // remove console if present + ResultSetScreenInteraction rssi = new ResultSetScreenInteraction(plugin, id); + if (rssi.resultSet() && rssi.getUuid() != null) { + Entity screen = chunk.getWorld().getEntity(rssi.getUuid()); + if (screen != null && screen.getPersistentDataContainer().has(plugin.getUnaryKey(), PersistentDataType.STRING)) { + String uuids = screen.getPersistentDataContainer().get(plugin.getUnaryKey(), PersistentDataType.STRING); + if (uuids != null) { + // remove the console + new ConsoleDestroyer(plugin).returnStack(uuids, id); + } + } + } chunks = TARDISChunkUtils.getConsoleChunks(chunk, tud.getSchematic()); if (!tardis.getCreeper().isEmpty()) { Location creeper = TARDISStaticLocationGetters.getLocationFromDB(tardis.getCreeper()); From fe7f915e36bb40b2965433801d712d4f679b41ee Mon Sep 17 00:00:00 2001 From: eccentricdevotion Date: Sun, 12 May 2024 23:55:35 +1200 Subject: [PATCH 96/96] Update bone.tschm --- src/main/resources/consoles/bone.tschm | Bin 2646 -> 2835 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/consoles/bone.tschm b/src/main/resources/consoles/bone.tschm index efa85bedcce10292785cce75c33068085b354d0e..b306e175cd446ac77cd2222ffb3e52b1e0fd1041 100644 GIT binary patch literal 2835 zcmaKucQhLc8^$9-6I!)fE)}s!iB+p+6*XhTH5*0Ltk%||c2OhLsM=a1Vk=4zs#aU0 z_DpGL>`jg0yWjomyXV~Vz5hP%InVRH&p$t&mter(bFpD->pAm*`Am#nc@5Y{+SvRU z$}`PRxN^%QPUhORC?@cG&6(-m!t}y5{=4U=DJgp%eJKYWyt2VM9z1b{0R!>93o$1P zk2#r`LP`dfUwD(_8NN3SR7fj6&QW@}pV#?p0`gHHVFcTS6Rl;SuEBPN_~y`Dq0sZH zUaTuJB~XsHc4H8R=DWZ89Cte*G0=ft%V^01h0IvvH`M`#InVs*wKNjd8r#zd39M%u zoZ_MJYSdUJXMhy&ikenFRWDcuz!63ZDX3JZo zBLZADVrox@Apuan4H`8Mx+1F{yKmg`7_k~*BF!&kj=?ZhQv=GFPhHePzg0FCW`x+3 z5R?eK(q*xYsu8}CcvT?>nG*K|PHdJW+e;dD+VMs2EGWt05f=tmfOX+CW5uxjD$iDa zvoxdSg#0JagLj;}Py))N_1=`io*<^;OO{Wyi}9i9I1E*pZw`P(P@=6su65@3w9}Si ztpK1&*AD8U5zT-68~}WiWREqZwpeqy5pIQ0qaUO2>Xa}jqCtqO_$nP(LTIQL+G@2x zue`S5MF{zqG5z0V0kFxHv_Uglvd^koWe*GwBwBsUtW5ABX_hyMiS~2ItunPJ(36fv zMrTi)G8%ipo(g)^<7**jtD`7K(w`Od$(Hzj%kpUAdomz6%JAnE{Ru!XR8z%7w#FeQOTwI^)U=-hF|G?HgfX3N4^{3^?K)ePxJ+%zrpc90Sw|9fr|kuA$gp?gT9yS8x&qqhXcj7g zOQ}W1Vt-hxUxbbKXl51jw%l^|P>@2oXpB!DY?#b_$Ga(F z+1&ZMh->K|Sdcg%WfZLH^GW46<{DJLtF`{4T4R1G#@WJ&cD*J3t??`Ud8Ll9wmGyd04bB2D%2 zWEe%|GMqm?JYTLVSNCL4P&^I_^fKPde>tM6I6hI~C%~N?vS`eQG$IjfwVGDT?jtmP4H1i)Q97ch7GH&dpm}Dl zvQKJhGS-_w>^L<`yBVSvXV*!CNXGl46Ju?JZ&1?$8HHG0idn&%hSVh*bn_`3M*}B#WXkIUSj^{ZaYTtHzZmiUS0x9c_pKvEZbfFT2zP z)Ot;2){cV)ioD{a%YH6ZF+=?k&rk|;TzQekngLB$)gYF%@A(T7@i@M!kaTKeOFu=S z*%5l^ke&P64k}dZWwTB!7k$}BFlus3oAZ*0-ELCIyG$M&GwlqYnbUckc(=pJu%W*= zeadt>Sa9vF4N*s*)mBx{3p|SXl<3Zj2Z)t}Oatd@UF^~J>=39_w07Q9Yn5AwrH!({ zea#n|p$p zA`2^7B^h}hzSR^b5l;VZ4b_n$x5bX(hS_MRG~d9Jiq?#=(r+uS{srmrr9)wb)Egf8 zhx^44uF@5*Qj|INknJ+{5zRVdGfU`{hNR?lA)l)=@U&Q4u>v-$Nj243i~>}qc2W=N z=2Mv?hOI=))D>KjQxV-XUUaPw3(_PLU7Wd{?K${^LouARcG%ya&uA(-oHq?7-5mm1 zKr_x1XG-q}4@|tQzgZXZD_4D3wp9ht(X;x$K+;}>4EPt8(YIfm8tY#xH3^b`)a6Xkm6qn^rNME zTo&(s6@od|Je8PBkUp97eU$U9s?wVhA42fY3DV@p|NeeWs7ftF#ZA5`O{9R_O>dRF=jJ7u+U_~^f?@@gjoWk~gO&5!^Tz@~D#Q=Jk9^p)DS2%z7iFZx zMwjlNElC@_S*YR5sQL2(bOgcx=4CxuN5pJA&1lrSCC2uNXg+C5X-a(h8=bq{xzhDb od+X@8P3yJ<9ff{pvROFjr2JOnK6ia93a?l@6>h}*D;f+ZBuc59um$Ch-!73-q!a=4rwHIk5hwtVk@fZ_`FyYkH?3c zjwngRFqU84m~k;1reUxY!*KVbn^lWG!H>77@&pf^AMy{2c541n7h?iB#}lyK)Ek1_0T0& zS=&Ru^ZTd;XaF(-4FJf5*y*2et^)J12R9aH2ewA4*zb(bOq25)23JKzZ zZz0g$QhUB2>&++$Mo;UoZaR~6F1?w!P3SORzHPGbufHP!`U;)Q8>xA5&x=*>ep2O z@uEA|jqX-$O&+>&h<%2_X~S(bXZyAYgKeS%a7bQK|3B^HS!?Mh~rzRfXBe zazt*zba>NIIRHYi!F=C#cTxUI;|dy|s0Z|Q)|a^(NH|T?Ij3saEa<4_{v|%)2^D4W z0H4J^r=sB9!MX&ob>2H;u_75z(lgr>h1R=HTMBA!0Y33V;!SAmFKNot5p$mM&pAQ) z=Y>knj@Weil!l#gRiTNc9c?^IK$zar9lE z#e*UGlk#=)Dmh~%b%75~=mOr#p=cbE$)vs<%Bs(*tf01yMj*A^30TdncPo|V7^Nfk zZJfMCVB;BYb)wC__2}>t1viZ{Cs9U~$zH;y!F8t=4{jhLc$lccnKxrhawY`vXHTc= zc+gu}RrRCn??MlobbPzk2FQhJotI@>yHwuIr9;&ijK(dg>URa;SSqFuVrEO_En0Rz)O**0sxytq zc$974Ay`s*y{g9wvC+UW<;4Ipw%3<=d{(^(W=!HZALu>}Z!aC!$$xeR_wrLpJ)cEv zF26co&i8&uIFVC)%Hz}-$j)7Uk?8k}^W$%a-pS!#7te*B5B_|zxBqw6pm&GtAD&(u zp4U9+{P@dJ-4lI1J~%izTy@aDN5>b3Zx8yqcXHz8hkjpmP}U!>kNJFdez5vd^1_!7 zWdS5iAKGpbSiCRuV& zp-Gk;Q*4qe?bu9{v|YB@pIX9Da)?D*$xz1viwpm~W zEyUSUAxor%&NiKqY%4)dRM@AokHridKmaaDp-K!?Nwd`;0BJ5T0Zfg8oEp_%027-! z_vM(_gyJz^AOK-9QCT*axr8#aGF7QX!1&~(*Flr)xg$%0COSrXCP=ndv1B9EVU@i4 zN1w4Q71IYXU8xYL{M7mG@5?*!JXxE?RB79v6|XM}*doRk7=Z=aP65!LWMdDTfcp~D zW?=H7mq{x|$Sv)aw4mxg8m!F9AMQYu0;W%F3g9|*D*(8-Arg*+*B~7Hlm!aUn3#Z? zfdJsza_7Dr6BAH81`Gs1FW9xTH-&*yRC5Gm+)frIuG-wvC}Imwl7A;Aojwjo-_2 z0!H*k&^TCbjO@Nh4gkw;zpNG){_W*vgXt7*i(vD%2*%lvev2^0hH$qZ-8KYz-UrD* zS_FEQx>C2uhPw|!2!i7h$r?hJ4<=RRba{LdMiJrVJ^&?T8PJl1wp>jed1+o{L1h{3 zoFJ{rpp=@AZ8SKbs+WOk=#yhXRT!ZP`~67cAO%eR(T`wq5P+eF-P2|rD_th&%I*NM zRdO&k2I{cH8Z!Wyrl%b=d!LaA^inPkR!y{tx!PFK4NwPZwv4ip_|X9Kn8eeiLhrgNZH zSwY%YFbv=qutV6M0L&JOiP07vQ9~2hH$Bp672zfd$R0MW0&t}q9)MN?4X}cdO3zbw zSfV&mdT z#28<_xmP#uHrEfB#9TiBeT+b|3`lLUhhYTFXT)a9u$#Gl0LTb502zS>AS2KKWCRe9 zCM=#(wTN@+I-#J~-h`8Dn!h5B)5wdMPejOK^;WqXXYi-%+&Y7gu5;%MK0UZjJ|dD; z{`1YrE0CX0)aw*I^^!vG;D>tgoPQlSgWVnZPyTV8Se`)^y9lr8FXv1!{>wg#Qx;KK zl&kN~AlqxfnS?hqc>MA+OvAA(GsySuP$icwb574r)oG>?TV$=tN~r5Cyn;{J73}W3 zyoA%U^NXYBtJpvL`fcyKdbi!O8O!rNwIgp