Remove trailing whitespace

This commit is contained in:
filoghost 2021-06-20 17:23:48 +02:00
parent 860d586750
commit ae07fe0bb5
294 changed files with 2293 additions and 2293 deletions

View File

@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable;
* @since 1
*/
public interface Hologram {
/**
* Appends a text line to end of this hologram.
*
@ -31,8 +31,8 @@ public interface Hologram {
* @since 1
*/
@NotNull TextLine appendTextLine(@Nullable String text);
/**
* Appends an item line to end of this hologram.
*
@ -41,8 +41,8 @@ public interface Hologram {
* @since 1
*/
@NotNull ItemLine appendItemLine(@NotNull ItemStack itemStack);
/**
* Inserts a text line in this hologram.
*
@ -53,8 +53,8 @@ public interface Hologram {
* @since 1
*/
@NotNull TextLine insertTextLine(int index, @Nullable String text);
/**
* Inserts an item line in this hologram.
*
@ -65,8 +65,8 @@ public interface Hologram {
* @since 1
*/
@NotNull ItemLine insertItemLine(int index, @NotNull ItemStack itemStack);
/**
* Finds the element at a given index in the lines.
*
@ -76,7 +76,7 @@ public interface Hologram {
* @since 1
*/
@NotNull HologramLine getLine(int index);
/**
* Removes a line at a given index. Since: v2.0.1
*
@ -85,8 +85,8 @@ public interface Hologram {
* @since 1
*/
void removeLine(int index);
/**
* Removes all the lines from this hologram.
*
@ -94,7 +94,7 @@ public interface Hologram {
*/
void clearLines();
/**
* Checks the amount of lines of the hologram.
*
@ -102,8 +102,8 @@ public interface Hologram {
* @since 1
*/
int getLineCount();
/**
* The physical height of the hologram, counting all the lines. Since: v2.1.4
*
@ -111,8 +111,8 @@ public interface Hologram {
* @since 1
*/
double getHeight();
/**
* Teleports a hologram to the given location.
*
@ -120,8 +120,8 @@ public interface Hologram {
* @since 1
*/
void teleport(@NotNull Location location);
/**
* Teleports a hologram to the given location.
*
@ -132,7 +132,7 @@ public interface Hologram {
* @since 1
*/
void teleport(@NotNull World world, double x, double y, double z);
/**
* Returns the position of the hologram.
*
@ -140,7 +140,7 @@ public interface Hologram {
* @since 1
*/
@NotNull Location getLocation();
/**
* Returns the X coordinate.
*
@ -148,8 +148,8 @@ public interface Hologram {
* @since 1
*/
double getX();
/**
* Returns the Y coordinate.
*
@ -157,8 +157,8 @@ public interface Hologram {
* @since 1
*/
double getY();
/**
* Returns the Z coordinate.
*
@ -166,8 +166,8 @@ public interface Hologram {
* @since 1
*/
double getZ();
/**
* Returns the world.
*
@ -175,8 +175,8 @@ public interface Hologram {
* @since 1
*/
@NotNull World getWorld();
/**
* Returns the {@link VisibilitySettings} of this hologram.
* <br><b style = "color: red">Note</b>: the usage of the VisibilitySettings requires ProtocolLib.
@ -186,8 +186,8 @@ public interface Hologram {
* @since 1
*/
@NotNull VisibilitySettings getVisibilitySettings();
/**
* Returns when the hologram was created. Useful for removing old holograms.
*
@ -213,7 +213,7 @@ public interface Hologram {
* @since 1
*/
void setAllowPlaceholders(boolean allowPlaceholders);
/**
* Deletes this hologram. Editing or teleporting the hologram when deleted
* will throw an exception. Lines will be automatically cleared.
@ -222,8 +222,8 @@ public interface Hologram {
* @since 1
*/
void delete();
/**
* Checks if a hologram was deleted.
*
@ -231,5 +231,5 @@ public interface Hologram {
* @since 1
*/
boolean isDeleted();
}

View File

@ -39,7 +39,7 @@ public interface HolographicDisplaysAPI {
static int getVersion() {
return 1;
}
static @NotNull HolographicDisplaysAPI get(@NotNull Plugin plugin) {
return HolographicDisplaysAPIProvider.getImplementation().getHolographicDisplaysAPI(plugin);
}
@ -70,7 +70,7 @@ public interface HolographicDisplaysAPI {
* @since 1
*/
boolean isRegisteredPlaceholder(@NotNull String identifier);
/**
* Returns all the registered placeholder identifiers.
*

View File

@ -36,7 +36,7 @@ public interface VisibilitySettings {
* @since 1
*/
void setDefaultVisibility(@NotNull Visibility defaultVisibility);
/**
* Sets the visibility for a specific player, overriding the default value ({@link #getDefaultVisibility()}).
* The individual visibility value can be reverted with {@link #resetIndividualVisibility(Player)}.
@ -58,7 +58,7 @@ public interface VisibilitySettings {
* @since 1
*/
void resetIndividualVisibilityAll();
/**
* Checks if a hologram is visible to a player, taking into account the individual visibility for the specific
* player and the default visibility.
@ -74,10 +74,10 @@ public interface VisibilitySettings {
* The available statuses for the visibility of a hologram.
*/
enum Visibility {
VISIBLE,
HIDDEN
}
}

View File

@ -22,5 +22,5 @@ public interface PickupHandler {
* @since 1
*/
void onPickup(@NotNull Player player);
}

View File

@ -22,5 +22,5 @@ public interface TouchHandler {
* @since 1
*/
void onTouch(@NotNull Player player);
}

View File

@ -14,23 +14,23 @@ import org.jetbrains.annotations.ApiStatus.Internal;
public abstract class HolographicDisplaysAPIProvider {
public static final String ERROR_IMPLEMENTATION_NOT_SET = "Holographic Displays did not load properly (no API implementation was set)";
private static HolographicDisplaysAPIProvider implementation;
public static void setImplementation(HolographicDisplaysAPIProvider implementation) {
HolographicDisplaysAPIProvider.implementation = implementation;
}
public static HolographicDisplaysAPIProvider getImplementation() {
if (implementation == null) {
throw new IllegalStateException(ERROR_IMPLEMENTATION_NOT_SET);
}
return implementation;
}
public abstract HolographicDisplaysAPI getHolographicDisplaysAPI(Plugin plugin);
public abstract boolean isHologramEntity(Entity entity);
}

View File

@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable;
* @since 1
*/
public interface CollectableLine extends HologramLine {
/**
* Sets the PickupHandler for this line.
*
@ -22,7 +22,7 @@ public interface CollectableLine extends HologramLine {
* @since 1
*/
void setPickupHandler(@Nullable PickupHandler pickupHandler);
/**
* Returns the current PickupHandler of this line.
*
@ -30,5 +30,5 @@ public interface CollectableLine extends HologramLine {
* @since 1
*/
@Nullable PickupHandler getPickupHandler();
}

View File

@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull;
* @since 1
*/
public interface HologramLine {
/**
* Returns the parent Hologram of this line.
*
@ -22,7 +22,7 @@ public interface HologramLine {
* @since 1
*/
@NotNull Hologram getParent();
/**
* Removes this line from the parent Hologram. Since: v2.0.1
* Do not call if the Hologram has been deleted, an exception will be thrown.

View File

@ -28,5 +28,5 @@ public interface ItemLine extends CollectableLine, TouchableLine {
* @since 1
*/
void setItemStack(@NotNull ItemStack itemStack);
}

View File

@ -19,7 +19,7 @@ public interface TextLine extends TouchableLine {
* @since 1
*/
@Nullable String getText();
/**
* Sets the text of this TextLine.
*
@ -27,5 +27,5 @@ public interface TextLine extends TouchableLine {
* @since 1
*/
void setText(@Nullable String text);
}

View File

@ -22,7 +22,7 @@ public interface TouchableLine extends HologramLine {
* @since 1
*/
void setTouchHandler(@Nullable TouchHandler touchHandler);
/**
* Returns the current TouchHandler of this line.
*
@ -30,5 +30,5 @@ public interface TouchableLine extends HologramLine {
* @since 1
*/
@Nullable TouchHandler getTouchHandler();
}

View File

@ -16,5 +16,5 @@ public interface IndividualPlaceholderFactory {
* @since 1
*/
@Nullable IndividualPlaceholder getPlaceholder(@Nullable String argument);
}

View File

@ -16,5 +16,5 @@ public interface PlaceholderFactory {
* @since 1
*/
@Nullable Placeholder getPlaceholder(@Nullable String argument);
}

View File

@ -10,7 +10,7 @@ import me.filoghost.holographicdisplays.common.hologram.StandardHologramLine;
import me.filoghost.holographicdisplays.common.nms.SpawnFailedException;
public class DebugLogger {
private static boolean debug;
private static final String PREFIX = "[Debug] ";
@ -27,7 +27,7 @@ public class DebugLogger {
Log.info(PREFIX + msg, thrown);
}
}
public static void warning(String msg) {
warning(msg, null);
}
@ -37,7 +37,7 @@ public class DebugLogger {
Log.warning(PREFIX + msg, thrown);
}
}
public static void severe(String msg) {
severe(msg, null);
}
@ -47,7 +47,7 @@ public class DebugLogger {
Log.severe(PREFIX + msg, thrown);
}
}
public static void handleSpawnFail(SpawnFailedException exception, StandardHologramLine parentHologramLine) {
severe("Couldn't spawn entity for this hologram: " + parentHologramLine.getHologram(), exception);
}

View File

@ -12,7 +12,7 @@ public class Utils {
public static double distanceSquared(double locX1, double locX2, double locZ1, double locZ2) {
return square(locX1 - locX2) + square(locZ1 - locZ2);
}
public static double square(double num) {
return num * num;
}
@ -20,12 +20,12 @@ public class Utils {
public static String formatExceptionMessage(Throwable t) {
return formatExceptionMessage(t.getMessage());
}
public static String formatExceptionMessage(String message) {
if (Strings.isEmpty(message)) {
return message;
}
message = Strings.capitalizeFirst(message);
char lastChar = message.charAt(message.length() - 1);
if (Character.isLetterOrDigit(lastChar)) {

View File

@ -13,13 +13,13 @@ import org.bukkit.plugin.Plugin;
import java.util.List;
public interface StandardHologram {
World getWorld();
double getX();
double getY();
double getZ();
boolean isInChunk(Chunk chunk);

View File

@ -16,23 +16,23 @@ import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
public interface NMSManager {
/**
* Register all the custom entities of the plugin.
*
* @throws Exception if anything during the process fails
*/
void setup() throws Exception;
NMSArmorStand spawnNMSArmorStand(World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine)
throws SpawnFailedException;
NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack)
throws SpawnFailedException;
NMSSlime spawnNMSSlime(World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine)
throws SpawnFailedException;
boolean isNMSEntityBase(Entity bukkitEntity);
NMSEntity getNMSEntityBase(Entity bukkitEntity);

View File

@ -12,19 +12,19 @@ import org.bukkit.entity.Player;
* A custom entity that is part of a hologram.
*/
public interface NMSEntity {
StandardHologramLine getHologramLine();
void setLocationNMS(double x, double y, double z);
boolean isDeadNMS();
void killEntityNMS();
int getIdNMS();
org.bukkit.entity.Entity getBukkitEntityNMS();
boolean isTrackedBy(Player bukkitPlayer);
}

View File

@ -8,12 +8,12 @@ package me.filoghost.holographicdisplays.common.nms.entity;
import org.bukkit.inventory.ItemStack;
public interface NMSItem extends NMSEntity {
void setItemStackNMS(ItemStack stack);
/**
* Returns the item stack NMS object.
*/
Object getRawItemStack();
}

View File

@ -6,5 +6,5 @@
package me.filoghost.holographicdisplays.common.nms.entity;
public interface NMSSlime extends NMSEntity {
}

View File

@ -8,5 +8,5 @@ package me.filoghost.holographicdisplays.common.nms.entity;
public interface NMSVehicle extends NMSEntity {
void setPassengerNMS(NMSEntity passenger);
}

View File

@ -11,5 +11,5 @@
<artifactId>holographicdisplays-example-deathholograms</artifactId>
<name>HolographicDisplays Example DeathHolograms</name>
</project>

View File

@ -20,7 +20,7 @@ import java.time.format.DateTimeFormatter;
public class DeathHolograms extends JavaPlugin implements Listener {
private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("H:mm");
private HolographicDisplaysAPI holographicDisplaysAPI;
@Override
@ -31,18 +31,18 @@ public class DeathHolograms extends JavaPlugin implements Listener {
this.setEnabled(false);
return;
}
holographicDisplaysAPI = HolographicDisplaysAPI.get(this);
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
Hologram hologram = holographicDisplaysAPI.createHologram(event.getEntity().getEyeLocation());
hologram.appendTextLine(ChatColor.RED + "Player " + ChatColor.GOLD + event.getEntity().getName() + ChatColor.RED + " died here!");
hologram.appendTextLine(ChatColor.GRAY + "Time of death: " + TIME_FORMATTER.format(Instant.now()));
}
}

View File

@ -17,13 +17,13 @@
<module>death-holograms</module>
<module>power-ups</module>
</modules>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>holographicdisplays-api</artifactId>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>

View File

@ -38,31 +38,31 @@ public class PowerUps extends JavaPlugin implements Listener {
holographicDisplaysAPI = HolographicDisplaysAPI.get(this);
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
if (event.getEntityType() == EntityType.ZOMBIE) {
// Remove normal drops and exp
event.getDrops().clear();
event.setDroppedExp(0);
// Spawn the floating item with a label
Hologram hologram = holographicDisplaysAPI.createHologram(event.getEntity().getLocation().add(0.0, 0.9, 0.0));
hologram.appendTextLine(ChatColor.AQUA + "" + ChatColor.BOLD + "Speed PowerUp");
ItemLine icon = hologram.appendItemLine(new ItemStack(Material.SUGAR));
icon.setPickupHandler((Player player) -> {
// Play an effect
player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null);
// 30 seconds of speed II
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 1), true);
// Delete the hologram
hologram.delete();
});
}
}
}

View File

@ -23,7 +23,7 @@
<groupId>${project.groupId}</groupId>
<artifactId>holographicdisplays-api</artifactId>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>

View File

@ -11,5 +11,5 @@
<artifactId>holographicdisplays-legacy-api-v1</artifactId>
<name>HolographicDisplays Legacy API v1</name>
</project>

View File

@ -53,7 +53,7 @@ public interface FloatingItem {
@Deprecated
boolean hasTouchHandler();
@Deprecated
void setPickupHandler(PickupHandler handler);
@ -71,5 +71,5 @@ public interface FloatingItem {
@Deprecated
boolean isDeleted();
}

View File

@ -19,7 +19,7 @@ public interface Hologram {
@Deprecated
void hide();
@Deprecated
void addLine(String text);
@ -34,40 +34,40 @@ public interface Hologram {
@Deprecated
String[] getLines();
@Deprecated
int getLinesLength();
@Deprecated
void clearLines();
@Deprecated
Location getLocation();
@Deprecated
double getX();
@Deprecated
double getY();
@Deprecated
double getZ();
@Deprecated
World getWorld();
@Deprecated
void setLocation(Location location);
@Deprecated
void teleport(Location location);
@Deprecated
void setTouchHandler(TouchHandler handler);
@Deprecated
TouchHandler getTouchHandler();
@Deprecated
boolean hasTouchHandler();
@ -79,5 +79,5 @@ public interface Hologram {
@Deprecated
boolean isDeleted();
}

View File

@ -24,7 +24,7 @@ import java.util.Set;
public class HolographicDisplaysAPI {
private static final Set<String> notifiedPlugins = new HashSet<>();
@Deprecated
public static Hologram createHologram(Plugin plugin, Location source, String... lines) {
throw removedAPIException(plugin);
@ -39,22 +39,22 @@ public class HolographicDisplaysAPI {
public static Hologram createIndividualHologram(Plugin plugin, Location source, Player whoCanSee, String... lines) {
throw removedAPIException(plugin);
}
@Deprecated
public static Hologram createIndividualHologram(Plugin plugin, Location source, List<Player> whoCanSee, String... lines) {
throw removedAPIException(plugin);
}
@Deprecated
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, Player whoCanSee, ItemStack itemstack) {
throw removedAPIException(plugin);
}
@Deprecated
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, List<Player> whoCanSee, ItemStack itemstack) {
throw removedAPIException(plugin);
}
@Deprecated
public static Hologram[] getHolograms(Plugin plugin) {
throw removedAPIException(plugin);
@ -64,7 +64,7 @@ public class HolographicDisplaysAPI {
public static FloatingItem[] getFloatingItems(Plugin plugin) {
throw removedAPIException(plugin);
}
private static RuntimeException removedAPIException(Plugin plugin) {
if (plugin != null && notifiedPlugins.add(plugin.getName())) {
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Holographic Displays] The plugin \""

View File

@ -15,5 +15,5 @@ public interface ItemTouchHandler {
@Deprecated
void onTouch(FloatingItem floatingItem, Player player);
}

View File

@ -15,5 +15,5 @@ public interface PickupHandler {
@Deprecated
void onPickup(FloatingItem floatingItem, Player player);
}

View File

@ -15,5 +15,5 @@ public interface TouchHandler {
@Deprecated
void onTouch(Hologram hologram, Player player);
}

View File

@ -23,7 +23,7 @@ public interface Hologram {
@Deprecated
ItemLine appendItemLine(ItemStack itemStack);
@Deprecated
TextLine insertTextLine(int index, String text);
@ -32,7 +32,7 @@ public interface Hologram {
@Deprecated
HologramLine getLine(int index);
@Deprecated
void removeLine(int index);
@ -47,13 +47,13 @@ public interface Hologram {
@Deprecated
void teleport(Location location);
@Deprecated
void teleport(World world, double x, double y, double z);
@Deprecated
Location getLocation();
@Deprecated
double getX();
@ -62,7 +62,7 @@ public interface Hologram {
@Deprecated
double getZ();
@Deprecated
World getWorld();
@ -77,11 +77,11 @@ public interface Hologram {
@Deprecated
void setAllowPlaceholders(boolean allowPlaceholders);
@Deprecated
void delete();
@Deprecated
boolean isDeleted();
}

View File

@ -35,7 +35,7 @@ public class HologramsAPI {
public static boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer) {
return HologramsAPIProvider.getImplementation().registerPlaceholder(plugin, textPlaceholder, refreshRate, replacer);
}
@Deprecated
public static Collection<String> getRegisteredPlaceholders(Plugin plugin) {
return HologramsAPIProvider.getImplementation().getRegisteredPlaceholders(plugin);
@ -45,7 +45,7 @@ public class HologramsAPI {
public static boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder) {
return HologramsAPIProvider.getImplementation().unregisterPlaceholder(plugin, textPlaceholder);
}
@Deprecated
public static void unregisterPlaceholders(Plugin plugin) {
HologramsAPIProvider.getImplementation().unregisterPlaceholders(plugin);

View File

@ -15,23 +15,23 @@ public interface VisibilityManager {
@Deprecated
boolean isVisibleByDefault();
@Deprecated
void setVisibleByDefault(boolean visibleByDefault);
@Deprecated
void showTo(Player player);
@Deprecated
void hideTo(Player player);
@Deprecated
boolean isVisibleTo(Player player);
@Deprecated
void resetVisibility(Player player);
@Deprecated
void resetVisibilityAll();
}

View File

@ -15,5 +15,5 @@ public interface PickupHandler {
@Deprecated
void onPickup(Player player);
}

View File

@ -15,5 +15,5 @@ public interface TouchHandler {
@Deprecated
void onTouch(Player player);
}

View File

@ -21,7 +21,7 @@ import java.util.Collection;
@Deprecated
@Internal
public abstract class HologramsAPIProvider {
private static HologramsAPIProvider implementation;
@Deprecated
@ -34,7 +34,7 @@ public abstract class HologramsAPIProvider {
if (implementation == null) {
throw new IllegalStateException(HolographicDisplaysAPIProvider.ERROR_IMPLEMENTATION_NOT_SET);
}
return implementation;
}

View File

@ -15,8 +15,8 @@ public interface CollectableLine extends HologramLine {
@Deprecated
void setPickupHandler(PickupHandler pickupHandler);
@Deprecated
PickupHandler getPickupHandler();
}

View File

@ -15,7 +15,7 @@ public interface HologramLine {
@Deprecated
Hologram getParent();
@Deprecated
void removeLine();

View File

@ -18,5 +18,5 @@ public interface ItemLine extends CollectableLine, TouchableLine {
@Deprecated
void setItemStack(ItemStack itemStack);
}

View File

@ -13,8 +13,8 @@ public interface TextLine extends TouchableLine {
@Deprecated
String getText();
@Deprecated
void setText(String text);
}

View File

@ -15,8 +15,8 @@ public interface TouchableLine extends HologramLine {
@Deprecated
void setTouchHandler(TouchHandler touchHandler);
@Deprecated
TouchHandler getTouchHandler();
}

View File

@ -13,5 +13,5 @@ public interface PlaceholderReplacer {
@Deprecated
String update();
}

View File

@ -29,7 +29,7 @@
<module>v1_16_r2</module>
<module>v1_16_r3</module>
</modules>
<dependencies>
<dependency>
<groupId>me.filoghost.fcommons</groupId>

View File

@ -17,7 +17,7 @@
<groupId>${project.groupId}</groupId>
<artifactId>holographicdisplays-common</artifactId>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>

View File

@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand {
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
super(server, entity);
}
// Disallow all the bukkit methods
@Override
public void remove() {
// Cannot be removed, this is the most important to override
@ -60,7 +60,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
@Override public void setCollidable(boolean collidable) {}
@Override public void setGliding(boolean gliding) {}
@Override public boolean setLeashHolder(Entity holder) { return false; }
// Methods from Entity
@Override public void setVelocity(Vector vel) {}
@Override public boolean teleport(Location loc) { return false; }
@ -81,5 +81,5 @@ public class CraftNMSArmorStand extends CraftArmorStand {
@Override public void setMomentum(Vector value) {}
@Override public void setSilent(boolean flag) {}
@Override public void setTicksLived(int value) {}
}

View File

@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem {
}
// Disallow all the bukkit methods
@Override
public void remove() {
// Cannot be removed, this is the most important to override
@ -48,9 +48,9 @@ public class CraftNMSItem extends CraftItem {
@Override public void setMomentum(Vector value) {}
@Override public void setSilent(boolean flag) {}
@Override public void setTicksLived(int value) {}
// Methods from Item
@Override public void setItemStack(ItemStack stack) {}
@Override public void setPickupDelay(int delay) {}
}

View File

@ -22,14 +22,14 @@ 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; }
@ -64,5 +64,5 @@ public class CraftNMSSlime extends CraftSlime {
// Methods from Slime
@Override public void setSize(int size) {}
}

View File

@ -40,13 +40,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
private final ProtocolPacketSettings protocolPacketSettings;
private final VersionNMSEntityHelper helper;
private String customName;
public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) {
super(world);
this.parentHologramLine = parentHologramLine;
this.protocolPacketSettings = protocolPacketSettings;
this.helper = new VersionNMSEntityHelper(this);
super.setInvisible(true);
super.setSmall(true);
super.setArms(false);
@ -57,32 +57,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet
forceSetBoundingBox(new NullBoundingBox());
}
@Override
public void m() {
// Disable normal ticking for this entity
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity
if (super.onGround) {
super.onGround = false;
}
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity
if (super.onGround) {
super.onGround = false;
}
}
@Override
public void b(NBTTagCompound nbttagcompound) {
// Do not save NBT
}
@Override
public boolean c(NBTTagCompound nbttagcompound) {
// Do not save NBT
@ -94,23 +94,23 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
// Do not save NBT
return false;
}
@Override
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -120,17 +120,17 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
}
@Override
public void setCustomName(String customName) {
// Prevents changes to custom name
}
@Override
public void setCustomNameVisible(boolean visible) {
// Prevents changes to custom name visibility
@ -152,21 +152,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
// Prevent armor stand from being equipped
}
@Override
public void a(AxisAlignedBB boundingBox) {
// Prevent changes to bounding box
}
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
super.a(boundingBox);
}
@Override
public void a(SoundEffect soundeffect, float f, float f1) {
// Remove sounds
}
@Override
public void setCustomNameNMS(String customName) {
if (Objects.equals(this.customName, customName)) {
@ -180,22 +180,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
protected static String createCustomNameNMSObject(String customName) {
return customName != null ? Strings.truncate(customName, 256) : "";
}
@Override
public String getCustomNameStringNMS() {
return this.customName;
}
@Override
public String getCustomNameObjectNMS() {
return super.getCustomName();
}
@Override
public void die() {
// Prevent entity from dying
}
@Override
public CraftEntity getBukkitEntity() {
if (super.bukkitEntity == null) {
@ -203,12 +203,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
}
return super.bukkitEntity;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
@ -236,7 +236,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public boolean isDeadNMS() {
return super.dead;
}
@Override
public int getIdNMS() {
return super.getId();
@ -246,7 +246,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public StandardHologramLine getHologramLine() {
return parentHologramLine;
}
@Override
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
@ -256,5 +256,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public boolean isTrackedBy(Player bukkitPlayer) {
return helper.isTrackedBy(bukkitPlayer);
}
}

View File

@ -26,27 +26,27 @@ import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
public class EntityNMSItem extends EntityItem implements NMSItem {
private final StandardItemLine parentHologramLine;
private final VersionNMSEntityHelper helper;
private int resendMountPacketTicks;
public EntityNMSItem(World world, StandardItemLine parentHologramLine) {
super(world);
this.parentHologramLine = parentHologramLine;
this.helper = new VersionNMSEntityHelper(this);
super.pickupDelay = Integer.MAX_VALUE;
}
@Override
public void m() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
if (resendMountPacketTicks++ > 20) {
resendMountPacketTicks = 0;
@ -57,15 +57,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
}
}
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
// Method called when a player is near
@Override
public void d(EntityHuman human) {
@ -73,18 +73,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
// Too low or too high, it's a bit weird
return;
}
if (human instanceof EntityPlayer) {
parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity());
// 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
@ -96,23 +96,23 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
// Do not save NBT
return false;
}
@Override
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -122,17 +122,17 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
}
@Override
public void die() {
// Prevent entity from dying
}
@Override
public boolean isAlive() {
// This override prevents items from being picked up by hoppers (should have no side effects)
@ -151,12 +151,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public boolean isDeadNMS() {
return super.dead;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
@ -165,32 +165,32 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
@Override
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
ItemStack newItem = CraftItemStack.asNMSCopy(stack);
if (newItem == null) {
newItem = new ItemStack(Blocks.BEDROCK);
}
if (newItem.getTag() == null) {
newItem.setTag(new NBTTagCompound());
}
NBTTagCompound display = newItem.getTag().getCompound("display");
if (!newItem.getTag().hasKey("display")) {
newItem.getTag().set("display", display);
}
NBTTagList tagList = new NBTTagList();
tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE));
display.set("Lore", tagList);
super.setItemStack(newItem);
}
@Override
public int getIdNMS() {
return super.getId();
}
@Override
public StandardHologramLine getHologramLine() {
return parentHologramLine;
@ -210,5 +210,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public Object getRawItemStack() {
return super.getItemStack();
}
}

View File

@ -23,17 +23,17 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEntityEvent;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private final StandardHologramLine parentHologramLine;
private final VersionNMSEntityHelper helper;
private int resendMountPacketTicks;
public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) {
super(world);
this.parentHologramLine = parentHologramLine;
this.helper = new VersionNMSEntityHelper(this);
super.persistent = true;
super.collides = false;
super.a(0.0F, 0.0F);
@ -41,14 +41,14 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
super.setInvisible(true);
forceSetBoundingBox(new NullBoundingBox());
}
@Override
public void m() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
if (resendMountPacketTicks++ > 20) {
resendMountPacketTicks = 0;
@ -59,29 +59,29 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
}
}
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
@Override
public void a(AxisAlignedBB boundingBox) {
// Prevent changes to bounding box
}
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
super.a(boundingBox);
}
@Override
public void b(NBTTagCompound nbttagcompound) {
// Do not save NBT
}
@Override
public boolean c(NBTTagCompound nbttagcompound) {
// Do not save NBT
@ -93,23 +93,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
// Do not save NBT
return false;
}
@Override
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean damageEntity(DamageSource damageSource, float amount) {
if (damageSource instanceof EntityDamageSource) {
@ -122,7 +122,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
}
return false;
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -132,7 +132,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
@ -142,22 +142,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public void setCustomName(String customName) {
// Prevents changes to custom name
}
@Override
public void setCustomNameVisible(boolean visible) {
// Prevents changes to custom name visibility
}
@Override
public void a(SoundEffect soundeffect, float f, float f1) {
// Remove sounds
}
@Override
public void die() {
// Prevent entity from dying
}
@Override
public CraftEntity getBukkitEntity() {
if (super.bukkitEntity == null) {
@ -170,22 +170,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public boolean isDeadNMS() {
return super.dead;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
}
@Override
public int getIdNMS() {
return super.getId();
}
@Override
public StandardHologramLine getHologramLine() {
return parentHologramLine;

View File

@ -75,7 +75,7 @@ public class NullBoundingBox extends AxisAlignedBB {
public AxisAlignedBB shrink(double arg0) {
return this;
}
@Override
public AxisAlignedBB a(BlockPosition arg0) {
return this;
@ -105,7 +105,7 @@ public class NullBoundingBox extends AxisAlignedBB {
public AxisAlignedBB e(double arg0) {
return this;
}
@Override
public AxisAlignedBB g(double arg0) {
return this;

View File

@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry>
public VersionNMSEntityHelper(Entity entity) {
this.entity = entity;
}
@Override
protected EntityTrackerEntry getTracker0() {
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());
@ -35,7 +35,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry>
return false;
}
}
public void broadcastPacket(Packet<?> packet) {
EntityTrackerEntry tracker = getTracker();
if (tracker != null) {

View File

@ -30,14 +30,14 @@ import org.bukkit.inventory.ItemStack;
import java.util.Map;
public class VersionNMSManager implements NMSManager {
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD
= ReflectField.lookup(new ClassToken<Map<Class<?>, String>>() {}, EntityTypes.class, "d");
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD
= ReflectField.lookup(new ClassToken<Map<Class<?>, Integer>>() {}, EntityTypes.class, "f");
private static final ReflectMethod<?> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class);
private final ProtocolPacketSettings protocolPacketSettings;
public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) {
@ -50,12 +50,12 @@ public class VersionNMSManager implements NMSManager {
registerCustomEntity(EntityNMSItem.class, "Item", 1);
registerCustomEntity(EntityNMSSlime.class, "Slime", 55);
}
public void registerCustomEntity(Class<?> entityClass, String name, int id) throws Exception {
ENTITY_NAMES_BY_CLASS_FIELD.getStatic().put(entityClass, name);
ENTITY_IDS_BY_CLASS_FIELD.getStatic().put(entityClass, id);
}
@Override
public NMSItem spawnNMSItem(
org.bukkit.World bukkitWorld, double x, double y, double z,
@ -68,7 +68,7 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, item);
return item;
}
@Override
public EntityNMSSlime spawnNMSSlime(
org.bukkit.World bukkitWorld, double x, double y, double z,
@ -79,7 +79,7 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, slime);
return slime;
}
@Override
public NMSArmorStand spawnNMSArmorStand(
org.bukkit.World world, double x, double y, double z,
@ -90,22 +90,22 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, armorStand);
return armorStand;
}
private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException {
Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add");
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
// This should never happen
nmsEntity.dead = true;
throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED);
}
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
nmsWorld.entityList.add(nmsEntity);
try {
REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity);
} catch (ReflectiveOperationException e) {
@ -113,7 +113,7 @@ public class VersionNMSManager implements NMSManager {
throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e);
}
}
@Override
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity;
@ -122,19 +122,19 @@ public class VersionNMSManager implements NMSManager {
@Override
public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
if (nmsEntity instanceof NMSEntity) {
return (NMSEntity) nmsEntity;
} else {
return null;
}
}
@Override
public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
Entity nmsEntity = nmsWorld.getEntity(entityID);
if (nmsEntity instanceof NMSEntity) {
return (NMSEntity) nmsEntity;
} else {

View File

@ -17,7 +17,7 @@
<groupId>${project.groupId}</groupId>
<artifactId>holographicdisplays-common</artifactId>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>

View File

@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand {
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
super(server, entity);
}
// Disallow all the bukkit methods
@Override
public void remove() {
// Cannot be removed, this is the most important to override
@ -60,7 +60,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
@Override public void setCollidable(boolean collidable) {}
@Override public void setGliding(boolean gliding) {}
@Override public boolean setLeashHolder(Entity holder) { return false; }
// Methods from Entity
@Override public void setVelocity(Vector vel) {}
@Override public boolean teleport(Location loc) { return false; }
@ -81,5 +81,5 @@ public class CraftNMSArmorStand extends CraftArmorStand {
@Override public void setMomentum(Vector value) {}
@Override public void setSilent(boolean flag) {}
@Override public void setTicksLived(int value) {}
}

View File

@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem {
}
// Disallow all the bukkit methods
@Override
public void remove() {
// Cannot be removed, this is the most important to override
@ -48,9 +48,9 @@ public class CraftNMSItem extends CraftItem {
@Override public void setMomentum(Vector value) {}
@Override public void setSilent(boolean flag) {}
@Override public void setTicksLived(int value) {}
// Methods from Item
@Override public void setItemStack(ItemStack stack) {}
@Override public void setPickupDelay(int delay) {}
}

View File

@ -22,14 +22,14 @@ 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; }
@ -64,5 +64,5 @@ public class CraftNMSSlime extends CraftSlime {
// Methods from Slime
@Override public void setSize(int size) {}
}

View File

@ -40,13 +40,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
private final ProtocolPacketSettings protocolPacketSettings;
private final VersionNMSEntityHelper helper;
private String customName;
public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) {
super(world);
this.parentHologramLine = parentHologramLine;
this.protocolPacketSettings = protocolPacketSettings;
this.helper = new VersionNMSEntityHelper(this);
super.setInvisible(true);
super.setSmall(true);
super.setArms(false);
@ -57,32 +57,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet
forceSetBoundingBox(new NullBoundingBox());
}
@Override
public void A_() {
// Disable normal ticking for this entity
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity
if (super.onGround) {
super.onGround = false;
}
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity
if (super.onGround) {
super.onGround = false;
}
}
@Override
public void b(NBTTagCompound nbttagcompound) {
// Do not save NBT
}
@Override
public boolean c(NBTTagCompound nbttagcompound) {
// Do not save NBT
@ -94,23 +94,23 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
// Do not save NBT
return false;
}
@Override
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -120,17 +120,17 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
}
@Override
public void setCustomName(String customName) {
// Prevents changes to custom name
}
@Override
public void setCustomNameVisible(boolean visible) {
// Prevents changes to custom name visibility
@ -152,21 +152,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
// Prevent armor stand from being equipped
}
@Override
public void a(AxisAlignedBB boundingBox) {
// Prevent changes to bounding box
}
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
super.a(boundingBox);
}
@Override
public void a(SoundEffect soundeffect, float f, float f1) {
// Remove sounds
}
@Override
public void setCustomNameNMS(String customName) {
if (Objects.equals(this.customName, customName)) {
@ -180,22 +180,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
protected static String createCustomNameNMSObject(String customName) {
return customName != null ? Strings.truncate(customName, 256) : "";
}
@Override
public String getCustomNameStringNMS() {
return this.customName;
}
@Override
public String getCustomNameObjectNMS() {
return super.getCustomName();
}
@Override
public void die() {
// Prevent entity from dying
}
@Override
public CraftEntity getBukkitEntity() {
if (super.bukkitEntity == null) {
@ -203,12 +203,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
}
return super.bukkitEntity;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
@ -236,7 +236,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public boolean isDeadNMS() {
return super.dead;
}
@Override
public int getIdNMS() {
return super.getId();
@ -246,7 +246,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public StandardHologramLine getHologramLine() {
return parentHologramLine;
}
@Override
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
@ -256,5 +256,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public boolean isTrackedBy(Player bukkitPlayer) {
return helper.isTrackedBy(bukkitPlayer);
}
}

View File

@ -24,34 +24,34 @@ import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
public class EntityNMSItem extends EntityItem implements NMSItem {
private final StandardItemLine parentHologramLine;
private final VersionNMSEntityHelper helper;
public EntityNMSItem(World world, StandardItemLine parentHologramLine) {
super(world);
this.parentHologramLine = parentHologramLine;
this.helper = new VersionNMSEntityHelper(this);
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
}
@Override
public void A_() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
// Method called when a player is near
@Override
public void d(EntityHuman human) {
@ -59,18 +59,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
// Too low or too high, it's a bit weird
return;
}
if (human instanceof EntityPlayer) {
parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity());
// 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
@ -82,23 +82,23 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
// Do not save NBT
return false;
}
@Override
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -108,17 +108,17 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
}
@Override
public void die() {
// Prevent entity from dying
}
@Override
public boolean isAlive() {
// This override prevents items from being picked up by hoppers (should have no side effects)
@ -137,12 +137,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public boolean isDeadNMS() {
return super.dead;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
@ -151,7 +151,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
@Override
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
ItemStack newItem = CraftItemStack.asNMSCopy(stack);
if (newItem == null || newItem == ItemStack.a) { // ItemStack.a is returned if the stack is not valid
newItem = new ItemStack(Blocks.BEDROCK);
}
@ -167,15 +167,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
NBTTagList tagList = new NBTTagList();
tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE));
display.set("Lore", tagList);
super.setItemStack(newItem);
}
@Override
public int getIdNMS() {
return super.getId();
}
@Override
public StandardHologramLine getHologramLine() {
return parentHologramLine;
@ -190,10 +190,10 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public boolean isTrackedBy(Player bukkitPlayer) {
return helper.isTrackedBy(bukkitPlayer);
}
@Override
public Object getRawItemStack() {
return super.getItemStack();
}
}

View File

@ -21,15 +21,15 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEntityEvent;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private final StandardHologramLine parentHologramLine;
private final VersionNMSEntityHelper helper;
public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) {
super(world);
this.parentHologramLine = parentHologramLine;
this.helper = new VersionNMSEntityHelper(this);
super.persistent = true;
super.collides = false;
super.a(0.0F, 0.0F);
@ -37,37 +37,37 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
super.setInvisible(true);
forceSetBoundingBox(new NullBoundingBox());
}
@Override
public void A_() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
@Override
public void a(AxisAlignedBB boundingBox) {
// Prevent changes to bounding box
}
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
super.a(boundingBox);
}
@Override
public void b(NBTTagCompound nbttagcompound) {
// Do not save NBT
}
@Override
public boolean c(NBTTagCompound nbttagcompound) {
// Do not save NBT
@ -79,23 +79,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
// Do not save NBT
return false;
}
@Override
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean damageEntity(DamageSource damageSource, float amount) {
if (damageSource instanceof EntityDamageSource) {
@ -108,7 +108,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
}
return false;
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -118,7 +118,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
@ -128,22 +128,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public void setCustomName(String customName) {
// Prevents changes to custom name
}
@Override
public void setCustomNameVisible(boolean visible) {
// Prevents changes to custom name visibility
}
@Override
public void a(SoundEffect soundeffect, float f, float f1) {
// Remove sounds
}
@Override
public void die() {
// Prevent entity from dying
}
@Override
public CraftEntity getBukkitEntity() {
if (super.bukkitEntity == null) {
@ -156,22 +156,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public boolean isDeadNMS() {
return super.dead;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
}
@Override
public int getIdNMS() {
return super.getId();
}
@Override
public StandardHologramLine getHologramLine() {
return parentHologramLine;
@ -186,5 +186,5 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public boolean isTrackedBy(Player bukkitPlayer) {
return helper.isTrackedBy(bukkitPlayer);
}
}

View File

@ -60,7 +60,7 @@ public class NullBoundingBox extends AxisAlignedBB {
public AxisAlignedBB shrink(double arg0) {
return this;
}
@Override
public AxisAlignedBB a(BlockPosition arg0) {
return this;
@ -90,7 +90,7 @@ public class NullBoundingBox extends AxisAlignedBB {
public AxisAlignedBB e(double arg0) {
return this;
}
@Override
public AxisAlignedBB g(double arg0) {
return this;

View File

@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry>
public VersionNMSEntityHelper(Entity entity) {
this.entity = entity;
}
@Override
protected EntityTrackerEntry getTracker0() {
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());

View File

@ -30,7 +30,7 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.inventory.ItemStack;
public class VersionNMSManager implements NMSManager {
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD
= ReflectField.lookup(new ClassToken<RegistryID<Class<? extends Entity>>>() {}, RegistryMaterials.class, "a");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD
@ -43,17 +43,17 @@ public class VersionNMSManager implements NMSManager {
public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) {
this.protocolPacketSettings = protocolPacketSettings;
}
@Override
public void setup() throws Exception {
registerCustomEntity(EntityNMSSlime.class, 55);
}
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
// Use reflection to get the RegistryID of entities
RegistryID<Class<? extends Entity>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b);
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
// Save the the ID -> entity class mapping before the registration
Object oldValue = idToClassMap[id];
@ -63,7 +63,7 @@ public class VersionNMSManager implements NMSManager {
// Restore the ID -> entity class mapping
idToClassMap[id] = oldValue;
}
@Override
public NMSItem spawnNMSItem(
org.bukkit.World bukkitWorld, double x, double y, double z,
@ -76,7 +76,7 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, item);
return item;
}
@Override
public EntityNMSSlime spawnNMSSlime(
org.bukkit.World bukkitWorld, double x, double y, double z,
@ -87,7 +87,7 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, slime);
return slime;
}
@Override
public NMSArmorStand spawnNMSArmorStand(
org.bukkit.World world, double x, double y, double z,
@ -98,22 +98,22 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, armorStand);
return armorStand;
}
private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException {
Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add");
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
// This should never happen
nmsEntity.dead = true;
throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED);
}
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
nmsWorld.entityList.add(nmsEntity);
try {
REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity);
} catch (ReflectiveOperationException e) {
@ -121,7 +121,7 @@ public class VersionNMSManager implements NMSManager {
throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e);
}
}
@Override
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity;
@ -130,19 +130,19 @@ public class VersionNMSManager implements NMSManager {
@Override
public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
if (nmsEntity instanceof NMSEntity) {
return (NMSEntity) nmsEntity;
} else {
return null;
}
}
@Override
public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
Entity nmsEntity = nmsWorld.getEntity(entityID);
if (nmsEntity instanceof NMSEntity) {
return (NMSEntity) nmsEntity;
} else {

View File

@ -17,7 +17,7 @@
<groupId>${project.groupId}</groupId>
<artifactId>holographicdisplays-common</artifactId>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>

View File

@ -24,16 +24,16 @@ public class CraftNMSArmorStand extends CraftArmorStand {
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand 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 ArmorStand class
@Override public void setArms(boolean arms) {}
@Override public void setBasePlate(boolean basePlate) {}
@Override public void setBodyPose(EulerAngle pose) {}
@ -61,7 +61,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
@Override public void setCollidable(boolean collidable) {}
@Override public void setGliding(boolean gliding) {}
@Override public boolean setLeashHolder(Entity holder) { return false; }
// Methods from Entity
@Override public void setVelocity(Vector vel) {}
@Override public boolean teleport(Location loc) { return false; }
@ -82,5 +82,5 @@ public class CraftNMSArmorStand extends CraftArmorStand {
@Override public void setMomentum(Vector value) {}
@Override public void setSilent(boolean flag) {}
@Override public void setTicksLived(int value) {}
}

View File

@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem {
}
// Disallow all the bukkit methods
@Override
public void remove() {
// Cannot be removed, this is the most important to override
@ -48,9 +48,9 @@ public class CraftNMSItem extends CraftItem {
@Override public void setMomentum(Vector value) {}
@Override public void setSilent(boolean flag) {}
@Override public void setTicksLived(int value) {}
// Methods from Item
@Override public void setItemStack(ItemStack stack) {}
@Override public void setPickupDelay(int delay) {}
}

View File

@ -22,14 +22,14 @@ 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; }
@ -64,5 +64,5 @@ public class CraftNMSSlime extends CraftSlime {
// Methods from Slime
@Override public void setSize(int size) {}
}

View File

@ -40,13 +40,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
private final ProtocolPacketSettings protocolPacketSettings;
private final VersionNMSEntityHelper helper;
private String customName;
public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) {
super(world);
this.parentHologramLine = parentHologramLine;
this.protocolPacketSettings = protocolPacketSettings;
this.helper = new VersionNMSEntityHelper(this);
super.setInvisible(true);
super.setSmall(true);
super.setArms(false);
@ -57,32 +57,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet
forceSetBoundingBox(new NullBoundingBox());
}
@Override
public void B_() {
// Disable normal ticking for this entity
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity
if (super.onGround) {
super.onGround = false;
}
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity
if (super.onGround) {
super.onGround = false;
}
}
@Override
public void b(NBTTagCompound nbttagcompound) {
// Do not save NBT
}
@Override
public boolean c(NBTTagCompound nbttagcompound) {
// Do not save NBT
@ -94,23 +94,23 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
// Do not save NBT
return false;
}
@Override
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -120,17 +120,17 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
}
@Override
public void setCustomName(String customName) {
// Prevents changes to custom name
}
@Override
public void setCustomNameVisible(boolean visible) {
// Prevents changes to custom name visibility
@ -152,21 +152,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
// Prevent armor stand from being equipped
}
@Override
public void a(AxisAlignedBB boundingBox) {
// Prevent changes to bounding box
}
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
super.a(boundingBox);
}
@Override
public void a(SoundEffect soundeffect, float f, float f1) {
// Remove sounds
}
@Override
public void setCustomNameNMS(String customName) {
if (Objects.equals(this.customName, customName)) {
@ -180,22 +180,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
protected static String createCustomNameNMSObject(String customName) {
return customName != null ? Strings.truncate(customName, 256) : "";
}
@Override
public String getCustomNameStringNMS() {
return this.customName;
}
@Override
public String getCustomNameObjectNMS() {
return super.getCustomName();
}
@Override
public void die() {
// Prevent entity from dying
}
@Override
public CraftEntity getBukkitEntity() {
if (super.bukkitEntity == null) {
@ -203,12 +203,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
}
return super.bukkitEntity;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
@ -236,7 +236,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public boolean isDeadNMS() {
return super.dead;
}
@Override
public int getIdNMS() {
return super.getId();
@ -246,7 +246,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public StandardHologramLine getHologramLine() {
return parentHologramLine;
}
@Override
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
@ -256,5 +256,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public boolean isTrackedBy(Player bukkitPlayer) {
return helper.isTrackedBy(bukkitPlayer);
}
}

View File

@ -24,34 +24,34 @@ import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
public class EntityNMSItem extends EntityItem implements NMSItem {
private final StandardItemLine parentHologramLine;
private final VersionNMSEntityHelper helper;
public EntityNMSItem(World world, StandardItemLine parentHologramLine) {
super(world);
this.parentHologramLine = parentHologramLine;
this.helper = new VersionNMSEntityHelper(this);
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
}
@Override
public void B_() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
// Method called when a player is near
@Override
public void d(EntityHuman human) {
@ -59,18 +59,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
// Too low or too high, it's a bit weird
return;
}
if (human instanceof EntityPlayer) {
parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity());
// 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
@ -82,23 +82,23 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
// Do not save NBT
return false;
}
@Override
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -108,17 +108,17 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
}
@Override
public void die() {
// Prevent entity from dying
}
@Override
public boolean isAlive() {
// This override prevents items from being picked up by hoppers (should have no side effects)
@ -137,12 +137,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public boolean isDeadNMS() {
return super.dead;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
@ -151,7 +151,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
@Override
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
ItemStack newItem = CraftItemStack.asNMSCopy(stack);
if (newItem == null || newItem == ItemStack.a) { // ItemStack.a is returned if the stack is not valid
newItem = new ItemStack(Blocks.BEDROCK);
}
@ -167,15 +167,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
NBTTagList tagList = new NBTTagList();
tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE));
display.set("Lore", tagList);
super.setItemStack(newItem);
}
@Override
public int getIdNMS() {
return super.getId();
}
@Override
public StandardHologramLine getHologramLine() {
return parentHologramLine;
@ -195,5 +195,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public Object getRawItemStack() {
return super.getItemStack();
}
}

View File

@ -21,15 +21,15 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEntityEvent;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private final StandardHologramLine parentHologramLine;
private final VersionNMSEntityHelper helper;
public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) {
super(world);
this.parentHologramLine = parentHologramLine;
this.helper = new VersionNMSEntityHelper(this);
super.persistent = true;
super.collides = false;
super.a(0.0F, 0.0F);
@ -37,37 +37,37 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
super.setInvisible(true);
forceSetBoundingBox(new NullBoundingBox());
}
@Override
public void B_() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
@Override
public void a(AxisAlignedBB boundingBox) {
// Prevent changes to bounding box
}
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
super.a(boundingBox);
}
@Override
public void b(NBTTagCompound nbttagcompound) {
// Do not save NBT
}
@Override
public boolean c(NBTTagCompound nbttagcompound) {
// Do not save NBT
@ -79,23 +79,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
// Do not save NBT
return false;
}
@Override
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean damageEntity(DamageSource damageSource, float amount) {
if (damageSource instanceof EntityDamageSource) {
@ -108,7 +108,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
}
return false;
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -118,7 +118,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
@ -128,12 +128,12 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public void setCustomName(String customName) {
// Prevents changes to custom name
}
@Override
public void setCustomNameVisible(boolean visible) {
// Prevents changes to custom name visibility
}
@Override
public void a(SoundEffect soundeffect, float f, float f1) {
// Remove sounds
@ -143,7 +143,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public void die() {
// Prevent entity from dying
}
@Override
public CraftEntity getBukkitEntity() {
if (super.bukkitEntity == null) {
@ -156,22 +156,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public boolean isDeadNMS() {
return super.dead;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
}
@Override
public int getIdNMS() {
return super.getId();
}
@Override
public StandardHologramLine getHologramLine() {
return parentHologramLine;

View File

@ -60,7 +60,7 @@ public class NullBoundingBox extends AxisAlignedBB {
public AxisAlignedBB shrink(double arg0) {
return this;
}
@Override
public AxisAlignedBB a(BlockPosition arg0) {
return this;
@ -90,7 +90,7 @@ public class NullBoundingBox extends AxisAlignedBB {
public AxisAlignedBB e(double arg0) {
return this;
}
@Override
public AxisAlignedBB g(double arg0) {
return this;

View File

@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry>
public VersionNMSEntityHelper(Entity entity) {
this.entity = entity;
}
@Override
protected EntityTrackerEntry getTracker0() {
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());

View File

@ -30,7 +30,7 @@ import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
import org.bukkit.inventory.ItemStack;
public class VersionNMSManager implements NMSManager {
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD
= ReflectField.lookup(new ClassToken<RegistryID<Class<? extends Entity>>>() {}, RegistryMaterials.class, "a");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD
@ -43,17 +43,17 @@ public class VersionNMSManager implements NMSManager {
public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) {
this.protocolPacketSettings = protocolPacketSettings;
}
@Override
public void setup() throws Exception {
registerCustomEntity(EntityNMSSlime.class, 55);
}
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
// Use reflection to get the RegistryID of entities
RegistryID<Class<? extends Entity>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b);
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
// Save the the ID -> entity class mapping before the registration
Object oldValue = idToClassMap[id];
@ -63,7 +63,7 @@ public class VersionNMSManager implements NMSManager {
// Restore the ID -> entity class mapping
idToClassMap[id] = oldValue;
}
@Override
public NMSItem spawnNMSItem(
org.bukkit.World bukkitWorld, double x, double y, double z,
@ -76,7 +76,7 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, item);
return item;
}
@Override
public EntityNMSSlime spawnNMSSlime(
org.bukkit.World bukkitWorld, double x, double y, double z,
@ -87,7 +87,7 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, slime);
return slime;
}
@Override
public NMSArmorStand spawnNMSArmorStand(
org.bukkit.World world, double x, double y, double z,
@ -98,22 +98,22 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, armorStand);
return armorStand;
}
private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException {
Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add");
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
// This should never happen
nmsEntity.dead = true;
throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED);
}
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
nmsWorld.entityList.add(nmsEntity);
try {
REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity);
} catch (ReflectiveOperationException e) {
@ -121,7 +121,7 @@ public class VersionNMSManager implements NMSManager {
throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e);
}
}
@Override
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity;
@ -130,19 +130,19 @@ public class VersionNMSManager implements NMSManager {
@Override
public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
if (nmsEntity instanceof NMSEntity) {
return (NMSEntity) nmsEntity;
} else {
return null;
}
}
@Override
public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
Entity nmsEntity = nmsWorld.getEntity(entityID);
if (nmsEntity instanceof NMSEntity) {
return (NMSEntity) nmsEntity;
} else {
@ -154,5 +154,5 @@ public class VersionNMSManager implements NMSManager {
public Object createCustomNameNMSObject(String customName) {
return EntityNMSArmorStand.createCustomNameNMSObject(customName);
}
}

View File

@ -17,7 +17,7 @@
<groupId>${project.groupId}</groupId>
<artifactId>holographicdisplays-common</artifactId>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>

View File

@ -24,16 +24,16 @@ public class CraftNMSArmorStand extends CraftArmorStand {
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand 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 ArmorStand class
@Override public void setArms(boolean arms) {}
@Override public void setBasePlate(boolean basePlate) {}
@Override public void setBodyPose(EulerAngle pose) {}
@ -62,7 +62,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
@Override public void setGliding(boolean gliding) {}
@Override public boolean setLeashHolder(Entity holder) { return false; }
@Override public void setSwimming(boolean swimming) {}
// Methods from Entity
@Override public void setVelocity(Vector vel) {}
@Override public boolean teleport(Location loc) { return false; }
@ -83,6 +83,6 @@ public class CraftNMSArmorStand extends CraftArmorStand {
@Override public void setMomentum(Vector value) {}
@Override public void setSilent(boolean flag) {}
@Override public void setTicksLived(int value) {}
}

View File

@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem {
}
// Disallow all the bukkit methods
@Override
public void remove() {
// Cannot be removed, this is the most important to override
@ -48,9 +48,9 @@ public class CraftNMSItem extends CraftItem {
@Override public void setMomentum(Vector value) {}
@Override public void setSilent(boolean flag) {}
@Override public void setTicksLived(int value) {}
// Methods from Item
@Override public void setItemStack(ItemStack stack) {}
@Override public void setPickupDelay(int delay) {}
}

View File

@ -23,14 +23,14 @@ 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; }
@ -63,10 +63,10 @@ public class CraftNMSSlime extends CraftSlime {
@Override public void setMomentum(Vector value) {}
@Override public void setSilent(boolean flag) {}
@Override public void setTicksLived(int value) {}
// Methods from Slime
@Override public void setSize(int size) {}
@Override public void setTarget(LivingEntity target) {}
}

View File

@ -42,13 +42,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
private final ProtocolPacketSettings protocolPacketSettings;
private final VersionNMSEntityHelper helper;
private String customName;
public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) {
super(world);
this.parentHologramLine = parentHologramLine;
this.protocolPacketSettings = protocolPacketSettings;
this.helper = new VersionNMSEntityHelper(this);
super.setInvisible(true);
super.setSmall(true);
super.setArms(false);
@ -59,32 +59,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet
forceSetBoundingBox(new NullBoundingBox());
}
@Override
public void tick() {
// Disable normal ticking for this entity
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity
if (super.onGround) {
super.onGround = false;
}
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity
if (super.onGround) {
super.onGround = false;
}
}
@Override
public void b(NBTTagCompound nbttagcompound) {
// Do not save NBT
}
@Override
public boolean c(NBTTagCompound nbttagcompound) {
// Do not save NBT
@ -96,23 +96,23 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
// Do not save NBT
return false;
}
@Override
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -122,17 +122,17 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
}
@Override
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
// Prevents changes to custom name
}
@Override
public void setCustomNameVisible(boolean visible) {
// Prevents changes to custom name visibility
@ -154,21 +154,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
// Prevent armor stand from being equipped
}
@Override
public void a(AxisAlignedBB boundingBox) {
// Prevent changes to bounding box
}
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
super.a(boundingBox);
}
@Override
public void a(SoundEffect soundeffect, float f, float f1) {
// Remove sounds
}
@Override
public void setCustomNameNMS(String customName) {
if (Objects.equals(this.customName, customName)) {
@ -182,22 +182,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
protected static IChatBaseComponent createCustomNameNMSObject(String customName) {
return CraftChatMessage.fromStringOrNull(Strings.truncate(customName, 300));
}
@Override
public String getCustomNameStringNMS() {
return this.customName;
}
@Override
public IChatBaseComponent getCustomNameObjectNMS() {
return super.getCustomName();
}
@Override
public void die() {
// Prevent entity from dying
}
@Override
public CraftEntity getBukkitEntity() {
if (super.bukkitEntity == null) {
@ -205,12 +205,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
}
return super.bukkitEntity;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
@ -238,7 +238,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public boolean isDeadNMS() {
return super.dead;
}
@Override
public int getIdNMS() {
return super.getId();
@ -248,7 +248,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public StandardHologramLine getHologramLine() {
return parentHologramLine;
}
@Override
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
@ -258,5 +258,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public boolean isTrackedBy(Player bukkitPlayer) {
return helper.isTrackedBy(bukkitPlayer);
}
}

View File

@ -24,34 +24,34 @@ import org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
public class EntityNMSItem extends EntityItem implements NMSItem {
private final StandardItemLine parentHologramLine;
private final VersionNMSEntityHelper helper;
public EntityNMSItem(World world, StandardItemLine parentHologramLine) {
super(world);
this.parentHologramLine = parentHologramLine;
this.helper = new VersionNMSEntityHelper(this);
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
}
@Override
public void tick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
// Method called when a player is near
@Override
public void d(EntityHuman human) {
@ -59,18 +59,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
// Too low or too high, it's a bit weird
return;
}
if (human instanceof EntityPlayer) {
parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity());
// 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
@ -82,23 +82,23 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
// Do not save NBT
return false;
}
@Override
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -108,7 +108,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
@ -118,7 +118,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public void die() {
// Prevent entity from dying
}
@Override
public boolean isAlive() {
// This override prevents items from being picked up by hoppers (should have no side effects)
@ -137,12 +137,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public boolean isDeadNMS() {
return super.dead;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
@ -151,7 +151,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
@Override
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
ItemStack newItem = CraftItemStack.asNMSCopy(stack);
if (newItem == null || newItem == ItemStack.a) { // ItemStack.a is returned if the stack is not valid
newItem = new ItemStack(Blocks.BEDROCK);
}
@ -167,15 +167,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
NBTTagList tagList = new NBTTagList();
tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE));
display.set("Lore", tagList);
super.setItemStack(newItem);
}
@Override
public int getIdNMS() {
return super.getId();
}
@Override
public StandardHologramLine getHologramLine() {
return parentHologramLine;
@ -195,5 +195,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public Object getRawItemStack() {
return super.getItemStack();
}
}

View File

@ -22,15 +22,15 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEntityEvent;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private final StandardHologramLine parentHologramLine;
private final VersionNMSEntityHelper helper;
public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) {
super(world);
this.parentHologramLine = parentHologramLine;
this.helper = new VersionNMSEntityHelper(this);
super.persistent = true;
super.collides = false;
super.a(0.0F, 0.0F);
@ -38,37 +38,37 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
super.setInvisible(true);
forceSetBoundingBox(new NullBoundingBox());
}
@Override
public void tick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
@Override
public void a(AxisAlignedBB boundingBox) {
// Prevent changes to bounding box
}
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
super.a(boundingBox);
}
@Override
public void b(NBTTagCompound nbttagcompound) {
// Do not save NBT
}
@Override
public boolean c(NBTTagCompound nbttagcompound) {
// Do not save NBT
@ -80,23 +80,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
// Do not save NBT
return false;
}
@Override
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean damageEntity(DamageSource damageSource, float amount) {
if (damageSource instanceof EntityDamageSource) {
@ -109,7 +109,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
}
return false;
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -119,7 +119,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
@ -129,22 +129,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
// Prevents changes to custom name
}
@Override
public void setCustomNameVisible(boolean visible) {
// Prevents changes to custom name visibility
}
@Override
public void a(SoundEffect soundeffect, float f, float f1) {
// Remove sounds
}
@Override
public void die() {
// Prevent entity from dying
}
@Override
public CraftEntity getBukkitEntity() {
if (super.bukkitEntity == null) {
@ -157,22 +157,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public boolean isDeadNMS() {
return super.dead;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
}
@Override
public int getIdNMS() {
return super.getId();
}
@Override
public StandardHologramLine getHologramLine() {
return parentHologramLine;

View File

@ -46,7 +46,7 @@ public class NullBoundingBox extends AxisAlignedBB {
public AxisAlignedBB shrink(double arg0) {
return this;
}
@Override
public AxisAlignedBB a(BlockPosition arg0) {
return this;
@ -61,7 +61,7 @@ public class NullBoundingBox extends AxisAlignedBB {
public boolean b(Vec3D arg0) {
return false;
}
@Override
public AxisAlignedBB g(double arg0) {
return this;

View File

@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry>
public VersionNMSEntityHelper(Entity entity) {
this.entity = entity;
}
@Override
protected EntityTrackerEntry getTracker0() {
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());

View File

@ -33,7 +33,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.List;
public class VersionNMSManager implements NMSManager {
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD
= ReflectField.lookup(new ClassToken<RegistryID<EntityTypes<?>>>() {}, RegistryMaterials.class, "a");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD
@ -48,17 +48,17 @@ public class VersionNMSManager implements NMSManager {
public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) {
this.protocolPacketSettings = protocolPacketSettings;
}
@Override
public void setup() throws Exception {
registerCustomEntity(EntityNMSSlime.class, 55);
}
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
// Use reflection to get the RegistryID of entities
RegistryID<EntityTypes<?>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.REGISTRY);
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
// Save the the ID -> EntityTypes mapping before the registration
Object oldValue = idToClassMap[id];
@ -68,7 +68,7 @@ public class VersionNMSManager implements NMSManager {
// Restore the ID -> EntityTypes mapping
idToClassMap[id] = oldValue;
}
@Override
public NMSItem spawnNMSItem(
org.bukkit.World bukkitWorld, double x, double y, double z,
@ -81,7 +81,7 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, item);
return item;
}
@Override
public EntityNMSSlime spawnNMSSlime(
org.bukkit.World bukkitWorld, double x, double y, double z,
@ -92,7 +92,7 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, slime);
return slime;
}
@Override
public NMSArmorStand spawnNMSArmorStand(
org.bukkit.World world, double x, double y, double z,
@ -103,19 +103,19 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, armorStand);
return armorStand;
}
private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException {
Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add");
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
// This should never happen
nmsEntity.dead = true;
throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED);
}
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
if (NMSCommons.IS_PAPER_SERVER) {
try {
@ -129,7 +129,7 @@ public class VersionNMSManager implements NMSManager {
} else {
nmsWorld.entityList.add(nmsEntity);
}
try {
REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity);
} catch (ReflectiveOperationException e) {
@ -137,7 +137,7 @@ public class VersionNMSManager implements NMSManager {
throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e);
}
}
@Override
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity;
@ -146,19 +146,19 @@ public class VersionNMSManager implements NMSManager {
@Override
public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
if (nmsEntity instanceof NMSEntity) {
return (NMSEntity) nmsEntity;
} else {
return null;
}
}
@Override
public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
Entity nmsEntity = nmsWorld.getEntity(entityID);
if (nmsEntity instanceof NMSEntity) {
return (NMSEntity) nmsEntity;
} else {
@ -170,5 +170,5 @@ public class VersionNMSManager implements NMSManager {
public Object createCustomNameNMSObject(String customName) {
return EntityNMSArmorStand.createCustomNameNMSObject(customName);
}
}

View File

@ -17,7 +17,7 @@
<groupId>${project.groupId}</groupId>
<artifactId>holographicdisplays-common</artifactId>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>

View File

@ -24,16 +24,16 @@ public class CraftNMSArmorStand extends CraftArmorStand {
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand 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 ArmorStand class
@Override public void setArms(boolean arms) {}
@Override public void setBasePlate(boolean basePlate) {}
@Override public void setBodyPose(EulerAngle pose) {}
@ -62,7 +62,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
@Override public void setGliding(boolean gliding) {}
@Override public boolean setLeashHolder(Entity holder) { return false; }
@Override public void setSwimming(boolean swimming) {}
// Methods from Entity
@Override public void setVelocity(Vector vel) {}
@Override public boolean teleport(Location loc) { return false; }
@ -84,6 +84,6 @@ public class CraftNMSArmorStand extends CraftArmorStand {
@Override public void setSilent(boolean flag) {}
@Override public void setTicksLived(int value) {}
@Override public void setPersistent(boolean flag) {}
}

View File

@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem {
}
// Disallow all the bukkit methods
@Override
public void remove() {
// Cannot be removed, this is the most important to override
@ -49,9 +49,9 @@ public class CraftNMSItem extends CraftItem {
@Override public void setSilent(boolean flag) {}
@Override public void setTicksLived(int value) {}
@Override public void setPersistent(boolean flag) {}
// Methods from Item
@Override public void setItemStack(ItemStack stack) {}
@Override public void setPickupDelay(int delay) {}
}

View File

@ -24,14 +24,14 @@ 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; }
@ -65,7 +65,7 @@ public class CraftNMSSlime extends CraftSlime {
@Override public void setSilent(boolean flag) {}
@Override public void setTicksLived(int value) {}
@Override public void setPersistent(boolean flag) {}
// Methods from Mob
@Override public void setLootTable(LootTable table) {}
@Override public void setSeed(long seed) {}
@ -73,5 +73,5 @@ public class CraftNMSSlime extends CraftSlime {
// Methods from Slime
@Override public void setSize(int size) {}
@Override public void setTarget(LivingEntity target) {}
}

View File

@ -42,13 +42,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
private final ProtocolPacketSettings protocolPacketSettings;
private final VersionNMSEntityHelper helper;
private String customName;
public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) {
super(world);
this.parentHologramLine = parentHologramLine;
this.protocolPacketSettings = protocolPacketSettings;
this.helper = new VersionNMSEntityHelper(this);
super.setInvisible(true);
super.setSmall(true);
super.setArms(false);
@ -59,32 +59,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet
forceSetBoundingBox(new NullBoundingBox());
}
@Override
public void tick() {
// Disable normal ticking for this entity
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity
if (super.onGround) {
super.onGround = false;
}
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity
if (super.onGround) {
super.onGround = false;
}
}
@Override
public void b(NBTTagCompound nbttagcompound) {
// Do not save NBT
}
@Override
public boolean c(NBTTagCompound nbttagcompound) {
// Do not save NBT
@ -96,23 +96,23 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
// Do not save NBT
return false;
}
@Override
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -122,17 +122,17 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
}
@Override
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
// Prevents changes to custom name
}
@Override
public void setCustomNameVisible(boolean visible) {
// Prevents changes to custom name visibility
@ -154,21 +154,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
// Prevent armor stand from being equipped
}
@Override
public void a(AxisAlignedBB boundingBox) {
// Prevent changes to bounding box
}
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
super.a(boundingBox);
}
@Override
public void a(SoundEffect soundeffect, float f, float f1) {
// Remove sounds
}
@Override
public void setCustomNameNMS(String customName) {
if (Objects.equals(this.customName, customName)) {
@ -182,22 +182,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
protected static IChatBaseComponent createCustomNameNMSObject(String customName) {
return CraftChatMessage.fromStringOrNull(Strings.truncate(customName, 300));
}
@Override
public String getCustomNameStringNMS() {
return this.customName;
}
@Override
public IChatBaseComponent getCustomNameObjectNMS() {
return super.getCustomName();
}
@Override
public void die() {
// Prevent entity from dying
}
@Override
public CraftEntity getBukkitEntity() {
if (super.bukkitEntity == null) {
@ -205,12 +205,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
}
return super.bukkitEntity;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
@ -238,7 +238,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public boolean isDeadNMS() {
return super.dead;
}
@Override
public int getIdNMS() {
return super.getId();
@ -248,7 +248,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public StandardHologramLine getHologramLine() {
return parentHologramLine;
}
@Override
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
@ -258,5 +258,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
public boolean isTrackedBy(Player bukkitPlayer) {
return helper.isTrackedBy(bukkitPlayer);
}
}

View File

@ -24,34 +24,34 @@ import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack;
import org.bukkit.entity.Player;
public class EntityNMSItem extends EntityItem implements NMSItem {
private final StandardItemLine parentHologramLine;
private final VersionNMSEntityHelper helper;
public EntityNMSItem(World world, StandardItemLine parentHologramLine) {
super(world);
this.parentHologramLine = parentHologramLine;
this.helper = new VersionNMSEntityHelper(this);
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
}
@Override
public void tick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
// Method called when a player is near
@Override
public void d(EntityHuman human) {
@ -59,18 +59,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
// Too low or too high, it's a bit weird
return;
}
if (human instanceof EntityPlayer) {
parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity());
// 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
@ -82,23 +82,23 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
// Do not save NBT
return false;
}
@Override
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -108,17 +108,17 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
}
@Override
public void die() {
// Prevent entity from dying
}
@Override
public boolean isAlive() {
// This override prevents items from being picked up by hoppers (should have no side effects)
@ -137,12 +137,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public boolean isDeadNMS() {
return super.dead;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
@ -151,7 +151,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
@Override
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
ItemStack newItem = CraftItemStack.asNMSCopy(stack);
if (newItem == null || newItem == ItemStack.a) { // ItemStack.a is returned if the stack is not valid
newItem = new ItemStack(Blocks.BEDROCK);
}
@ -167,15 +167,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
NBTTagList tagList = new NBTTagList();
tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE));
display.set("Lore", tagList);
super.setItemStack(newItem);
}
@Override
public int getIdNMS() {
return super.getId();
}
@Override
public StandardHologramLine getHologramLine() {
return parentHologramLine;
@ -195,5 +195,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public Object getRawItemStack() {
return super.getItemStack();
}
}

View File

@ -22,15 +22,15 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEntityEvent;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private final StandardHologramLine parentHologramLine;
private final VersionNMSEntityHelper helper;
public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) {
super(world);
this.parentHologramLine = parentHologramLine;
this.helper = new VersionNMSEntityHelper(this);
super.persistent = true;
super.collides = false;
super.a(0.0F, 0.0F);
@ -38,37 +38,37 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
super.setInvisible(true);
forceSetBoundingBox(new NullBoundingBox());
}
@Override
public void tick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
@Override
public void inactiveTick() {
// Disable normal ticking for this entity
// So it won't get removed
ticksLived = 0;
}
@Override
public void a(AxisAlignedBB boundingBox) {
// Prevent changes to bounding box
}
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
super.a(boundingBox);
}
@Override
public void b(NBTTagCompound nbttagcompound) {
// Do not save NBT
}
@Override
public boolean c(NBTTagCompound nbttagcompound) {
// Do not save NBT
@ -80,23 +80,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
// Do not save NBT
return false;
}
@Override
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
// Do not save NBT
return nbttagcompound;
}
@Override
public void f(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public void a(NBTTagCompound nbttagcompound) {
// Do not load NBT
}
@Override
public boolean damageEntity(DamageSource damageSource, float amount) {
if (damageSource instanceof EntityDamageSource) {
@ -109,7 +109,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
}
return false;
}
@Override
public boolean isInvulnerable(DamageSource source) {
/*
@ -119,32 +119,32 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
*/
return true;
}
@Override
public boolean isCollidable() {
return false;
}
@Override
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
// Prevents changes to custom name
}
@Override
public void setCustomNameVisible(boolean visible) {
// Prevents changes to custom name visibility
}
@Override
public void a(SoundEffect soundeffect, float f, float f1) {
// Remove sounds
}
@Override
public void die() {
// Prevent entity from dying
}
@Override
public CraftEntity getBukkitEntity() {
if (super.bukkitEntity == null) {
@ -157,22 +157,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public boolean isDeadNMS() {
return super.dead;
}
@Override
public void killEntityNMS() {
super.dead = true;
}
@Override
public void setLocationNMS(double x, double y, double z) {
super.setPosition(x, y, z);
}
@Override
public int getIdNMS() {
return super.getId();
}
@Override
public StandardHologramLine getHologramLine() {
return parentHologramLine;

View File

@ -46,7 +46,7 @@ public class NullBoundingBox extends AxisAlignedBB {
public AxisAlignedBB shrink(double arg0) {
return this;
}
@Override
public AxisAlignedBB a(BlockPosition arg0) {
return this;
@ -61,7 +61,7 @@ public class NullBoundingBox extends AxisAlignedBB {
public boolean b(Vec3D arg0) {
return false;
}
@Override
public AxisAlignedBB g(double arg0) {
return this;

View File

@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry>
public VersionNMSEntityHelper(Entity entity) {
this.entity = entity;
}
@Override
protected EntityTrackerEntry getTracker0() {
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());

View File

@ -34,7 +34,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.List;
public class VersionNMSManager implements NMSManager {
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD
= ReflectField.lookup(new ClassToken<RegistryID<EntityTypes<?>>>() {}, RegistryMaterials.class, "b");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD
@ -49,17 +49,17 @@ public class VersionNMSManager implements NMSManager {
public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) {
this.protocolPacketSettings = protocolPacketSettings;
}
@Override
public void setup() throws Exception {
registerCustomEntity(EntityNMSSlime.class, 55);
}
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
// Use reflection to get the RegistryID of entities
RegistryID<EntityTypes<?>> registryID = REGISTRY_ID_FIELD.get(IRegistry.ENTITY_TYPE);
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
// Save the the ID -> EntityTypes mapping before the registration
Object oldValue = idToClassMap[id];
@ -69,7 +69,7 @@ public class VersionNMSManager implements NMSManager {
// Restore the ID -> EntityTypes mapping
idToClassMap[id] = oldValue;
}
@Override
public NMSItem spawnNMSItem(
org.bukkit.World bukkitWorld, double x, double y, double z,
@ -82,7 +82,7 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, item);
return item;
}
@Override
public EntityNMSSlime spawnNMSSlime(
org.bukkit.World bukkitWorld, double x, double y, double z,
@ -93,7 +93,7 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, slime);
return slime;
}
@Override
public NMSArmorStand spawnNMSArmorStand(
org.bukkit.World world, double x, double y, double z,
@ -104,19 +104,19 @@ public class VersionNMSManager implements NMSManager {
addEntityToWorld(nmsWorld, armorStand);
return armorStand;
}
private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException {
Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add");
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
if (!nmsWorld.isChunkLoaded(chunkX, chunkZ, true)) { // The boolean "true" is currently unused
// This should never happen
nmsEntity.dead = true;
throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED);
}
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
if (NMSCommons.IS_PAPER_SERVER) {
try {
@ -130,7 +130,7 @@ public class VersionNMSManager implements NMSManager {
} else {
nmsWorld.entityList.add(nmsEntity);
}
try {
REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity);
} catch (ReflectiveOperationException e) {
@ -138,7 +138,7 @@ public class VersionNMSManager implements NMSManager {
throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e);
}
}
@Override
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity;
@ -147,19 +147,19 @@ public class VersionNMSManager implements NMSManager {
@Override
public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
if (nmsEntity instanceof NMSEntity) {
return (NMSEntity) nmsEntity;
} else {
return null;
}
}
@Override
public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
Entity nmsEntity = nmsWorld.getEntity(entityID);
if (nmsEntity instanceof NMSEntity) {
return (NMSEntity) nmsEntity;
} else {
@ -171,5 +171,5 @@ public class VersionNMSManager implements NMSManager {
public Object createCustomNameNMSObject(String customName) {
return EntityNMSArmorStand.createCustomNameNMSObject(customName);
}
}

View File

@ -17,7 +17,7 @@
<groupId>${project.groupId}</groupId>
<artifactId>holographicdisplays-common</artifactId>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>

View File

@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand {
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
super(server, entity);
}
// Disallow all the bukkit methods
@Override
public void remove() {
// Cannot be removed, this is the most important to override
@ -61,7 +61,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
@Override public void setGliding(boolean gliding) {}
@Override public boolean setLeashHolder(Entity holder) { return false; }
@Override public void setSwimming(boolean swimming) {}
// Methods from Entity class
@Override public void setVelocity(Vector vel) {}
@Override public boolean teleport(Location loc) { return false; }
@ -84,6 +84,6 @@ public class CraftNMSArmorStand extends CraftArmorStand {
@Override public void setTicksLived(int value) {}
@Override public void setPersistent(boolean flag) {}
@Override public void setRotation(float yaw, float pitch) {}
}

View File

@ -22,12 +22,12 @@ public class CraftNMSItem extends CraftItem {
}
// Disallow all the bukkit methods
@Override
public void remove() {
// Cannot be removed, this is the most important to override
}
// Methods from Item class
@Override public void setItemStack(ItemStack stack) {}
@Override public void setPickupDelay(int delay) {}
@ -54,5 +54,5 @@ public class CraftNMSItem extends CraftItem {
@Override public void setTicksLived(int value) {}
@Override public void setPersistent(boolean flag) {}
@Override public void setRotation(float yaw, float pitch) {}
}

View File

@ -24,22 +24,22 @@ 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 Slime class
@Override public void setSize(int size) {}
@Override public void setTarget(LivingEntity target) {}
// Methods from Mob class
@Override public void setLootTable(LootTable table) {}
@Override public void setSeed(long seed) {}
// Methods from LivingEntity class
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }

Some files were not shown because too many files have changed in this diff Show More