mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-24 09:47:38 +01:00
Drop 1.6.4 support.
This commit is contained in:
parent
1a0b4d5320
commit
b78239b520
@ -47,9 +47,6 @@ public class HolographicDisplays extends JavaPlugin {
|
||||
// Since 1.9 there is a different offset for the nametag.
|
||||
private static boolean is19orGreater;
|
||||
|
||||
// Used for the server pinger.
|
||||
private static boolean isPreNetty;
|
||||
|
||||
// The new version found by the updater, null if there is no new version.
|
||||
private static String newVersion;
|
||||
|
||||
@ -93,10 +90,7 @@ public class HolographicDisplays extends JavaPlugin {
|
||||
// Caused by MCPC+ / Cauldron renaming packages, extract the version from Bukkit.getVersion().
|
||||
version = VersionUtils.getMinecraftVersion();
|
||||
|
||||
if ("1.6.4".equals(version)) {
|
||||
version = "v1_6_R3";
|
||||
isPreNetty = true;
|
||||
} else if ("1.7.2".equals(version)) {
|
||||
if ("1.7.2".equals(version)) {
|
||||
version = "v1_7_R1";
|
||||
} else if ("1.7.5".equals(version)) {
|
||||
version = "v1_7_R2";
|
||||
@ -115,9 +109,7 @@ public class HolographicDisplays extends JavaPlugin {
|
||||
}
|
||||
|
||||
// It's simple, we don't need reflection.
|
||||
if ("v1_6_R3".equals(version)) {
|
||||
nmsManager = new com.gmail.filoghost.holographicdisplays.nms.v1_6_R3.NmsManagerImpl();
|
||||
} else if ("v1_7_R1".equals(version)) {
|
||||
if ("v1_7_R1".equals(version)) {
|
||||
nmsManager = new com.gmail.filoghost.holographicdisplays.nms.v1_7_R1.NmsManagerImpl();
|
||||
} else if ("v1_7_R2".equals(version)) {
|
||||
nmsManager = new com.gmail.filoghost.holographicdisplays.nms.v1_7_R2.NmsManagerImpl();
|
||||
@ -150,7 +142,7 @@ public class HolographicDisplays extends JavaPlugin {
|
||||
printWarnAndDisable(
|
||||
"******************************************************",
|
||||
" This version of HolographicDisplays only",
|
||||
" works on server versions from 1.6.4 to 1.10.",
|
||||
" works on server versions from 1.7 to 1.10.",
|
||||
" The plugin will be disabled.",
|
||||
"******************************************************"
|
||||
);
|
||||
@ -287,10 +279,6 @@ public class HolographicDisplays extends JavaPlugin {
|
||||
return is19orGreater;
|
||||
}
|
||||
|
||||
public static boolean isPreNetty() {
|
||||
return isPreNetty;
|
||||
}
|
||||
|
||||
private static void printWarnAndDisable(String... messages) {
|
||||
StringBuffer buffer = new StringBuffer("\n ");
|
||||
for (String message : messages) {
|
||||
|
@ -22,8 +22,6 @@ public class BungeeServerTracker {
|
||||
private static Map<String, BungeeServerInfo> trackedServers = new ConcurrentHashMap<String, BungeeServerInfo>();
|
||||
private static int taskID = -1;
|
||||
|
||||
private static ServerPinger pinger = HolographicDisplays.isPreNetty() ? ServerPinger.PRE_NETTY_REWRITE : ServerPinger.POST_NETTY_REWRITE;
|
||||
|
||||
public static void resetTrackedServers() {
|
||||
trackedServers.clear();
|
||||
}
|
||||
@ -161,7 +159,7 @@ public class BungeeServerTracker {
|
||||
boolean displayOffline = false;
|
||||
|
||||
try {
|
||||
PingResponse data = pinger.fetchData(entry.getValue(), Configuration.pingerTimeout);
|
||||
PingResponse data = ServerPinger.fetchData(entry.getValue(), Configuration.pingerTimeout);
|
||||
|
||||
if (data.isOnline()) {
|
||||
serverInfo.setOnline(true);
|
||||
|
@ -1,18 +1,51 @@
|
||||
package com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
public class ServerPinger {
|
||||
|
||||
public static PingResponse fetchData(final ServerAddress serverAddress, int timeout) throws SocketTimeoutException, UnknownHostException, IOException, Exception {
|
||||
|
||||
Socket socket = null;
|
||||
DataOutputStream dataOut = null;
|
||||
DataInputStream dataIn = null;
|
||||
|
||||
try {
|
||||
socket = new Socket(serverAddress.getAddress(), serverAddress.getPort());
|
||||
socket.setSoTimeout(timeout);
|
||||
dataOut = new DataOutputStream(socket.getOutputStream());
|
||||
dataIn = new DataInputStream(socket.getInputStream());
|
||||
final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
||||
final DataOutputStream handshake = new DataOutputStream(byteOut);
|
||||
handshake.write(0);
|
||||
PacketUtils.writeVarInt(handshake, 4);
|
||||
PacketUtils.writeString(handshake, serverAddress.getAddress(), PacketUtils.UTF8);
|
||||
handshake.writeShort(serverAddress.getPort());
|
||||
PacketUtils.writeVarInt(handshake, 1);
|
||||
byte[] bytes = byteOut.toByteArray();
|
||||
PacketUtils.writeVarInt(dataOut, bytes.length);
|
||||
dataOut.write(bytes);
|
||||
bytes = new byte[] { 0 };
|
||||
PacketUtils.writeVarInt(dataOut, bytes.length);
|
||||
dataOut.write(bytes);
|
||||
PacketUtils.readVarInt(dataIn);
|
||||
PacketUtils.readVarInt(dataIn);
|
||||
final byte[] responseData = new byte[PacketUtils.readVarInt(dataIn)];
|
||||
dataIn.readFully(responseData);
|
||||
final String jsonString = new String(responseData, PacketUtils.UTF8);
|
||||
return new PingResponse(jsonString, serverAddress);
|
||||
}
|
||||
finally {
|
||||
PacketUtils.closeQuietly(dataOut);
|
||||
PacketUtils.closeQuietly(dataIn);
|
||||
PacketUtils.closeQuietly(socket);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class ServerPinger {
|
||||
|
||||
// For 1.7 and higher
|
||||
public static final ServerPinger POST_NETTY_REWRITE = new ServerPingerPostNetty();
|
||||
|
||||
// For 1.6 and lower
|
||||
public static final ServerPinger PRE_NETTY_REWRITE = new ServerPingerPreNetty();
|
||||
|
||||
public abstract PingResponse fetchData(final ServerAddress serverAddress, int timeout) throws SocketTimeoutException, UnknownHostException, IOException, Exception;
|
||||
|
||||
}
|
||||
|
@ -1,52 +0,0 @@
|
||||
package com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
final class ServerPingerPostNetty extends ServerPinger {
|
||||
|
||||
@Override
|
||||
public PingResponse fetchData(final ServerAddress serverAddress, int timeout) throws SocketTimeoutException, UnknownHostException, IOException, Exception {
|
||||
|
||||
Socket socket = null;
|
||||
DataOutputStream dataOut = null;
|
||||
DataInputStream dataIn = null;
|
||||
|
||||
try {
|
||||
socket = new Socket(serverAddress.getAddress(), serverAddress.getPort());
|
||||
socket.setSoTimeout(timeout);
|
||||
dataOut = new DataOutputStream(socket.getOutputStream());
|
||||
dataIn = new DataInputStream(socket.getInputStream());
|
||||
final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
||||
final DataOutputStream handshake = new DataOutputStream(byteOut);
|
||||
handshake.write(0);
|
||||
PacketUtils.writeVarInt(handshake, 4);
|
||||
PacketUtils.writeString(handshake, serverAddress.getAddress(), PacketUtils.UTF8);
|
||||
handshake.writeShort(serverAddress.getPort());
|
||||
PacketUtils.writeVarInt(handshake, 1);
|
||||
byte[] bytes = byteOut.toByteArray();
|
||||
PacketUtils.writeVarInt(dataOut, bytes.length);
|
||||
dataOut.write(bytes);
|
||||
bytes = new byte[] { 0 };
|
||||
PacketUtils.writeVarInt(dataOut, bytes.length);
|
||||
dataOut.write(bytes);
|
||||
PacketUtils.readVarInt(dataIn);
|
||||
PacketUtils.readVarInt(dataIn);
|
||||
final byte[] responseData = new byte[PacketUtils.readVarInt(dataIn)];
|
||||
dataIn.readFully(responseData);
|
||||
final String jsonString = new String(responseData, PacketUtils.UTF8);
|
||||
return new PingResponse(jsonString, serverAddress);
|
||||
}
|
||||
finally {
|
||||
PacketUtils.closeQuietly(dataOut);
|
||||
PacketUtils.closeQuietly(dataIn);
|
||||
PacketUtils.closeQuietly(socket);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger;
|
||||
|
||||
import java.lang.Override;
|
||||
import java.io.IOException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.lang.Integer;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.net.Socket;
|
||||
import java.util.Arrays;
|
||||
import java.lang.String;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||
|
||||
final class ServerPingerPreNetty extends ServerPinger {
|
||||
|
||||
@Override
|
||||
public PingResponse fetchData(final ServerAddress serverAddress, int timeout) throws SocketTimeoutException, UnknownHostException, IOException, Exception {
|
||||
|
||||
Socket socket = null;
|
||||
DataOutputStream dataOut = null;
|
||||
DataInputStream dataIn = null;
|
||||
|
||||
try {
|
||||
socket = new Socket(serverAddress.getAddress(), serverAddress.getPort());
|
||||
socket.setSoTimeout(timeout);
|
||||
dataOut = new DataOutputStream(socket.getOutputStream());
|
||||
dataIn = new DataInputStream(socket.getInputStream());
|
||||
PacketUtils.a(dataOut, "FE");
|
||||
PacketUtils.a(dataOut, "01");
|
||||
dataIn.readByte();
|
||||
dataIn.readByte();
|
||||
final int length = dataIn.readByte() * 2;
|
||||
final byte[] bytes = new byte[length];
|
||||
dataIn.readFully(bytes);
|
||||
socket.close();
|
||||
final String[] info = new String(bytes, PacketUtils.UTF16BE).split(String.valueOf('\0'));
|
||||
|
||||
if (info.length < 6) {
|
||||
DebugHandler.logToConsole("Received invalid ping response: " + Arrays.toString(info));
|
||||
return new PingResponse(true, "Invalid ping response", 0, 0);
|
||||
}
|
||||
|
||||
final PingResponse response = new PingResponse(true, info[3], Integer.parseInt(info[4]), Integer.parseInt(info[5]));
|
||||
// String versionName = info[2];
|
||||
// String protocol = info[1];
|
||||
return response;
|
||||
}
|
||||
finally {
|
||||
PacketUtils.closeQuietly(dataIn);
|
||||
PacketUtils.closeQuietly(dataOut);
|
||||
PacketUtils.closeQuietly(socket);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftHorse;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSHorse extends CraftHorse {
|
||||
|
||||
public CraftNMSHorse(CraftServer server, EntityNMSHorse entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Horse class
|
||||
@Override public void setVariant(Variant variant) { }
|
||||
@Override public void setColor(Color color) { }
|
||||
@Override public void setStyle(Style style) { }
|
||||
@Override public void setCarryingChest(boolean chest) { }
|
||||
@Override public void setDomestication(int domestication) { }
|
||||
@Override public void setJumpStrength(double jump) { }
|
||||
|
||||
// Methods form Ageable class
|
||||
@Override public void setAge(int age) { }
|
||||
@Override public void setAgeLock(boolean lock) { }
|
||||
@Override public void setBreed(boolean breed) { }
|
||||
@Override public void setAdult() { }
|
||||
@Override public void setBaby() { }
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
|
||||
// Methods from Tameable
|
||||
@Override public void setTamed(boolean tame) { }
|
||||
@Override public void setOwner(AnimalTamer owner) { }
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftItem;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSItem extends CraftItem {
|
||||
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftSlime;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSSlime extends CraftSlime {
|
||||
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
|
||||
// Methods from Slime
|
||||
@Override public void setSize(int size) { }
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftWitherSkull;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftNMSWitherSkull extends CraftWitherSkull {
|
||||
|
||||
public CraftNMSWitherSkull(CraftServer server, EntityNMSWitherSkull entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Method from Fireball
|
||||
@Override public void setDirection(Vector dir) { }
|
||||
|
||||
// Method from Projectile
|
||||
@Override public void setBounce(boolean bounce) { }
|
||||
|
||||
// Methods from Explosive
|
||||
@Override public void setYield(float yield) { }
|
||||
@Override public void setIsIncendiary(boolean fire) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
|
||||
}
|
@ -1,185 +0,0 @@
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
|
||||
|
||||
import net.minecraft.server.v1_6_R3.Entity;
|
||||
import net.minecraft.server.v1_6_R3.EntityHorse;
|
||||
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_6_R3.World;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSHorse;
|
||||
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
||||
|
||||
public class EntityNMSHorse extends EntityHorse implements NMSHorse {
|
||||
|
||||
private boolean lockTick;
|
||||
private CraftHologramLine parentPiece;
|
||||
|
||||
public EntityNMSHorse(World world, CraftHologramLine parentPiece) {
|
||||
super(world);
|
||||
super.ageLocked = true;
|
||||
super.persistent = true;
|
||||
super.boundingBox.a = 0.0;
|
||||
super.boundingBox.b = 0.0;
|
||||
super.boundingBox.c = 0.0;
|
||||
super.boundingBox.d = 0.0;
|
||||
super.boundingBox.e = 0.0;
|
||||
super.boundingBox.f = 0.0;
|
||||
a(0.0F, 0.0F);
|
||||
setAge(-1700000); // This is a magic value. No one will see the real horse.
|
||||
this.parentPiece = parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void l_() {
|
||||
// Checks every 20 ticks.
|
||||
if (ticksLived % 20 == 0) {
|
||||
// The horse dies without a vehicle.
|
||||
if (this.vehicle == null) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if (!lockTick) {
|
||||
super.l_();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable() {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeSound(String sound, float volume, float pitch) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockTick(boolean lock) {
|
||||
lockTick = lock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
setLockTick(false);
|
||||
super.die();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
if (name != null && name.length() > 64) {
|
||||
name = name.substring(0, 64);
|
||||
}
|
||||
super.setCustomName(name);
|
||||
super.setCustomNameVisible(name != null && !name.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
this.bukkitEntity = new CraftNMSHorse(this.world.getServer(), this);
|
||||
}
|
||||
return this.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
die();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftHologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
ReflectionUtils.setPrivateField(Entity.class, this, "f", (double) 0.0);
|
||||
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
|
||||
} catch (Exception ex) {
|
||||
DebugHandler.handleDebugException(ex);
|
||||
}
|
||||
|
||||
if (this.vehicle != null) {
|
||||
this.vehicle.passenger = null;
|
||||
}
|
||||
|
||||
this.vehicle = entity;
|
||||
entity.passenger = this;
|
||||
}
|
||||
|
||||
}
|
@ -1,216 +0,0 @@
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
|
||||
|
||||
import net.minecraft.server.v1_6_R3.Block;
|
||||
import net.minecraft.server.v1_6_R3.Entity;
|
||||
import net.minecraft.server.v1_6_R3.EntityHuman;
|
||||
import net.minecraft.server.v1_6_R3.EntityItem;
|
||||
import net.minecraft.server.v1_6_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_6_R3.ItemStack;
|
||||
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_6_R3.NBTTagList;
|
||||
import net.minecraft.server.v1_6_R3.NBTTagString;
|
||||
import net.minecraft.server.v1_6_R3.World;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.listener.MainListener;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
||||
import com.gmail.filoghost.holographicdisplays.object.line.CraftItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
||||
|
||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
|
||||
private boolean lockTick;
|
||||
private CraftItemLine parentPiece;
|
||||
|
||||
public EntityNMSItem(World world, CraftItemLine piece) {
|
||||
super(world);
|
||||
super.pickupDelay = Integer.MAX_VALUE;
|
||||
this.parentPiece = piece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void l_() {
|
||||
// Checks every 20 ticks.
|
||||
if (ticksLived % 20 == 0) {
|
||||
// The item dies without a vehicle.
|
||||
if (this.vehicle == null) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if (!lockTick) {
|
||||
super.l_();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
// Dirty method to check if the icon is being picked up
|
||||
StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace();
|
||||
if (stacktrace.length > 2 && stacktrace[2].getClassName().contains("EntityInsentient")) {
|
||||
return null; // Try to pickup this, dear entity ignoring the pickupDelay!
|
||||
}
|
||||
|
||||
return super.getItemStack();
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void b_(EntityHuman human) {
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
MainListener.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable() {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockTick(boolean lock) {
|
||||
lockTick = lock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
setLockTick(false);
|
||||
super.die();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
this.bukkitEntity = new CraftNMSItem(this.world.getServer(), this);
|
||||
}
|
||||
return this.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return this.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
die();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
||||
ItemStack newItem = CraftItemStack.asNMSCopy(stack);
|
||||
|
||||
if (newItem == null) {
|
||||
newItem = new ItemStack(Block.BEDROCK);
|
||||
}
|
||||
|
||||
if (newItem.tag == null) {
|
||||
newItem.tag = new NBTTagCompound();
|
||||
}
|
||||
NBTTagCompound display = newItem.tag.getCompound("display");
|
||||
|
||||
if (!newItem.tag.hasKey("display")) {
|
||||
newItem.tag.set("display", display);
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
|
||||
display.set("Lore", tagList);
|
||||
newItem.count = 0;
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
ReflectionUtils.setPrivateField(Entity.class, this, "f", (double) 0.0);
|
||||
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
|
||||
} catch (Exception ex) {
|
||||
DebugHandler.handleDebugException(ex);
|
||||
}
|
||||
|
||||
if (this.vehicle != null) {
|
||||
this.vehicle.passenger = null;
|
||||
}
|
||||
|
||||
this.vehicle = entity;
|
||||
entity.passenger = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
}
|
@ -1,187 +0,0 @@
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
|
||||
|
||||
import net.minecraft.server.v1_6_R3.DamageSource;
|
||||
import net.minecraft.server.v1_6_R3.Entity;
|
||||
import net.minecraft.server.v1_6_R3.EntityDamageSource;
|
||||
import net.minecraft.server.v1_6_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_6_R3.EntitySlime;
|
||||
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_6_R3.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
|
||||
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.object.line.CraftTouchSlimeLine;
|
||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
||||
|
||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
|
||||
private boolean lockTick;
|
||||
private CraftTouchSlimeLine parentPiece;
|
||||
|
||||
public EntityNMSSlime(World world, CraftTouchSlimeLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.boundingBox.a = 0.0;
|
||||
super.boundingBox.b = 0.0;
|
||||
super.boundingBox.c = 0.0;
|
||||
super.boundingBox.d = 0.0;
|
||||
super.boundingBox.e = 0.0;
|
||||
super.boundingBox.f = 0.0;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void l_() {
|
||||
// Checks every 20 ticks.
|
||||
if (ticksLived % 20 == 0) {
|
||||
// The slime dies without a vehicle.
|
||||
if (this.vehicle == null) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if (!lockTick) {
|
||||
super.l_();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity()));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable() {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeSound(String sound, float volume, float pitch) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockTick(boolean lock) {
|
||||
lockTick = lock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
setLockTick(false);
|
||||
super.die();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
this.bukkitEntity = new CraftNMSSlime(this.world.getServer(), this);
|
||||
}
|
||||
return this.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
die();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftHologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
ReflectionUtils.setPrivateField(Entity.class, this, "f", (double) 0.0);
|
||||
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
|
||||
} catch (Exception ex) {
|
||||
DebugHandler.handleDebugException(ex);
|
||||
}
|
||||
|
||||
if (this.vehicle != null) {
|
||||
this.vehicle.passenger = null;
|
||||
}
|
||||
|
||||
this.vehicle = entity;
|
||||
entity.passenger = this;
|
||||
}
|
||||
}
|
@ -1,168 +0,0 @@
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSWitherSkull;
|
||||
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
||||
|
||||
import net.minecraft.server.v1_6_R3.EntityWitherSkull;
|
||||
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_6_R3.Packet34EntityTeleport;
|
||||
import net.minecraft.server.v1_6_R3.World;
|
||||
import net.minecraft.server.v1_6_R3.EntityPlayer;
|
||||
|
||||
public class EntityNMSWitherSkull extends EntityWitherSkull implements NMSWitherSkull {
|
||||
|
||||
private boolean lockTick;
|
||||
private CraftHologramLine parentPiece;
|
||||
|
||||
private int teleportedRecently;
|
||||
|
||||
public EntityNMSWitherSkull(World world, CraftHologramLine parentPiece) {
|
||||
super(world);
|
||||
super.motX = 0.0;
|
||||
super.motY = 0.0;
|
||||
super.motZ = 0.0;
|
||||
super.dirX = 0.0;
|
||||
super.dirY = 0.0;
|
||||
super.dirZ = 0.0;
|
||||
super.boundingBox.a = 0.0;
|
||||
super.boundingBox.b = 0.0;
|
||||
super.boundingBox.c = 0.0;
|
||||
super.boundingBox.d = 0.0;
|
||||
super.boundingBox.e = 0.0;
|
||||
super.boundingBox.f = 0.0;
|
||||
a(0.0F, 0.0F);
|
||||
this.parentPiece = parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable() {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void l_() {
|
||||
// Fixed the position being modified by random move packets.
|
||||
if (teleportedRecently != -1) {
|
||||
if (teleportedRecently++ > 10) {
|
||||
teleportedRecently = -1;
|
||||
Packet34EntityTeleport teleportPacket = new Packet34EntityTeleport(this);
|
||||
|
||||
for (Object obj : this.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - this.locX) + Utils.square(nmsPlayer.locZ - this.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!lockTick) {
|
||||
super.l_();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeSound(String sound, float f1, float f2) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockTick(boolean lock) {
|
||||
lockTick = lock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
setLockTick(false);
|
||||
super.die();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
this.bukkitEntity = new CraftNMSWitherSkull(this.world.getServer(), this);
|
||||
}
|
||||
return this.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
die();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
|
||||
teleportedRecently = 0;
|
||||
|
||||
// Send a packet near to update the position.
|
||||
Packet34EntityTeleport teleportPacket = new Packet34EntityTeleport(this);
|
||||
|
||||
for (Object obj : this.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - this.locX) + Utils.square(nmsPlayer.locZ - this.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return this.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftHologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.craftbukkit.libs.com.google.gson.stream.JsonWriter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.FancyMessage;
|
||||
|
||||
public class FancyMessageImpl implements FancyMessage {
|
||||
|
||||
private final List<MessagePart> messageParts;
|
||||
|
||||
public FancyMessageImpl(final String firstPartText) {
|
||||
messageParts = new ArrayList<MessagePart>();
|
||||
messageParts.add(new MessagePart(firstPartText));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FancyMessageImpl color(final ChatColor color) {
|
||||
if (!color.isColor()) {
|
||||
throw new IllegalArgumentException(color.name() + " is not a color");
|
||||
}
|
||||
latest().color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FancyMessageImpl style(final ChatColor... styles) {
|
||||
for (final ChatColor style : styles) {
|
||||
if (!style.isFormat()) {
|
||||
throw new IllegalArgumentException(style.name() + " is not a style");
|
||||
}
|
||||
}
|
||||
latest().styles = styles;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FancyMessageImpl file(final String path) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FancyMessageImpl link(final String url) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FancyMessageImpl suggest(final String command) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FancyMessageImpl command(final String command) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FancyMessageImpl tooltip(final String text) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FancyMessageImpl then(final Object obj) {
|
||||
messageParts.add(new MessagePart(obj.toString()));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJSONString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (MessagePart part : messageParts) {
|
||||
if (part.color != null) {
|
||||
sb.append(part.color.toString());
|
||||
}
|
||||
if (part.styles != null && part.styles.length > 0) {
|
||||
for (ChatColor style : part.styles) {
|
||||
sb.append(style.toString());
|
||||
}
|
||||
}
|
||||
sb.append(part.text);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Player player) {
|
||||
player.sendMessage(toJSONString());
|
||||
}
|
||||
|
||||
private MessagePart latest() {
|
||||
return messageParts.get(messageParts.size() - 1);
|
||||
}
|
||||
|
||||
static class MessagePart {
|
||||
|
||||
public ChatColor color = null;
|
||||
public ChatColor[] styles = null;
|
||||
public String clickActionName = null;
|
||||
public String clickActionData = null;
|
||||
public String hoverActionName = null;
|
||||
public String hoverActionData = null;
|
||||
public final String text;
|
||||
|
||||
public MessagePart(final String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public JsonWriter writeJson(final JsonWriter json) throws IOException {
|
||||
json.beginObject().name("text").value(text);
|
||||
if (color != null) {
|
||||
json.name("color").value(color.name().toLowerCase());
|
||||
}
|
||||
if (styles != null) {
|
||||
for (final ChatColor style : styles) {
|
||||
json.name(style == ChatColor.UNDERLINE ? "underlined" : style.name().toLowerCase()).value(true);
|
||||
}
|
||||
}
|
||||
if (clickActionName != null && clickActionData != null) {
|
||||
json.name("clickEvent")
|
||||
.beginObject()
|
||||
.name("action").value(clickActionName)
|
||||
.name("value").value(clickActionData)
|
||||
.endObject();
|
||||
}
|
||||
if (hoverActionName != null && hoverActionData != null) {
|
||||
json.name("hoverEvent")
|
||||
.beginObject()
|
||||
.name("action").value(hoverActionName)
|
||||
.name("value").value(hoverActionData)
|
||||
.endObject();
|
||||
}
|
||||
return json.endObject();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,168 +0,0 @@
|
||||
package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.server.v1_6_R3.Entity;
|
||||
import net.minecraft.server.v1_6_R3.EntityTypes;
|
||||
import net.minecraft.server.v1_6_R3.World;
|
||||
import net.minecraft.server.v1_6_R3.WorldServer;
|
||||
import net.minecraft.server.v1_6_R3.MathHelper;
|
||||
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.FancyMessage;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.NMSManager;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSHorse;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSWitherSkull;
|
||||
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
|
||||
import com.gmail.filoghost.holographicdisplays.object.line.CraftItemLine;
|
||||
import com.gmail.filoghost.holographicdisplays.object.line.CraftTouchSlimeLine;
|
||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
||||
|
||||
public class NmsManagerImpl implements NMSManager {
|
||||
|
||||
private Method validateEntityMethod;
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
registerCustomEntity(EntityNMSHorse.class, "EntityHorse", 100);
|
||||
registerCustomEntity(EntityNMSWitherSkull.class, "WitherSkull", 19);
|
||||
registerCustomEntity(EntityNMSItem.class, "Item", 1);
|
||||
registerCustomEntity(EntityNMSSlime.class, "Slime", 55);
|
||||
|
||||
if (!VersionUtils.isMCPCOrCauldron()) {
|
||||
validateEntityMethod = World.class.getDeclaredMethod("a", Entity.class);
|
||||
validateEntityMethod.setAccessible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void registerCustomEntity(Class entityClass, String name, int id) throws Exception {
|
||||
if (VersionUtils.isMCPCOrCauldron()) {
|
||||
// MCPC+ / Cauldron entity registration.
|
||||
Class<?> entityTypesClass = Class.forName("net.minecraft.server.v1_6_R3.EntityTypes");
|
||||
ReflectionUtils.putInPrivateStaticMap(entityTypesClass, "field_75626_c", entityClass, name);
|
||||
ReflectionUtils.putInPrivateStaticMap(entityTypesClass, "field_75624_e", entityClass, Integer.valueOf(id));
|
||||
} else {
|
||||
// Normal entity registration.
|
||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "c", entityClass, name);
|
||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "e", entityClass, Integer.valueOf(id));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSHorse spawnNMSHorse(org.bukkit.World world, double x, double y, double z, CraftHologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSHorse invisibleHorse = new EntityNMSHorse(nmsWorld, parentPiece);
|
||||
invisibleHorse.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, invisibleHorse)) {
|
||||
DebugHandler.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return invisibleHorse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSWitherSkull spawnNMSWitherSkull(org.bukkit.World bukkitWorld, double x, double y, double z, CraftHologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSWitherSkull staticWitherSkull = new EntityNMSWitherSkull(nmsWorld, parentPiece);
|
||||
staticWitherSkull.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, staticWitherSkull)) {
|
||||
DebugHandler.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return staticWitherSkull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, CraftItemLine parentPiece, ItemStack stack) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece);
|
||||
customItem.setLocationNMS(x, y, z);
|
||||
customItem.setItemStackNMS(stack);
|
||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||
DebugHandler.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return customItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, CraftTouchSlimeLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||
touchSlime.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||
DebugHandler.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return touchSlime;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||
|
||||
if (validateEntityMethod == null) {
|
||||
return nmsWorld.addEntity(nmsEntity, SpawnReason.CUSTOM);
|
||||
}
|
||||
|
||||
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
||||
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
||||
|
||||
if (!nmsWorld.chunkProviderServer.isChunkLoaded(chunkX, chunkZ)) {
|
||||
// This should never happen
|
||||
nmsEntity.dead = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
|
||||
nmsWorld.entityList.add(nmsEntity);
|
||||
|
||||
try {
|
||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FancyMessage newFancyMessage(String text) {
|
||||
return new FancyMessageImpl(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChatHoverFeature() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, CraftHologramLine parentPiece) {
|
||||
throw new NotImplementedException("Method can only be used on 1.8 or higher");
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ public class BungeeCleanupTask implements Runnable {
|
||||
if (lastRequest != 0 && System.currentTimeMillis() - lastRequest > 600000) { // 10 * 60 * 1000 = 10 minutes.
|
||||
// Don't track that server anymore.
|
||||
iter.remove();
|
||||
DebugHandler.logToConsole("Untracked bungee server \"" + next.getKey() + "\" due to inactivity.");
|
||||
DebugHandler.logToConsole("Removed bungee server \"" + next.getKey() + "\" from tracking due to inactivity.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user