refactor: move enums into own file
This commit is contained in:
parent
eb9bfc78d1
commit
817a437b5d
6 changed files with 32 additions and 18 deletions
|
@ -0,0 +1,5 @@
|
|||
package de.cliffbreak.varo.enums;
|
||||
|
||||
public enum PlayerCacheType {
|
||||
NAME, SKINPARTS, MAINHAND, WORLD, X, Y, Z, YAW, PITCH,
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package de.cliffbreak.varo.enums;
|
||||
|
||||
public enum PlayerInteractType {
|
||||
ATTACK, INTERACT,
|
||||
}
|
|
@ -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,
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue