diff --git a/.project b/.project new file mode 100644 index 0000000..dafc5dc --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + thebridge + + + + + + + + diff --git a/MultiArena-TheBridge/.classpath b/MultiArena-TheBridge/.classpath index 78d3ef7..2b49d10 100644 --- a/MultiArena-TheBridge/.classpath +++ b/MultiArena-TheBridge/.classpath @@ -12,5 +12,6 @@ + diff --git a/MultiArena-TheBridge/.project b/MultiArena-TheBridge/.project index 37d6216..a6fe83b 100644 --- a/MultiArena-TheBridge/.project +++ b/MultiArena-TheBridge/.project @@ -1,6 +1,6 @@ - MultiArena-TheBridge + TheBridge diff --git a/MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Cosmeticbase.java b/MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Cosmeticbase.java index 56cda34..6a26850 100644 --- a/MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Cosmeticbase.java +++ b/MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Cosmeticbase.java @@ -32,7 +32,7 @@ public class Cosmeticbase { try { Class.forName("com.mysql.jdbc.Driver"); connection = DriverManager.getConnection("jdbc:mysql://" + (plugin.getConfig().getString("MySQL.host") +":"+ plugin.getConfig().getString("MySQL.port")) + "/" + plugin.getConfig().getString("MySQL.database") + "?serverTimezone=" + TimeZone.getDefault().getID() + "&autoReconnect=true&wait_timeout=31536000&interactive_timeout=31536000", plugin.getConfig().getString("MySQL.username"), plugin.getConfig().getString("MySQL.password")); - Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[TheBridge] MySQL conectada."); + Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[TheBridge] MySQL connected."); newTables(); } catch (Exception e) { e.printStackTrace(); @@ -51,7 +51,7 @@ public class Cosmeticbase { Class.forName("org.sqlite.JDBC"); try { connection = DriverManager.getConnection("jdbc:sqlite:" + DataFile); - Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[TheBridge] SQLLite conectado."); + Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[TheBridge] SQLLite connected."); newTables(); } catch (SQLException ex2) { ex2.printStackTrace(); diff --git a/MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Database.java b/MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Database.java index c32d516..d403135 100644 --- a/MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Database.java +++ b/MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Database.java @@ -34,7 +34,7 @@ public class Database { try { Class.forName("com.mysql.jdbc.Driver"); connection = DriverManager.getConnection("jdbc:mysql://" + (plugin.getConfig().getString("MySQL.host") +":"+ plugin.getConfig().getString("MySQL.port")) + "/" + plugin.getConfig().getString("MySQL.database") + "?serverTimezone=" + TimeZone.getDefault().getID() + "&autoReconnect=true&wait_timeout=31536000&interactive_timeout=31536000", plugin.getConfig().getString("MySQL.username"), plugin.getConfig().getString("MySQL.password")); - Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[TheBridge] MySQL conectada."); + Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[TheBridge] MySQL connected."); newTables(); } catch (Exception e) { e.printStackTrace(); @@ -53,7 +53,7 @@ public class Database { Class.forName("org.sqlite.JDBC"); try { connection = DriverManager.getConnection("jdbc:sqlite:" + DataFile); - Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[TheBridge] SQLLite conectado."); + Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[TheBridge] SQLLite connected."); newTables(); } catch (SQLException ex2) { ex2.printStackTrace(); diff --git a/MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologramAPI.java b/MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologramAPI.java index feff959..1769967 100644 --- a/MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologramAPI.java +++ b/MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologramAPI.java @@ -13,34 +13,36 @@ import net.md_5.bungee.api.ChatColor; public class TruenoHologramAPI { private static String version; - - private static void setupVersion(){ - try { - version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; - } catch (ArrayIndexOutOfBoundsException ex) { - ex.printStackTrace(); - } + + private static void setupVersion() { + try { + version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; + } catch (ArrayIndexOutOfBoundsException ex) { + ex.printStackTrace(); + } } - - public static TruenoHologram getNewHologram(){ - if(version==null){ + + public static TruenoHologram getNewHologram() { + if (version == null) { setupVersion(); } if (version.equals("v1_8_R3")) { - return new TruenoHologram_v1_8_R3(); - } else if (version.equals("v1_9_R2")) { - return new TruenoHologram_v1_9_R2(); - } else if (version.equals("v1_10_R1")) { - return new TruenoHologram_v1_10_R1(); - } else if (version.equals("v1_11_R1")) { - return new TruenoHologram_v1_11_R1(); - } else if (version.equals("v1_12_R1")) { - return new TruenoHologram_v1_12_R1(); - } else { - Bukkit.getLogger().log(Level.SEVERE, ChatColor.RED + "Unsopported server version."); - return null; - } + return new TruenoHologram_v1_8_R3(); + } else if (version.equals("v1_9_R2")) { + return new TruenoHologram_v1_9_R2(); + } else if (version.equals("v1_10_R1")) { + return new TruenoHologram_v1_10_R1(); + } else if (version.equals("v1_11_R1")) { + return new TruenoHologram_v1_11_R1(); + } else if (version.equals("v1_12_R1")) { + return new TruenoHologram_v1_12_R1(); + } else if (version.equals("v1_13_R2")) { + return new TruenoHologram_v1_13_R2(); + } else { + Bukkit.getLogger().log(Level.SEVERE, ChatColor.RED + "Unsopported server version."); + return null; + } } - + } diff --git a/MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_13_R2.java b/MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_13_R2.java new file mode 100644 index 0000000..8e124a8 --- /dev/null +++ b/MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_13_R2.java @@ -0,0 +1,278 @@ +package cx.sfy.TheBridge.hologram; + +import java.util.ArrayList; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_13_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +import net.minecraft.server.v1_13_R2.EntityArmorStand; +import net.minecraft.server.v1_13_R2.IChatBaseComponent.ChatSerializer; +import net.minecraft.server.v1_13_R2.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_13_R2.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_13_R2.WorldServer; + +public class TruenoHologram_v1_13_R2 implements TruenoHologram{ + + private Location location; + private ArrayList lines; + private double linesdistance = 0.30; + + private ArrayList armor_lines = new ArrayList<>(); + private ArrayList NmsArmorLines = new ArrayList<>(); + + private Player player = null; + + @Override + public void setupWorldHologram(Location loc, ArrayList lines) { + this.location = loc.clone(); + this.lines = lines; + + } + + @Override + public void setupPlayerHologram(Player player, Location loc, ArrayList lines) { + this.player = player; + this.location = loc.clone(); + this.lines = lines; + + } + + @Override + public Location getLocation(){ + return this.location; + } + + @Override + public Player getPlayer(){ + return player; + } + + private void NmsDestroy(EntityArmorStand hololine){ + final PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(hololine.getId()); + ((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(packet); + } + + private Location getNmsLocation(EntityArmorStand hololine){ + return new Location(hololine.getWorld().getWorld(), hololine.locX, hololine.locY, hololine.locZ); + } + + private void NmsSpawn(EntityArmorStand stand, String line, Location loc){ + stand.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0); + stand.setCustomName(ChatSerializer.a(line)); + stand.setCustomNameVisible(true); + stand.setNoGravity(true); + stand.setSmall(true); + stand.setInvisible(true); + stand.setBasePlate(false); + stand.setArms(false); + if(!line.equals("")){ + final PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(stand); + ((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(packet); + } + } + + private void spawn(){ + int ind = 0; + for(final String line : lines){ + Location finalLoc = location.clone(); + finalLoc.setY(location.getY()+(linesdistance*lines.size())); + if(this.player!=null){ + if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance); + final WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle(); + final EntityArmorStand stand = new EntityArmorStand(s); + NmsSpawn(stand, line, finalLoc); + NmsArmorLines.add(stand); + } + else{ + if(ind>0) finalLoc = armor_lines.get(ind-1).getLocation(); finalLoc.setY(finalLoc.getY()-linesdistance); + final ArmorStand Armorline = (ArmorStand) location.getWorld().spawnEntity(finalLoc, EntityType.ARMOR_STAND); + Armorline.setBasePlate(false); + Armorline.setCustomNameVisible(true); + Armorline.setGravity(false); + Armorline.setCanPickupItems(false); + Armorline.setCustomName(line); + Armorline.setSmall(true); + Armorline.setVisible(false); + armor_lines.add(Armorline); + if(line.equals("")) Armorline.remove(); + } + ind++; + } + } + + private void despawn(){ + if(this.player!=null){ + for(final EntityArmorStand nmsStand : NmsArmorLines) + NmsDestroy(nmsStand); + NmsArmorLines.clear(); + } + else{ + for(final ArmorStand line : armor_lines) + line.remove(); + armor_lines.clear(); + } + } + + @Override + public void setDistanceBetweenLines(Double distance){ + this.linesdistance = distance; + } + + @Override + public void display(){ + spawn(); + } + + @Override + public void update(ArrayList lines){ + if(this.player != null){ + int ind = 0; + for(final String newline : lines) + if(this.lines.size()>= ind){ + final String oldline = this.lines.get(ind); + if(!newline.equals(oldline)) + if(!newline.equals("")){ + final EntityArmorStand oldstand = NmsArmorLines.get(ind); + Location finalLoc = location.clone(); + finalLoc.setY(location.getY()+(linesdistance*lines.size())); + if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance); + final WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle(); + final EntityArmorStand stand = new EntityArmorStand(s); + NmsSpawn(stand, newline, finalLoc); + this.NmsArmorLines.set(ind, stand); + this.lines.set(ind, newline); + NmsDestroy(oldstand); + } + else{ + this.lines.set(ind, newline); + final EntityArmorStand oldstand = NmsArmorLines.get(ind); + NmsDestroy(oldstand); + } + ind++; + } + else{ + Location finalLoc = location.clone(); + finalLoc.setY(location.getY()+(linesdistance*lines.size())); + if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance); + final WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle(); + final EntityArmorStand stand = new EntityArmorStand(s); + NmsSpawn(stand, newline, finalLoc); + this.NmsArmorLines.add(stand); + this.lines.add(newline); + } + if(lines.size() > this.lines.size()){ + final int dif = lines.size() - this.lines.size(); + for(int in = 0; in <=dif; in++){ + final int arrayind = (this.lines.size()-1)-in; + this.lines.remove(arrayind); + NmsDestroy(this.NmsArmorLines.get(arrayind)); + this.NmsArmorLines.remove(arrayind); + } + } + } + else{ + int ind = 0; + for(final String newline : lines) + if(this.lines.size()>= ind){ + final String oldline = this.lines.get(ind); + if(!newline.equals(oldline)) + if(newline != "") + this.armor_lines.get(ind).setCustomName(newline); + else{ + this.lines.set(ind, newline); + final ArmorStand oldstand = armor_lines.get(ind); + oldstand.remove(); + } + ind++; + } + else{ + Location finalLoc = location.clone(); + finalLoc.setY(location.getY()+(linesdistance*lines.size())); + if(ind>0) finalLoc = armor_lines.get(ind-1).getLocation(); finalLoc.setY(finalLoc.getY()-linesdistance); + final ArmorStand Armorline = (ArmorStand) location.getWorld().spawnEntity(finalLoc, EntityType.ARMOR_STAND); + Armorline.setBasePlate(false); + Armorline.setCustomNameVisible(true); + Armorline.setGravity(false); + Armorline.setCanPickupItems(false); + Armorline.setCustomName(newline); + Armorline.setSmall(true); + Armorline.setVisible(false); + armor_lines.add(Armorline); + this.lines.add(newline); + } + if(lines.size() > this.lines.size()){ + final int dif = lines.size() - this.lines.size(); + for(int in = 0; in <=dif; in++){ + final int arrayind = (this.lines.size()-1)-in; + this.lines.remove(arrayind); + this.armor_lines.get(arrayind).remove(); + this.armor_lines.remove(arrayind); + } + } + } + } + + @Override + public void updateLine(int index, String text){ + if(this.lines.size() >= index){ + final int realindex = (this.lines.size()-1)-index; + final String oldtext = this.lines.get(realindex); + if(!text.equals(oldtext)){ + if(this.player != null){ + if(text != ""){ + final EntityArmorStand oldstand = NmsArmorLines.get(realindex); + Location finalLoc = location.clone(); + finalLoc.setY(location.getY()+(linesdistance*lines.size())); + if(realindex>0) finalLoc = getNmsLocation(NmsArmorLines.get(realindex-1)); finalLoc.setY(finalLoc.getY()-linesdistance); + final WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle(); + final EntityArmorStand stand = new EntityArmorStand(s); + NmsSpawn(stand, text, finalLoc); + this.NmsArmorLines.set(realindex, stand); + NmsDestroy(oldstand); + } + else{ + this.lines.set(realindex, text); + final EntityArmorStand oldstand = NmsArmorLines.get(realindex); + NmsDestroy(oldstand); + } + } else if(text != "") + this.armor_lines.get(realindex).setCustomName(text); + else{ + final ArmorStand oldstand = armor_lines.get(realindex); + oldstand.remove(); + } + this.lines.set(realindex, text); + } + } + + } + + @Override + public void removeLine(int index){ + if(this.lines.size() >= index){ + final int realindex = (this.lines.size()-1)-index; + if(this.player != null){ + final EntityArmorStand stand = NmsArmorLines.get(realindex); + this.NmsArmorLines.remove(stand); + NmsDestroy(stand); + } else + this.armor_lines.get(realindex).remove(); + this.lines.remove(realindex); + } + } + + @Override + public void delete(){ + despawn(); + this.player = null; + this.NmsArmorLines = new ArrayList<>(); + this.armor_lines = new ArrayList<>(); + this.lines = new ArrayList<>(); + this.location = null; + } + +} diff --git a/MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/GameManager.java b/MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/GameManager.java index 4866ad9..361099a 100644 --- a/MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/GameManager.java +++ b/MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/GameManager.java @@ -38,7 +38,7 @@ public class GameManager { this.playerGameFour = new HashMap(); this.kit = Bukkit.getServer().createInventory(null, InventoryType.PLAYER); if (plugin.getConfig().getString("kit") == null) { - Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "No hay un kit establecido. Usa " + ChatColor.YELLOW + "/bridges setkit"); + Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "You don't have a default kit set up. Use " + ChatColor.YELLOW + "/bridges setkit"); } else { try { kit.setContents(plugin.getKit().fromBase64(plugin.getConfig().getString("kit")).getContents()); @@ -77,10 +77,10 @@ public class GameManager { FileConfiguration yml = YamlConfiguration.loadConfiguration(arena); String name = yml.getString("name"); if (yml.getString("locations.lobby") == null) { - Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "El mapa " + ChatColor.YELLOW + name + " " + ChatColor.RED + "no tiene seteado el Lobby."); + Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "The map " + ChatColor.YELLOW + name + " " + ChatColor.RED + "doesn't have lobby location set up."); } if (yml.getString("locations.spect") == null) { - Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "El mapa " + ChatColor.YELLOW + name + " " + ChatColor.RED + "no tiene seteado el Spectador."); + Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "The map " + ChatColor.YELLOW + name + " " + ChatColor.RED + "doesn't have spectator location set up."); } Location hRed = null; Location hBlue = null; @@ -188,11 +188,11 @@ public class GameManager { if (yml.getString("mode").toLowerCase().equals("normal")) { String name = yml.getString("name"); if (yml.getString("locations.lobby") == null) { - Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "El mapa " + ChatColor.YELLOW + name + " " + ChatColor.RED + "no tiene seteado el Lobby."); + Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "The map " + ChatColor.YELLOW + name + " " + ChatColor.RED + "doesn't have lobby location set up."); continue; } if (yml.getString("locations.spect") == null) { - Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "El mapa " + ChatColor.YELLOW + name + " " + ChatColor.RED + "no tiene seteado el Spectador."); + Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "The map " + ChatColor.YELLOW + name + " " + ChatColor.RED + "doesn't have spectator location set up."); continue; } plugin.getWC().resetWorld(name);