diff --git a/src/nl/marido/deluxeheads/LiveHead.java b/src/nl/marido/deluxeheads/LiveHead.java index bc703d7..0364b2a 100644 --- a/src/nl/marido/deluxeheads/LiveHead.java +++ b/src/nl/marido/deluxeheads/LiveHead.java @@ -5,22 +5,24 @@ import java.util.List; import org.bukkit.Location; import org.bukkit.scheduler.BukkitRunnable; +import nl.marido.deluxeheads.api.DeluxeHeadsAPI.Head; + public class LiveHead { private int frames; - private List texures; + private List texures; private Location location; // Do not pay attention to this class, this is just a sort of sketch which is not ready. - public LiveHead(int frames, List texures, Location location /*.more.*/) { + public LiveHead(int frames, List texures, Location location /*.more.*/) { // Safety first, experimental features should not crash servers. if (frames > 60) frames = 60; this.frames = frames; if (texures.size() > frames) while (texures.size() != frames) { - texures.remove(0); + texures.remove(texures.size()); // logic - the last ones will be removed } this.texures = texures; this.location = location; diff --git a/src/nl/marido/deluxeheads/config/lang/LangConfig.java b/src/nl/marido/deluxeheads/config/lang/LangConfig.java index b070136..6f80d51 100644 --- a/src/nl/marido/deluxeheads/config/lang/LangConfig.java +++ b/src/nl/marido/deluxeheads/config/lang/LangConfig.java @@ -20,7 +20,6 @@ public class LangConfig { public LangConfig() { this.configFile = new FileConfigFile("lang.yml"); - reload(); } diff --git a/src/nl/marido/deluxeheads/config/lang/LangMessage.java b/src/nl/marido/deluxeheads/config/lang/LangMessage.java index e0d5a60..25c3826 100644 --- a/src/nl/marido/deluxeheads/config/lang/LangMessage.java +++ b/src/nl/marido/deluxeheads/config/lang/LangMessage.java @@ -3,66 +3,73 @@ package nl.marido.deluxeheads.config.lang; import java.util.Arrays; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import nl.marido.deluxeheads.util.ArrayUtils; public final class LangMessage { - - private final String[] messages; - private final Placeholder[] placeholders; - public LangMessage(String... messages) { - this(messages, new Placeholder[0]); - } + private final String[] messages; + private final Placeholder[] placeholders; - private LangMessage(String[] messages, Placeholder[] placeholders) { - this.messages = messages; - this.placeholders = placeholders; - } + public LangMessage(String... messages) { + this(messages, new Placeholder[0]); + } - public LangMessage with(Placeholder... placeholders) { - return new LangMessage(messages, ArrayUtils.append(this.placeholders, placeholders)); - } + private LangMessage(String[] messages, Placeholder[] placeholders) { + this.messages = messages; + this.placeholders = placeholders; + } - public LangMessage with(String key, Object value) { - return with(new Placeholder(key, value)); - } + public LangMessage with(Placeholder... placeholders) { + return new LangMessage(messages, ArrayUtils.append(this.placeholders, placeholders)); + } - public int getLineCount() { - return messages.length; - } + public LangMessage with(String key, Object value) { + return with(new Placeholder(key, value)); + } - public boolean isEmpty() { - return getLineCount() == 0; - } + public int getLineCount() { + return messages.length; + } - @Override - public String toString() { - return getSingle(); - } + public boolean isEmpty() { + return getLineCount() == 0; + } - public String getSingle() { - return (isEmpty() ? "" : get()[0]); - } - - public String[] get() { - return Placeholder.applyAll(Placeholder.colourAll(messages), placeholders); - } + @Override + public String toString() { + return getSingle(); + } - public void send(CommandSender sender) { - for (String message : get()) { - sender.sendMessage(message); - } - } + public String getSingle() { + return (isEmpty() ? "" : get()[0]); + } - public Object getConfigSaveValue() { - if(isEmpty()) - return ""; + public String[] get() { + return Placeholder.applyAll(Placeholder.colourAll(messages), placeholders); + } - if(getLineCount() == 1) - return messages[0]; + public void send(CommandSender sender) { + for (String message : get()) { + sender.sendMessage(message); + } + } + + public void send(Player player) { + for (String message : get()) { + player.sendMessage(message); + } + } + + public Object getConfigSaveValue() { + if (isEmpty()) + return ""; + + if (getLineCount() == 1) + return messages[0]; + + return Arrays.asList(messages); + } - return Arrays.asList(messages); - } - } diff --git a/src/nl/marido/deluxeheads/menu/CacheHeadsMenu.java b/src/nl/marido/deluxeheads/menu/CacheHeadsMenu.java index 2a72da0..fe4e5d4 100644 --- a/src/nl/marido/deluxeheads/menu/CacheHeadsMenu.java +++ b/src/nl/marido/deluxeheads/menu/CacheHeadsMenu.java @@ -5,9 +5,7 @@ import java.util.function.Function; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.entity.Player; -import nl.marido.deluxeheads.DeluxeHeads; import nl.marido.deluxeheads.cache.CacheFile; import nl.marido.deluxeheads.cache.CacheHead; import nl.marido.deluxeheads.menu.ui.Bounds; @@ -175,19 +173,4 @@ public class CacheHeadsMenu extends Element { } - @Deprecated - public static void openHeadsMenu(Player player) { - InventoryMenu inventory = new InventoryMenu(player, "Heads", 6); - - CacheHeadsMenu menu = new CacheHeadsMenu(DeluxeHeads.getCache(), inventory, inventory.bounds, head -> { - player.sendMessage(head.getName()); - return MenuResponse.NONE; - }); - - menu.setTemplate(DeluxeHeads.getMenus().getBrowseTemplate()); - - inventory.addElement(menu); - inventory.open(); - } - } diff --git a/src/nl/marido/deluxeheads/menu/ui/item/Item.java b/src/nl/marido/deluxeheads/menu/ui/item/Item.java index d260185..a5495af 100644 --- a/src/nl/marido/deluxeheads/menu/ui/item/Item.java +++ b/src/nl/marido/deluxeheads/menu/ui/item/Item.java @@ -206,7 +206,6 @@ public final class Item { return new Item(type, 1, data, null, null, false); } return new Item(type, 1, (short) 0, null, null, false); - // TODO: Needs manual testing on 1.13. } public static Item create(ItemStack itemStack) { @@ -261,7 +260,7 @@ public final class Item { int typeId = section.getInt("type"); String convertedType = DeluxeHeads.getLegacyIDs().fromId(typeId); - if (convertedType == null) { + if (convertedType == null || convertedType.isEmpty()) { DeluxeHeads.warning("Invalid type of item " + section.getCurrentPath() + ", " + "unknown type id " + typeId); return; } diff --git a/src/nl/marido/deluxeheads/volatilecode/reflection/Version.java b/src/nl/marido/deluxeheads/volatilecode/reflection/Version.java index 41ec32a..6c55acc 100644 --- a/src/nl/marido/deluxeheads/volatilecode/reflection/Version.java +++ b/src/nl/marido/deluxeheads/volatilecode/reflection/Version.java @@ -1,84 +1,83 @@ package nl.marido.deluxeheads.volatilecode.reflection; - public class Version { - - private static final char[] allowed = "0123456789_".toCharArray(); - public static final Version v1_8 = Version.getVersion("v1_8"); - public static final Version v1_10 = Version.getVersion("v1_10"); - public static final Version v1_13 = Version.getVersion("v1_13"); - - private int major; - private int minor; - private int revision; - - public Version(int major, int minor, int revision) { - this.major = major; - this.minor = minor; - this.revision = revision; - } - - public int getMajor() { - return major; - } - - public int getMinor() { - return minor; - } - - public int getRevision() { - return revision; - } - - public boolean higherThan(Version other) { - return other.getMajor() < getMajor() || other.getMinor() < getMinor() || other.getRevision() < getRevision(); - } - - public static Version getVersion() { - return getVersion(ReflectionUtils.getServerVersion()); - } - - public static Version getVersion(String version) { - StringBuilder builder = new StringBuilder(); - - for (char c : version.toCharArray()) { - if (isAllowed(c)) { - builder.append(c); - } - } - - String[] split = builder.toString().split("_"); - - if (split.length != 2 && split.length != 3) { - throw new IllegalArgumentException("version is not of the valid type v?_?_R?"); - } - - int major = Integer.valueOf(split[0]); - int minor = Integer.valueOf(split[1]); - int revision = 0; - - if (split.length == 3) { - revision = Integer.valueOf(split[2]); - } - - return new Version(major, minor, revision); - } - public static boolean isAbove(Version version) { - return getVersion().higherThan(version); - } + private static final char[] allowed = "0123456789_".toCharArray(); + public static final Version v1_8 = Version.getVersion("v1_8"); + public static final Version v1_10 = Version.getVersion("v1_10"); + public static final Version v1_13 = Version.getVersion("v1_13"); - public static boolean isBelow(Version version) { - return version.higherThan(getVersion()); - } + private int major; + private int minor; + private int revision; + + public Version(int major, int minor, int revision) { + this.major = major; + this.minor = minor; + this.revision = revision; + } + + public int getMajor() { + return major; + } + + public int getMinor() { + return minor; + } + + public int getRevision() { + return revision; + } + + public boolean higherThan(Version other) { + return other.getMajor() < getMajor() || other.getMinor() < getMinor() || other.getRevision() < getRevision(); + } + + public static Version getVersion() { + return getVersion(ReflectionUtils.getServerVersion()); + } + + public static Version getVersion(String version) { + StringBuilder builder = new StringBuilder(); + + for (char c : version.toCharArray()) { + if (isAllowed(c)) { + builder.append(c); + } + } + + String[] split = builder.toString().split("_"); + + if (split.length != 2 && split.length != 3) { + throw new IllegalArgumentException("version is not of the valid type v?_?_R?"); + } + + int major = Integer.valueOf(split[0]); + int minor = Integer.valueOf(split[1]); + int revision = 0; + + if (split.length == 3) { + revision = Integer.valueOf(split[2]); + } + + return new Version(major, minor, revision); + } + + public static boolean isAbove(Version version) { + return getVersion().higherThan(version); + } + + public static boolean isBelow(Version version) { + return version.higherThan(getVersion()); + } + + private static boolean isAllowed(char c) { + for (char ch : allowed) { + if (ch == c) { + return true; + } + } + return false; + } - private static boolean isAllowed(char c) { - for (char ch : allowed) { - if (ch == c) { - return true; - } - } - return false; - } - } diff --git a/src/plugin.yml b/src/plugin.yml index 44e655b..8516ced 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -2,7 +2,7 @@ main: nl.marido.deluxeheads.DeluxeHeads author: Marido name: DeluxeHeads description: Enhance your server with over 17,000 awesome unique heads with amazing features. -version: 2.1.2 +version: 2.1.3 api-version: 1.13 softdepend: [Vault, PlayerPoints, BlockStore] loadbefore: [DeluxeMenus]