Convert tabs to spaces
This commit is contained in:
parent
9c97e0ed39
commit
09f99be342
42
api/pom.xml
42
api/pom.xml
|
@ -1,29 +1,29 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||||
<artifactId>holographicdisplays-parent</artifactId>
|
<artifactId>holographicdisplays-parent</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>holographicdisplays-api</artifactId>
|
<artifactId>holographicdisplays-api</artifactId>
|
||||||
<name>HolographicDisplays API</name>
|
<name>HolographicDisplays API</name>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -27,193 +27,193 @@ import org.bukkit.inventory.ItemStack;
|
||||||
* To create one, please see {@link HologramsAPI#createHologram(org.bukkit.plugin.Plugin, Location)}.
|
* To create one, please see {@link HologramsAPI#createHologram(org.bukkit.plugin.Plugin, Location)}.
|
||||||
*/
|
*/
|
||||||
public interface Hologram {
|
public interface Hologram {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends a text line to end of this hologram.
|
* Appends a text line to end of this hologram.
|
||||||
*
|
*
|
||||||
* @param text the content of the line, can be null for an empty line
|
* @param text the content of the line, can be null for an empty line
|
||||||
* @return the new TextLine appended
|
* @return the new TextLine appended
|
||||||
*/
|
*/
|
||||||
public TextLine appendTextLine(String text);
|
public TextLine appendTextLine(String text);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends an item line to end of this hologram.
|
* Appends an item line to end of this hologram.
|
||||||
*
|
*
|
||||||
* @param itemStack the content of the line
|
* @param itemStack the content of the line
|
||||||
* @return the new ItemLine appended
|
* @return the new ItemLine appended
|
||||||
*/
|
*/
|
||||||
public ItemLine appendItemLine(ItemStack itemStack);
|
public ItemLine appendItemLine(ItemStack itemStack);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a text line in this hologram.
|
* Inserts a text line in this hologram.
|
||||||
*
|
*
|
||||||
* @param index the line is inserted before this index. If 0, the new line will
|
* @param index the line is inserted before this index. If 0, the new line will
|
||||||
* be inserted before the first line.
|
* be inserted before the first line.
|
||||||
* @param text the content of the line, can be null for an empty line
|
* @param text the content of the line, can be null for an empty line
|
||||||
* @return the new TextLine inserted
|
* @return the new TextLine inserted
|
||||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||||
*/
|
*/
|
||||||
public TextLine insertTextLine(int index, String text);
|
public TextLine insertTextLine(int index, String text);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts an item line in this hologram.
|
* Inserts an item line in this hologram.
|
||||||
*
|
*
|
||||||
* @param index the line is inserted before this index. If 0, the new line will
|
* @param index the line is inserted before this index. If 0, the new line will
|
||||||
* be inserted before the first line.
|
* be inserted before the first line.
|
||||||
* @param itemStack the content of the line
|
* @param itemStack the content of the line
|
||||||
* @return the new ItemLine inserted
|
* @return the new ItemLine inserted
|
||||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||||
*/
|
*/
|
||||||
public ItemLine insertItemLine(int index, ItemStack itemStack);
|
public ItemLine insertItemLine(int index, ItemStack itemStack);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the element at a given index in the lines.
|
* Finds the element at a given index in the lines.
|
||||||
*
|
*
|
||||||
* @param index the index of the line to retrieve.
|
* @param index the index of the line to retrieve.
|
||||||
* @return the hologram line at the given index, can be an {@link ItemLine} or a {@link TextLine}.
|
* @return the hologram line at the given index, can be an {@link ItemLine} or a {@link TextLine}.
|
||||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||||
*/
|
*/
|
||||||
public HologramLine getLine(int index);
|
public HologramLine getLine(int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a line at a given index. Since: v2.0.1
|
* Removes a line at a given index. Since: v2.0.1
|
||||||
*
|
*
|
||||||
* @param index the index of the line, that should be between 0 and size() - 1.
|
* @param index the index of the line, that should be between 0 and size() - 1.
|
||||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||||
*/
|
*/
|
||||||
public void removeLine(int index);
|
public void removeLine(int index);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all the lines from this hologram.
|
* Removes all the lines from this hologram.
|
||||||
*/
|
*/
|
||||||
public void clearLines();
|
public void clearLines();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the amount of lines of the hologram.
|
* Checks the amount of lines of the hologram.
|
||||||
*
|
*
|
||||||
* @return the amount of lines
|
* @return the amount of lines
|
||||||
*/
|
*/
|
||||||
public int size();
|
public int size();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The physical height of the hologram, counting all the lines. Since: v2.1.4
|
* The physical height of the hologram, counting all the lines. Since: v2.1.4
|
||||||
*
|
*
|
||||||
* @return the height of the hologram, counting all the lines and the gaps between them
|
* @return the height of the hologram, counting all the lines and the gaps between them
|
||||||
*/
|
*/
|
||||||
public double getHeight();
|
public double getHeight();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Teleports a hologram to the given location.
|
* Teleports a hologram to the given location.
|
||||||
*
|
*
|
||||||
* @param location the new location
|
* @param location the new location
|
||||||
*/
|
*/
|
||||||
public void teleport(Location location);
|
public void teleport(Location location);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Teleports a hologram to the given location.
|
* Teleports a hologram to the given location.
|
||||||
*
|
*
|
||||||
* @param world the world where the hologram should be teleported,
|
* @param world the world where the hologram should be teleported,
|
||||||
* use {@link #getWorld()} to teleport it in the same world.
|
* use {@link #getWorld()} to teleport it in the same world.
|
||||||
* @param x the X coordinate
|
* @param x the X coordinate
|
||||||
* @param y the Y coordinate
|
* @param y the Y coordinate
|
||||||
* @param z the Z coordinate
|
* @param z the Z coordinate
|
||||||
*/
|
*/
|
||||||
public void teleport(World world, double x, double y, double z);
|
public void teleport(World world, double x, double y, double z);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the position of the hologram.
|
* Returns the position of the hologram.
|
||||||
*
|
*
|
||||||
* @return the Location of the hologram
|
* @return the Location of the hologram
|
||||||
*/
|
*/
|
||||||
public Location getLocation();
|
public Location getLocation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the X coordinate.
|
* Returns the X coordinate.
|
||||||
*
|
*
|
||||||
* @return the X coordinate of the hologram
|
* @return the X coordinate of the hologram
|
||||||
*/
|
*/
|
||||||
public double getX();
|
public double getX();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Y coordinate.
|
* Returns the Y coordinate.
|
||||||
*
|
*
|
||||||
* @return the Y coordinate of the hologram
|
* @return the Y coordinate of the hologram
|
||||||
*/
|
*/
|
||||||
public double getY();
|
public double getY();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Z coordinate.
|
* Returns the Z coordinate.
|
||||||
*
|
*
|
||||||
* @return the Z coordinate of the hologram
|
* @return the Z coordinate of the hologram
|
||||||
*/
|
*/
|
||||||
public double getZ();
|
public double getZ();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the world.
|
* Returns the world.
|
||||||
*
|
*
|
||||||
* @return the world of the hologram
|
* @return the world of the hologram
|
||||||
*/
|
*/
|
||||||
public World getWorld();
|
public World getWorld();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link VisibilityManager} of this hologram.
|
* Returns the {@link VisibilityManager} of this hologram.
|
||||||
* <br><b style = "color: red">Note</b>: the usage of the VisibilityManager requires ProtocolLib.
|
* <br><b style = "color: red">Note</b>: the usage of the VisibilityManager requires ProtocolLib.
|
||||||
* Without the plugin, holograms will be always visible.
|
* Without the plugin, holograms will be always visible.
|
||||||
*
|
*
|
||||||
* @return the VisibilityManager of this hologram
|
* @return the VisibilityManager of this hologram
|
||||||
*/
|
*/
|
||||||
public VisibilityManager getVisibilityManager();
|
public VisibilityManager getVisibilityManager();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns when the hologram was created. Useful for removing old holograms.
|
* Returns when the hologram was created. Useful for removing old holograms.
|
||||||
*
|
*
|
||||||
* @return the timestamp of when the hologram was created, in milliseconds
|
* @return the timestamp of when the hologram was created, in milliseconds
|
||||||
*/
|
*/
|
||||||
public long getCreationTimestamp();
|
public long getCreationTimestamp();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the hologram will track and replace placeholders.
|
* Checks if the hologram will track and replace placeholders.
|
||||||
* This is false by default.
|
* This is false by default.
|
||||||
*
|
*
|
||||||
* @return if the hologram allows placeholders
|
* @return if the hologram allows placeholders
|
||||||
*/
|
*/
|
||||||
public boolean isAllowPlaceholders();
|
public boolean isAllowPlaceholders();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets if the hologram should track and replace placeholders.
|
* Sets if the hologram should track and replace placeholders.
|
||||||
* By default if will not track them.
|
* By default if will not track them.
|
||||||
*
|
*
|
||||||
* @param allowPlaceholders if the hologram should track placeholders
|
* @param allowPlaceholders if the hologram should track placeholders
|
||||||
*/
|
*/
|
||||||
public void setAllowPlaceholders(boolean allowPlaceholders);
|
public void setAllowPlaceholders(boolean allowPlaceholders);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes this hologram. Editing or teleporting the hologram when deleted
|
* Deletes this hologram. Editing or teleporting the hologram when deleted
|
||||||
* will throw an exception. Lines will be automatically cleared.
|
* will throw an exception. Lines will be automatically cleared.
|
||||||
* You should remove all the references of the hologram after deletion.
|
* You should remove all the references of the hologram after deletion.
|
||||||
*/
|
*/
|
||||||
public void delete();
|
public void delete();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a hologram was deleted.
|
* Checks if a hologram was deleted.
|
||||||
*
|
*
|
||||||
* @return true if this hologram was deleted
|
* @return true if this hologram was deleted
|
||||||
*/
|
*/
|
||||||
public boolean isDeleted();
|
public boolean isDeleted();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,94 +27,94 @@ import java.util.Collection;
|
||||||
* It provides methods to create holograms and to register custom placeholders.
|
* It provides methods to create holograms and to register custom placeholders.
|
||||||
*/
|
*/
|
||||||
public class HologramsAPI {
|
public class HologramsAPI {
|
||||||
|
|
||||||
|
|
||||||
private HologramsAPI() {
|
private HologramsAPI() {
|
||||||
// No constructor needed.
|
// No constructor needed.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a hologram at given location.
|
* Creates a hologram at given location.
|
||||||
*
|
*
|
||||||
* @param plugin the plugin that creates it
|
* @param plugin the plugin that creates it
|
||||||
* @param source the location where it will appear
|
* @param source the location where it will appear
|
||||||
* @return the new hologram created
|
* @return the new hologram created
|
||||||
*/
|
*/
|
||||||
public static Hologram createHologram(Plugin plugin, Location source) {
|
public static Hologram createHologram(Plugin plugin, Location source) {
|
||||||
return BackendAPI.getImplementation().createHologram(plugin, source);
|
return BackendAPI.getImplementation().createHologram(plugin, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all the holograms created by a given plugin.
|
* Finds all the holograms created by a given plugin.
|
||||||
*
|
*
|
||||||
* @param plugin the plugin to search for in holograms
|
* @param plugin the plugin to search for in holograms
|
||||||
* @return the holograms created by a plugin. the Collection is a copy
|
* @return the holograms created by a plugin. the Collection is a copy
|
||||||
* and modifying it has no effect on the holograms.
|
* and modifying it has no effect on the holograms.
|
||||||
*/
|
*/
|
||||||
public static Collection<Hologram> getHolograms(Plugin plugin) {
|
public static Collection<Hologram> getHolograms(Plugin plugin) {
|
||||||
return BackendAPI.getImplementation().getHolograms(plugin);
|
return BackendAPI.getImplementation().getHolograms(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a new placeholder that can be used in holograms created with commands.
|
* Registers a new placeholder that can be used in holograms created with commands.
|
||||||
* With this method, you can basically expand the core of HolographicDisplays.
|
* With this method, you can basically expand the core of HolographicDisplays.
|
||||||
*
|
*
|
||||||
* @param plugin the owner plugin of the placeholder
|
* @param plugin the owner plugin of the placeholder
|
||||||
* @param textPlaceholder the text that the placeholder will be associated to (e.g.: "{onlinePlayers}")
|
* @param textPlaceholder the text that the placeholder will be associated to (e.g.: "{onlinePlayers}")
|
||||||
* @param refreshRate the refresh rate of the placeholder, in seconds. Keep in mind that the minimum is 0.1 seconds, and that will be rounded to tenths of seconds
|
* @param refreshRate the refresh rate of the placeholder, in seconds. Keep in mind that the minimum is 0.1 seconds, and that will be rounded to tenths of seconds
|
||||||
* @param replacer the implementation that will return the text to replace the placeholder, where the update() method is called every <b>refreshRate</b> seconds
|
* @param replacer the implementation that will return the text to replace the placeholder, where the update() method is called every <b>refreshRate</b> seconds
|
||||||
* @return true if the registration was successfull, false if it was already registered
|
* @return true if the registration was successfull, false if it was already registered
|
||||||
*/
|
*/
|
||||||
public static boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer) {
|
public static boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer) {
|
||||||
return BackendAPI.getImplementation().registerPlaceholder(plugin, textPlaceholder, refreshRate, replacer);
|
return BackendAPI.getImplementation().registerPlaceholder(plugin, textPlaceholder, refreshRate, replacer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all the placeholders registered by a given plugin.
|
* Finds all the placeholders registered by a given plugin.
|
||||||
*
|
*
|
||||||
* @param plugin the plugin to search for
|
* @param plugin the plugin to search for
|
||||||
* @return a collection of placeholders registered by the plugin
|
* @return a collection of placeholders registered by the plugin
|
||||||
*/
|
*/
|
||||||
public static Collection<String> getRegisteredPlaceholders(Plugin plugin) {
|
public static Collection<String> getRegisteredPlaceholders(Plugin plugin) {
|
||||||
return BackendAPI.getImplementation().getRegisteredPlaceholders(plugin);
|
return BackendAPI.getImplementation().getRegisteredPlaceholders(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregister a placeholder created by a plugin.
|
* Unregister a placeholder created by a plugin.
|
||||||
*
|
*
|
||||||
* @param plugin the plugin that owns the placeholder
|
* @param plugin the plugin that owns the placeholder
|
||||||
* @param textPlaceholder the placeholder to remove
|
* @param textPlaceholder the placeholder to remove
|
||||||
* @return true if found and removed, false otherwise
|
* @return true if found and removed, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder) {
|
public static boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder) {
|
||||||
return BackendAPI.getImplementation().unregisterPlaceholder(plugin, textPlaceholder);
|
return BackendAPI.getImplementation().unregisterPlaceholder(plugin, textPlaceholder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets and removes all the placeholders registered by a plugin. This is useful
|
* Resets and removes all the placeholders registered by a plugin. This is useful
|
||||||
* when you have configurable placeholders and you want to remove all of them.
|
* when you have configurable placeholders and you want to remove all of them.
|
||||||
*
|
*
|
||||||
* @param plugin the plugin that owns the placeholders
|
* @param plugin the plugin that owns the placeholders
|
||||||
*/
|
*/
|
||||||
public static void unregisterPlaceholders(Plugin plugin) {
|
public static void unregisterPlaceholders(Plugin plugin) {
|
||||||
BackendAPI.getImplementation().unregisterPlaceholders(plugin);
|
BackendAPI.getImplementation().unregisterPlaceholders(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if an entity is part of a hologram.
|
* Checks if an entity is part of a hologram.
|
||||||
*
|
*
|
||||||
* @param bukkitEntity the entity to check
|
* @param bukkitEntity the entity to check
|
||||||
* @return true if the entity is a part of a hologram
|
* @return true if the entity is a part of a hologram
|
||||||
*/
|
*/
|
||||||
public static boolean isHologramEntity(Entity bukkitEntity) {
|
public static boolean isHologramEntity(Entity bukkitEntity) {
|
||||||
return BackendAPI.getImplementation().isHologramEntity(bukkitEntity);
|
return BackendAPI.getImplementation().isHologramEntity(bukkitEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,59 +22,59 @@ import org.bukkit.entity.Player;
|
||||||
* (when a hologram is not specifically being hidden/shown to a player) can be customized.
|
* (when a hologram is not specifically being hidden/shown to a player) can be customized.
|
||||||
*/
|
*/
|
||||||
public interface VisibilityManager {
|
public interface VisibilityManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the hologram is visible by default. If not changed, this value
|
* Returns if the hologram is visible by default. If not changed, this value
|
||||||
* is true by default so the hologram is visible to everyone.
|
* is true by default so the hologram is visible to everyone.
|
||||||
*
|
*
|
||||||
* @return if the hologram hologram is visible by default
|
* @return if the hologram hologram is visible by default
|
||||||
*/
|
*/
|
||||||
public boolean isVisibleByDefault();
|
public boolean isVisibleByDefault();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets if the hologram is visible by default. If not changed, this value
|
* Sets if the hologram is visible by default. If not changed, this value
|
||||||
* is true by default so the hologram is visible to everyone.
|
* is true by default so the hologram is visible to everyone.
|
||||||
*
|
*
|
||||||
* @param visibleByDefault the new behaviour
|
* @param visibleByDefault the new behaviour
|
||||||
*/
|
*/
|
||||||
public void setVisibleByDefault(boolean visibleByDefault);
|
public void setVisibleByDefault(boolean visibleByDefault);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the hologram to a player, overriding the value of {@link #isVisibleByDefault()}.
|
* Shows the hologram to a player, overriding the value of {@link #isVisibleByDefault()}.
|
||||||
* This is persistent if the players goes offline.
|
* This is persistent if the players goes offline.
|
||||||
*
|
*
|
||||||
* @param player the involved player
|
* @param player the involved player
|
||||||
*/
|
*/
|
||||||
public void showTo(Player player);
|
public void showTo(Player player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hides the hologram to a player, overriding the value of {@link #isVisibleByDefault()}.
|
* Hides the hologram to a player, overriding the value of {@link #isVisibleByDefault()}.
|
||||||
* This is persistent if the players goes offline.
|
* This is persistent if the players goes offline.
|
||||||
*
|
*
|
||||||
* @param player the involved player
|
* @param player the involved player
|
||||||
*/
|
*/
|
||||||
public void hideTo(Player player);
|
public void hideTo(Player player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a hologram is visible to a player.
|
* Checks if a hologram is visible to a player.
|
||||||
*
|
*
|
||||||
* @param player the involved player
|
* @param player the involved player
|
||||||
* @return if the player can see the hologram
|
* @return if the player can see the hologram
|
||||||
*/
|
*/
|
||||||
public boolean isVisibleTo(Player player);
|
public boolean isVisibleTo(Player player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the visibility to the default value. If you previously called {@link #showTo(Player)}
|
* Resets the visibility to the default value. If you previously called {@link #showTo(Player)}
|
||||||
* or {@link #hideTo(Player)} to override the default visibility, this method will reset it
|
* or {@link #hideTo(Player)} to override the default visibility, this method will reset it
|
||||||
* to reflect the value of {@link #isVisibleByDefault()}.
|
* to reflect the value of {@link #isVisibleByDefault()}.
|
||||||
*
|
*
|
||||||
* @param player the involved player
|
* @param player the involved player
|
||||||
*/
|
*/
|
||||||
public void resetVisibility(Player player);
|
public void resetVisibility(Player player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the visibility for all the players. See {@link #resetVisibility(Player)} for more details.
|
* Resets the visibility for all the players. See {@link #resetVisibility(Player)} for more details.
|
||||||
*/
|
*/
|
||||||
public void resetVisibilityAll();
|
public void resetVisibilityAll();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,10 @@ import org.bukkit.entity.Player;
|
||||||
*/
|
*/
|
||||||
public interface PickupHandler {
|
public interface PickupHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player picks up the item.
|
* Called when a player picks up the item.
|
||||||
* @param player the player who picked up the item
|
* @param player the player who picked up the item
|
||||||
*/
|
*/
|
||||||
public void onPickup(Player player);
|
public void onPickup(Player player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,10 @@ import org.bukkit.entity.Player;
|
||||||
*/
|
*/
|
||||||
public interface TouchHandler {
|
public interface TouchHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player interacts with the hologram (right click).
|
* Called when a player interacts with the hologram (right click).
|
||||||
* @param player the player who interacts
|
* @param player the player who interacts
|
||||||
*/
|
*/
|
||||||
public void onTouch(Player player);
|
public void onTouch(Player player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,34 +23,34 @@ import org.bukkit.plugin.Plugin;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public abstract class BackendAPI {
|
public abstract class BackendAPI {
|
||||||
|
|
||||||
private static BackendAPI implementation;
|
private static BackendAPI implementation;
|
||||||
|
|
||||||
public static void setImplementation(BackendAPI implementation) {
|
public static void setImplementation(BackendAPI implementation) {
|
||||||
BackendAPI.implementation = implementation;
|
BackendAPI.implementation = implementation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BackendAPI getImplementation() {
|
public static BackendAPI getImplementation() {
|
||||||
if (implementation == null) {
|
if (implementation == null) {
|
||||||
throw new IllegalStateException("No API implementation set. Is Holographic Displays enabled?");
|
throw new IllegalStateException("No API implementation set. Is Holographic Displays enabled?");
|
||||||
}
|
}
|
||||||
|
|
||||||
return implementation;
|
return implementation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Hologram createHologram(Plugin plugin, Location source);
|
public abstract Hologram createHologram(Plugin plugin, Location source);
|
||||||
|
|
||||||
public abstract Collection<Hologram> getHolograms(Plugin plugin);
|
public abstract Collection<Hologram> getHolograms(Plugin plugin);
|
||||||
|
|
||||||
public abstract boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer);
|
public abstract boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer);
|
||||||
|
|
||||||
public abstract Collection<String> getRegisteredPlaceholders(Plugin plugin);
|
public abstract Collection<String> getRegisteredPlaceholders(Plugin plugin);
|
||||||
|
|
||||||
public abstract boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder);
|
public abstract boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder);
|
||||||
|
|
||||||
public abstract void unregisterPlaceholders(Plugin plugin);
|
public abstract void unregisterPlaceholders(Plugin plugin);
|
||||||
|
|
||||||
public abstract boolean isHologramEntity(Entity bukkitEntity);
|
public abstract boolean isHologramEntity(Entity bukkitEntity);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,19 +20,19 @@ import me.filoghost.holographicdisplays.api.handler.PickupHandler;
|
||||||
* A line of a Hologram that can be picked up.
|
* A line of a Hologram that can be picked up.
|
||||||
*/
|
*/
|
||||||
public interface CollectableLine extends HologramLine {
|
public interface CollectableLine extends HologramLine {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the PickupHandler for this line.
|
* Sets the PickupHandler for this line.
|
||||||
*
|
*
|
||||||
* @param pickupHandler the new PickupHandler, can be null.
|
* @param pickupHandler the new PickupHandler, can be null.
|
||||||
*/
|
*/
|
||||||
public void setPickupHandler(PickupHandler pickupHandler);
|
public void setPickupHandler(PickupHandler pickupHandler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current PickupHandler of this line.
|
* Returns the current PickupHandler of this line.
|
||||||
*
|
*
|
||||||
* @return the current PickupHandler, can be null.
|
* @return the current PickupHandler, can be null.
|
||||||
*/
|
*/
|
||||||
public PickupHandler getPickupHandler();
|
public PickupHandler getPickupHandler();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,18 +20,18 @@ import me.filoghost.holographicdisplays.api.Hologram;
|
||||||
* Interface to represent a line in a Hologram.
|
* Interface to represent a line in a Hologram.
|
||||||
*/
|
*/
|
||||||
public interface HologramLine {
|
public interface HologramLine {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the parent Hologram of this line.
|
* Returns the parent Hologram of this line.
|
||||||
*
|
*
|
||||||
* @return the parent Hologram.
|
* @return the parent Hologram.
|
||||||
*/
|
*/
|
||||||
public Hologram getParent();
|
public Hologram getParent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes this line from the parent Hologram. Since: v2.0.1
|
* 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.
|
* Do not call if the Hologram has been deleted, an exception will be thrown.
|
||||||
*/
|
*/
|
||||||
public void removeLine();
|
public void removeLine();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,18 +18,18 @@ import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public interface ItemLine extends CollectableLine, TouchableLine {
|
public interface ItemLine extends CollectableLine, TouchableLine {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ItemStack of this ItemLine.
|
* Returns the ItemStack of this ItemLine.
|
||||||
*
|
*
|
||||||
* @return the ItemStack if this ItemLine.
|
* @return the ItemStack if this ItemLine.
|
||||||
*/
|
*/
|
||||||
public ItemStack getItemStack();
|
public ItemStack getItemStack();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the ItemStack for this ItemLine.
|
* Sets the ItemStack for this ItemLine.
|
||||||
*
|
*
|
||||||
* @param itemStack the new item, should not be null.
|
* @param itemStack the new item, should not be null.
|
||||||
*/
|
*/
|
||||||
public void setItemStack(ItemStack itemStack);
|
public void setItemStack(ItemStack itemStack);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,18 +16,18 @@ package me.filoghost.holographicdisplays.api.line;
|
||||||
|
|
||||||
public interface TextLine extends TouchableLine {
|
public interface TextLine extends TouchableLine {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current text of this TextLine.
|
* Returns the current text of this TextLine.
|
||||||
*
|
*
|
||||||
* @return the current text of this line.
|
* @return the current text of this line.
|
||||||
*/
|
*/
|
||||||
public String getText();
|
public String getText();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the text of this TextLine.
|
* Sets the text of this TextLine.
|
||||||
*
|
*
|
||||||
* @param text the new text of this line.
|
* @param text the new text of this line.
|
||||||
*/
|
*/
|
||||||
public void setText(String text);
|
public void setText(String text);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,18 +21,18 @@ import me.filoghost.holographicdisplays.api.handler.TouchHandler;
|
||||||
*/
|
*/
|
||||||
public interface TouchableLine extends HologramLine {
|
public interface TouchableLine extends HologramLine {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the TouchHandler for this line.
|
* Sets the TouchHandler for this line.
|
||||||
*
|
*
|
||||||
* @param touchHandler the new TouchHandler, can be null.
|
* @param touchHandler the new TouchHandler, can be null.
|
||||||
*/
|
*/
|
||||||
public void setTouchHandler(TouchHandler touchHandler);
|
public void setTouchHandler(TouchHandler touchHandler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current TouchHandler of this line.
|
* Returns the current TouchHandler of this line.
|
||||||
*
|
*
|
||||||
* @return the current TouchHandler, can be null.
|
* @return the current TouchHandler, can be null.
|
||||||
*/
|
*/
|
||||||
public TouchHandler getTouchHandler();
|
public TouchHandler getTouchHandler();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,10 @@ package me.filoghost.holographicdisplays.api.placeholder;
|
||||||
|
|
||||||
public interface PlaceholderReplacer {
|
public interface PlaceholderReplacer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to update a placeholder's replacement.
|
* Called to update a placeholder's replacement.
|
||||||
* @return the replacement
|
* @return the replacement
|
||||||
*/
|
*/
|
||||||
public String update();
|
public String update();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||||
<artifactId>holographicdisplays-parent</artifactId>
|
<artifactId>holographicdisplays-parent</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>holographicdisplays-config</artifactId>
|
<artifactId>holographicdisplays-config</artifactId>
|
||||||
<name>HolographicDisplays Config</name>
|
<name>HolographicDisplays Config</name>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-utils</artifactId>
|
<artifactId>holographicdisplays-utils</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -18,39 +18,39 @@ import java.util.Arrays;
|
||||||
|
|
||||||
public enum ConfigNode {
|
public enum ConfigNode {
|
||||||
|
|
||||||
SPACE_BETWEEN_LINES("space-between-lines", 0.02),
|
SPACE_BETWEEN_LINES("space-between-lines", 0.02),
|
||||||
QUICK_EDIT_COMMANDS("quick-edit-commands", true),
|
QUICK_EDIT_COMMANDS("quick-edit-commands", true),
|
||||||
IMAGES_SYMBOL("images.symbol", "[x]"),
|
IMAGES_SYMBOL("images.symbol", "[x]"),
|
||||||
TRANSPARENCY_SPACE("images.transparency.space", " [|] "),
|
TRANSPARENCY_SPACE("images.transparency.space", " [|] "),
|
||||||
TRANSPARENCY_COLOR("images.transparency.color", "&7"),
|
TRANSPARENCY_COLOR("images.transparency.color", "&7"),
|
||||||
UPDATE_NOTIFICATION("update-notification", true),
|
UPDATE_NOTIFICATION("update-notification", true),
|
||||||
BUNGEE_REFRESH_SECONDS("bungee.refresh-seconds", 3),
|
BUNGEE_REFRESH_SECONDS("bungee.refresh-seconds", 3),
|
||||||
BUNGEE_USE_REDIS_BUNGEE("bungee.use-RedisBungee", false),
|
BUNGEE_USE_REDIS_BUNGEE("bungee.use-RedisBungee", false),
|
||||||
BUNGEE_USE_FULL_PINGER("bungee.pinger.enable", false),
|
BUNGEE_USE_FULL_PINGER("bungee.pinger.enable", false),
|
||||||
BUNGEE_PINGER_TIMEOUT("bungee.pinger.timeout", 500),
|
BUNGEE_PINGER_TIMEOUT("bungee.pinger.timeout", 500),
|
||||||
BUNGEE_PINGER_OFFLINE_MOTD("bungee.pinger.offline-motd", "&cOffline, couldn't get the MOTD."),
|
BUNGEE_PINGER_OFFLINE_MOTD("bungee.pinger.offline-motd", "&cOffline, couldn't get the MOTD."),
|
||||||
BUNGEE_PINGER_ONLINE_FORMAT("bungee.pinger.status.online", "&aOnline"),
|
BUNGEE_PINGER_ONLINE_FORMAT("bungee.pinger.status.online", "&aOnline"),
|
||||||
BUNGEE_PINGER_OFFLINE_FORMAT("bungee.pinger.status.offline", "&cOffline"),
|
BUNGEE_PINGER_OFFLINE_FORMAT("bungee.pinger.status.offline", "&cOffline"),
|
||||||
BUNGEE_PINGER_TRIM_MOTD("bungee.pinger.motd-remove-leading-trailing-spaces", true),
|
BUNGEE_PINGER_TRIM_MOTD("bungee.pinger.motd-remove-leading-trailing-spaces", true),
|
||||||
BUNGEE_PINGER_SERVERS("bungee.pinger.servers", Arrays.asList("hub: 127.0.0.1:25565", "survival: 127.0.0.1:25566", "minigames: 127.0.0.1:25567")),
|
BUNGEE_PINGER_SERVERS("bungee.pinger.servers", Arrays.asList("hub: 127.0.0.1:25565", "survival: 127.0.0.1:25566", "minigames: 127.0.0.1:25567")),
|
||||||
TIME_FORMAT("time.format", "H:mm"),
|
TIME_FORMAT("time.format", "H:mm"),
|
||||||
TIME_ZONE("time.zone", "GMT+1"),
|
TIME_ZONE("time.zone", "GMT+1"),
|
||||||
DEBUG("debug", false);
|
DEBUG("debug", false);
|
||||||
|
|
||||||
private final String path;
|
private final String path;
|
||||||
private final Object value;
|
private final Object value;
|
||||||
|
|
||||||
private ConfigNode(String path, Object defaultValue) {
|
private ConfigNode(String path, Object defaultValue) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
value = defaultValue;
|
value = defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getDefaultValue() {
|
public Object getDefaultValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,186 +35,186 @@ import java.util.logging.Level;
|
||||||
* Useful for fast access.
|
* Useful for fast access.
|
||||||
*/
|
*/
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
|
|
||||||
public static double spaceBetweenLines;
|
public static double spaceBetweenLines;
|
||||||
public static boolean quickEditCommands;
|
public static boolean quickEditCommands;
|
||||||
public static String imageSymbol;
|
public static String imageSymbol;
|
||||||
public static String transparencySymbol;
|
public static String transparencySymbol;
|
||||||
public static boolean updateNotification;
|
public static boolean updateNotification;
|
||||||
public static ChatColor transparencyColor;
|
public static ChatColor transparencyColor;
|
||||||
|
|
||||||
public static SimpleDateFormat timeFormat;
|
public static SimpleDateFormat timeFormat;
|
||||||
|
|
||||||
public static int bungeeRefreshSeconds;
|
public static int bungeeRefreshSeconds;
|
||||||
public static boolean useRedisBungee;
|
public static boolean useRedisBungee;
|
||||||
|
|
||||||
public static boolean pingerEnable;
|
public static boolean pingerEnable;
|
||||||
public static int pingerTimeout;
|
public static int pingerTimeout;
|
||||||
public static String pingerOfflineMotd;
|
public static String pingerOfflineMotd;
|
||||||
public static String pingerStatusOnline;
|
public static String pingerStatusOnline;
|
||||||
public static String pingerStatusOffline;
|
public static String pingerStatusOffline;
|
||||||
public static boolean pingerTrimMotd;
|
public static boolean pingerTrimMotd;
|
||||||
public static Map<String, ServerAddress> pingerServers;
|
public static Map<String, ServerAddress> pingerServers;
|
||||||
|
|
||||||
|
|
||||||
public static void load(Plugin plugin) {
|
public static void load(Plugin plugin) {
|
||||||
File configFile = new File(plugin.getDataFolder(), "config.yml");
|
File configFile = new File(plugin.getDataFolder(), "config.yml");
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
plugin.getDataFolder().mkdirs();
|
plugin.getDataFolder().mkdirs();
|
||||||
plugin.saveResource("config.yml", true);
|
plugin.saveResource("config.yml", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
try {
|
try {
|
||||||
config.load(configFile);
|
config.load(configFile);
|
||||||
} catch (InvalidConfigurationException e) {
|
} catch (InvalidConfigurationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
ConsoleLogger.log(Level.WARNING, "The configuration is not a valid YAML file! Please check it with a tool like http://yaml-online-parser.appspot.com/");
|
ConsoleLogger.log(Level.WARNING, "The configuration is not a valid YAML file! Please check it with a tool like http://yaml-online-parser.appspot.com/");
|
||||||
return;
|
return;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
ConsoleLogger.log(Level.WARNING, "I/O error while reading the configuration. Was the file in use?");
|
ConsoleLogger.log(Level.WARNING, "I/O error while reading the configuration. Was the file in use?");
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
ConsoleLogger.log(Level.WARNING, "Unhandled exception while reading the configuration!");
|
ConsoleLogger.log(Level.WARNING, "Unhandled exception while reading the configuration!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean needsSave = false;
|
boolean needsSave = false;
|
||||||
|
|
||||||
for (ConfigNode node : ConfigNode.values()) {
|
for (ConfigNode node : ConfigNode.values()) {
|
||||||
if (!config.isSet(node.getPath())) {
|
if (!config.isSet(node.getPath())) {
|
||||||
needsSave = true;
|
needsSave = true;
|
||||||
config.set(node.getPath(), node.getDefaultValue());
|
config.set(node.getPath(), node.getDefaultValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the old values.
|
// Check the old values.
|
||||||
List<String> nodesToRemove = Arrays.asList(
|
List<String> nodesToRemove = Arrays.asList(
|
||||||
"vertical-spacing",
|
"vertical-spacing",
|
||||||
"time-format",
|
"time-format",
|
||||||
"bungee-refresh-seconds",
|
"bungee-refresh-seconds",
|
||||||
"using-RedisBungee",
|
"using-RedisBungee",
|
||||||
"bungee-online-format",
|
"bungee-online-format",
|
||||||
"bungee-offline-format",
|
"bungee-offline-format",
|
||||||
"precise-hologram-movement"
|
"precise-hologram-movement"
|
||||||
);
|
);
|
||||||
|
|
||||||
for (String oldNode : nodesToRemove) {
|
for (String oldNode : nodesToRemove) {
|
||||||
if (config.isSet(oldNode)) {
|
if (config.isSet(oldNode)) {
|
||||||
config.set(oldNode, null);
|
config.set(oldNode, null);
|
||||||
needsSave = true;
|
needsSave = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (needsSave) {
|
if (needsSave) {
|
||||||
config.options().header(String.join("\n",
|
config.options().header(String.join("\n",
|
||||||
".",
|
".",
|
||||||
". Read the tutorial at: http://dev.bukkit.org/bukkit-plugins/holographic-displays/",
|
". Read the tutorial at: http://dev.bukkit.org/bukkit-plugins/holographic-displays/",
|
||||||
".",
|
".",
|
||||||
". Plugin created by filoghost.",
|
". Plugin created by filoghost.",
|
||||||
"."));
|
"."));
|
||||||
config.options().copyHeader(true);
|
config.options().copyHeader(true);
|
||||||
try {
|
try {
|
||||||
config.save(configFile);
|
config.save(configFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
ConsoleLogger.log(Level.WARNING, "I/O error while saving the configuration. Was the file in use?");
|
ConsoleLogger.log(Level.WARNING, "I/O error while saving the configuration. Was the file in use?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spaceBetweenLines = config.getDouble(ConfigNode.SPACE_BETWEEN_LINES.getPath());
|
spaceBetweenLines = config.getDouble(ConfigNode.SPACE_BETWEEN_LINES.getPath());
|
||||||
quickEditCommands = config.getBoolean(ConfigNode.QUICK_EDIT_COMMANDS.getPath());
|
quickEditCommands = config.getBoolean(ConfigNode.QUICK_EDIT_COMMANDS.getPath());
|
||||||
|
|
||||||
updateNotification = config.getBoolean(ConfigNode.UPDATE_NOTIFICATION.getPath());
|
updateNotification = config.getBoolean(ConfigNode.UPDATE_NOTIFICATION.getPath());
|
||||||
|
|
||||||
imageSymbol = StringConverter.toReadableFormat(config.getString(ConfigNode.IMAGES_SYMBOL.getPath()));
|
imageSymbol = StringConverter.toReadableFormat(config.getString(ConfigNode.IMAGES_SYMBOL.getPath()));
|
||||||
transparencySymbol = StringConverter.toReadableFormat(config.getString(ConfigNode.TRANSPARENCY_SPACE.getPath()));
|
transparencySymbol = StringConverter.toReadableFormat(config.getString(ConfigNode.TRANSPARENCY_SPACE.getPath()));
|
||||||
bungeeRefreshSeconds = config.getInt(ConfigNode.BUNGEE_REFRESH_SECONDS.getPath());
|
bungeeRefreshSeconds = config.getInt(ConfigNode.BUNGEE_REFRESH_SECONDS.getPath());
|
||||||
useRedisBungee = config.getBoolean(ConfigNode.BUNGEE_USE_REDIS_BUNGEE.getPath());
|
useRedisBungee = config.getBoolean(ConfigNode.BUNGEE_USE_REDIS_BUNGEE.getPath());
|
||||||
|
|
||||||
pingerEnable = config.getBoolean(ConfigNode.BUNGEE_USE_FULL_PINGER.getPath());
|
pingerEnable = config.getBoolean(ConfigNode.BUNGEE_USE_FULL_PINGER.getPath());
|
||||||
pingerTimeout = config.getInt(ConfigNode.BUNGEE_PINGER_TIMEOUT.getPath());
|
pingerTimeout = config.getInt(ConfigNode.BUNGEE_PINGER_TIMEOUT.getPath());
|
||||||
pingerTrimMotd = config.getBoolean(ConfigNode.BUNGEE_PINGER_TRIM_MOTD.getPath());
|
pingerTrimMotd = config.getBoolean(ConfigNode.BUNGEE_PINGER_TRIM_MOTD.getPath());
|
||||||
|
|
||||||
pingerOfflineMotd = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_OFFLINE_MOTD.getPath()));
|
pingerOfflineMotd = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_OFFLINE_MOTD.getPath()));
|
||||||
pingerStatusOnline = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_ONLINE_FORMAT.getPath()));
|
pingerStatusOnline = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_ONLINE_FORMAT.getPath()));
|
||||||
pingerStatusOffline = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_OFFLINE_FORMAT.getPath()));
|
pingerStatusOffline = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_OFFLINE_FORMAT.getPath()));
|
||||||
|
|
||||||
if (pingerTimeout <= 0) {
|
if (pingerTimeout <= 0) {
|
||||||
pingerTimeout = 100;
|
pingerTimeout = 100;
|
||||||
} else if (pingerTimeout >= 10000) {
|
} else if (pingerTimeout >= 10000) {
|
||||||
pingerTimeout = 10000;
|
pingerTimeout = 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
pingerServers = new HashMap<>();
|
pingerServers = new HashMap<>();
|
||||||
|
|
||||||
if (pingerEnable) {
|
if (pingerEnable) {
|
||||||
for (String singleServer : config.getStringList(ConfigNode.BUNGEE_PINGER_SERVERS.getPath())) {
|
for (String singleServer : config.getStringList(ConfigNode.BUNGEE_PINGER_SERVERS.getPath())) {
|
||||||
String[] nameAndAddress = singleServer.split(":", 2);
|
String[] nameAndAddress = singleServer.split(":", 2);
|
||||||
if (nameAndAddress.length < 2) {
|
if (nameAndAddress.length < 2) {
|
||||||
ConsoleLogger.log(Level.WARNING, "The server info \"" + singleServer + "\" is not valid. There should be a name and an address, separated by a colon.");
|
ConsoleLogger.log(Level.WARNING, "The server info \"" + singleServer + "\" is not valid. There should be a name and an address, separated by a colon.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = nameAndAddress[0].trim();
|
String name = nameAndAddress[0].trim();
|
||||||
String address = nameAndAddress[1].replace(" ", "");
|
String address = nameAndAddress[1].replace(" ", "");
|
||||||
|
|
||||||
String ip;
|
String ip;
|
||||||
int port;
|
int port;
|
||||||
|
|
||||||
if (address.contains(":")) {
|
if (address.contains(":")) {
|
||||||
String[] ipAndPort = address.split(":", 2);
|
String[] ipAndPort = address.split(":", 2);
|
||||||
ip = ipAndPort[0];
|
ip = ipAndPort[0];
|
||||||
try {
|
try {
|
||||||
port = Integer.parseInt(ipAndPort[1]);
|
port = Integer.parseInt(ipAndPort[1]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
ConsoleLogger.log(Level.WARNING, "Invalid port number in the server info \"" + singleServer + "\".");
|
ConsoleLogger.log(Level.WARNING, "Invalid port number in the server info \"" + singleServer + "\".");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ip = address;
|
ip = address;
|
||||||
port = 25565; // The default Minecraft port.
|
port = 25565; // The default Minecraft port.
|
||||||
}
|
}
|
||||||
|
|
||||||
pingerServers.put(name, new ServerAddress(ip, port));
|
pingerServers.put(name, new ServerAddress(ip, port));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleLogger.setDebugEnabled(config.getBoolean(ConfigNode.DEBUG.getPath()));
|
ConsoleLogger.setDebugEnabled(config.getBoolean(ConfigNode.DEBUG.getPath()));
|
||||||
|
|
||||||
String tempColor = config.getString(ConfigNode.TRANSPARENCY_COLOR.getPath()).replace('&', ChatColor.COLOR_CHAR);
|
String tempColor = config.getString(ConfigNode.TRANSPARENCY_COLOR.getPath()).replace('&', ChatColor.COLOR_CHAR);
|
||||||
boolean foundColor = false;
|
boolean foundColor = false;
|
||||||
for (ChatColor chatColor : ChatColor.values()) {
|
for (ChatColor chatColor : ChatColor.values()) {
|
||||||
if (chatColor.toString().equals(tempColor)) {
|
if (chatColor.toString().equals(tempColor)) {
|
||||||
Configuration.transparencyColor = chatColor;
|
Configuration.transparencyColor = chatColor;
|
||||||
foundColor = true;
|
foundColor = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!foundColor) {
|
if (!foundColor) {
|
||||||
Configuration.transparencyColor = ChatColor.GRAY;
|
Configuration.transparencyColor = ChatColor.GRAY;
|
||||||
ConsoleLogger.log(Level.WARNING, "You didn't set a valid chat color for transparency in the configuration, light gray (&7) will be used.");
|
ConsoleLogger.log(Level.WARNING, "You didn't set a valid chat color for transparency in the configuration, light gray (&7) will be used.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
timeFormat = new SimpleDateFormat(config.getString(ConfigNode.TIME_FORMAT.getPath()));
|
timeFormat = new SimpleDateFormat(config.getString(ConfigNode.TIME_FORMAT.getPath()));
|
||||||
timeFormat.setTimeZone(TimeZone.getTimeZone(config.getString(ConfigNode.TIME_ZONE.getPath())));
|
timeFormat.setTimeZone(TimeZone.getTimeZone(config.getString(ConfigNode.TIME_ZONE.getPath())));
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
timeFormat = new SimpleDateFormat("H:mm");
|
timeFormat = new SimpleDateFormat("H:mm");
|
||||||
ConsoleLogger.log(Level.WARNING, "Time format not valid in the configuration, using the default.");
|
ConsoleLogger.log(Level.WARNING, "Time format not valid in the configuration, using the default.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bungeeRefreshSeconds < 1) {
|
if (bungeeRefreshSeconds < 1) {
|
||||||
ConsoleLogger.log(Level.WARNING, "The minimum interval for pinging BungeeCord's servers is 1 second. It has been automatically set.");
|
ConsoleLogger.log(Level.WARNING, "The minimum interval for pinging BungeeCord's servers is 1 second. It has been automatically set.");
|
||||||
bungeeRefreshSeconds = 1;
|
bungeeRefreshSeconds = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bungeeRefreshSeconds > 60) {
|
if (bungeeRefreshSeconds > 60) {
|
||||||
ConsoleLogger.log(Level.WARNING, "The maximum interval for pinging BungeeCord's servers is 60 seconds. It has been automatically set.");
|
ConsoleLogger.log(Level.WARNING, "The maximum interval for pinging BungeeCord's servers is 60 seconds. It has been automatically set.");
|
||||||
bungeeRefreshSeconds = 60;
|
bungeeRefreshSeconds = 60;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,38 +25,38 @@ import java.text.DecimalFormatSymbols;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class LocationSerializer {
|
public class LocationSerializer {
|
||||||
|
|
||||||
private static DecimalFormat numberFormat = new DecimalFormat("0.000", DecimalFormatSymbols.getInstance(Locale.ROOT));
|
private static DecimalFormat numberFormat = new DecimalFormat("0.000", DecimalFormatSymbols.getInstance(Locale.ROOT));
|
||||||
|
|
||||||
public static Location locationFromString(String input) throws WorldNotFoundException, InvalidFormatException {
|
public static Location locationFromString(String input) throws WorldNotFoundException, InvalidFormatException {
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
throw new InvalidFormatException();
|
throw new InvalidFormatException();
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] parts = input.split(",");
|
String[] parts = input.split(",");
|
||||||
|
|
||||||
if (parts.length != 4) {
|
if (parts.length != 4) {
|
||||||
throw new InvalidFormatException();
|
throw new InvalidFormatException();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
double x = Double.parseDouble(parts[1].replace(" ", ""));
|
double x = Double.parseDouble(parts[1].replace(" ", ""));
|
||||||
double y = Double.parseDouble(parts[2].replace(" ", ""));
|
double y = Double.parseDouble(parts[2].replace(" ", ""));
|
||||||
double z = Double.parseDouble(parts[3].replace(" ", ""));
|
double z = Double.parseDouble(parts[3].replace(" ", ""));
|
||||||
|
|
||||||
World world = Bukkit.getWorld(parts[0].trim());
|
World world = Bukkit.getWorld(parts[0].trim());
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
throw new WorldNotFoundException(parts[0].trim());
|
throw new WorldNotFoundException(parts[0].trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Location(world, x, y, z);
|
return new Location(world, x, y, z);
|
||||||
|
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
throw new InvalidFormatException();
|
throw new InvalidFormatException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String locationToString(Location loc) {
|
public static String locationToString(Location loc) {
|
||||||
return (loc.getWorld().getName() + ", " + numberFormat.format(loc.getX()) + ", " + numberFormat.format(loc.getY()) + ", " + numberFormat.format(loc.getZ()));
|
return (loc.getWorld().getName() + ", " + numberFormat.format(loc.getX()) + ", " + numberFormat.format(loc.getY()) + ", " + numberFormat.format(loc.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,26 +15,26 @@
|
||||||
package me.filoghost.holographicdisplays.disk;
|
package me.filoghost.holographicdisplays.disk;
|
||||||
|
|
||||||
public class ServerAddress {
|
public class ServerAddress {
|
||||||
|
|
||||||
private String ip;
|
private String ip;
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
public ServerAddress(String ip, int port) {
|
public ServerAddress(String ip, int port) {
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAddress() {
|
public String getAddress() {
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPort() {
|
public int getPort() {
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return ip + ":" + port;
|
return ip + ":" + port;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,80 +19,80 @@ import org.bukkit.ChatColor;
|
||||||
|
|
||||||
public class StringConverter {
|
public class StringConverter {
|
||||||
|
|
||||||
private static final boolean HEX_CHAT_COLORS_ENABLED = Utils.classExists("org.bukkit.entity.Strider");
|
private static final boolean HEX_CHAT_COLORS_ENABLED = Utils.classExists("org.bukkit.entity.Strider");
|
||||||
private static final int HEX_COLOR_LENGTH = 6;
|
private static final int HEX_COLOR_LENGTH = 6;
|
||||||
|
|
||||||
public static String toReadableFormat(String input) {
|
public static String toReadableFormat(String input) {
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
input = UnicodeSymbols.placeholdersToSymbols(input);
|
input = UnicodeSymbols.placeholdersToSymbols(input);
|
||||||
input = addColors(input);
|
input = addColors(input);
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String addColors(String input) {
|
public static String addColors(String input) {
|
||||||
if (!input.contains("&")) {
|
if (!input.contains("&")) {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder output = new StringBuilder(input.length());
|
StringBuilder output = new StringBuilder(input.length());
|
||||||
|
|
||||||
for (int i = 0; i < input.length(); i++) {
|
for (int i = 0; i < input.length(); i++) {
|
||||||
char current = input.charAt(i);
|
char current = input.charAt(i);
|
||||||
|
|
||||||
if (current == '&' && i + 1 < input.length()) {
|
if (current == '&' && i + 1 < input.length()) {
|
||||||
char next = input.charAt(i + 1);
|
char next = input.charAt(i + 1);
|
||||||
|
|
||||||
if (next == '#' && HEX_CHAT_COLORS_ENABLED && isValidHexColor(input, i + 2)) {
|
if (next == '#' && HEX_CHAT_COLORS_ENABLED && isValidHexColor(input, i + 2)) {
|
||||||
output.append(ChatColor.COLOR_CHAR);
|
output.append(ChatColor.COLOR_CHAR);
|
||||||
output.append('x');
|
output.append('x');
|
||||||
|
|
||||||
for (int j = 0; j < HEX_COLOR_LENGTH; j++) {
|
for (int j = 0; j < HEX_COLOR_LENGTH; j++) {
|
||||||
output.append(ChatColor.COLOR_CHAR);
|
output.append(ChatColor.COLOR_CHAR);
|
||||||
output.append(Character.toLowerCase(input.charAt(i + 2 + j)));
|
output.append(Character.toLowerCase(input.charAt(i + 2 + j)));
|
||||||
}
|
}
|
||||||
|
|
||||||
i += 1 + HEX_COLOR_LENGTH; // Skip '#' and hex string, which are already converted and added
|
i += 1 + HEX_COLOR_LENGTH; // Skip '#' and hex string, which are already converted and added
|
||||||
|
|
||||||
} else if (isColorCode(next)) {
|
} else if (isColorCode(next)) {
|
||||||
output.append(ChatColor.COLOR_CHAR);
|
output.append(ChatColor.COLOR_CHAR);
|
||||||
output.append(Character.toLowerCase(next));
|
output.append(Character.toLowerCase(next));
|
||||||
|
|
||||||
i++; // Skip next character, which is already added
|
i++; // Skip next character, which is already added
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
output.append(current);
|
output.append(current);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
output.append(current);
|
output.append(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isValidHexColor(String input, int startIndex) {
|
private static boolean isValidHexColor(String input, int startIndex) {
|
||||||
if (input.length() - startIndex < HEX_COLOR_LENGTH) {
|
if (input.length() - startIndex < HEX_COLOR_LENGTH) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < HEX_COLOR_LENGTH; i++) {
|
for (int i = 0; i < HEX_COLOR_LENGTH; i++) {
|
||||||
if (!isHexCode(input.charAt(startIndex + i))) {
|
if (!isHexCode(input.charAt(startIndex + i))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isHexCode(char c) {
|
private static boolean isHexCode(char c) {
|
||||||
return "0123456789AaBbCcDdEeFf".indexOf(c) > -1;
|
return "0123456789AaBbCcDdEeFf".indexOf(c) > -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isColorCode(char c) {
|
private static boolean isColorCode(char c) {
|
||||||
return "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(c) > -1;
|
return "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(c) > -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,79 +29,79 @@ import java.util.logging.Level;
|
||||||
|
|
||||||
public class UnicodeSymbols {
|
public class UnicodeSymbols {
|
||||||
|
|
||||||
private static Map<String, String> placeholders = new HashMap<>();
|
private static Map<String, String> placeholders = new HashMap<>();
|
||||||
|
|
||||||
public static void load(Plugin plugin) {
|
public static void load(Plugin plugin) {
|
||||||
placeholders.clear();
|
placeholders.clear();
|
||||||
|
|
||||||
File file = new File(plugin.getDataFolder(), "symbols.yml");
|
File file = new File(plugin.getDataFolder(), "symbols.yml");
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
plugin.getDataFolder().mkdirs();
|
plugin.getDataFolder().mkdirs();
|
||||||
plugin.saveResource("symbols.yml", true);
|
plugin.saveResource("symbols.yml", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> lines;
|
List<String> lines;
|
||||||
try {
|
try {
|
||||||
lines = FileUtils.readLines(file);
|
lines = FileUtils.readLines(file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ConsoleLogger.log(Level.WARNING, "I/O error while reading symbols.yml. Was the file in use?", e);
|
ConsoleLogger.log(Level.WARNING, "I/O error while reading symbols.yml. Was the file in use?", e);
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsoleLogger.log(Level.WARNING, "Unhandled exception while reading symbols.yml!", e);
|
ConsoleLogger.log(Level.WARNING, "Unhandled exception while reading symbols.yml!", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
|
|
||||||
// Comment or empty line.
|
// Comment or empty line.
|
||||||
if (line.length() == 0 || line.startsWith("#")) {
|
if (line.length() == 0 || line.startsWith("#")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!line.contains(":")) {
|
if (!line.contains(":")) {
|
||||||
ConsoleLogger.log(Level.WARNING, "Unable to parse a line(" + line + ") from symbols.yml: it must contain ':' to separate the placeholder and the replacement.");
|
ConsoleLogger.log(Level.WARNING, "Unable to parse a line(" + line + ") from symbols.yml: it must contain ':' to separate the placeholder and the replacement.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int indexOf = line.indexOf(':');
|
int indexOf = line.indexOf(':');
|
||||||
String placeholder = unquote(line.substring(0, indexOf).trim());
|
String placeholder = unquote(line.substring(0, indexOf).trim());
|
||||||
String replacement = StringEscapeUtils.unescapeJava(unquote(line.substring(indexOf + 1, line.length()).trim()));
|
String replacement = StringEscapeUtils.unescapeJava(unquote(line.substring(indexOf + 1, line.length()).trim()));
|
||||||
|
|
||||||
if (placeholder.isEmpty() || replacement.isEmpty()) {
|
if (placeholder.isEmpty() || replacement.isEmpty()) {
|
||||||
ConsoleLogger.log(Level.WARNING, "Unable to parse a line(" + line + ") from symbols.yml: the placeholder and the replacement must have both at least 1 character.");
|
ConsoleLogger.log(Level.WARNING, "Unable to parse a line(" + line + ") from symbols.yml: the placeholder and the replacement must have both at least 1 character.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (placeholder.length() > 30) {
|
if (placeholder.length() > 30) {
|
||||||
ConsoleLogger.log(Level.WARNING, "Unable to parse a line(" + line + ") from symbols.yml: the placeholder cannot be longer than 30 characters.");
|
ConsoleLogger.log(Level.WARNING, "Unable to parse a line(" + line + ") from symbols.yml: the placeholder cannot be longer than 30 characters.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
placeholders.put(placeholder, replacement);
|
placeholders.put(placeholder, replacement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static String placeholdersToSymbols(String input) {
|
protected static String placeholdersToSymbols(String input) {
|
||||||
for (Entry<String, String> entry : placeholders.entrySet()) {
|
for (Entry<String, String> entry : placeholders.entrySet()) {
|
||||||
input = input.replace(entry.getKey(), entry.getValue());
|
input = input.replace(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String unquote(String input) {
|
private static String unquote(String input) {
|
||||||
if (input.length() < 2) {
|
if (input.length() < 2) {
|
||||||
// Cannot be quoted.
|
// Cannot be quoted.
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
if (input.startsWith("'") && input.endsWith("'")) {
|
if (input.startsWith("'") && input.endsWith("'")) {
|
||||||
return input.substring(1, input.length() - 1);
|
return input.substring(1, input.length() - 1);
|
||||||
} else if (input.startsWith("\"") && input.endsWith("\"")) {
|
} else if (input.startsWith("\"") && input.endsWith("\"")) {
|
||||||
return input.substring(1, input.length() - 1);
|
return input.substring(1, input.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,6 @@ package me.filoghost.holographicdisplays.exception;
|
||||||
|
|
||||||
public class InvalidFormatException extends Exception {
|
public class InvalidFormatException extends Exception {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,10 @@ package me.filoghost.holographicdisplays.exception;
|
||||||
|
|
||||||
public class WorldNotFoundException extends Exception {
|
public class WorldNotFoundException extends Exception {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public WorldNotFoundException(String message) {
|
public WorldNotFoundException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||||
<artifactId>holographicdisplays-example</artifactId>
|
<artifactId>holographicdisplays-example</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>holographicdisplays-example-deathholograms</artifactId>
|
<artifactId>holographicdisplays-example-deathholograms</artifactId>
|
||||||
<name>HolographicDisplays Example DeathHolograms</name>
|
<name>HolographicDisplays Example DeathHolograms</name>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -27,28 +27,28 @@ import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class DeathHolograms extends JavaPlugin implements Listener {
|
public class DeathHolograms extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
||||||
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
|
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
|
||||||
getLogger().severe("*** This plugin will be disabled. ***");
|
getLogger().severe("*** This plugin will be disabled. ***");
|
||||||
this.setEnabled(false);
|
this.setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
|
|
||||||
Hologram hologram = HologramsAPI.createHologram(this, event.getEntity().getEyeLocation());
|
Hologram hologram = HologramsAPI.createHologram(this, event.getEntity().getEyeLocation());
|
||||||
|
|
||||||
hologram.appendTextLine(ChatColor.RED + "Player " + ChatColor.GOLD + event.getEntity().getName() + ChatColor.RED + " died here!");
|
hologram.appendTextLine(ChatColor.RED + "Player " + ChatColor.GOLD + event.getEntity().getName() + ChatColor.RED + " died here!");
|
||||||
hologram.appendTextLine(ChatColor.GRAY + "Time of death: " + new SimpleDateFormat("H:m").format(new Date()));
|
hologram.appendTextLine(ChatColor.GRAY + "Time of death: " + new SimpleDateFormat("H:m").format(new Date()));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||||
<artifactId>holographicdisplays-parent</artifactId>
|
<artifactId>holographicdisplays-parent</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>holographicdisplays-example</artifactId>
|
<artifactId>holographicdisplays-example</artifactId>
|
||||||
<name>HolographicDisplays Example</name>
|
<name>HolographicDisplays Example</name>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>death-holograms</module>
|
<module>death-holograms</module>
|
||||||
<module>power-ups</module>
|
<module>power-ups</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-api</artifactId>
|
<artifactId>holographicdisplays-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||||
<artifactId>holographicdisplays-example</artifactId>
|
<artifactId>holographicdisplays-example</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>holographicdisplays-example-powerups</artifactId>
|
<artifactId>holographicdisplays-example-powerups</artifactId>
|
||||||
<name>HolographicDisplays Example PowerUps</name>
|
<name>HolographicDisplays Example PowerUps</name>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -33,53 +33,53 @@ import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
public class PowerUps extends JavaPlugin implements Listener {
|
public class PowerUps extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
||||||
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
|
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
|
||||||
getLogger().severe("*** This plugin will be disabled. ***");
|
getLogger().severe("*** This plugin will be disabled. ***");
|
||||||
this.setEnabled(false);
|
this.setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
|
|
||||||
if (event.getEntityType() == EntityType.ZOMBIE) {
|
if (event.getEntityType() == EntityType.ZOMBIE) {
|
||||||
|
|
||||||
// Remove normal drops and exp.
|
// Remove normal drops and exp.
|
||||||
event.getDrops().clear();
|
event.getDrops().clear();
|
||||||
event.setDroppedExp(0);
|
event.setDroppedExp(0);
|
||||||
|
|
||||||
// Spawn the floating item with a label.
|
// Spawn the floating item with a label.
|
||||||
final Hologram hologram = HologramsAPI.createHologram(this, event.getEntity().getLocation().add(0.0, 0.9, 0.0));
|
final Hologram hologram = HologramsAPI.createHologram(this, event.getEntity().getLocation().add(0.0, 0.9, 0.0));
|
||||||
hologram.appendTextLine(ChatColor.AQUA + "" + ChatColor.BOLD + "Speed PowerUp");
|
hologram.appendTextLine(ChatColor.AQUA + "" + ChatColor.BOLD + "Speed PowerUp");
|
||||||
ItemLine icon = hologram.appendItemLine(new ItemStack(Material.SUGAR));
|
ItemLine icon = hologram.appendItemLine(new ItemStack(Material.SUGAR));
|
||||||
|
|
||||||
icon.setPickupHandler(new PickupHandler() {
|
icon.setPickupHandler(new PickupHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickup(Player player) {
|
public void onPickup(Player player) {
|
||||||
|
|
||||||
// Play an effect.
|
// Play an effect.
|
||||||
player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null);
|
player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null);
|
||||||
|
|
||||||
// 30 seconds of speed II.
|
// 30 seconds of speed II.
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 1), true);
|
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 1), true);
|
||||||
|
|
||||||
// Delete the hologram.
|
// Delete the hologram.
|
||||||
hologram.delete();
|
hologram.delete();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||||
<artifactId>holographicdisplays-parent</artifactId>
|
<artifactId>holographicdisplays-parent</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>holographicdisplays-legacy-v1</artifactId>
|
<artifactId>holographicdisplays-legacy-v1</artifactId>
|
||||||
<name>HolographicDisplays Legacy v1</name>
|
<name>HolographicDisplays Legacy v1</name>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-api</artifactId>
|
<artifactId>holographicdisplays-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-utils</artifactId>
|
<artifactId>holographicdisplays-utils</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -24,60 +24,60 @@ import org.bukkit.inventory.ItemStack;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface FloatingItem {
|
public interface FloatingItem {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean update();
|
public boolean update();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void hide();
|
public void hide();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setItemStack(ItemStack itemstack);
|
public void setItemStack(ItemStack itemstack);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ItemStack getItemStack();
|
public ItemStack getItemStack();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Location getLocation();
|
public Location getLocation();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public double getX();
|
public double getX();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public double getY();
|
public double getY();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public double getZ();
|
public double getZ();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public World getWorld();
|
public World getWorld();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void teleport(Location location);
|
public void teleport(Location location);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTouchHandler(ItemTouchHandler handler);
|
public void setTouchHandler(ItemTouchHandler handler);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ItemTouchHandler getTouchHandler();
|
public ItemTouchHandler getTouchHandler();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean hasTouchHandler();
|
public boolean hasTouchHandler();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setPickupHandler(PickupHandler handler);
|
public void setPickupHandler(PickupHandler handler);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public PickupHandler getPickupHandler();
|
public PickupHandler getPickupHandler();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean hasPickupHandler();
|
public boolean hasPickupHandler();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public long getCreationTimestamp();
|
public long getCreationTimestamp();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void delete();
|
public void delete();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean isDeleted();
|
public boolean isDeleted();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,70 +23,70 @@ import org.bukkit.World;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface Hologram {
|
public interface Hologram {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean update();
|
public boolean update();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void hide();
|
public void hide();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void addLine(String text);
|
public void addLine(String text);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void removeLine(int index);
|
public void removeLine(int index);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setLine(int index, String text);
|
public void setLine(int index, String text);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void insertLine(int index, String text);
|
public void insertLine(int index, String text);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String[] getLines();
|
public String[] getLines();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int getLinesLength();
|
public int getLinesLength();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void clearLines();
|
public void clearLines();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Location getLocation();
|
public Location getLocation();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public double getX();
|
public double getX();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public double getY();
|
public double getY();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public double getZ();
|
public double getZ();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public World getWorld();
|
public World getWorld();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setLocation(Location location);
|
public void setLocation(Location location);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void teleport(Location location);
|
public void teleport(Location location);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTouchHandler(TouchHandler handler);
|
public void setTouchHandler(TouchHandler handler);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public TouchHandler getTouchHandler();
|
public TouchHandler getTouchHandler();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean hasTouchHandler();
|
public boolean hasTouchHandler();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public long getCreationTimestamp();
|
public long getCreationTimestamp();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void delete();
|
public void delete();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean isDeleted();
|
public boolean isDeleted();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,128 +40,128 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class HolographicDisplaysAPI {
|
public class HolographicDisplaysAPI {
|
||||||
|
|
||||||
private static Set<String> notifiedPlugins = new HashSet<>();
|
private static Set<String> notifiedPlugins = new HashSet<>();
|
||||||
|
|
||||||
private static void notifyOldAPI(Plugin plugin) {
|
private static void notifyOldAPI(Plugin plugin) {
|
||||||
Validator.notNull(plugin, "plugin");
|
Validator.notNull(plugin, "plugin");
|
||||||
|
|
||||||
if (notifiedPlugins.add(plugin.getName())) {
|
if (notifiedPlugins.add(plugin.getName())) {
|
||||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Holographic Displays] The plugin \"" + plugin.getName() + "\" is still using the old API of Holographic Displays. "
|
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Holographic Displays] The plugin \"" + plugin.getName() + "\" is still using the old API of Holographic Displays. "
|
||||||
+ "Please notify the author and ask them to update it, the old API will be removed soon.");
|
+ "Please notify the author and ask them to update it, the old API will be removed soon.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Hologram createHologram(Plugin plugin, Location source, String... lines) {
|
public static Hologram createHologram(Plugin plugin, Location source, String... lines) {
|
||||||
notifyOldAPI(plugin);
|
notifyOldAPI(plugin);
|
||||||
|
|
||||||
validateLocation(source);
|
validateLocation(source);
|
||||||
|
|
||||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
hologram.appendTextLine(line);
|
hologram.appendTextLine(line);
|
||||||
}
|
}
|
||||||
return new HologramAdapter(plugin, hologram);
|
return new HologramAdapter(plugin, hologram);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static FloatingItem createFloatingItem(Plugin plugin, Location source, ItemStack itemstack) {
|
public static FloatingItem createFloatingItem(Plugin plugin, Location source, ItemStack itemstack) {
|
||||||
notifyOldAPI(plugin);
|
notifyOldAPI(plugin);
|
||||||
|
|
||||||
validateLocation(source);
|
validateLocation(source);
|
||||||
validateItem(itemstack);
|
validateItem(itemstack);
|
||||||
|
|
||||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||||
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
||||||
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, Player whoCanSee, String... lines) {
|
public static Hologram createIndividualHologram(Plugin plugin, Location source, Player whoCanSee, String... lines) {
|
||||||
notifyOldAPI(plugin);
|
notifyOldAPI(plugin);
|
||||||
|
|
||||||
return createIndividualHologram(plugin, source, Arrays.asList(whoCanSee), lines);
|
return createIndividualHologram(plugin, source, Arrays.asList(whoCanSee), lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, List<Player> whoCanSee, String... lines) {
|
public static Hologram createIndividualHologram(Plugin plugin, Location source, List<Player> whoCanSee, String... lines) {
|
||||||
notifyOldAPI(plugin);
|
notifyOldAPI(plugin);
|
||||||
|
|
||||||
validateLocation(source);
|
validateLocation(source);
|
||||||
|
|
||||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||||
|
|
||||||
hologram.getVisibilityManager().setVisibleByDefault(false);
|
hologram.getVisibilityManager().setVisibleByDefault(false);
|
||||||
if (whoCanSee != null) {
|
if (whoCanSee != null) {
|
||||||
for (Player player : whoCanSee) {
|
for (Player player : whoCanSee) {
|
||||||
hologram.getVisibilityManager().showTo(player);
|
hologram.getVisibilityManager().showTo(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
hologram.appendTextLine(line);
|
hologram.appendTextLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HologramAdapter(plugin, hologram);
|
return new HologramAdapter(plugin, hologram);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, Player whoCanSee, ItemStack itemstack) {
|
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, Player whoCanSee, ItemStack itemstack) {
|
||||||
notifyOldAPI(plugin);
|
notifyOldAPI(plugin);
|
||||||
|
|
||||||
return createIndividualFloatingItem(plugin, source, Arrays.asList(whoCanSee), itemstack);
|
return createIndividualFloatingItem(plugin, source, Arrays.asList(whoCanSee), itemstack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, List<Player> whoCanSee, ItemStack itemstack) {
|
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, List<Player> whoCanSee, ItemStack itemstack) {
|
||||||
notifyOldAPI(plugin);
|
notifyOldAPI(plugin);
|
||||||
|
|
||||||
validateLocation(source);
|
validateLocation(source);
|
||||||
validateItem(itemstack);
|
validateItem(itemstack);
|
||||||
|
|
||||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||||
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
||||||
|
|
||||||
hologram.getVisibilityManager().setVisibleByDefault(false);
|
hologram.getVisibilityManager().setVisibleByDefault(false);
|
||||||
if (whoCanSee != null) {
|
if (whoCanSee != null) {
|
||||||
for (Player player : whoCanSee) {
|
for (Player player : whoCanSee) {
|
||||||
hologram.getVisibilityManager().showTo(player);
|
hologram.getVisibilityManager().showTo(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Hologram[] getHolograms(Plugin plugin) {
|
public static Hologram[] getHolograms(Plugin plugin) {
|
||||||
notifyOldAPI(plugin);
|
notifyOldAPI(plugin);
|
||||||
|
|
||||||
Collection<HologramAdapter> pluginHolograms = HologramAdapter.activeHolograms.getOrDefault(plugin, Collections.emptyList());
|
Collection<HologramAdapter> pluginHolograms = HologramAdapter.activeHolograms.getOrDefault(plugin, Collections.emptyList());
|
||||||
return pluginHolograms.toArray(new HologramAdapter[0]);
|
return pluginHolograms.toArray(new HologramAdapter[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static FloatingItem[] getFloatingItems(Plugin plugin) {
|
public static FloatingItem[] getFloatingItems(Plugin plugin) {
|
||||||
notifyOldAPI(plugin);
|
notifyOldAPI(plugin);
|
||||||
|
|
||||||
Collection<FloatingItemAdapter> pluginFloatingItems = FloatingItemAdapter.activeFloatingItems.getOrDefault(plugin, Collections.emptyList());
|
Collection<FloatingItemAdapter> pluginFloatingItems = FloatingItemAdapter.activeFloatingItems.getOrDefault(plugin, Collections.emptyList());
|
||||||
return pluginFloatingItems.toArray(new FloatingItemAdapter[0]);
|
return pluginFloatingItems.toArray(new FloatingItemAdapter[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static boolean isHologramEntity(Entity bukkitEntity) {
|
public static boolean isHologramEntity(Entity bukkitEntity) {
|
||||||
return HologramsAPI.isHologramEntity(bukkitEntity);
|
return HologramsAPI.isHologramEntity(bukkitEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void validateLocation(Location loc) {
|
private static void validateLocation(Location loc) {
|
||||||
Validator.notNull(loc, "location");
|
Validator.notNull(loc, "location");
|
||||||
Validator.notNull(loc.getWorld(), "location's world");
|
Validator.notNull(loc.getWorld(), "location's world");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void validateItem(ItemStack itemstack) {
|
private static void validateItem(ItemStack itemstack) {
|
||||||
Validator.notNull(itemstack, "itemstack");
|
Validator.notNull(itemstack, "itemstack");
|
||||||
Validator.isTrue(itemstack.getType() != Material.AIR, "itemstack cannot be AIR");
|
Validator.isTrue(itemstack.getType() != Material.AIR, "itemstack cannot be AIR");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.bukkit.entity.Player;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface ItemTouchHandler {
|
public interface ItemTouchHandler {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void onTouch(FloatingItem floatingItem, Player player);
|
public void onTouch(FloatingItem floatingItem, Player player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.bukkit.entity.Player;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface PickupHandler {
|
public interface PickupHandler {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void onPickup(FloatingItem floatingItem, Player player);
|
public void onPickup(FloatingItem floatingItem, Player player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.bukkit.entity.Player;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface TouchHandler {
|
public interface TouchHandler {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void onTouch(Hologram hologram, Player player);
|
public void onTouch(Hologram hologram, Player player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,130 +31,130 @@ import java.util.Map;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class FloatingItemAdapter implements FloatingItem {
|
public class FloatingItemAdapter implements FloatingItem {
|
||||||
|
|
||||||
public static Map<Plugin, Collection<FloatingItemAdapter>> activeFloatingItems = new HashMap<>();
|
public static Map<Plugin, Collection<FloatingItemAdapter>> activeFloatingItems = new HashMap<>();
|
||||||
|
|
||||||
private Plugin plugin;
|
private Plugin plugin;
|
||||||
public Hologram hologram;
|
public Hologram hologram;
|
||||||
private ItemLine itemLine;
|
private ItemLine itemLine;
|
||||||
private ItemTouchHandler touchHandler;
|
private ItemTouchHandler touchHandler;
|
||||||
private PickupHandler pickupHandler;
|
private PickupHandler pickupHandler;
|
||||||
|
|
||||||
public FloatingItemAdapter(Plugin plugin, Hologram delegateHologram, ItemLine delegateItemLine) {
|
public FloatingItemAdapter(Plugin plugin, Hologram delegateHologram, ItemLine delegateItemLine) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.hologram = delegateHologram;
|
this.hologram = delegateHologram;
|
||||||
this.itemLine = delegateItemLine;
|
this.itemLine = delegateItemLine;
|
||||||
|
|
||||||
activeFloatingItems.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
activeFloatingItems.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update() {
|
public boolean update() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hide() {
|
public void hide() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemStack(ItemStack itemstack) {
|
public void setItemStack(ItemStack itemstack) {
|
||||||
itemLine.setItemStack(itemstack);
|
itemLine.setItemStack(itemstack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemStack() {
|
public ItemStack getItemStack() {
|
||||||
return itemLine.getItemStack();
|
return itemLine.getItemStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
return hologram.getLocation();
|
return hologram.getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getX() {
|
public double getX() {
|
||||||
return hologram.getX();
|
return hologram.getX();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getY() {
|
public double getY() {
|
||||||
return hologram.getY();
|
return hologram.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getZ() {
|
public double getZ() {
|
||||||
return hologram.getZ();
|
return hologram.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getWorld() {
|
public World getWorld() {
|
||||||
return hologram.getWorld();
|
return hologram.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void teleport(Location location) {
|
public void teleport(Location location) {
|
||||||
hologram.teleport(location);
|
hologram.teleport(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTouchHandler(ItemTouchHandler handler) {
|
public void setTouchHandler(ItemTouchHandler handler) {
|
||||||
this.touchHandler = handler;
|
this.touchHandler = handler;
|
||||||
|
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
itemLine.setTouchHandler(new ItemTouchHandlerAdapter(this, handler));
|
itemLine.setTouchHandler(new ItemTouchHandlerAdapter(this, handler));
|
||||||
} else {
|
} else {
|
||||||
itemLine.setTouchHandler(null);
|
itemLine.setTouchHandler(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemTouchHandler getTouchHandler() {
|
public ItemTouchHandler getTouchHandler() {
|
||||||
return touchHandler;
|
return touchHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasTouchHandler() {
|
public boolean hasTouchHandler() {
|
||||||
return touchHandler != null;
|
return touchHandler != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPickupHandler(PickupHandler handler) {
|
public void setPickupHandler(PickupHandler handler) {
|
||||||
this.pickupHandler = handler;
|
this.pickupHandler = handler;
|
||||||
|
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
itemLine.setPickupHandler(new PickupHandlerAdapter(this, handler));
|
itemLine.setPickupHandler(new PickupHandlerAdapter(this, handler));
|
||||||
} else {
|
} else {
|
||||||
itemLine.setPickupHandler(null);
|
itemLine.setPickupHandler(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PickupHandler getPickupHandler() {
|
public PickupHandler getPickupHandler() {
|
||||||
return pickupHandler;
|
return pickupHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPickupHandler() {
|
public boolean hasPickupHandler() {
|
||||||
return pickupHandler != null;
|
return pickupHandler != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCreationTimestamp() {
|
public long getCreationTimestamp() {
|
||||||
return hologram.getCreationTimestamp();
|
return hologram.getCreationTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete() {
|
public void delete() {
|
||||||
hologram.delete();
|
hologram.delete();
|
||||||
|
|
||||||
activeFloatingItems.get(plugin).remove(this);
|
activeFloatingItems.get(plugin).remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeleted() {
|
public boolean isDeleted() {
|
||||||
return hologram.isDeleted();
|
return hologram.isDeleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,172 +30,172 @@ import java.util.Map;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class HologramAdapter implements Hologram {
|
public class HologramAdapter implements Hologram {
|
||||||
|
|
||||||
public static Map<Plugin, Collection<HologramAdapter>> activeHolograms = new HashMap<>();
|
public static Map<Plugin, Collection<HologramAdapter>> activeHolograms = new HashMap<>();
|
||||||
|
|
||||||
private Plugin plugin;
|
private Plugin plugin;
|
||||||
private me.filoghost.holographicdisplays.api.Hologram hologram;
|
private me.filoghost.holographicdisplays.api.Hologram hologram;
|
||||||
private TouchHandler touchHandler;
|
private TouchHandler touchHandler;
|
||||||
|
|
||||||
public HologramAdapter(Plugin plugin, me.filoghost.holographicdisplays.api.Hologram delegate) {
|
public HologramAdapter(Plugin plugin, me.filoghost.holographicdisplays.api.Hologram delegate) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.hologram = delegate;
|
this.hologram = delegate;
|
||||||
|
|
||||||
activeHolograms.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
activeHolograms.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean update() {
|
public boolean update() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void hide() {
|
public void hide() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void addLine(String text) {
|
public void addLine(String text) {
|
||||||
hologram.appendTextLine(text);
|
hologram.appendTextLine(text);
|
||||||
updateTouchHandler();
|
updateTouchHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setLine(int index, String text) {
|
public void setLine(int index, String text) {
|
||||||
hologram.removeLine(index);
|
hologram.removeLine(index);
|
||||||
hologram.insertTextLine(index, text);
|
hologram.insertTextLine(index, text);
|
||||||
updateTouchHandler();
|
updateTouchHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void insertLine(int index, String text) {
|
public void insertLine(int index, String text) {
|
||||||
hologram.insertTextLine(index, text);
|
hologram.insertTextLine(index, text);
|
||||||
updateTouchHandler();
|
updateTouchHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String[] getLines() {
|
public String[] getLines() {
|
||||||
String[] lines = new String[hologram.size()];
|
String[] lines = new String[hologram.size()];
|
||||||
for (int i = 0; i < lines.length; i++) {
|
for (int i = 0; i < lines.length; i++) {
|
||||||
HologramLine lineObject = hologram.getLine(i);
|
HologramLine lineObject = hologram.getLine(i);
|
||||||
if (lineObject instanceof TextLine) {
|
if (lineObject instanceof TextLine) {
|
||||||
lines[i] = ((TextLine) lineObject).getText();
|
lines[i] = ((TextLine) lineObject).getText();
|
||||||
} else {
|
} else {
|
||||||
lines[i] = "";
|
lines[i] = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int getLinesLength() {
|
public int getLinesLength() {
|
||||||
return hologram.size();
|
return hologram.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setLocation(Location location) {
|
public void setLocation(Location location) {
|
||||||
hologram.teleport(location);
|
hologram.teleport(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTouchHandler(TouchHandler handler) {
|
public void setTouchHandler(TouchHandler handler) {
|
||||||
this.touchHandler = handler;
|
this.touchHandler = handler;
|
||||||
updateTouchHandler();
|
updateTouchHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTouchHandler() {
|
private void updateTouchHandler() {
|
||||||
for (int i = 0; i < hologram.size(); i++) {
|
for (int i = 0; i < hologram.size(); i++) {
|
||||||
HologramLine line = hologram.getLine(i);
|
HologramLine line = hologram.getLine(i);
|
||||||
if (!(line instanceof TouchableLine)) {
|
if (!(line instanceof TouchableLine)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TouchableLine touchableLine = (TouchableLine) line;
|
TouchableLine touchableLine = (TouchableLine) line;
|
||||||
|
|
||||||
if (touchHandler != null) {
|
if (touchHandler != null) {
|
||||||
touchableLine.setTouchHandler(new HologramTouchHandlerAdapter(this, touchHandler));
|
touchableLine.setTouchHandler(new HologramTouchHandlerAdapter(this, touchHandler));
|
||||||
} else {
|
} else {
|
||||||
touchableLine.setTouchHandler(null);
|
touchableLine.setTouchHandler(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public TouchHandler getTouchHandler() {
|
public TouchHandler getTouchHandler() {
|
||||||
return touchHandler;
|
return touchHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean hasTouchHandler() {
|
public boolean hasTouchHandler() {
|
||||||
return touchHandler != null;
|
return touchHandler != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeLine(int index) {
|
public void removeLine(int index) {
|
||||||
hologram.removeLine(index);
|
hologram.removeLine(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearLines() {
|
public void clearLines() {
|
||||||
hologram.clearLines();
|
hologram.clearLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
return hologram.getLocation();
|
return hologram.getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getX() {
|
public double getX() {
|
||||||
return hologram.getX();
|
return hologram.getX();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getY() {
|
public double getY() {
|
||||||
return hologram.getY();
|
return hologram.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getZ() {
|
public double getZ() {
|
||||||
return hologram.getZ();
|
return hologram.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getWorld() {
|
public World getWorld() {
|
||||||
return hologram.getWorld();
|
return hologram.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void teleport(Location location) {
|
public void teleport(Location location) {
|
||||||
hologram.teleport(location);
|
hologram.teleport(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCreationTimestamp() {
|
public long getCreationTimestamp() {
|
||||||
return hologram.getCreationTimestamp();
|
return hologram.getCreationTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete() {
|
public void delete() {
|
||||||
hologram.delete();
|
hologram.delete();
|
||||||
|
|
||||||
activeHolograms.get(plugin).remove(this);
|
activeHolograms.get(plugin).remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeleted() {
|
public boolean isDeleted() {
|
||||||
return hologram.isDeleted();
|
return hologram.isDeleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,17 +21,17 @@ import org.bukkit.entity.Player;
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class HologramTouchHandlerAdapter implements me.filoghost.holographicdisplays.api.handler.TouchHandler {
|
public class HologramTouchHandlerAdapter implements me.filoghost.holographicdisplays.api.handler.TouchHandler {
|
||||||
|
|
||||||
protected TouchHandler oldHandler;
|
protected TouchHandler oldHandler;
|
||||||
private Hologram hologram;
|
private Hologram hologram;
|
||||||
|
|
||||||
public HologramTouchHandlerAdapter(Hologram hologram, TouchHandler oldHandler) {
|
public HologramTouchHandlerAdapter(Hologram hologram, TouchHandler oldHandler) {
|
||||||
this.hologram = hologram;
|
this.hologram = hologram;
|
||||||
this.oldHandler = oldHandler;
|
this.oldHandler = oldHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTouch(Player player) {
|
public void onTouch(Player player) {
|
||||||
oldHandler.onTouch(hologram, player);
|
oldHandler.onTouch(hologram, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,17 +22,17 @@ import org.bukkit.entity.Player;
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class ItemTouchHandlerAdapter implements TouchHandler {
|
public class ItemTouchHandlerAdapter implements TouchHandler {
|
||||||
|
|
||||||
protected ItemTouchHandler oldHandler;
|
protected ItemTouchHandler oldHandler;
|
||||||
private FloatingItem item;
|
private FloatingItem item;
|
||||||
|
|
||||||
public ItemTouchHandlerAdapter(FloatingItem item, ItemTouchHandler oldHandler) {
|
public ItemTouchHandlerAdapter(FloatingItem item, ItemTouchHandler oldHandler) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.oldHandler = oldHandler;
|
this.oldHandler = oldHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTouch(Player player) {
|
public void onTouch(Player player) {
|
||||||
oldHandler.onTouch(item, player);
|
oldHandler.onTouch(item, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,17 +21,17 @@ import org.bukkit.entity.Player;
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class PickupHandlerAdapter implements me.filoghost.holographicdisplays.api.handler.PickupHandler {
|
public class PickupHandlerAdapter implements me.filoghost.holographicdisplays.api.handler.PickupHandler {
|
||||||
|
|
||||||
public PickupHandler oldHandler;
|
public PickupHandler oldHandler;
|
||||||
private FloatingItem item;
|
private FloatingItem item;
|
||||||
|
|
||||||
public PickupHandlerAdapter(FloatingItem item, PickupHandler oldPickupHandler) {
|
public PickupHandlerAdapter(FloatingItem item, PickupHandler oldPickupHandler) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.oldHandler = oldPickupHandler;
|
this.oldHandler = oldPickupHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickup(Player player) {
|
public void onPickup(Player player) {
|
||||||
oldHandler.onPickup(item, player);
|
oldHandler.onPickup(item, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||||
<artifactId>holographicdisplays-parent</artifactId>
|
<artifactId>holographicdisplays-parent</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>holographicdisplays-legacy-v2</artifactId>
|
<artifactId>holographicdisplays-legacy-v2</artifactId>
|
||||||
<name>HolographicDisplays Legacy v2</name>
|
<name>HolographicDisplays Legacy v2</name>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-api</artifactId>
|
<artifactId>holographicdisplays-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-utils</artifactId>
|
<artifactId>holographicdisplays-utils</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -27,70 +27,70 @@ import org.bukkit.inventory.ItemStack;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface Hologram {
|
public interface Hologram {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public TextLine appendTextLine(String text);
|
public TextLine appendTextLine(String text);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ItemLine appendItemLine(ItemStack itemStack);
|
public ItemLine appendItemLine(ItemStack itemStack);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public TextLine insertTextLine(int index, String text);
|
public TextLine insertTextLine(int index, String text);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ItemLine insertItemLine(int index, ItemStack itemStack);
|
public ItemLine insertItemLine(int index, ItemStack itemStack);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public HologramLine getLine(int index);
|
public HologramLine getLine(int index);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void removeLine(int index);
|
public void removeLine(int index);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void clearLines();
|
public void clearLines();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int size();
|
public int size();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public double getHeight();
|
public double getHeight();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void teleport(Location location);
|
public void teleport(Location location);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void teleport(World world, double x, double y, double z);
|
public void teleport(World world, double x, double y, double z);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Location getLocation();
|
public Location getLocation();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public double getX();
|
public double getX();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public double getY();
|
public double getY();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public double getZ();
|
public double getZ();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public World getWorld();
|
public World getWorld();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public VisibilityManager getVisibilityManager();
|
public VisibilityManager getVisibilityManager();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public long getCreationTimestamp();
|
public long getCreationTimestamp();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean isAllowPlaceholders();
|
public boolean isAllowPlaceholders();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setAllowPlaceholders(boolean allowPlaceholders);
|
public void setAllowPlaceholders(boolean allowPlaceholders);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void delete();
|
public void delete();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean isDeleted();
|
public boolean isDeleted();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,41 +28,41 @@ import java.util.Collection;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class HologramsAPI {
|
public class HologramsAPI {
|
||||||
|
|
||||||
private HologramsAPI() {}
|
private HologramsAPI() {}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Hologram createHologram(Plugin plugin, Location source) {
|
public static Hologram createHologram(Plugin plugin, Location source) {
|
||||||
return BackendAPI.getImplementation().createHologram(plugin, source);
|
return BackendAPI.getImplementation().createHologram(plugin, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Collection<Hologram> getHolograms(Plugin plugin) {
|
public static Collection<Hologram> getHolograms(Plugin plugin) {
|
||||||
return BackendAPI.getImplementation().getHolograms(plugin);
|
return BackendAPI.getImplementation().getHolograms(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer) {
|
public static boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer) {
|
||||||
return BackendAPI.getImplementation().registerPlaceholder(plugin, textPlaceholder, refreshRate, replacer);
|
return BackendAPI.getImplementation().registerPlaceholder(plugin, textPlaceholder, refreshRate, replacer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Collection<String> getRegisteredPlaceholders(Plugin plugin) {
|
public static Collection<String> getRegisteredPlaceholders(Plugin plugin) {
|
||||||
return BackendAPI.getImplementation().getRegisteredPlaceholders(plugin);
|
return BackendAPI.getImplementation().getRegisteredPlaceholders(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder) {
|
public static boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder) {
|
||||||
return BackendAPI.getImplementation().unregisterPlaceholder(plugin, textPlaceholder);
|
return BackendAPI.getImplementation().unregisterPlaceholder(plugin, textPlaceholder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void unregisterPlaceholders(Plugin plugin) {
|
public static void unregisterPlaceholders(Plugin plugin) {
|
||||||
BackendAPI.getImplementation().unregisterPlaceholders(plugin);
|
BackendAPI.getImplementation().unregisterPlaceholders(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static boolean isHologramEntity(Entity bukkitEntity) {
|
public static boolean isHologramEntity(Entity bukkitEntity) {
|
||||||
return BackendAPI.getImplementation().isHologramEntity(bukkitEntity);
|
return BackendAPI.getImplementation().isHologramEntity(bukkitEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,25 +22,25 @@ import org.bukkit.entity.Player;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface VisibilityManager {
|
public interface VisibilityManager {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean isVisibleByDefault();
|
public boolean isVisibleByDefault();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setVisibleByDefault(boolean visibleByDefault);
|
public void setVisibleByDefault(boolean visibleByDefault);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void showTo(Player player);
|
public void showTo(Player player);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void hideTo(Player player);
|
public void hideTo(Player player);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean isVisibleTo(Player player);
|
public boolean isVisibleTo(Player player);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void resetVisibility(Player player);
|
public void resetVisibility(Player player);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void resetVisibilityAll();
|
public void resetVisibilityAll();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.bukkit.entity.Player;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface PickupHandler {
|
public interface PickupHandler {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void onPickup(Player player);
|
public void onPickup(Player player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.bukkit.entity.Player;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface TouchHandler {
|
public interface TouchHandler {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void onTouch(Player player);
|
public void onTouch(Player player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,42 +27,42 @@ import java.util.Collection;
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public abstract class BackendAPI {
|
public abstract class BackendAPI {
|
||||||
|
|
||||||
private static BackendAPI implementation;
|
private static BackendAPI implementation;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void setImplementation(BackendAPI implementation) {
|
public static void setImplementation(BackendAPI implementation) {
|
||||||
BackendAPI.implementation = implementation;
|
BackendAPI.implementation = implementation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static BackendAPI getImplementation() {
|
public static BackendAPI getImplementation() {
|
||||||
if (implementation == null) {
|
if (implementation == null) {
|
||||||
throw new IllegalStateException("No API implementation set. Is Holographic Displays enabled?");
|
throw new IllegalStateException("No API implementation set. Is Holographic Displays enabled?");
|
||||||
}
|
}
|
||||||
|
|
||||||
return implementation;
|
return implementation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public abstract Hologram createHologram(Plugin plugin, Location source);
|
public abstract Hologram createHologram(Plugin plugin, Location source);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public abstract Collection<Hologram> getHolograms(Plugin plugin);
|
public abstract Collection<Hologram> getHolograms(Plugin plugin);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public abstract boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer);
|
public abstract boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public abstract Collection<String> getRegisteredPlaceholders(Plugin plugin);
|
public abstract Collection<String> getRegisteredPlaceholders(Plugin plugin);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public abstract boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder);
|
public abstract boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public abstract void unregisterPlaceholders(Plugin plugin);
|
public abstract void unregisterPlaceholders(Plugin plugin);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public abstract boolean isHologramEntity(Entity bukkitEntity);
|
public abstract boolean isHologramEntity(Entity bukkitEntity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,10 @@ import com.gmail.filoghost.holographicdisplays.api.handler.PickupHandler;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface CollectableLine extends HologramLine {
|
public interface CollectableLine extends HologramLine {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setPickupHandler(PickupHandler pickupHandler);
|
public void setPickupHandler(PickupHandler pickupHandler);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public PickupHandler getPickupHandler();
|
public PickupHandler getPickupHandler();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,10 @@ import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface HologramLine {
|
public interface HologramLine {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Hologram getParent();
|
public Hologram getParent();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void removeLine();
|
public void removeLine();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,10 @@ import org.bukkit.inventory.ItemStack;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface ItemLine extends CollectableLine, TouchableLine {
|
public interface ItemLine extends CollectableLine, TouchableLine {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ItemStack getItemStack();
|
public ItemStack getItemStack();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setItemStack(ItemStack itemStack);
|
public void setItemStack(ItemStack itemStack);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,10 @@ package com.gmail.filoghost.holographicdisplays.api.line;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface TextLine extends TouchableLine {
|
public interface TextLine extends TouchableLine {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getText();
|
public String getText();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setText(String text);
|
public void setText(String text);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,10 @@ import com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface TouchableLine extends HologramLine {
|
public interface TouchableLine extends HologramLine {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTouchHandler(TouchHandler touchHandler);
|
public void setTouchHandler(TouchHandler touchHandler);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public TouchHandler getTouchHandler();
|
public TouchHandler getTouchHandler();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ package com.gmail.filoghost.holographicdisplays.api.placeholder;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface PlaceholderReplacer {
|
public interface PlaceholderReplacer {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String update();
|
public String update();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||||
<artifactId>holographicdisplays-nms</artifactId>
|
<artifactId>holographicdisplays-nms</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||||
<name>HolographicDisplays NMS Interfaces</name>
|
<name>HolographicDisplays NMS Interfaces</name>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-api</artifactId>
|
<artifactId>holographicdisplays-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -17,19 +17,19 @@ package me.filoghost.holographicdisplays.nms.interfaces;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ChatComponentAdapter<T> {
|
public interface ChatComponentAdapter<T> {
|
||||||
|
|
||||||
T cast(Object chatComponentObject);
|
T cast(Object chatComponentObject);
|
||||||
|
|
||||||
String getText(T chatComponent);
|
String getText(T chatComponent);
|
||||||
|
|
||||||
List<T> getSiblings(T chatComponent);
|
List<T> getSiblings(T chatComponent);
|
||||||
|
|
||||||
void addSibling(T chatComponent, T newSibling);
|
void addSibling(T chatComponent, T newSibling);
|
||||||
|
|
||||||
default T cloneComponent(T chatComponent) {
|
default T cloneComponent(T chatComponent) {
|
||||||
return cloneComponent(chatComponent, getText(chatComponent));
|
return cloneComponent(chatComponent, getText(chatComponent));
|
||||||
}
|
}
|
||||||
|
|
||||||
T cloneComponent(T chatComponent, String newText);
|
T cloneComponent(T chatComponent, String newText);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,64 +17,64 @@ package me.filoghost.holographicdisplays.nms.interfaces;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CustomNameHelper {
|
public class CustomNameHelper {
|
||||||
|
|
||||||
|
|
||||||
public static String replaceCustomNameString(Object customNameObject, String target, String replacement) {
|
public static String replaceCustomNameString(Object customNameObject, String target, String replacement) {
|
||||||
String customName = (String) customNameObject;
|
String customName = (String) customNameObject;
|
||||||
if (customName.contains(target)) {
|
if (customName.contains(target)) {
|
||||||
return customName.replace(target, replacement);
|
return customName.replace(target, replacement);
|
||||||
} else {
|
} else {
|
||||||
return customName;
|
return customName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T replaceCustomNameChatComponent(ChatComponentAdapter<T> versionAdapter, Object customNameObject, String target, String replacement) {
|
public static <T> T replaceCustomNameChatComponent(ChatComponentAdapter<T> versionAdapter, Object customNameObject, String target, String replacement) {
|
||||||
// Custom name is expected to be a ChatComponentText with empty text and child components (called "siblings") that do not contain more components.
|
// Custom name is expected to be a ChatComponentText with empty text and child components (called "siblings") that do not contain more components.
|
||||||
T rootComponent = versionAdapter.cast(customNameObject);
|
T rootComponent = versionAdapter.cast(customNameObject);
|
||||||
if (!versionAdapter.getText(rootComponent).isEmpty()) {
|
if (!versionAdapter.getText(rootComponent).isEmpty()) {
|
||||||
throw new IllegalArgumentException("Expected root component with empty text");
|
throw new IllegalArgumentException("Expected root component with empty text");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean[] childrenContainingTarget = null;
|
boolean[] childrenContainingTarget = null;
|
||||||
List<T> children = versionAdapter.getSiblings(rootComponent);
|
List<T> children = versionAdapter.getSiblings(rootComponent);
|
||||||
int childrenSize = children.size();
|
int childrenSize = children.size();
|
||||||
|
|
||||||
for (int i = 0; i < childrenSize; i++) {
|
for (int i = 0; i < childrenSize; i++) {
|
||||||
T childComponent = versionAdapter.cast(children.get(i));
|
T childComponent = versionAdapter.cast(children.get(i));
|
||||||
|
|
||||||
if (!versionAdapter.getSiblings(childComponent).isEmpty()) {
|
if (!versionAdapter.getSiblings(childComponent).isEmpty()) {
|
||||||
throw new IllegalArgumentException("Expected child component without sub-nodes");
|
throw new IllegalArgumentException("Expected child component without sub-nodes");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (versionAdapter.getText(childComponent).contains(target)) {
|
if (versionAdapter.getText(childComponent).contains(target)) {
|
||||||
// Lazy initialization for performance, since this method can be called frequently.
|
// Lazy initialization for performance, since this method can be called frequently.
|
||||||
if (childrenContainingTarget == null) {
|
if (childrenContainingTarget == null) {
|
||||||
childrenContainingTarget = new boolean[childrenSize];
|
childrenContainingTarget = new boolean[childrenSize];
|
||||||
}
|
}
|
||||||
childrenContainingTarget[i] = true;
|
childrenContainingTarget[i] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (childrenContainingTarget == null) {
|
if (childrenContainingTarget == null) {
|
||||||
// No match found, return original unmodified object.
|
// No match found, return original unmodified object.
|
||||||
return rootComponent;
|
return rootComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone all the objects and apply replacements where needed.
|
// Clone all the objects and apply replacements where needed.
|
||||||
T clonedRoot = versionAdapter.cloneComponent(rootComponent);
|
T clonedRoot = versionAdapter.cloneComponent(rootComponent);
|
||||||
for (int i = 0; i < childrenSize; i++) {
|
for (int i = 0; i < childrenSize; i++) {
|
||||||
T childComponent = children.get(i);
|
T childComponent = children.get(i);
|
||||||
|
|
||||||
String newText = versionAdapter.getText(childComponent);
|
String newText = versionAdapter.getText(childComponent);
|
||||||
if (childrenContainingTarget[i]) {
|
if (childrenContainingTarget[i]) {
|
||||||
newText = newText.replace(target, replacement);
|
newText = newText.replace(target, replacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
T clonedChild = versionAdapter.cloneComponent(childComponent, newText);
|
T clonedChild = versionAdapter.cloneComponent(childComponent, newText);
|
||||||
versionAdapter.addSibling(clonedRoot, clonedChild);
|
versionAdapter.addSibling(clonedRoot, clonedChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
return clonedRoot;
|
return clonedRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,6 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public interface ItemPickupManager {
|
public interface ItemPickupManager {
|
||||||
|
|
||||||
public void handleItemLinePickup(Player player, PickupHandler pickupHandler, Hologram hologram);
|
public void handleItemLinePickup(Player player, PickupHandler pickupHandler, Hologram hologram);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,22 +24,22 @@ import org.bukkit.World;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public interface NMSManager {
|
public interface NMSManager {
|
||||||
|
|
||||||
// A method to register all the custom entities of the plugin, it may fail.
|
// A method to register all the custom entities of the plugin, it may fail.
|
||||||
public void setup() throws Exception;
|
public void setup() throws Exception;
|
||||||
|
|
||||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket);
|
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket);
|
||||||
|
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager);
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager);
|
||||||
|
|
||||||
public NMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece);
|
public NMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece);
|
||||||
|
|
||||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity);
|
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity);
|
||||||
|
|
||||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity);
|
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity);
|
||||||
|
|
||||||
public NMSEntityBase getNMSEntityBaseFromID(World bukkitWorld, int entityID);
|
public NMSEntityBase getNMSEntityBaseFromID(World bukkitWorld, int entityID);
|
||||||
|
|
||||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement);
|
public Object replaceCustomNameText(Object customNameObject, String target, String replacement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
package me.filoghost.holographicdisplays.nms.interfaces.entity;
|
package me.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||||
|
|
||||||
public interface NMSArmorStand extends NMSNameable {
|
public interface NMSArmorStand extends NMSNameable {
|
||||||
|
|
||||||
// Sets the location through NMS and optionally broadcast an additional teleport packet containing the location.
|
// Sets the location through NMS and optionally broadcast an additional teleport packet containing the location.
|
||||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket);
|
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
package me.filoghost.holographicdisplays.nms.interfaces.entity;
|
package me.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||||
|
|
||||||
public interface NMSCanMount extends NMSEntityBase {
|
public interface NMSCanMount extends NMSEntityBase {
|
||||||
|
|
||||||
// Sets the passenger of this entity through NMS.
|
// Sets the passenger of this entity through NMS.
|
||||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase);
|
public void setPassengerOfNMS(NMSEntityBase vehicleBase);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,20 +20,20 @@ import me.filoghost.holographicdisplays.api.line.HologramLine;
|
||||||
* An interface to represent a custom NMS entity being part of a hologram.
|
* An interface to represent a custom NMS entity being part of a hologram.
|
||||||
*/
|
*/
|
||||||
public interface NMSEntityBase {
|
public interface NMSEntityBase {
|
||||||
|
|
||||||
// Returns the linked CraftHologramLine, all the entities are part of a piece. Should never be null.
|
// Returns the linked CraftHologramLine, all the entities are part of a piece. Should never be null.
|
||||||
public HologramLine getHologramLine();
|
public HologramLine getHologramLine();
|
||||||
|
|
||||||
// Returns if the entity is dead through NMS.
|
// Returns if the entity is dead through NMS.
|
||||||
public boolean isDeadNMS();
|
public boolean isDeadNMS();
|
||||||
|
|
||||||
// Kills the entity through NMS.
|
// Kills the entity through NMS.
|
||||||
public void killEntityNMS();
|
public void killEntityNMS();
|
||||||
|
|
||||||
// The entity ID.
|
// The entity ID.
|
||||||
public int getIdNMS();
|
public int getIdNMS();
|
||||||
|
|
||||||
// Returns the bukkit entity.
|
// Returns the bukkit entity.
|
||||||
public org.bukkit.entity.Entity getBukkitEntityNMS();
|
public org.bukkit.entity.Entity getBukkitEntityNMS();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,17 +17,17 @@ package me.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public interface NMSItem extends NMSEntityBase, NMSCanMount {
|
public interface NMSItem extends NMSEntityBase, NMSCanMount {
|
||||||
|
|
||||||
// Sets the location through NMS.
|
// Sets the location through NMS.
|
||||||
public void setLocationNMS(double x, double y, double z);
|
public void setLocationNMS(double x, double y, double z);
|
||||||
|
|
||||||
// Sets the bukkit ItemStack for this item.
|
// Sets the bukkit ItemStack for this item.
|
||||||
public void setItemStackNMS(ItemStack stack);
|
public void setItemStackNMS(ItemStack stack);
|
||||||
|
|
||||||
// Sets if this item can be picked up by players.
|
// Sets if this item can be picked up by players.
|
||||||
public void allowPickup(boolean pickup);
|
public void allowPickup(boolean pickup);
|
||||||
|
|
||||||
// The raw NMS ItemStack object.
|
// The raw NMS ItemStack object.
|
||||||
public Object getRawItemStack();
|
public Object getRawItemStack();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,14 +15,14 @@
|
||||||
package me.filoghost.holographicdisplays.nms.interfaces.entity;
|
package me.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||||
|
|
||||||
public interface NMSNameable extends NMSEntityBase {
|
public interface NMSNameable extends NMSEntityBase {
|
||||||
|
|
||||||
// Sets a custom name as a String.
|
// Sets a custom name as a String.
|
||||||
public void setCustomNameNMS(String name);
|
public void setCustomNameNMS(String name);
|
||||||
|
|
||||||
// Returns the custom name as a String.
|
// Returns the custom name as a String.
|
||||||
public String getCustomNameStringNMS();
|
public String getCustomNameStringNMS();
|
||||||
|
|
||||||
// Returns the custom name as version-dependent NMS object (String for MC 1.12 and below, ChatComponent for MC 1.13+ a ChatComponent).
|
// Returns the custom name as version-dependent NMS object (String for MC 1.12 and below, ChatComponent for MC 1.13+ a ChatComponent).
|
||||||
public Object getCustomNameObjectNMS();
|
public Object getCustomNameObjectNMS();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
package me.filoghost.holographicdisplays.nms.interfaces.entity;
|
package me.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||||
|
|
||||||
public interface NMSSlime extends NMSEntityBase, NMSCanMount {
|
public interface NMSSlime extends NMSEntityBase, NMSCanMount {
|
||||||
|
|
||||||
// Sets the location through NMS.
|
// Sets the location through NMS.
|
||||||
public void setLocationNMS(double x, double y, double z);
|
public void setLocationNMS(double x, double y, double z);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
54
nms/pom.xml
54
nms/pom.xml
|
@ -1,34 +1,34 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||||
<artifactId>holographicdisplays-parent</artifactId>
|
<artifactId>holographicdisplays-parent</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>holographicdisplays-nms</artifactId>
|
<artifactId>holographicdisplays-nms</artifactId>
|
||||||
<name>HolographicDisplays NMS</name>
|
<name>HolographicDisplays NMS</name>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>interfaces</module>
|
<module>interfaces</module>
|
||||||
<module>v1_8_r2</module>
|
<module>v1_8_r2</module>
|
||||||
<module>v1_8_r3</module>
|
<module>v1_8_r3</module>
|
||||||
<module>v1_9_r1</module>
|
<module>v1_9_r1</module>
|
||||||
<module>v1_9_r2</module>
|
<module>v1_9_r2</module>
|
||||||
<module>v1_10_r1</module>
|
<module>v1_10_r1</module>
|
||||||
<module>v1_11_r1</module>
|
<module>v1_11_r1</module>
|
||||||
<module>v1_12_r1</module>
|
<module>v1_12_r1</module>
|
||||||
<module>v1_13_r1</module>
|
<module>v1_13_r1</module>
|
||||||
<module>v1_13_r2</module>
|
<module>v1_13_r2</module>
|
||||||
<module>v1_14_r1</module>
|
<module>v1_14_r1</module>
|
||||||
<module>v1_15_r1</module>
|
<module>v1_15_r1</module>
|
||||||
<module>v1_16_r1</module>
|
<module>v1_16_r1</module>
|
||||||
<module>v1_16_r2</module>
|
<module>v1_16_r2</module>
|
||||||
<module>v1_16_r3</module>
|
<module>v1_16_r3</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||||
<artifactId>holographicdisplays-nms</artifactId>
|
<artifactId>holographicdisplays-nms</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>holographicdisplays-nms-v1_10_r1</artifactId>
|
<artifactId>holographicdisplays-nms-v1_10_r1</artifactId>
|
||||||
<name>HolographicDisplays NMS v1_10_R1</name>
|
<name>HolographicDisplays NMS v1_10_R1</name>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>nms-repo</id>
|
<id>nms-repo</id>
|
||||||
<url>https://repo.codemc.io/repository/nms/</url>
|
<url>https://repo.codemc.io/repository/nms/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-utils</artifactId>
|
<artifactId>holographicdisplays-utils</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -29,64 +29,64 @@ import java.util.Collection;
|
||||||
|
|
||||||
public class CraftNMSArmorStand extends CraftArmorStand {
|
public class CraftNMSArmorStand extends CraftArmorStand {
|
||||||
|
|
||||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow all the bukkit methods.
|
// Disallow all the bukkit methods.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
// Cannot be removed, this is the most important to override.
|
// Cannot be removed, this is the most important to override.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from Armor stand class
|
// Methods from Armor stand class
|
||||||
@Override public void setArms(boolean arms) { }
|
@Override public void setArms(boolean arms) { }
|
||||||
@Override public void setBasePlate(boolean basePlate) { }
|
@Override public void setBasePlate(boolean basePlate) { }
|
||||||
@Override public void setBodyPose(EulerAngle pose) { }
|
@Override public void setBodyPose(EulerAngle pose) { }
|
||||||
@Override public void setBoots(ItemStack item) { }
|
@Override public void setBoots(ItemStack item) { }
|
||||||
@Override public void setChestplate(ItemStack item) { }
|
@Override public void setChestplate(ItemStack item) { }
|
||||||
@Override public void setHeadPose(EulerAngle pose) { }
|
@Override public void setHeadPose(EulerAngle pose) { }
|
||||||
@Override public void setHelmet(ItemStack item) { }
|
@Override public void setHelmet(ItemStack item) { }
|
||||||
@Override public void setItemInHand(ItemStack item) { }
|
@Override public void setItemInHand(ItemStack item) { }
|
||||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||||
@Override public void setLeggings(ItemStack item) { }
|
@Override public void setLeggings(ItemStack item) { }
|
||||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||||
@Override public void setSmall(boolean small) { }
|
@Override public void setSmall(boolean small) { }
|
||||||
@Override public void setVisible(boolean visible) { }
|
@Override public void setVisible(boolean visible) { }
|
||||||
@Override public void setMarker(boolean marker) { }
|
@Override public void setMarker(boolean marker) { }
|
||||||
|
|
||||||
// Methods from LivingEntity class
|
// Methods from LivingEntity class
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||||
@Override public void setAI(boolean ai) { }
|
@Override public void setAI(boolean ai) { }
|
||||||
@Override public void setCanPickupItems(boolean pickup) { }
|
@Override public void setCanPickupItems(boolean pickup) { }
|
||||||
@Override public void setCollidable(boolean collidable) { }
|
@Override public void setCollidable(boolean collidable) { }
|
||||||
@Override public void setGliding(boolean gliding) { }
|
@Override public void setGliding(boolean gliding) { }
|
||||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||||
|
|
||||||
// Methods from Entity
|
// Methods from Entity
|
||||||
@Override public void setVelocity(Vector vel) { }
|
@Override public void setVelocity(Vector vel) { }
|
||||||
@Override public boolean teleport(Location loc) { return false; }
|
@Override public boolean teleport(Location loc) { return false; }
|
||||||
@Override public boolean teleport(Entity entity) { return false; }
|
@Override public boolean teleport(Entity entity) { return false; }
|
||||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||||
@Override public void setFireTicks(int ticks) { }
|
@Override public void setFireTicks(int ticks) { }
|
||||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||||
@Override public boolean eject() { return false; }
|
@Override public boolean eject() { return false; }
|
||||||
@Override public boolean leaveVehicle() { return false; }
|
@Override public boolean leaveVehicle() { return false; }
|
||||||
@Override public void playEffect(EntityEffect effect) { }
|
@Override public void playEffect(EntityEffect effect) { }
|
||||||
@Override public void setCustomName(String name) { }
|
@Override public void setCustomName(String name) { }
|
||||||
@Override public void setCustomNameVisible(boolean flag) { }
|
@Override public void setCustomNameVisible(boolean flag) { }
|
||||||
@Override public void setGlowing(boolean flag) { }
|
@Override public void setGlowing(boolean flag) { }
|
||||||
@Override public void setGravity(boolean gravity) { }
|
@Override public void setGravity(boolean gravity) { }
|
||||||
@Override public void setInvulnerable(boolean flag) { }
|
@Override public void setInvulnerable(boolean flag) { }
|
||||||
@Override public void setMomentum(Vector value) { }
|
@Override public void setMomentum(Vector value) { }
|
||||||
@Override public void setSilent(boolean flag) { }
|
@Override public void setSilent(boolean flag) { }
|
||||||
@Override public void setTicksLived(int value) { }
|
@Override public void setTicksLived(int value) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,39 +25,39 @@ import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class CraftNMSItem extends CraftItem {
|
public class CraftNMSItem extends CraftItem {
|
||||||
|
|
||||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow all the bukkit methods.
|
// Disallow all the bukkit methods.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
// Cannot be removed, this is the most important to override.
|
// Cannot be removed, this is the most important to override.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from Entity
|
// Methods from Entity
|
||||||
@Override public void setVelocity(Vector vel) { }
|
@Override public void setVelocity(Vector vel) { }
|
||||||
@Override public boolean teleport(Location loc) { return false; }
|
@Override public boolean teleport(Location loc) { return false; }
|
||||||
@Override public boolean teleport(Entity entity) { return false; }
|
@Override public boolean teleport(Entity entity) { return false; }
|
||||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||||
@Override public void setFireTicks(int ticks) { }
|
@Override public void setFireTicks(int ticks) { }
|
||||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||||
@Override public boolean eject() { return false; }
|
@Override public boolean eject() { return false; }
|
||||||
@Override public boolean leaveVehicle() { return false; }
|
@Override public boolean leaveVehicle() { return false; }
|
||||||
@Override public void playEffect(EntityEffect effect) { }
|
@Override public void playEffect(EntityEffect effect) { }
|
||||||
@Override public void setCustomName(String name) { }
|
@Override public void setCustomName(String name) { }
|
||||||
@Override public void setCustomNameVisible(boolean flag) { }
|
@Override public void setCustomNameVisible(boolean flag) { }
|
||||||
@Override public void setGlowing(boolean flag) { }
|
@Override public void setGlowing(boolean flag) { }
|
||||||
@Override public void setGravity(boolean gravity) { }
|
@Override public void setGravity(boolean gravity) { }
|
||||||
@Override public void setInvulnerable(boolean flag) { }
|
@Override public void setInvulnerable(boolean flag) { }
|
||||||
@Override public void setMomentum(Vector value) { }
|
@Override public void setMomentum(Vector value) { }
|
||||||
@Override public void setSilent(boolean flag) { }
|
@Override public void setSilent(boolean flag) { }
|
||||||
@Override public void setTicksLived(int value) { }
|
@Override public void setTicksLived(int value) { }
|
||||||
|
|
||||||
// Methods from Item
|
// Methods from Item
|
||||||
@Override public void setItemStack(ItemStack stack) { }
|
@Override public void setItemStack(ItemStack stack) { }
|
||||||
@Override public void setPickupDelay(int delay) { }
|
@Override public void setPickupDelay(int delay) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,49 +27,49 @@ import java.util.Collection;
|
||||||
|
|
||||||
public class CraftNMSSlime extends CraftSlime {
|
public class CraftNMSSlime extends CraftSlime {
|
||||||
|
|
||||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow all the bukkit methods.
|
// Disallow all the bukkit methods.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
// Cannot be removed, this is the most important to override.
|
// Cannot be removed, this is the most important to override.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from LivingEntity class
|
// Methods from LivingEntity class
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||||
@Override public void setAI(boolean ai) { }
|
@Override public void setAI(boolean ai) { }
|
||||||
@Override public void setCanPickupItems(boolean pickup) { }
|
@Override public void setCanPickupItems(boolean pickup) { }
|
||||||
@Override public void setCollidable(boolean collidable) { }
|
@Override public void setCollidable(boolean collidable) { }
|
||||||
@Override public void setGliding(boolean gliding) { }
|
@Override public void setGliding(boolean gliding) { }
|
||||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||||
|
|
||||||
// Methods from Entity
|
// Methods from Entity
|
||||||
@Override public void setVelocity(Vector vel) { }
|
@Override public void setVelocity(Vector vel) { }
|
||||||
@Override public boolean teleport(Location loc) { return false; }
|
@Override public boolean teleport(Location loc) { return false; }
|
||||||
@Override public boolean teleport(Entity entity) { return false; }
|
@Override public boolean teleport(Entity entity) { return false; }
|
||||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||||
@Override public void setFireTicks(int ticks) { }
|
@Override public void setFireTicks(int ticks) { }
|
||||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||||
@Override public boolean eject() { return false; }
|
@Override public boolean eject() { return false; }
|
||||||
@Override public boolean leaveVehicle() { return false; }
|
@Override public boolean leaveVehicle() { return false; }
|
||||||
@Override public void playEffect(EntityEffect effect) { }
|
@Override public void playEffect(EntityEffect effect) { }
|
||||||
@Override public void setCustomName(String name) { }
|
@Override public void setCustomName(String name) { }
|
||||||
@Override public void setCustomNameVisible(boolean flag) { }
|
@Override public void setCustomNameVisible(boolean flag) { }
|
||||||
@Override public void setGlowing(boolean flag) { }
|
@Override public void setGlowing(boolean flag) { }
|
||||||
@Override public void setGravity(boolean gravity) { }
|
@Override public void setGravity(boolean gravity) { }
|
||||||
@Override public void setInvulnerable(boolean flag) { }
|
@Override public void setInvulnerable(boolean flag) { }
|
||||||
@Override public void setMomentum(Vector value) { }
|
@Override public void setMomentum(Vector value) { }
|
||||||
@Override public void setSilent(boolean flag) { }
|
@Override public void setSilent(boolean flag) { }
|
||||||
@Override public void setTicksLived(int value) { }
|
@Override public void setTicksLived(int value) { }
|
||||||
|
|
||||||
// Methods from Slime
|
// Methods from Slime
|
||||||
@Override public void setSize(int size) { }
|
@Override public void setSize(int size) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,208 +35,208 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||||
|
|
||||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
||||||
|
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
private String customName;
|
private String customName;
|
||||||
|
|
||||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||||
super(world);
|
super(world);
|
||||||
super.setInvisible(true);
|
super.setInvisible(true);
|
||||||
super.setSmall(true);
|
super.setSmall(true);
|
||||||
super.setArms(false);
|
super.setArms(false);
|
||||||
super.setNoGravity(true);
|
super.setNoGravity(true);
|
||||||
super.setBasePlate(true);
|
super.setBasePlate(true);
|
||||||
super.setMarker(true);
|
super.setMarker(true);
|
||||||
super.collides = false;
|
super.collides = false;
|
||||||
this.parentPiece = parentPiece;
|
this.parentPiece = parentPiece;
|
||||||
forceSetBoundingBox(new NullBoundingBox());
|
forceSetBoundingBox(new NullBoundingBox());
|
||||||
|
|
||||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m() {
|
public void m() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||||
if (this.onGround) {
|
if (this.onGround) {
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inactiveTick() {
|
public void inactiveTick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||||
if (this.onGround) {
|
if (this.onGround) {
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(NBTTagCompound nbttagcompound) {
|
public boolean c(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(NBTTagCompound nbttagcompound) {
|
public boolean d(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void f(NBTTagCompound nbttagcompound) {
|
public void f(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvulnerable(DamageSource source) {
|
public boolean isInvulnerable(DamageSource source) {
|
||||||
/*
|
/*
|
||||||
* The field Entity.invulnerable is private.
|
* The field Entity.invulnerable is private.
|
||||||
* It's only used while saving NBTTags, but since the entity would be killed
|
* It's only used while saving NBTTags, but since the entity would be killed
|
||||||
* on chunk unload, we prefer to override isInvulnerable().
|
* on chunk unload, we prefer to override isInvulnerable().
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomName(String customName) {
|
public void setCustomName(String customName) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomNameVisible(boolean visible) {
|
public void setCustomNameVisible(boolean visible) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, ItemStack itemstack, EnumHand enumhand) {
|
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, ItemStack itemstack, EnumHand enumhand) {
|
||||||
// Prevent stand being equipped
|
// Prevent stand being equipped
|
||||||
return EnumInteractionResult.PASS;
|
return EnumInteractionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(int i, ItemStack item) {
|
public boolean c(int i, ItemStack item) {
|
||||||
// Prevent stand being equipped
|
// Prevent stand being equipped
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||||
// Prevent stand being equipped
|
// Prevent stand being equipped
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(AxisAlignedBB boundingBox) {
|
public void a(AxisAlignedBB boundingBox) {
|
||||||
// Do not change it!
|
// Do not change it!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||||
super.a(boundingBox);
|
super.a(boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||||
// Remove sounds.
|
// Remove sounds.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomNameNMS(String name) {
|
public void setCustomNameNMS(String name) {
|
||||||
this.customName = Utils.limitLength(name, 300);
|
this.customName = Utils.limitLength(name, 300);
|
||||||
super.setCustomName(customName);
|
super.setCustomName(customName);
|
||||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCustomNameStringNMS() {
|
public String getCustomNameStringNMS() {
|
||||||
return this.customName;
|
return this.customName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getCustomNameObjectNMS() {
|
public Object getCustomNameObjectNMS() {
|
||||||
return super.getCustomName();
|
return super.getCustomName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
// Prevent being killed.
|
// Prevent being killed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||||
}
|
}
|
||||||
return super.bukkitEntity;
|
return super.bukkitEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void killEntityNMS() {
|
public void killEntityNMS() {
|
||||||
super.dead = true;
|
super.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
if (broadcastLocationPacket) {
|
if (broadcastLocationPacket) {
|
||||||
broadcastLocationPacketNMS();
|
broadcastLocationPacketNMS();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object obj : super.world.players) {
|
for (Object obj : super.world.players) {
|
||||||
if (obj instanceof EntityPlayer) {
|
if (obj instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return super.dead;
|
return super.dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIdNMS() {
|
public int getIdNMS() {
|
||||||
return super.getId();
|
return super.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HologramLine getHologramLine() {
|
public HologramLine getHologramLine() {
|
||||||
return parentPiece;
|
return parentPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||||
return getBukkitEntity();
|
return getBukkitEntity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,230 +41,230 @@ import org.bukkit.entity.Player;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||||
|
|
||||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||||
|
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
private ItemPickupManager itemPickupManager;
|
private ItemPickupManager itemPickupManager;
|
||||||
|
|
||||||
private int resendMountPacketTicks;
|
private int resendMountPacketTicks;
|
||||||
|
|
||||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||||
super(world);
|
super(world);
|
||||||
super.pickupDelay = Integer.MAX_VALUE;
|
super.pickupDelay = Integer.MAX_VALUE;
|
||||||
this.parentPiece = piece;
|
this.parentPiece = piece;
|
||||||
this.itemPickupManager = itemPickupManager;
|
this.itemPickupManager = itemPickupManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m() {
|
public void m() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
|
|
||||||
if (resendMountPacketTicks++ > 20) {
|
if (resendMountPacketTicks++ > 20) {
|
||||||
resendMountPacketTicks = 0;
|
resendMountPacketTicks = 0;
|
||||||
|
|
||||||
if (bB() != null) {
|
if (bB() != null) {
|
||||||
// Send a packet near to "remind" players that the item is riding the armor stand (Spigot bug or client bug)
|
// Send a packet near to "remind" players that the item is riding the armor stand (Spigot bug or client bug)
|
||||||
PacketPlayOutMount mountPacket = new PacketPlayOutMount(bB());
|
PacketPlayOutMount mountPacket = new PacketPlayOutMount(bB());
|
||||||
|
|
||||||
for (Object obj : super.world.players) {
|
for (Object obj : super.world.players) {
|
||||||
if (obj instanceof EntityPlayer) {
|
if (obj instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inactiveTick() {
|
public void inactiveTick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method called when a player is near.
|
// Method called when a player is near.
|
||||||
@Override
|
@Override
|
||||||
public void d(EntityHuman human) {
|
public void d(EntityHuman human) {
|
||||||
|
|
||||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||||
// Too low or too high, it's a bit weird.
|
// Too low or too high, it's a bit weird.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||||
// It is never added to the inventory.
|
// It is never added to the inventory.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(NBTTagCompound nbttagcompound) {
|
public boolean c(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(NBTTagCompound nbttagcompound) {
|
public boolean d(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void f(NBTTagCompound nbttagcompound) {
|
public void f(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvulnerable(DamageSource source) {
|
public boolean isInvulnerable(DamageSource source) {
|
||||||
/*
|
/*
|
||||||
* The field Entity.invulnerable is private.
|
* The field Entity.invulnerable is private.
|
||||||
* It's only used while saving NBTTags, but since the entity would be killed
|
* It's only used while saving NBTTags, but since the entity would be killed
|
||||||
* on chunk unload, we prefer to override isInvulnerable().
|
* on chunk unload, we prefer to override isInvulnerable().
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
// Prevent being killed.
|
// Prevent being killed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAlive() {
|
public boolean isAlive() {
|
||||||
// This override prevents items from being picked up by hoppers.
|
// This override prevents items from being picked up by hoppers.
|
||||||
// Should have no side effects.
|
// Should have no side effects.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||||
}
|
}
|
||||||
return super.bukkitEntity;
|
return super.bukkitEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return super.dead;
|
return super.dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void killEntityNMS() {
|
public void killEntityNMS() {
|
||||||
super.dead = true;
|
super.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocationNMS(double x, double y, double z) {
|
public void setLocationNMS(double x, double y, double z) {
|
||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
||||||
ItemStack newItem = CraftItemStack.asNMSCopy(stack);
|
ItemStack newItem = CraftItemStack.asNMSCopy(stack);
|
||||||
|
|
||||||
if (newItem == null) {
|
if (newItem == null) {
|
||||||
newItem = new ItemStack(Blocks.BEDROCK);
|
newItem = new ItemStack(Blocks.BEDROCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newItem.getTag() == null) {
|
if (newItem.getTag() == null) {
|
||||||
newItem.setTag(new NBTTagCompound());
|
newItem.setTag(new NBTTagCompound());
|
||||||
}
|
}
|
||||||
NBTTagCompound display = newItem.getTag().getCompound("display");
|
NBTTagCompound display = newItem.getTag().getCompound("display");
|
||||||
|
|
||||||
if (!newItem.getTag().hasKey("display")) {
|
if (!newItem.getTag().hasKey("display")) {
|
||||||
newItem.getTag().set("display", display);
|
newItem.getTag().set("display", display);
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTagList tagList = new NBTTagList();
|
NBTTagList tagList = new NBTTagList();
|
||||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||||
display.set("Lore", tagList);
|
display.set("Lore", tagList);
|
||||||
|
|
||||||
setItemStack(newItem);
|
setItemStack(newItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIdNMS() {
|
public int getIdNMS() {
|
||||||
return super.getId();
|
return super.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemLine getHologramLine() {
|
public ItemLine getHologramLine() {
|
||||||
return parentPiece;
|
return parentPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void allowPickup(boolean pickup) {
|
public void allowPickup(boolean pickup) {
|
||||||
if (pickup) {
|
if (pickup) {
|
||||||
super.pickupDelay = 0;
|
super.pickupDelay = 0;
|
||||||
} else {
|
} else {
|
||||||
super.pickupDelay = Integer.MAX_VALUE;
|
super.pickupDelay = Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||||
return getBukkitEntity();
|
return getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||||
// It should never dismount
|
// It should never dismount
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity entity = (Entity) vehicleBase;
|
Entity entity = (Entity) vehicleBase;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (super.bB() != null) {
|
if (super.bB() != null) {
|
||||||
Entity oldVehicle = super.bB();
|
Entity oldVehicle = super.bB();
|
||||||
VEHICLE_FIELD.set(this, null);
|
VEHICLE_FIELD.set(this, null);
|
||||||
oldVehicle.passengers.remove(this);
|
oldVehicle.passengers.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
VEHICLE_FIELD.set(this, entity);
|
VEHICLE_FIELD.set(this, entity);
|
||||||
entity.passengers.clear();
|
entity.passengers.clear();
|
||||||
entity.passengers.add(this);
|
entity.passengers.add(this);
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getRawItemStack() {
|
public Object getRawItemStack() {
|
||||||
return super.getItemStack();
|
return super.getItemStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,208 +37,208 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||||
|
|
||||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||||
|
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
|
||||||
private int resendMountPacketTicks;
|
private int resendMountPacketTicks;
|
||||||
|
|
||||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||||
super(world);
|
super(world);
|
||||||
super.persistent = true;
|
super.persistent = true;
|
||||||
super.collides = false;
|
super.collides = false;
|
||||||
a(0.0F, 0.0F);
|
a(0.0F, 0.0F);
|
||||||
setSize(1);
|
setSize(1);
|
||||||
setInvisible(true);
|
setInvisible(true);
|
||||||
this.parentPiece = parentPiece;
|
this.parentPiece = parentPiece;
|
||||||
forceSetBoundingBox(new NullBoundingBox());
|
forceSetBoundingBox(new NullBoundingBox());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m() {
|
public void m() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
|
|
||||||
if (resendMountPacketTicks++ > 20) {
|
if (resendMountPacketTicks++ > 20) {
|
||||||
resendMountPacketTicks = 0;
|
resendMountPacketTicks = 0;
|
||||||
|
|
||||||
if (bB() != null) {
|
if (bB() != null) {
|
||||||
// Send a packet near to "remind" players that the slime is riding the armor stand (Spigot bug or client bug)
|
// Send a packet near to "remind" players that the slime is riding the armor stand (Spigot bug or client bug)
|
||||||
PacketPlayOutMount mountPacket = new PacketPlayOutMount(bB());
|
PacketPlayOutMount mountPacket = new PacketPlayOutMount(bB());
|
||||||
|
|
||||||
for (Object obj : super.world.players) {
|
for (Object obj : super.world.players) {
|
||||||
if (obj instanceof EntityPlayer) {
|
if (obj instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inactiveTick() {
|
public void inactiveTick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(AxisAlignedBB boundingBox) {
|
public void a(AxisAlignedBB boundingBox) {
|
||||||
// Do not change it!
|
// Do not change it!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||||
super.a(boundingBox);
|
super.a(boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(NBTTagCompound nbttagcompound) {
|
public boolean c(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(NBTTagCompound nbttagcompound) {
|
public boolean d(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void f(NBTTagCompound nbttagcompound) {
|
public void f(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||||
if (damageSource instanceof EntityDamageSource) {
|
if (damageSource instanceof EntityDamageSource) {
|
||||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvulnerable(DamageSource source) {
|
public boolean isInvulnerable(DamageSource source) {
|
||||||
/*
|
/*
|
||||||
* The field Entity.invulnerable is private.
|
* The field Entity.invulnerable is private.
|
||||||
* It's only used while saving NBTTags, but since the entity would be killed
|
* It's only used while saving NBTTags, but since the entity would be killed
|
||||||
* on chunk unload, we prefer to override isInvulnerable().
|
* on chunk unload, we prefer to override isInvulnerable().
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomName(String customName) {
|
public void setCustomName(String customName) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomNameVisible(boolean visible) {
|
public void setCustomNameVisible(boolean visible) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||||
// Remove sounds.
|
// Remove sounds.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
// Prevent being killed.
|
// Prevent being killed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||||
}
|
}
|
||||||
return super.bukkitEntity;
|
return super.bukkitEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return super.dead;
|
return super.dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void killEntityNMS() {
|
public void killEntityNMS() {
|
||||||
super.dead = true;
|
super.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocationNMS(double x, double y, double z) {
|
public void setLocationNMS(double x, double y, double z) {
|
||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIdNMS() {
|
public int getIdNMS() {
|
||||||
return super.getId();
|
return super.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HologramLine getHologramLine() {
|
public HologramLine getHologramLine() {
|
||||||
return parentPiece;
|
return parentPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||||
return getBukkitEntity();
|
return getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||||
// It should never dismount
|
// It should never dismount
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity entity = (Entity) vehicleBase;
|
Entity entity = (Entity) vehicleBase;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (super.bB() != null) {
|
if (super.bB() != null) {
|
||||||
Entity oldVehicle = super.bB();
|
Entity oldVehicle = super.bB();
|
||||||
VEHICLE_FIELD.set(this, null);
|
VEHICLE_FIELD.set(this, null);
|
||||||
oldVehicle.passengers.remove(this);
|
oldVehicle.passengers.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
VEHICLE_FIELD.set(this, entity);
|
VEHICLE_FIELD.set(this, entity);
|
||||||
entity.passengers.clear();
|
entity.passengers.clear();
|
||||||
entity.passengers.add(this);
|
entity.passengers.add(this);
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,69 +39,69 @@ import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class NmsManagerImpl implements NMSManager {
|
public class NmsManagerImpl implements NMSManager {
|
||||||
|
|
||||||
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d");
|
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d");
|
||||||
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
|
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
registerCustomEntity(EntityNMSArmorStand.class, "ArmorStand", 30);
|
registerCustomEntity(EntityNMSArmorStand.class, "ArmorStand", 30);
|
||||||
registerCustomEntity(EntityNMSItem.class, "Item", 1);
|
registerCustomEntity(EntityNMSItem.class, "Item", 1);
|
||||||
registerCustomEntity(EntityNMSSlime.class, "Slime", 55);
|
registerCustomEntity(EntityNMSSlime.class, "Slime", 55);
|
||||||
|
|
||||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||||
validateEntityMethod.setAccessible(true);
|
validateEntityMethod.setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCustomEntity(Class<?> entityClass, String name, int id) throws Exception {
|
public void registerCustomEntity(Class<?> entityClass, String name, int id) throws Exception {
|
||||||
ENTITY_NAMES_BY_CLASS_FIELD.getStatic().put(entityClass, name);
|
ENTITY_NAMES_BY_CLASS_FIELD.getStatic().put(entityClass, name);
|
||||||
ENTITY_IDS_BY_CLASS_FIELD.getStatic().put(entityClass, Integer.valueOf(id));
|
ENTITY_IDS_BY_CLASS_FIELD.getStatic().put(entityClass, Integer.valueOf(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||||
customItem.setLocationNMS(x, y, z);
|
customItem.setLocationNMS(x, y, z);
|
||||||
customItem.setItemStackNMS(stack);
|
customItem.setItemStackNMS(stack);
|
||||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||||
}
|
}
|
||||||
return customItem;
|
return customItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||||
touchSlime.setLocationNMS(x, y, z);
|
touchSlime.setLocationNMS(x, y, z);
|
||||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||||
}
|
}
|
||||||
return touchSlime;
|
return touchSlime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||||
}
|
}
|
||||||
return invisibleArmorStand;
|
return invisibleArmorStand;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||||
|
|
||||||
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
||||||
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
||||||
|
|
||||||
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
||||||
// This should never happen
|
// This should never happen
|
||||||
nmsEntity.dead = true;
|
nmsEntity.dead = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -110,45 +110,45 @@ public class NmsManagerImpl implements NMSManager {
|
||||||
nmsWorld.entityList.add(nmsEntity);
|
nmsWorld.entityList.add(nmsEntity);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||||
|
|
||||||
if (nmsEntity instanceof NMSEntityBase) {
|
if (nmsEntity instanceof NMSEntityBase) {
|
||||||
return ((NMSEntityBase) nmsEntity);
|
return ((NMSEntityBase) nmsEntity);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||||
|
|
||||||
if (nmsEntity instanceof NMSEntityBase) {
|
if (nmsEntity instanceof NMSEntityBase) {
|
||||||
return ((NMSEntityBase) nmsEntity);
|
return ((NMSEntityBase) nmsEntity);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
||||||
return CustomNameHelper.replaceCustomNameString(customNameObject, target, replacement);
|
return CustomNameHelper.replaceCustomNameString(customNameObject, target, replacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,103 +21,103 @@ import net.minecraft.server.v1_10_R1.Vec3D;
|
||||||
|
|
||||||
public class NullBoundingBox extends AxisAlignedBB {
|
public class NullBoundingBox extends AxisAlignedBB {
|
||||||
|
|
||||||
public NullBoundingBox() {
|
public NullBoundingBox() {
|
||||||
super(0, 0, 0, 0, 0, 0);
|
super(0, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double a() {
|
public double a() {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double a(AxisAlignedBB arg0, double arg1) {
|
public double a(AxisAlignedBB arg0, double arg1) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean a(Vec3D arg0) {
|
public boolean a(Vec3D arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double b(AxisAlignedBB arg0, double arg1) {
|
public double b(AxisAlignedBB arg0, double arg1) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean b(AxisAlignedBB arg0) {
|
public boolean b(AxisAlignedBB arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double c(AxisAlignedBB arg0, double arg1) {
|
public double c(AxisAlignedBB arg0, double arg1) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB c(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB c(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB shrink(double arg0) {
|
public AxisAlignedBB shrink(double arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(BlockPosition arg0) {
|
public AxisAlignedBB a(BlockPosition arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean b(Vec3D arg0) {
|
public boolean b(Vec3D arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(Vec3D arg0) {
|
public boolean c(Vec3D arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(Vec3D arg0) {
|
public boolean d(Vec3D arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB e(double arg0) {
|
public AxisAlignedBB e(double arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB g(double arg0) {
|
public AxisAlignedBB g(double arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||||
<artifactId>holographicdisplays-nms</artifactId>
|
<artifactId>holographicdisplays-nms</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>holographicdisplays-nms-v1_11_r1</artifactId>
|
<artifactId>holographicdisplays-nms-v1_11_r1</artifactId>
|
||||||
<name>HolographicDisplays NMS v1_11_R1</name>
|
<name>HolographicDisplays NMS v1_11_R1</name>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>nms-repo</id>
|
<id>nms-repo</id>
|
||||||
<url>https://repo.codemc.io/repository/nms/</url>
|
<url>https://repo.codemc.io/repository/nms/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-utils</artifactId>
|
<artifactId>holographicdisplays-utils</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.11-R0.1-SNAPSHOT</version>
|
<version>1.11-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -29,64 +29,64 @@ import java.util.Collection;
|
||||||
|
|
||||||
public class CraftNMSArmorStand extends CraftArmorStand {
|
public class CraftNMSArmorStand extends CraftArmorStand {
|
||||||
|
|
||||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow all the bukkit methods.
|
// Disallow all the bukkit methods.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
// Cannot be removed, this is the most important to override.
|
// Cannot be removed, this is the most important to override.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from Armor stand class
|
// Methods from Armor stand class
|
||||||
@Override public void setArms(boolean arms) { }
|
@Override public void setArms(boolean arms) { }
|
||||||
@Override public void setBasePlate(boolean basePlate) { }
|
@Override public void setBasePlate(boolean basePlate) { }
|
||||||
@Override public void setBodyPose(EulerAngle pose) { }
|
@Override public void setBodyPose(EulerAngle pose) { }
|
||||||
@Override public void setBoots(ItemStack item) { }
|
@Override public void setBoots(ItemStack item) { }
|
||||||
@Override public void setChestplate(ItemStack item) { }
|
@Override public void setChestplate(ItemStack item) { }
|
||||||
@Override public void setHeadPose(EulerAngle pose) { }
|
@Override public void setHeadPose(EulerAngle pose) { }
|
||||||
@Override public void setHelmet(ItemStack item) { }
|
@Override public void setHelmet(ItemStack item) { }
|
||||||
@Override public void setItemInHand(ItemStack item) { }
|
@Override public void setItemInHand(ItemStack item) { }
|
||||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||||
@Override public void setLeggings(ItemStack item) { }
|
@Override public void setLeggings(ItemStack item) { }
|
||||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||||
@Override public void setSmall(boolean small) { }
|
@Override public void setSmall(boolean small) { }
|
||||||
@Override public void setVisible(boolean visible) { }
|
@Override public void setVisible(boolean visible) { }
|
||||||
@Override public void setMarker(boolean marker) { }
|
@Override public void setMarker(boolean marker) { }
|
||||||
|
|
||||||
// Methods from LivingEntity class
|
// Methods from LivingEntity class
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||||
@Override public void setAI(boolean ai) { }
|
@Override public void setAI(boolean ai) { }
|
||||||
@Override public void setCanPickupItems(boolean pickup) { }
|
@Override public void setCanPickupItems(boolean pickup) { }
|
||||||
@Override public void setCollidable(boolean collidable) { }
|
@Override public void setCollidable(boolean collidable) { }
|
||||||
@Override public void setGliding(boolean gliding) { }
|
@Override public void setGliding(boolean gliding) { }
|
||||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||||
|
|
||||||
// Methods from Entity
|
// Methods from Entity
|
||||||
@Override public void setVelocity(Vector vel) { }
|
@Override public void setVelocity(Vector vel) { }
|
||||||
@Override public boolean teleport(Location loc) { return false; }
|
@Override public boolean teleport(Location loc) { return false; }
|
||||||
@Override public boolean teleport(Entity entity) { return false; }
|
@Override public boolean teleport(Entity entity) { return false; }
|
||||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||||
@Override public void setFireTicks(int ticks) { }
|
@Override public void setFireTicks(int ticks) { }
|
||||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||||
@Override public boolean eject() { return false; }
|
@Override public boolean eject() { return false; }
|
||||||
@Override public boolean leaveVehicle() { return false; }
|
@Override public boolean leaveVehicle() { return false; }
|
||||||
@Override public void playEffect(EntityEffect effect) { }
|
@Override public void playEffect(EntityEffect effect) { }
|
||||||
@Override public void setCustomName(String name) { }
|
@Override public void setCustomName(String name) { }
|
||||||
@Override public void setCustomNameVisible(boolean flag) { }
|
@Override public void setCustomNameVisible(boolean flag) { }
|
||||||
@Override public void setGlowing(boolean flag) { }
|
@Override public void setGlowing(boolean flag) { }
|
||||||
@Override public void setGravity(boolean gravity) { }
|
@Override public void setGravity(boolean gravity) { }
|
||||||
@Override public void setInvulnerable(boolean flag) { }
|
@Override public void setInvulnerable(boolean flag) { }
|
||||||
@Override public void setMomentum(Vector value) { }
|
@Override public void setMomentum(Vector value) { }
|
||||||
@Override public void setSilent(boolean flag) { }
|
@Override public void setSilent(boolean flag) { }
|
||||||
@Override public void setTicksLived(int value) { }
|
@Override public void setTicksLived(int value) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,39 +25,39 @@ import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class CraftNMSItem extends CraftItem {
|
public class CraftNMSItem extends CraftItem {
|
||||||
|
|
||||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow all the bukkit methods.
|
// Disallow all the bukkit methods.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
// Cannot be removed, this is the most important to override.
|
// Cannot be removed, this is the most important to override.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from Entity
|
// Methods from Entity
|
||||||
@Override public void setVelocity(Vector vel) { }
|
@Override public void setVelocity(Vector vel) { }
|
||||||
@Override public boolean teleport(Location loc) { return false; }
|
@Override public boolean teleport(Location loc) { return false; }
|
||||||
@Override public boolean teleport(Entity entity) { return false; }
|
@Override public boolean teleport(Entity entity) { return false; }
|
||||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||||
@Override public void setFireTicks(int ticks) { }
|
@Override public void setFireTicks(int ticks) { }
|
||||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||||
@Override public boolean eject() { return false; }
|
@Override public boolean eject() { return false; }
|
||||||
@Override public boolean leaveVehicle() { return false; }
|
@Override public boolean leaveVehicle() { return false; }
|
||||||
@Override public void playEffect(EntityEffect effect) { }
|
@Override public void playEffect(EntityEffect effect) { }
|
||||||
@Override public void setCustomName(String name) { }
|
@Override public void setCustomName(String name) { }
|
||||||
@Override public void setCustomNameVisible(boolean flag) { }
|
@Override public void setCustomNameVisible(boolean flag) { }
|
||||||
@Override public void setGlowing(boolean flag) { }
|
@Override public void setGlowing(boolean flag) { }
|
||||||
@Override public void setGravity(boolean gravity) { }
|
@Override public void setGravity(boolean gravity) { }
|
||||||
@Override public void setInvulnerable(boolean flag) { }
|
@Override public void setInvulnerable(boolean flag) { }
|
||||||
@Override public void setMomentum(Vector value) { }
|
@Override public void setMomentum(Vector value) { }
|
||||||
@Override public void setSilent(boolean flag) { }
|
@Override public void setSilent(boolean flag) { }
|
||||||
@Override public void setTicksLived(int value) { }
|
@Override public void setTicksLived(int value) { }
|
||||||
|
|
||||||
// Methods from Item
|
// Methods from Item
|
||||||
@Override public void setItemStack(ItemStack stack) { }
|
@Override public void setItemStack(ItemStack stack) { }
|
||||||
@Override public void setPickupDelay(int delay) { }
|
@Override public void setPickupDelay(int delay) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,49 +27,49 @@ import java.util.Collection;
|
||||||
|
|
||||||
public class CraftNMSSlime extends CraftSlime {
|
public class CraftNMSSlime extends CraftSlime {
|
||||||
|
|
||||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow all the bukkit methods.
|
// Disallow all the bukkit methods.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
// Cannot be removed, this is the most important to override.
|
// Cannot be removed, this is the most important to override.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from LivingEntity class
|
// Methods from LivingEntity class
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||||
@Override public void setAI(boolean ai) { }
|
@Override public void setAI(boolean ai) { }
|
||||||
@Override public void setCanPickupItems(boolean pickup) { }
|
@Override public void setCanPickupItems(boolean pickup) { }
|
||||||
@Override public void setCollidable(boolean collidable) { }
|
@Override public void setCollidable(boolean collidable) { }
|
||||||
@Override public void setGliding(boolean gliding) { }
|
@Override public void setGliding(boolean gliding) { }
|
||||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||||
|
|
||||||
// Methods from Entity
|
// Methods from Entity
|
||||||
@Override public void setVelocity(Vector vel) { }
|
@Override public void setVelocity(Vector vel) { }
|
||||||
@Override public boolean teleport(Location loc) { return false; }
|
@Override public boolean teleport(Location loc) { return false; }
|
||||||
@Override public boolean teleport(Entity entity) { return false; }
|
@Override public boolean teleport(Entity entity) { return false; }
|
||||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||||
@Override public void setFireTicks(int ticks) { }
|
@Override public void setFireTicks(int ticks) { }
|
||||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||||
@Override public boolean eject() { return false; }
|
@Override public boolean eject() { return false; }
|
||||||
@Override public boolean leaveVehicle() { return false; }
|
@Override public boolean leaveVehicle() { return false; }
|
||||||
@Override public void playEffect(EntityEffect effect) { }
|
@Override public void playEffect(EntityEffect effect) { }
|
||||||
@Override public void setCustomName(String name) { }
|
@Override public void setCustomName(String name) { }
|
||||||
@Override public void setCustomNameVisible(boolean flag) { }
|
@Override public void setCustomNameVisible(boolean flag) { }
|
||||||
@Override public void setGlowing(boolean flag) { }
|
@Override public void setGlowing(boolean flag) { }
|
||||||
@Override public void setGravity(boolean gravity) { }
|
@Override public void setGravity(boolean gravity) { }
|
||||||
@Override public void setInvulnerable(boolean flag) { }
|
@Override public void setInvulnerable(boolean flag) { }
|
||||||
@Override public void setMomentum(Vector value) { }
|
@Override public void setMomentum(Vector value) { }
|
||||||
@Override public void setSilent(boolean flag) { }
|
@Override public void setSilent(boolean flag) { }
|
||||||
@Override public void setTicksLived(int value) { }
|
@Override public void setTicksLived(int value) { }
|
||||||
|
|
||||||
// Methods from Slime
|
// Methods from Slime
|
||||||
@Override public void setSize(int size) { }
|
@Override public void setSize(int size) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,208 +35,208 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
|
||||||
|
|
||||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
||||||
|
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
private String customName;
|
private String customName;
|
||||||
|
|
||||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||||
super(world);
|
super(world);
|
||||||
super.setInvisible(true);
|
super.setInvisible(true);
|
||||||
super.setSmall(true);
|
super.setSmall(true);
|
||||||
super.setArms(false);
|
super.setArms(false);
|
||||||
super.setNoGravity(true);
|
super.setNoGravity(true);
|
||||||
super.setBasePlate(true);
|
super.setBasePlate(true);
|
||||||
super.setMarker(true);
|
super.setMarker(true);
|
||||||
super.collides = false;
|
super.collides = false;
|
||||||
this.parentPiece = parentPiece;
|
this.parentPiece = parentPiece;
|
||||||
forceSetBoundingBox(new NullBoundingBox());
|
forceSetBoundingBox(new NullBoundingBox());
|
||||||
|
|
||||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void A_() {
|
public void A_() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||||
if (this.onGround) {
|
if (this.onGround) {
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inactiveTick() {
|
public void inactiveTick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||||
if (this.onGround) {
|
if (this.onGround) {
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(NBTTagCompound nbttagcompound) {
|
public boolean c(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(NBTTagCompound nbttagcompound) {
|
public boolean d(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void f(NBTTagCompound nbttagcompound) {
|
public void f(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvulnerable(DamageSource source) {
|
public boolean isInvulnerable(DamageSource source) {
|
||||||
/*
|
/*
|
||||||
* The field Entity.invulnerable is private.
|
* The field Entity.invulnerable is private.
|
||||||
* It's only used while saving NBTTags, but since the entity would be killed
|
* It's only used while saving NBTTags, but since the entity would be killed
|
||||||
* on chunk unload, we prefer to override isInvulnerable().
|
* on chunk unload, we prefer to override isInvulnerable().
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomName(String customName) {
|
public void setCustomName(String customName) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomNameVisible(boolean visible) {
|
public void setCustomNameVisible(boolean visible) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||||
// Prevent stand being equipped
|
// Prevent stand being equipped
|
||||||
return EnumInteractionResult.PASS;
|
return EnumInteractionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(int i, ItemStack item) {
|
public boolean c(int i, ItemStack item) {
|
||||||
// Prevent stand being equipped
|
// Prevent stand being equipped
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||||
// Prevent stand being equipped
|
// Prevent stand being equipped
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(AxisAlignedBB boundingBox) {
|
public void a(AxisAlignedBB boundingBox) {
|
||||||
// Do not change it!
|
// Do not change it!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||||
super.a(boundingBox);
|
super.a(boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||||
// Remove sounds.
|
// Remove sounds.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomNameNMS(String name) {
|
public void setCustomNameNMS(String name) {
|
||||||
this.customName = Utils.limitLength(name, 300);
|
this.customName = Utils.limitLength(name, 300);
|
||||||
super.setCustomName(customName);
|
super.setCustomName(customName);
|
||||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCustomNameStringNMS() {
|
public String getCustomNameStringNMS() {
|
||||||
return this.customName;
|
return this.customName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getCustomNameObjectNMS() {
|
public Object getCustomNameObjectNMS() {
|
||||||
return super.getCustomName();
|
return super.getCustomName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
// Prevent being killed.
|
// Prevent being killed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||||
}
|
}
|
||||||
return super.bukkitEntity;
|
return super.bukkitEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void killEntityNMS() {
|
public void killEntityNMS() {
|
||||||
super.dead = true;
|
super.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
if (broadcastLocationPacket) {
|
if (broadcastLocationPacket) {
|
||||||
broadcastLocationPacketNMS();
|
broadcastLocationPacketNMS();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object obj : super.world.players) {
|
for (Object obj : super.world.players) {
|
||||||
if (obj instanceof EntityPlayer) {
|
if (obj instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return super.dead;
|
return super.dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIdNMS() {
|
public int getIdNMS() {
|
||||||
return super.getId();
|
return super.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HologramLine getHologramLine() {
|
public HologramLine getHologramLine() {
|
||||||
return parentPiece;
|
return parentPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||||
return getBukkitEntity();
|
return getBukkitEntity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,207 +39,207 @@ import org.bukkit.entity.Player;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||||
|
|
||||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||||
|
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
private ItemPickupManager itemPickupManager;
|
private ItemPickupManager itemPickupManager;
|
||||||
|
|
||||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||||
super(world);
|
super(world);
|
||||||
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
||||||
this.parentPiece = piece;
|
this.parentPiece = piece;
|
||||||
this.itemPickupManager = itemPickupManager;
|
this.itemPickupManager = itemPickupManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void A_() {
|
public void A_() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inactiveTick() {
|
public void inactiveTick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method called when a player is near.
|
// Method called when a player is near.
|
||||||
@Override
|
@Override
|
||||||
public void d(EntityHuman human) {
|
public void d(EntityHuman human) {
|
||||||
|
|
||||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||||
// Too low or too high, it's a bit weird.
|
// Too low or too high, it's a bit weird.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||||
// It is never added to the inventory.
|
// It is never added to the inventory.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(NBTTagCompound nbttagcompound) {
|
public boolean c(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(NBTTagCompound nbttagcompound) {
|
public boolean d(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void f(NBTTagCompound nbttagcompound) {
|
public void f(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvulnerable(DamageSource source) {
|
public boolean isInvulnerable(DamageSource source) {
|
||||||
/*
|
/*
|
||||||
* The field Entity.invulnerable is private.
|
* The field Entity.invulnerable is private.
|
||||||
* It's only used while saving NBTTags, but since the entity would be killed
|
* It's only used while saving NBTTags, but since the entity would be killed
|
||||||
* on chunk unload, we prefer to override isInvulnerable().
|
* on chunk unload, we prefer to override isInvulnerable().
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
// Prevent being killed.
|
// Prevent being killed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAlive() {
|
public boolean isAlive() {
|
||||||
// This override prevents items from being picked up by hoppers.
|
// This override prevents items from being picked up by hoppers.
|
||||||
// Should have no side effects.
|
// Should have no side effects.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||||
}
|
}
|
||||||
return super.bukkitEntity;
|
return super.bukkitEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return super.dead;
|
return super.dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void killEntityNMS() {
|
public void killEntityNMS() {
|
||||||
super.dead = true;
|
super.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocationNMS(double x, double y, double z) {
|
public void setLocationNMS(double x, double y, double z) {
|
||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
||||||
ItemStack newItem = CraftItemStack.asNMSCopy(stack); // ItemStack.a is returned if the stack is null, invalid or the material is not an Item
|
ItemStack newItem = CraftItemStack.asNMSCopy(stack); // ItemStack.a is returned if the stack is null, invalid or the material is not an Item
|
||||||
|
|
||||||
if (newItem == null || newItem == ItemStack.a) {
|
if (newItem == null || newItem == ItemStack.a) {
|
||||||
newItem = new ItemStack(Blocks.BEDROCK);
|
newItem = new ItemStack(Blocks.BEDROCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newItem.getTag() == null) {
|
if (newItem.getTag() == null) {
|
||||||
newItem.setTag(new NBTTagCompound());
|
newItem.setTag(new NBTTagCompound());
|
||||||
}
|
}
|
||||||
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
||||||
if (!newItem.getTag().hasKey("display")) {
|
if (!newItem.getTag().hasKey("display")) {
|
||||||
newItem.getTag().set("display", display);
|
newItem.getTag().set("display", display);
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTagList tagList = new NBTTagList();
|
NBTTagList tagList = new NBTTagList();
|
||||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||||
display.set("Lore", tagList);
|
display.set("Lore", tagList);
|
||||||
|
|
||||||
setItemStack(newItem);
|
setItemStack(newItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIdNMS() {
|
public int getIdNMS() {
|
||||||
return super.getId();
|
return super.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemLine getHologramLine() {
|
public ItemLine getHologramLine() {
|
||||||
return parentPiece;
|
return parentPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void allowPickup(boolean pickup) {
|
public void allowPickup(boolean pickup) {
|
||||||
if (pickup) {
|
if (pickup) {
|
||||||
super.pickupDelay = 0;
|
super.pickupDelay = 0;
|
||||||
} else {
|
} else {
|
||||||
super.pickupDelay = 32767;
|
super.pickupDelay = 32767;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||||
return getBukkitEntity();
|
return getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||||
// It should never dismount
|
// It should never dismount
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity entity = (Entity) vehicleBase;
|
Entity entity = (Entity) vehicleBase;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (super.bB() != null) {
|
if (super.bB() != null) {
|
||||||
Entity oldVehicle = super.bB();
|
Entity oldVehicle = super.bB();
|
||||||
VEHICLE_FIELD.set(this, null);
|
VEHICLE_FIELD.set(this, null);
|
||||||
oldVehicle.passengers.remove(this);
|
oldVehicle.passengers.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
VEHICLE_FIELD.set(this, entity);
|
VEHICLE_FIELD.set(this, entity);
|
||||||
entity.passengers.clear();
|
entity.passengers.clear();
|
||||||
entity.passengers.add(this);
|
entity.passengers.add(this);
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getRawItemStack() {
|
public Object getRawItemStack() {
|
||||||
return super.getItemStack();
|
return super.getItemStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,186 +35,186 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||||
|
|
||||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||||
|
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
|
||||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||||
super(world);
|
super(world);
|
||||||
super.persistent = true;
|
super.persistent = true;
|
||||||
super.collides = false;
|
super.collides = false;
|
||||||
a(0.0F, 0.0F);
|
a(0.0F, 0.0F);
|
||||||
setSize(1, false);
|
setSize(1, false);
|
||||||
setInvisible(true);
|
setInvisible(true);
|
||||||
this.parentPiece = parentPiece;
|
this.parentPiece = parentPiece;
|
||||||
forceSetBoundingBox(new NullBoundingBox());
|
forceSetBoundingBox(new NullBoundingBox());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void A_() {
|
public void A_() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inactiveTick() {
|
public void inactiveTick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(AxisAlignedBB boundingBox) {
|
public void a(AxisAlignedBB boundingBox) {
|
||||||
// Do not change it!
|
// Do not change it!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||||
super.a(boundingBox);
|
super.a(boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(NBTTagCompound nbttagcompound) {
|
public boolean c(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(NBTTagCompound nbttagcompound) {
|
public boolean d(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void f(NBTTagCompound nbttagcompound) {
|
public void f(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||||
if (damageSource instanceof EntityDamageSource) {
|
if (damageSource instanceof EntityDamageSource) {
|
||||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvulnerable(DamageSource source) {
|
public boolean isInvulnerable(DamageSource source) {
|
||||||
/*
|
/*
|
||||||
* The field Entity.invulnerable is private.
|
* The field Entity.invulnerable is private.
|
||||||
* It's only used while saving NBTTags, but since the entity would be killed
|
* It's only used while saving NBTTags, but since the entity would be killed
|
||||||
* on chunk unload, we prefer to override isInvulnerable().
|
* on chunk unload, we prefer to override isInvulnerable().
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomName(String customName) {
|
public void setCustomName(String customName) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomNameVisible(boolean visible) {
|
public void setCustomNameVisible(boolean visible) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||||
// Remove sounds.
|
// Remove sounds.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
// Prevent being killed.
|
// Prevent being killed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||||
}
|
}
|
||||||
return super.bukkitEntity;
|
return super.bukkitEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return super.dead;
|
return super.dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void killEntityNMS() {
|
public void killEntityNMS() {
|
||||||
super.dead = true;
|
super.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocationNMS(double x, double y, double z) {
|
public void setLocationNMS(double x, double y, double z) {
|
||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIdNMS() {
|
public int getIdNMS() {
|
||||||
return super.getId();
|
return super.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HologramLine getHologramLine() {
|
public HologramLine getHologramLine() {
|
||||||
return parentPiece;
|
return parentPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||||
return getBukkitEntity();
|
return getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||||
// It should never dismount
|
// It should never dismount
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity entity = (Entity) vehicleBase;
|
Entity entity = (Entity) vehicleBase;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (super.bB() != null) {
|
if (super.bB() != null) {
|
||||||
Entity oldVehicle = super.bB();
|
Entity oldVehicle = super.bB();
|
||||||
VEHICLE_FIELD.set(this, null);
|
VEHICLE_FIELD.set(this, null);
|
||||||
oldVehicle.passengers.remove(this);
|
oldVehicle.passengers.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
VEHICLE_FIELD.set(this, entity);
|
VEHICLE_FIELD.set(this, entity);
|
||||||
entity.passengers.clear();
|
entity.passengers.clear();
|
||||||
entity.passengers.add(this);
|
entity.passengers.add(this);
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,77 +40,77 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class NmsManagerImpl implements NMSManager {
|
public class NmsManagerImpl implements NMSManager {
|
||||||
|
|
||||||
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
|
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
|
||||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
|
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||||
validateEntityMethod.setAccessible(true);
|
validateEntityMethod.setAccessible(true);
|
||||||
|
|
||||||
registerCustomEntity(EntityNMSSlime.class, 55);
|
registerCustomEntity(EntityNMSSlime.class, 55);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||||
// Use reflection to get the RegistryID of entities.
|
// Use reflection to get the RegistryID of entities.
|
||||||
RegistryID<Class<? extends Entity>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b);
|
RegistryID<Class<? extends Entity>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b);
|
||||||
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
||||||
|
|
||||||
// Save the the ID -> entity class mapping before the registration.
|
// Save the the ID -> entity class mapping before the registration.
|
||||||
Object oldValue = idToClassMap[id];
|
Object oldValue = idToClassMap[id];
|
||||||
|
|
||||||
// Register the entity class.
|
// Register the entity class.
|
||||||
registryID.a(entityClass, id);
|
registryID.a(entityClass, id);
|
||||||
|
|
||||||
// Restore the ID -> entity class mapping.
|
// Restore the ID -> entity class mapping.
|
||||||
idToClassMap[id] = oldValue;
|
idToClassMap[id] = oldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||||
customItem.setLocationNMS(x, y, z);
|
customItem.setLocationNMS(x, y, z);
|
||||||
customItem.setItemStackNMS(stack);
|
customItem.setItemStackNMS(stack);
|
||||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||||
}
|
}
|
||||||
return customItem;
|
return customItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||||
touchSlime.setLocationNMS(x, y, z);
|
touchSlime.setLocationNMS(x, y, z);
|
||||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||||
}
|
}
|
||||||
return touchSlime;
|
return touchSlime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||||
}
|
}
|
||||||
return invisibleArmorStand;
|
return invisibleArmorStand;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||||
|
|
||||||
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
||||||
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
||||||
|
|
||||||
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
||||||
// This should never happen
|
// This should never happen
|
||||||
nmsEntity.dead = true;
|
nmsEntity.dead = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -119,45 +119,45 @@ public class NmsManagerImpl implements NMSManager {
|
||||||
nmsWorld.entityList.add(nmsEntity);
|
nmsWorld.entityList.add(nmsEntity);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||||
|
|
||||||
if (nmsEntity instanceof NMSEntityBase) {
|
if (nmsEntity instanceof NMSEntityBase) {
|
||||||
return ((NMSEntityBase) nmsEntity);
|
return ((NMSEntityBase) nmsEntity);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||||
|
|
||||||
if (nmsEntity instanceof NMSEntityBase) {
|
if (nmsEntity instanceof NMSEntityBase) {
|
||||||
return ((NMSEntityBase) nmsEntity);
|
return ((NMSEntityBase) nmsEntity);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
||||||
return CustomNameHelper.replaceCustomNameString(customNameObject, target, replacement);
|
return CustomNameHelper.replaceCustomNameString(customNameObject, target, replacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,121 +21,121 @@ import net.minecraft.server.v1_11_R1.Vec3D;
|
||||||
|
|
||||||
public class NullBoundingBox extends AxisAlignedBB {
|
public class NullBoundingBox extends AxisAlignedBB {
|
||||||
|
|
||||||
public NullBoundingBox() {
|
public NullBoundingBox() {
|
||||||
super(0, 0, 0, 0, 0, 0);
|
super(0, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double a() {
|
public double a() {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double a(AxisAlignedBB arg0, double arg1) {
|
public double a(AxisAlignedBB arg0, double arg1) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double b(AxisAlignedBB arg0, double arg1) {
|
public double b(AxisAlignedBB arg0, double arg1) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double c(AxisAlignedBB arg0, double arg1) {
|
public double c(AxisAlignedBB arg0, double arg1) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB shrink(double arg0) {
|
public AxisAlignedBB shrink(double arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(BlockPosition arg0) {
|
public AxisAlignedBB a(BlockPosition arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean b(Vec3D arg0) {
|
public boolean b(Vec3D arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(Vec3D arg0) {
|
public boolean c(Vec3D arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(Vec3D arg0) {
|
public boolean d(Vec3D arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB e(double arg0) {
|
public AxisAlignedBB e(double arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB g(double arg0) {
|
public AxisAlignedBB g(double arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(Vec3D arg0) {
|
public AxisAlignedBB a(Vec3D arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(AxisAlignedBB arg0) {
|
public boolean c(AxisAlignedBB arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean e(Vec3D arg0) {
|
public boolean e(Vec3D arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||||
<artifactId>holographicdisplays-nms</artifactId>
|
<artifactId>holographicdisplays-nms</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>holographicdisplays-nms-v1_12_r1</artifactId>
|
<artifactId>holographicdisplays-nms-v1_12_r1</artifactId>
|
||||||
<name>HolographicDisplays NMS v1_12_R1</name>
|
<name>HolographicDisplays NMS v1_12_R1</name>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>nms-repo</id>
|
<id>nms-repo</id>
|
||||||
<url>https://repo.codemc.io/repository/nms/</url>
|
<url>https://repo.codemc.io/repository/nms/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-utils</artifactId>
|
<artifactId>holographicdisplays-utils</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.12-R0.1-SNAPSHOT</version>
|
<version>1.12-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -29,65 +29,65 @@ import java.util.Collection;
|
||||||
|
|
||||||
public class CraftNMSArmorStand extends CraftArmorStand {
|
public class CraftNMSArmorStand extends CraftArmorStand {
|
||||||
|
|
||||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow all the bukkit methods.
|
// Disallow all the bukkit methods.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
// Cannot be removed, this is the most important to override.
|
// Cannot be removed, this is the most important to override.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from Armor stand class
|
// Methods from Armor stand class
|
||||||
|
|
||||||
@Override public void setArms(boolean arms) { }
|
@Override public void setArms(boolean arms) { }
|
||||||
@Override public void setBasePlate(boolean basePlate) { }
|
@Override public void setBasePlate(boolean basePlate) { }
|
||||||
@Override public void setBodyPose(EulerAngle pose) { }
|
@Override public void setBodyPose(EulerAngle pose) { }
|
||||||
@Override public void setBoots(ItemStack item) { }
|
@Override public void setBoots(ItemStack item) { }
|
||||||
@Override public void setChestplate(ItemStack item) { }
|
@Override public void setChestplate(ItemStack item) { }
|
||||||
@Override public void setHeadPose(EulerAngle pose) { }
|
@Override public void setHeadPose(EulerAngle pose) { }
|
||||||
@Override public void setHelmet(ItemStack item) { }
|
@Override public void setHelmet(ItemStack item) { }
|
||||||
@Override public void setItemInHand(ItemStack item) { }
|
@Override public void setItemInHand(ItemStack item) { }
|
||||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||||
@Override public void setLeggings(ItemStack item) { }
|
@Override public void setLeggings(ItemStack item) { }
|
||||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||||
@Override public void setSmall(boolean small) { }
|
@Override public void setSmall(boolean small) { }
|
||||||
@Override public void setVisible(boolean visible) { }
|
@Override public void setVisible(boolean visible) { }
|
||||||
@Override public void setMarker(boolean marker) { }
|
@Override public void setMarker(boolean marker) { }
|
||||||
|
|
||||||
// Methods from LivingEntity class
|
// Methods from LivingEntity class
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||||
@Override public void setAI(boolean ai) { }
|
@Override public void setAI(boolean ai) { }
|
||||||
@Override public void setCanPickupItems(boolean pickup) { }
|
@Override public void setCanPickupItems(boolean pickup) { }
|
||||||
@Override public void setCollidable(boolean collidable) { }
|
@Override public void setCollidable(boolean collidable) { }
|
||||||
@Override public void setGliding(boolean gliding) { }
|
@Override public void setGliding(boolean gliding) { }
|
||||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||||
|
|
||||||
// Methods from Entity
|
// Methods from Entity
|
||||||
@Override public void setVelocity(Vector vel) { }
|
@Override public void setVelocity(Vector vel) { }
|
||||||
@Override public boolean teleport(Location loc) { return false; }
|
@Override public boolean teleport(Location loc) { return false; }
|
||||||
@Override public boolean teleport(Entity entity) { return false; }
|
@Override public boolean teleport(Entity entity) { return false; }
|
||||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||||
@Override public void setFireTicks(int ticks) { }
|
@Override public void setFireTicks(int ticks) { }
|
||||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||||
@Override public boolean eject() { return false; }
|
@Override public boolean eject() { return false; }
|
||||||
@Override public boolean leaveVehicle() { return false; }
|
@Override public boolean leaveVehicle() { return false; }
|
||||||
@Override public void playEffect(EntityEffect effect) { }
|
@Override public void playEffect(EntityEffect effect) { }
|
||||||
@Override public void setCustomName(String name) { }
|
@Override public void setCustomName(String name) { }
|
||||||
@Override public void setCustomNameVisible(boolean flag) { }
|
@Override public void setCustomNameVisible(boolean flag) { }
|
||||||
@Override public void setGlowing(boolean flag) { }
|
@Override public void setGlowing(boolean flag) { }
|
||||||
@Override public void setGravity(boolean gravity) { }
|
@Override public void setGravity(boolean gravity) { }
|
||||||
@Override public void setInvulnerable(boolean flag) { }
|
@Override public void setInvulnerable(boolean flag) { }
|
||||||
@Override public void setMomentum(Vector value) { }
|
@Override public void setMomentum(Vector value) { }
|
||||||
@Override public void setSilent(boolean flag) { }
|
@Override public void setSilent(boolean flag) { }
|
||||||
@Override public void setTicksLived(int value) { }
|
@Override public void setTicksLived(int value) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,39 +25,39 @@ import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class CraftNMSItem extends CraftItem {
|
public class CraftNMSItem extends CraftItem {
|
||||||
|
|
||||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow all the bukkit methods.
|
// Disallow all the bukkit methods.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
// Cannot be removed, this is the most important to override.
|
// Cannot be removed, this is the most important to override.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from Entity
|
// Methods from Entity
|
||||||
@Override public void setVelocity(Vector vel) { }
|
@Override public void setVelocity(Vector vel) { }
|
||||||
@Override public boolean teleport(Location loc) { return false; }
|
@Override public boolean teleport(Location loc) { return false; }
|
||||||
@Override public boolean teleport(Entity entity) { return false; }
|
@Override public boolean teleport(Entity entity) { return false; }
|
||||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||||
@Override public void setFireTicks(int ticks) { }
|
@Override public void setFireTicks(int ticks) { }
|
||||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||||
@Override public boolean eject() { return false; }
|
@Override public boolean eject() { return false; }
|
||||||
@Override public boolean leaveVehicle() { return false; }
|
@Override public boolean leaveVehicle() { return false; }
|
||||||
@Override public void playEffect(EntityEffect effect) { }
|
@Override public void playEffect(EntityEffect effect) { }
|
||||||
@Override public void setCustomName(String name) { }
|
@Override public void setCustomName(String name) { }
|
||||||
@Override public void setCustomNameVisible(boolean flag) { }
|
@Override public void setCustomNameVisible(boolean flag) { }
|
||||||
@Override public void setGlowing(boolean flag) { }
|
@Override public void setGlowing(boolean flag) { }
|
||||||
@Override public void setGravity(boolean gravity) { }
|
@Override public void setGravity(boolean gravity) { }
|
||||||
@Override public void setInvulnerable(boolean flag) { }
|
@Override public void setInvulnerable(boolean flag) { }
|
||||||
@Override public void setMomentum(Vector value) { }
|
@Override public void setMomentum(Vector value) { }
|
||||||
@Override public void setSilent(boolean flag) { }
|
@Override public void setSilent(boolean flag) { }
|
||||||
@Override public void setTicksLived(int value) { }
|
@Override public void setTicksLived(int value) { }
|
||||||
|
|
||||||
// Methods from Item
|
// Methods from Item
|
||||||
@Override public void setItemStack(ItemStack stack) { }
|
@Override public void setItemStack(ItemStack stack) { }
|
||||||
@Override public void setPickupDelay(int delay) { }
|
@Override public void setPickupDelay(int delay) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,49 +27,49 @@ import java.util.Collection;
|
||||||
|
|
||||||
public class CraftNMSSlime extends CraftSlime {
|
public class CraftNMSSlime extends CraftSlime {
|
||||||
|
|
||||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow all the bukkit methods.
|
// Disallow all the bukkit methods.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
// Cannot be removed, this is the most important to override.
|
// Cannot be removed, this is the most important to override.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from LivingEntity class
|
// Methods from LivingEntity class
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||||
@Override public void setAI(boolean ai) { }
|
@Override public void setAI(boolean ai) { }
|
||||||
@Override public void setCanPickupItems(boolean pickup) { }
|
@Override public void setCanPickupItems(boolean pickup) { }
|
||||||
@Override public void setCollidable(boolean collidable) { }
|
@Override public void setCollidable(boolean collidable) { }
|
||||||
@Override public void setGliding(boolean gliding) { }
|
@Override public void setGliding(boolean gliding) { }
|
||||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||||
|
|
||||||
// Methods from Entity
|
// Methods from Entity
|
||||||
@Override public void setVelocity(Vector vel) { }
|
@Override public void setVelocity(Vector vel) { }
|
||||||
@Override public boolean teleport(Location loc) { return false; }
|
@Override public boolean teleport(Location loc) { return false; }
|
||||||
@Override public boolean teleport(Entity entity) { return false; }
|
@Override public boolean teleport(Entity entity) { return false; }
|
||||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||||
@Override public void setFireTicks(int ticks) { }
|
@Override public void setFireTicks(int ticks) { }
|
||||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||||
@Override public boolean eject() { return false; }
|
@Override public boolean eject() { return false; }
|
||||||
@Override public boolean leaveVehicle() { return false; }
|
@Override public boolean leaveVehicle() { return false; }
|
||||||
@Override public void playEffect(EntityEffect effect) { }
|
@Override public void playEffect(EntityEffect effect) { }
|
||||||
@Override public void setCustomName(String name) { }
|
@Override public void setCustomName(String name) { }
|
||||||
@Override public void setCustomNameVisible(boolean flag) { }
|
@Override public void setCustomNameVisible(boolean flag) { }
|
||||||
@Override public void setGlowing(boolean flag) { }
|
@Override public void setGlowing(boolean flag) { }
|
||||||
@Override public void setGravity(boolean gravity) { }
|
@Override public void setGravity(boolean gravity) { }
|
||||||
@Override public void setInvulnerable(boolean flag) { }
|
@Override public void setInvulnerable(boolean flag) { }
|
||||||
@Override public void setMomentum(Vector value) { }
|
@Override public void setMomentum(Vector value) { }
|
||||||
@Override public void setSilent(boolean flag) { }
|
@Override public void setSilent(boolean flag) { }
|
||||||
@Override public void setTicksLived(int value) { }
|
@Override public void setTicksLived(int value) { }
|
||||||
|
|
||||||
// Methods from Slime
|
// Methods from Slime
|
||||||
@Override public void setSize(int size) { }
|
@Override public void setSize(int size) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,208 +35,208 @@ import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
|
||||||
|
|
||||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
||||||
|
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
private String customName;
|
private String customName;
|
||||||
|
|
||||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||||
super(world);
|
super(world);
|
||||||
super.setInvisible(true);
|
super.setInvisible(true);
|
||||||
super.setSmall(true);
|
super.setSmall(true);
|
||||||
super.setArms(false);
|
super.setArms(false);
|
||||||
super.setNoGravity(true);
|
super.setNoGravity(true);
|
||||||
super.setBasePlate(true);
|
super.setBasePlate(true);
|
||||||
super.setMarker(true);
|
super.setMarker(true);
|
||||||
super.collides = false;
|
super.collides = false;
|
||||||
this.parentPiece = parentPiece;
|
this.parentPiece = parentPiece;
|
||||||
forceSetBoundingBox(new NullBoundingBox());
|
forceSetBoundingBox(new NullBoundingBox());
|
||||||
|
|
||||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void B_() {
|
public void B_() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||||
if (this.onGround) {
|
if (this.onGround) {
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inactiveTick() {
|
public void inactiveTick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||||
if (this.onGround) {
|
if (this.onGround) {
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(NBTTagCompound nbttagcompound) {
|
public boolean c(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(NBTTagCompound nbttagcompound) {
|
public boolean d(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void f(NBTTagCompound nbttagcompound) {
|
public void f(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvulnerable(DamageSource source) {
|
public boolean isInvulnerable(DamageSource source) {
|
||||||
/*
|
/*
|
||||||
* The field Entity.invulnerable is private.
|
* The field Entity.invulnerable is private.
|
||||||
* It's only used while saving NBTTags, but since the entity would be killed
|
* It's only used while saving NBTTags, but since the entity would be killed
|
||||||
* on chunk unload, we prefer to override isInvulnerable().
|
* on chunk unload, we prefer to override isInvulnerable().
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomName(String customName) {
|
public void setCustomName(String customName) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomNameVisible(boolean visible) {
|
public void setCustomNameVisible(boolean visible) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||||
// Prevent stand being equipped
|
// Prevent stand being equipped
|
||||||
return EnumInteractionResult.PASS;
|
return EnumInteractionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(int i, ItemStack item) {
|
public boolean c(int i, ItemStack item) {
|
||||||
// Prevent stand being equipped
|
// Prevent stand being equipped
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||||
// Prevent stand being equipped
|
// Prevent stand being equipped
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(AxisAlignedBB boundingBox) {
|
public void a(AxisAlignedBB boundingBox) {
|
||||||
// Do not change it!
|
// Do not change it!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||||
super.a(boundingBox);
|
super.a(boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||||
// Remove sounds.
|
// Remove sounds.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomNameNMS(String name) {
|
public void setCustomNameNMS(String name) {
|
||||||
this.customName = Utils.limitLength(name, 300);
|
this.customName = Utils.limitLength(name, 300);
|
||||||
super.setCustomName(customName);
|
super.setCustomName(customName);
|
||||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCustomNameStringNMS() {
|
public String getCustomNameStringNMS() {
|
||||||
return this.customName;
|
return this.customName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getCustomNameObjectNMS() {
|
public Object getCustomNameObjectNMS() {
|
||||||
return super.getCustomName();
|
return super.getCustomName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
// Prevent being killed.
|
// Prevent being killed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||||
}
|
}
|
||||||
return super.bukkitEntity;
|
return super.bukkitEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void killEntityNMS() {
|
public void killEntityNMS() {
|
||||||
super.dead = true;
|
super.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
if (broadcastLocationPacket) {
|
if (broadcastLocationPacket) {
|
||||||
broadcastLocationPacketNMS();
|
broadcastLocationPacketNMS();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object obj : super.world.players) {
|
for (Object obj : super.world.players) {
|
||||||
if (obj instanceof EntityPlayer) {
|
if (obj instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return super.dead;
|
return super.dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIdNMS() {
|
public int getIdNMS() {
|
||||||
return super.getId();
|
return super.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HologramLine getHologramLine() {
|
public HologramLine getHologramLine() {
|
||||||
return parentPiece;
|
return parentPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||||
return getBukkitEntity();
|
return getBukkitEntity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,207 +39,207 @@ import org.bukkit.entity.Player;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||||
|
|
||||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||||
|
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
private ItemPickupManager itemPickupManager;
|
private ItemPickupManager itemPickupManager;
|
||||||
|
|
||||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||||
super(world);
|
super(world);
|
||||||
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
||||||
this.parentPiece = piece;
|
this.parentPiece = piece;
|
||||||
this.itemPickupManager = itemPickupManager;
|
this.itemPickupManager = itemPickupManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void B_() {
|
public void B_() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inactiveTick() {
|
public void inactiveTick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method called when a player is near.
|
// Method called when a player is near.
|
||||||
@Override
|
@Override
|
||||||
public void d(EntityHuman human) {
|
public void d(EntityHuman human) {
|
||||||
|
|
||||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||||
// Too low or too high, it's a bit weird.
|
// Too low or too high, it's a bit weird.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||||
// It is never added to the inventory.
|
// It is never added to the inventory.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(NBTTagCompound nbttagcompound) {
|
public boolean c(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(NBTTagCompound nbttagcompound) {
|
public boolean d(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void f(NBTTagCompound nbttagcompound) {
|
public void f(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvulnerable(DamageSource source) {
|
public boolean isInvulnerable(DamageSource source) {
|
||||||
/*
|
/*
|
||||||
* The field Entity.invulnerable is private.
|
* The field Entity.invulnerable is private.
|
||||||
* It's only used while saving NBTTags, but since the entity would be killed
|
* It's only used while saving NBTTags, but since the entity would be killed
|
||||||
* on chunk unload, we prefer to override isInvulnerable().
|
* on chunk unload, we prefer to override isInvulnerable().
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
// Prevent being killed.
|
// Prevent being killed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAlive() {
|
public boolean isAlive() {
|
||||||
// This override prevents items from being picked up by hoppers.
|
// This override prevents items from being picked up by hoppers.
|
||||||
// Should have no side effects.
|
// Should have no side effects.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||||
}
|
}
|
||||||
return super.bukkitEntity;
|
return super.bukkitEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return super.dead;
|
return super.dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void killEntityNMS() {
|
public void killEntityNMS() {
|
||||||
super.dead = true;
|
super.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocationNMS(double x, double y, double z) {
|
public void setLocationNMS(double x, double y, double z) {
|
||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
||||||
ItemStack newItem = CraftItemStack.asNMSCopy(stack); // ItemStack.a is returned if the stack is null, invalid or the material is not an Item
|
ItemStack newItem = CraftItemStack.asNMSCopy(stack); // ItemStack.a is returned if the stack is null, invalid or the material is not an Item
|
||||||
|
|
||||||
if (newItem == null || newItem == ItemStack.a) {
|
if (newItem == null || newItem == ItemStack.a) {
|
||||||
newItem = new ItemStack(Blocks.BEDROCK);
|
newItem = new ItemStack(Blocks.BEDROCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newItem.getTag() == null) {
|
if (newItem.getTag() == null) {
|
||||||
newItem.setTag(new NBTTagCompound());
|
newItem.setTag(new NBTTagCompound());
|
||||||
}
|
}
|
||||||
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
||||||
if (!newItem.getTag().hasKey("display")) {
|
if (!newItem.getTag().hasKey("display")) {
|
||||||
newItem.getTag().set("display", display);
|
newItem.getTag().set("display", display);
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTagList tagList = new NBTTagList();
|
NBTTagList tagList = new NBTTagList();
|
||||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||||
display.set("Lore", tagList);
|
display.set("Lore", tagList);
|
||||||
|
|
||||||
setItemStack(newItem);
|
setItemStack(newItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIdNMS() {
|
public int getIdNMS() {
|
||||||
return super.getId();
|
return super.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemLine getHologramLine() {
|
public ItemLine getHologramLine() {
|
||||||
return parentPiece;
|
return parentPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void allowPickup(boolean pickup) {
|
public void allowPickup(boolean pickup) {
|
||||||
if (pickup) {
|
if (pickup) {
|
||||||
super.pickupDelay = 0;
|
super.pickupDelay = 0;
|
||||||
} else {
|
} else {
|
||||||
super.pickupDelay = 32767;
|
super.pickupDelay = 32767;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||||
return getBukkitEntity();
|
return getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||||
// It should never dismount
|
// It should never dismount
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity entity = (Entity) vehicleBase;
|
Entity entity = (Entity) vehicleBase;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (super.bJ() != null) {
|
if (super.bJ() != null) {
|
||||||
Entity oldVehicle = super.bJ();
|
Entity oldVehicle = super.bJ();
|
||||||
VEHICLE_FIELD.set(this, null);
|
VEHICLE_FIELD.set(this, null);
|
||||||
oldVehicle.passengers.remove(this);
|
oldVehicle.passengers.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
VEHICLE_FIELD.set(this, entity);
|
VEHICLE_FIELD.set(this, entity);
|
||||||
entity.passengers.clear();
|
entity.passengers.clear();
|
||||||
entity.passengers.add(this);
|
entity.passengers.add(this);
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getRawItemStack() {
|
public Object getRawItemStack() {
|
||||||
return super.getItemStack();
|
return super.getItemStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,186 +35,186 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||||
|
|
||||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||||
|
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
|
||||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||||
super(world);
|
super(world);
|
||||||
super.persistent = true;
|
super.persistent = true;
|
||||||
super.collides = false;
|
super.collides = false;
|
||||||
a(0.0F, 0.0F);
|
a(0.0F, 0.0F);
|
||||||
setSize(1, false);
|
setSize(1, false);
|
||||||
setInvisible(true);
|
setInvisible(true);
|
||||||
this.parentPiece = parentPiece;
|
this.parentPiece = parentPiece;
|
||||||
forceSetBoundingBox(new NullBoundingBox());
|
forceSetBoundingBox(new NullBoundingBox());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void B_() {
|
public void B_() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inactiveTick() {
|
public void inactiveTick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(AxisAlignedBB boundingBox) {
|
public void a(AxisAlignedBB boundingBox) {
|
||||||
// Do not change it!
|
// Do not change it!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||||
super.a(boundingBox);
|
super.a(boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(NBTTagCompound nbttagcompound) {
|
public boolean c(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(NBTTagCompound nbttagcompound) {
|
public boolean d(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void f(NBTTagCompound nbttagcompound) {
|
public void f(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||||
if (damageSource instanceof EntityDamageSource) {
|
if (damageSource instanceof EntityDamageSource) {
|
||||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvulnerable(DamageSource source) {
|
public boolean isInvulnerable(DamageSource source) {
|
||||||
/*
|
/*
|
||||||
* The field Entity.invulnerable is private.
|
* The field Entity.invulnerable is private.
|
||||||
* It's only used while saving NBTTags, but since the entity would be killed
|
* It's only used while saving NBTTags, but since the entity would be killed
|
||||||
* on chunk unload, we prefer to override isInvulnerable().
|
* on chunk unload, we prefer to override isInvulnerable().
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomName(String customName) {
|
public void setCustomName(String customName) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomNameVisible(boolean visible) {
|
public void setCustomNameVisible(boolean visible) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||||
// Remove sounds.
|
// Remove sounds.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
// Prevent being killed.
|
// Prevent being killed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||||
}
|
}
|
||||||
return super.bukkitEntity;
|
return super.bukkitEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return super.dead;
|
return super.dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void killEntityNMS() {
|
public void killEntityNMS() {
|
||||||
super.dead = true;
|
super.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocationNMS(double x, double y, double z) {
|
public void setLocationNMS(double x, double y, double z) {
|
||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIdNMS() {
|
public int getIdNMS() {
|
||||||
return super.getId();
|
return super.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HologramLine getHologramLine() {
|
public HologramLine getHologramLine() {
|
||||||
return parentPiece;
|
return parentPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||||
return getBukkitEntity();
|
return getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||||
// It should never dismount
|
// It should never dismount
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity entity = (Entity) vehicleBase;
|
Entity entity = (Entity) vehicleBase;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (super.bJ() != null) {
|
if (super.bJ() != null) {
|
||||||
Entity oldVehicle = super.bJ();
|
Entity oldVehicle = super.bJ();
|
||||||
VEHICLE_FIELD.set(this, null);
|
VEHICLE_FIELD.set(this, null);
|
||||||
oldVehicle.passengers.remove(this);
|
oldVehicle.passengers.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
VEHICLE_FIELD.set(this, entity);
|
VEHICLE_FIELD.set(this, entity);
|
||||||
entity.passengers.clear();
|
entity.passengers.clear();
|
||||||
entity.passengers.add(this);
|
entity.passengers.add(this);
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,77 +40,77 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class NmsManagerImpl implements NMSManager {
|
public class NmsManagerImpl implements NMSManager {
|
||||||
|
|
||||||
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
|
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
|
||||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
|
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||||
validateEntityMethod.setAccessible(true);
|
validateEntityMethod.setAccessible(true);
|
||||||
|
|
||||||
registerCustomEntity(EntityNMSSlime.class, 55);
|
registerCustomEntity(EntityNMSSlime.class, 55);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||||
// Use reflection to get the RegistryID of entities.
|
// Use reflection to get the RegistryID of entities.
|
||||||
RegistryID<Class<? extends Entity>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b);
|
RegistryID<Class<? extends Entity>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b);
|
||||||
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
||||||
|
|
||||||
// Save the the ID -> entity class mapping before the registration.
|
// Save the the ID -> entity class mapping before the registration.
|
||||||
Object oldValue = idToClassMap[id];
|
Object oldValue = idToClassMap[id];
|
||||||
|
|
||||||
// Register the entity class.
|
// Register the entity class.
|
||||||
registryID.a(entityClass, id);
|
registryID.a(entityClass, id);
|
||||||
|
|
||||||
// Restore the ID -> entity class mapping.
|
// Restore the ID -> entity class mapping.
|
||||||
idToClassMap[id] = oldValue;
|
idToClassMap[id] = oldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||||
customItem.setLocationNMS(x, y, z);
|
customItem.setLocationNMS(x, y, z);
|
||||||
customItem.setItemStackNMS(stack);
|
customItem.setItemStackNMS(stack);
|
||||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||||
}
|
}
|
||||||
return customItem;
|
return customItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||||
touchSlime.setLocationNMS(x, y, z);
|
touchSlime.setLocationNMS(x, y, z);
|
||||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||||
}
|
}
|
||||||
return touchSlime;
|
return touchSlime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||||
}
|
}
|
||||||
return invisibleArmorStand;
|
return invisibleArmorStand;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||||
|
|
||||||
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
||||||
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
||||||
|
|
||||||
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
||||||
// This should never happen
|
// This should never happen
|
||||||
nmsEntity.dead = true;
|
nmsEntity.dead = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -119,45 +119,45 @@ public class NmsManagerImpl implements NMSManager {
|
||||||
nmsWorld.entityList.add(nmsEntity);
|
nmsWorld.entityList.add(nmsEntity);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||||
|
|
||||||
if (nmsEntity instanceof NMSEntityBase) {
|
if (nmsEntity instanceof NMSEntityBase) {
|
||||||
return ((NMSEntityBase) nmsEntity);
|
return ((NMSEntityBase) nmsEntity);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||||
|
|
||||||
if (nmsEntity instanceof NMSEntityBase) {
|
if (nmsEntity instanceof NMSEntityBase) {
|
||||||
return ((NMSEntityBase) nmsEntity);
|
return ((NMSEntityBase) nmsEntity);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
||||||
return CustomNameHelper.replaceCustomNameString(customNameObject, target, replacement);
|
return CustomNameHelper.replaceCustomNameString(customNameObject, target, replacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,121 +21,121 @@ import net.minecraft.server.v1_12_R1.Vec3D;
|
||||||
|
|
||||||
public class NullBoundingBox extends AxisAlignedBB {
|
public class NullBoundingBox extends AxisAlignedBB {
|
||||||
|
|
||||||
public NullBoundingBox() {
|
public NullBoundingBox() {
|
||||||
super(0, 0, 0, 0, 0, 0);
|
super(0, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double a() {
|
public double a() {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double a(AxisAlignedBB arg0, double arg1) {
|
public double a(AxisAlignedBB arg0, double arg1) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double b(AxisAlignedBB arg0, double arg1) {
|
public double b(AxisAlignedBB arg0, double arg1) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double c(AxisAlignedBB arg0, double arg1) {
|
public double c(AxisAlignedBB arg0, double arg1) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB shrink(double arg0) {
|
public AxisAlignedBB shrink(double arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(BlockPosition arg0) {
|
public AxisAlignedBB a(BlockPosition arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean b(Vec3D arg0) {
|
public boolean b(Vec3D arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(Vec3D arg0) {
|
public boolean c(Vec3D arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(Vec3D arg0) {
|
public boolean d(Vec3D arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB e(double arg0) {
|
public AxisAlignedBB e(double arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB g(double arg0) {
|
public AxisAlignedBB g(double arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(Vec3D arg0) {
|
public AxisAlignedBB a(Vec3D arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(AxisAlignedBB arg0) {
|
public boolean c(AxisAlignedBB arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean e(Vec3D arg0) {
|
public boolean e(Vec3D arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||||
<artifactId>holographicdisplays-nms</artifactId>
|
<artifactId>holographicdisplays-nms</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>holographicdisplays-nms-v1_13_r1</artifactId>
|
<artifactId>holographicdisplays-nms-v1_13_r1</artifactId>
|
||||||
<name>HolographicDisplays NMS v1_13_R1</name>
|
<name>HolographicDisplays NMS v1_13_R1</name>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>nms-repo</id>
|
<id>nms-repo</id>
|
||||||
<url>https://repo.codemc.io/repository/nms/</url>
|
<url>https://repo.codemc.io/repository/nms/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>holographicdisplays-utils</artifactId>
|
<artifactId>holographicdisplays-utils</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.13-R0.1-SNAPSHOT</version>
|
<version>1.13-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -29,67 +29,67 @@ import java.util.Collection;
|
||||||
|
|
||||||
public class CraftNMSArmorStand extends CraftArmorStand {
|
public class CraftNMSArmorStand extends CraftArmorStand {
|
||||||
|
|
||||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow all the bukkit methods.
|
// Disallow all the bukkit methods.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
// Cannot be removed, this is the most important to override.
|
// Cannot be removed, this is the most important to override.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from Armor stand class
|
// Methods from Armor stand class
|
||||||
|
|
||||||
@Override public void setArms(boolean arms) { }
|
@Override public void setArms(boolean arms) { }
|
||||||
@Override public void setBasePlate(boolean basePlate) { }
|
@Override public void setBasePlate(boolean basePlate) { }
|
||||||
@Override public void setBodyPose(EulerAngle pose) { }
|
@Override public void setBodyPose(EulerAngle pose) { }
|
||||||
@Override public void setBoots(ItemStack item) { }
|
@Override public void setBoots(ItemStack item) { }
|
||||||
@Override public void setChestplate(ItemStack item) { }
|
@Override public void setChestplate(ItemStack item) { }
|
||||||
@Override public void setHeadPose(EulerAngle pose) { }
|
@Override public void setHeadPose(EulerAngle pose) { }
|
||||||
@Override public void setHelmet(ItemStack item) { }
|
@Override public void setHelmet(ItemStack item) { }
|
||||||
@Override public void setItemInHand(ItemStack item) { }
|
@Override public void setItemInHand(ItemStack item) { }
|
||||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||||
@Override public void setLeggings(ItemStack item) { }
|
@Override public void setLeggings(ItemStack item) { }
|
||||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||||
@Override public void setSmall(boolean small) { }
|
@Override public void setSmall(boolean small) { }
|
||||||
@Override public void setVisible(boolean visible) { }
|
@Override public void setVisible(boolean visible) { }
|
||||||
@Override public void setMarker(boolean marker) { }
|
@Override public void setMarker(boolean marker) { }
|
||||||
|
|
||||||
// Methods from LivingEntity class
|
// Methods from LivingEntity class
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||||
@Override public void setAI(boolean ai) { }
|
@Override public void setAI(boolean ai) { }
|
||||||
@Override public void setCanPickupItems(boolean pickup) { }
|
@Override public void setCanPickupItems(boolean pickup) { }
|
||||||
@Override public void setCollidable(boolean collidable) { }
|
@Override public void setCollidable(boolean collidable) { }
|
||||||
@Override public void setGliding(boolean gliding) { }
|
@Override public void setGliding(boolean gliding) { }
|
||||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||||
@Override public void setSwimming(boolean swimming) { }
|
@Override public void setSwimming(boolean swimming) { }
|
||||||
|
|
||||||
// Methods from Entity
|
// Methods from Entity
|
||||||
@Override public void setVelocity(Vector vel) { }
|
@Override public void setVelocity(Vector vel) { }
|
||||||
@Override public boolean teleport(Location loc) { return false; }
|
@Override public boolean teleport(Location loc) { return false; }
|
||||||
@Override public boolean teleport(Entity entity) { return false; }
|
@Override public boolean teleport(Entity entity) { return false; }
|
||||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||||
@Override public void setFireTicks(int ticks) { }
|
@Override public void setFireTicks(int ticks) { }
|
||||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||||
@Override public boolean eject() { return false; }
|
@Override public boolean eject() { return false; }
|
||||||
@Override public boolean leaveVehicle() { return false; }
|
@Override public boolean leaveVehicle() { return false; }
|
||||||
@Override public void playEffect(EntityEffect effect) { }
|
@Override public void playEffect(EntityEffect effect) { }
|
||||||
@Override public void setCustomName(String name) { }
|
@Override public void setCustomName(String name) { }
|
||||||
@Override public void setCustomNameVisible(boolean flag) { }
|
@Override public void setCustomNameVisible(boolean flag) { }
|
||||||
@Override public void setGlowing(boolean flag) { }
|
@Override public void setGlowing(boolean flag) { }
|
||||||
@Override public void setGravity(boolean gravity) { }
|
@Override public void setGravity(boolean gravity) { }
|
||||||
@Override public void setInvulnerable(boolean flag) { }
|
@Override public void setInvulnerable(boolean flag) { }
|
||||||
@Override public void setMomentum(Vector value) { }
|
@Override public void setMomentum(Vector value) { }
|
||||||
@Override public void setSilent(boolean flag) { }
|
@Override public void setSilent(boolean flag) { }
|
||||||
@Override public void setTicksLived(int value) { }
|
@Override public void setTicksLived(int value) { }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,39 +25,39 @@ import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class CraftNMSItem extends CraftItem {
|
public class CraftNMSItem extends CraftItem {
|
||||||
|
|
||||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow all the bukkit methods.
|
// Disallow all the bukkit methods.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
// Cannot be removed, this is the most important to override.
|
// Cannot be removed, this is the most important to override.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from Entity
|
// Methods from Entity
|
||||||
@Override public void setVelocity(Vector vel) { }
|
@Override public void setVelocity(Vector vel) { }
|
||||||
@Override public boolean teleport(Location loc) { return false; }
|
@Override public boolean teleport(Location loc) { return false; }
|
||||||
@Override public boolean teleport(Entity entity) { return false; }
|
@Override public boolean teleport(Entity entity) { return false; }
|
||||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||||
@Override public void setFireTicks(int ticks) { }
|
@Override public void setFireTicks(int ticks) { }
|
||||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||||
@Override public boolean eject() { return false; }
|
@Override public boolean eject() { return false; }
|
||||||
@Override public boolean leaveVehicle() { return false; }
|
@Override public boolean leaveVehicle() { return false; }
|
||||||
@Override public void playEffect(EntityEffect effect) { }
|
@Override public void playEffect(EntityEffect effect) { }
|
||||||
@Override public void setCustomName(String name) { }
|
@Override public void setCustomName(String name) { }
|
||||||
@Override public void setCustomNameVisible(boolean flag) { }
|
@Override public void setCustomNameVisible(boolean flag) { }
|
||||||
@Override public void setGlowing(boolean flag) { }
|
@Override public void setGlowing(boolean flag) { }
|
||||||
@Override public void setGravity(boolean gravity) { }
|
@Override public void setGravity(boolean gravity) { }
|
||||||
@Override public void setInvulnerable(boolean flag) { }
|
@Override public void setInvulnerable(boolean flag) { }
|
||||||
@Override public void setMomentum(Vector value) { }
|
@Override public void setMomentum(Vector value) { }
|
||||||
@Override public void setSilent(boolean flag) { }
|
@Override public void setSilent(boolean flag) { }
|
||||||
@Override public void setTicksLived(int value) { }
|
@Override public void setTicksLived(int value) { }
|
||||||
|
|
||||||
// Methods from Item
|
// Methods from Item
|
||||||
@Override public void setItemStack(ItemStack stack) { }
|
@Override public void setItemStack(ItemStack stack) { }
|
||||||
@Override public void setPickupDelay(int delay) { }
|
@Override public void setPickupDelay(int delay) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,52 +28,52 @@ import java.util.Collection;
|
||||||
|
|
||||||
public class CraftNMSSlime extends CraftSlime {
|
public class CraftNMSSlime extends CraftSlime {
|
||||||
|
|
||||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow all the bukkit methods.
|
// Disallow all the bukkit methods.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
// Cannot be removed, this is the most important to override.
|
// Cannot be removed, this is the most important to override.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from LivingEntity class
|
// Methods from LivingEntity class
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||||
@Override public void setAI(boolean ai) { }
|
@Override public void setAI(boolean ai) { }
|
||||||
@Override public void setCanPickupItems(boolean pickup) { }
|
@Override public void setCanPickupItems(boolean pickup) { }
|
||||||
@Override public void setCollidable(boolean collidable) { }
|
@Override public void setCollidable(boolean collidable) { }
|
||||||
@Override public void setGliding(boolean gliding) { }
|
@Override public void setGliding(boolean gliding) { }
|
||||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||||
@Override public void setSwimming(boolean swimming) { }
|
@Override public void setSwimming(boolean swimming) { }
|
||||||
|
|
||||||
// Methods from Entity
|
// Methods from Entity
|
||||||
@Override public void setVelocity(Vector vel) { }
|
@Override public void setVelocity(Vector vel) { }
|
||||||
@Override public boolean teleport(Location loc) { return false; }
|
@Override public boolean teleport(Location loc) { return false; }
|
||||||
@Override public boolean teleport(Entity entity) { return false; }
|
@Override public boolean teleport(Entity entity) { return false; }
|
||||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||||
@Override public void setFireTicks(int ticks) { }
|
@Override public void setFireTicks(int ticks) { }
|
||||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||||
@Override public boolean eject() { return false; }
|
@Override public boolean eject() { return false; }
|
||||||
@Override public boolean leaveVehicle() { return false; }
|
@Override public boolean leaveVehicle() { return false; }
|
||||||
@Override public void playEffect(EntityEffect effect) { }
|
@Override public void playEffect(EntityEffect effect) { }
|
||||||
@Override public void setCustomName(String name) { }
|
@Override public void setCustomName(String name) { }
|
||||||
@Override public void setCustomNameVisible(boolean flag) { }
|
@Override public void setCustomNameVisible(boolean flag) { }
|
||||||
@Override public void setGlowing(boolean flag) { }
|
@Override public void setGlowing(boolean flag) { }
|
||||||
@Override public void setGravity(boolean gravity) { }
|
@Override public void setGravity(boolean gravity) { }
|
||||||
@Override public void setInvulnerable(boolean flag) { }
|
@Override public void setInvulnerable(boolean flag) { }
|
||||||
@Override public void setMomentum(Vector value) { }
|
@Override public void setMomentum(Vector value) { }
|
||||||
@Override public void setSilent(boolean flag) { }
|
@Override public void setSilent(boolean flag) { }
|
||||||
@Override public void setTicksLived(int value) { }
|
@Override public void setTicksLived(int value) { }
|
||||||
|
|
||||||
|
|
||||||
// Methods from Slime
|
// Methods from Slime
|
||||||
@Override public void setSize(int size) { }
|
@Override public void setSize(int size) { }
|
||||||
@Override public void setTarget(LivingEntity target) { }
|
@Override public void setTarget(LivingEntity target) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,208 +37,208 @@ import org.bukkit.craftbukkit.v1_13_R1.util.CraftChatMessage;
|
||||||
|
|
||||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
||||||
|
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
private String customName;
|
private String customName;
|
||||||
|
|
||||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||||
super(world);
|
super(world);
|
||||||
super.setInvisible(true);
|
super.setInvisible(true);
|
||||||
super.setSmall(true);
|
super.setSmall(true);
|
||||||
super.setArms(false);
|
super.setArms(false);
|
||||||
super.setNoGravity(true);
|
super.setNoGravity(true);
|
||||||
super.setBasePlate(true);
|
super.setBasePlate(true);
|
||||||
super.setMarker(true);
|
super.setMarker(true);
|
||||||
super.collides = false;
|
super.collides = false;
|
||||||
this.parentPiece = parentPiece;
|
this.parentPiece = parentPiece;
|
||||||
forceSetBoundingBox(new NullBoundingBox());
|
forceSetBoundingBox(new NullBoundingBox());
|
||||||
|
|
||||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||||
if (this.onGround) {
|
if (this.onGround) {
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inactiveTick() {
|
public void inactiveTick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||||
if (this.onGround) {
|
if (this.onGround) {
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(NBTTagCompound nbttagcompound) {
|
public boolean c(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(NBTTagCompound nbttagcompound) {
|
public boolean d(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void f(NBTTagCompound nbttagcompound) {
|
public void f(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvulnerable(DamageSource source) {
|
public boolean isInvulnerable(DamageSource source) {
|
||||||
/*
|
/*
|
||||||
* The field Entity.invulnerable is private.
|
* The field Entity.invulnerable is private.
|
||||||
* It's only used while saving NBTTags, but since the entity would be killed
|
* It's only used while saving NBTTags, but since the entity would be killed
|
||||||
* on chunk unload, we prefer to override isInvulnerable().
|
* on chunk unload, we prefer to override isInvulnerable().
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
|
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomNameVisible(boolean visible) {
|
public void setCustomNameVisible(boolean visible) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||||
// Prevent stand being equipped
|
// Prevent stand being equipped
|
||||||
return EnumInteractionResult.PASS;
|
return EnumInteractionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(int i, ItemStack item) {
|
public boolean c(int i, ItemStack item) {
|
||||||
// Prevent stand being equipped
|
// Prevent stand being equipped
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||||
// Prevent stand being equipped
|
// Prevent stand being equipped
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(AxisAlignedBB boundingBox) {
|
public void a(AxisAlignedBB boundingBox) {
|
||||||
// Do not change it!
|
// Do not change it!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||||
super.a(boundingBox);
|
super.a(boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||||
// Remove sounds.
|
// Remove sounds.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomNameNMS(String name) {
|
public void setCustomNameNMS(String name) {
|
||||||
this.customName = Utils.limitLength(name, 300);
|
this.customName = Utils.limitLength(name, 300);
|
||||||
super.setCustomName(CraftChatMessage.fromStringOrNull(customName));
|
super.setCustomName(CraftChatMessage.fromStringOrNull(customName));
|
||||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCustomNameStringNMS() {
|
public String getCustomNameStringNMS() {
|
||||||
return this.customName;
|
return this.customName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getCustomNameObjectNMS() {
|
public Object getCustomNameObjectNMS() {
|
||||||
return super.getCustomName();
|
return super.getCustomName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
// Prevent being killed.
|
// Prevent being killed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||||
}
|
}
|
||||||
return super.bukkitEntity;
|
return super.bukkitEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void killEntityNMS() {
|
public void killEntityNMS() {
|
||||||
super.dead = true;
|
super.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
if (broadcastLocationPacket) {
|
if (broadcastLocationPacket) {
|
||||||
broadcastLocationPacketNMS();
|
broadcastLocationPacketNMS();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object obj : super.world.players) {
|
for (Object obj : super.world.players) {
|
||||||
if (obj instanceof EntityPlayer) {
|
if (obj instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return super.dead;
|
return super.dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIdNMS() {
|
public int getIdNMS() {
|
||||||
return super.getId();
|
return super.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HologramLine getHologramLine() {
|
public HologramLine getHologramLine() {
|
||||||
return parentPiece;
|
return parentPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||||
return getBukkitEntity();
|
return getBukkitEntity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,207 +39,207 @@ import org.bukkit.entity.Player;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||||
|
|
||||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax");
|
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax");
|
||||||
|
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
private ItemPickupManager itemPickupManager;
|
private ItemPickupManager itemPickupManager;
|
||||||
|
|
||||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||||
super(world);
|
super(world);
|
||||||
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
||||||
this.parentPiece = piece;
|
this.parentPiece = piece;
|
||||||
this.itemPickupManager = itemPickupManager;
|
this.itemPickupManager = itemPickupManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inactiveTick() {
|
public void inactiveTick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method called when a player is near.
|
// Method called when a player is near.
|
||||||
@Override
|
@Override
|
||||||
public void d(EntityHuman human) {
|
public void d(EntityHuman human) {
|
||||||
|
|
||||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||||
// Too low or too high, it's a bit weird.
|
// Too low or too high, it's a bit weird.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||||
// It is never added to the inventory.
|
// It is never added to the inventory.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(NBTTagCompound nbttagcompound) {
|
public boolean c(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(NBTTagCompound nbttagcompound) {
|
public boolean d(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void f(NBTTagCompound nbttagcompound) {
|
public void f(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvulnerable(DamageSource source) {
|
public boolean isInvulnerable(DamageSource source) {
|
||||||
/*
|
/*
|
||||||
* The field Entity.invulnerable is private.
|
* The field Entity.invulnerable is private.
|
||||||
* It's only used while saving NBTTags, but since the entity would be killed
|
* It's only used while saving NBTTags, but since the entity would be killed
|
||||||
* on chunk unload, we prefer to override isInvulnerable().
|
* on chunk unload, we prefer to override isInvulnerable().
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
// Prevent being killed.
|
// Prevent being killed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAlive() {
|
public boolean isAlive() {
|
||||||
// This override prevents items from being picked up by hoppers.
|
// This override prevents items from being picked up by hoppers.
|
||||||
// Should have no side effects.
|
// Should have no side effects.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||||
}
|
}
|
||||||
return super.bukkitEntity;
|
return super.bukkitEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return super.dead;
|
return super.dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void killEntityNMS() {
|
public void killEntityNMS() {
|
||||||
super.dead = true;
|
super.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocationNMS(double x, double y, double z) {
|
public void setLocationNMS(double x, double y, double z) {
|
||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
||||||
ItemStack newItem = CraftItemStack.asNMSCopy(stack); // ItemStack.a is returned if the stack is null, invalid or the material is not an Item
|
ItemStack newItem = CraftItemStack.asNMSCopy(stack); // ItemStack.a is returned if the stack is null, invalid or the material is not an Item
|
||||||
|
|
||||||
if (newItem == null || newItem == ItemStack.a) {
|
if (newItem == null || newItem == ItemStack.a) {
|
||||||
newItem = new ItemStack(Blocks.BEDROCK);
|
newItem = new ItemStack(Blocks.BEDROCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newItem.getTag() == null) {
|
if (newItem.getTag() == null) {
|
||||||
newItem.setTag(new NBTTagCompound());
|
newItem.setTag(new NBTTagCompound());
|
||||||
}
|
}
|
||||||
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
||||||
if (!newItem.getTag().hasKey("display")) {
|
if (!newItem.getTag().hasKey("display")) {
|
||||||
newItem.getTag().set("display", display);
|
newItem.getTag().set("display", display);
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTagList tagList = new NBTTagList();
|
NBTTagList tagList = new NBTTagList();
|
||||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||||
display.set("Lore", tagList);
|
display.set("Lore", tagList);
|
||||||
|
|
||||||
setItemStack(newItem);
|
setItemStack(newItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIdNMS() {
|
public int getIdNMS() {
|
||||||
return super.getId();
|
return super.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemLine getHologramLine() {
|
public ItemLine getHologramLine() {
|
||||||
return parentPiece;
|
return parentPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void allowPickup(boolean pickup) {
|
public void allowPickup(boolean pickup) {
|
||||||
if (pickup) {
|
if (pickup) {
|
||||||
super.pickupDelay = 0;
|
super.pickupDelay = 0;
|
||||||
} else {
|
} else {
|
||||||
super.pickupDelay = 32767;
|
super.pickupDelay = 32767;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||||
return getBukkitEntity();
|
return getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||||
// It should never dismount
|
// It should never dismount
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity entity = (Entity) vehicleBase;
|
Entity entity = (Entity) vehicleBase;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (super.getVehicle() != null) {
|
if (super.getVehicle() != null) {
|
||||||
Entity oldVehicle = super.getVehicle();
|
Entity oldVehicle = super.getVehicle();
|
||||||
VEHICLE_FIELD.set(this, null);
|
VEHICLE_FIELD.set(this, null);
|
||||||
oldVehicle.passengers.remove(this);
|
oldVehicle.passengers.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
VEHICLE_FIELD.set(this, entity);
|
VEHICLE_FIELD.set(this, entity);
|
||||||
entity.passengers.clear();
|
entity.passengers.clear();
|
||||||
entity.passengers.add(this);
|
entity.passengers.add(this);
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getRawItemStack() {
|
public Object getRawItemStack() {
|
||||||
return super.getItemStack();
|
return super.getItemStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,186 +36,186 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||||
|
|
||||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax");
|
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax");
|
||||||
|
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
|
||||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||||
super(world);
|
super(world);
|
||||||
super.persistent = true;
|
super.persistent = true;
|
||||||
super.collides = false;
|
super.collides = false;
|
||||||
a(0.0F, 0.0F);
|
a(0.0F, 0.0F);
|
||||||
setSize(1, false);
|
setSize(1, false);
|
||||||
setInvisible(true);
|
setInvisible(true);
|
||||||
this.parentPiece = parentPiece;
|
this.parentPiece = parentPiece;
|
||||||
forceSetBoundingBox(new NullBoundingBox());
|
forceSetBoundingBox(new NullBoundingBox());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inactiveTick() {
|
public void inactiveTick() {
|
||||||
// Disable normal ticking for this entity.
|
// Disable normal ticking for this entity.
|
||||||
|
|
||||||
// So it won't get removed.
|
// So it won't get removed.
|
||||||
ticksLived = 0;
|
ticksLived = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(AxisAlignedBB boundingBox) {
|
public void a(AxisAlignedBB boundingBox) {
|
||||||
// Do not change it!
|
// Do not change it!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||||
super.a(boundingBox);
|
super.a(boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(NBTTagCompound nbttagcompound) {
|
public boolean c(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean d(NBTTagCompound nbttagcompound) {
|
public boolean d(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void f(NBTTagCompound nbttagcompound) {
|
public void f(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
// Do not load NBT.
|
// Do not load NBT.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||||
if (damageSource instanceof EntityDamageSource) {
|
if (damageSource instanceof EntityDamageSource) {
|
||||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvulnerable(DamageSource source) {
|
public boolean isInvulnerable(DamageSource source) {
|
||||||
/*
|
/*
|
||||||
* The field Entity.invulnerable is private.
|
* The field Entity.invulnerable is private.
|
||||||
* It's only used while saving NBTTags, but since the entity would be killed
|
* It's only used while saving NBTTags, but since the entity would be killed
|
||||||
* on chunk unload, we prefer to override isInvulnerable().
|
* on chunk unload, we prefer to override isInvulnerable().
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
|
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomNameVisible(boolean visible) {
|
public void setCustomNameVisible(boolean visible) {
|
||||||
// Locks the custom name.
|
// Locks the custom name.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||||
// Remove sounds.
|
// Remove sounds.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
// Prevent being killed.
|
// Prevent being killed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||||
}
|
}
|
||||||
return super.bukkitEntity;
|
return super.bukkitEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return super.dead;
|
return super.dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void killEntityNMS() {
|
public void killEntityNMS() {
|
||||||
super.dead = true;
|
super.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocationNMS(double x, double y, double z) {
|
public void setLocationNMS(double x, double y, double z) {
|
||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIdNMS() {
|
public int getIdNMS() {
|
||||||
return super.getId();
|
return super.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HologramLine getHologramLine() {
|
public HologramLine getHologramLine() {
|
||||||
return parentPiece;
|
return parentPiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||||
return getBukkitEntity();
|
return getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||||
// It should never dismount
|
// It should never dismount
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity entity = (Entity) vehicleBase;
|
Entity entity = (Entity) vehicleBase;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (super.getVehicle() != null) {
|
if (super.getVehicle() != null) {
|
||||||
Entity oldVehicle = super.getVehicle();
|
Entity oldVehicle = super.getVehicle();
|
||||||
VEHICLE_FIELD.set(this, null);
|
VEHICLE_FIELD.set(this, null);
|
||||||
oldVehicle.passengers.remove(this);
|
oldVehicle.passengers.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
VEHICLE_FIELD.set(this, entity);
|
VEHICLE_FIELD.set(this, entity);
|
||||||
entity.passengers.clear();
|
entity.passengers.clear();
|
||||||
entity.passengers.add(this);
|
entity.passengers.add(this);
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,169 +45,169 @@ import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class NmsManagerImpl implements NMSManager {
|
public class NmsManagerImpl implements NMSManager {
|
||||||
|
|
||||||
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
|
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
|
||||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
|
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
|
||||||
private static final ReflectField<List<Entity>> ENTITY_LIST_FIELD = new ReflectField<>(World.class, "entityList");
|
private static final ReflectField<List<Entity>> ENTITY_LIST_FIELD = new ReflectField<>(World.class, "entityList");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||||
validateEntityMethod.setAccessible(true);
|
validateEntityMethod.setAccessible(true);
|
||||||
|
|
||||||
registerCustomEntity(EntityNMSSlime.class, 55);
|
registerCustomEntity(EntityNMSSlime.class, 55);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||||
// Use reflection to get the RegistryID of entities.
|
// Use reflection to get the RegistryID of entities.
|
||||||
RegistryID<EntityTypes<?>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.REGISTRY);
|
RegistryID<EntityTypes<?>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.REGISTRY);
|
||||||
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
||||||
|
|
||||||
// Save the the ID -> EntityTypes mapping before the registration.
|
// Save the the ID -> EntityTypes mapping before the registration.
|
||||||
Object oldValue = idToClassMap[id];
|
Object oldValue = idToClassMap[id];
|
||||||
|
|
||||||
// Register the EntityTypes object.
|
// Register the EntityTypes object.
|
||||||
registryID.a(new EntityTypes<>(entityClass, world -> null, true, true, null), id);
|
registryID.a(new EntityTypes<>(entityClass, world -> null, true, true, null), id);
|
||||||
|
|
||||||
// Restore the ID -> EntityTypes mapping.
|
// Restore the ID -> EntityTypes mapping.
|
||||||
idToClassMap[id] = oldValue;
|
idToClassMap[id] = oldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||||
customItem.setLocationNMS(x, y, z);
|
customItem.setLocationNMS(x, y, z);
|
||||||
customItem.setItemStackNMS(stack);
|
customItem.setItemStackNMS(stack);
|
||||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||||
}
|
}
|
||||||
return customItem;
|
return customItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||||
touchSlime.setLocationNMS(x, y, z);
|
touchSlime.setLocationNMS(x, y, z);
|
||||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||||
}
|
}
|
||||||
return touchSlime;
|
return touchSlime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||||
}
|
}
|
||||||
return invisibleArmorStand;
|
return invisibleArmorStand;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||||
|
|
||||||
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
||||||
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
||||||
|
|
||||||
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
||||||
// This should never happen
|
// This should never happen
|
||||||
nmsEntity.dead = true;
|
nmsEntity.dead = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
|
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
|
||||||
if (VersionUtils.isPaperServer()) {
|
if (VersionUtils.isPaperServer()) {
|
||||||
try {
|
try {
|
||||||
// Workaround because nmsWorld.entityList is a different class in Paper, if used without reflection it throws NoSuchFieldError.
|
// Workaround because nmsWorld.entityList is a different class in Paper, if used without reflection it throws NoSuchFieldError.
|
||||||
ENTITY_LIST_FIELD.get(nmsWorld).add(nmsEntity);
|
ENTITY_LIST_FIELD.get(nmsWorld).add(nmsEntity);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nmsWorld.entityList.add(nmsEntity);
|
nmsWorld.entityList.add(nmsEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||||
|
|
||||||
if (nmsEntity instanceof NMSEntityBase) {
|
if (nmsEntity instanceof NMSEntityBase) {
|
||||||
return ((NMSEntityBase) nmsEntity);
|
return ((NMSEntityBase) nmsEntity);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||||
|
|
||||||
if (nmsEntity instanceof NMSEntityBase) {
|
if (nmsEntity instanceof NMSEntityBase) {
|
||||||
return ((NMSEntityBase) nmsEntity);
|
return ((NMSEntityBase) nmsEntity);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
||||||
return CustomNameHelper.replaceCustomNameChatComponent(NMSChatComponentAdapter.INSTANCE, customNameObject, target, replacement);
|
return CustomNameHelper.replaceCustomNameChatComponent(NMSChatComponentAdapter.INSTANCE, customNameObject, target, replacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static enum NMSChatComponentAdapter implements ChatComponentAdapter<IChatBaseComponent> {
|
private static enum NMSChatComponentAdapter implements ChatComponentAdapter<IChatBaseComponent> {
|
||||||
|
|
||||||
INSTANCE {
|
INSTANCE {
|
||||||
|
|
||||||
public ChatComponentText cast(Object chatComponentObject) {
|
public ChatComponentText cast(Object chatComponentObject) {
|
||||||
return (ChatComponentText) chatComponentObject;
|
return (ChatComponentText) chatComponentObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText(IChatBaseComponent chatComponent) {
|
public String getText(IChatBaseComponent chatComponent) {
|
||||||
return chatComponent.getText();
|
return chatComponent.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IChatBaseComponent> getSiblings(IChatBaseComponent chatComponent) {
|
public List<IChatBaseComponent> getSiblings(IChatBaseComponent chatComponent) {
|
||||||
return chatComponent.a();
|
return chatComponent.a();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSibling(IChatBaseComponent chatComponent, IChatBaseComponent newSibling) {
|
public void addSibling(IChatBaseComponent chatComponent, IChatBaseComponent newSibling) {
|
||||||
chatComponent.addSibling(newSibling);
|
chatComponent.addSibling(newSibling);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChatComponentText cloneComponent(IChatBaseComponent chatComponent, String newText) {
|
public ChatComponentText cloneComponent(IChatBaseComponent chatComponent, String newText) {
|
||||||
ChatComponentText clonedChatComponent = new ChatComponentText(newText);
|
ChatComponentText clonedChatComponent = new ChatComponentText(newText);
|
||||||
clonedChatComponent.setChatModifier(chatComponent.getChatModifier().clone());
|
clonedChatComponent.setChatModifier(chatComponent.getChatModifier().clone());
|
||||||
return clonedChatComponent;
|
return clonedChatComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,111 +22,111 @@ import net.minecraft.server.v1_13_R1.Vec3D;
|
||||||
|
|
||||||
public class NullBoundingBox extends AxisAlignedBB {
|
public class NullBoundingBox extends AxisAlignedBB {
|
||||||
|
|
||||||
public NullBoundingBox() {
|
public NullBoundingBox() {
|
||||||
super(0, 0, 0, 0, 0, 0);
|
super(0, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double a() {
|
public double a() {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB shrink(double arg0) {
|
public AxisAlignedBB shrink(double arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(BlockPosition arg0) {
|
public AxisAlignedBB a(BlockPosition arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean b(Vec3D arg0) {
|
public boolean b(Vec3D arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB g(double arg0) {
|
public AxisAlignedBB g(double arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB a(Vec3D arg0) {
|
public AxisAlignedBB a(Vec3D arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean c(AxisAlignedBB arg0) {
|
public boolean c(AxisAlignedBB arg0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double a(EnumAxis arg0) {
|
public double a(EnumAxis arg0) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MovingObjectPosition a(Vec3D arg0, Vec3D arg1, BlockPosition arg2) {
|
public MovingObjectPosition a(Vec3D arg0, Vec3D arg1, BlockPosition arg2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double b(EnumAxis arg0) {
|
public double b(EnumAxis arg0) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean e(double arg0, double arg1, double arg2) {
|
public boolean e(double arg0, double arg1, double arg2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB f(double arg0, double arg1, double arg2) {
|
public AxisAlignedBB f(double arg0, double arg1, double arg2) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue