Browse Source

Fixed 1.9 - 1.14 particles. Using standard spigot api.

master
pintux98 6 years ago
parent
commit
fbcba68cb3
  1. 21
      MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Cosmeticbase.java
  2. 60
      MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/ParticleHandler.java

21
MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Cosmeticbase.java

@ -86,9 +86,10 @@ public class Cosmeticbase {
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("INSERT INTO `BG_Cosmetic` ");
queryBuilder.append("(`UUID`, `Name`, `Cage`, `Arrow_Trail`, `Feet_Trail`, `KillSound`) ");
queryBuilder.append(
"(`UUID`, `Name`, `Cage`, `Arrow_Trail`, `Feet_Trail`, `KillSound`, 'Victory', 'Ability', 'Kit') ");
queryBuilder.append("VALUES ");
queryBuilder.append("(?, ?, ?, ?, ?, ?);");
queryBuilder.append("(?, ?, ?, ?, ?, ?, ?, ?, ?);");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
preparedStatement.setString(1, fId);
preparedStatement.setString(2, name);
@ -96,6 +97,9 @@ public class Cosmeticbase {
preparedStatement.setString(4, "default");
preparedStatement.setString(5, "default");
preparedStatement.setString(6, "default");
preparedStatement.setString(7, "default");
preparedStatement.setString(8, "default");
preparedStatement.setString(9, "default");
preparedStatement.executeUpdate();
} catch (final SQLException sqlException) {
sqlException.printStackTrace();
@ -162,7 +166,8 @@ public class Cosmeticbase {
ResultSet resultSet = null;
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("SELECT `Cage`, `Arrow_Trail`, `Feet_Trail`, `KillSound` ");
queryBuilder.append(
"SELECT `Cage`, `Arrow_Trail`, `Feet_Trail`, `KillSound`, 'Victory', 'Ability', 'Kit' ");
queryBuilder.append("FROM `BG_Cosmetic` ");
queryBuilder.append("WHERE `UUID` = ? ");
queryBuilder.append("LIMIT 1;");
@ -201,14 +206,18 @@ public class Cosmeticbase {
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("UPDATE `BG_Cosmetic` SET ");
queryBuilder.append("`Cage` = ?, `Arrow_Trail` = ?, `Feet_Trail` = ?, `KillSound` = ? ");
queryBuilder.append(
"`Cage` = ?, `Arrow_Trail` = ?, `Feet_Trail` = ?, `KillSound` = ?, 'Victory' = ?, 'Ability' = ?, 'Kit' = ?");
queryBuilder.append("WHERE `UUID` = ?;");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
preparedStatement.setString(1, stat.getCage());
preparedStatement.setString(2, stat.getArrow_trail());
preparedStatement.setString(3, stat.getFeet_trail());
preparedStatement.setString(4, "default");
preparedStatement.setString(5, stat.getUUID());
preparedStatement.setString(5, "default");
preparedStatement.setString(6, "default");
preparedStatement.setString(7, "default");
preparedStatement.setString(8, stat.getUUID());
preparedStatement.executeUpdate();
} catch (SQLException sqlException) {
sqlException.printStackTrace();
@ -233,7 +242,7 @@ public class Cosmeticbase {
Statement statement = connection.createStatement();
try {
statement.executeUpdate(
"CREATE TABLE IF NOT EXISTS BG_Cosmetic (UUID VARCHAR(60), Name VARCHAR(60), Cage TEXT, Arrow_Trail TEXT, Feet_Trail TEXT, KillSound TEXT)");
"CREATE TABLE IF NOT EXISTS BG_Cosmetic (UUID VARCHAR(60), Name VARCHAR(60), Cage TEXT, Arrow_Trail TEXT, Feet_Trail TEXT, KillSound TEXT, Victory TEXT, Ability TEXT, Kit TEXT)");
} catch (SQLException ex) {
try {
if (statement != null) {

60
MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/ParticleHandler.java

@ -8,6 +8,7 @@ import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -19,7 +20,6 @@ public class ParticleHandler {
private static Method player_sendPacket = null;
private static HashMap<Class<? extends Entity>, Method> handles = new HashMap<Class<? extends Entity>, Method>();
private static boolean newParticlePacketConstructor = false;
private static Class<Enum> enumParticle = null;
private ParticleType type;
@ -27,8 +27,6 @@ public class ParticleHandler {
private int count;
private double radius;
private static boolean compatible = true;
public static void load() {
String vString = getVersion().replace("v", "");
double v = 0;
@ -37,25 +35,20 @@ public class ParticleHandler {
v = Double.parseDouble(array[0] + "." + array[1]);
}
try {
Bukkit.getLogger().info("[ParticleHandler] Hooking into Netty NMS classes");
packetClass = getNmsClass("PacketPlayOutWorldParticles");
if (v == 1.8 || v == 1.9 || v == 1.10 || v == 1.11 || v == 1.12) {
Bukkit.getLogger().info("[ParticleHandler] Version is " + v + " - using old packet constructor");
if (v == 1.8) {
Bukkit.getLogger().info("[ParticleHandler] Hooking into Netty NMS classes");
Bukkit.getLogger().info("[ParticleHandler] Version is " + v + " - using packet constructor");
enumParticle = (Class<Enum>) getNmsClass("EnumParticle");
packetConstructor = packetClass.getDeclaredConstructor(enumParticle, boolean.class, float.class,
float.class, float.class, float.class, float.class, float.class, float.class, int.class,
int[].class);
} else {
Bukkit.getLogger().info("[ParticleHandler] Version is " + v + " - using new packet constructor");
newParticlePacketConstructor = true;
enumParticle = (Class<Enum>) getNmsClass("EnumParticle");
packetConstructor = packetClass.getDeclaredConstructor(enumParticle, boolean.class, float.class,
float.class, float.class, float.class, float.class, float.class, float.class, int.class);
Bukkit.getLogger().info("[ParticleHandler] Hooking into the new particle system");
}
} catch (Exception ex) {
ex.printStackTrace();
Bukkit.getLogger().severe("[ParticleHandler] Failed to initialize NMS components!");
compatible = false;
}
}
@ -79,13 +72,25 @@ public class ParticleHandler {
}
public void sendToLocation(Location location) {
try {
Object packet = createPacket(location);
for (Player player : Bukkit.getOnlinePlayers()) {
sendPacket(player, packet);
String vString = getVersion().replace("v", "");
double v = 0;
if (!vString.isEmpty()) {
String[] array = vString.split("_");
v = Double.parseDouble(array[0] + "." + array[1]);
}
if (v == 1.8) {
try {
Object packet = createPacket(location);
for (Player player : Bukkit.getOnlinePlayers()) {
sendPacket(player, packet);
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
} else {
location.getWorld().spawnParticle(Particle.valueOf(type.getName().toUpperCase()), (float) location.getX(),
(float) location.getY(), (float) location.getZ(), this.count, (float) this.radius,
(float) this.radius, (float) this.radius, (float) this.speed);
}
}
@ -95,17 +100,10 @@ public class ParticleHandler {
this.count = 1;
}
Object packet;
if (newParticlePacketConstructor) {
Object particleType = enumParticle.getEnumConstants()[type.getId()];
packet = packetConstructor.newInstance(particleType, true, (float) location.getX(),
(float) location.getY(), (float) location.getZ(), (float) this.radius, (float) this.radius,
(float) this.radius, (float) this.speed, this.count);
} else {
Object particleType = enumParticle.getEnumConstants()[type.getId()];
packet = packetConstructor.newInstance(particleType, true, (float) location.getX(),
(float) location.getY(), (float) location.getZ(), (float) this.radius, (float) this.radius,
(float) this.radius, (float) this.speed, this.count, new int[0]);
}
Object particleType = enumParticle.getEnumConstants()[type.getId()];
packet = packetConstructor.newInstance(particleType, true, (float) location.getX(), (float) location.getY(),
(float) location.getZ(), (float) this.radius, (float) this.radius, (float) this.radius,
(float) this.speed, this.count, new int[0]);
return packet;
} catch (IllegalAccessException ex) {
ex.printStackTrace();
@ -178,10 +176,6 @@ public class ParticleHandler {
return "";
}
public static boolean isCompatible() {
return compatible;
}
public enum ParticleType {
EXPLOSION_NORMAL("explode", 0, 17), EXPLOSION_LARGE("largeexplode", 1, 1),

Loading…
Cancel
Save