diff --git a/src/de/epiceric/shopchest/interfaces/Hologram.java b/src/de/epiceric/shopchest/interfaces/Hologram.java index a15e193..97e5b0a 100644 --- a/src/de/epiceric/shopchest/interfaces/Hologram.java +++ b/src/de/epiceric/shopchest/interfaces/Hologram.java @@ -8,18 +8,16 @@ import java.util.List; public interface Hologram { - public Location getLocation(); + Location getLocation(); - public List getEntities(); + void showPlayer(OfflinePlayer p); - public void showPlayer(OfflinePlayer p); + void hidePlayer(OfflinePlayer p); - public void hidePlayer(OfflinePlayer p); + boolean isVisible(OfflinePlayer p); - public boolean isVisible(OfflinePlayer p); + boolean exists(); - public boolean exists(); - - public void remove(); + void remove(); } diff --git a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_10_R1.java b/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_10_R1.java index f1525f9..d4f75f0 100644 --- a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_10_R1.java +++ b/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_10_R1.java @@ -1,27 +1,23 @@ package de.epiceric.shopchest.interfaces.hologram; import de.epiceric.shopchest.interfaces.Hologram; -import net.minecraft.server.v1_10_R1.EntityArmorStand; -import net.minecraft.server.v1_10_R1.PacketPlayOutEntityDestroy; -import net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_10_R1.*; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; public class Hologram_1_10_R1 implements Hologram { private boolean exists = false; private int count; - private List entitylist = new ArrayList(); + private List entityList = new ArrayList<>(); private String[] text; private Location location; - private double DISTANCE = 0.25D; - private HashMap visible = new HashMap(); + private List visible = new ArrayList<>(); public Hologram_1_10_R1(String[] text, Location location) { this.text = text; @@ -33,31 +29,26 @@ public class Hologram_1_10_R1 implements Hologram { return location; } - public List getEntities() { - return entitylist; - } - public void showPlayer(OfflinePlayer p) { - for (Object o : entitylist) { + for (Object o : entityList) { EntityArmorStand armor = (EntityArmorStand) o; PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(armor); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } - visible.put(p, true); + visible.add(p); } public void hidePlayer(OfflinePlayer p) { - for (Object o : entitylist) { + for (Object o : entityList) { EntityArmorStand armor = (EntityArmorStand) o; PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(armor.getId()); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } - visible.put(p, false); + visible.remove(p); } public boolean isVisible(OfflinePlayer p) { - if (visible.containsKey(p)) return visible.get(p); - else return false; + return visible.contains(p); } private void create() { @@ -67,13 +58,13 @@ public class Hologram_1_10_R1 implements Hologram { entity.setCustomNameVisible(true); entity.setInvisible(true); entity.setNoGravity(true); - entitylist.add(entity); - this.location.subtract(0, this.DISTANCE, 0); + entityList.add(entity); + this.location.subtract(0, 0.25, 0); count++; } for (int i = 0; i < count; i++) { - this.location.add(0, this.DISTANCE, 0); + this.location.add(0, 0.25, 0); } count = 0; @@ -85,7 +76,7 @@ public class Hologram_1_10_R1 implements Hologram { } public void remove() { - for (EntityArmorStand e : entitylist) { + for (EntityArmorStand e : entityList) { e.die(); } exists = false; diff --git a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R1.java b/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R1.java index 36a2ce5..c52bc8f 100644 --- a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R1.java +++ b/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R1.java @@ -10,18 +10,16 @@ import org.bukkit.craftbukkit.v1_8_R1.CraftWorld; import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; public class Hologram_1_8_R1 implements Hologram { private boolean exists = false; private int count; - private List entitylist = new ArrayList(); + private List entityList = new ArrayList<>(); private String[] text; private Location location; - private double DISTANCE = 0.25D; - private HashMap visible = new HashMap(); + private List visible = new ArrayList<>(); public Hologram_1_8_R1(String[] text, Location location) { this.text = text; @@ -33,31 +31,26 @@ public class Hologram_1_8_R1 implements Hologram { return location; } - public List getEntities() { - return entitylist; - } - public void showPlayer(OfflinePlayer p) { - for (Object o : entitylist) { + for (Object o : entityList) { EntityArmorStand armor = (EntityArmorStand) o; PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(armor); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } - visible.put(p, true); + visible.add(p); } public void hidePlayer(OfflinePlayer p) { - for (Object o : entitylist) { + for (Object o : entityList) { EntityArmorStand armor = (EntityArmorStand) o; PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(armor.getId()); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } - visible.put(p, false); + visible.remove(p); } public boolean isVisible(OfflinePlayer p) { - if (visible.containsKey(p)) return visible.get(p); - else return false; + return visible.contains(p); } private void create() { @@ -67,13 +60,13 @@ public class Hologram_1_8_R1 implements Hologram { entity.setCustomNameVisible(true); entity.setInvisible(true); entity.setGravity(false); - entitylist.add(entity); - this.location.subtract(0, this.DISTANCE, 0); + entityList.add(entity); + this.location.subtract(0, 0.25, 0); count++; } for (int i = 0; i < count; i++) { - this.location.add(0, this.DISTANCE, 0); + this.location.add(0, 0.25, 0); } count = 0; @@ -85,7 +78,7 @@ public class Hologram_1_8_R1 implements Hologram { } public void remove() { - for (EntityArmorStand e : entitylist) { + for (EntityArmorStand e : entityList) { e.die(); } exists = false; diff --git a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R2.java b/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R2.java index 457c9fa..c8148fa 100644 --- a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R2.java +++ b/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R2.java @@ -17,11 +17,10 @@ public class Hologram_1_8_R2 implements Hologram { private boolean exists = false; private int count; - private List entitylist = new ArrayList(); + private List entityList = new ArrayList<>(); private String[] text; private Location location; - private double DISTANCE = 0.25D; - private HashMap visible = new HashMap(); + private List visible = new ArrayList<>(); public Hologram_1_8_R2(String[] text, Location location) { this.text = text; @@ -33,31 +32,26 @@ public class Hologram_1_8_R2 implements Hologram { return location; } - public List getEntities() { - return entitylist; - } - public void showPlayer(OfflinePlayer p) { - for (Object o : entitylist) { + for (Object o : entityList) { EntityArmorStand armor = (EntityArmorStand) o; PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(armor); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } - visible.put(p, true); + visible.add(p); } public void hidePlayer(OfflinePlayer p) { - for (Object o : entitylist) { + for (Object o : entityList) { EntityArmorStand armor = (EntityArmorStand) o; PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(armor.getId()); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } - visible.put(p, false); + visible.remove(p); } public boolean isVisible(OfflinePlayer p) { - if (visible.containsKey(p)) return visible.get(p); - else return false; + return visible.contains(p); } private void create() { @@ -67,13 +61,13 @@ public class Hologram_1_8_R2 implements Hologram { entity.setCustomNameVisible(true); entity.setInvisible(true); entity.setGravity(false); - entitylist.add(entity); - this.location.subtract(0, this.DISTANCE, 0); + entityList.add(entity); + this.location.subtract(0, 0.25, 0); count++; } for (int i = 0; i < count; i++) { - this.location.add(0, this.DISTANCE, 0); + this.location.add(0, 0.25, 0); } count = 0; @@ -85,7 +79,7 @@ public class Hologram_1_8_R2 implements Hologram { } public void remove() { - for (EntityArmorStand e : entitylist) { + for (EntityArmorStand e : entityList) { e.die(); } exists = false; diff --git a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R3.java b/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R3.java index 45c9e54..b502039 100644 --- a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R3.java +++ b/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R3.java @@ -17,11 +17,10 @@ public class Hologram_1_8_R3 implements Hologram { private boolean exists = false; private int count; - private List entitylist = new ArrayList(); + private List entityList = new ArrayList<>(); private String[] text; private Location location; - private double DISTANCE = 0.25D; - private HashMap visible = new HashMap(); + private List visible = new ArrayList<>(); public Hologram_1_8_R3(String[] text, Location location) { this.text = text; @@ -33,31 +32,26 @@ public class Hologram_1_8_R3 implements Hologram { return location; } - public List getEntities() { - return entitylist; - } - public void showPlayer(OfflinePlayer p) { - for (Object o : entitylist) { + for (Object o : entityList) { EntityArmorStand armor = (EntityArmorStand) o; PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(armor); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } - visible.put(p, true); + visible.add(p); } public void hidePlayer(OfflinePlayer p) { - for (Object o : entitylist) { + for (Object o : entityList) { EntityArmorStand armor = (EntityArmorStand) o; PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(armor.getId()); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } - visible.put(p, false); + visible.remove(p); } public boolean isVisible(OfflinePlayer p) { - if (visible.containsKey(p)) return visible.get(p); - else return false; + return visible.contains(p); } private void create() { @@ -67,13 +61,13 @@ public class Hologram_1_8_R3 implements Hologram { entity.setCustomNameVisible(true); entity.setInvisible(true); entity.setGravity(false); - entitylist.add(entity); - this.location.subtract(0, this.DISTANCE, 0); + entityList.add(entity); + this.location.subtract(0, 0.25, 0); count++; } for (int i = 0; i < count; i++) { - this.location.add(0, this.DISTANCE, 0); + this.location.add(0, 0.25, 0); } count = 0; @@ -85,7 +79,7 @@ public class Hologram_1_8_R3 implements Hologram { } public void remove() { - for (EntityArmorStand e : entitylist) { + for (EntityArmorStand e : entityList) { e.die(); } exists = false; diff --git a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R1.java b/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R1.java index d6b39a3..8e01d09 100644 --- a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R1.java +++ b/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R1.java @@ -17,11 +17,10 @@ public class Hologram_1_9_R1 implements Hologram { private boolean exists = false; private int count; - private List entitylist = new ArrayList(); + private List entityList = new ArrayList<>(); private String[] text; private Location location; - private double DISTANCE = 0.25D; - private HashMap visible = new HashMap(); + private List visible = new ArrayList<>(); public Hologram_1_9_R1(String[] text, Location location) { this.text = text; @@ -33,31 +32,26 @@ public class Hologram_1_9_R1 implements Hologram { return location; } - public List getEntities() { - return entitylist; - } - public void showPlayer(OfflinePlayer p) { - for (Object o : entitylist) { + for (Object o : entityList) { EntityArmorStand armor = (EntityArmorStand) o; PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(armor); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } - visible.put(p, true); + visible.add(p); } public void hidePlayer(OfflinePlayer p) { - for (Object o : entitylist) { + for (Object o : entityList) { EntityArmorStand armor = (EntityArmorStand) o; PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(armor.getId()); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } - visible.put(p, false); + visible.remove(p); } public boolean isVisible(OfflinePlayer p) { - if (visible.containsKey(p)) return visible.get(p); - else return false; + return visible.contains(p); } private void create() { @@ -67,13 +61,13 @@ public class Hologram_1_9_R1 implements Hologram { entity.setCustomNameVisible(true); entity.setInvisible(true); entity.setGravity(false); - entitylist.add(entity); - this.location.subtract(0, this.DISTANCE, 0); + entityList.add(entity); + this.location.subtract(0, 0.25, 0); count++; } for (int i = 0; i < count; i++) { - this.location.add(0, this.DISTANCE, 0); + this.location.add(0, 0.25, 0); } count = 0; @@ -85,7 +79,7 @@ public class Hologram_1_9_R1 implements Hologram { } public void remove() { - for (EntityArmorStand e : entitylist) { + for (EntityArmorStand e : entityList) { e.die(); } exists = false; diff --git a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R2.java b/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R2.java index aa2c8d3..138400d 100644 --- a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R2.java +++ b/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R2.java @@ -10,18 +10,16 @@ import org.bukkit.craftbukkit.v1_9_R2.CraftWorld; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; public class Hologram_1_9_R2 implements Hologram { private boolean exists = false; private int count; - private List entitylist = new ArrayList(); + private List entityList = new ArrayList<>(); private String[] text; private Location location; - private double DISTANCE = 0.25D; - private HashMap visible = new HashMap(); + private List visible = new ArrayList<>(); public Hologram_1_9_R2(String[] text, Location location) { this.text = text; @@ -33,31 +31,26 @@ public class Hologram_1_9_R2 implements Hologram { return location; } - public List getEntities() { - return entitylist; - } - public void showPlayer(OfflinePlayer p) { - for (Object o : entitylist) { + for (Object o : entityList) { EntityArmorStand armor = (EntityArmorStand) o; PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(armor); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } - visible.put(p, true); + visible.add(p); } public void hidePlayer(OfflinePlayer p) { - for (Object o : entitylist) { + for (Object o : entityList) { EntityArmorStand armor = (EntityArmorStand) o; PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(armor.getId()); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } - visible.put(p, false); + visible.remove(p); } public boolean isVisible(OfflinePlayer p) { - if (visible.containsKey(p)) return visible.get(p); - else return false; + return visible.contains(p); } private void create() { @@ -67,13 +60,13 @@ public class Hologram_1_9_R2 implements Hologram { entity.setCustomNameVisible(true); entity.setInvisible(true); entity.setGravity(false); - entitylist.add(entity); - this.location.subtract(0, this.DISTANCE, 0); + entityList.add(entity); + this.location.subtract(0, 0.25, 0); count++; } for (int i = 0; i < count; i++) { - this.location.add(0, this.DISTANCE, 0); + this.location.add(0, 0.25, 0); } count = 0; @@ -85,7 +78,7 @@ public class Hologram_1_9_R2 implements Hologram { } public void remove() { - for (EntityArmorStand e : entitylist) { + for (EntityArmorStand e : entityList) { e.die(); } exists = false;