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"?>
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
<name>HolographicDisplays API</name>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
<name>HolographicDisplays API</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -27,193 +27,193 @@ import org.bukkit.inventory.ItemStack;
|
|||
* To create one, please see {@link HologramsAPI#createHologram(org.bukkit.plugin.Plugin, Location)}.
|
||||
*/
|
||||
public interface Hologram {
|
||||
|
||||
/**
|
||||
* Appends a text line to end of this hologram.
|
||||
*
|
||||
* @param text the content of the line, can be null for an empty line
|
||||
* @return the new TextLine appended
|
||||
*/
|
||||
public TextLine appendTextLine(String text);
|
||||
|
||||
|
||||
/**
|
||||
* Appends an item line to end of this hologram.
|
||||
*
|
||||
* @param itemStack the content of the line
|
||||
* @return the new ItemLine appended
|
||||
*/
|
||||
public ItemLine appendItemLine(ItemStack itemStack);
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a text line in this hologram.
|
||||
*
|
||||
* @param index the line is inserted before this index. If 0, the new line will
|
||||
* be inserted before the first line.
|
||||
* @param text the content of the line, can be null for an empty line
|
||||
* @return the new TextLine inserted
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||
*/
|
||||
public TextLine insertTextLine(int index, String text);
|
||||
|
||||
|
||||
/**
|
||||
* Inserts an item line in this hologram.
|
||||
*
|
||||
* @param index the line is inserted before this index. If 0, the new line will
|
||||
* be inserted before the first line.
|
||||
* @param itemStack the content of the line
|
||||
* @return the new ItemLine inserted
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||
*/
|
||||
public ItemLine insertItemLine(int index, ItemStack itemStack);
|
||||
|
||||
|
||||
/**
|
||||
* Finds the element at a given index in the lines.
|
||||
*
|
||||
* @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}.
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||
*/
|
||||
public HologramLine getLine(int index);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||
*/
|
||||
public void removeLine(int index);
|
||||
|
||||
|
||||
/**
|
||||
* Removes all the lines from this hologram.
|
||||
*/
|
||||
public void clearLines();
|
||||
|
||||
/**
|
||||
* Appends a text line to end of this hologram.
|
||||
*
|
||||
* @param text the content of the line, can be null for an empty line
|
||||
* @return the new TextLine appended
|
||||
*/
|
||||
public TextLine appendTextLine(String text);
|
||||
|
||||
|
||||
/**
|
||||
* Appends an item line to end of this hologram.
|
||||
*
|
||||
* @param itemStack the content of the line
|
||||
* @return the new ItemLine appended
|
||||
*/
|
||||
public ItemLine appendItemLine(ItemStack itemStack);
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a text line in this hologram.
|
||||
*
|
||||
* @param index the line is inserted before this index. If 0, the new line will
|
||||
* be inserted before the first line.
|
||||
* @param text the content of the line, can be null for an empty line
|
||||
* @return the new TextLine inserted
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||
*/
|
||||
public TextLine insertTextLine(int index, String text);
|
||||
|
||||
|
||||
/**
|
||||
* Inserts an item line in this hologram.
|
||||
*
|
||||
* @param index the line is inserted before this index. If 0, the new line will
|
||||
* be inserted before the first line.
|
||||
* @param itemStack the content of the line
|
||||
* @return the new ItemLine inserted
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||
*/
|
||||
public ItemLine insertItemLine(int index, ItemStack itemStack);
|
||||
|
||||
|
||||
/**
|
||||
* Finds the element at a given index in the lines.
|
||||
*
|
||||
* @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}.
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||
*/
|
||||
public HologramLine getLine(int index);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
|
||||
*/
|
||||
public void removeLine(int index);
|
||||
|
||||
|
||||
/**
|
||||
* Removes all the lines from this hologram.
|
||||
*/
|
||||
public void clearLines();
|
||||
|
||||
|
||||
/**
|
||||
* Checks the amount of lines of the hologram.
|
||||
*
|
||||
* @return the amount of lines
|
||||
*/
|
||||
public int size();
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public double getHeight();
|
||||
|
||||
|
||||
/**
|
||||
* Teleports a hologram to the given location.
|
||||
*
|
||||
* @param location the new location
|
||||
*/
|
||||
public void teleport(Location location);
|
||||
|
||||
|
||||
/**
|
||||
* Teleports a hologram to the given location.
|
||||
*
|
||||
* @param world the world where the hologram should be teleported,
|
||||
* use {@link #getWorld()} to teleport it in the same world.
|
||||
* @param x the X coordinate
|
||||
* @param y the Y coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public void teleport(World world, double x, double y, double z);
|
||||
|
||||
/**
|
||||
* Returns the position of the hologram.
|
||||
*
|
||||
* @return the Location of the hologram
|
||||
*/
|
||||
public Location getLocation();
|
||||
|
||||
/**
|
||||
* Returns the X coordinate.
|
||||
*
|
||||
* @return the X coordinate of the hologram
|
||||
*/
|
||||
public double getX();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Y coordinate.
|
||||
*
|
||||
* @return the Y coordinate of the hologram
|
||||
*/
|
||||
public double getY();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Z coordinate.
|
||||
*
|
||||
* @return the Z coordinate of the hologram
|
||||
*/
|
||||
public double getZ();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the world.
|
||||
*
|
||||
* @return the world of the hologram
|
||||
*/
|
||||
public World getWorld();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the {@link VisibilityManager} of this hologram.
|
||||
* <br><b style = "color: red">Note</b>: the usage of the VisibilityManager requires ProtocolLib.
|
||||
* Without the plugin, holograms will be always visible.
|
||||
*
|
||||
* @return the VisibilityManager of this hologram
|
||||
*/
|
||||
public VisibilityManager getVisibilityManager();
|
||||
|
||||
|
||||
/**
|
||||
* Returns when the hologram was created. Useful for removing old holograms.
|
||||
*
|
||||
* @return the timestamp of when the hologram was created, in milliseconds
|
||||
*/
|
||||
public long getCreationTimestamp();
|
||||
|
||||
/**
|
||||
* Checks the amount of lines of the hologram.
|
||||
*
|
||||
* @return the amount of lines
|
||||
*/
|
||||
public int size();
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public double getHeight();
|
||||
|
||||
|
||||
/**
|
||||
* Teleports a hologram to the given location.
|
||||
*
|
||||
* @param location the new location
|
||||
*/
|
||||
public void teleport(Location location);
|
||||
|
||||
|
||||
/**
|
||||
* Teleports a hologram to the given location.
|
||||
*
|
||||
* @param world the world where the hologram should be teleported,
|
||||
* use {@link #getWorld()} to teleport it in the same world.
|
||||
* @param x the X coordinate
|
||||
* @param y the Y coordinate
|
||||
* @param z the Z coordinate
|
||||
*/
|
||||
public void teleport(World world, double x, double y, double z);
|
||||
|
||||
/**
|
||||
* Returns the position of the hologram.
|
||||
*
|
||||
* @return the Location of the hologram
|
||||
*/
|
||||
public Location getLocation();
|
||||
|
||||
/**
|
||||
* Returns the X coordinate.
|
||||
*
|
||||
* @return the X coordinate of the hologram
|
||||
*/
|
||||
public double getX();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Y coordinate.
|
||||
*
|
||||
* @return the Y coordinate of the hologram
|
||||
*/
|
||||
public double getY();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Z coordinate.
|
||||
*
|
||||
* @return the Z coordinate of the hologram
|
||||
*/
|
||||
public double getZ();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the world.
|
||||
*
|
||||
* @return the world of the hologram
|
||||
*/
|
||||
public World getWorld();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the {@link VisibilityManager} of this hologram.
|
||||
* <br><b style = "color: red">Note</b>: the usage of the VisibilityManager requires ProtocolLib.
|
||||
* Without the plugin, holograms will be always visible.
|
||||
*
|
||||
* @return the VisibilityManager of this hologram
|
||||
*/
|
||||
public VisibilityManager getVisibilityManager();
|
||||
|
||||
|
||||
/**
|
||||
* Returns when the hologram was created. Useful for removing old holograms.
|
||||
*
|
||||
* @return the timestamp of when the hologram was created, in milliseconds
|
||||
*/
|
||||
public long getCreationTimestamp();
|
||||
|
||||
/**
|
||||
* Checks if the hologram will track and replace placeholders.
|
||||
* This is false by default.
|
||||
*
|
||||
* @return if the hologram allows placeholders
|
||||
*/
|
||||
public boolean isAllowPlaceholders();
|
||||
/**
|
||||
* Checks if the hologram will track and replace placeholders.
|
||||
* This is false by default.
|
||||
*
|
||||
* @return if the hologram allows placeholders
|
||||
*/
|
||||
public boolean isAllowPlaceholders();
|
||||
|
||||
/**
|
||||
* Sets if the hologram should track and replace placeholders.
|
||||
* By default if will not track them.
|
||||
*
|
||||
* @param allowPlaceholders if the hologram should track placeholders
|
||||
*/
|
||||
public void setAllowPlaceholders(boolean allowPlaceholders);
|
||||
|
||||
/**
|
||||
* Deletes this hologram. Editing or teleporting the hologram when deleted
|
||||
* will throw an exception. Lines will be automatically cleared.
|
||||
* You should remove all the references of the hologram after deletion.
|
||||
*/
|
||||
public void delete();
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a hologram was deleted.
|
||||
*
|
||||
* @return true if this hologram was deleted
|
||||
*/
|
||||
public boolean isDeleted();
|
||||
|
||||
/**
|
||||
* Sets if the hologram should track and replace placeholders.
|
||||
* By default if will not track them.
|
||||
*
|
||||
* @param allowPlaceholders if the hologram should track placeholders
|
||||
*/
|
||||
public void setAllowPlaceholders(boolean allowPlaceholders);
|
||||
|
||||
/**
|
||||
* Deletes this hologram. Editing or teleporting the hologram when deleted
|
||||
* will throw an exception. Lines will be automatically cleared.
|
||||
* You should remove all the references of the hologram after deletion.
|
||||
*/
|
||||
public void delete();
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a hologram was deleted.
|
||||
*
|
||||
* @return true if this hologram was deleted
|
||||
*/
|
||||
public boolean isDeleted();
|
||||
|
||||
}
|
||||
|
|
|
@ -27,94 +27,94 @@ import java.util.Collection;
|
|||
* It provides methods to create holograms and to register custom placeholders.
|
||||
*/
|
||||
public class HologramsAPI {
|
||||
|
||||
|
||||
private HologramsAPI() {
|
||||
// No constructor needed.
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a hologram at given location.
|
||||
*
|
||||
* @param plugin the plugin that creates it
|
||||
* @param source the location where it will appear
|
||||
* @return the new hologram created
|
||||
*/
|
||||
public static Hologram createHologram(Plugin plugin, Location source) {
|
||||
return BackendAPI.getImplementation().createHologram(plugin, source);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds all the holograms created by a given plugin.
|
||||
*
|
||||
* @param plugin the plugin to search for in holograms
|
||||
* @return the holograms created by a plugin. the Collection is a copy
|
||||
* and modifying it has no effect on the holograms.
|
||||
*/
|
||||
public static Collection<Hologram> getHolograms(Plugin plugin) {
|
||||
return BackendAPI.getImplementation().getHolograms(plugin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers a new placeholder that can be used in holograms created with commands.
|
||||
* With this method, you can basically expand the core of HolographicDisplays.
|
||||
*
|
||||
* @param plugin the owner plugin of the placeholder
|
||||
* @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 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
|
||||
*/
|
||||
public static boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer) {
|
||||
return BackendAPI.getImplementation().registerPlaceholder(plugin, textPlaceholder, refreshRate, replacer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds all the placeholders registered by a given plugin.
|
||||
*
|
||||
* @param plugin the plugin to search for
|
||||
* @return a collection of placeholders registered by the plugin
|
||||
*/
|
||||
public static Collection<String> getRegisteredPlaceholders(Plugin plugin) {
|
||||
return BackendAPI.getImplementation().getRegisteredPlaceholders(plugin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a placeholder created by a plugin.
|
||||
*
|
||||
* @param plugin the plugin that owns the placeholder
|
||||
* @param textPlaceholder the placeholder to remove
|
||||
* @return true if found and removed, false otherwise
|
||||
*/
|
||||
public static boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder) {
|
||||
return BackendAPI.getImplementation().unregisterPlaceholder(plugin, textPlaceholder);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param plugin the plugin that owns the placeholders
|
||||
*/
|
||||
public static void unregisterPlaceholders(Plugin plugin) {
|
||||
BackendAPI.getImplementation().unregisterPlaceholders(plugin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if an entity is part of a hologram.
|
||||
*
|
||||
* @param bukkitEntity the entity to check
|
||||
* @return true if the entity is a part of a hologram
|
||||
*/
|
||||
public static boolean isHologramEntity(Entity bukkitEntity) {
|
||||
return BackendAPI.getImplementation().isHologramEntity(bukkitEntity);
|
||||
}
|
||||
|
||||
|
||||
private HologramsAPI() {
|
||||
// No constructor needed.
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a hologram at given location.
|
||||
*
|
||||
* @param plugin the plugin that creates it
|
||||
* @param source the location where it will appear
|
||||
* @return the new hologram created
|
||||
*/
|
||||
public static Hologram createHologram(Plugin plugin, Location source) {
|
||||
return BackendAPI.getImplementation().createHologram(plugin, source);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds all the holograms created by a given plugin.
|
||||
*
|
||||
* @param plugin the plugin to search for in holograms
|
||||
* @return the holograms created by a plugin. the Collection is a copy
|
||||
* and modifying it has no effect on the holograms.
|
||||
*/
|
||||
public static Collection<Hologram> getHolograms(Plugin plugin) {
|
||||
return BackendAPI.getImplementation().getHolograms(plugin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers a new placeholder that can be used in holograms created with commands.
|
||||
* With this method, you can basically expand the core of HolographicDisplays.
|
||||
*
|
||||
* @param plugin the owner plugin of the placeholder
|
||||
* @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 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
|
||||
*/
|
||||
public static boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer) {
|
||||
return BackendAPI.getImplementation().registerPlaceholder(plugin, textPlaceholder, refreshRate, replacer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds all the placeholders registered by a given plugin.
|
||||
*
|
||||
* @param plugin the plugin to search for
|
||||
* @return a collection of placeholders registered by the plugin
|
||||
*/
|
||||
public static Collection<String> getRegisteredPlaceholders(Plugin plugin) {
|
||||
return BackendAPI.getImplementation().getRegisteredPlaceholders(plugin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a placeholder created by a plugin.
|
||||
*
|
||||
* @param plugin the plugin that owns the placeholder
|
||||
* @param textPlaceholder the placeholder to remove
|
||||
* @return true if found and removed, false otherwise
|
||||
*/
|
||||
public static boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder) {
|
||||
return BackendAPI.getImplementation().unregisterPlaceholder(plugin, textPlaceholder);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param plugin the plugin that owns the placeholders
|
||||
*/
|
||||
public static void unregisterPlaceholders(Plugin plugin) {
|
||||
BackendAPI.getImplementation().unregisterPlaceholders(plugin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if an entity is part of a hologram.
|
||||
*
|
||||
* @param bukkitEntity the entity to check
|
||||
* @return true if the entity is a part of a hologram
|
||||
*/
|
||||
public static boolean isHologramEntity(Entity 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.
|
||||
*/
|
||||
public interface VisibilityManager {
|
||||
|
||||
/**
|
||||
* Returns if the hologram is visible by default. If not changed, this value
|
||||
* is true by default so the hologram is visible to everyone.
|
||||
*
|
||||
* @return if the hologram hologram is visible by default
|
||||
*/
|
||||
public boolean isVisibleByDefault();
|
||||
|
||||
/**
|
||||
* Sets if the hologram is visible by default. If not changed, this value
|
||||
* is true by default so the hologram is visible to everyone.
|
||||
*
|
||||
* @param visibleByDefault the new behaviour
|
||||
*/
|
||||
public void setVisibleByDefault(boolean visibleByDefault);
|
||||
|
||||
/**
|
||||
* Shows the hologram to a player, overriding the value of {@link #isVisibleByDefault()}.
|
||||
* This is persistent if the players goes offline.
|
||||
*
|
||||
* @param player the involved player
|
||||
*/
|
||||
public void showTo(Player player);
|
||||
|
||||
/**
|
||||
* Hides the hologram to a player, overriding the value of {@link #isVisibleByDefault()}.
|
||||
* This is persistent if the players goes offline.
|
||||
*
|
||||
* @param player the involved player
|
||||
*/
|
||||
public void hideTo(Player player);
|
||||
|
||||
/**
|
||||
* Checks if a hologram is visible to a player.
|
||||
*
|
||||
* @param player the involved player
|
||||
* @return if the player can see the hologram
|
||||
*/
|
||||
public boolean isVisibleTo(Player 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
|
||||
* to reflect the value of {@link #isVisibleByDefault()}.
|
||||
*
|
||||
* @param player the involved player
|
||||
*/
|
||||
public void resetVisibility(Player player);
|
||||
|
||||
/**
|
||||
* Resets the visibility for all the players. See {@link #resetVisibility(Player)} for more details.
|
||||
*/
|
||||
public void resetVisibilityAll();
|
||||
|
||||
|
||||
/**
|
||||
* Returns if the hologram is visible by default. If not changed, this value
|
||||
* is true by default so the hologram is visible to everyone.
|
||||
*
|
||||
* @return if the hologram hologram is visible by default
|
||||
*/
|
||||
public boolean isVisibleByDefault();
|
||||
|
||||
/**
|
||||
* Sets if the hologram is visible by default. If not changed, this value
|
||||
* is true by default so the hologram is visible to everyone.
|
||||
*
|
||||
* @param visibleByDefault the new behaviour
|
||||
*/
|
||||
public void setVisibleByDefault(boolean visibleByDefault);
|
||||
|
||||
/**
|
||||
* Shows the hologram to a player, overriding the value of {@link #isVisibleByDefault()}.
|
||||
* This is persistent if the players goes offline.
|
||||
*
|
||||
* @param player the involved player
|
||||
*/
|
||||
public void showTo(Player player);
|
||||
|
||||
/**
|
||||
* Hides the hologram to a player, overriding the value of {@link #isVisibleByDefault()}.
|
||||
* This is persistent if the players goes offline.
|
||||
*
|
||||
* @param player the involved player
|
||||
*/
|
||||
public void hideTo(Player player);
|
||||
|
||||
/**
|
||||
* Checks if a hologram is visible to a player.
|
||||
*
|
||||
* @param player the involved player
|
||||
* @return if the player can see the hologram
|
||||
*/
|
||||
public boolean isVisibleTo(Player 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
|
||||
* to reflect the value of {@link #isVisibleByDefault()}.
|
||||
*
|
||||
* @param player the involved player
|
||||
*/
|
||||
public void resetVisibility(Player player);
|
||||
|
||||
/**
|
||||
* Resets the visibility for all the players. See {@link #resetVisibility(Player)} for more details.
|
||||
*/
|
||||
public void resetVisibilityAll();
|
||||
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ import org.bukkit.entity.Player;
|
|||
*/
|
||||
public interface PickupHandler {
|
||||
|
||||
/**
|
||||
* Called when a player picks up the item.
|
||||
* @param player the player who picked up the item
|
||||
*/
|
||||
public void onPickup(Player player);
|
||||
|
||||
/**
|
||||
* Called when a player picks up the item.
|
||||
* @param player the player who picked up the item
|
||||
*/
|
||||
public void onPickup(Player player);
|
||||
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ import org.bukkit.entity.Player;
|
|||
*/
|
||||
public interface TouchHandler {
|
||||
|
||||
/**
|
||||
* Called when a player interacts with the hologram (right click).
|
||||
* @param player the player who interacts
|
||||
*/
|
||||
public void onTouch(Player player);
|
||||
|
||||
/**
|
||||
* Called when a player interacts with the hologram (right click).
|
||||
* @param player the player who interacts
|
||||
*/
|
||||
public void onTouch(Player player);
|
||||
|
||||
}
|
||||
|
|
|
@ -23,34 +23,34 @@ import org.bukkit.plugin.Plugin;
|
|||
import java.util.Collection;
|
||||
|
||||
public abstract class BackendAPI {
|
||||
|
||||
private static BackendAPI implementation;
|
||||
|
||||
public static void setImplementation(BackendAPI implementation) {
|
||||
BackendAPI.implementation = implementation;
|
||||
}
|
||||
|
||||
public static BackendAPI getImplementation() {
|
||||
if (implementation == null) {
|
||||
throw new IllegalStateException("No API implementation set. Is Holographic Displays enabled?");
|
||||
}
|
||||
|
||||
return implementation;
|
||||
}
|
||||
|
||||
private static BackendAPI implementation;
|
||||
|
||||
public static void setImplementation(BackendAPI implementation) {
|
||||
BackendAPI.implementation = implementation;
|
||||
}
|
||||
|
||||
public static BackendAPI getImplementation() {
|
||||
if (implementation == null) {
|
||||
throw new IllegalStateException("No API implementation set. Is Holographic Displays enabled?");
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
public interface CollectableLine extends HologramLine {
|
||||
|
||||
/**
|
||||
* Sets the PickupHandler for this line.
|
||||
*
|
||||
* @param pickupHandler the new PickupHandler, can be null.
|
||||
*/
|
||||
public void setPickupHandler(PickupHandler pickupHandler);
|
||||
|
||||
/**
|
||||
* Returns the current PickupHandler of this line.
|
||||
*
|
||||
* @return the current PickupHandler, can be null.
|
||||
*/
|
||||
public PickupHandler getPickupHandler();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the PickupHandler for this line.
|
||||
*
|
||||
* @param pickupHandler the new PickupHandler, can be null.
|
||||
*/
|
||||
public void setPickupHandler(PickupHandler pickupHandler);
|
||||
|
||||
/**
|
||||
* Returns the current PickupHandler of this line.
|
||||
*
|
||||
* @return the current PickupHandler, can be null.
|
||||
*/
|
||||
public PickupHandler getPickupHandler();
|
||||
|
||||
}
|
||||
|
|
|
@ -20,18 +20,18 @@ import me.filoghost.holographicdisplays.api.Hologram;
|
|||
* Interface to represent a line in a Hologram.
|
||||
*/
|
||||
public interface HologramLine {
|
||||
|
||||
/**
|
||||
* Returns the parent Hologram of this line.
|
||||
*
|
||||
* @return the parent Hologram.
|
||||
*/
|
||||
public Hologram getParent();
|
||||
|
||||
/**
|
||||
* Removes this line from the parent Hologram. Since: v2.0.1
|
||||
* Do not call if the Hologram has been deleted, an exception will be thrown.
|
||||
*/
|
||||
public void removeLine();
|
||||
|
||||
/**
|
||||
* Returns the parent Hologram of this line.
|
||||
*
|
||||
* @return the parent Hologram.
|
||||
*/
|
||||
public Hologram getParent();
|
||||
|
||||
/**
|
||||
* Removes this line from the parent Hologram. Since: v2.0.1
|
||||
* Do not call if the Hologram has been deleted, an exception will be thrown.
|
||||
*/
|
||||
public void removeLine();
|
||||
|
||||
}
|
||||
|
|
|
@ -18,18 +18,18 @@ import org.bukkit.inventory.ItemStack;
|
|||
|
||||
public interface ItemLine extends CollectableLine, TouchableLine {
|
||||
|
||||
/**
|
||||
* Returns the ItemStack of this ItemLine.
|
||||
*
|
||||
* @return the ItemStack if this ItemLine.
|
||||
*/
|
||||
public ItemStack getItemStack();
|
||||
/**
|
||||
* Returns the ItemStack of this ItemLine.
|
||||
*
|
||||
* @return the ItemStack if this ItemLine.
|
||||
*/
|
||||
public ItemStack getItemStack();
|
||||
|
||||
/**
|
||||
* Sets the ItemStack for this ItemLine.
|
||||
*
|
||||
* @param itemStack the new item, should not be null.
|
||||
*/
|
||||
public void setItemStack(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Sets the ItemStack for this ItemLine.
|
||||
*
|
||||
* @param itemStack the new item, should not be null.
|
||||
*/
|
||||
public void setItemStack(ItemStack itemStack);
|
||||
|
||||
}
|
||||
|
|
|
@ -16,18 +16,18 @@ package me.filoghost.holographicdisplays.api.line;
|
|||
|
||||
public interface TextLine extends TouchableLine {
|
||||
|
||||
/**
|
||||
* Returns the current text of this TextLine.
|
||||
*
|
||||
* @return the current text of this line.
|
||||
*/
|
||||
public String getText();
|
||||
|
||||
/**
|
||||
* Sets the text of this TextLine.
|
||||
*
|
||||
* @param text the new text of this line.
|
||||
*/
|
||||
public void setText(String text);
|
||||
|
||||
/**
|
||||
* Returns the current text of this TextLine.
|
||||
*
|
||||
* @return the current text of this line.
|
||||
*/
|
||||
public String getText();
|
||||
|
||||
/**
|
||||
* Sets the text of this TextLine.
|
||||
*
|
||||
* @param text the new text of this line.
|
||||
*/
|
||||
public void setText(String text);
|
||||
|
||||
}
|
||||
|
|
|
@ -21,18 +21,18 @@ import me.filoghost.holographicdisplays.api.handler.TouchHandler;
|
|||
*/
|
||||
public interface TouchableLine extends HologramLine {
|
||||
|
||||
/**
|
||||
* Sets the TouchHandler for this line.
|
||||
*
|
||||
* @param touchHandler the new TouchHandler, can be null.
|
||||
*/
|
||||
public void setTouchHandler(TouchHandler touchHandler);
|
||||
|
||||
/**
|
||||
* Returns the current TouchHandler of this line.
|
||||
*
|
||||
* @return the current TouchHandler, can be null.
|
||||
*/
|
||||
public TouchHandler getTouchHandler();
|
||||
|
||||
/**
|
||||
* Sets the TouchHandler for this line.
|
||||
*
|
||||
* @param touchHandler the new TouchHandler, can be null.
|
||||
*/
|
||||
public void setTouchHandler(TouchHandler touchHandler);
|
||||
|
||||
/**
|
||||
* Returns the current TouchHandler of this line.
|
||||
*
|
||||
* @return the current TouchHandler, can be null.
|
||||
*/
|
||||
public TouchHandler getTouchHandler();
|
||||
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ package me.filoghost.holographicdisplays.api.placeholder;
|
|||
|
||||
public interface PlaceholderReplacer {
|
||||
|
||||
/**
|
||||
* Called to update a placeholder's replacement.
|
||||
* @return the replacement
|
||||
*/
|
||||
public String update();
|
||||
|
||||
/**
|
||||
* Called to update a placeholder's replacement.
|
||||
* @return the replacement
|
||||
*/
|
||||
public String update();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
<?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"
|
||||
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>
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-config</artifactId>
|
||||
<name>HolographicDisplays Config</name>
|
||||
<artifactId>holographicdisplays-config</artifactId>
|
||||
<name>HolographicDisplays Config</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -18,39 +18,39 @@ import java.util.Arrays;
|
|||
|
||||
public enum ConfigNode {
|
||||
|
||||
SPACE_BETWEEN_LINES("space-between-lines", 0.02),
|
||||
QUICK_EDIT_COMMANDS("quick-edit-commands", true),
|
||||
IMAGES_SYMBOL("images.symbol", "[x]"),
|
||||
TRANSPARENCY_SPACE("images.transparency.space", " [|] "),
|
||||
TRANSPARENCY_COLOR("images.transparency.color", "&7"),
|
||||
UPDATE_NOTIFICATION("update-notification", true),
|
||||
BUNGEE_REFRESH_SECONDS("bungee.refresh-seconds", 3),
|
||||
BUNGEE_USE_REDIS_BUNGEE("bungee.use-RedisBungee", false),
|
||||
BUNGEE_USE_FULL_PINGER("bungee.pinger.enable", false),
|
||||
BUNGEE_PINGER_TIMEOUT("bungee.pinger.timeout", 500),
|
||||
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_OFFLINE_FORMAT("bungee.pinger.status.offline", "&cOffline"),
|
||||
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")),
|
||||
TIME_FORMAT("time.format", "H:mm"),
|
||||
TIME_ZONE("time.zone", "GMT+1"),
|
||||
DEBUG("debug", false);
|
||||
|
||||
private final String path;
|
||||
private final Object value;
|
||||
|
||||
private ConfigNode(String path, Object defaultValue) {
|
||||
this.path = path;
|
||||
value = defaultValue;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public Object getDefaultValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
SPACE_BETWEEN_LINES("space-between-lines", 0.02),
|
||||
QUICK_EDIT_COMMANDS("quick-edit-commands", true),
|
||||
IMAGES_SYMBOL("images.symbol", "[x]"),
|
||||
TRANSPARENCY_SPACE("images.transparency.space", " [|] "),
|
||||
TRANSPARENCY_COLOR("images.transparency.color", "&7"),
|
||||
UPDATE_NOTIFICATION("update-notification", true),
|
||||
BUNGEE_REFRESH_SECONDS("bungee.refresh-seconds", 3),
|
||||
BUNGEE_USE_REDIS_BUNGEE("bungee.use-RedisBungee", false),
|
||||
BUNGEE_USE_FULL_PINGER("bungee.pinger.enable", false),
|
||||
BUNGEE_PINGER_TIMEOUT("bungee.pinger.timeout", 500),
|
||||
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_OFFLINE_FORMAT("bungee.pinger.status.offline", "&cOffline"),
|
||||
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")),
|
||||
TIME_FORMAT("time.format", "H:mm"),
|
||||
TIME_ZONE("time.zone", "GMT+1"),
|
||||
DEBUG("debug", false);
|
||||
|
||||
private final String path;
|
||||
private final Object value;
|
||||
|
||||
private ConfigNode(String path, Object defaultValue) {
|
||||
this.path = path;
|
||||
value = defaultValue;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public Object getDefaultValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,186 +35,186 @@ import java.util.logging.Level;
|
|||
* Useful for fast access.
|
||||
*/
|
||||
public class Configuration {
|
||||
|
||||
public static double spaceBetweenLines;
|
||||
public static boolean quickEditCommands;
|
||||
public static String imageSymbol;
|
||||
public static String transparencySymbol;
|
||||
public static boolean updateNotification;
|
||||
public static ChatColor transparencyColor;
|
||||
|
||||
public static SimpleDateFormat timeFormat;
|
||||
|
||||
public static int bungeeRefreshSeconds;
|
||||
public static boolean useRedisBungee;
|
||||
|
||||
public static boolean pingerEnable;
|
||||
public static int pingerTimeout;
|
||||
public static String pingerOfflineMotd;
|
||||
public static String pingerStatusOnline;
|
||||
public static String pingerStatusOffline;
|
||||
public static boolean pingerTrimMotd;
|
||||
public static Map<String, ServerAddress> pingerServers;
|
||||
|
||||
public static double spaceBetweenLines;
|
||||
public static boolean quickEditCommands;
|
||||
public static String imageSymbol;
|
||||
public static String transparencySymbol;
|
||||
public static boolean updateNotification;
|
||||
public static ChatColor transparencyColor;
|
||||
|
||||
public static SimpleDateFormat timeFormat;
|
||||
|
||||
public static int bungeeRefreshSeconds;
|
||||
public static boolean useRedisBungee;
|
||||
|
||||
public static boolean pingerEnable;
|
||||
public static int pingerTimeout;
|
||||
public static String pingerOfflineMotd;
|
||||
public static String pingerStatusOnline;
|
||||
public static String pingerStatusOffline;
|
||||
public static boolean pingerTrimMotd;
|
||||
public static Map<String, ServerAddress> pingerServers;
|
||||
|
||||
|
||||
public static void load(Plugin plugin) {
|
||||
File configFile = new File(plugin.getDataFolder(), "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
plugin.getDataFolder().mkdirs();
|
||||
plugin.saveResource("config.yml", true);
|
||||
}
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
try {
|
||||
config.load(configFile);
|
||||
} catch (InvalidConfigurationException e) {
|
||||
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/");
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.log(Level.WARNING, "I/O error while reading the configuration. Was the file in use?");
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.log(Level.WARNING, "Unhandled exception while reading the configuration!");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean needsSave = false;
|
||||
|
||||
for (ConfigNode node : ConfigNode.values()) {
|
||||
if (!config.isSet(node.getPath())) {
|
||||
needsSave = true;
|
||||
config.set(node.getPath(), node.getDefaultValue());
|
||||
}
|
||||
}
|
||||
|
||||
// Check the old values.
|
||||
List<String> nodesToRemove = Arrays.asList(
|
||||
"vertical-spacing",
|
||||
"time-format",
|
||||
"bungee-refresh-seconds",
|
||||
"using-RedisBungee",
|
||||
"bungee-online-format",
|
||||
"bungee-offline-format",
|
||||
"precise-hologram-movement"
|
||||
);
|
||||
|
||||
public static void load(Plugin plugin) {
|
||||
File configFile = new File(plugin.getDataFolder(), "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
plugin.getDataFolder().mkdirs();
|
||||
plugin.saveResource("config.yml", true);
|
||||
}
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
try {
|
||||
config.load(configFile);
|
||||
} catch (InvalidConfigurationException e) {
|
||||
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/");
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.log(Level.WARNING, "I/O error while reading the configuration. Was the file in use?");
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.log(Level.WARNING, "Unhandled exception while reading the configuration!");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean needsSave = false;
|
||||
|
||||
for (ConfigNode node : ConfigNode.values()) {
|
||||
if (!config.isSet(node.getPath())) {
|
||||
needsSave = true;
|
||||
config.set(node.getPath(), node.getDefaultValue());
|
||||
}
|
||||
}
|
||||
|
||||
// Check the old values.
|
||||
List<String> nodesToRemove = Arrays.asList(
|
||||
"vertical-spacing",
|
||||
"time-format",
|
||||
"bungee-refresh-seconds",
|
||||
"using-RedisBungee",
|
||||
"bungee-online-format",
|
||||
"bungee-offline-format",
|
||||
"precise-hologram-movement"
|
||||
);
|
||||
|
||||
for (String oldNode : nodesToRemove) {
|
||||
if (config.isSet(oldNode)) {
|
||||
config.set(oldNode, null);
|
||||
needsSave = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (needsSave) {
|
||||
config.options().header(String.join("\n",
|
||||
".",
|
||||
". Read the tutorial at: http://dev.bukkit.org/bukkit-plugins/holographic-displays/",
|
||||
".",
|
||||
". Plugin created by filoghost.",
|
||||
"."));
|
||||
config.options().copyHeader(true);
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.log(Level.WARNING, "I/O error while saving the configuration. Was the file in use?");
|
||||
}
|
||||
}
|
||||
|
||||
spaceBetweenLines = config.getDouble(ConfigNode.SPACE_BETWEEN_LINES.getPath());
|
||||
quickEditCommands = config.getBoolean(ConfigNode.QUICK_EDIT_COMMANDS.getPath());
|
||||
|
||||
updateNotification = config.getBoolean(ConfigNode.UPDATE_NOTIFICATION.getPath());
|
||||
|
||||
imageSymbol = StringConverter.toReadableFormat(config.getString(ConfigNode.IMAGES_SYMBOL.getPath()));
|
||||
transparencySymbol = StringConverter.toReadableFormat(config.getString(ConfigNode.TRANSPARENCY_SPACE.getPath()));
|
||||
bungeeRefreshSeconds = config.getInt(ConfigNode.BUNGEE_REFRESH_SECONDS.getPath());
|
||||
useRedisBungee = config.getBoolean(ConfigNode.BUNGEE_USE_REDIS_BUNGEE.getPath());
|
||||
|
||||
pingerEnable = config.getBoolean(ConfigNode.BUNGEE_USE_FULL_PINGER.getPath());
|
||||
pingerTimeout = config.getInt(ConfigNode.BUNGEE_PINGER_TIMEOUT.getPath());
|
||||
pingerTrimMotd = config.getBoolean(ConfigNode.BUNGEE_PINGER_TRIM_MOTD.getPath());
|
||||
|
||||
pingerOfflineMotd = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_OFFLINE_MOTD.getPath()));
|
||||
pingerStatusOnline = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_ONLINE_FORMAT.getPath()));
|
||||
pingerStatusOffline = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_OFFLINE_FORMAT.getPath()));
|
||||
|
||||
if (pingerTimeout <= 0) {
|
||||
pingerTimeout = 100;
|
||||
} else if (pingerTimeout >= 10000) {
|
||||
pingerTimeout = 10000;
|
||||
}
|
||||
|
||||
pingerServers = new HashMap<>();
|
||||
|
||||
if (pingerEnable) {
|
||||
for (String singleServer : config.getStringList(ConfigNode.BUNGEE_PINGER_SERVERS.getPath())) {
|
||||
String[] nameAndAddress = singleServer.split(":", 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.");
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = nameAndAddress[0].trim();
|
||||
String address = nameAndAddress[1].replace(" ", "");
|
||||
|
||||
String ip;
|
||||
int port;
|
||||
|
||||
if (address.contains(":")) {
|
||||
String[] ipAndPort = address.split(":", 2);
|
||||
ip = ipAndPort[0];
|
||||
try {
|
||||
port = Integer.parseInt(ipAndPort[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
ConsoleLogger.log(Level.WARNING, "Invalid port number in the server info \"" + singleServer + "\".");
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
ip = address;
|
||||
port = 25565; // The default Minecraft port.
|
||||
}
|
||||
|
||||
pingerServers.put(name, new ServerAddress(ip, port));
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleLogger.setDebugEnabled(config.getBoolean(ConfigNode.DEBUG.getPath()));
|
||||
|
||||
String tempColor = config.getString(ConfigNode.TRANSPARENCY_COLOR.getPath()).replace('&', ChatColor.COLOR_CHAR);
|
||||
boolean foundColor = false;
|
||||
for (ChatColor chatColor : ChatColor.values()) {
|
||||
if (chatColor.toString().equals(tempColor)) {
|
||||
Configuration.transparencyColor = chatColor;
|
||||
foundColor = true;
|
||||
}
|
||||
}
|
||||
if (!foundColor) {
|
||||
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.");
|
||||
}
|
||||
|
||||
try {
|
||||
timeFormat = new SimpleDateFormat(config.getString(ConfigNode.TIME_FORMAT.getPath()));
|
||||
timeFormat.setTimeZone(TimeZone.getTimeZone(config.getString(ConfigNode.TIME_ZONE.getPath())));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
timeFormat = new SimpleDateFormat("H:mm");
|
||||
ConsoleLogger.log(Level.WARNING, "Time format not valid in the configuration, using the default.");
|
||||
}
|
||||
|
||||
if (bungeeRefreshSeconds < 1) {
|
||||
ConsoleLogger.log(Level.WARNING, "The minimum interval for pinging BungeeCord's servers is 1 second. It has been automatically set.");
|
||||
bungeeRefreshSeconds = 1;
|
||||
}
|
||||
|
||||
if (bungeeRefreshSeconds > 60) {
|
||||
ConsoleLogger.log(Level.WARNING, "The maximum interval for pinging BungeeCord's servers is 60 seconds. It has been automatically set.");
|
||||
bungeeRefreshSeconds = 60;
|
||||
}
|
||||
}
|
||||
for (String oldNode : nodesToRemove) {
|
||||
if (config.isSet(oldNode)) {
|
||||
config.set(oldNode, null);
|
||||
needsSave = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (needsSave) {
|
||||
config.options().header(String.join("\n",
|
||||
".",
|
||||
". Read the tutorial at: http://dev.bukkit.org/bukkit-plugins/holographic-displays/",
|
||||
".",
|
||||
". Plugin created by filoghost.",
|
||||
"."));
|
||||
config.options().copyHeader(true);
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.log(Level.WARNING, "I/O error while saving the configuration. Was the file in use?");
|
||||
}
|
||||
}
|
||||
|
||||
spaceBetweenLines = config.getDouble(ConfigNode.SPACE_BETWEEN_LINES.getPath());
|
||||
quickEditCommands = config.getBoolean(ConfigNode.QUICK_EDIT_COMMANDS.getPath());
|
||||
|
||||
updateNotification = config.getBoolean(ConfigNode.UPDATE_NOTIFICATION.getPath());
|
||||
|
||||
imageSymbol = StringConverter.toReadableFormat(config.getString(ConfigNode.IMAGES_SYMBOL.getPath()));
|
||||
transparencySymbol = StringConverter.toReadableFormat(config.getString(ConfigNode.TRANSPARENCY_SPACE.getPath()));
|
||||
bungeeRefreshSeconds = config.getInt(ConfigNode.BUNGEE_REFRESH_SECONDS.getPath());
|
||||
useRedisBungee = config.getBoolean(ConfigNode.BUNGEE_USE_REDIS_BUNGEE.getPath());
|
||||
|
||||
pingerEnable = config.getBoolean(ConfigNode.BUNGEE_USE_FULL_PINGER.getPath());
|
||||
pingerTimeout = config.getInt(ConfigNode.BUNGEE_PINGER_TIMEOUT.getPath());
|
||||
pingerTrimMotd = config.getBoolean(ConfigNode.BUNGEE_PINGER_TRIM_MOTD.getPath());
|
||||
|
||||
pingerOfflineMotd = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_OFFLINE_MOTD.getPath()));
|
||||
pingerStatusOnline = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_ONLINE_FORMAT.getPath()));
|
||||
pingerStatusOffline = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_OFFLINE_FORMAT.getPath()));
|
||||
|
||||
if (pingerTimeout <= 0) {
|
||||
pingerTimeout = 100;
|
||||
} else if (pingerTimeout >= 10000) {
|
||||
pingerTimeout = 10000;
|
||||
}
|
||||
|
||||
pingerServers = new HashMap<>();
|
||||
|
||||
if (pingerEnable) {
|
||||
for (String singleServer : config.getStringList(ConfigNode.BUNGEE_PINGER_SERVERS.getPath())) {
|
||||
String[] nameAndAddress = singleServer.split(":", 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.");
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = nameAndAddress[0].trim();
|
||||
String address = nameAndAddress[1].replace(" ", "");
|
||||
|
||||
String ip;
|
||||
int port;
|
||||
|
||||
if (address.contains(":")) {
|
||||
String[] ipAndPort = address.split(":", 2);
|
||||
ip = ipAndPort[0];
|
||||
try {
|
||||
port = Integer.parseInt(ipAndPort[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
ConsoleLogger.log(Level.WARNING, "Invalid port number in the server info \"" + singleServer + "\".");
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
ip = address;
|
||||
port = 25565; // The default Minecraft port.
|
||||
}
|
||||
|
||||
pingerServers.put(name, new ServerAddress(ip, port));
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleLogger.setDebugEnabled(config.getBoolean(ConfigNode.DEBUG.getPath()));
|
||||
|
||||
String tempColor = config.getString(ConfigNode.TRANSPARENCY_COLOR.getPath()).replace('&', ChatColor.COLOR_CHAR);
|
||||
boolean foundColor = false;
|
||||
for (ChatColor chatColor : ChatColor.values()) {
|
||||
if (chatColor.toString().equals(tempColor)) {
|
||||
Configuration.transparencyColor = chatColor;
|
||||
foundColor = true;
|
||||
}
|
||||
}
|
||||
if (!foundColor) {
|
||||
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.");
|
||||
}
|
||||
|
||||
try {
|
||||
timeFormat = new SimpleDateFormat(config.getString(ConfigNode.TIME_FORMAT.getPath()));
|
||||
timeFormat.setTimeZone(TimeZone.getTimeZone(config.getString(ConfigNode.TIME_ZONE.getPath())));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
timeFormat = new SimpleDateFormat("H:mm");
|
||||
ConsoleLogger.log(Level.WARNING, "Time format not valid in the configuration, using the default.");
|
||||
}
|
||||
|
||||
if (bungeeRefreshSeconds < 1) {
|
||||
ConsoleLogger.log(Level.WARNING, "The minimum interval for pinging BungeeCord's servers is 1 second. It has been automatically set.");
|
||||
bungeeRefreshSeconds = 1;
|
||||
}
|
||||
|
||||
if (bungeeRefreshSeconds > 60) {
|
||||
ConsoleLogger.log(Level.WARNING, "The maximum interval for pinging BungeeCord's servers is 60 seconds. It has been automatically set.");
|
||||
bungeeRefreshSeconds = 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,38 +25,38 @@ import java.text.DecimalFormatSymbols;
|
|||
import java.util.Locale;
|
||||
|
||||
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 {
|
||||
if (input == null) {
|
||||
throw new InvalidFormatException();
|
||||
}
|
||||
|
||||
String[] parts = input.split(",");
|
||||
|
||||
if (parts.length != 4) {
|
||||
throw new InvalidFormatException();
|
||||
}
|
||||
|
||||
try {
|
||||
double x = Double.parseDouble(parts[1].replace(" ", ""));
|
||||
double y = Double.parseDouble(parts[2].replace(" ", ""));
|
||||
double z = Double.parseDouble(parts[3].replace(" ", ""));
|
||||
|
||||
World world = Bukkit.getWorld(parts[0].trim());
|
||||
if (world == null) {
|
||||
throw new WorldNotFoundException(parts[0].trim());
|
||||
}
|
||||
|
||||
return new Location(world, x, y, z);
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new InvalidFormatException();
|
||||
}
|
||||
}
|
||||
|
||||
public static String locationToString(Location loc) {
|
||||
return (loc.getWorld().getName() + ", " + numberFormat.format(loc.getX()) + ", " + numberFormat.format(loc.getY()) + ", " + numberFormat.format(loc.getZ()));
|
||||
}
|
||||
public static Location locationFromString(String input) throws WorldNotFoundException, InvalidFormatException {
|
||||
if (input == null) {
|
||||
throw new InvalidFormatException();
|
||||
}
|
||||
|
||||
String[] parts = input.split(",");
|
||||
|
||||
if (parts.length != 4) {
|
||||
throw new InvalidFormatException();
|
||||
}
|
||||
|
||||
try {
|
||||
double x = Double.parseDouble(parts[1].replace(" ", ""));
|
||||
double y = Double.parseDouble(parts[2].replace(" ", ""));
|
||||
double z = Double.parseDouble(parts[3].replace(" ", ""));
|
||||
|
||||
World world = Bukkit.getWorld(parts[0].trim());
|
||||
if (world == null) {
|
||||
throw new WorldNotFoundException(parts[0].trim());
|
||||
}
|
||||
|
||||
return new Location(world, x, y, z);
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new InvalidFormatException();
|
||||
}
|
||||
}
|
||||
|
||||
public static String locationToString(Location loc) {
|
||||
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;
|
||||
|
||||
public class ServerAddress {
|
||||
|
||||
private String ip;
|
||||
private int port;
|
||||
|
||||
public ServerAddress(String ip, int port) {
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
private String ip;
|
||||
private int port;
|
||||
|
||||
public ServerAddress(String ip, int port) {
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return ip;
|
||||
}
|
||||
public String getAddress() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ip + ":" + port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ip + ":" + port;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,80 +19,80 @@ import org.bukkit.ChatColor;
|
|||
|
||||
public class StringConverter {
|
||||
|
||||
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 boolean HEX_CHAT_COLORS_ENABLED = Utils.classExists("org.bukkit.entity.Strider");
|
||||
private static final int HEX_COLOR_LENGTH = 6;
|
||||
|
||||
public static String toReadableFormat(String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
public static String toReadableFormat(String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
input = UnicodeSymbols.placeholdersToSymbols(input);
|
||||
input = addColors(input);
|
||||
return input;
|
||||
}
|
||||
input = UnicodeSymbols.placeholdersToSymbols(input);
|
||||
input = addColors(input);
|
||||
return input;
|
||||
}
|
||||
|
||||
public static String addColors(String input) {
|
||||
if (!input.contains("&")) {
|
||||
return input;
|
||||
}
|
||||
public static String addColors(String input) {
|
||||
if (!input.contains("&")) {
|
||||
return input;
|
||||
}
|
||||
|
||||
StringBuilder output = new StringBuilder(input.length());
|
||||
StringBuilder output = new StringBuilder(input.length());
|
||||
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
char current = input.charAt(i);
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
char current = input.charAt(i);
|
||||
|
||||
if (current == '&' && i + 1 < input.length()) {
|
||||
char next = input.charAt(i + 1);
|
||||
if (current == '&' && i + 1 < input.length()) {
|
||||
char next = input.charAt(i + 1);
|
||||
|
||||
if (next == '#' && HEX_CHAT_COLORS_ENABLED && isValidHexColor(input, i + 2)) {
|
||||
output.append(ChatColor.COLOR_CHAR);
|
||||
output.append('x');
|
||||
if (next == '#' && HEX_CHAT_COLORS_ENABLED && isValidHexColor(input, i + 2)) {
|
||||
output.append(ChatColor.COLOR_CHAR);
|
||||
output.append('x');
|
||||
|
||||
for (int j = 0; j < HEX_COLOR_LENGTH; j++) {
|
||||
output.append(ChatColor.COLOR_CHAR);
|
||||
output.append(Character.toLowerCase(input.charAt(i + 2 + j)));
|
||||
}
|
||||
for (int j = 0; j < HEX_COLOR_LENGTH; j++) {
|
||||
output.append(ChatColor.COLOR_CHAR);
|
||||
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)) {
|
||||
output.append(ChatColor.COLOR_CHAR);
|
||||
output.append(Character.toLowerCase(next));
|
||||
} else if (isColorCode(next)) {
|
||||
output.append(ChatColor.COLOR_CHAR);
|
||||
output.append(Character.toLowerCase(next));
|
||||
|
||||
i++; // Skip next character, which is already added
|
||||
i++; // Skip next character, which is already added
|
||||
|
||||
} else {
|
||||
output.append(current);
|
||||
}
|
||||
} else {
|
||||
output.append(current);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
output.append(current);
|
||||
}
|
||||
} else {
|
||||
output.append(current);
|
||||
}
|
||||
}
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
private static boolean isValidHexColor(String input, int startIndex) {
|
||||
if (input.length() - startIndex < HEX_COLOR_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
private static boolean isValidHexColor(String input, int startIndex) {
|
||||
if (input.length() - startIndex < HEX_COLOR_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < HEX_COLOR_LENGTH; i++) {
|
||||
if (!isHexCode(input.charAt(startIndex + i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < HEX_COLOR_LENGTH; i++) {
|
||||
if (!isHexCode(input.charAt(startIndex + i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isHexCode(char c) {
|
||||
return "0123456789AaBbCcDdEeFf".indexOf(c) > -1;
|
||||
}
|
||||
private static boolean isHexCode(char c) {
|
||||
return "0123456789AaBbCcDdEeFf".indexOf(c) > -1;
|
||||
}
|
||||
|
||||
private static boolean isColorCode(char c) {
|
||||
return "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(c) > -1;
|
||||
}
|
||||
|
||||
private static boolean isColorCode(char c) {
|
||||
return "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(c) > -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,79 +29,79 @@ import java.util.logging.Level;
|
|||
|
||||
public class UnicodeSymbols {
|
||||
|
||||
private static Map<String, String> placeholders = new HashMap<>();
|
||||
|
||||
public static void load(Plugin plugin) {
|
||||
placeholders.clear();
|
||||
|
||||
File file = new File(plugin.getDataFolder(), "symbols.yml");
|
||||
|
||||
if (!file.exists()) {
|
||||
plugin.getDataFolder().mkdirs();
|
||||
plugin.saveResource("symbols.yml", true);
|
||||
}
|
||||
|
||||
List<String> lines;
|
||||
try {
|
||||
lines = FileUtils.readLines(file);
|
||||
} catch (IOException e) {
|
||||
ConsoleLogger.log(Level.WARNING, "I/O error while reading symbols.yml. Was the file in use?", e);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.log(Level.WARNING, "Unhandled exception while reading symbols.yml!", e);
|
||||
return;
|
||||
}
|
||||
|
||||
for (String line : lines) {
|
||||
|
||||
// Comment or empty line.
|
||||
if (line.length() == 0 || line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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.");
|
||||
continue;
|
||||
}
|
||||
|
||||
int indexOf = line.indexOf(':');
|
||||
String placeholder = unquote(line.substring(0, indexOf).trim());
|
||||
String replacement = StringEscapeUtils.unescapeJava(unquote(line.substring(indexOf + 1, line.length()).trim()));
|
||||
private static Map<String, String> placeholders = new HashMap<>();
|
||||
|
||||
public static void load(Plugin plugin) {
|
||||
placeholders.clear();
|
||||
|
||||
File file = new File(plugin.getDataFolder(), "symbols.yml");
|
||||
|
||||
if (!file.exists()) {
|
||||
plugin.getDataFolder().mkdirs();
|
||||
plugin.saveResource("symbols.yml", true);
|
||||
}
|
||||
|
||||
List<String> lines;
|
||||
try {
|
||||
lines = FileUtils.readLines(file);
|
||||
} catch (IOException e) {
|
||||
ConsoleLogger.log(Level.WARNING, "I/O error while reading symbols.yml. Was the file in use?", e);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.log(Level.WARNING, "Unhandled exception while reading symbols.yml!", e);
|
||||
return;
|
||||
}
|
||||
|
||||
for (String line : lines) {
|
||||
|
||||
// Comment or empty line.
|
||||
if (line.length() == 0 || line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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.");
|
||||
continue;
|
||||
}
|
||||
|
||||
int indexOf = line.indexOf(':');
|
||||
String placeholder = unquote(line.substring(0, indexOf).trim());
|
||||
String replacement = StringEscapeUtils.unescapeJava(unquote(line.substring(indexOf + 1, line.length()).trim()));
|
||||
|
||||
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.");
|
||||
continue;
|
||||
}
|
||||
|
||||
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.");
|
||||
continue;
|
||||
}
|
||||
|
||||
placeholders.put(placeholder, replacement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static String placeholdersToSymbols(String input) {
|
||||
for (Entry<String, String> entry : placeholders.entrySet()) {
|
||||
input = input.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
private static String unquote(String input) {
|
||||
if (input.length() < 2) {
|
||||
// Cannot be quoted.
|
||||
return input;
|
||||
}
|
||||
if (input.startsWith("'") && input.endsWith("'")) {
|
||||
return input.substring(1, input.length() - 1);
|
||||
} else if (input.startsWith("\"") && input.endsWith("\"")) {
|
||||
return input.substring(1, input.length() - 1);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
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.");
|
||||
continue;
|
||||
}
|
||||
|
||||
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.");
|
||||
continue;
|
||||
}
|
||||
|
||||
placeholders.put(placeholder, replacement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static String placeholdersToSymbols(String input) {
|
||||
for (Entry<String, String> entry : placeholders.entrySet()) {
|
||||
input = input.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
private static String unquote(String input) {
|
||||
if (input.length() < 2) {
|
||||
// Cannot be quoted.
|
||||
return input;
|
||||
}
|
||||
if (input.startsWith("'") && input.endsWith("'")) {
|
||||
return input.substring(1, input.length() - 1);
|
||||
} else if (input.startsWith("\"") && input.endsWith("\"")) {
|
||||
return input.substring(1, input.length() - 1);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,6 @@ package me.filoghost.holographicdisplays.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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public WorldNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public WorldNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?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"
|
||||
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>
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-example</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-example</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-example-deathholograms</artifactId>
|
||||
<name>HolographicDisplays Example DeathHolograms</name>
|
||||
|
||||
<artifactId>holographicdisplays-example-deathholograms</artifactId>
|
||||
<name>HolographicDisplays Example DeathHolograms</name>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -27,28 +27,28 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Date;
|
||||
|
||||
public class DeathHolograms extends JavaPlugin implements Listener {
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
||||
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
|
||||
getLogger().severe("*** This plugin will be disabled. ***");
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
|
||||
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.GRAY + "Time of death: " + new SimpleDateFormat("H:m").format(new Date()));
|
||||
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
||||
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
|
||||
getLogger().severe("*** This plugin will be disabled. ***");
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
|
||||
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.GRAY + "Time of death: " + new SimpleDateFormat("H:m").format(new Date()));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
<?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"
|
||||
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>
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-example</artifactId>
|
||||
<name>HolographicDisplays Example</name>
|
||||
<packaging>pom</packaging>
|
||||
<artifactId>holographicdisplays-example</artifactId>
|
||||
<name>HolographicDisplays Example</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>death-holograms</module>
|
||||
<module>power-ups</module>
|
||||
</modules>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<modules>
|
||||
<module>death-holograms</module>
|
||||
<module>power-ups</module>
|
||||
</modules>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?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"
|
||||
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>
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-example</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-example</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-example-powerups</artifactId>
|
||||
<name>HolographicDisplays Example PowerUps</name>
|
||||
<artifactId>holographicdisplays-example-powerups</artifactId>
|
||||
<name>HolographicDisplays Example PowerUps</name>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -33,53 +33,53 @@ import org.bukkit.potion.PotionEffect;
|
|||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class PowerUps extends JavaPlugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
||||
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
|
||||
getLogger().severe("*** This plugin will be disabled. ***");
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
|
||||
if (event.getEntityType() == EntityType.ZOMBIE) {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
||||
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
|
||||
getLogger().severe("*** This plugin will be disabled. ***");
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
|
||||
if (event.getEntityType() == EntityType.ZOMBIE) {
|
||||
|
||||
// Remove normal drops and exp.
|
||||
event.getDrops().clear();
|
||||
event.setDroppedExp(0);
|
||||
|
||||
// Spawn the floating item with a label.
|
||||
final Hologram hologram = HologramsAPI.createHologram(this, event.getEntity().getLocation().add(0.0, 0.9, 0.0));
|
||||
hologram.appendTextLine(ChatColor.AQUA + "" + ChatColor.BOLD + "Speed PowerUp");
|
||||
ItemLine icon = hologram.appendItemLine(new ItemStack(Material.SUGAR));
|
||||
|
||||
icon.setPickupHandler(new PickupHandler() {
|
||||
|
||||
@Override
|
||||
public void onPickup(Player player) {
|
||||
|
||||
// Play an effect.
|
||||
player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null);
|
||||
|
||||
// 30 seconds of speed II.
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 1), true);
|
||||
|
||||
// Delete the hologram.
|
||||
hologram.delete();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
// Remove normal drops and exp.
|
||||
event.getDrops().clear();
|
||||
event.setDroppedExp(0);
|
||||
|
||||
// Spawn the floating item with a label.
|
||||
final Hologram hologram = HologramsAPI.createHologram(this, event.getEntity().getLocation().add(0.0, 0.9, 0.0));
|
||||
hologram.appendTextLine(ChatColor.AQUA + "" + ChatColor.BOLD + "Speed PowerUp");
|
||||
ItemLine icon = hologram.appendItemLine(new ItemStack(Material.SUGAR));
|
||||
|
||||
icon.setPickupHandler(new PickupHandler() {
|
||||
|
||||
@Override
|
||||
public void onPickup(Player player) {
|
||||
|
||||
// Play an effect.
|
||||
player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null);
|
||||
|
||||
// 30 seconds of speed II.
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 1), true);
|
||||
|
||||
// Delete the hologram.
|
||||
hologram.delete();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
<?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"
|
||||
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>
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-legacy-v1</artifactId>
|
||||
<name>HolographicDisplays Legacy v1</name>
|
||||
<artifactId>holographicdisplays-legacy-v1</artifactId>
|
||||
<name>HolographicDisplays Legacy v1</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -24,60 +24,60 @@ import org.bukkit.inventory.ItemStack;
|
|||
@Deprecated
|
||||
public interface FloatingItem {
|
||||
|
||||
@Deprecated
|
||||
public boolean update();
|
||||
@Deprecated
|
||||
public boolean update();
|
||||
|
||||
@Deprecated
|
||||
public void hide();
|
||||
@Deprecated
|
||||
public void hide();
|
||||
|
||||
@Deprecated
|
||||
public void setItemStack(ItemStack itemstack);
|
||||
@Deprecated
|
||||
public void setItemStack(ItemStack itemstack);
|
||||
|
||||
@Deprecated
|
||||
public ItemStack getItemStack();
|
||||
@Deprecated
|
||||
public ItemStack getItemStack();
|
||||
|
||||
@Deprecated
|
||||
public Location getLocation();
|
||||
@Deprecated
|
||||
public Location getLocation();
|
||||
|
||||
@Deprecated
|
||||
public double getX();
|
||||
@Deprecated
|
||||
public double getX();
|
||||
|
||||
@Deprecated
|
||||
public double getY();
|
||||
@Deprecated
|
||||
public double getY();
|
||||
|
||||
@Deprecated
|
||||
public double getZ();
|
||||
@Deprecated
|
||||
public double getZ();
|
||||
|
||||
@Deprecated
|
||||
public World getWorld();
|
||||
@Deprecated
|
||||
public World getWorld();
|
||||
|
||||
@Deprecated
|
||||
public void teleport(Location location);
|
||||
@Deprecated
|
||||
public void teleport(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void setTouchHandler(ItemTouchHandler handler);
|
||||
@Deprecated
|
||||
public void setTouchHandler(ItemTouchHandler handler);
|
||||
|
||||
@Deprecated
|
||||
public ItemTouchHandler getTouchHandler();
|
||||
@Deprecated
|
||||
public ItemTouchHandler getTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public void setPickupHandler(PickupHandler handler);
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public void setPickupHandler(PickupHandler handler);
|
||||
|
||||
@Deprecated
|
||||
public PickupHandler getPickupHandler();
|
||||
@Deprecated
|
||||
public PickupHandler getPickupHandler();
|
||||
|
||||
@Deprecated
|
||||
public boolean hasPickupHandler();
|
||||
@Deprecated
|
||||
public boolean hasPickupHandler();
|
||||
|
||||
@Deprecated
|
||||
public long getCreationTimestamp();
|
||||
@Deprecated
|
||||
public long getCreationTimestamp();
|
||||
|
||||
@Deprecated
|
||||
public void delete();
|
||||
@Deprecated
|
||||
public void delete();
|
||||
|
||||
@Deprecated
|
||||
public boolean isDeleted();
|
||||
@Deprecated
|
||||
public boolean isDeleted();
|
||||
}
|
||||
|
|
|
@ -23,70 +23,70 @@ import org.bukkit.World;
|
|||
@Deprecated
|
||||
public interface Hologram {
|
||||
|
||||
@Deprecated
|
||||
public boolean update();
|
||||
@Deprecated
|
||||
public boolean update();
|
||||
|
||||
@Deprecated
|
||||
public void hide();
|
||||
|
||||
@Deprecated
|
||||
public void addLine(String text);
|
||||
@Deprecated
|
||||
public void hide();
|
||||
|
||||
@Deprecated
|
||||
public void addLine(String text);
|
||||
|
||||
@Deprecated
|
||||
public void removeLine(int index);
|
||||
@Deprecated
|
||||
public void removeLine(int index);
|
||||
|
||||
@Deprecated
|
||||
public void setLine(int index, String text);
|
||||
@Deprecated
|
||||
public void setLine(int index, String text);
|
||||
|
||||
@Deprecated
|
||||
public void insertLine(int index, String text);
|
||||
@Deprecated
|
||||
public void insertLine(int index, String text);
|
||||
|
||||
@Deprecated
|
||||
public String[] getLines();
|
||||
|
||||
@Deprecated
|
||||
public int getLinesLength();
|
||||
|
||||
@Deprecated
|
||||
public void clearLines();
|
||||
|
||||
@Deprecated
|
||||
public Location getLocation();
|
||||
|
||||
@Deprecated
|
||||
public double getX();
|
||||
|
||||
@Deprecated
|
||||
public double getY();
|
||||
|
||||
@Deprecated
|
||||
public double getZ();
|
||||
|
||||
@Deprecated
|
||||
public World getWorld();
|
||||
@Deprecated
|
||||
public String[] getLines();
|
||||
|
||||
@Deprecated
|
||||
public int getLinesLength();
|
||||
|
||||
@Deprecated
|
||||
public void clearLines();
|
||||
|
||||
@Deprecated
|
||||
public Location getLocation();
|
||||
|
||||
@Deprecated
|
||||
public double getX();
|
||||
|
||||
@Deprecated
|
||||
public double getY();
|
||||
|
||||
@Deprecated
|
||||
public double getZ();
|
||||
|
||||
@Deprecated
|
||||
public World getWorld();
|
||||
|
||||
@Deprecated
|
||||
public void setLocation(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void teleport(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void setTouchHandler(TouchHandler handler);
|
||||
@Deprecated
|
||||
public void setLocation(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void teleport(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void setTouchHandler(TouchHandler handler);
|
||||
|
||||
@Deprecated
|
||||
public TouchHandler getTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler();
|
||||
@Deprecated
|
||||
public TouchHandler getTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public long getCreationTimestamp();
|
||||
@Deprecated
|
||||
public long getCreationTimestamp();
|
||||
|
||||
@Deprecated
|
||||
public void delete();
|
||||
@Deprecated
|
||||
public void delete();
|
||||
|
||||
@Deprecated
|
||||
public boolean isDeleted();
|
||||
|
||||
@Deprecated
|
||||
public boolean isDeleted();
|
||||
|
||||
}
|
||||
|
|
|
@ -40,128 +40,128 @@ import java.util.Set;
|
|||
*/
|
||||
@Deprecated
|
||||
public class HolographicDisplaysAPI {
|
||||
|
||||
private static Set<String> notifiedPlugins = new HashSet<>();
|
||||
|
||||
private static void notifyOldAPI(Plugin plugin) {
|
||||
Validator.notNull(plugin, "plugin");
|
||||
|
||||
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. "
|
||||
+ "Please notify the author and ask them to update it, the old API will be removed soon.");
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createHologram(Plugin plugin, Location source, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
for (String line : lines) {
|
||||
hologram.appendTextLine(line);
|
||||
}
|
||||
return new HologramAdapter(plugin, hologram);
|
||||
}
|
||||
|
||||
private static Set<String> notifiedPlugins = new HashSet<>();
|
||||
|
||||
private static void notifyOldAPI(Plugin plugin) {
|
||||
Validator.notNull(plugin, "plugin");
|
||||
|
||||
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. "
|
||||
+ "Please notify the author and ask them to update it, the old API will be removed soon.");
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createHologram(Plugin plugin, Location source, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
for (String line : lines) {
|
||||
hologram.appendTextLine(line);
|
||||
}
|
||||
return new HologramAdapter(plugin, hologram);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createFloatingItem(Plugin plugin, Location source, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
validateItem(itemstack);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
||||
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
||||
}
|
||||
@Deprecated
|
||||
public static FloatingItem createFloatingItem(Plugin plugin, Location source, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
validateItem(itemstack);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
||||
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, Player whoCanSee, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
return createIndividualHologram(plugin, source, Arrays.asList(whoCanSee), lines);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, List<Player> whoCanSee, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
|
||||
hologram.getVisibilityManager().setVisibleByDefault(false);
|
||||
if (whoCanSee != null) {
|
||||
for (Player player : whoCanSee) {
|
||||
hologram.getVisibilityManager().showTo(player);
|
||||
}
|
||||
}
|
||||
|
||||
for (String line : lines) {
|
||||
hologram.appendTextLine(line);
|
||||
}
|
||||
|
||||
return new HologramAdapter(plugin, hologram);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, Player whoCanSee, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
return createIndividualFloatingItem(plugin, source, Arrays.asList(whoCanSee), itemstack);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, List<Player> whoCanSee, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
validateItem(itemstack);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
||||
|
||||
hologram.getVisibilityManager().setVisibleByDefault(false);
|
||||
if (whoCanSee != null) {
|
||||
for (Player player : whoCanSee) {
|
||||
hologram.getVisibilityManager().showTo(player);
|
||||
}
|
||||
}
|
||||
|
||||
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram[] getHolograms(Plugin plugin) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
Collection<HologramAdapter> pluginHolograms = HologramAdapter.activeHolograms.getOrDefault(plugin, Collections.emptyList());
|
||||
return pluginHolograms.toArray(new HologramAdapter[0]);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem[] getFloatingItems(Plugin plugin) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
Collection<FloatingItemAdapter> pluginFloatingItems = FloatingItemAdapter.activeFloatingItems.getOrDefault(plugin, Collections.emptyList());
|
||||
return pluginFloatingItems.toArray(new FloatingItemAdapter[0]);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean isHologramEntity(Entity bukkitEntity) {
|
||||
return HologramsAPI.isHologramEntity(bukkitEntity);
|
||||
}
|
||||
|
||||
private static void validateLocation(Location loc) {
|
||||
Validator.notNull(loc, "location");
|
||||
Validator.notNull(loc.getWorld(), "location's world");
|
||||
}
|
||||
|
||||
private static void validateItem(ItemStack itemstack) {
|
||||
Validator.notNull(itemstack, "itemstack");
|
||||
Validator.isTrue(itemstack.getType() != Material.AIR, "itemstack cannot be AIR");
|
||||
}
|
||||
@Deprecated
|
||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, Player whoCanSee, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
return createIndividualHologram(plugin, source, Arrays.asList(whoCanSee), lines);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, List<Player> whoCanSee, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
|
||||
hologram.getVisibilityManager().setVisibleByDefault(false);
|
||||
if (whoCanSee != null) {
|
||||
for (Player player : whoCanSee) {
|
||||
hologram.getVisibilityManager().showTo(player);
|
||||
}
|
||||
}
|
||||
|
||||
for (String line : lines) {
|
||||
hologram.appendTextLine(line);
|
||||
}
|
||||
|
||||
return new HologramAdapter(plugin, hologram);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, Player whoCanSee, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
return createIndividualFloatingItem(plugin, source, Arrays.asList(whoCanSee), itemstack);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, List<Player> whoCanSee, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
validateItem(itemstack);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
||||
|
||||
hologram.getVisibilityManager().setVisibleByDefault(false);
|
||||
if (whoCanSee != null) {
|
||||
for (Player player : whoCanSee) {
|
||||
hologram.getVisibilityManager().showTo(player);
|
||||
}
|
||||
}
|
||||
|
||||
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram[] getHolograms(Plugin plugin) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
Collection<HologramAdapter> pluginHolograms = HologramAdapter.activeHolograms.getOrDefault(plugin, Collections.emptyList());
|
||||
return pluginHolograms.toArray(new HologramAdapter[0]);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem[] getFloatingItems(Plugin plugin) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
Collection<FloatingItemAdapter> pluginFloatingItems = FloatingItemAdapter.activeFloatingItems.getOrDefault(plugin, Collections.emptyList());
|
||||
return pluginFloatingItems.toArray(new FloatingItemAdapter[0]);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean isHologramEntity(Entity bukkitEntity) {
|
||||
return HologramsAPI.isHologramEntity(bukkitEntity);
|
||||
}
|
||||
|
||||
private static void validateLocation(Location loc) {
|
||||
Validator.notNull(loc, "location");
|
||||
Validator.notNull(loc.getWorld(), "location's world");
|
||||
}
|
||||
|
||||
private static void validateItem(ItemStack itemstack) {
|
||||
Validator.notNull(itemstack, "itemstack");
|
||||
Validator.isTrue(itemstack.getType() != Material.AIR, "itemstack cannot be AIR");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.bukkit.entity.Player;
|
|||
@Deprecated
|
||||
public interface ItemTouchHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onTouch(FloatingItem floatingItem, Player player);
|
||||
|
||||
@Deprecated
|
||||
public void onTouch(FloatingItem floatingItem, Player player);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.bukkit.entity.Player;
|
|||
@Deprecated
|
||||
public interface PickupHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onPickup(FloatingItem floatingItem, Player player);
|
||||
|
||||
@Deprecated
|
||||
public void onPickup(FloatingItem floatingItem, Player player);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.bukkit.entity.Player;
|
|||
@Deprecated
|
||||
public interface TouchHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onTouch(Hologram hologram, Player player);
|
||||
|
||||
@Deprecated
|
||||
public void onTouch(Hologram hologram, Player player);
|
||||
|
||||
}
|
||||
|
|
|
@ -31,130 +31,130 @@ import java.util.Map;
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class FloatingItemAdapter implements FloatingItem {
|
||||
|
||||
public static Map<Plugin, Collection<FloatingItemAdapter>> activeFloatingItems = new HashMap<>();
|
||||
|
||||
private Plugin plugin;
|
||||
public Hologram hologram;
|
||||
private ItemLine itemLine;
|
||||
private ItemTouchHandler touchHandler;
|
||||
private PickupHandler pickupHandler;
|
||||
|
||||
public FloatingItemAdapter(Plugin plugin, Hologram delegateHologram, ItemLine delegateItemLine) {
|
||||
this.plugin = plugin;
|
||||
this.hologram = delegateHologram;
|
||||
this.itemLine = delegateItemLine;
|
||||
|
||||
activeFloatingItems.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
||||
}
|
||||
|
||||
public static Map<Plugin, Collection<FloatingItemAdapter>> activeFloatingItems = new HashMap<>();
|
||||
|
||||
private Plugin plugin;
|
||||
public Hologram hologram;
|
||||
private ItemLine itemLine;
|
||||
private ItemTouchHandler touchHandler;
|
||||
private PickupHandler pickupHandler;
|
||||
|
||||
public FloatingItemAdapter(Plugin plugin, Hologram delegateHologram, ItemLine delegateItemLine) {
|
||||
this.plugin = plugin;
|
||||
this.hologram = delegateHologram;
|
||||
this.itemLine = delegateItemLine;
|
||||
|
||||
activeFloatingItems.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean update() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void hide() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStack(ItemStack itemstack) {
|
||||
itemLine.setItemStack(itemstack);
|
||||
}
|
||||
@Override
|
||||
public void setItemStack(ItemStack itemstack) {
|
||||
itemLine.setItemStack(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return itemLine.getItemStack();
|
||||
}
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return itemLine.getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return hologram.getLocation();
|
||||
}
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return hologram.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return hologram.getX();
|
||||
}
|
||||
@Override
|
||||
public double getX() {
|
||||
return hologram.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getY() {
|
||||
return hologram.getY();
|
||||
}
|
||||
@Override
|
||||
public double getY() {
|
||||
return hologram.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZ() {
|
||||
return hologram.getZ();
|
||||
}
|
||||
@Override
|
||||
public double getZ() {
|
||||
return hologram.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return hologram.getWorld();
|
||||
}
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return hologram.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
@Override
|
||||
public void teleport(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTouchHandler(ItemTouchHandler handler) {
|
||||
this.touchHandler = handler;
|
||||
|
||||
if (handler != null) {
|
||||
itemLine.setTouchHandler(new ItemTouchHandlerAdapter(this, handler));
|
||||
} else {
|
||||
itemLine.setTouchHandler(null);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setTouchHandler(ItemTouchHandler handler) {
|
||||
this.touchHandler = handler;
|
||||
|
||||
if (handler != null) {
|
||||
itemLine.setTouchHandler(new ItemTouchHandlerAdapter(this, handler));
|
||||
} else {
|
||||
itemLine.setTouchHandler(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTouchHandler getTouchHandler() {
|
||||
return touchHandler;
|
||||
}
|
||||
@Override
|
||||
public ItemTouchHandler getTouchHandler() {
|
||||
return touchHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTouchHandler() {
|
||||
return touchHandler != null;
|
||||
}
|
||||
@Override
|
||||
public boolean hasTouchHandler() {
|
||||
return touchHandler != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPickupHandler(PickupHandler handler) {
|
||||
this.pickupHandler = handler;
|
||||
|
||||
if (handler != null) {
|
||||
itemLine.setPickupHandler(new PickupHandlerAdapter(this, handler));
|
||||
} else {
|
||||
itemLine.setPickupHandler(null);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setPickupHandler(PickupHandler handler) {
|
||||
this.pickupHandler = handler;
|
||||
|
||||
if (handler != null) {
|
||||
itemLine.setPickupHandler(new PickupHandlerAdapter(this, handler));
|
||||
} else {
|
||||
itemLine.setPickupHandler(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PickupHandler getPickupHandler() {
|
||||
return pickupHandler;
|
||||
}
|
||||
@Override
|
||||
public PickupHandler getPickupHandler() {
|
||||
return pickupHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPickupHandler() {
|
||||
return pickupHandler != null;
|
||||
}
|
||||
@Override
|
||||
public boolean hasPickupHandler() {
|
||||
return pickupHandler != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTimestamp() {
|
||||
return hologram.getCreationTimestamp();
|
||||
}
|
||||
@Override
|
||||
public long getCreationTimestamp() {
|
||||
return hologram.getCreationTimestamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
hologram.delete();
|
||||
|
||||
activeFloatingItems.get(plugin).remove(this);
|
||||
}
|
||||
@Override
|
||||
public void delete() {
|
||||
hologram.delete();
|
||||
|
||||
activeFloatingItems.get(plugin).remove(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return hologram.isDeleted();
|
||||
}
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return hologram.isDeleted();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,172 +30,172 @@ import java.util.Map;
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class HologramAdapter implements Hologram {
|
||||
|
||||
public static Map<Plugin, Collection<HologramAdapter>> activeHolograms = new HashMap<>();
|
||||
|
||||
private Plugin plugin;
|
||||
private me.filoghost.holographicdisplays.api.Hologram hologram;
|
||||
private TouchHandler touchHandler;
|
||||
|
||||
public HologramAdapter(Plugin plugin, me.filoghost.holographicdisplays.api.Hologram delegate) {
|
||||
this.plugin = plugin;
|
||||
this.hologram = delegate;
|
||||
|
||||
activeHolograms.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean update() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Map<Plugin, Collection<HologramAdapter>> activeHolograms = new HashMap<>();
|
||||
|
||||
private Plugin plugin;
|
||||
private me.filoghost.holographicdisplays.api.Hologram hologram;
|
||||
private TouchHandler touchHandler;
|
||||
|
||||
public HologramAdapter(Plugin plugin, me.filoghost.holographicdisplays.api.Hologram delegate) {
|
||||
this.plugin = plugin;
|
||||
this.hologram = delegate;
|
||||
|
||||
activeHolograms.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean update() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void hide() {
|
||||
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public void hide() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addLine(String text) {
|
||||
hologram.appendTextLine(text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addLine(String text) {
|
||||
hologram.appendTextLine(text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setLine(int index, String text) {
|
||||
hologram.removeLine(index);
|
||||
hologram.insertTextLine(index, text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setLine(int index, String text) {
|
||||
hologram.removeLine(index);
|
||||
hologram.insertTextLine(index, text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void insertLine(int index, String text) {
|
||||
hologram.insertTextLine(index, text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public void insertLine(int index, String text) {
|
||||
hologram.insertTextLine(index, text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String[] getLines() {
|
||||
String[] lines = new String[hologram.size()];
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
HologramLine lineObject = hologram.getLine(i);
|
||||
if (lineObject instanceof TextLine) {
|
||||
lines[i] = ((TextLine) lineObject).getText();
|
||||
} else {
|
||||
lines[i] = "";
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public String[] getLines() {
|
||||
String[] lines = new String[hologram.size()];
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
HologramLine lineObject = hologram.getLine(i);
|
||||
if (lineObject instanceof TextLine) {
|
||||
lines[i] = ((TextLine) lineObject).getText();
|
||||
} else {
|
||||
lines[i] = "";
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getLinesLength() {
|
||||
return hologram.size();
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getLinesLength() {
|
||||
return hologram.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setLocation(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setLocation(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setTouchHandler(TouchHandler handler) {
|
||||
this.touchHandler = handler;
|
||||
updateTouchHandler();
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setTouchHandler(TouchHandler handler) {
|
||||
this.touchHandler = handler;
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
private void updateTouchHandler() {
|
||||
for (int i = 0; i < hologram.size(); i++) {
|
||||
HologramLine line = hologram.getLine(i);
|
||||
if (!(line instanceof TouchableLine)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TouchableLine touchableLine = (TouchableLine) line;
|
||||
|
||||
if (touchHandler != null) {
|
||||
touchableLine.setTouchHandler(new HologramTouchHandlerAdapter(this, touchHandler));
|
||||
} else {
|
||||
touchableLine.setTouchHandler(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void updateTouchHandler() {
|
||||
for (int i = 0; i < hologram.size(); i++) {
|
||||
HologramLine line = hologram.getLine(i);
|
||||
if (!(line instanceof TouchableLine)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TouchableLine touchableLine = (TouchableLine) line;
|
||||
|
||||
if (touchHandler != null) {
|
||||
touchableLine.setTouchHandler(new HologramTouchHandlerAdapter(this, touchHandler));
|
||||
} else {
|
||||
touchableLine.setTouchHandler(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public TouchHandler getTouchHandler() {
|
||||
return touchHandler;
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public TouchHandler getTouchHandler() {
|
||||
return touchHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler() {
|
||||
return touchHandler != null;
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler() {
|
||||
return touchHandler != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLine(int index) {
|
||||
hologram.removeLine(index);
|
||||
}
|
||||
@Override
|
||||
public void removeLine(int index) {
|
||||
hologram.removeLine(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearLines() {
|
||||
hologram.clearLines();
|
||||
}
|
||||
@Override
|
||||
public void clearLines() {
|
||||
hologram.clearLines();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return hologram.getLocation();
|
||||
}
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return hologram.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return hologram.getX();
|
||||
}
|
||||
@Override
|
||||
public double getX() {
|
||||
return hologram.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getY() {
|
||||
return hologram.getY();
|
||||
}
|
||||
@Override
|
||||
public double getY() {
|
||||
return hologram.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZ() {
|
||||
return hologram.getZ();
|
||||
}
|
||||
@Override
|
||||
public double getZ() {
|
||||
return hologram.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return hologram.getWorld();
|
||||
}
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return hologram.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
@Override
|
||||
public void teleport(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTimestamp() {
|
||||
return hologram.getCreationTimestamp();
|
||||
}
|
||||
@Override
|
||||
public long getCreationTimestamp() {
|
||||
return hologram.getCreationTimestamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
hologram.delete();
|
||||
|
||||
activeHolograms.get(plugin).remove(this);
|
||||
}
|
||||
@Override
|
||||
public void delete() {
|
||||
hologram.delete();
|
||||
|
||||
activeHolograms.get(plugin).remove(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return hologram.isDeleted();
|
||||
}
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return hologram.isDeleted();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,17 +21,17 @@ import org.bukkit.entity.Player;
|
|||
@SuppressWarnings("deprecation")
|
||||
public class HologramTouchHandlerAdapter implements me.filoghost.holographicdisplays.api.handler.TouchHandler {
|
||||
|
||||
protected TouchHandler oldHandler;
|
||||
private Hologram hologram;
|
||||
|
||||
public HologramTouchHandlerAdapter(Hologram hologram, TouchHandler oldHandler) {
|
||||
this.hologram = hologram;
|
||||
this.oldHandler = oldHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch(Player player) {
|
||||
oldHandler.onTouch(hologram, player);
|
||||
}
|
||||
protected TouchHandler oldHandler;
|
||||
private Hologram hologram;
|
||||
|
||||
public HologramTouchHandlerAdapter(Hologram hologram, TouchHandler oldHandler) {
|
||||
this.hologram = hologram;
|
||||
this.oldHandler = oldHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch(Player player) {
|
||||
oldHandler.onTouch(hologram, player);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,17 +22,17 @@ import org.bukkit.entity.Player;
|
|||
@SuppressWarnings("deprecation")
|
||||
public class ItemTouchHandlerAdapter implements TouchHandler {
|
||||
|
||||
protected ItemTouchHandler oldHandler;
|
||||
private FloatingItem item;
|
||||
|
||||
public ItemTouchHandlerAdapter(FloatingItem item, ItemTouchHandler oldHandler) {
|
||||
this.item = item;
|
||||
this.oldHandler = oldHandler;
|
||||
}
|
||||
protected ItemTouchHandler oldHandler;
|
||||
private FloatingItem item;
|
||||
|
||||
public ItemTouchHandlerAdapter(FloatingItem item, ItemTouchHandler oldHandler) {
|
||||
this.item = item;
|
||||
this.oldHandler = oldHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch(Player player) {
|
||||
oldHandler.onTouch(item, player);
|
||||
}
|
||||
@Override
|
||||
public void onTouch(Player player) {
|
||||
oldHandler.onTouch(item, player);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,17 +21,17 @@ import org.bukkit.entity.Player;
|
|||
@SuppressWarnings("deprecation")
|
||||
public class PickupHandlerAdapter implements me.filoghost.holographicdisplays.api.handler.PickupHandler {
|
||||
|
||||
public PickupHandler oldHandler;
|
||||
private FloatingItem item;
|
||||
|
||||
public PickupHandlerAdapter(FloatingItem item, PickupHandler oldPickupHandler) {
|
||||
this.item = item;
|
||||
this.oldHandler = oldPickupHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickup(Player player) {
|
||||
oldHandler.onPickup(item, player);
|
||||
}
|
||||
public PickupHandler oldHandler;
|
||||
private FloatingItem item;
|
||||
|
||||
public PickupHandlerAdapter(FloatingItem item, PickupHandler oldPickupHandler) {
|
||||
this.item = item;
|
||||
this.oldHandler = oldPickupHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickup(Player player) {
|
||||
oldHandler.onPickup(item, player);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
<?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"
|
||||
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>
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-legacy-v2</artifactId>
|
||||
<name>HolographicDisplays Legacy v2</name>
|
||||
<artifactId>holographicdisplays-legacy-v2</artifactId>
|
||||
<name>HolographicDisplays Legacy v2</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
</dependency>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -27,70 +27,70 @@ import org.bukkit.inventory.ItemStack;
|
|||
@Deprecated
|
||||
public interface Hologram {
|
||||
|
||||
@Deprecated
|
||||
public TextLine appendTextLine(String text);
|
||||
@Deprecated
|
||||
public TextLine appendTextLine(String text);
|
||||
|
||||
@Deprecated
|
||||
public ItemLine appendItemLine(ItemStack itemStack);
|
||||
|
||||
@Deprecated
|
||||
public TextLine insertTextLine(int index, String text);
|
||||
@Deprecated
|
||||
public ItemLine appendItemLine(ItemStack itemStack);
|
||||
|
||||
@Deprecated
|
||||
public TextLine insertTextLine(int index, String text);
|
||||
|
||||
@Deprecated
|
||||
public ItemLine insertItemLine(int index, ItemStack itemStack);
|
||||
@Deprecated
|
||||
public ItemLine insertItemLine(int index, ItemStack itemStack);
|
||||
|
||||
@Deprecated
|
||||
public HologramLine getLine(int index);
|
||||
|
||||
@Deprecated
|
||||
public void removeLine(int index);
|
||||
@Deprecated
|
||||
public HologramLine getLine(int index);
|
||||
|
||||
@Deprecated
|
||||
public void removeLine(int index);
|
||||
|
||||
@Deprecated
|
||||
public void clearLines();
|
||||
@Deprecated
|
||||
public void clearLines();
|
||||
|
||||
@Deprecated
|
||||
public int size();
|
||||
@Deprecated
|
||||
public int size();
|
||||
|
||||
@Deprecated
|
||||
public double getHeight();
|
||||
@Deprecated
|
||||
public double getHeight();
|
||||
|
||||
@Deprecated
|
||||
public void teleport(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void teleport(World world, double x, double y, double z);
|
||||
|
||||
@Deprecated
|
||||
public Location getLocation();
|
||||
|
||||
@Deprecated
|
||||
public double getX();
|
||||
@Deprecated
|
||||
public void teleport(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void teleport(World world, double x, double y, double z);
|
||||
|
||||
@Deprecated
|
||||
public Location getLocation();
|
||||
|
||||
@Deprecated
|
||||
public double getX();
|
||||
|
||||
@Deprecated
|
||||
public double getY();
|
||||
@Deprecated
|
||||
public double getY();
|
||||
|
||||
@Deprecated
|
||||
public double getZ();
|
||||
|
||||
@Deprecated
|
||||
public World getWorld();
|
||||
@Deprecated
|
||||
public double getZ();
|
||||
|
||||
@Deprecated
|
||||
public World getWorld();
|
||||
|
||||
@Deprecated
|
||||
public VisibilityManager getVisibilityManager();
|
||||
@Deprecated
|
||||
public VisibilityManager getVisibilityManager();
|
||||
|
||||
@Deprecated
|
||||
public long getCreationTimestamp();
|
||||
@Deprecated
|
||||
public long getCreationTimestamp();
|
||||
|
||||
@Deprecated
|
||||
public boolean isAllowPlaceholders();
|
||||
@Deprecated
|
||||
public boolean isAllowPlaceholders();
|
||||
|
||||
@Deprecated
|
||||
public void setAllowPlaceholders(boolean allowPlaceholders);
|
||||
|
||||
@Deprecated
|
||||
public void delete();
|
||||
|
||||
@Deprecated
|
||||
public boolean isDeleted();
|
||||
|
||||
@Deprecated
|
||||
public void setAllowPlaceholders(boolean allowPlaceholders);
|
||||
|
||||
@Deprecated
|
||||
public void delete();
|
||||
|
||||
@Deprecated
|
||||
public boolean isDeleted();
|
||||
|
||||
}
|
||||
|
|
|
@ -28,41 +28,41 @@ import java.util.Collection;
|
|||
@Deprecated
|
||||
public class HologramsAPI {
|
||||
|
||||
private HologramsAPI() {}
|
||||
private HologramsAPI() {}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createHologram(Plugin plugin, Location source) {
|
||||
return BackendAPI.getImplementation().createHologram(plugin, source);
|
||||
}
|
||||
@Deprecated
|
||||
public static Hologram createHologram(Plugin plugin, Location source) {
|
||||
return BackendAPI.getImplementation().createHologram(plugin, source);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Collection<Hologram> getHolograms(Plugin plugin) {
|
||||
return BackendAPI.getImplementation().getHolograms(plugin);
|
||||
}
|
||||
@Deprecated
|
||||
public static Collection<Hologram> getHolograms(Plugin plugin) {
|
||||
return BackendAPI.getImplementation().getHolograms(plugin);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer) {
|
||||
return BackendAPI.getImplementation().registerPlaceholder(plugin, textPlaceholder, refreshRate, replacer);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Collection<String> getRegisteredPlaceholders(Plugin plugin) {
|
||||
return BackendAPI.getImplementation().getRegisteredPlaceholders(plugin);
|
||||
}
|
||||
@Deprecated
|
||||
public static boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer) {
|
||||
return BackendAPI.getImplementation().registerPlaceholder(plugin, textPlaceholder, refreshRate, replacer);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Collection<String> getRegisteredPlaceholders(Plugin plugin) {
|
||||
return BackendAPI.getImplementation().getRegisteredPlaceholders(plugin);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder) {
|
||||
return BackendAPI.getImplementation().unregisterPlaceholder(plugin, textPlaceholder);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void unregisterPlaceholders(Plugin plugin) {
|
||||
BackendAPI.getImplementation().unregisterPlaceholders(plugin);
|
||||
}
|
||||
@Deprecated
|
||||
public static boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder) {
|
||||
return BackendAPI.getImplementation().unregisterPlaceholder(plugin, textPlaceholder);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void unregisterPlaceholders(Plugin plugin) {
|
||||
BackendAPI.getImplementation().unregisterPlaceholders(plugin);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean isHologramEntity(Entity bukkitEntity) {
|
||||
return BackendAPI.getImplementation().isHologramEntity(bukkitEntity);
|
||||
}
|
||||
@Deprecated
|
||||
public static boolean isHologramEntity(Entity bukkitEntity) {
|
||||
return BackendAPI.getImplementation().isHologramEntity(bukkitEntity);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,25 +22,25 @@ import org.bukkit.entity.Player;
|
|||
@Deprecated
|
||||
public interface VisibilityManager {
|
||||
|
||||
@Deprecated
|
||||
public boolean isVisibleByDefault();
|
||||
|
||||
@Deprecated
|
||||
public void setVisibleByDefault(boolean visibleByDefault);
|
||||
|
||||
@Deprecated
|
||||
public void showTo(Player player);
|
||||
|
||||
@Deprecated
|
||||
public void hideTo(Player player);
|
||||
|
||||
@Deprecated
|
||||
public boolean isVisibleTo(Player player);
|
||||
|
||||
@Deprecated
|
||||
public void resetVisibility(Player player);
|
||||
|
||||
@Deprecated
|
||||
public void resetVisibilityAll();
|
||||
|
||||
@Deprecated
|
||||
public boolean isVisibleByDefault();
|
||||
|
||||
@Deprecated
|
||||
public void setVisibleByDefault(boolean visibleByDefault);
|
||||
|
||||
@Deprecated
|
||||
public void showTo(Player player);
|
||||
|
||||
@Deprecated
|
||||
public void hideTo(Player player);
|
||||
|
||||
@Deprecated
|
||||
public boolean isVisibleTo(Player player);
|
||||
|
||||
@Deprecated
|
||||
public void resetVisibility(Player player);
|
||||
|
||||
@Deprecated
|
||||
public void resetVisibilityAll();
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.bukkit.entity.Player;
|
|||
@Deprecated
|
||||
public interface PickupHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onPickup(Player player);
|
||||
|
||||
@Deprecated
|
||||
public void onPickup(Player player);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.bukkit.entity.Player;
|
|||
@Deprecated
|
||||
public interface TouchHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onTouch(Player player);
|
||||
|
||||
@Deprecated
|
||||
public void onTouch(Player player);
|
||||
|
||||
}
|
||||
|
|
|
@ -27,42 +27,42 @@ import java.util.Collection;
|
|||
*/
|
||||
@Deprecated
|
||||
public abstract class BackendAPI {
|
||||
|
||||
private static BackendAPI implementation;
|
||||
|
||||
private static BackendAPI implementation;
|
||||
|
||||
@Deprecated
|
||||
public static void setImplementation(BackendAPI implementation) {
|
||||
BackendAPI.implementation = implementation;
|
||||
}
|
||||
@Deprecated
|
||||
public static void setImplementation(BackendAPI implementation) {
|
||||
BackendAPI.implementation = implementation;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static BackendAPI getImplementation() {
|
||||
if (implementation == null) {
|
||||
throw new IllegalStateException("No API implementation set. Is Holographic Displays enabled?");
|
||||
}
|
||||
|
||||
return implementation;
|
||||
}
|
||||
@Deprecated
|
||||
public static BackendAPI getImplementation() {
|
||||
if (implementation == null) {
|
||||
throw new IllegalStateException("No API implementation set. Is Holographic Displays enabled?");
|
||||
}
|
||||
|
||||
return implementation;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public abstract Hologram createHologram(Plugin plugin, Location source);
|
||||
@Deprecated
|
||||
public abstract Hologram createHologram(Plugin plugin, Location source);
|
||||
|
||||
@Deprecated
|
||||
public abstract Collection<Hologram> getHolograms(Plugin plugin);
|
||||
@Deprecated
|
||||
public abstract Collection<Hologram> getHolograms(Plugin plugin);
|
||||
|
||||
@Deprecated
|
||||
public abstract boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer);
|
||||
@Deprecated
|
||||
public abstract boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer);
|
||||
|
||||
@Deprecated
|
||||
public abstract Collection<String> getRegisteredPlaceholders(Plugin plugin);
|
||||
@Deprecated
|
||||
public abstract Collection<String> getRegisteredPlaceholders(Plugin plugin);
|
||||
|
||||
@Deprecated
|
||||
public abstract boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder);
|
||||
@Deprecated
|
||||
public abstract boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder);
|
||||
|
||||
@Deprecated
|
||||
public abstract void unregisterPlaceholders(Plugin plugin);
|
||||
@Deprecated
|
||||
public abstract void unregisterPlaceholders(Plugin plugin);
|
||||
|
||||
@Deprecated
|
||||
public abstract boolean isHologramEntity(Entity bukkitEntity);
|
||||
@Deprecated
|
||||
public abstract boolean isHologramEntity(Entity bukkitEntity);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ import com.gmail.filoghost.holographicdisplays.api.handler.PickupHandler;
|
|||
@Deprecated
|
||||
public interface CollectableLine extends HologramLine {
|
||||
|
||||
@Deprecated
|
||||
public void setPickupHandler(PickupHandler pickupHandler);
|
||||
|
||||
@Deprecated
|
||||
public PickupHandler getPickupHandler();
|
||||
|
||||
@Deprecated
|
||||
public void setPickupHandler(PickupHandler pickupHandler);
|
||||
|
||||
@Deprecated
|
||||
public PickupHandler getPickupHandler();
|
||||
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
|||
@Deprecated
|
||||
public interface HologramLine {
|
||||
|
||||
@Deprecated
|
||||
public Hologram getParent();
|
||||
|
||||
@Deprecated
|
||||
public void removeLine();
|
||||
@Deprecated
|
||||
public Hologram getParent();
|
||||
|
||||
@Deprecated
|
||||
public void removeLine();
|
||||
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ import org.bukkit.inventory.ItemStack;
|
|||
@Deprecated
|
||||
public interface ItemLine extends CollectableLine, TouchableLine {
|
||||
|
||||
@Deprecated
|
||||
public ItemStack getItemStack();
|
||||
@Deprecated
|
||||
public ItemStack getItemStack();
|
||||
|
||||
@Deprecated
|
||||
public void setItemStack(ItemStack itemStack);
|
||||
|
||||
@Deprecated
|
||||
public void setItemStack(ItemStack itemStack);
|
||||
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@ package com.gmail.filoghost.holographicdisplays.api.line;
|
|||
@Deprecated
|
||||
public interface TextLine extends TouchableLine {
|
||||
|
||||
@Deprecated
|
||||
public String getText();
|
||||
|
||||
@Deprecated
|
||||
public void setText(String text);
|
||||
|
||||
@Deprecated
|
||||
public String getText();
|
||||
|
||||
@Deprecated
|
||||
public void setText(String text);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ import com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler;
|
|||
@Deprecated
|
||||
public interface TouchableLine extends HologramLine {
|
||||
|
||||
@Deprecated
|
||||
public void setTouchHandler(TouchHandler touchHandler);
|
||||
|
||||
@Deprecated
|
||||
public TouchHandler getTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public void setTouchHandler(TouchHandler touchHandler);
|
||||
|
||||
@Deprecated
|
||||
public TouchHandler getTouchHandler();
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package com.gmail.filoghost.holographicdisplays.api.placeholder;
|
|||
@Deprecated
|
||||
public interface PlaceholderReplacer {
|
||||
|
||||
@Deprecated
|
||||
public String update();
|
||||
|
||||
@Deprecated
|
||||
public String update();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
<?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"
|
||||
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>
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
<name>HolographicDisplays NMS Interfaces</name>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
<name>HolographicDisplays NMS Interfaces</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -17,19 +17,19 @@ package me.filoghost.holographicdisplays.nms.interfaces;
|
|||
import java.util.List;
|
||||
|
||||
public interface ChatComponentAdapter<T> {
|
||||
|
||||
T cast(Object chatComponentObject);
|
||||
|
||||
String getText(T chatComponent);
|
||||
|
||||
List<T> getSiblings(T chatComponent);
|
||||
|
||||
void addSibling(T chatComponent, T newSibling);
|
||||
|
||||
default T cloneComponent(T chatComponent) {
|
||||
return cloneComponent(chatComponent, getText(chatComponent));
|
||||
}
|
||||
|
||||
T cloneComponent(T chatComponent, String newText);
|
||||
|
||||
}
|
||||
|
||||
T cast(Object chatComponentObject);
|
||||
|
||||
String getText(T chatComponent);
|
||||
|
||||
List<T> getSiblings(T chatComponent);
|
||||
|
||||
void addSibling(T chatComponent, T newSibling);
|
||||
|
||||
default T cloneComponent(T chatComponent) {
|
||||
return cloneComponent(chatComponent, getText(chatComponent));
|
||||
}
|
||||
|
||||
T cloneComponent(T chatComponent, String newText);
|
||||
|
||||
}
|
||||
|
|
|
@ -17,64 +17,64 @@ package me.filoghost.holographicdisplays.nms.interfaces;
|
|||
import java.util.List;
|
||||
|
||||
public class CustomNameHelper {
|
||||
|
||||
|
||||
public static String replaceCustomNameString(Object customNameObject, String target, String replacement) {
|
||||
String customName = (String) customNameObject;
|
||||
if (customName.contains(target)) {
|
||||
return customName.replace(target, replacement);
|
||||
} else {
|
||||
return customName;
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
T rootComponent = versionAdapter.cast(customNameObject);
|
||||
if (!versionAdapter.getText(rootComponent).isEmpty()) {
|
||||
throw new IllegalArgumentException("Expected root component with empty text");
|
||||
}
|
||||
|
||||
boolean[] childrenContainingTarget = null;
|
||||
List<T> children = versionAdapter.getSiblings(rootComponent);
|
||||
int childrenSize = children.size();
|
||||
|
||||
for (int i = 0; i < childrenSize; i++) {
|
||||
T childComponent = versionAdapter.cast(children.get(i));
|
||||
|
||||
|
||||
public static String replaceCustomNameString(Object customNameObject, String target, String replacement) {
|
||||
String customName = (String) customNameObject;
|
||||
if (customName.contains(target)) {
|
||||
return customName.replace(target, replacement);
|
||||
} else {
|
||||
return customName;
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
T rootComponent = versionAdapter.cast(customNameObject);
|
||||
if (!versionAdapter.getText(rootComponent).isEmpty()) {
|
||||
throw new IllegalArgumentException("Expected root component with empty text");
|
||||
}
|
||||
|
||||
boolean[] childrenContainingTarget = null;
|
||||
List<T> children = versionAdapter.getSiblings(rootComponent);
|
||||
int childrenSize = children.size();
|
||||
|
||||
for (int i = 0; i < childrenSize; i++) {
|
||||
T childComponent = versionAdapter.cast(children.get(i));
|
||||
|
||||
if (!versionAdapter.getSiblings(childComponent).isEmpty()) {
|
||||
throw new IllegalArgumentException("Expected child component without sub-nodes");
|
||||
}
|
||||
|
||||
if (versionAdapter.getText(childComponent).contains(target)) {
|
||||
// Lazy initialization for performance, since this method can be called frequently.
|
||||
if (childrenContainingTarget == null) {
|
||||
childrenContainingTarget = new boolean[childrenSize];
|
||||
}
|
||||
childrenContainingTarget[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (childrenContainingTarget == null) {
|
||||
// No match found, return original unmodified object.
|
||||
return rootComponent;
|
||||
}
|
||||
|
||||
// Clone all the objects and apply replacements where needed.
|
||||
T clonedRoot = versionAdapter.cloneComponent(rootComponent);
|
||||
for (int i = 0; i < childrenSize; i++) {
|
||||
T childComponent = children.get(i);
|
||||
|
||||
String newText = versionAdapter.getText(childComponent);
|
||||
if (childrenContainingTarget[i]) {
|
||||
newText = newText.replace(target, replacement);
|
||||
}
|
||||
|
||||
T clonedChild = versionAdapter.cloneComponent(childComponent, newText);
|
||||
versionAdapter.addSibling(clonedRoot, clonedChild);
|
||||
}
|
||||
|
||||
return clonedRoot;
|
||||
}
|
||||
if (!versionAdapter.getSiblings(childComponent).isEmpty()) {
|
||||
throw new IllegalArgumentException("Expected child component without sub-nodes");
|
||||
}
|
||||
|
||||
if (versionAdapter.getText(childComponent).contains(target)) {
|
||||
// Lazy initialization for performance, since this method can be called frequently.
|
||||
if (childrenContainingTarget == null) {
|
||||
childrenContainingTarget = new boolean[childrenSize];
|
||||
}
|
||||
childrenContainingTarget[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (childrenContainingTarget == null) {
|
||||
// No match found, return original unmodified object.
|
||||
return rootComponent;
|
||||
}
|
||||
|
||||
// Clone all the objects and apply replacements where needed.
|
||||
T clonedRoot = versionAdapter.cloneComponent(rootComponent);
|
||||
for (int i = 0; i < childrenSize; i++) {
|
||||
T childComponent = children.get(i);
|
||||
|
||||
String newText = versionAdapter.getText(childComponent);
|
||||
if (childrenContainingTarget[i]) {
|
||||
newText = newText.replace(target, replacement);
|
||||
}
|
||||
|
||||
T clonedChild = versionAdapter.cloneComponent(childComponent, newText);
|
||||
versionAdapter.addSibling(clonedRoot, clonedChild);
|
||||
}
|
||||
|
||||
return clonedRoot;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ import org.bukkit.entity.Player;
|
|||
|
||||
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;
|
||||
|
||||
public interface NMSManager {
|
||||
|
||||
// A method to register all the custom entities of the plugin, it may fail.
|
||||
public void setup() throws Exception;
|
||||
|
||||
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 NMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece);
|
||||
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity);
|
||||
|
||||
// A method to register all the custom entities of the plugin, it may fail.
|
||||
public void setup() throws Exception;
|
||||
|
||||
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 NMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece);
|
||||
|
||||
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;
|
||||
|
||||
public interface NMSArmorStand extends NMSNameable {
|
||||
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
package me.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||
|
||||
public interface NMSCanMount extends NMSEntityBase {
|
||||
|
||||
// Sets the passenger of this entity through NMS.
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase);
|
||||
|
||||
|
||||
// Sets the passenger of this entity through NMS.
|
||||
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.
|
||||
*/
|
||||
public interface NMSEntityBase {
|
||||
|
||||
// Returns the linked CraftHologramLine, all the entities are part of a piece. Should never be null.
|
||||
public HologramLine getHologramLine();
|
||||
|
||||
// Returns if the entity is dead through NMS.
|
||||
public boolean isDeadNMS();
|
||||
|
||||
// Kills the entity through NMS.
|
||||
public void killEntityNMS();
|
||||
|
||||
// The entity ID.
|
||||
public int getIdNMS();
|
||||
|
||||
// Returns the bukkit entity.
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS();
|
||||
|
||||
// Returns the linked CraftHologramLine, all the entities are part of a piece. Should never be null.
|
||||
public HologramLine getHologramLine();
|
||||
|
||||
// Returns if the entity is dead through NMS.
|
||||
public boolean isDeadNMS();
|
||||
|
||||
// Kills the entity through NMS.
|
||||
public void killEntityNMS();
|
||||
|
||||
// The entity ID.
|
||||
public int getIdNMS();
|
||||
|
||||
// Returns the bukkit entity.
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS();
|
||||
|
||||
}
|
||||
|
|
|
@ -17,17 +17,17 @@ package me.filoghost.holographicdisplays.nms.interfaces.entity;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface NMSItem extends NMSEntityBase, NMSCanMount {
|
||||
|
||||
// Sets the location through NMS.
|
||||
public void setLocationNMS(double x, double y, double z);
|
||||
|
||||
// Sets the bukkit ItemStack for this item.
|
||||
public void setItemStackNMS(ItemStack stack);
|
||||
|
||||
// Sets if this item can be picked up by players.
|
||||
public void allowPickup(boolean pickup);
|
||||
|
||||
// The raw NMS ItemStack object.
|
||||
public Object getRawItemStack();
|
||||
|
||||
|
||||
// Sets the location through NMS.
|
||||
public void setLocationNMS(double x, double y, double z);
|
||||
|
||||
// Sets the bukkit ItemStack for this item.
|
||||
public void setItemStackNMS(ItemStack stack);
|
||||
|
||||
// Sets if this item can be picked up by players.
|
||||
public void allowPickup(boolean pickup);
|
||||
|
||||
// The raw NMS ItemStack object.
|
||||
public Object getRawItemStack();
|
||||
|
||||
}
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
package me.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||
|
||||
public interface NMSNameable extends NMSEntityBase {
|
||||
|
||||
// Sets a custom name as a String.
|
||||
public void setCustomNameNMS(String name);
|
||||
|
||||
// Returns the custom name as a String.
|
||||
public String getCustomNameStringNMS();
|
||||
|
||||
// Sets a custom name as a String.
|
||||
public void setCustomNameNMS(String name);
|
||||
|
||||
// Returns the custom name as a String.
|
||||
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).
|
||||
public Object getCustomNameObjectNMS();
|
||||
|
||||
// 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();
|
||||
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
package me.filoghost.holographicdisplays.nms.interfaces.entity;
|
||||
|
||||
public interface NMSSlime extends NMSEntityBase, NMSCanMount {
|
||||
|
||||
// Sets the location through NMS.
|
||||
public void setLocationNMS(double x, double y, double z);
|
||||
|
||||
|
||||
// Sets the location through NMS.
|
||||
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"?>
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<name>HolographicDisplays NMS</name>
|
||||
<packaging>pom</packaging>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<name>HolographicDisplays NMS</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>interfaces</module>
|
||||
<module>v1_8_r2</module>
|
||||
<module>v1_8_r3</module>
|
||||
<module>v1_9_r1</module>
|
||||
<module>v1_9_r2</module>
|
||||
<module>v1_10_r1</module>
|
||||
<module>v1_11_r1</module>
|
||||
<module>v1_12_r1</module>
|
||||
<module>v1_13_r1</module>
|
||||
<module>v1_13_r2</module>
|
||||
<module>v1_14_r1</module>
|
||||
<module>v1_15_r1</module>
|
||||
<module>v1_16_r1</module>
|
||||
<module>v1_16_r2</module>
|
||||
<module>v1_16_r3</module>
|
||||
</modules>
|
||||
<modules>
|
||||
<module>interfaces</module>
|
||||
<module>v1_8_r2</module>
|
||||
<module>v1_8_r3</module>
|
||||
<module>v1_9_r1</module>
|
||||
<module>v1_9_r2</module>
|
||||
<module>v1_10_r1</module>
|
||||
<module>v1_11_r1</module>
|
||||
<module>v1_12_r1</module>
|
||||
<module>v1_13_r1</module>
|
||||
<module>v1_13_r2</module>
|
||||
<module>v1_14_r1</module>
|
||||
<module>v1_15_r1</module>
|
||||
<module>v1_16_r1</module>
|
||||
<module>v1_16_r2</module>
|
||||
<module>v1_16_r3</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -1,41 +1,41 @@
|
|||
<?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"
|
||||
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>
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-v1_10_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_10_R1</name>
|
||||
<artifactId>holographicdisplays-nms-v1_10_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_10_R1</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.io/repository/nms/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.io/repository/nms/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -29,64 +29,64 @@ import java.util.Collection;
|
|||
|
||||
public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
|
||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Armor stand class
|
||||
@Override public void setArms(boolean arms) { }
|
||||
@Override public void setBasePlate(boolean basePlate) { }
|
||||
@Override public void setBodyPose(EulerAngle pose) { }
|
||||
@Override public void setBoots(ItemStack item) { }
|
||||
@Override public void setChestplate(ItemStack item) { }
|
||||
@Override public void setHeadPose(EulerAngle pose) { }
|
||||
@Override public void setHelmet(ItemStack item) { }
|
||||
@Override public void setItemInHand(ItemStack item) { }
|
||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||
@Override public void setLeggings(ItemStack item) { }
|
||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||
@Override public void setSmall(boolean small) { }
|
||||
@Override public void setVisible(boolean visible) { }
|
||||
@Override public void setMarker(boolean marker) { }
|
||||
// Methods from Armor stand class
|
||||
@Override public void setArms(boolean arms) { }
|
||||
@Override public void setBasePlate(boolean basePlate) { }
|
||||
@Override public void setBodyPose(EulerAngle pose) { }
|
||||
@Override public void setBoots(ItemStack item) { }
|
||||
@Override public void setChestplate(ItemStack item) { }
|
||||
@Override public void setHeadPose(EulerAngle pose) { }
|
||||
@Override public void setHelmet(ItemStack item) { }
|
||||
@Override public void setItemInHand(ItemStack item) { }
|
||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||
@Override public void setLeggings(ItemStack item) { }
|
||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||
@Override public void setSmall(boolean small) { }
|
||||
@Override public void setVisible(boolean visible) { }
|
||||
@Override public void setMarker(boolean marker) { }
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
}
|
||||
|
|
|
@ -25,39 +25,39 @@ import org.bukkit.util.Vector;
|
|||
|
||||
public class CraftNMSItem extends CraftItem {
|
||||
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
|
||||
}
|
||||
|
|
|
@ -27,49 +27,49 @@ import java.util.Collection;
|
|||
|
||||
public class CraftNMSSlime extends CraftSlime {
|
||||
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Slime
|
||||
@Override public void setSize(int size) { }
|
||||
|
||||
// Methods from Slime
|
||||
@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 {
|
||||
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
super.setArms(false);
|
||||
super.setNoGravity(true);
|
||||
super.setBasePlate(true);
|
||||
super.setMarker(true);
|
||||
super.collides = false;
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
|
||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
super.setArms(false);
|
||||
super.setNoGravity(true);
|
||||
super.setBasePlate(true);
|
||||
super.setMarker(true);
|
||||
super.collides = false;
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
|
||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, ItemStack itemstack, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, ItemStack itemstack, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean c(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameStringNMS() {
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomNameObjectNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||
super.setPosition(x, y, z);
|
||||
if (broadcastLocationPacket) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameStringNMS() {
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomNameObjectNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||
super.setPosition(x, y, z);
|
||||
if (broadcastLocationPacket) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,230 +41,230 @@ import org.bukkit.entity.Player;
|
|||
import java.util.logging.Level;
|
||||
|
||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||
|
||||
private ItemLine parentPiece;
|
||||
private ItemPickupManager itemPickupManager;
|
||||
|
||||
private int resendMountPacketTicks;
|
||||
|
||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||
super(world);
|
||||
super.pickupDelay = Integer.MAX_VALUE;
|
||||
this.parentPiece = piece;
|
||||
this.itemPickupManager = itemPickupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
|
||||
if (resendMountPacketTicks++ > 20) {
|
||||
resendMountPacketTicks = 0;
|
||||
|
||||
if (bB() != null) {
|
||||
// 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());
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
|
||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||
// Too low or too high, it's a bit weird.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||
|
||||
private ItemLine parentPiece;
|
||||
private ItemPickupManager itemPickupManager;
|
||||
|
||||
private int resendMountPacketTicks;
|
||||
|
||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||
super(world);
|
||||
super.pickupDelay = Integer.MAX_VALUE;
|
||||
this.parentPiece = piece;
|
||||
this.itemPickupManager = itemPickupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
|
||||
if (resendMountPacketTicks++ > 20) {
|
||||
resendMountPacketTicks = 0;
|
||||
|
||||
if (bB() != null) {
|
||||
// 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());
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
|
||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||
// Too low or too high, it's a bit weird.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
// This override prevents items from being picked up by hoppers.
|
||||
// Should have no side effects.
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
// This override prevents items from being picked up by hoppers.
|
||||
// Should have no side effects.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
||||
ItemStack newItem = CraftItemStack.asNMSCopy(stack);
|
||||
|
||||
if (newItem == null) {
|
||||
newItem = new ItemStack(Blocks.BEDROCK);
|
||||
}
|
||||
|
||||
if (newItem.getTag() == null) {
|
||||
newItem.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display");
|
||||
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
display.set("Lore", tagList);
|
||||
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
@Override
|
||||
public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) {
|
||||
ItemStack newItem = CraftItemStack.asNMSCopy(stack);
|
||||
|
||||
if (newItem == null) {
|
||||
newItem = new ItemStack(Blocks.BEDROCK);
|
||||
}
|
||||
|
||||
if (newItem.getTag() == null) {
|
||||
newItem.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display");
|
||||
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
display.set("Lore", tagList);
|
||||
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bB() != null) {
|
||||
Entity oldVehicle = super.bB();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
try {
|
||||
if (super.bB() != null) {
|
||||
Entity oldVehicle = super.bB();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,208 +37,208 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
|||
import java.util.logging.Level;
|
||||
|
||||
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 int resendMountPacketTicks;
|
||||
|
||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
|
||||
if (resendMountPacketTicks++ > 20) {
|
||||
resendMountPacketTicks = 0;
|
||||
private HologramLine parentPiece;
|
||||
|
||||
private int resendMountPacketTicks;
|
||||
|
||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
|
||||
if (resendMountPacketTicks++ > 20) {
|
||||
resendMountPacketTicks = 0;
|
||||
|
||||
if (bB() != null) {
|
||||
// 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());
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
if (bB() != null) {
|
||||
// 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());
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bB() != null) {
|
||||
Entity oldVehicle = super.bB();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bB() != null) {
|
||||
Entity oldVehicle = super.bB();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,69 +39,69 @@ import java.lang.reflect.Method;
|
|||
import java.util.Map;
|
||||
|
||||
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<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
|
||||
|
||||
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 Method validateEntityMethod;
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
registerCustomEntity(EntityNMSArmorStand.class, "ArmorStand", 30);
|
||||
registerCustomEntity(EntityNMSItem.class, "Item", 1);
|
||||
registerCustomEntity(EntityNMSSlime.class, "Slime", 55);
|
||||
|
||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||
validateEntityMethod.setAccessible(true);
|
||||
}
|
||||
|
||||
public void registerCustomEntity(Class<?> entityClass, String name, int id) throws Exception {
|
||||
ENTITY_NAMES_BY_CLASS_FIELD.getStatic().put(entityClass, name);
|
||||
ENTITY_IDS_BY_CLASS_FIELD.getStatic().put(entityClass, Integer.valueOf(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||
customItem.setLocationNMS(x, y, z);
|
||||
customItem.setItemStackNMS(stack);
|
||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return customItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||
touchSlime.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return touchSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||
|
||||
private Method validateEntityMethod;
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
registerCustomEntity(EntityNMSArmorStand.class, "ArmorStand", 30);
|
||||
registerCustomEntity(EntityNMSItem.class, "Item", 1);
|
||||
registerCustomEntity(EntityNMSSlime.class, "Slime", 55);
|
||||
|
||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||
validateEntityMethod.setAccessible(true);
|
||||
}
|
||||
|
||||
public void registerCustomEntity(Class<?> entityClass, String name, int id) throws Exception {
|
||||
ENTITY_NAMES_BY_CLASS_FIELD.getStatic().put(entityClass, name);
|
||||
ENTITY_IDS_BY_CLASS_FIELD.getStatic().put(entityClass, Integer.valueOf(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||
customItem.setLocationNMS(x, y, z);
|
||||
customItem.setItemStackNMS(stack);
|
||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return customItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||
touchSlime.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return touchSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||
|
||||
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
||||
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
||||
|
||||
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
||||
// This should never happen
|
||||
// This should never happen
|
||||
nmsEntity.dead = true;
|
||||
return false;
|
||||
}
|
||||
|
@ -110,45 +110,45 @@ public class NmsManagerImpl implements NMSManager {
|
|||
nmsWorld.entityList.add(nmsEntity);
|
||||
|
||||
try {
|
||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
||||
return CustomNameHelper.replaceCustomNameString(customNameObject, target, replacement);
|
||||
}
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object replaceCustomNameText(Object customNameObject, String target, String 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 NullBoundingBox() {
|
||||
super(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
public NullBoundingBox() {
|
||||
super(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a() {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double a() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double a(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean a(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double b(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double b(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean b(AxisAlignedBB arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean b(AxisAlignedBB arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double c(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double c(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB c(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB c(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB shrink(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(BlockPosition arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB shrink(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(BlockPosition arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean b(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean b(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean c(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean d(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB e(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB g(double arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB e(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB g(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,41 +1,41 @@
|
|||
<?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"
|
||||
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>
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-v1_11_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_11_R1</name>
|
||||
<artifactId>holographicdisplays-nms-v1_11_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_11_R1</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.io/repository/nms/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.io/repository/nms/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.11-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.11-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -29,64 +29,64 @@ import java.util.Collection;
|
|||
|
||||
public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
|
||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Armor stand class
|
||||
@Override public void setArms(boolean arms) { }
|
||||
@Override public void setBasePlate(boolean basePlate) { }
|
||||
@Override public void setBodyPose(EulerAngle pose) { }
|
||||
@Override public void setBoots(ItemStack item) { }
|
||||
@Override public void setChestplate(ItemStack item) { }
|
||||
@Override public void setHeadPose(EulerAngle pose) { }
|
||||
@Override public void setHelmet(ItemStack item) { }
|
||||
@Override public void setItemInHand(ItemStack item) { }
|
||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||
@Override public void setLeggings(ItemStack item) { }
|
||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||
@Override public void setSmall(boolean small) { }
|
||||
@Override public void setVisible(boolean visible) { }
|
||||
@Override public void setMarker(boolean marker) { }
|
||||
// Methods from Armor stand class
|
||||
@Override public void setArms(boolean arms) { }
|
||||
@Override public void setBasePlate(boolean basePlate) { }
|
||||
@Override public void setBodyPose(EulerAngle pose) { }
|
||||
@Override public void setBoots(ItemStack item) { }
|
||||
@Override public void setChestplate(ItemStack item) { }
|
||||
@Override public void setHeadPose(EulerAngle pose) { }
|
||||
@Override public void setHelmet(ItemStack item) { }
|
||||
@Override public void setItemInHand(ItemStack item) { }
|
||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||
@Override public void setLeggings(ItemStack item) { }
|
||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||
@Override public void setSmall(boolean small) { }
|
||||
@Override public void setVisible(boolean visible) { }
|
||||
@Override public void setMarker(boolean marker) { }
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
}
|
||||
|
|
|
@ -25,39 +25,39 @@ import org.bukkit.util.Vector;
|
|||
|
||||
public class CraftNMSItem extends CraftItem {
|
||||
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
|
||||
}
|
||||
|
|
|
@ -27,49 +27,49 @@ import java.util.Collection;
|
|||
|
||||
public class CraftNMSSlime extends CraftSlime {
|
||||
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Slime
|
||||
@Override public void setSize(int size) { }
|
||||
|
||||
// Methods from Slime
|
||||
@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 {
|
||||
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
super.setArms(false);
|
||||
super.setNoGravity(true);
|
||||
super.setBasePlate(true);
|
||||
super.setMarker(true);
|
||||
super.collides = false;
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
|
||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void A_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
super.setArms(false);
|
||||
super.setNoGravity(true);
|
||||
super.setBasePlate(true);
|
||||
super.setMarker(true);
|
||||
super.collides = false;
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
|
||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void A_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean c(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameStringNMS() {
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomNameObjectNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||
super.setPosition(x, y, z);
|
||||
if (broadcastLocationPacket) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameStringNMS() {
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomNameObjectNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||
super.setPosition(x, y, z);
|
||||
if (broadcastLocationPacket) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,207 +39,207 @@ import org.bukkit.entity.Player;
|
|||
import java.util.logging.Level;
|
||||
|
||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||
|
||||
private ItemLine parentPiece;
|
||||
private ItemPickupManager itemPickupManager;
|
||||
|
||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||
super(world);
|
||||
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
||||
this.parentPiece = piece;
|
||||
this.itemPickupManager = itemPickupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void A_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
|
||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||
// Too low or too high, it's a bit weird.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||
|
||||
private ItemLine parentPiece;
|
||||
private ItemPickupManager itemPickupManager;
|
||||
|
||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||
super(world);
|
||||
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
||||
this.parentPiece = piece;
|
||||
this.itemPickupManager = itemPickupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void A_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
|
||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||
// Too low or too high, it's a bit weird.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
// This override prevents items from being picked up by hoppers.
|
||||
// Should have no side effects.
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
// This override prevents items from being picked up by hoppers.
|
||||
// Should have no side effects.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public 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
|
||||
|
||||
if (newItem == null || newItem == ItemStack.a) {
|
||||
newItem = new ItemStack(Blocks.BEDROCK);
|
||||
}
|
||||
@Override
|
||||
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
|
||||
|
||||
if (newItem == null || newItem == ItemStack.a) {
|
||||
newItem = new ItemStack(Blocks.BEDROCK);
|
||||
}
|
||||
|
||||
if (newItem.getTag() == null) {
|
||||
newItem.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
if (newItem.getTag() == null) {
|
||||
newItem.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
display.set("Lore", tagList);
|
||||
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = 32767;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
display.set("Lore", tagList);
|
||||
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = 32767;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bB() != null) {
|
||||
Entity oldVehicle = super.bB();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
try {
|
||||
if (super.bB() != null) {
|
||||
Entity oldVehicle = super.bB();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,186 +35,186 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
|||
import java.util.logging.Level;
|
||||
|
||||
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;
|
||||
|
||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1, false);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void A_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
private HologramLine parentPiece;
|
||||
|
||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1, false);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void A_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bB() != null) {
|
||||
Entity oldVehicle = super.bB();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bB() != null) {
|
||||
Entity oldVehicle = super.bB();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,77 +40,77 @@ import org.bukkit.inventory.ItemStack;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
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<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
|
||||
|
||||
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 Method validateEntityMethod;
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||
validateEntityMethod.setAccessible(true);
|
||||
|
||||
registerCustomEntity(EntityNMSSlime.class, 55);
|
||||
}
|
||||
|
||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||
// Use reflection to get the RegistryID of entities.
|
||||
RegistryID<Class<? extends Entity>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b);
|
||||
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
||||
|
||||
// Save the the ID -> entity class mapping before the registration.
|
||||
Object oldValue = idToClassMap[id];
|
||||
private Method validateEntityMethod;
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||
validateEntityMethod.setAccessible(true);
|
||||
|
||||
registerCustomEntity(EntityNMSSlime.class, 55);
|
||||
}
|
||||
|
||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||
// Use reflection to get the RegistryID of entities.
|
||||
RegistryID<Class<? extends Entity>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b);
|
||||
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
||||
|
||||
// Save the the ID -> entity class mapping before the registration.
|
||||
Object oldValue = idToClassMap[id];
|
||||
|
||||
// Register the entity class.
|
||||
registryID.a(entityClass, id);
|
||||
// Register the entity class.
|
||||
registryID.a(entityClass, id);
|
||||
|
||||
// Restore the ID -> entity class mapping.
|
||||
idToClassMap[id] = oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||
customItem.setLocationNMS(x, y, z);
|
||||
customItem.setItemStackNMS(stack);
|
||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return customItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||
touchSlime.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return touchSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||
|
||||
// Restore the ID -> entity class mapping.
|
||||
idToClassMap[id] = oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||
customItem.setLocationNMS(x, y, z);
|
||||
customItem.setItemStackNMS(stack);
|
||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return customItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||
touchSlime.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return touchSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||
|
||||
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
||||
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
||||
|
||||
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
||||
// This should never happen
|
||||
// This should never happen
|
||||
nmsEntity.dead = true;
|
||||
return false;
|
||||
}
|
||||
|
@ -119,45 +119,45 @@ public class NmsManagerImpl implements NMSManager {
|
|||
nmsWorld.entityList.add(nmsEntity);
|
||||
|
||||
try {
|
||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
||||
return CustomNameHelper.replaceCustomNameString(customNameObject, target, replacement);
|
||||
}
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object replaceCustomNameText(Object customNameObject, String target, String 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 NullBoundingBox() {
|
||||
super(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
public NullBoundingBox() {
|
||||
super(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a() {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double a() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double a(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double b(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double b(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double c(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double c(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB shrink(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(BlockPosition arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB shrink(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(BlockPosition arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean b(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean b(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean c(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean d(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB e(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB g(double arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB e(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB g(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(Vec3D arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB a(Vec3D arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(AxisAlignedBB arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean c(AxisAlignedBB arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean e(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean e(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,41 +1,41 @@
|
|||
<?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"
|
||||
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>
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-v1_12_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_12_R1</name>
|
||||
<artifactId>holographicdisplays-nms-v1_12_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_12_R1</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.io/repository/nms/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.io/repository/nms/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -29,65 +29,65 @@ import java.util.Collection;
|
|||
|
||||
public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
|
||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Armor stand class
|
||||
|
||||
@Override public void setArms(boolean arms) { }
|
||||
@Override public void setBasePlate(boolean basePlate) { }
|
||||
@Override public void setBodyPose(EulerAngle pose) { }
|
||||
@Override public void setBoots(ItemStack item) { }
|
||||
@Override public void setChestplate(ItemStack item) { }
|
||||
@Override public void setHeadPose(EulerAngle pose) { }
|
||||
@Override public void setHelmet(ItemStack item) { }
|
||||
@Override public void setItemInHand(ItemStack item) { }
|
||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||
@Override public void setLeggings(ItemStack item) { }
|
||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||
@Override public void setSmall(boolean small) { }
|
||||
@Override public void setVisible(boolean visible) { }
|
||||
@Override public void setMarker(boolean marker) { }
|
||||
// Methods from Armor stand class
|
||||
|
||||
@Override public void setArms(boolean arms) { }
|
||||
@Override public void setBasePlate(boolean basePlate) { }
|
||||
@Override public void setBodyPose(EulerAngle pose) { }
|
||||
@Override public void setBoots(ItemStack item) { }
|
||||
@Override public void setChestplate(ItemStack item) { }
|
||||
@Override public void setHeadPose(EulerAngle pose) { }
|
||||
@Override public void setHelmet(ItemStack item) { }
|
||||
@Override public void setItemInHand(ItemStack item) { }
|
||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||
@Override public void setLeggings(ItemStack item) { }
|
||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||
@Override public void setSmall(boolean small) { }
|
||||
@Override public void setVisible(boolean visible) { }
|
||||
@Override public void setMarker(boolean marker) { }
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
}
|
||||
|
|
|
@ -25,39 +25,39 @@ import org.bukkit.util.Vector;
|
|||
|
||||
public class CraftNMSItem extends CraftItem {
|
||||
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
|
||||
}
|
||||
|
|
|
@ -27,49 +27,49 @@ import java.util.Collection;
|
|||
|
||||
public class CraftNMSSlime extends CraftSlime {
|
||||
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Slime
|
||||
@Override public void setSize(int size) { }
|
||||
|
||||
// Methods from Slime
|
||||
@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 {
|
||||
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
super.setArms(false);
|
||||
super.setNoGravity(true);
|
||||
super.setBasePlate(true);
|
||||
super.setMarker(true);
|
||||
super.collides = false;
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
|
||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void B_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
super.setArms(false);
|
||||
super.setNoGravity(true);
|
||||
super.setBasePlate(true);
|
||||
super.setMarker(true);
|
||||
super.collides = false;
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
|
||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void B_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean c(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameStringNMS() {
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomNameObjectNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||
super.setPosition(x, y, z);
|
||||
if (broadcastLocationPacket) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(customName);
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameStringNMS() {
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomNameObjectNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||
super.setPosition(x, y, z);
|
||||
if (broadcastLocationPacket) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,207 +39,207 @@ import org.bukkit.entity.Player;
|
|||
import java.util.logging.Level;
|
||||
|
||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||
|
||||
private ItemLine parentPiece;
|
||||
private ItemPickupManager itemPickupManager;
|
||||
|
||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||
super(world);
|
||||
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
||||
this.parentPiece = piece;
|
||||
this.itemPickupManager = itemPickupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void B_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
|
||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||
// Too low or too high, it's a bit weird.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
|
||||
|
||||
private ItemLine parentPiece;
|
||||
private ItemPickupManager itemPickupManager;
|
||||
|
||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||
super(world);
|
||||
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
||||
this.parentPiece = piece;
|
||||
this.itemPickupManager = itemPickupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void B_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
|
||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||
// Too low or too high, it's a bit weird.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
// This override prevents items from being picked up by hoppers.
|
||||
// Should have no side effects.
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
// This override prevents items from being picked up by hoppers.
|
||||
// Should have no side effects.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public 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
|
||||
|
||||
if (newItem == null || newItem == ItemStack.a) {
|
||||
newItem = new ItemStack(Blocks.BEDROCK);
|
||||
}
|
||||
@Override
|
||||
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
|
||||
|
||||
if (newItem == null || newItem == ItemStack.a) {
|
||||
newItem = new ItemStack(Blocks.BEDROCK);
|
||||
}
|
||||
|
||||
if (newItem.getTag() == null) {
|
||||
newItem.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
if (newItem.getTag() == null) {
|
||||
newItem.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
display.set("Lore", tagList);
|
||||
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = 32767;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
display.set("Lore", tagList);
|
||||
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = 32767;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bJ() != null) {
|
||||
Entity oldVehicle = super.bJ();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
try {
|
||||
if (super.bJ() != null) {
|
||||
Entity oldVehicle = super.bJ();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,186 +35,186 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
|||
import java.util.logging.Level;
|
||||
|
||||
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;
|
||||
|
||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1, false);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void B_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
private HologramLine parentPiece;
|
||||
|
||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1, false);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void B_() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
@Override
|
||||
public void setCustomName(String customName) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bJ() != null) {
|
||||
Entity oldVehicle = super.bJ();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.bJ() != null) {
|
||||
Entity oldVehicle = super.bJ();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,77 +40,77 @@ import org.bukkit.inventory.ItemStack;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
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<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
|
||||
|
||||
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 Method validateEntityMethod;
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||
validateEntityMethod.setAccessible(true);
|
||||
|
||||
registerCustomEntity(EntityNMSSlime.class, 55);
|
||||
}
|
||||
|
||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||
// Use reflection to get the RegistryID of entities.
|
||||
RegistryID<Class<? extends Entity>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b);
|
||||
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
||||
|
||||
// Save the the ID -> entity class mapping before the registration.
|
||||
Object oldValue = idToClassMap[id];
|
||||
private Method validateEntityMethod;
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||
validateEntityMethod.setAccessible(true);
|
||||
|
||||
registerCustomEntity(EntityNMSSlime.class, 55);
|
||||
}
|
||||
|
||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||
// Use reflection to get the RegistryID of entities.
|
||||
RegistryID<Class<? extends Entity>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b);
|
||||
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
||||
|
||||
// Save the the ID -> entity class mapping before the registration.
|
||||
Object oldValue = idToClassMap[id];
|
||||
|
||||
// Register the entity class.
|
||||
registryID.a(entityClass, id);
|
||||
// Register the entity class.
|
||||
registryID.a(entityClass, id);
|
||||
|
||||
// Restore the ID -> entity class mapping.
|
||||
idToClassMap[id] = oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||
customItem.setLocationNMS(x, y, z);
|
||||
customItem.setItemStackNMS(stack);
|
||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return customItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||
touchSlime.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return touchSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||
|
||||
// Restore the ID -> entity class mapping.
|
||||
idToClassMap[id] = oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||
customItem.setLocationNMS(x, y, z);
|
||||
customItem.setItemStackNMS(stack);
|
||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return customItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||
touchSlime.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return touchSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||
|
||||
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
||||
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
||||
|
||||
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
||||
// This should never happen
|
||||
// This should never happen
|
||||
nmsEntity.dead = true;
|
||||
return false;
|
||||
}
|
||||
|
@ -119,45 +119,45 @@ public class NmsManagerImpl implements NMSManager {
|
|||
nmsWorld.entityList.add(nmsEntity);
|
||||
|
||||
try {
|
||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
||||
return CustomNameHelper.replaceCustomNameString(customNameObject, target, replacement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object replaceCustomNameText(Object customNameObject, String target, String 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 NullBoundingBox() {
|
||||
super(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
public NullBoundingBox() {
|
||||
super(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a() {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double a() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double a(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double b(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double b(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double c(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double c(AxisAlignedBB arg0, double arg1) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB shrink(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(BlockPosition arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB shrink(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(BlockPosition arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean b(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean b(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean c(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean d(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB e(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB g(double arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB e(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB g(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(Vec3D arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB a(Vec3D arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(AxisAlignedBB arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean c(AxisAlignedBB arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean e(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean e(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,41 +1,41 @@
|
|||
<?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"
|
||||
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>
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-nms</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-nms-v1_13_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_13_R1</name>
|
||||
<artifactId>holographicdisplays-nms-v1_13_r1</artifactId>
|
||||
<name>HolographicDisplays NMS v1_13_R1</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.io/repository/nms/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.io/repository/nms/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-nms-interfaces</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -29,67 +29,67 @@ import java.util.Collection;
|
|||
|
||||
public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
|
||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Armor stand class
|
||||
|
||||
@Override public void setArms(boolean arms) { }
|
||||
@Override public void setBasePlate(boolean basePlate) { }
|
||||
@Override public void setBodyPose(EulerAngle pose) { }
|
||||
@Override public void setBoots(ItemStack item) { }
|
||||
@Override public void setChestplate(ItemStack item) { }
|
||||
@Override public void setHeadPose(EulerAngle pose) { }
|
||||
@Override public void setHelmet(ItemStack item) { }
|
||||
@Override public void setItemInHand(ItemStack item) { }
|
||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||
@Override public void setLeggings(ItemStack item) { }
|
||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||
@Override public void setSmall(boolean small) { }
|
||||
@Override public void setVisible(boolean visible) { }
|
||||
@Override public void setMarker(boolean marker) { }
|
||||
// Methods from Armor stand class
|
||||
|
||||
@Override public void setArms(boolean arms) { }
|
||||
@Override public void setBasePlate(boolean basePlate) { }
|
||||
@Override public void setBodyPose(EulerAngle pose) { }
|
||||
@Override public void setBoots(ItemStack item) { }
|
||||
@Override public void setChestplate(ItemStack item) { }
|
||||
@Override public void setHeadPose(EulerAngle pose) { }
|
||||
@Override public void setHelmet(ItemStack item) { }
|
||||
@Override public void setItemInHand(ItemStack item) { }
|
||||
@Override public void setLeftArmPose(EulerAngle pose) { }
|
||||
@Override public void setLeftLegPose(EulerAngle pose) { }
|
||||
@Override public void setLeggings(ItemStack item) { }
|
||||
@Override public void setRightArmPose(EulerAngle pose) { }
|
||||
@Override public void setRightLegPose(EulerAngle pose) { }
|
||||
@Override public void setSmall(boolean small) { }
|
||||
@Override public void setVisible(boolean visible) { }
|
||||
@Override public void setMarker(boolean marker) { }
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -25,39 +25,39 @@ import org.bukkit.util.Vector;
|
|||
|
||||
public class CraftNMSItem extends CraftItem {
|
||||
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
public CraftNMSItem(CraftServer server, EntityNMSItem entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Item
|
||||
@Override public void setItemStack(ItemStack stack) { }
|
||||
@Override public void setPickupDelay(int delay) { }
|
||||
|
||||
}
|
||||
|
|
|
@ -28,52 +28,52 @@ import java.util.Collection;
|
|||
|
||||
public class CraftNMSSlime extends CraftSlime {
|
||||
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) { }
|
||||
public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
// Disallow all the bukkit methods.
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
// Cannot be removed, this is the most important to override.
|
||||
}
|
||||
|
||||
// Methods from LivingEntity class
|
||||
@Override public boolean addPotionEffect(PotionEffect effect) { return false; }
|
||||
@Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; }
|
||||
@Override public boolean addPotionEffects(Collection<PotionEffect> effects) { return false; }
|
||||
@Override public void setRemoveWhenFarAway(boolean remove) { }
|
||||
@Override public void setAI(boolean ai) { }
|
||||
@Override public void setCanPickupItems(boolean pickup) { }
|
||||
@Override public void setCollidable(boolean collidable) { }
|
||||
@Override public void setGliding(boolean gliding) { }
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
// Methods from Entity
|
||||
@Override public void setVelocity(Vector vel) { }
|
||||
@Override public boolean teleport(Location loc) { return false; }
|
||||
@Override public boolean teleport(Entity entity) { return false; }
|
||||
@Override public boolean teleport(Location loc, TeleportCause cause) { return false; }
|
||||
@Override public boolean teleport(Entity entity, TeleportCause cause) { return false; }
|
||||
@Override public void setFireTicks(int ticks) { }
|
||||
@Override public boolean setPassenger(Entity entity) { return false; }
|
||||
@Override public boolean eject() { return false; }
|
||||
@Override public boolean leaveVehicle() { return false; }
|
||||
@Override public void playEffect(EntityEffect effect) { }
|
||||
@Override public void setCustomName(String name) { }
|
||||
@Override public void setCustomNameVisible(boolean flag) { }
|
||||
@Override public void setGlowing(boolean flag) { }
|
||||
@Override public void setGravity(boolean gravity) { }
|
||||
@Override public void setInvulnerable(boolean flag) { }
|
||||
@Override public void setMomentum(Vector value) { }
|
||||
@Override public void setSilent(boolean flag) { }
|
||||
@Override public void setTicksLived(int value) { }
|
||||
|
||||
|
||||
// Methods from Slime
|
||||
@Override public void setSize(int size) { }
|
||||
@Override public void setTarget(LivingEntity target) { }
|
||||
|
||||
// Methods from Slime
|
||||
@Override public void setSize(int size) { }
|
||||
@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 {
|
||||
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
super.setArms(false);
|
||||
super.setNoGravity(true);
|
||||
super.setBasePlate(true);
|
||||
super.setMarker(true);
|
||||
super.collides = false;
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
|
||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
private HologramLine parentPiece;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
super.setArms(false);
|
||||
super.setNoGravity(true);
|
||||
super.setBasePlate(true);
|
||||
super.setMarker(true);
|
||||
super.collides = false;
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
|
||||
this.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean c(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(customName));
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameStringNMS() {
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomNameObjectNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||
super.setPosition(x, y, z);
|
||||
if (broadcastLocationPacket) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameNMS(String name) {
|
||||
this.customName = Utils.limitLength(name, 300);
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(customName));
|
||||
super.setCustomNameVisible(customName != null && !customName.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomNameStringNMS() {
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomNameObjectNMS() {
|
||||
return super.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z, boolean broadcastLocationPacket) {
|
||||
super.setPosition(x, y, z);
|
||||
if (broadcastLocationPacket) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (Object obj : super.world.players) {
|
||||
if (obj instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,207 +39,207 @@ import org.bukkit.entity.Player;
|
|||
import java.util.logging.Level;
|
||||
|
||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax");
|
||||
|
||||
private ItemLine parentPiece;
|
||||
private ItemPickupManager itemPickupManager;
|
||||
|
||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||
super(world);
|
||||
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
||||
this.parentPiece = piece;
|
||||
this.itemPickupManager = itemPickupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
|
||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||
// Too low or too high, it's a bit weird.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax");
|
||||
|
||||
private ItemLine parentPiece;
|
||||
private ItemPickupManager itemPickupManager;
|
||||
|
||||
public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) {
|
||||
super(world);
|
||||
super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item
|
||||
this.parentPiece = piece;
|
||||
this.itemPickupManager = itemPickupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
// Method called when a player is near.
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
|
||||
if (human.locY < super.locY - 1.5 || human.locY > super.locY + 1.0) {
|
||||
// Too low or too high, it's a bit weird.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) {
|
||||
itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece.getPickupHandler(), parentPiece.getParent());
|
||||
// It is never added to the inventory.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
// This override prevents items from being picked up by hoppers.
|
||||
// Should have no side effects.
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
// This override prevents items from being picked up by hoppers.
|
||||
// Should have no side effects.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSItem(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public 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
|
||||
|
||||
if (newItem == null || newItem == ItemStack.a) {
|
||||
newItem = new ItemStack(Blocks.BEDROCK);
|
||||
}
|
||||
@Override
|
||||
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
|
||||
|
||||
if (newItem == null || newItem == ItemStack.a) {
|
||||
newItem = new ItemStack(Blocks.BEDROCK);
|
||||
}
|
||||
|
||||
if (newItem.getTag() == null) {
|
||||
newItem.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
if (newItem.getTag() == null) {
|
||||
newItem.setTag(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
display.set("Lore", tagList);
|
||||
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = 32767;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore
|
||||
display.set("Lore", tagList);
|
||||
|
||||
setItemStack(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowPickup(boolean pickup) {
|
||||
if (pickup) {
|
||||
super.pickupDelay = 0;
|
||||
} else {
|
||||
super.pickupDelay = 32767;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.getVehicle() != null) {
|
||||
Entity oldVehicle = super.getVehicle();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
try {
|
||||
if (super.getVehicle() != null) {
|
||||
Entity oldVehicle = super.getVehicle();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
@Override
|
||||
public Object getRawItemStack() {
|
||||
return super.getItemStack();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,186 +36,186 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
|||
import java.util.logging.Level;
|
||||
|
||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax");
|
||||
|
||||
private HologramLine parentPiece;
|
||||
|
||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1, false);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax");
|
||||
|
||||
private HologramLine parentPiece;
|
||||
|
||||
public EntityNMSSlime(World world, HologramLine parentPiece) {
|
||||
super(world);
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
a(0.0F, 0.0F);
|
||||
setSize(1, false);
|
||||
setInvisible(true);
|
||||
this.parentPiece = parentPiece;
|
||||
forceSetBoundingBox(new NullBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// So it won't get removed.
|
||||
ticksLived = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity())); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
@Override
|
||||
public void setCustomName(IChatBaseComponent ichatbasecomponent) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (super.bukkitEntity == null) {
|
||||
super.bukkitEntity = new CraftNMSSlime(super.world.getServer(), this);
|
||||
}
|
||||
return super.bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
@Override
|
||||
public boolean isDeadNMS() {
|
||||
return super.dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killEntityNMS() {
|
||||
super.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdNMS() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HologramLine getHologramLine() {
|
||||
return parentPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.getVehicle() != null) {
|
||||
Entity oldVehicle = super.getVehicle();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getBukkitEntityNMS() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
|
||||
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
|
||||
// It should never dismount
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) vehicleBase;
|
||||
|
||||
try {
|
||||
if (super.getVehicle() != null) {
|
||||
Entity oldVehicle = super.getVehicle();
|
||||
VEHICLE_FIELD.set(this, null);
|
||||
oldVehicle.passengers.remove(this);
|
||||
}
|
||||
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
VEHICLE_FIELD.set(this, entity);
|
||||
entity.passengers.clear();
|
||||
entity.passengers.add(this);
|
||||
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
ConsoleLogger.logDebug(Level.SEVERE, "Couldn't set passenger", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,169 +45,169 @@ import java.lang.reflect.Method;
|
|||
import java.util.List;
|
||||
|
||||
public class NmsManagerImpl implements NMSManager {
|
||||
|
||||
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<List<Entity>> ENTITY_LIST_FIELD = new ReflectField<>(World.class, "entityList");
|
||||
|
||||
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<List<Entity>> ENTITY_LIST_FIELD = new ReflectField<>(World.class, "entityList");
|
||||
|
||||
private Method validateEntityMethod;
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||
validateEntityMethod.setAccessible(true);
|
||||
|
||||
registerCustomEntity(EntityNMSSlime.class, 55);
|
||||
}
|
||||
|
||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||
// Use reflection to get the RegistryID of entities.
|
||||
RegistryID<EntityTypes<?>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.REGISTRY);
|
||||
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
||||
|
||||
// Save the the ID -> EntityTypes mapping before the registration.
|
||||
Object oldValue = idToClassMap[id];
|
||||
private Method validateEntityMethod;
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
validateEntityMethod = World.class.getDeclaredMethod("b", Entity.class);
|
||||
validateEntityMethod.setAccessible(true);
|
||||
|
||||
registerCustomEntity(EntityNMSSlime.class, 55);
|
||||
}
|
||||
|
||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||
// Use reflection to get the RegistryID of entities.
|
||||
RegistryID<EntityTypes<?>> registryID = REGISTRY_ID_FIELD.get(EntityTypes.REGISTRY);
|
||||
Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID);
|
||||
|
||||
// Save the the ID -> EntityTypes mapping before the registration.
|
||||
Object oldValue = idToClassMap[id];
|
||||
|
||||
// Register the EntityTypes object.
|
||||
registryID.a(new EntityTypes<>(entityClass, world -> null, true, true, null), id);
|
||||
// Register the EntityTypes object.
|
||||
registryID.a(new EntityTypes<>(entityClass, world -> null, true, true, null), id);
|
||||
|
||||
// Restore the ID -> EntityTypes mapping.
|
||||
idToClassMap[id] = oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||
customItem.setLocationNMS(x, y, z);
|
||||
customItem.setItemStackNMS(stack);
|
||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return customItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||
touchSlime.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return touchSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||
|
||||
// Restore the ID -> EntityTypes mapping.
|
||||
idToClassMap[id] = oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager);
|
||||
customItem.setLocationNMS(x, y, z);
|
||||
customItem.setItemStackNMS(stack);
|
||||
if (!addEntityToWorld(nmsWorld, customItem)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return customItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece);
|
||||
touchSlime.setLocationNMS(x, y, z);
|
||||
if (!addEntityToWorld(nmsWorld, touchSlime)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return touchSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece, boolean broadcastLocationPacket) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece);
|
||||
invisibleArmorStand.setLocationNMS(x, y, z, broadcastLocationPacket);
|
||||
if (!addEntityToWorld(nmsWorld, invisibleArmorStand)) {
|
||||
ConsoleLogger.handleSpawnFail(parentPiece);
|
||||
}
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
private boolean addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) {
|
||||
Validator.isTrue(Bukkit.isPrimaryThread(), "Async entity add");
|
||||
|
||||
final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0);
|
||||
final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0);
|
||||
|
||||
if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) {
|
||||
// This should never happen
|
||||
// This should never happen
|
||||
nmsEntity.dead = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
|
||||
if (VersionUtils.isPaperServer()) {
|
||||
try {
|
||||
// Workaround because nmsWorld.entityList is a different class in Paper, if used without reflection it throws NoSuchFieldError.
|
||||
ENTITY_LIST_FIELD.get(nmsWorld).add(nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
// Workaround because nmsWorld.entityList is a different class in Paper, if used without reflection it throws NoSuchFieldError.
|
||||
ENTITY_LIST_FIELD.get(nmsWorld).add(nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
nmsWorld.entityList.add(nmsEntity);
|
||||
nmsWorld.entityList.add(nmsEntity);
|
||||
}
|
||||
|
||||
try {
|
||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
validateEntityMethod.invoke(nmsWorld, nmsEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntityBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
||||
return CustomNameHelper.replaceCustomNameChatComponent(NMSChatComponentAdapter.INSTANCE, customNameObject, target, replacement);
|
||||
}
|
||||
|
||||
private static enum NMSChatComponentAdapter implements ChatComponentAdapter<IChatBaseComponent> {
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSEntityBase getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntityBase) {
|
||||
return ((NMSEntityBase) nmsEntity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object replaceCustomNameText(Object customNameObject, String target, String replacement) {
|
||||
return CustomNameHelper.replaceCustomNameChatComponent(NMSChatComponentAdapter.INSTANCE, customNameObject, target, replacement);
|
||||
}
|
||||
|
||||
private static enum NMSChatComponentAdapter implements ChatComponentAdapter<IChatBaseComponent> {
|
||||
|
||||
INSTANCE {
|
||||
|
||||
public ChatComponentText cast(Object chatComponentObject) {
|
||||
return (ChatComponentText) chatComponentObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(IChatBaseComponent chatComponent) {
|
||||
return chatComponent.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IChatBaseComponent> getSiblings(IChatBaseComponent chatComponent) {
|
||||
return chatComponent.a();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSibling(IChatBaseComponent chatComponent, IChatBaseComponent newSibling) {
|
||||
chatComponent.addSibling(newSibling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatComponentText cloneComponent(IChatBaseComponent chatComponent, String newText) {
|
||||
ChatComponentText clonedChatComponent = new ChatComponentText(newText);
|
||||
clonedChatComponent.setChatModifier(chatComponent.getChatModifier().clone());
|
||||
return clonedChatComponent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
INSTANCE {
|
||||
|
||||
public ChatComponentText cast(Object chatComponentObject) {
|
||||
return (ChatComponentText) chatComponentObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(IChatBaseComponent chatComponent) {
|
||||
return chatComponent.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IChatBaseComponent> getSiblings(IChatBaseComponent chatComponent) {
|
||||
return chatComponent.a();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSibling(IChatBaseComponent chatComponent, IChatBaseComponent newSibling) {
|
||||
chatComponent.addSibling(newSibling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatComponentText cloneComponent(IChatBaseComponent chatComponent, String newText) {
|
||||
ChatComponentText clonedChatComponent = new ChatComponentText(newText);
|
||||
clonedChatComponent.setChatModifier(chatComponent.getChatModifier().clone());
|
||||
return clonedChatComponent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,111 +22,111 @@ import net.minecraft.server.v1_13_R1.Vec3D;
|
|||
|
||||
public class NullBoundingBox extends AxisAlignedBB {
|
||||
|
||||
public NullBoundingBox() {
|
||||
super(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
public NullBoundingBox() {
|
||||
super(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a() {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double a() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB a(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB a(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public MovingObjectPosition b(Vec3D arg0, Vec3D arg1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB grow(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB shrink(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(BlockPosition arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB shrink(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(BlockPosition arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean b(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB g(double arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public boolean b(Vec3D arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB g(double arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB a(Vec3D arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB a(Vec3D arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB b(AxisAlignedBB arg0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB b(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(AxisAlignedBB arg0) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean c(AxisAlignedBB arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public AxisAlignedBB d(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double a(EnumAxis arg0) {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double a(EnumAxis arg0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition a(Vec3D arg0, Vec3D arg1, BlockPosition arg2) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public MovingObjectPosition a(Vec3D arg0, Vec3D arg1, BlockPosition arg2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double b(EnumAxis arg0) {
|
||||
return 0.0;
|
||||
}
|
||||
@Override
|
||||
public double b(EnumAxis arg0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean e(double arg0, double arg1, double arg2) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean e(double arg0, double arg1, double arg2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB f(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB f(double arg0, double arg1, double arg2) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue