Merge pull request #6 from Cazcez/master

Fixes DISABLE_LOYALTY_PORTALS doesn't work and issue #4
This commit is contained in:
mfnalex 2023-03-12 10:22:56 +01:00 committed by GitHub
commit 1300762753
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) {