Fixes DISABLE_LOYALTY_PORTALS doesn't work

This commit is contained in:
Cazcez 2023-02-25 18:43:24 +03:00
parent 2606f39e81
commit e62949e132
3 changed files with 5 additions and 4 deletions

View File

@ -44,6 +44,7 @@ public class Main extends JavaPlugin {
Bukkit.getPluginManager().registerEvents(new ImpalingListener(), this);
Bukkit.getPluginManager().registerEvents(new OffhandListener(), this);
Bukkit.getPluginManager().registerEvents(new TridentThrowListener(), this);
Bukkit.getPluginManager().registerEvents(new PortalListener(), this);
getCommand("bettertridents").setExecutor(new ReloadCommand());
@SuppressWarnings("unused") Metrics metrics = new Metrics(this, 11460);
}

View File

@ -19,8 +19,8 @@ public class PortalListener implements Listener {
if(!main.getConfig().getBoolean(Config.DISABLE_LOYALTY_PORTALS)) return;
if(event.getEntityType() != EntityType.TRIDENT) return;
Trident trident = (Trident) event.getEntity();
if(EnchantmentUtils.getLoyalty(trident)>0) {
main.debug("Prevented loyalty trident from travelling through portqal");
if(EnchantmentUtils.getLoyalty(trident)) {
main.debug("Prevented loyalty trident from travelling through portal");
event.setCancelled(true);
}
}

View File

@ -34,8 +34,8 @@ public class EnchantmentUtils {
trident.getPersistentDataContainer().set(Main.IMPALING_TAG, PersistentDataType.INTEGER, level);
}
public static int getLoyalty(Trident trident) {
return trident.getPersistentDataContainer().getOrDefault(Main.LOYALTY_TAG, PersistentDataType.INTEGER, 0);
public static boolean getLoyalty(Trident trident) {
return trident.getItem().getEnchantments().containsKey(Enchantment.LOYALTY);
}
public static void registerLoyalty(Trident trident, int level) {