diff --git a/libs/CMILib1.4.6.2.jar b/libs/CMILib1.4.6.2.jar deleted file mode 100644 index 5a261cda..00000000 Binary files a/libs/CMILib1.4.6.2.jar and /dev/null differ diff --git a/libs/StackMob-5.5.3.jar b/libs/StackMob-5.5.3.jar deleted file mode 100644 index 43c48557..00000000 Binary files a/libs/StackMob-5.5.3.jar and /dev/null differ diff --git a/libs/WildStackerAPI-2023.2.jar b/libs/WildStackerAPI-2023.2.jar deleted file mode 100644 index 51918427..00000000 Binary files a/libs/WildStackerAPI-2023.2.jar and /dev/null differ diff --git a/libs/mcMMO-2.1.175-SNAPSHOT.jar b/libs/mcMMO-2.1.175-SNAPSHOT.jar deleted file mode 100644 index e5ec2fc2..00000000 Binary files a/libs/mcMMO-2.1.175-SNAPSHOT.jar and /dev/null differ diff --git a/libs/mypet-3.11-20210318.180552-1.jar b/libs/mypet-3.11-20210318.180552-1.jar deleted file mode 100644 index 9b573dcb..00000000 Binary files a/libs/mypet-3.11-20210318.180552-1.jar and /dev/null differ diff --git a/libs/mypet-3.12.jar b/libs/mypet-3.12.jar new file mode 100644 index 00000000..cf77adb5 Binary files /dev/null and b/libs/mypet-3.12.jar differ diff --git a/pom.xml b/pom.xml index 3e3ff653..4e6c24f6 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 Jobs jobs - 5.2.2.5 + 5.2.3.0 Jobs http://maven.apache.org @@ -17,32 +17,16 @@ - io.papermc.paper - paper-api - 1.20.4-R0.1-SNAPSHOT + org.spigotmc + spigot-api + 1.20.6-R0.1-SNAPSHOT + provided + + + org.spigotmc + spigot + 1.20.6-R0.1-SNAPSHOT provided - - - org.ow2.asm - asm-commons - - - com.google.code.findbugs - jsr305 - - - com.googlecode.json-simple - json-simple - - - org.slf4j - slf4j-api - - - org.ow2.asm - asm - - com.mojang @@ -54,9 +38,7 @@ com.gmail.nossr50.mcMMO mcMMO - 2.1.175-SNAPSHOT - system - ${basedir}/libs/mcMMO-2.1.175-SNAPSHOT.jar + 2.2.004 @@ -76,38 +58,12 @@ - - io.lumine.xikage - MythicMobs - 4.11.0 - provided - io.lumine Mythic-Dist - 5.1.0-SNAPSHOT + 5.6.1 provided - - - com.sk89q - worldguard - 6.1 - - - com.sk89q - commandbook - - - org.bukkit - bukkit - - - com.sk89q.spigot - bukkit-classloader-check - - - com.sk89q.worldguard @@ -195,27 +151,21 @@ - net.Zrips + com.github.Zrips CMILib - latest - system - ${basedir}/libs/CMILib1.4.6.2.jar + 1.4.7.4 com.bgsoftware WildStackerAPI - latest - system - ${basedir}/libs/WildStackerAPI-2023.2.jar + 3.8.0 - com.github.Nathat23 - StackMob-5 - 5.5.3 - system - ${basedir}/libs/StackMob-5.5.3.jar + uk.antiperson.stackmob + StackMob + 5.8.2 @@ -224,10 +174,14 @@ 3.11-SNAPSHOT system - ${basedir}/libs/mypet-3.11-20210318.180552-1.jar + ${basedir}/libs/mypet-3.12.jar + + CodeMC + https://repo.codemc.org/repository/maven-public/ + nexus @@ -243,14 +197,13 @@ jitpack.io https://jitpack.io - - papermc - https://papermc.io/repo/repository/maven-public/ + neetgames + https://nexus.neetgames.com/repository/maven-releases/ - minecraft-repo - https://libraries.minecraft.net/ + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ @@ -258,6 +211,10 @@ https://repo.extendedclip.com/content/repositories/placeholderapi/ + + bg-repo + https://repo.bg-software.com/repository/api/ + @@ -283,14 +240,6 @@ 1.8 - - org.apache.maven.plugins - maven-jar-plugin - 2.3.1 - - D:/MC/Server 1.20/plugins - - \ No newline at end of file diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 294d8dee..891f4745 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -108,7 +108,6 @@ import com.gamingmesh.jobs.stuff.Util; import com.gamingmesh.jobs.stuff.VersionChecker; import com.gamingmesh.jobs.stuff.complement.Complement; import com.gamingmesh.jobs.stuff.complement.Complement1; -import com.gamingmesh.jobs.stuff.complement.Complement2; import com.gamingmesh.jobs.stuff.complement.JobsChatEvent; import com.gamingmesh.jobs.tasks.BufferedPaymentThread; import com.gamingmesh.jobs.tasks.DatabaseSaveThread; @@ -766,12 +765,7 @@ public final class Jobs extends JavaPlugin { HookManager.loadHooks(); registerListeners(); - if (Version.isCurrentEqualOrHigher(Version.v1_16_R3) && kyoriSupported) { - complement = new Complement2(); - //getServer().getPluginManager().registerEvents(new KyoriChatEvent(this), this); - } else { - complement = new Complement1(); - } + complement = new Complement1(); if (HookVault.isVaultEnable()) { // register economy diff --git a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java index 37447bd5..fdd5b4a4 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java @@ -36,7 +36,6 @@ import net.Zrips.CMILib.Items.CMIAsyncHead; import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Messages.CMIMessages; @SuppressWarnings("deprecation") @@ -260,12 +259,12 @@ public class ShopManager { Jobs.getJobsDAO().savePoints(jPlayer); player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.Paid", "%amount%", item.getPointPrice())); } - + if (item.getVaultPrice() > 0) { jPlayer.withdraw(item.getVaultPrice()); player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.Paid", "%amount%", Jobs.getEconomy().getEconomy().format(item.getVaultPrice()))); } - + openShopGui(player, page); } }; @@ -518,14 +517,14 @@ public class ShopManager { String potionData = ""; if (itemSection.contains("potion-type")) { - PotionType type; + PotionType type = null; try { type = PotionType.valueOf(itemSection.getString("potion-type", "speed").toUpperCase()); } catch (IllegalArgumentException ex) { - type = PotionType.SPEED; } - potionData += type.toString() + ":false:false"; + if (type != null) + potionData += type.toString() + ":false:false"; } String itemSring = mat.toString(); diff --git a/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java b/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java index 7f5c65c1..d724a2a5 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java @@ -9,7 +9,6 @@ import com.gamingmesh.jobs.hooks.McMMO.McMMO2_X_listener; import com.gamingmesh.jobs.hooks.McMMO.McMMOManager; import com.gamingmesh.jobs.hooks.MyPet.MyPetManager; import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobInterface; -import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobs4; import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobs5; import com.gamingmesh.jobs.hooks.WorldGuard.WorldGuardManager; import com.gamingmesh.jobs.hooks.stackMob.StackMobHandler; @@ -31,118 +30,112 @@ public class HookManager { private static PluginManager pm; public static void loadHooks() { - pm = PLUGIN.getServer().getPluginManager(); + pm = PLUGIN.getServer().getPluginManager(); - setMyPetManager(); - setWorldGuard(); - setMythicManager(); - setStackMobHandler(); - setWildStackerHandler(); + setMyPetManager(); + setWorldGuard(); + setMythicManager(); + setStackMobHandler(); + setWildStackerHandler(); } public static StackMobHandler getStackMobHandler() { - if (stackMobHandler == null) { - setStackMobHandler(); - } + if (stackMobHandler == null) { + setStackMobHandler(); + } - return stackMobHandler; + return stackMobHandler; } public static WildStackerHandler getWildStackerHandler() { - if (wildStackerHandler == null) { - setWildStackerHandler(); - } + if (wildStackerHandler == null) { + setWildStackerHandler(); + } - return wildStackerHandler; + return wildStackerHandler; } public static MyPetManager getMyPetManager() { - if (myPetManager == null) { - setMyPetManager(); - } + if (myPetManager == null) { + setMyPetManager(); + } - return myPetManager; + return myPetManager; } public static WorldGuardManager getWorldGuardManager() { - if (worldGuardManager == null) { - worldGuardManager = new WorldGuardManager(); - } + if (worldGuardManager == null) { + worldGuardManager = new WorldGuardManager(); + } - return worldGuardManager; + return worldGuardManager; } public static McMMOManager getMcMMOManager() { - if (McMMOManager == null) - McMMOManager = new McMMOManager(); + if (McMMOManager == null) + McMMOManager = new McMMOManager(); - return McMMOManager; + return McMMOManager; } public static MythicMobInterface getMythicManager() { - return MythicManager; + return MythicManager; } public static boolean checkMythicMobs() { - return Jobs.getGCManager().MythicMobsEnabled && MythicManager != null && MythicManager.check(); + return Jobs.getGCManager().MythicMobsEnabled && MythicManager != null && MythicManager.check(); } private static boolean setWorldGuard() { - if (JobsHook.WorldGuard.isEnabled()) { - worldGuardManager = new WorldGuardManager(); - CMIMessages.consoleMessage("&eWorldGuard detected."); - return true; - } + if (JobsHook.WorldGuard.isEnabled()) { + worldGuardManager = new WorldGuardManager(); + CMIMessages.consoleMessage("&eWorldGuard detected."); + return true; + } - return false; + return false; } private static void setMythicManager() { - if (!JobsHook.MythicMobs.isPresent()) - return; + if (!JobsHook.MythicMobs.isPresent()) + return; - try { - Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper"); - MythicManager = new MythicMobs4(PLUGIN); - CMIMessages.consoleMessage("&eMythicMobs 4.x detected."); - } catch (ClassNotFoundException ex) { - try { - Class.forName("io.lumine.mythic.bukkit.BukkitAPIHelper"); - MythicManager = new MythicMobs5(PLUGIN); - CMIMessages.consoleMessage("&eMythicMobs 5.x detected."); - } catch (ClassNotFoundException e) { - CMIMessages.consoleMessage("&cYour MythicMobs version is not supported by Jobs! Supported versions: 4.9.1+"); - } - } + try { + Class.forName("io.lumine.mythic.bukkit.BukkitAPIHelper"); + MythicManager = new MythicMobs5(PLUGIN); + CMIMessages.consoleMessage("&eMythicMobs 5.x detected."); + } catch (ClassNotFoundException e) { + CMIMessages.consoleMessage("&cYour MythicMobs version is not supported by Jobs! Supported versions: 4.9.1+"); + } } public static void setMcMMOlistener() { - try { - Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType"); - pm.registerEvents(new McMMO2_X_listener(), PLUGIN); - CMIMessages.consoleMessage("&eRegistered McMMO 2.x listener"); - } catch (ClassNotFoundException e) { - pm.registerEvents(new McMMO1_X_listener(), PLUGIN); - CMIMessages.consoleMessage("&eRegistered McMMO 1.x listener"); - } + try { + Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType"); + pm.registerEvents(new McMMO2_X_listener(), PLUGIN); + CMIMessages.consoleMessage("&eRegistered McMMO 2.x listener"); + } catch (ClassNotFoundException e) { + pm.registerEvents(new McMMO1_X_listener(), PLUGIN); + CMIMessages.consoleMessage("&eRegistered McMMO 1.x listener"); + } } private static void setMyPetManager() { - if (JobsHook.MyPet.isEnabled()) { - myPetManager = new MyPetManager(); - CMIMessages.consoleMessage("&eMyPet detected."); - } + if (JobsHook.MyPet.isEnabled()) { + myPetManager = new MyPetManager(); + CMIMessages.consoleMessage("&eMyPet detected."); + } } private static void setStackMobHandler() { - if (JobsHook.StackMob.isEnabled()) { - stackMobHandler = new StackMobHandler(); - } + if (JobsHook.StackMob.isEnabled()) { + stackMobHandler = new StackMobHandler(); + } } private static void setWildStackerHandler() { - if (JobsHook.WildStacker.isEnabled()) { - wildStackerHandler = new WildStackerHandler(); - } + if (JobsHook.WildStacker.isEnabled()) { + wildStackerHandler = new WildStackerHandler(); + } } } diff --git a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs4.java b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs4.java deleted file mode 100644 index 13818813..00000000 --- a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs4.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.gamingmesh.jobs.hooks.MythicMobs; - -import org.bukkit.entity.LivingEntity; -import org.bukkit.plugin.Plugin; - -import com.gamingmesh.jobs.Jobs; - -import io.lumine.xikage.mythicmobs.MythicMobs; -import io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper; -import io.lumine.xikage.mythicmobs.mobs.MythicMob; -import net.Zrips.CMILib.Messages.CMIMessages; - -public class MythicMobs4 implements MythicMobInterface { - - public BukkitAPIHelper apiHelper; - private Jobs plugin; - - public MythicMobs4(Jobs plugin) { - this.plugin = plugin; - } - - @Override - public void registerListener() { - plugin.getServer().getPluginManager().registerEvents(new MythicMobs4Listener(), plugin); - } - - @Override - public boolean isMythicMob(LivingEntity lVictim) { - return apiHelper != null && lVictim != null && apiHelper.isMythicMob(lVictim); - } - - @Override - public boolean check() { - Plugin mm = plugin.getServer().getPluginManager().getPlugin("MythicMobs"); - if (mm == null) - return false; - - try { - Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent"); - Class.forName("io.lumine.xikage.mythicmobs.mobs.MythicMob"); - Class.forName("io.lumine.xikage.mythicmobs.MythicMobs"); - } catch (ClassNotFoundException e) { - // Disabling - CMIMessages.consoleMessage("&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support."); - return false; - } - - apiHelper = ((MythicMobs) mm).getAPIHelper(); - CMIMessages.consoleMessage("&e[Jobs] &6MythicMobs was found - Enabling capabilities."); - return true; - } - - static boolean failed = false; - - @Override - public String getDisplayName(String id) { - if (failed || apiHelper == null) - return ""; - - MythicMob mm = apiHelper.getMythicMob(id); - try { - if (mm != null && mm.getDisplayName() != null) - return mm.getDisplayName().toString(); - } catch (Throwable e) { - if (!failed) { - failed = true; - e.printStackTrace(); - CMIMessages.consoleMessage("&cEncountered error when checking MythicMob entity name. Support for mythicMobs will be suspended for time beying. Please report this issue."); - } - } - - return ""; - } - -} diff --git a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs4Listener.java b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs4Listener.java deleted file mode 100644 index c7ebe594..00000000 --- a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs4Listener.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.gamingmesh.jobs.hooks.MythicMobs; - -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.actions.MMKillInfo; -import com.gamingmesh.jobs.container.ActionType; -import com.gamingmesh.jobs.container.JobsPlayer; -import com.gamingmesh.jobs.listeners.JobsPaymentListener; - -import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent; -import io.lumine.xikage.mythicmobs.mobs.MythicMob; - -public final class MythicMobs4Listener implements Listener { - - @EventHandler - public void onMythicMobDeath(MythicMobDeathEvent event) { - // Entity that died must be living - if (!(event.getEntity() instanceof LivingEntity)) - return; - - if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) - return; - - Player pDamager = null; - - // Checking if killer is player - Entity ent = null; - if (event.getKiller() instanceof Player) - pDamager = (Player) event.getKiller(); - // Checking if killer is tamed animal - else if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) { - ent = ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager(); - } else - return; - - if (pDamager == null) - return; - - // check if in creative - if (!JobsPaymentListener.payIfCreative(pDamager)) - return; - - if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName())) - return; - - JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager); - if (jDamager == null) - return; - - // pay - MythicMob lVictim = event.getMobType(); - if (lVictim != null) { - Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), ent); - } - } -} diff --git a/src/main/java/com/gamingmesh/jobs/hooks/WorldGuard/WorldGuardManager.java b/src/main/java/com/gamingmesh/jobs/hooks/WorldGuard/WorldGuardManager.java index 762e49fc..4403c34d 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/WorldGuard/WorldGuardManager.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/WorldGuard/WorldGuardManager.java @@ -15,7 +15,6 @@ import com.gamingmesh.jobs.container.RestrictedArea; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.regions.ProtectedRegion; import com.sk89q.worldguard.protection.regions.RegionContainer; @@ -23,109 +22,70 @@ import com.sk89q.worldguard.protection.regions.RegionContainer; public class WorldGuardManager { private WorldGuardPlugin wg; - private boolean useOld = false; public WorldGuardManager() { - Plugin pl = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard"); - if (pl instanceof WorldGuardPlugin) { - wg = (WorldGuardPlugin) pl; - - if (pl.getDescription().getVersion().equals("6.1")) { - useOld = true; - } - } + Plugin pl = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard"); + if (pl instanceof WorldGuardPlugin) { + wg = (WorldGuardPlugin) pl; + } } public WorldGuardPlugin getPlugin() { - return wg; + return wg; } public List getArea(Location loc) { - try { - if (useOld) { - RegionManager manager = wg.getRegionContainer().get(loc.getWorld()); + try { + RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); + RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld())); - if (manager != null) { - ApplicableRegionSet regions = manager.getApplicableRegions(loc); + if (regions != null) { + for (ProtectedRegion one : regions.getRegions().values()) { + List rest = Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId()); - for (ProtectedRegion one : regions.getRegions()) { - List rest = Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId()); + if (!rest.isEmpty()) + return rest; + } + } + } catch (Throwable e) { + } - if (!rest.isEmpty()) - return rest; - } - } - } else { - RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); - RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld())); - - if (regions != null) { - for (ProtectedRegion one : regions.getRegions().values()) { - List rest = Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId()); - - if (!rest.isEmpty()) - return rest; - } - } - } - } catch (Throwable e) { - } - - return new ArrayList<>(); + return new ArrayList<>(); } public boolean inArea(Location loc, String name) { - if (useOld) { - RegionManager manager = wg.getRegionContainer().get(loc.getWorld()); - if (manager != null) { - ApplicableRegionSet regions = manager.getApplicableRegions(loc); + RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); + RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld())); - for (ProtectedRegion one : regions.getRegions()) { - if (one.getId().equalsIgnoreCase(name) && one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) - return true; - } - } - } else { - RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); - RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld())); + if (regions != null) { + for (ProtectedRegion one : regions.getRegions().values()) { + if (one.getId().equalsIgnoreCase(name) && one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) + return true; + } + } - if (regions != null) { - for (ProtectedRegion one : regions.getRegions().values()) { - if (one.getId().equalsIgnoreCase(name) && one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) - return true; - } - } - } - - return false; + return false; } public ProtectedRegion getProtectedRegionByName(String name) { - for (World one : Bukkit.getServer().getWorlds()) { - Map regions = null; + for (World one : Bukkit.getServer().getWorlds()) { + Map regions = null; - if (useOld) { - RegionManager manager = wg.getRegionContainer().get(one); + RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); + RegionManager manager = container.get(BukkitAdapter.adapt(one)); - if (manager != null) - regions = manager.getRegions(); - } else { - RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); - RegionManager manager = container.get(BukkitAdapter.adapt(one)); + if (manager != null) + regions = manager.getRegions(); - if (manager != null) - regions = manager.getRegions(); - } + if (regions != null) { + for (Entry map : regions.entrySet()) { + if (map.getKey().equalsIgnoreCase(name)) + return map.getValue(); + } + } + } - if (regions != null) { - for (Entry map : regions.entrySet()) { - if (map.getKey().equalsIgnoreCase(name)) - return map.getValue(); - } - } - } - - return null; + return null; } } diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index b71b0f9d..78c085c6 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -252,7 +252,7 @@ public final class JobsPaymentListener implements Listener { public void onCowMilking(PlayerInteractEntityEvent event) { Entity entity = event.getRightClicked(); - CMIEntityType type = CMIEntityType.getByType(entity.getType()); + CMIEntityType type = CMIEntityType.get(entity.getType()); if (type != CMIEntityType.COW && type != CMIEntityType.MUSHROOM_COW && type != CMIEntityType.GOAT) return; @@ -264,7 +264,7 @@ public final class JobsPaymentListener implements Listener { return; } - if (itemInHand.getType() == Material.BOWL && entity.getType() != EntityType.MUSHROOM_COW) { + if (itemInHand.getType() == Material.BOWL && type != CMIEntityType.MUSHROOM_COW) { return; } @@ -1661,11 +1661,14 @@ public final class JobsPaymentListener implements Listener { if (!Jobs.getGCManager().canPerformActionInWorld(e)) return; - EntityType type = event.getEntityType(); - if (type != EntityType.PRIMED_TNT && type != EntityType.MINECART_TNT && type != CMIEntityType.ENDER_CRYSTAL.getType()) + CMIEntityType type = CMIEntityType.get(event.getEntityType()); + + + + if (type != CMIEntityType.TNT && type != CMIEntityType.TNT_MINECART && type != CMIEntityType.ENDER_CRYSTAL) return; - if (!Jobs.getGCManager().isUseTntFinder() && type != CMIEntityType.ENDER_CRYSTAL.getType()) + if (!Jobs.getGCManager().isUseTntFinder() && type != CMIEntityType.ENDER_CRYSTAL) return; double closest = 60.0; @@ -1697,7 +1700,7 @@ public final class JobsPaymentListener implements Listener { if (jPlayer == null) return; - if (!Jobs.getGCManager().isUseTntFinder() && type == CMIEntityType.ENDER_CRYSTAL.getType()) { + if (!Jobs.getGCManager().isUseTntFinder() && type == CMIEntityType.ENDER_CRYSTAL) { UUID eUUID = e.getUniqueId(); Entity killed = punchedEndCrystals.getIfPresent(eUUID); diff --git a/src/main/java/com/gamingmesh/jobs/stuff/complement/Complement2.java b/src/main/java/com/gamingmesh/jobs/stuff/complement/Complement2.java deleted file mode 100644 index c8e58c13..00000000 --- a/src/main/java/com/gamingmesh/jobs/stuff/complement/Complement2.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.gamingmesh.jobs.stuff.complement; - -import org.bukkit.block.Sign; -import org.bukkit.entity.Player; -import org.bukkit.event.block.SignChangeEvent; - -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.TextComponent; -import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; - -public class Complement2 implements Complement { - - protected String serialize(Component component) { - return LegacyComponentSerializer.legacyAmpersand().serialize(component); - } - - protected TextComponent deserialize(String t) { - return LegacyComponentSerializer.legacyAmpersand().deserialize(t); - } - - @Override - public String getLine(SignChangeEvent event, int line) { - Component l = event.line(line); - return l == null ? "" : serialize(l); - } - - @Override - public void setLine(SignChangeEvent event, int line, String text) { - event.line(line, deserialize(text)); - } - - @Override - public String getLine(Sign sign, int line) { - return serialize(sign.line(line)); - } - - @Override - public String getDisplayName(Player player) { - return serialize(player.displayName()); - } - - @Override - public void setLine(Sign sign, int line, String text) { - sign.line(line, deserialize(text)); - } - -} diff --git a/src/main/java/com/gamingmesh/jobs/stuff/complement/KyoriChatEvent.java b/src/main/java/com/gamingmesh/jobs/stuff/complement/KyoriChatEvent.java deleted file mode 100644 index f3b5242c..00000000 --- a/src/main/java/com/gamingmesh/jobs/stuff/complement/KyoriChatEvent.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.gamingmesh.jobs.stuff.complement; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.container.JobsPlayer; -import com.gamingmesh.jobs.stuff.Util; - -import io.papermc.paper.chat.ChatRenderer; -import io.papermc.paper.event.player.AsyncChatEvent; -import net.Zrips.CMILib.Version.Schedulers.CMIScheduler; -import net.kyori.adventure.text.TextReplacementConfig; - -public final class KyoriChatEvent extends Complement2 implements Listener { - - private Jobs plugin; - - public KyoriChatEvent(Jobs plugin) { - this.plugin = plugin; - } - - @EventHandler(priority = EventPriority.NORMAL) - public void asyncChatEvent(final AsyncChatEvent event) { - if (event.isCancelled() || Util.getJobsEditorMap().isEmpty()) - return; - - final String msg = Util.getJobsEditorMap().remove(event.getPlayer().getUniqueId()); - if (msg != null) { - CMIScheduler.get().runTask(() -> event.getPlayer().performCommand(msg + serialize(event.message()))); - event.setCancelled(true); - } - } - - // Adding to chat prefix job name - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onPlayerChat(AsyncChatEvent event) { - if (!Jobs.getGCManager().getModifyChat()) - return; - - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer()); - String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : ""; - if (honorific.equals(" ")) - honorific = ""; - - // TODO displayName returns the player display name not the chat component from - // chat plugins, like Essentials - // Now there is a parameter "player", so literally we need to add 800+ chat plugins - // to this plugin as dependency? - // 3rd attempt: now we tried to use text replacement config builder to match the variable - // result: instead of replacing the variable, now the chat message never been sent - //event.composer((player, displayName, msg) -> msg - //.replaceText(TextReplacementConfig.builder().match("{jobs}").once().replacement(h).build())); - - event.message(ChatRenderer.defaultRenderer().render(event.getPlayer(), event.getPlayer().displayName(), event.message(), event.getPlayer()).replaceText(TextReplacementConfig.builder().match( - "\\{jobs\\}").replacement(honorific).build())); - // 4th attempt: composeChat -> doing nothing -// event.message(ChatComposer.DEFAULT.composeChat(event.getPlayer(), event.getPlayer().displayName(), event.message()) -// .replaceText(TextReplacementConfig.builder().match("\\{jobs\\}").replacement(honorific).build())); - } - - // Changing chat prefix variable to job name - @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) - public void onPlayerChatLow(AsyncChatEvent event) { - onPlayerChatHigh(event); - } - - // Changing chat prefix variable to job name - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void onPlayerChatHigh(AsyncChatEvent event) { - if (Jobs.getGCManager().getModifyChat()) - return; - - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer()); - String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : ""; - if (honorific.equals(" ")) - honorific = ""; - - event.message(ChatRenderer.defaultRenderer().render(event.getPlayer(), event.getPlayer().displayName(), event.message(), event.getPlayer()).replaceText(TextReplacementConfig.builder().match( - "\\{jobs\\}").replacement(honorific).build())); - -// event.message(ChatComposer.DEFAULT -// .composeChat(event.getPlayer(), event.getPlayer().displayName(), event.message()) -// .replaceText(TextReplacementConfig.builder().match("\\{jobs\\}").replacement(honorific).build())); - } -}