diff --git a/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/commands/main/subs/AddlineCommand.java b/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/commands/main/subs/AddlineCommand.java index 9852722a..5ac1049e 100644 --- a/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/commands/main/subs/AddlineCommand.java +++ b/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/commands/main/subs/AddlineCommand.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.command.CommandSender; import com.gmail.filoghost.holographicdisplays.commands.Colors; @@ -15,6 +16,7 @@ import com.gmail.filoghost.holographicdisplays.event.NamedHologramEditedEvent; import com.gmail.filoghost.holographicdisplays.exception.CommandException; import com.gmail.filoghost.holographicdisplays.object.NamedHologram; import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager; +import com.gmail.filoghost.holographicdisplays.util.ItemUtils; import com.gmail.filoghost.holographicdisplays.util.Utils; public class AddlineCommand extends HologramSubCommand { @@ -38,8 +40,21 @@ public class AddlineCommand extends HologramSubCommand { public void execute(CommandSender sender, String label, String[] args) throws CommandException { NamedHologram hologram = NamedHologramManager.getHologram(args[0].toLowerCase()); CommandValidator.notNull(hologram, Strings.noSuchHologram(args[0].toLowerCase())); + String line = Utils.join(args, " ", 1, args.length); + + // Check material validity + if (line.toLowerCase().startsWith("icon:")) { + String iconMaterial = ItemUtils.stripSpacingChars(line.substring("icon:".length(), line.length())); + + if (iconMaterial.contains(":")) { + iconMaterial = iconMaterial.split(":")[0]; + } + + Material mat = ItemUtils.matchMaterial(iconMaterial); + CommandValidator.notNull(mat, "Invalid icon material."); + } - hologram.getLinesUnsafe().add(HologramDatabase.readLineFromString(Utils.join(args, " ", 1, args.length), hologram)); + hologram.getLinesUnsafe().add(HologramDatabase.readLineFromString(line, hologram)); hologram.refreshAll(); HologramDatabase.saveHologram(hologram); diff --git a/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/commands/main/subs/SetlineCommand.java b/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/commands/main/subs/SetlineCommand.java index 02b65a96..382571e6 100644 --- a/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/commands/main/subs/SetlineCommand.java +++ b/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/commands/main/subs/SetlineCommand.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.command.CommandSender; import com.gmail.filoghost.holographicdisplays.commands.Colors; @@ -15,6 +16,7 @@ import com.gmail.filoghost.holographicdisplays.event.NamedHologramEditedEvent; import com.gmail.filoghost.holographicdisplays.exception.CommandException; import com.gmail.filoghost.holographicdisplays.object.NamedHologram; import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager; +import com.gmail.filoghost.holographicdisplays.util.ItemUtils; import com.gmail.filoghost.holographicdisplays.util.Utils; public class SetlineCommand extends HologramSubCommand { @@ -39,14 +41,26 @@ public class SetlineCommand extends HologramSubCommand { public void execute(CommandSender sender, String label, String[] args) throws CommandException { NamedHologram hologram = NamedHologramManager.getHologram(args[0].toLowerCase()); CommandValidator.notNull(hologram, Strings.noSuchHologram(args[0].toLowerCase())); + String line = Utils.join(args, " ", 2, args.length); + // Check material validity + if (line.toLowerCase().startsWith("icon:")) { + String iconMaterial = ItemUtils.stripSpacingChars(line.substring("icon:".length(), line.length())); + if (iconMaterial.contains(":")) { + iconMaterial = iconMaterial.split(":")[0]; + } + + Material mat = ItemUtils.matchMaterial(iconMaterial); + CommandValidator.notNull(mat, "Invalid icon material."); + } + int lineNumber = CommandValidator.getInteger(args[1]); CommandValidator.isTrue(lineNumber >= 1 && lineNumber <= hologram.size(), "The line number must be between 1 and " + hologram.size() + "."); int index = lineNumber - 1; hologram.getLinesUnsafe().get(index).despawn(); - hologram.getLinesUnsafe().set(index, HologramDatabase.readLineFromString(Utils.join(args, " ", 2, args.length), hologram)); + hologram.getLinesUnsafe().set(index, HologramDatabase.readLineFromString(line, hologram)); hologram.refreshAll(); HologramDatabase.saveHologram(hologram); diff --git a/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSItem.java b/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSItem.java index 2ca53e39..cdbc7a98 100644 --- a/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSItem.java +++ b/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSItem.java @@ -103,6 +103,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem { */ return true; } + + @Override + public void inactiveTick() { + // Check inactive ticks. + + if (!lockTick) { + super.inactiveTick(); + } + } @Override public void setLockTick(boolean lock) { @@ -111,6 +120,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { @Override public void die() { + System.out.println("Hologram Item died:"); + Thread.dumpStack(); setLockTick(false); super.die(); } diff --git a/HolographicDisplays/plugin.yml b/HolographicDisplays/plugin.yml index 82eab663..283252da 100644 --- a/HolographicDisplays/plugin.yml +++ b/HolographicDisplays/plugin.yml @@ -1,6 +1,6 @@ name: HolographicDisplays main: com.gmail.filoghost.holographicdisplays.HolographicDisplays -version: 2.1.7 +version: 2.1.8 softdepend: [Multiverse-Core, MultiWorld, My Worlds, My_Worlds, ProtocolLib]