Browse Source

Cleaned some messages and first implementation of 1.13

master
pintux98 6 years ago
parent
commit
28dd8a990a
  1. 11
      .project
  2. 1
      MultiArena-TheBridge/.classpath
  3. 2
      MultiArena-TheBridge/.project
  4. 4
      MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Cosmeticbase.java
  5. 4
      MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Database.java
  6. 50
      MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologramAPI.java
  7. 278
      MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_13_R2.java
  8. 10
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/GameManager.java

11
.project

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>thebridge</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

1
MultiArena-TheBridge/.classpath

@ -12,5 +12,6 @@
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/spigot-1.10.2-R0.1-SNAPSHOT-latest.jar"/>
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/spigot-1.11.2.jar"/>
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/spigot-1.12.2.jar"/>
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/spigot-1.13.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

2
MultiArena-TheBridge/.project

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MultiArena-TheBridge</name>
<name>TheBridge</name>
<comment></comment>
<projects>
</projects>

4
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();

4
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();

50
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;
}
}
}

278
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<String> lines;
private double linesdistance = 0.30;
private ArrayList<ArmorStand> armor_lines = new ArrayList<>();
private ArrayList<EntityArmorStand> NmsArmorLines = new ArrayList<>();
private Player player = null;
@Override
public void setupWorldHologram(Location loc, ArrayList<String> lines) {
this.location = loc.clone();
this.lines = lines;
}
@Override
public void setupPlayerHologram(Player player, Location loc, ArrayList<String> 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<String> 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;
}
}

10
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/GameManager.java

@ -38,7 +38,7 @@ public class GameManager {
this.playerGameFour = new HashMap<Player, GameFour>();
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);

Loading…
Cancel
Save