diff --git a/plugin.yml b/plugin.yml index d2f88fb..e7c79cb 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,5 +1,5 @@ name: AuxProtect -version: 1.0.6 +version: 1.0.7 main: dev.heliosares.auxprotect.AuxProtect description: A plugin designed to suplement CoreProtect in a few ways. api-version: 1.13 diff --git a/pom.xml b/pom.xml index e9203f1..a190481 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 AuxProtect AuxProtect - 1.0.6 + 1.0.7 AuxProtect ${myPath}/plugins diff --git a/src/dev/heliosares/auxprotect/AuxProtect.java b/src/dev/heliosares/auxprotect/AuxProtect.java index f0663a1..0f5deab 100644 --- a/src/dev/heliosares/auxprotect/AuxProtect.java +++ b/src/dev/heliosares/auxprotect/AuxProtect.java @@ -69,6 +69,12 @@ public class AuxProtect extends JavaPlugin implements IAuxProtect { long lastloaded; + private int SERVER_VERSION; + + public int getCompatabilityVersion() { + return SERVER_VERSION; + } + @Override public void onEnable() { instance = this; @@ -77,6 +83,11 @@ public class AuxProtect extends JavaPlugin implements IAuxProtect { this.reloadConfig(); this.getConfig().options().copyDefaults(true); + debug = getConfig().getInt("debug", 0); + + config = new APConfig(this.getConfig()); + config.load(); + YMLManager langManager = new YMLManager("en-us", this); langManager.load(true); lang = new Language(langManager.getData()); @@ -87,10 +98,14 @@ public class AuxProtect extends JavaPlugin implements IAuxProtect { data.getData().set("lastloaded", System.currentTimeMillis()); data.save(); - config = new APConfig(this.getConfig()); - config.load(); - - debug = getConfig().getInt("debug", 0); + try { + SERVER_VERSION = Integer.parseInt(Bukkit.getBukkitVersion().split("\\.")[1]); + } catch (Exception e) { + warning("Failed to parse version string: \"" + Bukkit.getBukkitVersion() + "\". Defaulting to 1.16"); + SERVER_VERSION = 16; + e.printStackTrace(); + } + debug("Compatability version: " + SERVER_VERSION, 1); File sqliteFile = new File(getDataFolder(), "database/auxprotect.db"); if (!sqliteFile.getParentFile().exists()) { @@ -153,9 +168,7 @@ public class AuxProtect extends JavaPlugin implements IAuxProtect { if (System.currentTimeMillis() - lastPos > config.posInterval) { lastPos = System.currentTimeMillis(); for (Player player : Bukkit.getOnlinePlayers()) { - dbRunnable.add(new DbEntry("$" + player.getUniqueId().toString(), EntryAction.POS, false, - player.getLocation(), "", "Y:" + Math.round(player.getLocation().getYaw()) + " P:" - + Math.round(player.getLocation().getPitch()))); + PlayerListener.logPos(AuxProtect.this, player, player.getLocation(), ""); } } } diff --git a/src/dev/heliosares/auxprotect/command/XrayCommand.java b/src/dev/heliosares/auxprotect/command/XrayCommand.java index 9e652de..07403c1 100644 --- a/src/dev/heliosares/auxprotect/command/XrayCommand.java +++ b/src/dev/heliosares/auxprotect/command/XrayCommand.java @@ -260,7 +260,9 @@ public class XrayCommand implements CommandExecutor { actions.add(0); List blocks = new ArrayList<>(); blocks.add(Material.DIAMOND_ORE); - blocks.add(Material.DEEPSLATE_DIAMOND_ORE); + if (plugin.getCompatabilityVersion() >= 17) { + blocks.add(Material.DEEPSLATE_DIAMOND_ORE); + } blocks.add(Material.ANCIENT_DEBRIS); /* @@ -316,8 +318,8 @@ public class XrayCommand implements CommandExecutor { false, res.worldName(), res.getX(), res.getY(), res.getZ(), res.getType().toString().toLowerCase(), ""); - if (res.getType() == Material.DIAMOND_ORE - || res.getType() == Material.DEEPSLATE_DIAMOND_ORE) { + if (res.getType() == Material.DIAMOND_ORE || (plugin.getCompatabilityVersion() >= 17 + && res.getType() == Material.DEEPSLATE_DIAMOND_ORE)) { if (res.getY() > 18) { continue; } diff --git a/src/dev/heliosares/auxprotect/listeners/PlayerListener.java b/src/dev/heliosares/auxprotect/listeners/PlayerListener.java index c740b87..cebed29 100644 --- a/src/dev/heliosares/auxprotect/listeners/PlayerListener.java +++ b/src/dev/heliosares/auxprotect/listeners/PlayerListener.java @@ -55,14 +55,18 @@ public class PlayerListener implements Listener { public PlayerListener(AuxProtect plugin) { this.plugin = plugin; buckets = new ArrayList<>(); - buckets.add(Material.AXOLOTL_BUCKET); + if (plugin.getCompatabilityVersion() >= 17) { + buckets.add(Material.AXOLOTL_BUCKET); + } buckets.add(Material.COD_BUCKET); buckets.add(Material.SALMON_BUCKET); buckets.add(Material.TROPICAL_FISH_BUCKET); buckets.add(Material.PUFFERFISH_BUCKET); mobs = new ArrayList<>(); mobs.add(EntityType.PUFFERFISH); - mobs.add(EntityType.AXOLOTL); + if (plugin.getCompatabilityVersion() >= 17) { + mobs.add(EntityType.AXOLOTL); + } mobs.add(EntityType.TROPICAL_FISH); mobs.add(EntityType.COD); mobs.add(EntityType.SALMON); @@ -216,7 +220,8 @@ public class PlayerListener implements Listener { } @EventHandler - public void onWorldChange(PlayerTeleportEvent e) { + public void onPlayerTeleport(PlayerTeleportEvent e) { + logPos(plugin, e.getPlayer(), e.getTo(), "tele"); if (!plugin.config.inventoryOnWorldChange || e.getFrom().getWorld().equals(e.getTo().getWorld())) { return; } @@ -374,4 +379,9 @@ public class PlayerListener implements Listener { } return false; } + + public static void logPos(AuxProtect auxProtect, Player player, Location location, String string) { + auxProtect.dbRunnable.add(new DbEntry("$" + player.getUniqueId().toString(), EntryAction.POS, false, location, + string, "Y:" + Math.round(location.getYaw()) + " P:" + Math.round(location.getPitch()))); + } }