mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2025-04-02 01:35:42 +02:00
Fix Checkstyle violations by formatting code
This commit is contained in:
parent
305931bd73
commit
c1cd5b200c
@ -18,14 +18,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
* An object made of various lines, that can be items or holograms.
|
||||
* Holographic lines appear as a nametag without any entity below.
|
||||
* To create one, please see {@link HolographicDisplaysAPI#createHologram(Location)}.
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
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
|
||||
* @since 1
|
||||
@ -35,7 +35,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* Appends an item line to end of this hologram.
|
||||
*
|
||||
*
|
||||
* @param itemStack the content of the line
|
||||
* @return the new ItemLine appended
|
||||
* @since 1
|
||||
@ -45,9 +45,8 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* 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 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())
|
||||
@ -58,9 +57,8 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* 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 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())
|
||||
@ -71,7 +69,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* 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())
|
||||
@ -81,7 +79,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* 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())
|
||||
* @since 1
|
||||
@ -91,7 +89,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* Removes all the lines from this hologram.
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
void clearLines();
|
||||
@ -99,7 +97,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* Checks the amount of lines of the hologram.
|
||||
*
|
||||
*
|
||||
* @return the amount of lines
|
||||
* @since 1
|
||||
*/
|
||||
@ -108,7 +106,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @since 1
|
||||
*/
|
||||
@ -117,7 +115,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* Teleports a hologram to the given location.
|
||||
*
|
||||
*
|
||||
* @param location the new location
|
||||
* @since 1
|
||||
*/
|
||||
@ -126,9 +124,8 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* 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 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
|
||||
@ -138,7 +135,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* Returns the position of the hologram.
|
||||
*
|
||||
*
|
||||
* @return the Location of the hologram
|
||||
* @since 1
|
||||
*/
|
||||
@ -146,7 +143,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* Returns the X coordinate.
|
||||
*
|
||||
*
|
||||
* @return the X coordinate of the hologram
|
||||
* @since 1
|
||||
*/
|
||||
@ -155,7 +152,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* Returns the Y coordinate.
|
||||
*
|
||||
*
|
||||
* @return the Y coordinate of the hologram
|
||||
* @since 1
|
||||
*/
|
||||
@ -164,7 +161,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* Returns the Z coordinate.
|
||||
*
|
||||
*
|
||||
* @return the Z coordinate of the hologram
|
||||
* @since 1
|
||||
*/
|
||||
@ -173,7 +170,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* Returns the world.
|
||||
*
|
||||
*
|
||||
* @return the world of the hologram
|
||||
* @since 1
|
||||
*/
|
||||
@ -184,7 +181,7 @@ public interface Hologram {
|
||||
* 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
|
||||
* @since 1
|
||||
*/
|
||||
@ -193,7 +190,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* Returns when the hologram was created. Useful for removing old holograms.
|
||||
*
|
||||
*
|
||||
* @return the timestamp of when the hologram was created, in milliseconds
|
||||
* @since 1
|
||||
*/
|
||||
@ -202,7 +199,7 @@ public interface Hologram {
|
||||
/**
|
||||
* Checks if the hologram will track and replace placeholders.
|
||||
* This is false by default.
|
||||
*
|
||||
*
|
||||
* @return if the hologram allows placeholders
|
||||
* @since 1
|
||||
*/
|
||||
@ -211,7 +208,7 @@ public interface Hologram {
|
||||
/**
|
||||
* Sets if the hologram should track and replace placeholders.
|
||||
* By default if will not track them.
|
||||
*
|
||||
*
|
||||
* @param allowPlaceholders if the hologram should track placeholders
|
||||
* @since 1
|
||||
*/
|
||||
@ -221,7 +218,7 @@ public interface Hologram {
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
void delete();
|
||||
@ -229,7 +226,7 @@ public interface Hologram {
|
||||
|
||||
/**
|
||||
* Checks if a hologram was deleted.
|
||||
*
|
||||
*
|
||||
* @return true if this hologram was deleted
|
||||
* @since 1
|
||||
*/
|
||||
|
@ -16,7 +16,7 @@ import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Main entry point for accessing the Holographic Displays API.
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
public interface HolographicDisplaysAPI {
|
||||
@ -91,7 +91,7 @@ public interface HolographicDisplaysAPI {
|
||||
* Resets and removes all the registered placeholders.
|
||||
* <p>
|
||||
* May be useful to invoke before registering all the placeholders of your plugin.
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
void unregisterPlaceholders();
|
||||
|
@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* This object is used to manage the visibility of a hologram.
|
||||
* It allows to hide/show the hologram to certain players, and the default behaviour
|
||||
* (when a hologram is not specifically being hidden/shown to a player) can be customized.
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
public interface VisibilityManager {
|
||||
@ -20,7 +20,7 @@ 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
|
||||
* @since 1
|
||||
*/
|
||||
@ -29,7 +29,7 @@ public interface VisibilityManager {
|
||||
/**
|
||||
* 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
|
||||
* @since 1
|
||||
*/
|
||||
@ -38,7 +38,7 @@ public interface VisibilityManager {
|
||||
/**
|
||||
* 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
|
||||
* @since 1
|
||||
*/
|
||||
@ -47,7 +47,7 @@ public interface VisibilityManager {
|
||||
/**
|
||||
* 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
|
||||
* @since 1
|
||||
*/
|
||||
@ -55,7 +55,7 @@ public interface VisibilityManager {
|
||||
|
||||
/**
|
||||
* Checks if a hologram is visible to a player.
|
||||
*
|
||||
*
|
||||
* @param player the involved player
|
||||
* @return if the player can see the hologram
|
||||
* @since 1
|
||||
@ -66,7 +66,7 @@ public interface VisibilityManager {
|
||||
* 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
|
||||
* @since 1
|
||||
*/
|
||||
@ -74,7 +74,7 @@ public interface VisibilityManager {
|
||||
|
||||
/**
|
||||
* Resets the visibility for all the players. See {@link #resetVisibility(Player)} for more details.
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
void resetVisibilityAll();
|
||||
|
@ -10,13 +10,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Interface to handle items being picked up by players.
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
public interface PickupHandler {
|
||||
|
||||
/**
|
||||
* Called when a player picks up the item.
|
||||
*
|
||||
* @param player the player who picked up the item
|
||||
* @since 1
|
||||
*/
|
||||
|
@ -10,13 +10,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Interface to handle touch holograms.
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
public interface TouchHandler {
|
||||
|
||||
/**
|
||||
* Called when a player interacts with the hologram (right click).
|
||||
*
|
||||
* @param player the player who interacts
|
||||
* @since 1
|
||||
*/
|
||||
|
@ -10,14 +10,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* A line of a Hologram that can be picked up.
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
public interface CollectableLine extends HologramLine {
|
||||
|
||||
/**
|
||||
* Sets the PickupHandler for this line.
|
||||
*
|
||||
*
|
||||
* @param pickupHandler the new PickupHandler, can be null.
|
||||
* @since 1
|
||||
*/
|
||||
@ -25,7 +25,7 @@ public interface CollectableLine extends HologramLine {
|
||||
|
||||
/**
|
||||
* Returns the current PickupHandler of this line.
|
||||
*
|
||||
*
|
||||
* @return the current PickupHandler, can be null.
|
||||
* @since 1
|
||||
*/
|
||||
|
@ -10,14 +10,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Interface to represent a line in a Hologram.
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
public interface HologramLine {
|
||||
|
||||
/**
|
||||
* Returns the parent Hologram of this line.
|
||||
*
|
||||
*
|
||||
* @return the parent Hologram.
|
||||
* @since 1
|
||||
*/
|
||||
@ -26,7 +26,7 @@ public interface HologramLine {
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
void removeLine();
|
||||
|
@ -15,7 +15,7 @@ public interface ItemLine extends CollectableLine, TouchableLine {
|
||||
|
||||
/**
|
||||
* Returns the ItemStack of this ItemLine.
|
||||
*
|
||||
*
|
||||
* @return the ItemStack if this ItemLine.
|
||||
* @since 1
|
||||
*/
|
||||
@ -23,7 +23,7 @@ public interface ItemLine extends CollectableLine, TouchableLine {
|
||||
|
||||
/**
|
||||
* Sets the ItemStack for this ItemLine.
|
||||
*
|
||||
*
|
||||
* @param itemStack the new item, should not be null.
|
||||
* @since 1
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@ public interface TextLine extends TouchableLine {
|
||||
|
||||
/**
|
||||
* Returns the current text of this TextLine.
|
||||
*
|
||||
*
|
||||
* @return the current text of this line.
|
||||
* @since 1
|
||||
*/
|
||||
@ -22,7 +22,7 @@ public interface TextLine extends TouchableLine {
|
||||
|
||||
/**
|
||||
* Sets the text of this TextLine.
|
||||
*
|
||||
*
|
||||
* @param text the new text of this line.
|
||||
* @since 1
|
||||
*/
|
||||
|
@ -10,14 +10,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* A line of a Hologram that can be touched (right click).
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
public interface TouchableLine extends HologramLine {
|
||||
|
||||
/**
|
||||
* Sets the TouchHandler for this line.
|
||||
*
|
||||
*
|
||||
* @param touchHandler the new TouchHandler, can be null.
|
||||
* @since 1
|
||||
*/
|
||||
@ -25,7 +25,7 @@ public interface TouchableLine extends HologramLine {
|
||||
|
||||
/**
|
||||
* Returns the current TouchHandler of this line.
|
||||
*
|
||||
*
|
||||
* @return the current TouchHandler, can be null.
|
||||
* @since 1
|
||||
*/
|
||||
|
@ -9,7 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Simple callback to provide a placeholder replacement.
|
||||
*
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
@FunctionalInterface
|
||||
|
@ -11,28 +11,33 @@ import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntity;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSItem;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface NMSManager {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Register all the custom entities of the plugin.
|
||||
*
|
||||
*
|
||||
* @throws Exception if anything during the process fails
|
||||
*/
|
||||
void setup() throws Exception;
|
||||
|
||||
NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException;
|
||||
NMSArmorStand spawnNMSArmorStand(World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine)
|
||||
throws SpawnFailedException;
|
||||
|
||||
NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException;
|
||||
NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack)
|
||||
throws SpawnFailedException;
|
||||
|
||||
NMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException;
|
||||
NMSSlime spawnNMSSlime(World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine)
|
||||
throws SpawnFailedException;
|
||||
|
||||
boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity);
|
||||
boolean isNMSEntityBase(Entity bukkitEntity);
|
||||
|
||||
NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity);
|
||||
NMSEntity getNMSEntityBase(Entity bukkitEntity);
|
||||
|
||||
NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID);
|
||||
NMSEntity getNMSEntityBaseFromID(World bukkitWorld, int entityID);
|
||||
|
||||
CustomNameEditor getCustomNameEditor();
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class PowerUps extends JavaPlugin implements Listener {
|
||||
|
||||
// Spawn the floating item with a label
|
||||
Hologram hologram = holographicDisplaysAPI.createHologram(event.getEntity().getLocation().add(0.0, 0.9, 0.0));
|
||||
hologram.appendTextLine(ChatColor.AQUA + "" + ChatColor.BOLD + "Speed PowerUp");
|
||||
hologram.appendTextLine(ChatColor.AQUA + "" + ChatColor.BOLD + "Speed PowerUp");
|
||||
ItemLine icon = hologram.appendItemLine(new ItemStack(Material.SUGAR));
|
||||
|
||||
icon.setPickupHandler((Player player) -> {
|
||||
|
@ -57,7 +57,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
|
@ -37,7 +37,7 @@ public class CraftNMSSlime extends CraftSlime {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
|
@ -69,7 +69,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity
|
||||
|
@ -176,7 +176,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
NBTTagCompound display = newItem.getTag().getCompound("display");
|
||||
|
||||
if (!newItem.getTag().hasKey("display")) {
|
||||
newItem.getTag().set("display", display);
|
||||
newItem.getTag().set("display", display);
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
@ -115,7 +115,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
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
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -33,8 +33,10 @@ import java.util.Map;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken<Map<Class<?>, String>>(){}, EntityTypes.class, "d");
|
||||
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken<Map<Class<?>, Integer>>(){}, EntityTypes.class, "f");
|
||||
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD
|
||||
= ReflectField.lookup(new ClassToken<Map<Class<?>, String>>(){}, EntityTypes.class, "d");
|
||||
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD
|
||||
= ReflectField.lookup(new ClassToken<Map<Class<?>, Integer>>(){}, EntityTypes.class, "f");
|
||||
|
||||
private static final ReflectMethod<?> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class);
|
||||
|
||||
@ -57,7 +59,10 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -67,7 +72,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
@ -76,7 +83,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
org.bukkit.World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -117,7 +126,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -129,7 +138,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
|
@ -37,7 +37,7 @@ public class CraftNMSSlime extends CraftSlime {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
|
@ -76,7 +76,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
if (super.onGround) {
|
||||
super.onGround = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
|
@ -101,7 +101,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
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
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -33,8 +33,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken<RegistryID<Class<? extends Entity>>>(){}, RegistryMaterials.class, "a");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD
|
||||
= ReflectField.lookup(new ClassToken<RegistryID<Class<? extends Entity>>>(){}, RegistryMaterials.class, "a");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD
|
||||
= ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
|
||||
private static final ReflectMethod<?> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class);
|
||||
|
||||
@ -65,7 +67,10 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -75,7 +80,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
@ -84,7 +91,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
org.bukkit.World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -125,7 +134,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -137,7 +146,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
|
@ -37,7 +37,7 @@ public class CraftNMSSlime extends CraftSlime {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
|
||||
// Methods from Entity
|
||||
|
@ -101,7 +101,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
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
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -33,8 +33,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken<RegistryID<Class<? extends Entity>>>(){}, RegistryMaterials.class, "a");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD
|
||||
= ReflectField.lookup(new ClassToken<RegistryID<Class<? extends Entity>>>(){}, RegistryMaterials.class, "a");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD
|
||||
= ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
|
||||
private static final ReflectMethod<?> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class);
|
||||
|
||||
@ -65,7 +67,10 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -75,7 +80,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
@ -84,7 +91,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
org.bukkit.World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -125,7 +134,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -137,7 +146,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class CraftNMSSlime extends CraftSlime {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -102,7 +102,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
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
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -38,9 +38,12 @@ import java.util.List;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken<RegistryID<EntityTypes<?>>>(){}, RegistryMaterials.class, "a");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
private static final ReflectField<List<Entity>> ENTITY_LIST_FIELD = ReflectField.lookup(new ClassToken<List<Entity>>(){}, World.class, "entityList");
|
||||
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD
|
||||
= ReflectField.lookup(new ClassToken<RegistryID<EntityTypes<?>>>(){}, RegistryMaterials.class, "a");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD
|
||||
= ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
private static final ReflectField<List<Entity>> ENTITY_LIST_FIELD
|
||||
= ReflectField.lookup(new ClassToken<List<Entity>>(){}, World.class, "entityList");
|
||||
|
||||
private static final ReflectMethod<?> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class);
|
||||
|
||||
@ -71,7 +74,10 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -81,7 +87,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
@ -90,7 +98,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
org.bukkit.World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -113,7 +123,8 @@ public class VersionNMSManager implements NMSManager {
|
||||
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
|
||||
if (NMSCommons.IS_PAPER_SERVER) {
|
||||
try {
|
||||
// Workaround because nmsWorld.entityList is a different class in Paper, if used without reflection it throws NoSuchFieldError
|
||||
// Workaround because nmsWorld.entityList is a different class in Paper,
|
||||
// if used without reflection it throws NoSuchFieldError.
|
||||
ENTITY_LIST_FIELD.get(nmsWorld).add(nmsEntity);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
@ -141,7 +152,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -153,7 +164,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class CraftNMSSlime extends CraftSlime {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
@ -102,7 +102,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
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
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -39,9 +39,12 @@ import java.util.List;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken<RegistryID<EntityTypes<?>>>(){}, RegistryMaterials.class, "b");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
private static final ReflectField<List<Entity>> ENTITY_LIST_FIELD = ReflectField.lookup(new ClassToken<List<Entity>>(){}, World.class, "entityList");
|
||||
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD
|
||||
= ReflectField.lookup(new ClassToken<RegistryID<EntityTypes<?>>>(){}, RegistryMaterials.class, "b");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD
|
||||
= ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
private static final ReflectField<List<Entity>> ENTITY_LIST_FIELD
|
||||
= ReflectField.lookup(new ClassToken<List<Entity>>(){}, World.class, "entityList");
|
||||
|
||||
private static final ReflectMethod<?> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class);
|
||||
|
||||
@ -72,7 +75,10 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -82,7 +88,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
@ -91,7 +99,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
org.bukkit.World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -114,7 +124,8 @@ public class VersionNMSManager implements NMSManager {
|
||||
nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity);
|
||||
if (NMSCommons.IS_PAPER_SERVER) {
|
||||
try {
|
||||
// Workaround because nmsWorld.entityList is a different class in Paper, if used without reflection it throws NoSuchFieldError
|
||||
// Workaround because nmsWorld.entityList is a different class in Paper,
|
||||
// if used without reflection it throws NoSuchFieldError.
|
||||
ENTITY_LIST_FIELD.get(nmsWorld).add(nmsEntity);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
@ -142,7 +153,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -154,7 +165,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class CraftNMSSlime extends CraftSlime {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -104,7 +104,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
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
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -9,16 +9,16 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.reflection.ClassToken;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.fcommons.reflection.ReflectMethod;
|
||||
import me.filoghost.holographicdisplays.core.nms.CustomNameEditor;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardItemLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ChatComponentCustomNameEditor;
|
||||
import me.filoghost.holographicdisplays.core.nms.CustomNameEditor;
|
||||
import me.filoghost.holographicdisplays.core.nms.NMSManager;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.SpawnFailedException;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntity;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSItem;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardItemLine;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import net.minecraft.server.v1_14_R1.ChatBaseComponent;
|
||||
import net.minecraft.server.v1_14_R1.ChatComponentText;
|
||||
import net.minecraft.server.v1_14_R1.Entity;
|
||||
@ -40,9 +40,12 @@ import java.util.List;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken<RegistryID<EntityTypes<?>>>(){}, RegistryMaterials.class, "b");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
private static final ReflectMethod<Void> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class);
|
||||
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD
|
||||
= ReflectField.lookup(new ClassToken<RegistryID<EntityTypes<?>>>(){}, RegistryMaterials.class, "b");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD
|
||||
= ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
private static final ReflectMethod<Void> REGISTER_ENTITY_METHOD
|
||||
= ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class);
|
||||
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
|
||||
@ -51,7 +54,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
public void setup() throws Exception {
|
||||
registerCustomEntity(EntityNMSSlime.class, 55, 2.04f, 2.04f);
|
||||
}
|
||||
|
||||
@ -71,7 +74,10 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -81,7 +87,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
@ -90,7 +98,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -129,7 +139,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -141,7 +151,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -155,9 +165,11 @@ public class VersionNMSManager implements NMSManager {
|
||||
private enum VersionChatComponentCustomNameEditor implements ChatComponentCustomNameEditor<IChatBaseComponent> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
|
||||
private static final ReflectField<List<IChatBaseComponent>> OLD_SIBLINGS_FIELD
|
||||
= ReflectField.lookup(new ClassToken<List<IChatBaseComponent>>(){}, ChatBaseComponent.class, "a");
|
||||
|
||||
private boolean useNewGetSiblingsMethod = true;
|
||||
private final ReflectField<List<IChatBaseComponent>> OLD_SIBLINGS_FIELD = ReflectField.lookup(new ClassToken<List<IChatBaseComponent>>(){}, ChatBaseComponent.class, "a");
|
||||
|
||||
@Override
|
||||
public String getText(IChatBaseComponent chatComponent) {
|
||||
|
@ -57,7 +57,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class CraftNMSSlime extends CraftSlime {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -104,7 +104,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
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
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -39,9 +39,12 @@ import java.util.List;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken<RegistryID<EntityTypes<?>>>(){}, RegistryMaterials.class, "b");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
private static final ReflectMethod<Void> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class);
|
||||
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD
|
||||
= ReflectField.lookup(new ClassToken<RegistryID<EntityTypes<?>>>(){}, RegistryMaterials.class, "b");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD
|
||||
= ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
private static final ReflectMethod<Void> REGISTER_ENTITY_METHOD
|
||||
= ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class);
|
||||
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
|
||||
@ -50,7 +53,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
public void setup() throws Exception {
|
||||
registerCustomEntity(EntityNMSSlime.class, 55, 2.04f, 2.04f);
|
||||
}
|
||||
|
||||
@ -70,7 +73,10 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -80,7 +86,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
@ -89,7 +97,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -128,7 +138,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -140,7 +150,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class CraftNMSSlime extends CraftSlime {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -104,7 +104,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
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
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -39,9 +39,12 @@ import java.util.List;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken<RegistryID<EntityTypes<?>>>(){}, RegistryMaterials.class, "b");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
private static final ReflectMethod<Void> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class);
|
||||
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD
|
||||
= ReflectField.lookup(new ClassToken<RegistryID<EntityTypes<?>>>(){}, RegistryMaterials.class, "b");
|
||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD
|
||||
= ReflectField.lookup(Object[].class, RegistryID.class, "d");
|
||||
private static final ReflectMethod<Void> REGISTER_ENTITY_METHOD
|
||||
= ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class);
|
||||
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
|
||||
@ -50,7 +53,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
public void setup() throws Exception {
|
||||
registerCustomEntity(EntityNMSSlime.class, 55, 2.04f, 2.04f);
|
||||
}
|
||||
|
||||
@ -70,7 +73,10 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -80,7 +86,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
@ -89,7 +97,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -128,7 +138,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -140,7 +150,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class CraftNMSSlime extends CraftSlime {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -104,7 +104,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
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
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -39,8 +39,10 @@ import java.util.Map;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<Map<EntityTypes<?>, Integer>> REGISTRY_TO_ID_FIELD = ReflectField.lookup(new ClassToken<Map<EntityTypes<?>, Integer>>(){}, RegistryMaterials.class, "bg");
|
||||
private static final ReflectMethod<Void> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class);
|
||||
private static final ReflectField<Map<EntityTypes<?>, Integer>> REGISTRY_TO_ID_FIELD
|
||||
= ReflectField.lookup(new ClassToken<Map<EntityTypes<?>, Integer>>(){}, RegistryMaterials.class, "bg");
|
||||
private static final ReflectMethod<Void> REGISTER_ENTITY_METHOD
|
||||
= ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class);
|
||||
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
|
||||
@ -49,7 +51,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
public void setup() throws Exception {
|
||||
registerCustomEntity(EntityNMSSlime.class, 55, 2.04f, 2.04f);
|
||||
}
|
||||
|
||||
@ -61,7 +63,10 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -71,7 +76,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
@ -80,7 +87,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -119,7 +128,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -131,7 +140,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class CraftNMSArmorStand extends CraftArmorStand {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class CraftNMSSlime extends CraftSlime {
|
||||
@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 void setGliding(boolean gliding) {}
|
||||
@Override public boolean setLeashHolder(Entity holder) { return false; }
|
||||
@Override public void setSwimming(boolean swimming) {}
|
||||
|
||||
|
@ -104,7 +104,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
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
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -39,8 +39,10 @@ import java.util.Map;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<Map<EntityTypes<?>, Integer>> REGISTRY_TO_ID_FIELD = ReflectField.lookup(new ClassToken<Map<EntityTypes<?>, Integer>>(){}, RegistryMaterials.class, "bg");
|
||||
private static final ReflectMethod<Void> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class);
|
||||
private static final ReflectField<Map<EntityTypes<?>, Integer>> REGISTRY_TO_ID_FIELD
|
||||
= ReflectField.lookup(new ClassToken<Map<EntityTypes<?>, Integer>>(){}, RegistryMaterials.class, "bg");
|
||||
private static final ReflectMethod<Void> REGISTER_ENTITY_METHOD
|
||||
= ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class);
|
||||
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
|
||||
@ -49,7 +51,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() throws Exception {
|
||||
public void setup() throws Exception {
|
||||
registerCustomEntity(EntityNMSSlime.class, 55, 2.04f, 2.04f);
|
||||
}
|
||||
|
||||
@ -61,7 +63,10 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -71,7 +76,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
@ -80,7 +87,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -119,7 +128,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -131,7 +140,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ import java.util.Objects;
|
||||
|
||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
||||
|
||||
private static final ReflectMethod<Void> SET_MARKER_METHOD = ReflectMethod.lookup(void.class, EntityArmorStand.class, "n", boolean.class);
|
||||
private static final ReflectMethod<Void> SET_MARKER_METHOD
|
||||
= ReflectMethod.lookup(void.class, EntityArmorStand.class, "n", boolean.class);
|
||||
private static final ReflectField<Double> PASSENGER_PITCH_DELTA = ReflectField.lookup(double.class, Entity.class, "ar");
|
||||
private static final ReflectField<Double> PASSENGER_YAW_DELTA = ReflectField.lookup(double.class, Entity.class, "as");
|
||||
|
||||
|
@ -88,13 +88,15 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
public void e(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damageSource, float amount) {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity()));
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -34,8 +34,10 @@ import java.util.Map;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken<Map<Class<?>, String>>(){}, EntityTypes.class, "d");
|
||||
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken<Map<Class<?>, Integer>>(){}, EntityTypes.class, "f");
|
||||
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD
|
||||
= ReflectField.lookup(new ClassToken<Map<Class<?>, String>>(){}, EntityTypes.class, "d");
|
||||
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD
|
||||
= ReflectField.lookup(new ClassToken<Map<Class<?>, Integer>>(){}, EntityTypes.class, "f");
|
||||
|
||||
private static final ReflectMethod<?> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "a", Entity.class);
|
||||
|
||||
@ -58,7 +60,10 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -68,7 +73,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
@ -77,7 +84,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
org.bukkit.World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -126,7 +135,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -138,7 +147,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.a(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ import java.util.Objects;
|
||||
|
||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
||||
|
||||
private static final ReflectMethod<Void> SET_MARKER_METHOD = ReflectMethod.lookup(void.class, EntityArmorStand.class, "n", boolean.class);
|
||||
private static final ReflectMethod<Void> SET_MARKER_METHOD
|
||||
= ReflectMethod.lookup(void.class, EntityArmorStand.class, "n", boolean.class);
|
||||
private static final ReflectField<Double> PASSENGER_PITCH_DELTA = ReflectField.lookup(double.class, Entity.class, "ar");
|
||||
private static final ReflectField<Double> PASSENGER_YAW_DELTA = ReflectField.lookup(double.class, Entity.class, "as");
|
||||
|
||||
@ -80,7 +81,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
if (super.onGround) {
|
||||
super.onGround = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
|
@ -94,7 +94,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
if (damageSource instanceof EntityDamageSource) {
|
||||
EntityDamageSource entityDamageSource = (EntityDamageSource) damageSource;
|
||||
if (entityDamageSource.getEntity() instanceof EntityPlayer) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerInteractEntityEvent(((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity(), getBukkitEntity()));
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -34,8 +34,10 @@ import java.util.Map;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken<Map<Class<?>, String>>(){}, EntityTypes.class, "d");
|
||||
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken<Map<Class<?>, Integer>>(){}, EntityTypes.class, "f");
|
||||
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD
|
||||
= ReflectField.lookup(new ClassToken<Map<Class<?>, String>>(){}, EntityTypes.class, "d");
|
||||
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD
|
||||
= ReflectField.lookup(new ClassToken<Map<Class<?>, Integer>>(){}, EntityTypes.class, "f");
|
||||
|
||||
private static final ReflectMethod<?> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "a", Entity.class);
|
||||
|
||||
@ -56,9 +58,12 @@ public class VersionNMSManager implements NMSManager {
|
||||
ENTITY_NAMES_BY_CLASS_FIELD.getStatic().put(entityClass, name);
|
||||
ENTITY_IDS_BY_CLASS_FIELD.getStatic().put(entityClass, id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -66,18 +71,22 @@ public class VersionNMSManager implements NMSManager {
|
||||
addEntityToWorld(nmsWorld, item);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
addEntityToWorld(nmsWorld, slime);
|
||||
return slime;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
org.bukkit.World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -126,7 +135,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -138,7 +147,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.a(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
if (super.onGround) {
|
||||
super.onGround = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
|
@ -114,7 +114,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
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
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -33,8 +33,10 @@ import java.util.Map;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken<Map<Class<?>, String>>(){}, EntityTypes.class, "d");
|
||||
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken<Map<Class<?>, Integer>>(){}, EntityTypes.class, "f");
|
||||
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD
|
||||
= ReflectField.lookup(new ClassToken<Map<Class<?>, String>>(){}, EntityTypes.class, "d");
|
||||
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD
|
||||
= ReflectField.lookup(new ClassToken<Map<Class<?>, Integer>>(){}, EntityTypes.class, "f");
|
||||
|
||||
private static final ReflectMethod<?> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class);
|
||||
|
||||
@ -57,7 +59,10 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -67,7 +72,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
@ -76,7 +83,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
org.bukkit.World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -117,7 +126,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -129,7 +138,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -115,7 +115,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
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
|
||||
Player player = ((EntityPlayer) entityDamageSource.getEntity()).getBukkitEntity();
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(player, getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event); // Bukkit takes care of the exceptions
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -33,8 +33,10 @@ import java.util.Map;
|
||||
|
||||
public class VersionNMSManager implements NMSManager {
|
||||
|
||||
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken<Map<Class<?>, String>>(){}, EntityTypes.class, "d");
|
||||
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken<Map<Class<?>, Integer>>(){}, EntityTypes.class, "f");
|
||||
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD
|
||||
= ReflectField.lookup(new ClassToken<Map<Class<?>, String>>(){}, EntityTypes.class, "d");
|
||||
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD
|
||||
= ReflectField.lookup(new ClassToken<Map<Class<?>, Integer>>(){}, EntityTypes.class, "f");
|
||||
|
||||
private static final ReflectMethod<?> REGISTER_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class);
|
||||
|
||||
@ -57,7 +59,10 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException {
|
||||
public NMSItem spawnNMSItem(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardItemLine parentHologramLine,
|
||||
ItemStack stack) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSItem item = new EntityNMSItem(nmsWorld, parentHologramLine);
|
||||
item.setLocationNMS(x, y, z);
|
||||
@ -67,7 +72,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public EntityNMSSlime spawnNMSSlime(
|
||||
org.bukkit.World bukkitWorld, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle();
|
||||
EntityNMSSlime slime = new EntityNMSSlime(nmsWorld, parentHologramLine);
|
||||
slime.setLocationNMS(x, y, z);
|
||||
@ -76,7 +83,9 @@ public class VersionNMSManager implements NMSManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
public NMSArmorStand spawnNMSArmorStand(
|
||||
org.bukkit.World world, double x, double y, double z,
|
||||
StandardHologramLine parentHologramLine) throws SpawnFailedException {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
EntityNMSArmorStand armorStand = new EntityNMSArmorStand(nmsWorld, parentHologramLine, protocolPacketSettings);
|
||||
armorStand.setLocationNMS(x, y, z);
|
||||
@ -117,7 +126,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -129,7 +138,7 @@ public class VersionNMSManager implements NMSManager {
|
||||
Entity nmsEntity = nmsWorld.getEntity(entityID);
|
||||
|
||||
if (nmsEntity instanceof NMSEntity) {
|
||||
return ((NMSEntity) nmsEntity);
|
||||
return (NMSEntity) nmsEntity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -26,7 +26,10 @@ public class DefaultHolographicDisplaysAPIProvider extends HolographicDisplaysAP
|
||||
// Optimization: avoid creating a new instance every time a plugin requires it, in case it never stores a reference
|
||||
private final Map<Plugin, HolographicDisplaysAPI> apiInstanceCache;
|
||||
|
||||
public DefaultHolographicDisplaysAPIProvider(APIHologramManager apiHologramManager, NMSManager nmsManager, PlaceholderRegistry placeholderRegistry) {
|
||||
public DefaultHolographicDisplaysAPIProvider(
|
||||
APIHologramManager apiHologramManager,
|
||||
NMSManager nmsManager,
|
||||
PlaceholderRegistry placeholderRegistry) {
|
||||
this.apiHologramManager = apiHologramManager;
|
||||
this.nmsManager = nmsManager;
|
||||
this.placeholderRegistry = placeholderRegistry;
|
||||
|
@ -33,7 +33,7 @@ public class ServerPinger {
|
||||
writeByteArray(out, handshakeBytes.toByteArray());
|
||||
|
||||
// Status request packet
|
||||
writeByteArray(out, new byte[]{ 0x00 }); // Packet ID
|
||||
writeByteArray(out, new byte[]{0x00}); // Packet ID
|
||||
|
||||
// Response packet
|
||||
readVarInt(in); // Packet size
|
||||
|
@ -22,9 +22,9 @@ class DebugHelper {
|
||||
|
||||
public static void printInformation(PacketEvent event) {
|
||||
String verb = event.isServerPacket() ? "Sent" : "Received";
|
||||
String format = event.isServerPacket() ?
|
||||
"%s %s to %s" :
|
||||
"%s %s from %s";
|
||||
String format = event.isServerPacket()
|
||||
? "%s %s to %s"
|
||||
: "%s %s from %s";
|
||||
|
||||
String shortDescription = String.format(format,
|
||||
event.isCancelled() ? "Cancelled" : verb,
|
||||
@ -33,7 +33,7 @@ class DebugHelper {
|
||||
);
|
||||
|
||||
// Detailed will print the packet's content too
|
||||
try {
|
||||
try {
|
||||
System.out.println(shortDescription + ":\n" + getPacketDescription(event.getPacket()));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
@ -47,33 +47,38 @@ class DebugHelper {
|
||||
Class<?> clazz = packet.getClass();
|
||||
|
||||
// Get the first Minecraft super class
|
||||
while (clazz != null && clazz != Object.class &&
|
||||
(!MinecraftReflection.isMinecraftClass(clazz) ||
|
||||
Factory.class.isAssignableFrom(clazz))) {
|
||||
while (clazz != null
|
||||
&& clazz != Object.class
|
||||
&& (!MinecraftReflection.isMinecraftClass(clazz) || Factory.class.isAssignableFrom(clazz))) {
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
|
||||
return PrettyPrinter.printObject(packet, clazz, MinecraftReflection.getPacketClass(), PrettyPrinter.RECURSE_DEPTH, (StringBuilder output, Object value) -> {
|
||||
// Special case
|
||||
if (value instanceof byte[]) {
|
||||
byte[] data = (byte[]) value;
|
||||
|
||||
if (data.length > HEX_DUMP_THRESHOLD) {
|
||||
output.append("[");
|
||||
HexDumper.defaultDumper().appendTo(output, data);
|
||||
output.append("]");
|
||||
return true;
|
||||
}
|
||||
} else if (value != null) {
|
||||
EquivalentConverter<Object> converter = findConverter(value.getClass());
|
||||
return PrettyPrinter.printObject(
|
||||
packet,
|
||||
clazz,
|
||||
MinecraftReflection.getPacketClass(),
|
||||
PrettyPrinter.RECURSE_DEPTH,
|
||||
(StringBuilder output, Object value) -> {
|
||||
// Special case
|
||||
if (value instanceof byte[]) {
|
||||
byte[] data = (byte[]) value;
|
||||
|
||||
if (converter != null) {
|
||||
output.append(converter.getSpecific(value));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (data.length > HEX_DUMP_THRESHOLD) {
|
||||
output.append("[");
|
||||
HexDumper.defaultDumper().appendTo(output, data);
|
||||
output.append("]");
|
||||
return true;
|
||||
}
|
||||
} else if (value != null) {
|
||||
EquivalentConverter<Object> converter = findConverter(value.getClass());
|
||||
|
||||
if (converter != null) {
|
||||
output.append(converter.getSpecific(value));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -83,10 +88,11 @@ class DebugHelper {
|
||||
while (clazz != null) {
|
||||
EquivalentConverter<Object> result = converters.get(clazz);
|
||||
|
||||
if (result != null)
|
||||
if (result != null) {
|
||||
return result;
|
||||
else
|
||||
} else {
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class MetadataHelper {
|
||||
private Serializer chatComponentSerializer;
|
||||
|
||||
|
||||
public MetadataHelper() {
|
||||
MetadataHelper() {
|
||||
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_14_R1)) {
|
||||
itemSlotIndex = 7;
|
||||
} else if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_10_R1)) {
|
||||
@ -113,7 +113,7 @@ class MetadataHelper {
|
||||
|
||||
return ((Optional<?>) customNameNMSObject).orElse(null);
|
||||
|
||||
} else {
|
||||
} else {
|
||||
if (!(customNameNMSObject instanceof String)) {
|
||||
throw new IllegalArgumentException("Expected custom name of type " + String.class);
|
||||
}
|
||||
@ -136,9 +136,13 @@ class MetadataHelper {
|
||||
requireMinimumVersion(NMSVersion.v1_9_R1);
|
||||
|
||||
if (customNameUsesChatComponents) {
|
||||
dataWatcher.setObject(new WrappedDataWatcherObject(customNameIndex, chatComponentSerializer), Optional.ofNullable(customNameNMSObject));
|
||||
dataWatcher.setObject(
|
||||
new WrappedDataWatcherObject(customNameIndex, chatComponentSerializer),
|
||||
Optional.ofNullable(customNameNMSObject));
|
||||
} else {
|
||||
dataWatcher.setObject(new WrappedDataWatcherObject(customNameIndex, stringSerializer), customNameNMSObject);
|
||||
dataWatcher.setObject(
|
||||
new WrappedDataWatcherObject(customNameIndex, stringSerializer),
|
||||
customNameNMSObject);
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,9 +167,13 @@ class MetadataHelper {
|
||||
public void setItemMetadata(WrappedDataWatcher dataWatcher, Object nmsItemStack) {
|
||||
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_9_R1)) {
|
||||
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_11_R1)) {
|
||||
dataWatcher.setObject(new WrappedDataWatcherObject(itemSlotIndex, itemSerializer), nmsItemStack);
|
||||
dataWatcher.setObject(
|
||||
new WrappedDataWatcherObject(itemSlotIndex, itemSerializer),
|
||||
nmsItemStack);
|
||||
} else {
|
||||
dataWatcher.setObject(new WrappedDataWatcherObject(itemSlotIndex, itemSerializer), com.google.common.base.Optional.of(nmsItemStack));
|
||||
dataWatcher.setObject(
|
||||
new WrappedDataWatcherObject(itemSlotIndex, itemSerializer),
|
||||
com.google.common.base.Optional.of(nmsItemStack));
|
||||
}
|
||||
dataWatcher.setObject(new WrappedDataWatcherObject(airLevelIndex, intSerializer), 300);
|
||||
dataWatcher.setObject(new WrappedDataWatcherObject(entityStatusIndex, byteSerializer), (byte) 0);
|
||||
|
@ -35,7 +35,7 @@ class PacketListener extends PacketAdapter {
|
||||
private final MetadataHelper metadataHelper;
|
||||
private final ProtocolPacketSettings packetSettings;
|
||||
|
||||
public PacketListener(Plugin plugin, NMSManager nmsManager, MetadataHelper metadataHelper, ProtocolPacketSettings packetSettings) {
|
||||
PacketListener(Plugin plugin, NMSManager nmsManager, MetadataHelper metadataHelper, ProtocolPacketSettings packetSettings) {
|
||||
super(PacketAdapter.params()
|
||||
.plugin(plugin)
|
||||
.types(
|
||||
@ -132,31 +132,34 @@ class PacketListener extends PacketAdapter {
|
||||
event.setPacket(packetWrapper.getHandle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean replaceRelativePlaceholders(WrappedWatchableObject customNameWatchableObject, Player player, Collection<RelativePlaceholder> relativePlaceholders) {
|
||||
}
|
||||
|
||||
private boolean replaceRelativePlaceholders(
|
||||
WrappedWatchableObject customNameWatchableObject,
|
||||
Player player,
|
||||
Collection<RelativePlaceholder> relativePlaceholders) {
|
||||
if (customNameWatchableObject == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
final Object originalCustomNameNMSObject = metadataHelper.getCustomNameNMSObject(customNameWatchableObject);
|
||||
if (originalCustomNameNMSObject == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Object replacedCustomNameNMSObject = originalCustomNameNMSObject;
|
||||
for (RelativePlaceholder relativePlaceholder : relativePlaceholders) {
|
||||
replacedCustomNameNMSObject = nmsManager.getCustomNameEditor().replaceCustomName(
|
||||
replacedCustomNameNMSObject,
|
||||
relativePlaceholder.getTextPlaceholder(),
|
||||
replacedCustomNameNMSObject,
|
||||
relativePlaceholder.getTextPlaceholder(),
|
||||
relativePlaceholder.getReplacement(player));
|
||||
}
|
||||
|
||||
|
||||
if (replacedCustomNameNMSObject == originalCustomNameNMSObject) {
|
||||
// It means nothing has been replaced, since original custom name has been returned
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
metadataHelper.setCustomNameNMSObject(customNameWatchableObject, replacedCustomNameNMSObject);
|
||||
return true;
|
||||
}
|
||||
|
@ -33,13 +33,13 @@ class PacketSender {
|
||||
|
||||
private final MetadataHelper metadataHelper;
|
||||
|
||||
public PacketSender(MetadataHelper metadataHelper) {
|
||||
PacketSender(MetadataHelper metadataHelper) {
|
||||
this.metadataHelper = metadataHelper;
|
||||
}
|
||||
|
||||
public void sendDestroyEntitiesPacket(Player player, StandardHologram hologram) {
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
for (StandardHologramLine line : hologram.getLines()) {
|
||||
for (StandardHologramLine line : hologram.getLines()) {
|
||||
line.collectTrackedEntityIDs(player, ids);
|
||||
}
|
||||
|
||||
@ -96,13 +96,15 @@ class PacketSender {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendSpawnArmorStandPacket(Player receiver, NMSArmorStand armorStand) {
|
||||
private void sendSpawnArmorStandPacket(Player receiver, NMSArmorStand armorStand) {
|
||||
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_11_R1)) {
|
||||
AbstractPacket spawnPacket;
|
||||
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_14_R1)) {
|
||||
spawnPacket = new WrapperPlayServerSpawnEntityLiving(armorStand.getBukkitEntityNMS());
|
||||
} else {
|
||||
spawnPacket = new WrapperPlayServerSpawnEntity(armorStand.getBukkitEntityNMS(), WrapperPlayServerSpawnEntity.ObjectTypes.ARMOR_STAND, 1);
|
||||
spawnPacket = new WrapperPlayServerSpawnEntity(
|
||||
armorStand.getBukkitEntityNMS(),
|
||||
WrapperPlayServerSpawnEntity.ObjectTypes.ARMOR_STAND, 1);
|
||||
}
|
||||
spawnPacket.sendPacket(receiver);
|
||||
|
||||
@ -167,7 +169,7 @@ class PacketSender {
|
||||
}
|
||||
|
||||
|
||||
private void sendVehicleAttachPacket(Player receiver, NMSEntity vehicle, NMSEntity passenger) {
|
||||
private void sendVehicleAttachPacket(Player receiver, NMSEntity vehicle, NMSEntity passenger) {
|
||||
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_9_R1)) {
|
||||
WrapperPlayServerMount packet = new WrapperPlayServerMount();
|
||||
packet.setVehicleId(vehicle.getIdNMS());
|
||||
|
@ -47,7 +47,8 @@ public class ProtocolLibHook {
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
errorCollector.add(e, "could not detect ProtocolLib version (" + e.getMessage() + "), enabling support anyway and hoping for the best");
|
||||
errorCollector.add(e, "could not detect ProtocolLib version (" + e.getMessage() + "),"
|
||||
+ " enabling support anyway and hoping for the best");
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -30,23 +30,21 @@ public abstract class AbstractPacket {
|
||||
|
||||
/**
|
||||
* Constructs a new strongly typed wrapper for the given packet.
|
||||
* @param handle - handle to the raw packet data.
|
||||
* @param type - the packet type.
|
||||
*/
|
||||
protected AbstractPacket(PacketContainer handle, PacketType type) {
|
||||
// Make sure we're given a valid packet
|
||||
if (handle == null)
|
||||
if (handle == null) {
|
||||
throw new IllegalArgumentException("Packet handle cannot be NULL.");
|
||||
if (!Objects.equal(handle.getType(), type))
|
||||
throw new IllegalArgumentException(
|
||||
handle.getHandle() + " is not a packet of type " + type);
|
||||
}
|
||||
if (!Objects.equal(handle.getType(), type)) {
|
||||
throw new IllegalArgumentException(handle.getHandle() + " is not a packet of type " + type);
|
||||
}
|
||||
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a handle to the raw packet data.
|
||||
* @return Raw packet data.
|
||||
*/
|
||||
public PacketContainer getHandle() {
|
||||
return handle;
|
||||
@ -54,7 +52,7 @@ public abstract class AbstractPacket {
|
||||
|
||||
/**
|
||||
* Send the current packet to the given receiver.
|
||||
* @param receiver - the receiver.
|
||||
*
|
||||
* @throws RuntimeException If the packet cannot be sent.
|
||||
*/
|
||||
public void sendPacket(Player receiver) {
|
||||
@ -67,7 +65,7 @@ public abstract class AbstractPacket {
|
||||
|
||||
/**
|
||||
* Simulate receiving the current packet from the given sender.
|
||||
* @param sender - the sender.
|
||||
*
|
||||
* @throws RuntimeException If the packet cannot be received.
|
||||
*/
|
||||
public void receivePacket(Player sender) {
|
||||
|
@ -36,6 +36,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve whether or not the entity is leached onto the vehicle.
|
||||
*
|
||||
* @return TRUE if it is, FALSE otherwise.
|
||||
*/
|
||||
public boolean getLeached() {
|
||||
@ -44,6 +45,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Set whether or not the entity is leached onto the vehicle.
|
||||
*
|
||||
* @param value - TRUE if it is leached, FALSE otherwise.
|
||||
*/
|
||||
public void setLeached(boolean value) {
|
||||
@ -52,6 +54,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the player entity ID being attached.
|
||||
*
|
||||
* @return The current Entity ID
|
||||
*/
|
||||
public int getEntityId() {
|
||||
@ -60,6 +63,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Set the player entity ID being attached.
|
||||
*
|
||||
* @param value - new value.
|
||||
*/
|
||||
public void setEntityId(int value) {
|
||||
@ -68,6 +72,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the entity being attached.
|
||||
*
|
||||
* @param world - the current world of the entity.
|
||||
* @return The entity.
|
||||
*/
|
||||
@ -77,6 +82,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the entity being attached.
|
||||
*
|
||||
* @param event - the packet event.
|
||||
* @return The entity.
|
||||
*/
|
||||
@ -86,6 +92,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the vehicle entity ID attached to (-1 for unattaching).
|
||||
*
|
||||
* @return The current Vehicle ID
|
||||
*/
|
||||
public int getVehicleId() {
|
||||
@ -94,6 +101,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Set the vehicle entity ID attached to (-1 for unattaching).
|
||||
*
|
||||
* @param value - new value.
|
||||
*/
|
||||
public void setVehicleId(int value) {
|
||||
@ -102,6 +110,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the vehicle entity attached to (NULL for unattaching).
|
||||
*
|
||||
* @param world - the current world of the entity.
|
||||
* @return The vehicle.
|
||||
*/
|
||||
@ -111,6 +120,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the vehicle entity attached to (NULL for unattaching).
|
||||
*
|
||||
* @param event - the packet event.
|
||||
* @return The vehicle.
|
||||
*/
|
||||
|
@ -36,7 +36,6 @@ public class WrapperPlayServerEntityDestroy extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the IDs of the entities that will be destroyed.
|
||||
* @return The current entities.
|
||||
*/
|
||||
public List<Integer> getEntities() {
|
||||
return Ints.asList(handle.getIntegerArrays().read(0));
|
||||
@ -44,7 +43,6 @@ public class WrapperPlayServerEntityDestroy extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Set the entities that will be destroyed.
|
||||
* @param value - new value.
|
||||
*/
|
||||
public void setEntities(int[] entities) {
|
||||
handle.getIntegerArrays().write(0, entities);
|
||||
@ -52,7 +50,6 @@ public class WrapperPlayServerEntityDestroy extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Set the entities that will be destroyed.
|
||||
* @param value - new value.
|
||||
*/
|
||||
public void setEntities(List<Integer> entities) {
|
||||
setEntities(Ints.toArray(entities));
|
||||
|
@ -40,7 +40,6 @@ public class WrapperPlayServerEntityMetadata extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve unique entity ID to update.
|
||||
* @return The current Entity ID
|
||||
*/
|
||||
public int getEntityID() {
|
||||
return handle.getIntegers().read(0);
|
||||
@ -48,7 +47,6 @@ public class WrapperPlayServerEntityMetadata extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Set unique entity ID to update.
|
||||
* @param value - new value.
|
||||
*/
|
||||
public void setEntityID(int value) {
|
||||
handle.getIntegers().write(0, value);
|
||||
@ -56,8 +54,6 @@ public class WrapperPlayServerEntityMetadata extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the entity.
|
||||
* @param world - the current world of the entity.
|
||||
* @return The entity.
|
||||
*/
|
||||
public Entity getEntity(World world) {
|
||||
return handle.getEntityModifier(world).read(0);
|
||||
@ -65,26 +61,23 @@ public class WrapperPlayServerEntityMetadata extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the entity.
|
||||
* @param event - the packet event.
|
||||
* @return The entity.
|
||||
*/
|
||||
public Entity getEntity(PacketEvent event) {
|
||||
return getEntity(event.getPlayer().getWorld());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve a list of all the watchable objects.
|
||||
* <p>
|
||||
* This can be converted to a data watcher using {@link WrappedDataWatcher#WrappedDataWatcher(List) WrappedDataWatcher(List)}
|
||||
* @return The current metadata
|
||||
*/
|
||||
* This can be converted to a data watcher using {@link WrappedDataWatcher#WrappedDataWatcher(List)
|
||||
* WrappedDataWatcher(List)}
|
||||
*/
|
||||
public List<WrappedWatchableObject> getEntityMetadata() {
|
||||
return handle.getWatchableCollectionModifier().read(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of the watchable objects (meta data).
|
||||
* @param value - new value.
|
||||
*/
|
||||
public void setEntityMetadata(List<WrappedWatchableObject> value) {
|
||||
handle.getWatchableCollectionModifier().write(0, value);
|
||||
|
@ -36,40 +36,35 @@ public class WrapperPlayServerMount extends AbstractPacket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the player entity ID being attached.
|
||||
* @return The current Entity ID
|
||||
* Retrieve the entity ID being attached.
|
||||
*/
|
||||
public int getVehicleId() {
|
||||
return handle.getIntegers().read(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the player entity ID being attached.
|
||||
* @param value - new value.
|
||||
* Set the entity ID being attached.
|
||||
*/
|
||||
public void setVehicleId(int value) {
|
||||
handle.getIntegers().write(0, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the IDs of the entities that will be destroyed.
|
||||
* @return The current entities.
|
||||
* Retrieve the IDs of the passenger entities.
|
||||
*/
|
||||
public List<Integer> getPassengers() {
|
||||
return Ints.asList(handle.getIntegerArrays().read(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the entities that will be destroyed.
|
||||
* @param value - new value.
|
||||
* Set the passenger entities.
|
||||
*/
|
||||
public void setPassengers(int[] entities) {
|
||||
handle.getIntegerArrays().write(0, entities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the entities that will be destroyed.
|
||||
* @param value - new value.
|
||||
* Set the passenger entities.
|
||||
*/
|
||||
public void setPassengers(List<Integer> entities) {
|
||||
setPassengers(Ints.toArray(entities));
|
||||
|
@ -33,7 +33,7 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Represents the different object types.
|
||||
*
|
||||
*
|
||||
* @author Kristian
|
||||
*/
|
||||
public static class ObjectTypes extends IntEnum {
|
||||
@ -68,7 +68,6 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve an instance of the object types enum.
|
||||
* @return Object type enum.
|
||||
*/
|
||||
public static ObjectTypes getInstance() {
|
||||
return INSTANCE;
|
||||
@ -107,7 +106,6 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve entity ID of the Object.
|
||||
* @return The current EID
|
||||
*/
|
||||
public int getEntityID() {
|
||||
return handle.getIntegers().read(0);
|
||||
@ -115,8 +113,6 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the entity that will be spawned.
|
||||
* @param world - the current world of the entity.
|
||||
* @return The spawned entity.
|
||||
*/
|
||||
public Entity getEntity(World world) {
|
||||
return handle.getEntityModifier(world).read(0);
|
||||
@ -124,8 +120,6 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the entity that will be spawned.
|
||||
* @param event - the packet event.
|
||||
* @return The spawned entity.
|
||||
*/
|
||||
public Entity getEntity(PacketEvent event) {
|
||||
return getEntity(event.getPlayer().getWorld());
|
||||
@ -133,7 +127,6 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Set entity ID of the Object.
|
||||
* @param value - new value.
|
||||
*/
|
||||
public void setEntityID(int value) {
|
||||
handle.getIntegers().write(0, value);
|
||||
@ -141,7 +134,6 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the type of object. See {@link ObjectTypes}
|
||||
* @return The current Type
|
||||
*/
|
||||
public int getType() {
|
||||
return handle.getIntegers().read(6);
|
||||
@ -149,7 +141,6 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Set the type of object. See {@link ObjectTypes}.
|
||||
* @param value - new value.
|
||||
*/
|
||||
public void setType(int value) {
|
||||
handle.getIntegers().write(6, value);
|
||||
|
@ -46,14 +46,14 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket {
|
||||
|
||||
// Useful constructor
|
||||
private static PacketContainer fromEntity(Entity entity) {
|
||||
if (entityConstructor == null)
|
||||
if (entityConstructor == null) {
|
||||
entityConstructor = ProtocolLibrary.getProtocolManager().createPacketConstructor(TYPE, entity);
|
||||
}
|
||||
return entityConstructor.createPacket(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve entity ID.
|
||||
* @return The current EID
|
||||
*/
|
||||
public int getEntityID() {
|
||||
return handle.getIntegers().read(0);
|
||||
@ -61,8 +61,6 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the entity that will be spawned.
|
||||
* @param world - the current world of the entity.
|
||||
* @return The spawned entity.
|
||||
*/
|
||||
public Entity getEntity(World world) {
|
||||
return handle.getEntityModifier(world).read(0);
|
||||
@ -70,8 +68,6 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the entity that will be spawned.
|
||||
* @param event - the packet event.
|
||||
* @return The spawned entity.
|
||||
*/
|
||||
public Entity getEntity(PacketEvent event) {
|
||||
return getEntity(event.getPlayer().getWorld());
|
||||
@ -79,7 +75,6 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Set entity ID.
|
||||
* @param value - new value.
|
||||
*/
|
||||
public void setEntityID(int value) {
|
||||
handle.getIntegers().write(0, value);
|
||||
@ -87,7 +82,6 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Retrieve the type of mob.
|
||||
* @return The current Type
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public EntityType getType() {
|
||||
@ -96,7 +90,6 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Set the type of mob.
|
||||
* @param value - new value.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setType(EntityType value) {
|
||||
@ -107,7 +100,6 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket {
|
||||
* Retrieve the data watcher.
|
||||
* <p>
|
||||
* Content varies by mob, see Entities.
|
||||
* @return The current Metadata
|
||||
*/
|
||||
public WrappedDataWatcher getMetadata() {
|
||||
return handle.getDataWatcherModifier().read(0);
|
||||
@ -115,7 +107,6 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket {
|
||||
|
||||
/**
|
||||
* Set the data watcher.
|
||||
* @param value - new value.
|
||||
*/
|
||||
public void setMetadata(WrappedDataWatcher value) {
|
||||
handle.getDataWatcherModifier().write(0, value);
|
||||
|
@ -32,9 +32,9 @@ import me.filoghost.holographicdisplays.commands.subs.RemovelineCommand;
|
||||
import me.filoghost.holographicdisplays.commands.subs.SetlineCommand;
|
||||
import me.filoghost.holographicdisplays.commands.subs.TeleportCommand;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.nms.NMSManager;
|
||||
import me.filoghost.holographicdisplays.disk.ConfigManager;
|
||||
import me.filoghost.holographicdisplays.disk.Configuration;
|
||||
import me.filoghost.holographicdisplays.core.nms.NMSManager;
|
||||
import me.filoghost.holographicdisplays.object.internal.InternalHologram;
|
||||
import me.filoghost.holographicdisplays.object.internal.InternalHologramManager;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
@ -54,12 +54,12 @@ import java.util.logging.Level;
|
||||
public class HologramCommandManager extends SubCommandManager {
|
||||
|
||||
private final List<HologramSubCommand> subCommands;
|
||||
|
||||
private final HelpCommand helpCommand;
|
||||
|
||||
public HologramCommandManager(ConfigManager configManager, InternalHologramManager internalHologramManager, NMSManager nmsManager) {
|
||||
setName("holograms");
|
||||
subCommands = new ArrayList<>();
|
||||
this.helpCommand = new HelpCommand(this);
|
||||
this.subCommands = new ArrayList<>();
|
||||
|
||||
subCommands.add(new AddlineCommand(this, internalHologramManager, configManager));
|
||||
subCommands.add(new CreateCommand(internalHologramManager, configManager));
|
||||
@ -81,7 +81,7 @@ public class HologramCommandManager extends SubCommandManager {
|
||||
subCommands.add(new InfoCommand(this, internalHologramManager));
|
||||
|
||||
subCommands.add(new DebugCommand(nmsManager));
|
||||
subCommands.add(helpCommand = new HelpCommand(this));
|
||||
subCommands.add(helpCommand);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -132,8 +132,8 @@ public class HologramCommandManager extends SubCommandManager {
|
||||
message.append("[" + quickEditCommand.getActionName() + "]").color(ChatColor.DARK_AQUA)
|
||||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, usage))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(
|
||||
ChatColor.GRAY + "Click to insert in chat the highlighted part of the command:\n" +
|
||||
ChatColor.YELLOW + usage + ChatColor.DARK_GRAY + usageArgs)));
|
||||
ChatColor.GRAY + "Click to insert in chat the highlighted part of the command:\n"
|
||||
+ ChatColor.YELLOW + usage + ChatColor.DARK_GRAY + usageArgs)));
|
||||
message.append(" ", FormatRetention.NONE);
|
||||
}
|
||||
|
||||
@ -148,7 +148,9 @@ public class HologramCommandManager extends SubCommandManager {
|
||||
@Override
|
||||
protected void sendNoArgsMessage(CommandContext context) {
|
||||
CommandSender sender = context.getSender();
|
||||
sender.sendMessage(Colors.PRIMARY_SHADOW + "Server is running " + Colors.PRIMARY + "Holographic Displays " + Colors.PRIMARY_SHADOW + "v" + HolographicDisplays.getInstance().getDescription().getVersion() + " by " + Colors.PRIMARY + "filoghost");
|
||||
String version = HolographicDisplays.getInstance().getDescription().getVersion();
|
||||
sender.sendMessage(Colors.PRIMARY_SHADOW + "Server is running " + Colors.PRIMARY + "Holographic Displays "
|
||||
+ Colors.PRIMARY_SHADOW + "v" + version + " by " + Colors.PRIMARY + "filoghost");
|
||||
if (helpCommand.hasPermission(sender)) {
|
||||
sender.sendMessage(Colors.PRIMARY_SHADOW + "Commands: " + Colors.PRIMARY + helpCommand.getFullUsageText(context));
|
||||
}
|
||||
|
@ -28,7 +28,8 @@ public class HologramCommandValidate {
|
||||
}
|
||||
}
|
||||
|
||||
public static InternalHologram getInternalHologram(InternalHologramManager internalHologramManager, String hologramName) throws CommandException {
|
||||
public static InternalHologram getInternalHologram(InternalHologramManager internalHologramManager, String hologramName)
|
||||
throws CommandException {
|
||||
InternalHologram hologram = internalHologramManager.getHologramByName(hologramName);
|
||||
CommandValidate.notNull(hologram, "Cannot find a hologram named \"" + hologramName + "\".");
|
||||
return hologram;
|
||||
@ -36,8 +37,10 @@ public class HologramCommandValidate {
|
||||
|
||||
public static Path getUserReadableFile(Path dataFolder, String fileName) throws CommandException {
|
||||
Path targetFile = dataFolder.resolve(fileName);
|
||||
CommandValidate.check(FileUtils.isInsideDirectory(targetFile, dataFolder), "The specified file must be inside HolographicDisplays' folder.");
|
||||
CommandValidate.check(Files.exists(targetFile), "The specified file \"" + fileName + "\" does not exist inside HolographicDisplays' folder.");
|
||||
CommandValidate.check(FileUtils.isInsideDirectory(targetFile, dataFolder),
|
||||
"The specified file must be inside HolographicDisplays' folder.");
|
||||
CommandValidate.check(Files.exists(targetFile),
|
||||
"The specified file \"" + fileName + "\" does not exist inside HolographicDisplays' folder.");
|
||||
CommandValidate.check(!Files.isDirectory(targetFile), "The file cannot be a folder.");
|
||||
CommandValidate.check(!isConfigFile(targetFile), "Cannot read YML configuration files.");
|
||||
return targetFile;
|
||||
|
@ -12,7 +12,8 @@ import org.bukkit.command.CommandSender;
|
||||
public class Messages {
|
||||
|
||||
public static void sendTitle(CommandSender recipient, String title) {
|
||||
recipient.sendMessage("" + Colors.PRIMARY_SHADOW + ChatColor.BOLD + "----- " + title + Colors.PRIMARY_SHADOW + ChatColor.BOLD + " -----");
|
||||
recipient.sendMessage("" + Colors.PRIMARY_SHADOW + ChatColor.BOLD + "----- "
|
||||
+ title + Colors.PRIMARY_SHADOW + ChatColor.BOLD + " -----");
|
||||
}
|
||||
|
||||
public static void sendTip(CommandSender recipient, String tip) {
|
||||
@ -20,7 +21,8 @@ public class Messages {
|
||||
}
|
||||
|
||||
public static void sendWarning(CommandSender recipient, String warning) {
|
||||
recipient.sendMessage(ChatColor.RED + "( " + ChatColor.DARK_RED + ChatColor.BOLD + "!" + ChatColor.RED + " ) " + Colors.SECONDARY_SHADOW + warning);
|
||||
recipient.sendMessage(ChatColor.RED + "( " + ChatColor.DARK_RED + ChatColor.BOLD + "!" + ChatColor.RED + " ) "
|
||||
+ Colors.SECONDARY_SHADOW + warning);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,10 @@ public class AddlineCommand extends LineEditingCommand implements QuickEditComma
|
||||
private final InternalHologramManager internalHologramManager;
|
||||
private final ConfigManager configManager;
|
||||
|
||||
public AddlineCommand(HologramCommandManager commandManager, InternalHologramManager internalHologramManager, ConfigManager configManager) {
|
||||
public AddlineCommand(
|
||||
HologramCommandManager commandManager,
|
||||
InternalHologramManager internalHologramManager,
|
||||
ConfigManager configManager) {
|
||||
super("addline");
|
||||
setMinArgs(2);
|
||||
setUsageArgs("<hologram> <text>");
|
||||
|
@ -58,7 +58,9 @@ public class AlignCommand extends HologramSubCommand {
|
||||
hologram.teleport(loc);
|
||||
|
||||
configManager.saveHologramDatabase(internalHologramManager);
|
||||
sender.sendMessage(Colors.PRIMARY + "Hologram \"" + hologram.getName() + "\" aligned to the hologram \"" + referenceHologram.getName() + "\" on the " + axis.toUpperCase() + " axis.");
|
||||
sender.sendMessage(Colors.PRIMARY + "Hologram \"" + hologram.getName() + "\""
|
||||
+ " aligned to the hologram \"" + referenceHologram.getName() + "\""
|
||||
+ " on the " + axis.toUpperCase() + " axis.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -48,7 +48,8 @@ public class CopyCommand extends HologramSubCommand {
|
||||
|
||||
configManager.saveHologramDatabase(internalHologramManager);
|
||||
|
||||
sender.sendMessage(Colors.PRIMARY + "Hologram \"" + fromHologram.getName() + "\" copied into hologram \"" + toHologram.getName() + "\".");
|
||||
sender.sendMessage(Colors.PRIMARY + "Hologram \"" + fromHologram.getName() + "\""
|
||||
+ " copied into hologram \"" + toHologram.getName() + "\".");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -66,7 +66,8 @@ public class CreateCommand extends HologramSubCommand {
|
||||
CommandValidate.check(!text.equalsIgnoreCase("{empty}"), "The first line should not be empty.");
|
||||
|
||||
line = HologramCommandValidate.parseHologramLine(hologram, text);
|
||||
player.sendMessage(Colors.SECONDARY_SHADOW + "(Change the lines with /" + context.getRootLabel() + " edit " + hologram.getName() + ")");
|
||||
player.sendMessage(Colors.SECONDARY_SHADOW + "(Change the lines with /" + context.getRootLabel()
|
||||
+ " edit " + hologram.getName() + ")");
|
||||
} else {
|
||||
String defaultText = "Default hologram. Change it with "
|
||||
+ Colors.PRIMARY + "/" + context.getRootLabel() + " edit " + hologram.getName();
|
||||
@ -82,7 +83,10 @@ public class CreateCommand extends HologramSubCommand {
|
||||
player.sendMessage(Colors.PRIMARY + "You created a hologram named '" + hologram.getName() + "'.");
|
||||
|
||||
if (moveUp) {
|
||||
player.sendMessage(Colors.SECONDARY_SHADOW + "(You were on the ground, the hologram was automatically moved up. If you use /" + context.getRootLabel() + " movehere " + hologram.getName() + ", the hologram will be moved to your feet)");
|
||||
player.sendMessage(Colors.SECONDARY_SHADOW + "(You were on the ground,"
|
||||
+ " the hologram was automatically moved up."
|
||||
+ " If you use /" + context.getRootLabel() + " movehere " + hologram.getName() + ","
|
||||
+ " the hologram will be moved to your feet)");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class DebugCommand extends HologramSubCommand {
|
||||
}
|
||||
|
||||
StandardHologram ownerHologram = nmsEntity.getHologramLine().getHologram();
|
||||
HologramDebugInfo hologramDebugInfo = hologramsDebugInfo.computeIfAbsent(ownerHologram, mapKey -> new HologramDebugInfo());
|
||||
HologramDebugInfo hologramDebugInfo = hologramsDebugInfo.computeIfAbsent(ownerHologram, key -> new HologramDebugInfo());
|
||||
|
||||
if (nmsEntity.isDeadNMS()) {
|
||||
hologramDebugInfo.deadEntities++;
|
||||
@ -66,8 +66,10 @@ public class DebugCommand extends HologramSubCommand {
|
||||
for (Entry<StandardHologram, HologramDebugInfo> entry : hologramsDebugInfo.entrySet()) {
|
||||
StandardHologram hologram = entry.getKey();
|
||||
HologramDebugInfo debugInfo = entry.getValue();
|
||||
sender.sendMessage(Colors.PRIMARY_SHADOW + "- '" + hologram.toFormattedString() + "': " + hologram.getLineCount() + " lines, "
|
||||
+ debugInfo.getTotalEntities() + " entities (" + debugInfo.aliveEntities + " alive, " + debugInfo.deadEntities + " dead)");
|
||||
sender.sendMessage(Colors.PRIMARY_SHADOW + "- '" + hologram.toFormattedString() + "':"
|
||||
+ " " + hologram.getLineCount() + " lines,"
|
||||
+ " " + debugInfo.getTotalEntities() + " entities"
|
||||
+ " (" + debugInfo.aliveEntities + " alive, " + debugInfo.deadEntities + " dead)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,12 +56,12 @@ public class EditCommand extends HologramSubCommand {
|
||||
for (String tutLine : subCommand.getDescription(context)) {
|
||||
help.add(Colors.SECONDARY_SHADOW + tutLine);
|
||||
}
|
||||
|
||||
|
||||
((Player) sender).spigot().sendMessage(new ComponentBuilder(usage)
|
||||
.color(ChatColor.AQUA)
|
||||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, usage))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(String.join("\n", help))))
|
||||
.create());
|
||||
.color(ChatColor.AQUA)
|
||||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, usage))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(String.join("\n", help))))
|
||||
.create());
|
||||
|
||||
} else {
|
||||
sender.sendMessage(Colors.PRIMARY + usage);
|
||||
|
@ -48,12 +48,12 @@ public class HelpCommand extends HologramSubCommand {
|
||||
for (String tutLine : subCommand.getDescription(context)) {
|
||||
help.add(Colors.SECONDARY_SHADOW + tutLine);
|
||||
}
|
||||
|
||||
|
||||
((Player) sender).spigot().sendMessage(new ComponentBuilder(usage)
|
||||
.color(ChatColor.AQUA)
|
||||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, usage))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(String.join("\n", help))))
|
||||
.create());
|
||||
.color(ChatColor.AQUA)
|
||||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, usage))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(String.join("\n", help))))
|
||||
.create());
|
||||
|
||||
} else {
|
||||
sender.sendMessage(Colors.PRIMARY + usage);
|
||||
@ -69,14 +69,16 @@ public class HelpCommand extends HologramSubCommand {
|
||||
public static void sendHoverTip(Player player) {
|
||||
player.sendMessage("");
|
||||
player.spigot().sendMessage(new ComponentBuilder("TIP:").color(ChatColor.YELLOW).bold(true)
|
||||
.append(" Try to ", FormatRetention.NONE).color(ChatColor.GRAY)
|
||||
.append("hover").color(ChatColor.WHITE).underlined(true)
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.LIGHT_PURPLE + "Hover on the commands to get info about them.")))
|
||||
.append(" or ", FormatRetention.NONE).color(ChatColor.GRAY)
|
||||
.append("click").color(ChatColor.WHITE).underlined(true)
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.LIGHT_PURPLE + "Click on the commands to insert them in the chat.")))
|
||||
.append(" on the commands.", FormatRetention.NONE).color(ChatColor.GRAY)
|
||||
.create());
|
||||
.append(" Try to ", FormatRetention.NONE).color(ChatColor.GRAY)
|
||||
.append("hover").color(ChatColor.WHITE).underlined(true)
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
TextComponent.fromLegacyText(ChatColor.LIGHT_PURPLE + "Hover on the commands to get info about them.")))
|
||||
.append(" or ", FormatRetention.NONE).color(ChatColor.GRAY)
|
||||
.append("click").color(ChatColor.WHITE).underlined(true)
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
TextComponent.fromLegacyText(ChatColor.LIGHT_PURPLE + "Click on the commands to insert them in the chat.")))
|
||||
.append(" on the commands.", FormatRetention.NONE).color(ChatColor.GRAY)
|
||||
.create());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,9 @@ public class InfoCommand extends LineEditingCommand implements QuickEditCommand
|
||||
int index = 0;
|
||||
|
||||
for (InternalHologramLine line : hologram.getLines()) {
|
||||
sender.sendMessage(Colors.SECONDARY + Colors.BOLD + (++index) + Colors.SECONDARY_SHADOW + ". " + Colors.SECONDARY + line.getSerializedConfigValue());
|
||||
index++;
|
||||
sender.sendMessage(Colors.SECONDARY + Colors.BOLD + index
|
||||
+ Colors.SECONDARY_SHADOW + ". " + Colors.SECONDARY + line.getSerializedConfigValue());
|
||||
}
|
||||
commandManager.sendQuickEditCommands(context, hologram);
|
||||
}
|
||||
|
@ -26,8 +26,11 @@ public class InsertlineCommand extends LineEditingCommand implements QuickEditCo
|
||||
private final HologramCommandManager commandManager;
|
||||
private final InternalHologramManager internalHologramManager;
|
||||
private final ConfigManager configManager;
|
||||
|
||||
public InsertlineCommand(HologramCommandManager commandManager, InternalHologramManager internalHologramManager, ConfigManager configManager) {
|
||||
|
||||
public InsertlineCommand(
|
||||
HologramCommandManager commandManager,
|
||||
InternalHologramManager internalHologramManager,
|
||||
ConfigManager configManager) {
|
||||
super("insertline");
|
||||
setMinArgs(3);
|
||||
setUsageArgs("<hologram> <lineNumber> <text>");
|
||||
@ -49,7 +52,8 @@ public class InsertlineCommand extends LineEditingCommand implements QuickEditCo
|
||||
|
||||
int oldLinesAmount = hologram.getLineCount();
|
||||
|
||||
CommandValidate.check(insertAfterIndex >= 0 && insertAfterIndex <= oldLinesAmount, "The number must be between 0 and " + hologram.getLineCount() + "(amount of lines of the hologram).");
|
||||
CommandValidate.check(insertAfterIndex >= 0 && insertAfterIndex <= oldLinesAmount,
|
||||
"The number must be between 0 and " + hologram.getLineCount() + "(amount of lines of the hologram).");
|
||||
|
||||
InternalHologramLine line = HologramCommandValidate.parseHologramLine(hologram, serializedLine);
|
||||
hologram.insertLine(insertAfterIndex, line);
|
||||
|
@ -53,7 +53,12 @@ public class NearCommand extends HologramSubCommand {
|
||||
|
||||
Messages.sendTitle(player, "Near holograms");
|
||||
for (InternalHologram nearHologram : nearHolograms) {
|
||||
player.sendMessage(Colors.SECONDARY_SHADOW + "- " + Colors.SECONDARY + Colors.BOLD + nearHologram.getName() + " " + Colors.SECONDARY_SHADOW + "at x: " + (int) nearHologram.getX() + ", y: " + (int) nearHologram.getY() + ", z: " + (int) nearHologram.getZ() + " (lines: " + nearHologram.getLineCount() + ")");
|
||||
player.sendMessage(Colors.SECONDARY_SHADOW + "- "
|
||||
+ Colors.SECONDARY + Colors.BOLD + nearHologram.getName() + " " + Colors.SECONDARY_SHADOW + "at"
|
||||
+ " x: " + (int) nearHologram.getX() + ","
|
||||
+ " y: " + (int) nearHologram.getY() + ","
|
||||
+ " z: " + (int) nearHologram.getZ()
|
||||
+ " (lines: " + nearHologram.getLineCount() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,8 @@ public class ReadimageCommand extends LineEditingCommand {
|
||||
hologram.addLines(newLines);
|
||||
|
||||
if (newLines.size() < 5) {
|
||||
Messages.sendTip(sender, "The image has a very low height. You can increase it by increasing the width, it will scale automatically.");
|
||||
Messages.sendTip(sender, "The image has a very low height."
|
||||
+ " You can increase it by increasing the width, it will scale automatically.");
|
||||
}
|
||||
|
||||
configManager.saveHologramDatabase(internalHologramManager);
|
||||
|
@ -88,7 +88,8 @@ public class ReadtextCommand extends LineEditingCommand {
|
||||
configManager.saveHologramDatabase(internalHologramManager);
|
||||
|
||||
if (isImageExtension(FileUtils.getExtension(fileName))) {
|
||||
Messages.sendWarning(sender, "The read file has an image's extension. If it is an image, you should use /" + context.getRootLabel() + " readimage.");
|
||||
Messages.sendWarning(sender, "The read file has an image's extension."
|
||||
+ " If it is an image, you should use /" + context.getRootLabel() + " readimage.");
|
||||
}
|
||||
|
||||
sender.sendMessage(Colors.PRIMARY + "The lines were pasted into the hologram.");
|
||||
|
@ -24,7 +24,10 @@ public class RemovelineCommand extends LineEditingCommand implements QuickEditCo
|
||||
private final InternalHologramManager internalHologramManager;
|
||||
private final ConfigManager configManager;
|
||||
|
||||
public RemovelineCommand(HologramCommandManager commandManager, InternalHologramManager internalHologramManager, ConfigManager configManager) {
|
||||
public RemovelineCommand(
|
||||
HologramCommandManager commandManager,
|
||||
InternalHologramManager internalHologramManager,
|
||||
ConfigManager configManager) {
|
||||
super("removeline");
|
||||
setMinArgs(2);
|
||||
setUsageArgs("<hologram> <lineNumber>");
|
||||
@ -41,10 +44,12 @@ public class RemovelineCommand extends LineEditingCommand implements QuickEditCo
|
||||
|
||||
int lineNumber = CommandValidate.parseInteger(args[1]);
|
||||
|
||||
CommandValidate.check(lineNumber >= 1 && lineNumber <= hologram.getLineCount(), "The line number must be between 1 and " + hologram.getLineCount() + ".");
|
||||
CommandValidate.check(lineNumber >= 1 && lineNumber <= hologram.getLineCount(),
|
||||
"The line number must be between 1 and " + hologram.getLineCount() + ".");
|
||||
int index = lineNumber - 1;
|
||||
|
||||
CommandValidate.check(hologram.getLineCount() > 1, "The hologram should have at least 1 line. If you want to delete it, use /" + context.getRootLabel() + " delete.");
|
||||
CommandValidate.check(hologram.getLineCount() > 1,
|
||||
"The hologram should have at least 1 line. If you want to delete it, use /" + context.getRootLabel() + " delete.");
|
||||
|
||||
hologram.removeLine(index);
|
||||
|
||||
|
@ -26,7 +26,9 @@ public class SetlineCommand extends LineEditingCommand implements QuickEditComma
|
||||
private final InternalHologramManager internalHologramManager;
|
||||
private final ConfigManager configManager;
|
||||
|
||||
public SetlineCommand(HologramCommandManager commandManager, InternalHologramManager internalHologramManager, ConfigManager configManager) {
|
||||
public SetlineCommand(HologramCommandManager commandManager,
|
||||
InternalHologramManager internalHologramManager,
|
||||
ConfigManager configManager) {
|
||||
super("setline");
|
||||
setMinArgs(3);
|
||||
setUsageArgs("<hologram> <lineNumber> <newText>");
|
||||
@ -43,7 +45,8 @@ public class SetlineCommand extends LineEditingCommand implements QuickEditComma
|
||||
String serializedLine = Strings.joinFrom(" ", args, 2);
|
||||
|
||||
int lineNumber = CommandValidate.parseInteger(args[1]);
|
||||
CommandValidate.check(lineNumber >= 1 && lineNumber <= hologram.getLineCount(), "The line number must be between 1 and " + hologram.getLineCount() + ".");
|
||||
CommandValidate.check(lineNumber >= 1 && lineNumber <= hologram.getLineCount(),
|
||||
"The line number must be between 1 and " + hologram.getLineCount() + ".");
|
||||
int index = lineNumber - 1;
|
||||
|
||||
InternalHologramLine line = HologramCommandValidate.parseHologramLine(hologram, serializedLine);
|
||||
|
@ -93,7 +93,7 @@ public class ConfigManager extends BaseConfigManager {
|
||||
}
|
||||
|
||||
private String formatPath(Path path) {
|
||||
return ConfigErrors.formatPath(getRootDataFolder(), path);
|
||||
return ConfigErrors.formatPath(getRootDataFolder(), path);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class Configuration {
|
||||
public static void load(MainConfigModel config, ErrorCollector errorCollector) {
|
||||
spaceBetweenLines = config.spaceBetweenLines;
|
||||
quickEditCommands = config.quickEditCommands;
|
||||
timeFormat = parseTimeFormatter(config.timeFormat, config.timeZone, errorCollector);
|
||||
timeFormat = parseTimeFormatter(config.timeFormat, config.timeZone, errorCollector);
|
||||
updateNotification = config.updateNotification;
|
||||
|
||||
imageSymbol = StringConverter.toReadableFormat(config.imageSymbol);
|
||||
@ -134,7 +134,8 @@ public class Configuration {
|
||||
private static ServerAddress parseServerAddress(String singleServer, ErrorCollector errorCollector) {
|
||||
String[] nameAndAddress = Strings.splitAndTrim(singleServer, ":", 2);
|
||||
if (nameAndAddress.length < 2) {
|
||||
errorCollector.add("the server info \"" + singleServer + "\" is not valid. There should be a name and an address, separated by a colon");
|
||||
errorCollector.add("the server info \"" + singleServer + "\" is not valid."
|
||||
+ " There should be a name and an address, separated by a colon");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user