diff --git a/varo/src/main/java/de/cliffbreak/varo/enums/PlayerCacheType.java b/varo/src/main/java/de/cliffbreak/varo/enums/PlayerCacheType.java new file mode 100644 index 0000000..69f2b0a --- /dev/null +++ b/varo/src/main/java/de/cliffbreak/varo/enums/PlayerCacheType.java @@ -0,0 +1,5 @@ +package de.cliffbreak.varo.enums; + +public enum PlayerCacheType { + NAME, SKINPARTS, MAINHAND, WORLD, X, Y, Z, YAW, PITCH, +} \ No newline at end of file diff --git a/varo/src/main/java/de/cliffbreak/varo/enums/PlayerInteractType.java b/varo/src/main/java/de/cliffbreak/varo/enums/PlayerInteractType.java new file mode 100644 index 0000000..8a17ca3 --- /dev/null +++ b/varo/src/main/java/de/cliffbreak/varo/enums/PlayerInteractType.java @@ -0,0 +1,5 @@ +package de.cliffbreak.varo.enums; + +public enum PlayerInteractType { + ATTACK, INTERACT, +} \ No newline at end of file diff --git a/varo/src/main/java/de/cliffbreak/varo/events/PlayerInteractNPCEvent.java b/varo/src/main/java/de/cliffbreak/varo/events/PlayerInteractNPCEvent.java index 6f888ff..0571fa3 100644 --- a/varo/src/main/java/de/cliffbreak/varo/events/PlayerInteractNPCEvent.java +++ b/varo/src/main/java/de/cliffbreak/varo/events/PlayerInteractNPCEvent.java @@ -4,15 +4,17 @@ import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import de.cliffbreak.varo.enums.PlayerInteractType; + public class PlayerInteractNPCEvent extends Event { private static final HandlerList handlers = new HandlerList(); - private final Type type; + private final PlayerInteractType type; private final Player damager; private final int id; private final double damage; private final boolean isCritical; - public PlayerInteractNPCEvent(Type type, Player damager, int id, double damage, boolean isCritical) { + public PlayerInteractNPCEvent(PlayerInteractType type, Player damager, int id, double damage, boolean isCritical) { super(true); this.type = type; this.damager = damager; @@ -22,9 +24,9 @@ public class PlayerInteractNPCEvent extends Event { } /** - * @return InteractionType of the Event + * @return PlayerInteractType of the Event */ - public Type getType() { + public PlayerInteractType getType() { return type; } @@ -64,8 +66,4 @@ public class PlayerInteractNPCEvent extends Event { public static HandlerList getHandlerList() { return handlers; } - - public enum Type { - ATTACK, INTERACT, - } } \ No newline at end of file diff --git a/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerClientOptionsChangeListener.java b/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerClientOptionsChangeListener.java index a8b5e7c..7e01f21 100644 --- a/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerClientOptionsChangeListener.java +++ b/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerClientOptionsChangeListener.java @@ -6,7 +6,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import de.cliffbreak.varo.Varo; -import de.cliffbreak.varo.utils.PlayerCache.PlayerCacheType; +import de.cliffbreak.varo.enums.PlayerCacheType; public class PlayerClientOptionsChangeListener implements Listener { diff --git a/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerInteractNPCListener.java b/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerInteractNPCListener.java index 4cc0e59..57e86f3 100644 --- a/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerInteractNPCListener.java +++ b/varo/src/main/java/de/cliffbreak/varo/listeners/PlayerInteractNPCListener.java @@ -4,8 +4,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import de.cliffbreak.varo.Varo; +import de.cliffbreak.varo.enums.PlayerInteractType; import de.cliffbreak.varo.events.PlayerInteractNPCEvent; -import de.cliffbreak.varo.events.PlayerInteractNPCEvent.Type; public class PlayerInteractNPCListener implements Listener { @@ -17,7 +17,7 @@ public class PlayerInteractNPCListener implements Listener { @EventHandler public void onEntityDamageByEntity(final PlayerInteractNPCEvent e) { - if (e.getType().equals(Type.ATTACK)) { + if (e.getType().equals(PlayerInteractType.ATTACK)) { this.plugin.getNPCManager().addDamage(e.getDamager(), e.getId(), e.getDamage(), e.getIsCritical()); } } diff --git a/varo/src/main/java/de/cliffbreak/varo/utils/PlayerCache.java b/varo/src/main/java/de/cliffbreak/varo/utils/PlayerCache.java index 19d4c0d..ae8eb12 100644 --- a/varo/src/main/java/de/cliffbreak/varo/utils/PlayerCache.java +++ b/varo/src/main/java/de/cliffbreak/varo/utils/PlayerCache.java @@ -8,6 +8,7 @@ import org.bukkit.inventory.MainHand; import org.json.simple.JSONObject; import de.cliffbreak.varo.Varo; +import de.cliffbreak.varo.enums.PlayerCacheType; public class PlayerCache { @@ -64,12 +65,21 @@ public class PlayerCache { } public int getSkinParts(final String uuid) { - return (int) this.plugin.getDatabase().getPlayerCache(uuid, PlayerCacheType.SKINPARTS.toString().toLowerCase()); + Object skinParts = this.plugin.getDatabase().getPlayerCache(uuid, + PlayerCacheType.SKINPARTS.toString().toLowerCase()); + if (skinParts == null) { + return 127; + } + return (int) skinParts; } public MainHand getMainHand(final String uuid) { - return MainHand.valueOf((String) this.plugin.getDatabase().getPlayerCache(uuid, - PlayerCacheType.MAINHAND.toString().toLowerCase())); + String mainHand = (String) this.plugin.getDatabase().getPlayerCache(uuid, + PlayerCacheType.MAINHAND.toString().toLowerCase()); + if (mainHand == null) { + return MainHand.RIGHT; + } + return MainHand.valueOf(mainHand); } public byte getMainHandAsByte(final String uuid) { @@ -78,8 +88,4 @@ public class PlayerCache { else return (byte) 0; } - - public enum PlayerCacheType { - NAME, SKINPARTS, MAINHAND, WORLD, X, Y, Z, YAW, PITCH, - } } \ No newline at end of file