diff --git a/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/Configuration.java b/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/Configuration.java index c3f05d96..611acb7a 100644 --- a/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/Configuration.java +++ b/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/Configuration.java @@ -18,6 +18,7 @@ import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TimeZone; @@ -29,7 +30,6 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.Plugin; import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger; -import com.gmail.filoghost.holographicdisplays.util.Utils; /** * Just a bunch of static varibles to hold the settings. @@ -112,13 +112,12 @@ public class Configuration { if (needsSave) { - config.options().header(Utils.join(new String[] { + config.options().header(String.join("\n", ".", ". Read the tutorial at: http://dev.bukkit.org/bukkit-plugins/holographic-displays/", ".", ". Plugin created by filoghost.", - "."}, - "\n")); + ".")); config.options().copyHeader(true); try { config.save(configFile); @@ -153,7 +152,7 @@ public class Configuration { pingerTimeout = 10000; } - pingerServers = Utils.newMap(); + pingerServers = new HashMap<>(); if (pingerEnable) { for (String singleServer : config.getStringList(ConfigNode.BUNGEE_PINGER_SERVERS.getPath())) { diff --git a/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/UnicodeSymbols.java b/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/UnicodeSymbols.java index d299175f..b67f05f9 100644 --- a/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/UnicodeSymbols.java +++ b/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/UnicodeSymbols.java @@ -30,7 +30,7 @@ import com.gmail.filoghost.holographicdisplays.util.FileUtils; public class UnicodeSymbols { - private static Map placeholders = new HashMap(); + private static Map placeholders = new HashMap<>(); public static void load(Plugin plugin) { placeholders.clear(); diff --git a/JavaCompat/src/main/java/java/util/Optional.java b/JavaCompat/src/main/java/java/util/Optional.java deleted file mode 100644 index b585a1a1..00000000 --- a/JavaCompat/src/main/java/java/util/Optional.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package java.util; - -public class Optional { - - public T orElse(T other) { - return null; - } - -} diff --git a/JavaCompat/src/main/java/java/util/function/Function.java b/JavaCompat/src/main/java/java/util/function/Function.java deleted file mode 100644 index 2bb19d1b..00000000 --- a/JavaCompat/src/main/java/java/util/function/Function.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package java.util.function; - -public interface Function { - - R apply(T t); - -} diff --git a/JavaCompat/src/main/java/java/util/stream/Stream.java b/JavaCompat/src/main/java/java/util/stream/Stream.java deleted file mode 100644 index fdbb4245..00000000 --- a/JavaCompat/src/main/java/java/util/stream/Stream.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package java.util.stream; - -import java.util.Optional; - -public interface Stream { - - public Stream skip(long n); - - public Stream limit(long maxSize); - - public Optional findFirst(); - -} diff --git a/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSItem.java b/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSItem.java index f9a6a341..fcdec4dc 100644 --- a/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSItem.java +++ b/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSItem.java @@ -44,7 +44,7 @@ import net.minecraft.server.v1_10_R1.World; public class EntityNMSItem extends EntityItem implements NMSItem { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "au"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "au"); private boolean lockTick; private ItemLine parentPiece; diff --git a/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSSlime.java b/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSSlime.java index 3bb163b9..87308851 100644 --- a/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSSlime.java +++ b/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSSlime.java @@ -40,7 +40,7 @@ import net.minecraft.server.v1_10_R1.World; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "au"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "au"); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/NmsManagerImpl.java b/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/NmsManagerImpl.java index bf41ff18..2ed3c799 100644 --- a/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/NmsManagerImpl.java +++ b/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/NmsManagerImpl.java @@ -41,8 +41,8 @@ import net.minecraft.server.v1_10_R1.WorldServer; public class NmsManagerImpl implements NMSManager { - private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField, String>>(EntityTypes.class, "d"); - private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField, Integer>>(EntityTypes.class, "f"); + private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d"); + private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f"); private Method validateEntityMethod; diff --git a/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSItem.java b/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSItem.java index c5f54494..eaff8789 100644 --- a/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSItem.java +++ b/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSItem.java @@ -42,7 +42,7 @@ import net.minecraft.server.v1_11_R1.World; public class EntityNMSItem extends EntityItem implements NMSItem { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "au"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "au"); private boolean lockTick; private ItemLine parentPiece; diff --git a/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSSlime.java b/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSSlime.java index 8daa8e7d..b7915ce6 100644 --- a/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSSlime.java +++ b/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSSlime.java @@ -38,7 +38,7 @@ import net.minecraft.server.v1_11_R1.World; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "au"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "au"); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/NmsManagerImpl.java b/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/NmsManagerImpl.java index 00f36a22..01889f59 100644 --- a/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/NmsManagerImpl.java +++ b/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/NmsManagerImpl.java @@ -42,8 +42,8 @@ import net.minecraft.server.v1_11_R1.WorldServer; public class NmsManagerImpl implements NMSManager { - private static final ReflectField>> REGISTRY_ID_FIELD = new ReflectField>>(RegistryMaterials.class, "a"); - private static final ReflectField ID_TO_CLASS_MAP_FIELD = new ReflectField(RegistryID.class, "d"); + private static final ReflectField>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a"); + private static final ReflectField ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d"); private Method validateEntityMethod; diff --git a/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSItem.java b/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSItem.java index ab49bc78..ab4b76ed 100644 --- a/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSItem.java +++ b/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSItem.java @@ -42,7 +42,7 @@ import net.minecraft.server.v1_12_R1.World; public class EntityNMSItem extends EntityItem implements NMSItem { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "au"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "au"); private boolean lockTick; private ItemLine parentPiece; diff --git a/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSSlime.java b/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSSlime.java index 741619e3..8c3a4036 100644 --- a/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSSlime.java +++ b/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSSlime.java @@ -38,7 +38,7 @@ import net.minecraft.server.v1_12_R1.World; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "au"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "au"); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/NmsManagerImpl.java b/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/NmsManagerImpl.java index 5eeaa72f..50c34631 100644 --- a/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/NmsManagerImpl.java +++ b/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/NmsManagerImpl.java @@ -42,8 +42,8 @@ import net.minecraft.server.v1_12_R1.WorldServer; public class NmsManagerImpl implements NMSManager { - private static final ReflectField>> REGISTRY_ID_FIELD = new ReflectField>>(RegistryMaterials.class, "a"); - private static final ReflectField ID_TO_CLASS_MAP_FIELD = new ReflectField(RegistryID.class, "d"); + private static final ReflectField>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a"); + private static final ReflectField ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d"); private Method validateEntityMethod; diff --git a/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSItem.java b/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSItem.java index 6158ba1d..3a36129a 100644 --- a/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSItem.java +++ b/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSItem.java @@ -42,7 +42,7 @@ import net.minecraft.server.v1_13_R1.World; public class EntityNMSItem extends EntityItem implements NMSItem { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "ax"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax"); private boolean lockTick; private ItemLine parentPiece; diff --git a/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSSlime.java b/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSSlime.java index 853b7392..df16c35a 100644 --- a/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSSlime.java +++ b/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSSlime.java @@ -39,7 +39,7 @@ import net.minecraft.server.v1_13_R1.World; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "ax"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax"); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/NmsManagerImpl.java b/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/NmsManagerImpl.java index 742cdb6a..f8062e63 100644 --- a/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/NmsManagerImpl.java +++ b/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/NmsManagerImpl.java @@ -16,8 +16,6 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_13_R1; import java.lang.reflect.Method; import java.util.List; -import java.util.function.Function; - import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_13_R1.CraftWorld; import org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity; @@ -45,9 +43,9 @@ import net.minecraft.server.v1_13_R1.WorldServer; public class NmsManagerImpl implements NMSManager { - private static final ReflectField>> REGISTRY_ID_FIELD = new ReflectField>>(RegistryMaterials.class, "a"); - private static final ReflectField ID_TO_CLASS_MAP_FIELD = new ReflectField(RegistryID.class, "d"); - private static final ReflectField> ENTITY_LIST_FIELD = new ReflectField>(World.class, "entityList"); + private static final ReflectField>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a"); + private static final ReflectField ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d"); + private static final ReflectField> ENTITY_LIST_FIELD = new ReflectField<>(World.class, "entityList"); private Method validateEntityMethod; @@ -68,14 +66,7 @@ public class NmsManagerImpl implements NMSManager { Object oldValue = idToClassMap[id]; // Register the EntityTypes object. - registryID.a(new EntityTypes(entityClass, new Function() { - - @Override - public Entity apply(World world) { - return null; - } - - }, true, true, null), id); + registryID.a(new EntityTypes<>(entityClass, world -> null, true, true, null), id); // Restore the ID -> EntityTypes mapping. idToClassMap[id] = oldValue; diff --git a/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSItem.java b/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSItem.java index d8ee2f62..8b314fee 100644 --- a/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSItem.java +++ b/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSItem.java @@ -42,7 +42,7 @@ import net.minecraft.server.v1_13_R2.World; public class EntityNMSItem extends EntityItem implements NMSItem { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "vehicle"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "vehicle"); private boolean lockTick; private ItemLine parentPiece; diff --git a/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSSlime.java b/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSSlime.java index 597acfac..085f73ab 100644 --- a/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSSlime.java +++ b/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSSlime.java @@ -39,7 +39,7 @@ import net.minecraft.server.v1_13_R2.World; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "vehicle"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "vehicle"); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/NmsManagerImpl.java b/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/NmsManagerImpl.java index 02a291e3..35bb4449 100644 --- a/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/NmsManagerImpl.java +++ b/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/NmsManagerImpl.java @@ -16,8 +16,6 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_13_R2; import java.lang.reflect.Method; import java.util.List; -import java.util.function.Function; - import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_13_R2.CraftWorld; import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity; @@ -46,9 +44,9 @@ import net.minecraft.server.v1_13_R2.WorldServer; public class NmsManagerImpl implements NMSManager { - private static final ReflectField>> REGISTRY_ID_FIELD = new ReflectField>>(RegistryMaterials.class, "b"); - private static final ReflectField ID_TO_CLASS_MAP_FIELD = new ReflectField(RegistryID.class, "d"); - private static final ReflectField> ENTITY_LIST_FIELD = new ReflectField>(World.class, "entityList"); + private static final ReflectField>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "b"); + private static final ReflectField ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d"); + private static final ReflectField> ENTITY_LIST_FIELD = new ReflectField<>(World.class, "entityList"); private Method validateEntityMethod; @@ -69,14 +67,7 @@ public class NmsManagerImpl implements NMSManager { Object oldValue = idToClassMap[id]; // Register the EntityTypes object. - registryID.a(new EntityTypes(entityClass, new Function() { - - @Override - public Entity apply(World world) { - return null; - } - - }, true, true, null), id); + registryID.a(new EntityTypes<>(entityClass, world -> null, true, true, null), id); // Restore the ID -> EntityTypes mapping. idToClassMap[id] = oldValue; diff --git a/NMS/v1_14_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSItem.java b/NMS/v1_14_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSItem.java index 5e0ddb1f..89426587 100644 --- a/NMS/v1_14_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSItem.java +++ b/NMS/v1_14_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSItem.java @@ -43,7 +43,7 @@ import net.minecraft.server.v1_14_R1.World; public class EntityNMSItem extends EntityItem implements NMSItem { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "vehicle"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "vehicle"); private boolean lockTick; private ItemLine parentPiece; diff --git a/NMS/v1_14_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSSlime.java b/NMS/v1_14_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSSlime.java index f1d41d3a..e8e061f4 100644 --- a/NMS/v1_14_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSSlime.java +++ b/NMS/v1_14_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSSlime.java @@ -40,7 +40,7 @@ import net.minecraft.server.v1_14_R1.World; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "vehicle"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "vehicle"); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_14_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_14_R1/NmsManagerImpl.java b/NMS/v1_14_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_14_R1/NmsManagerImpl.java index a6a2d132..0b2f188b 100644 --- a/NMS/v1_14_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_14_R1/NmsManagerImpl.java +++ b/NMS/v1_14_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_14_R1/NmsManagerImpl.java @@ -39,14 +39,13 @@ import net.minecraft.server.v1_14_R1.IRegistry; import net.minecraft.server.v1_14_R1.MathHelper; import net.minecraft.server.v1_14_R1.RegistryID; import net.minecraft.server.v1_14_R1.RegistryMaterials; -import net.minecraft.server.v1_14_R1.World; import net.minecraft.server.v1_14_R1.WorldServer; public class NmsManagerImpl implements NMSManager { - private static final ReflectField>> REGISTRY_ID_FIELD = new ReflectField>>(RegistryMaterials.class, "b"); - private static final ReflectField ID_TO_CLASS_MAP_FIELD = new ReflectField(RegistryID.class, "d"); - private static final ReflectMethod REGISTER_ENTITY_METHOD = new ReflectMethod(WorldServer.class, "registerEntity", Entity.class); + private static final ReflectField>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "b"); + private static final ReflectField ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d"); + private static final ReflectMethod REGISTER_ENTITY_METHOD = new ReflectMethod<>(WorldServer.class, "registerEntity", Entity.class); @Override public void setup() throws Exception { @@ -62,14 +61,7 @@ public class NmsManagerImpl implements NMSManager { Object oldValue = idToClassMap[id]; // Register the EntityTypes object. - registryID.a(new EntityTypes(new EntityTypes.b() { - - @Override - public Entity create(EntityTypes entityType, World world) { - return null; - } - - }, EnumCreatureType.MONSTER, true, true, false, null, EntitySize.b(2.04f, 2.04f)), id); + registryID.a(new EntityTypes<>((entityType, world) -> null, EnumCreatureType.MONSTER, true, true, false, null, EntitySize.b(2.04f, 2.04f)), id); // Restore the ID -> EntityTypes mapping. idToClassMap[id] = oldValue; diff --git a/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSArmorStand.java b/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSArmorStand.java index bee85142..69962488 100644 --- a/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSArmorStand.java +++ b/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSArmorStand.java @@ -37,7 +37,7 @@ import net.minecraft.server.v1_8_R1.World; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private static final ReflectField DISABLED_SLOTS_FIELD = new ReflectField(EntityArmorStand.class, "bg"); + private static final ReflectField DISABLED_SLOTS_FIELD = new ReflectField<>(EntityArmorStand.class, "bg"); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSItem.java b/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSItem.java index 0cdd91c8..f900554f 100644 --- a/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSItem.java +++ b/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSItem.java @@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R1.World; public class EntityNMSItem extends EntityItem implements NMSItem { - private static final ReflectField RIDER_PITCH_DELTA = new ReflectField(Entity.class, "ap"); - private static final ReflectField RIDER_YAW_DELTA = new ReflectField(Entity.class, "aq"); + private static final ReflectField RIDER_PITCH_DELTA = new ReflectField<>(Entity.class, "ap"); + private static final ReflectField RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "aq"); private boolean lockTick; private ItemLine parentPiece; diff --git a/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSSlime.java b/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSSlime.java index 4d95a882..b85c123a 100644 --- a/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSSlime.java +++ b/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSSlime.java @@ -37,8 +37,8 @@ import net.minecraft.server.v1_8_R1.World; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - private static final ReflectField RIDER_PITCH_DELTA = new ReflectField(Entity.class, "ap"); - private static final ReflectField RIDER_YAW_DELTA = new ReflectField(Entity.class, "aq"); + private static final ReflectField RIDER_PITCH_DELTA = new ReflectField<>(Entity.class, "ap"); + private static final ReflectField RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "aq"); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/NmsManagerImpl.java b/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/NmsManagerImpl.java index 67113933..930a28ef 100644 --- a/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/NmsManagerImpl.java +++ b/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/NmsManagerImpl.java @@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R1.WorldServer; public class NmsManagerImpl implements NMSManager { - private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField, String>>(EntityTypes.class, "d"); - private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField, Integer>>(EntityTypes.class, "f"); + private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d"); + private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f"); private Method validateEntityMethod; diff --git a/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSArmorStand.java b/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSArmorStand.java index 0774d65c..ff8e5e9a 100644 --- a/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSArmorStand.java +++ b/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSArmorStand.java @@ -41,8 +41,8 @@ import net.minecraft.server.v1_8_R2.World; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private static final ReflectField DISABLED_SLOTS_FIELD = new ReflectField(EntityArmorStand.class, "bi"); - private static final ReflectMethod SET_MARKER_METHOD = new ReflectMethod(EntityArmorStand.class, "n", boolean.class); + private static final ReflectField DISABLED_SLOTS_FIELD = new ReflectField<>(EntityArmorStand.class, "bi"); + private static final ReflectMethod SET_MARKER_METHOD = new ReflectMethod<>(EntityArmorStand.class, "n", boolean.class); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSItem.java b/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSItem.java index a0c45337..64e702d1 100644 --- a/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSItem.java +++ b/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSItem.java @@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R2.World; public class EntityNMSItem extends EntityItem implements NMSItem { - private static final ReflectField RIDER_PITCH_DELTA = new ReflectField(Entity.class, "ar"); - private static final ReflectField RIDER_YAW_DELTA = new ReflectField(Entity.class, "as"); + private static final ReflectField RIDER_PITCH_DELTA = new ReflectField<>(Entity.class, "ar"); + private static final ReflectField RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "as"); private boolean lockTick; private ItemLine parentPiece; diff --git a/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSSlime.java b/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSSlime.java index 724c52ba..5e4576b4 100644 --- a/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSSlime.java +++ b/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSSlime.java @@ -37,8 +37,8 @@ import net.minecraft.server.v1_8_R2.World; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - private static final ReflectField RIDER_PITCH_DELTA = new ReflectField(Entity.class, "ar"); - private static final ReflectField RIDER_YAW_DELTA = new ReflectField(Entity.class, "as"); + private static final ReflectField RIDER_PITCH_DELTA = new ReflectField<>(Entity.class, "ar"); + private static final ReflectField RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "as"); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/NmsManagerImpl.java b/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/NmsManagerImpl.java index 687355ac..fa306a4c 100644 --- a/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/NmsManagerImpl.java +++ b/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/NmsManagerImpl.java @@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R2.WorldServer; public class NmsManagerImpl implements NMSManager { - private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField, String>>(EntityTypes.class, "d"); - private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField, Integer>>(EntityTypes.class, "f"); + private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d"); + private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f"); private Method validateEntityMethod; diff --git a/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSArmorStand.java b/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSArmorStand.java index 9ad32c81..87041e41 100644 --- a/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSArmorStand.java +++ b/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSArmorStand.java @@ -41,8 +41,8 @@ import net.minecraft.server.v1_8_R3.World; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private static final ReflectField DISABLED_SLOTS_FIELD = new ReflectField(EntityArmorStand.class, "bi"); - private static final ReflectMethod SET_MARKER_METHOD = new ReflectMethod(EntityArmorStand.class, "n", boolean.class); + private static final ReflectField DISABLED_SLOTS_FIELD = new ReflectField<>(EntityArmorStand.class, "bi"); + private static final ReflectMethod SET_MARKER_METHOD = new ReflectMethod<>(EntityArmorStand.class, "n", boolean.class); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSItem.java b/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSItem.java index 9e2d96df..722f5f02 100644 --- a/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSItem.java +++ b/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSItem.java @@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R3.World; public class EntityNMSItem extends EntityItem implements NMSItem { - private static final ReflectField RIDER_PITCH_DELTA = new ReflectField(Entity.class, "ar"); - private static final ReflectField RIDER_YAW_DELTA = new ReflectField(Entity.class, "as"); + private static final ReflectField RIDER_PITCH_DELTA = new ReflectField<>(Entity.class, "ar"); + private static final ReflectField RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "as"); private boolean lockTick; private ItemLine parentPiece; diff --git a/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSSlime.java b/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSSlime.java index 4dcf6720..766d3cbb 100644 --- a/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSSlime.java +++ b/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSSlime.java @@ -37,8 +37,8 @@ import net.minecraft.server.v1_8_R3.World; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - private static final ReflectField RIDER_PITCH_DELTA = new ReflectField(Entity.class, "ar"); - private static final ReflectField RIDER_YAW_DELTA = new ReflectField(Entity.class, "as"); + private static final ReflectField RIDER_PITCH_DELTA = new ReflectField<>(Entity.class, "ar"); + private static final ReflectField RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "as"); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/NmsManagerImpl.java b/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/NmsManagerImpl.java index 9d112970..80d51d24 100644 --- a/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/NmsManagerImpl.java +++ b/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/NmsManagerImpl.java @@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R3.WorldServer; public class NmsManagerImpl implements NMSManager { - private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField, String>>(EntityTypes.class, "d"); - private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField, Integer>>(EntityTypes.class, "f"); + private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d"); + private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f"); private Method validateEntityMethod; diff --git a/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSArmorStand.java b/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSArmorStand.java index 32a6b527..ef77f856 100644 --- a/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSArmorStand.java +++ b/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSArmorStand.java @@ -40,7 +40,7 @@ import net.minecraft.server.v1_9_R1.World; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private static final ReflectField DISABLED_SLOTS_FIELD = new ReflectField(EntityArmorStand.class, "bz"); + private static final ReflectField DISABLED_SLOTS_FIELD = new ReflectField<>(EntityArmorStand.class, "bz"); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSItem.java b/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSItem.java index 16a5bc15..512ca7c2 100644 --- a/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSItem.java +++ b/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSItem.java @@ -44,7 +44,7 @@ import net.minecraft.server.v1_9_R1.World; public class EntityNMSItem extends EntityItem implements NMSItem { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "as"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "as"); private boolean lockTick; private ItemLine parentPiece; diff --git a/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSSlime.java b/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSSlime.java index c3989d9e..50598036 100644 --- a/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSSlime.java +++ b/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSSlime.java @@ -40,7 +40,7 @@ import net.minecraft.server.v1_9_R1.World; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "as"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "as"); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/NmsManagerImpl.java b/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/NmsManagerImpl.java index 7fa18a46..c79a76b9 100644 --- a/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/NmsManagerImpl.java +++ b/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/NmsManagerImpl.java @@ -41,8 +41,8 @@ import net.minecraft.server.v1_9_R1.WorldServer; public class NmsManagerImpl implements NMSManager { - private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField, String>>(EntityTypes.class, "d"); - private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField, Integer>>(EntityTypes.class, "f"); + private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d"); + private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f"); private Method validateEntityMethod; diff --git a/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSItem.java b/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSItem.java index c5e7e1b7..571a9d63 100644 --- a/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSItem.java +++ b/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSItem.java @@ -44,7 +44,7 @@ import net.minecraft.server.v1_9_R2.World; public class EntityNMSItem extends EntityItem implements NMSItem { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "at"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "at"); private boolean lockTick; private ItemLine parentPiece; diff --git a/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSSlime.java b/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSSlime.java index 1efff3de..35c4cac6 100644 --- a/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSSlime.java +++ b/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSSlime.java @@ -40,7 +40,7 @@ import net.minecraft.server.v1_9_R2.World; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - private static final ReflectField VEHICLE_FIELD = new ReflectField(Entity.class, "at"); + private static final ReflectField VEHICLE_FIELD = new ReflectField<>(Entity.class, "at"); private boolean lockTick; private HologramLine parentPiece; diff --git a/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/NmsManagerImpl.java b/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/NmsManagerImpl.java index 1c47f83a..4e156f5b 100644 --- a/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/NmsManagerImpl.java +++ b/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/NmsManagerImpl.java @@ -41,8 +41,8 @@ import net.minecraft.server.v1_9_R2.WorldServer; public class NmsManagerImpl implements NMSManager { - private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField, String>>(EntityTypes.class, "d"); - private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField, Integer>>(EntityTypes.class, "f"); + private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d"); + private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f"); private Method validateEntityMethod; diff --git a/Plugin/src/main/java/com/gmail/filoghost/holograms/api/HolographicDisplaysAPI.java b/Plugin/src/main/java/com/gmail/filoghost/holograms/api/HolographicDisplaysAPI.java index eceeb887..ab51e515 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holograms/api/HolographicDisplaysAPI.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holograms/api/HolographicDisplaysAPI.java @@ -34,7 +34,6 @@ import com.gmail.filoghost.holographicdisplays.api.internal.BackendAPI; import com.gmail.filoghost.holographicdisplays.object.CraftHologram; import com.gmail.filoghost.holographicdisplays.object.PluginHologram; import com.gmail.filoghost.holographicdisplays.object.PluginHologramManager; -import com.gmail.filoghost.holographicdisplays.util.Utils; import com.gmail.filoghost.holographicdisplays.util.Validator; /** @@ -43,7 +42,7 @@ import com.gmail.filoghost.holographicdisplays.util.Validator; @Deprecated public class HolographicDisplaysAPI { - private static Set notifiedPlugins = new HashSet(); + private static Set notifiedPlugins = new HashSet<>(); private static void notifyOldAPI(Plugin plugin) { if (notifiedPlugins.add(plugin.getName())) { @@ -76,7 +75,7 @@ public class HolographicDisplaysAPI { @Deprecated public static Hologram createIndividualHologram(Plugin plugin, Location source, Player whoCanSee, String... lines) { notifyOldAPI(plugin); - List whoCanSeeList = new ArrayList(); + List whoCanSeeList = new ArrayList<>(); whoCanSeeList.add(whoCanSee); return createIndividualHologram(plugin, source, whoCanSeeList, lines); } @@ -107,7 +106,7 @@ public class HolographicDisplaysAPI { @Deprecated public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, Player whoCanSee, ItemStack itemstack) { notifyOldAPI(plugin); - List whoCanSeeList = new ArrayList(); + List whoCanSeeList = new ArrayList<>(); whoCanSeeList.add(whoCanSee); return createIndividualFloatingItem(plugin, source, whoCanSeeList, itemstack); } @@ -139,7 +138,7 @@ public class HolographicDisplaysAPI { notifyOldAPI(plugin); Validator.notNull(plugin, "plugin cannot be null"); - List pluginHolograms = Utils.newList(); + List pluginHolograms = new ArrayList<>();; for (PluginHologram pluginHologram : PluginHologramManager.getHolograms()) { if (pluginHologram.getOwner().equals(plugin)) { pluginHolograms.add(pluginHologram); diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/HolographicDisplays.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/HolographicDisplays.java index 226a81c2..adbda6c5 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/HolographicDisplays.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/HolographicDisplays.java @@ -24,7 +24,6 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.plugin.java.JavaPlugin; -import com.gmail.filoghost.holographicdisplays.SimpleUpdater.ResponseHandler; import com.gmail.filoghost.holographicdisplays.api.internal.BackendAPI; import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.BungeeServerTracker; import com.gmail.filoghost.holographicdisplays.bridge.protocollib.ProtocolLibHook; @@ -87,16 +86,11 @@ public class HolographicDisplays extends JavaPlugin { Configuration.load(this); if (Configuration.updateNotification) { - new SimpleUpdater(this, 75097).checkForUpdates(new ResponseHandler() { - - @Override - public void onUpdateFound(final String newVersion) { - - HolographicDisplays.newVersion = newVersion; - ConsoleLogger.log(Level.INFO, "Found a new version available: " + newVersion); - ConsoleLogger.log(Level.INFO, "Download it on Bukkit Dev:"); - ConsoleLogger.log(Level.INFO, "dev.bukkit.org/bukkit-plugins/holographic-displays"); - } + new SimpleUpdater(this, 75097).checkForUpdates(newVersion -> { + HolographicDisplays.newVersion = newVersion; + ConsoleLogger.log(Level.INFO, "Found a new version available: " + newVersion); + ConsoleLogger.log(Level.INFO, "Download it on Bukkit Dev:"); + ConsoleLogger.log(Level.INFO, "dev.bukkit.org/bukkit-plugins/holographic-displays"); }); } diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/bridge/bungeecord/BungeeServerTracker.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/bridge/bungeecord/BungeeServerTracker.java index a1eada59..71f1c0ec 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/bridge/bungeecord/BungeeServerTracker.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/bridge/bungeecord/BungeeServerTracker.java @@ -23,8 +23,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import org.bukkit.Bukkit; -import org.bukkit.scheduler.BukkitRunnable; - import com.gmail.filoghost.holographicdisplays.HolographicDisplays; import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.PingResponse; import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.ServerPinger; @@ -34,7 +32,7 @@ import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger; public class BungeeServerTracker { - private static Map trackedServers = new ConcurrentHashMap(); + private static Map trackedServers = new ConcurrentHashMap<>(); private static int taskID = -1; public static void resetTrackedServers() { @@ -153,66 +151,57 @@ public class BungeeServerTracker { } public static void startTask(int refreshSeconds) { - if (taskID != -1) { Bukkit.getScheduler().cancelTask(taskID); } - taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(HolographicDisplays.getInstance(), new Runnable() { - - @Override - public void run() { + taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(HolographicDisplays.getInstance(), () -> { - if (Configuration.pingerEnable) { - new BukkitRunnable() { - - @Override - public void run() { - for (Entry entry : Configuration.pingerServers.entrySet()) { - - BungeeServerInfo serverInfo = getOrCreateServerInfo(entry.getKey()); - boolean displayOffline = false; - - try { - PingResponse data = ServerPinger.fetchData(entry.getValue(), Configuration.pingerTimeout); - - if (data.isOnline()) { - serverInfo.setOnline(true); - serverInfo.setOnlinePlayers(data.getOnlinePlayers()); - serverInfo.setMaxPlayers(data.getMaxPlayers()); - serverInfo.setMotd(data.getMotd()); - } else { - displayOffline = true; - } - } catch (SocketTimeoutException e) { - displayOffline = true; - } catch (UnknownHostException e) { - ConsoleLogger.log(Level.WARNING, "Couldn't fetch data from " + entry.getKey() + "(" + entry.getValue().toString() + "): unknown host address."); - displayOffline = true; - } catch (IOException e) { - displayOffline = true; - } catch (Throwable t) { - displayOffline = true; - ConsoleLogger.log(Level.WARNING, "Couldn't fetch data from " + entry.getKey() + "(" + entry.getValue().toString() + ")", t); - } - - if (displayOffline) { - serverInfo.setOnline(false); - serverInfo.setOnlinePlayers(0); - serverInfo.setMaxPlayers(0); - serverInfo.setMotd(Configuration.pingerOfflineMotd); - } - } - } - }.runTaskAsynchronously(HolographicDisplays.getInstance()); + if (Configuration.pingerEnable) { + Bukkit.getScheduler().runTaskAsynchronously(HolographicDisplays.getInstance(), () -> { - } else { - for (String server : trackedServers.keySet()) { - BungeeChannel.getInstance().askPlayerCount(server); + for (Entry entry : Configuration.pingerServers.entrySet()) { + BungeeServerInfo serverInfo = getOrCreateServerInfo(entry.getKey()); + boolean displayOffline = false; + + try { + PingResponse data = ServerPinger.fetchData(entry.getValue(), Configuration.pingerTimeout); + + if (data.isOnline()) { + serverInfo.setOnline(true); + serverInfo.setOnlinePlayers(data.getOnlinePlayers()); + serverInfo.setMaxPlayers(data.getMaxPlayers()); + serverInfo.setMotd(data.getMotd()); + } else { + displayOffline = true; + } + } catch (SocketTimeoutException e) { + displayOffline = true; + } catch (UnknownHostException e) { + ConsoleLogger.log(Level.WARNING, "Couldn't fetch data from " + entry.getKey() + "(" + entry.getValue().toString() + "): unknown host address."); + displayOffline = true; + } catch (IOException e) { + displayOffline = true; + } catch (Throwable t) { + displayOffline = true; + ConsoleLogger.log(Level.WARNING, "Couldn't fetch data from " + entry.getKey() + "(" + entry.getValue().toString() + ")", t); + } + + if (displayOffline) { + serverInfo.setOnline(false); + serverInfo.setOnlinePlayers(0); + serverInfo.setMaxPlayers(0); + serverInfo.setMotd(Configuration.pingerOfflineMotd); + } } - } + }); + } else { + for (String server : trackedServers.keySet()) { + BungeeChannel.getInstance().askPlayerCount(server); + } } + }, 1, refreshSeconds * 20); } } diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/bridge/protocollib/current/ProtocolLibHookImpl.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/bridge/protocollib/current/ProtocolLibHookImpl.java index d8196ee2..936a6c71 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/bridge/protocollib/current/ProtocolLibHookImpl.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/bridge/protocollib/current/ProtocolLibHookImpl.java @@ -14,6 +14,7 @@ */ package com.gmail.filoghost.holographicdisplays.bridge.protocollib.current; +import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Optional; @@ -58,7 +59,6 @@ import com.gmail.filoghost.holographicdisplays.object.line.CraftTouchSlimeLine; import com.gmail.filoghost.holographicdisplays.object.line.CraftTouchableLine; import com.gmail.filoghost.holographicdisplays.placeholder.RelativePlaceholder; import com.gmail.filoghost.holographicdisplays.util.NMSVersion; -import com.gmail.filoghost.holographicdisplays.util.Utils; /** * This is for the ProtocolLib versions containing the WrappedDataWatcher.WrappedDataWatcherObject class. @@ -255,7 +255,7 @@ public class ProtocolLibHookImpl implements ProtocolLibHook { @Override public void sendDestroyEntitiesPacket(Player player, CraftHologram hologram) { - List ids = Utils.newList(); + List ids = new ArrayList<>(); for (CraftHologramLine line : hologram.getLinesUnsafe()) { if (line.isSpawned()) { for (int id : line.getEntitiesIDs()) { @@ -278,7 +278,7 @@ public class ProtocolLibHookImpl implements ProtocolLibHook { return; } - List ids = Utils.newList(); + List ids = new ArrayList<>(); for (int id : line.getEntitiesIDs()) { ids.add(id); } diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/HologramsCommandHandler.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/HologramsCommandHandler.java index ace55338..18a1342c 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/HologramsCommandHandler.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/HologramsCommandHandler.java @@ -16,6 +16,7 @@ package com.gmail.filoghost.holographicdisplays.commands.main; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -45,7 +46,6 @@ import com.gmail.filoghost.holographicdisplays.commands.main.subs.RemovelineComm import com.gmail.filoghost.holographicdisplays.commands.main.subs.SetlineCommand; import com.gmail.filoghost.holographicdisplays.commands.main.subs.TeleportCommand; import com.gmail.filoghost.holographicdisplays.exception.CommandException; -import com.gmail.filoghost.holographicdisplays.util.Utils; public class HologramsCommandHandler implements CommandExecutor { @@ -53,8 +53,8 @@ public class HologramsCommandHandler implements CommandExecutor { private Map, HologramSubCommand> subCommandsByClass; public HologramsCommandHandler() { - subCommands = Utils.newList(); - subCommandsByClass = Utils.newMap(); + subCommands = new ArrayList<>(); + subCommandsByClass = new HashMap<>(); registerSubCommand(new AddlineCommand()); registerSubCommand(new CreateCommand()); @@ -84,7 +84,7 @@ public class HologramsCommandHandler implements CommandExecutor { } public List getSubCommands() { - return new ArrayList(subCommands); + return new ArrayList<>(subCommands); } public HologramSubCommand getSubCommand(Class subCommandClass) { diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/EditCommand.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/EditCommand.java index b06a4540..c6c74746 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/EditCommand.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/EditCommand.java @@ -14,6 +14,7 @@ */ package com.gmail.filoghost.holographicdisplays.commands.main.subs; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -29,7 +30,6 @@ import com.gmail.filoghost.holographicdisplays.disk.Configuration; 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.Utils; import com.google.common.collect.Lists; import net.md_5.bungee.api.ChatColor; @@ -79,7 +79,7 @@ public class EditCommand extends HologramSubCommand { if (CommandValidator.isPlayerSender(sender)) { - List help = Utils.newList(); + List help = new ArrayList<>(); help.add(Colors.PRIMARY + usage); for (String tutLine : subCommand.getTutorial()) { help.add(Colors.SECONDARY_SHADOW + tutLine); @@ -88,7 +88,7 @@ public class EditCommand extends HologramSubCommand { ((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(Utils.join(help, "\n")))) + .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(String.join("\n", help)))) .create()); } else { diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/HelpCommand.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/HelpCommand.java index 49512ed2..be97ec99 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/HelpCommand.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/HelpCommand.java @@ -14,6 +14,7 @@ */ package com.gmail.filoghost.holographicdisplays.commands.main.subs; +import java.util.ArrayList; import java.util.List; import org.bukkit.command.CommandSender; @@ -25,8 +26,6 @@ import com.gmail.filoghost.holographicdisplays.commands.CommandValidator; import com.gmail.filoghost.holographicdisplays.commands.Strings; import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand; import com.gmail.filoghost.holographicdisplays.exception.CommandException; -import com.gmail.filoghost.holographicdisplays.util.Utils; - import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; @@ -62,7 +61,7 @@ public class HelpCommand extends HologramSubCommand { if (CommandValidator.isPlayerSender(sender)) { - List help = Utils.newList(); + List help = new ArrayList<>(); help.add(Colors.PRIMARY + usage); for (String tutLine : subCommand.getTutorial()) { help.add(Colors.SECONDARY_SHADOW + tutLine); @@ -71,7 +70,7 @@ public class HelpCommand extends HologramSubCommand { ((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(Utils.join(help, "\n")))) + .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(String.join("\n", help)))) .create()); } else { diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/NearCommand.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/NearCommand.java index 4812f39d..a261add7 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/NearCommand.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/NearCommand.java @@ -14,6 +14,7 @@ */ package com.gmail.filoghost.holographicdisplays.commands.main.subs; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -28,7 +29,6 @@ import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand; 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.Utils; public class NearCommand extends HologramSubCommand { @@ -55,7 +55,7 @@ public class NearCommand extends HologramSubCommand { World world = player.getWorld(); int radiusSquared = radius * radius; - List nearHolograms = Utils.newList(); + List nearHolograms = new ArrayList<>(); for (NamedHologram hologram : NamedHologramManager.getHolograms()) { if (hologram.getLocation().getWorld().equals(world) && hologram.getLocation().distanceSquared(player.getLocation()) <= radiusSquared) { diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/ReadimageCommand.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/ReadimageCommand.java index 58463aae..f7a7d9e5 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/ReadimageCommand.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/ReadimageCommand.java @@ -20,6 +20,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -41,7 +42,6 @@ import com.gmail.filoghost.holographicdisplays.image.ImageMessage; import com.gmail.filoghost.holographicdisplays.object.NamedHologram; import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager; import com.gmail.filoghost.holographicdisplays.util.FileUtils; -import com.gmail.filoghost.holographicdisplays.util.Utils; public class ReadimageCommand extends HologramSubCommand { @@ -67,7 +67,7 @@ public class ReadimageCommand extends HologramSubCommand { boolean append = false; - List newArgs = Utils.newList(); + List newArgs = new ArrayList<>(); for (int i = 0; i < args.length; i++) { if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-append")) { diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/disk/HologramDatabase.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/disk/HologramDatabase.java index 11bbd29b..fe6c1db9 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/disk/HologramDatabase.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/disk/HologramDatabase.java @@ -16,6 +16,7 @@ package com.gmail.filoghost.holographicdisplays.disk; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.logging.Level; @@ -38,7 +39,6 @@ import com.gmail.filoghost.holographicdisplays.object.line.CraftItemLine; import com.gmail.filoghost.holographicdisplays.object.line.CraftTextLine; import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger; import com.gmail.filoghost.holographicdisplays.util.ItemUtils; -import com.gmail.filoghost.holographicdisplays.util.Utils; public class HologramDatabase { @@ -133,7 +133,7 @@ public class HologramDatabase { ConfigurationSection configSection = config.isConfigurationSection(hologram.getName()) ? config.getConfigurationSection(hologram.getName()) : config.createSection(hologram.getName()); configSection.set("location", LocationSerializer.locationToString(hologram.getLocation())); - List lines = Utils.newList(); + List lines = new ArrayList<>(); for (CraftHologramLine line : hologram.getLinesUnsafe()) { diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/image/ImageMessage.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/image/ImageMessage.java index d3072d55..4e8d0f7f 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/image/ImageMessage.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/image/ImageMessage.java @@ -18,6 +18,7 @@ import java.awt.Color; import java.awt.Graphics2D; import java.awt.Image; import java.awt.image.BufferedImage; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -25,7 +26,6 @@ import org.bukkit.ChatColor; import com.gmail.filoghost.holographicdisplays.disk.Configuration; import com.gmail.filoghost.holographicdisplays.exception.TooWideException; -import com.gmail.filoghost.holographicdisplays.util.Utils; /** * Huge thanks to bobacadodl for this awesome library! @@ -35,10 +35,8 @@ public class ImageMessage { public static final int MAX_WIDTH = 150; - private static final Map colorsMap = Utils.newMap(); - - private static final Map graysMap = Utils.newMap(); - + private static final Map colorsMap = new HashMap<>(); + private static final Map graysMap = new HashMap<>(); static { colorsMap.put(ChatColor.DARK_BLUE, new Color(0, 0, 170)); @@ -70,7 +68,7 @@ public class ImageMessage { private ChatColor[][] toChatColorArray(BufferedImage image, int width) throws TooWideException { double ratio = (double) image.getHeight() / image.getWidth(); - int height = (int) (((double)width) * ratio); + int height = (int) ((width) * ratio); if (height == 0) { height = 1; } diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/listener/MainListener.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/listener/MainListener.java index 7e2dd353..2f7d093b 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/listener/MainListener.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/listener/MainListener.java @@ -14,6 +14,7 @@ */ package com.gmail.filoghost.holographicdisplays.listener; +import java.util.HashMap; import java.util.Map; import java.util.logging.Level; @@ -50,13 +51,12 @@ import com.gmail.filoghost.holographicdisplays.object.PluginHologram; import com.gmail.filoghost.holographicdisplays.object.PluginHologramManager; import com.gmail.filoghost.holographicdisplays.object.line.CraftTouchSlimeLine; import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger; -import com.gmail.filoghost.holographicdisplays.util.Utils; public class MainListener implements Listener, ItemPickupManager { private NMSManager nmsManager; - private Map anticlickSpam = Utils.newMap(); + private Map anticlickSpam = new HashMap<>(); public MainListener(NMSManager nmsManager) { this.nmsManager = nmsManager; @@ -86,12 +86,7 @@ public class MainListener implements Listener, ItemPickupManager { if (Bukkit.isPrimaryThread()) { processChunkLoad(chunk); } else { - Bukkit.getScheduler().runTask(HolographicDisplays.getInstance(), new Runnable() { - @Override - public void run() { - processChunkLoad(chunk); - } - }); + Bukkit.getScheduler().runTask(HolographicDisplays.getInstance(), () -> processChunkLoad(chunk)); } } } diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/CraftHologram.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/CraftHologram.java index 1089bf74..4cae1536 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/CraftHologram.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/CraftHologram.java @@ -14,6 +14,7 @@ */ package com.gmail.filoghost.holographicdisplays.object; +import java.util.ArrayList; import java.util.List; import org.bukkit.Chunk; @@ -57,7 +58,7 @@ public class CraftHologram implements Hologram, com.gmail.filoghost.holograms.ap Validator.notNull(location, "location"); updateLocation(location.getWorld(), location.getX(), location.getY(), location.getZ()); - lines = Utils.newList(); + lines = new ArrayList<>(); allowPlaceholders = false; creationTimestamp = System.currentTimeMillis(); visibilityManager = new CraftVisibilityManager(this); diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/CraftVisibilityManager.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/CraftVisibilityManager.java index ef194c5b..538a750a 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/CraftVisibilityManager.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/CraftVisibilityManager.java @@ -78,7 +78,7 @@ public class CraftVisibilityManager implements VisibilityManager { if (playersVisibilityMap == null) { // Lazy initialization - playersVisibilityMap = new ConcurrentHashMap(); + playersVisibilityMap = new ConcurrentHashMap<>(); } playersVisibilityMap.put(player.getName().toLowerCase(), true); @@ -97,7 +97,7 @@ public class CraftVisibilityManager implements VisibilityManager { if (playersVisibilityMap == null) { // Lazy initialization - playersVisibilityMap = new ConcurrentHashMap(); + playersVisibilityMap = new ConcurrentHashMap<>(); } playersVisibilityMap.put(player.getName().toLowerCase(), false); @@ -147,7 +147,7 @@ public class CraftVisibilityManager implements VisibilityManager { if (playersVisibilityMap != null) { // We need to refresh all the players - Set playerNames = new HashSet(playersVisibilityMap.keySet()); + Set playerNames = new HashSet<>(playersVisibilityMap.keySet()); for (String playerName : playerNames) { Player onlinePlayer = Bukkit.getPlayerExact(playerName); diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/NamedHologramManager.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/NamedHologramManager.java index 61c2af2d..2acf7046 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/NamedHologramManager.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/NamedHologramManager.java @@ -19,14 +19,12 @@ import java.util.List; import org.bukkit.Chunk; -import com.gmail.filoghost.holographicdisplays.util.Utils; - /** * This class is only used by the plugin itself. Other plugins should just use the API. */ public class NamedHologramManager { - private static List pluginHolograms = Utils.newList(); + private static List pluginHolograms = new ArrayList<>(); public static void addHologram(NamedHologram hologram) { pluginHolograms.add(hologram); @@ -40,7 +38,7 @@ public class NamedHologramManager { } public static List getHolograms() { - return new ArrayList(pluginHolograms); + return new ArrayList<>(pluginHolograms); } public static NamedHologram getHologram(String name) { @@ -75,7 +73,7 @@ public class NamedHologramManager { } public static void clearAll() { - List oldHolograms = new ArrayList(pluginHolograms); + List oldHolograms = new ArrayList<>(pluginHolograms); pluginHolograms.clear(); for (NamedHologram hologram : oldHolograms) { diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/PluginHologramManager.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/PluginHologramManager.java index 79ad6015..5ee70dbb 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/PluginHologramManager.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/PluginHologramManager.java @@ -16,6 +16,7 @@ package com.gmail.filoghost.holographicdisplays.object; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -23,14 +24,13 @@ import org.bukkit.Chunk; import org.bukkit.plugin.Plugin; import com.gmail.filoghost.holographicdisplays.api.Hologram; -import com.gmail.filoghost.holographicdisplays.util.Utils; /** * This class is only used by the plugin itself. Other plugins should just use the API. */ public class PluginHologramManager { - private static List pluginHolograms = Utils.newList(); + private static List pluginHolograms = new ArrayList<>(); public static void addHologram(PluginHologram hologram) { pluginHolograms.add(hologram); @@ -44,11 +44,11 @@ public class PluginHologramManager { } public static List getHolograms() { - return new ArrayList(pluginHolograms); + return new ArrayList<>(pluginHolograms); } public static Set getHolograms(Plugin plugin) { - Set ownedHolograms = Utils.newSet(); + Set ownedHolograms = new HashSet<>(); for (PluginHologram hologram : pluginHolograms) { if (hologram.getOwner().equals(plugin)) { @@ -78,7 +78,7 @@ public class PluginHologramManager { } public static void clearAll() { - List oldHolograms = new ArrayList(pluginHolograms); + List oldHolograms = new ArrayList<>(pluginHolograms); pluginHolograms.clear(); for (PluginHologram hologram : oldHolograms) { diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/line/CraftTextLine.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/line/CraftTextLine.java index e8cd660b..bcbd6099 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/line/CraftTextLine.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/object/line/CraftTextLine.java @@ -14,6 +14,7 @@ */ package com.gmail.filoghost.holographicdisplays.object.line; +import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -29,7 +30,6 @@ import com.gmail.filoghost.holographicdisplays.object.CraftHologram; import com.gmail.filoghost.holographicdisplays.placeholder.PlaceholdersManager; import com.gmail.filoghost.holographicdisplays.placeholder.RelativePlaceholder; import com.gmail.filoghost.holographicdisplays.util.Offsets; -import com.gmail.filoghost.holographicdisplays.util.Utils; public class CraftTextLine extends CraftTouchableLine implements TextLine { @@ -71,7 +71,7 @@ public class CraftTextLine extends CraftTouchableLine implements TextLine { for (RelativePlaceholder relativePlaceholder : RelativePlaceholder.getRegistry()) { if (text.contains(relativePlaceholder.getTextPlaceholder())) { if (relativePlaceholders == null) { - relativePlaceholders = Utils.newList(); + relativePlaceholders = new ArrayList<>(); } relativePlaceholders.add(relativePlaceholder); } diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/AnimationsRegister.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/AnimationsRegister.java index 9c4c6926..4bd21df9 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/AnimationsRegister.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/AnimationsRegister.java @@ -15,6 +15,7 @@ package com.gmail.filoghost.holographicdisplays.placeholder; import java.io.File; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Level; @@ -25,12 +26,11 @@ import com.gmail.filoghost.holographicdisplays.HolographicDisplays; import com.gmail.filoghost.holographicdisplays.disk.StringConverter; import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger; import com.gmail.filoghost.holographicdisplays.util.FileUtils; -import com.gmail.filoghost.holographicdisplays.util.Utils; public class AnimationsRegister { // - private final static Map animations = Utils.newMap(); + private final static Map animations = new HashMap<>(); public static void loadAnimations(Plugin plugin) { animations.clear(); diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/DynamicLineData.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/DynamicLineData.java index 42ffcaf1..5723845e 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/DynamicLineData.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/DynamicLineData.java @@ -14,12 +14,13 @@ */ package com.gmail.filoghost.holographicdisplays.placeholder; +import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; import com.gmail.filoghost.holographicdisplays.api.placeholder.PlaceholderReplacer; import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSNameable; -import com.gmail.filoghost.holographicdisplays.util.Utils; import com.gmail.filoghost.holographicdisplays.util.Validator; public class DynamicLineData { @@ -36,9 +37,9 @@ public class DynamicLineData { this.entity = entity; this.originalName = originalName; - placeholders = Utils.newSet(); - animations = Utils.newMap(); - replacers = Utils.newMap(); + placeholders = new HashSet<>(); + animations = new HashMap<>(); + replacers = new HashMap<>(); } public NMSNameable getEntity() { diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/PlaceholdersManager.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/PlaceholdersManager.java index e8ec06e1..b5f39f94 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/PlaceholdersManager.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/PlaceholdersManager.java @@ -14,6 +14,8 @@ */ package com.gmail.filoghost.holographicdisplays.placeholder; +import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; @@ -36,7 +38,7 @@ import com.gmail.filoghost.holographicdisplays.util.Utils; public class PlaceholdersManager { private static long elapsedTenthsOfSecond; - protected static Set linesToUpdate = Utils.newSet(); + protected static Set linesToUpdate = new HashSet<>(); private static final Pattern BUNGEE_ONLINE_PATTERN = makePlaceholderWithArgsPattern("online"); private static final Pattern BUNGEE_MAX_PATTERN = makePlaceholderWithArgsPattern("max_players"); @@ -56,43 +58,39 @@ public class PlaceholdersManager { public static void load(Plugin plugin) { - Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { + Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> { - @Override - public void run() { - - for (Placeholder placeholder : PlaceholdersRegister.getPlaceholders()) { - if (elapsedTenthsOfSecond % placeholder.getTenthsToRefresh() == 0) { - try { - placeholder.update(); - } catch (Throwable t) { - ConsoleLogger.log(Level.WARNING, "The placeholder " + placeholder.getTextPlaceholder() + " registered by the plugin " + placeholder.getOwner().getName() + " generated an exception while updating. Please contact the author of " + placeholder.getOwner().getName(), t); - } - } - } - - for (Placeholder placeholder : AnimationsRegister.getAnimations().values()) { - if (elapsedTenthsOfSecond % placeholder.getTenthsToRefresh() == 0) { + for (Placeholder placeholder : PlaceholdersRegister.getPlaceholders()) { + if (elapsedTenthsOfSecond % placeholder.getTenthsToRefresh() == 0) { + try { placeholder.update(); + } catch (Throwable t) { + ConsoleLogger.log(Level.WARNING, "The placeholder " + placeholder.getTextPlaceholder() + " registered by the plugin " + placeholder.getOwner().getName() + " generated an exception while updating. Please contact the author of " + placeholder.getOwner().getName(), t); } } - - Iterator iter = linesToUpdate.iterator(); - DynamicLineData currentLineData; - - while (iter.hasNext()) { - currentLineData = iter.next(); - - if (currentLineData.getEntity().isDeadNMS()) { - iter.remove(); - } else { - updatePlaceholders(currentLineData); - } - } - - elapsedTenthsOfSecond++; } + for (Placeholder placeholder : AnimationsRegister.getAnimations().values()) { + if (elapsedTenthsOfSecond % placeholder.getTenthsToRefresh() == 0) { + placeholder.update(); + } + } + + Iterator iter = linesToUpdate.iterator(); + DynamicLineData currentLineData; + + while (iter.hasNext()) { + currentLineData = iter.next(); + + if (currentLineData.getEntity().isDeadNMS()) { + iter.remove(); + } else { + updatePlaceholders(currentLineData); + } + } + + elapsedTenthsOfSecond++; + }, 2L, 2L); } @@ -142,7 +140,7 @@ public class PlaceholdersManager { if (name.contains(placeholder.getTextPlaceholder())) { if (normalPlaceholders == null) { - normalPlaceholders = Utils.newSet(); + normalPlaceholders = new HashSet<>(); } normalPlaceholders.add(placeholder); @@ -155,16 +153,12 @@ public class PlaceholdersManager { while (matcher.find()) { if (worldsOnlinePlayersReplacers == null) { - worldsOnlinePlayersReplacers = Utils.newMap(); + worldsOnlinePlayersReplacers = new HashMap<>(); } final String worldName = extractArgumentFromPlaceholder(matcher); - worldsOnlinePlayersReplacers.put(matcher.group(), new PlaceholderReplacer() { - - @Override - public String update() { - return WorldPlayerCounterTask.getCount(worldName); - } + worldsOnlinePlayersReplacers.put(matcher.group(), () -> { + return WorldPlayerCounterTask.getCount(worldName); }); } @@ -173,7 +167,7 @@ public class PlaceholdersManager { while (matcher.find()) { if (bungeeReplacers == null) { - bungeeReplacers = Utils.newMap(); + bungeeReplacers = new HashMap<>(); } final String serverName = extractArgumentFromPlaceholder(matcher); @@ -189,25 +183,17 @@ public class PlaceholdersManager { final String[] serversToTrack = split; // Add it to tracked servers. - bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() { - - @Override - public String update() { - int count = 0; - for (String serverToTrack : serversToTrack) { - count += BungeeServerTracker.getPlayersOnline(serverToTrack); - } - return String.valueOf(count); + bungeeReplacers.put(matcher.group(), () -> { + int count = 0; + for (String serverToTrack : serversToTrack) { + count += BungeeServerTracker.getPlayersOnline(serverToTrack); } + return String.valueOf(count); }); } else { // Normal, single tracked server. - bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() { - - @Override - public String update() { - return String.valueOf(BungeeServerTracker.getPlayersOnline(serverName)); - } + bungeeReplacers.put(matcher.group(), () -> { + return String.valueOf(BungeeServerTracker.getPlayersOnline(serverName)); }); } } @@ -217,19 +203,15 @@ public class PlaceholdersManager { while (matcher.find()) { if (bungeeReplacers == null) { - bungeeReplacers = Utils.newMap(); + bungeeReplacers = new HashMap<>(); } final String serverName = extractArgumentFromPlaceholder(matcher); BungeeServerTracker.track(serverName); // Track this server. // Add it to tracked servers. - bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() { - - @Override - public String update() { - return BungeeServerTracker.getMaxPlayers(serverName); - } + bungeeReplacers.put(matcher.group(), () -> { + return BungeeServerTracker.getMaxPlayers(serverName); }); } @@ -238,19 +220,15 @@ public class PlaceholdersManager { while (matcher.find()) { if (bungeeReplacers == null) { - bungeeReplacers = Utils.newMap(); + bungeeReplacers = new HashMap<>(); } final String serverName = extractArgumentFromPlaceholder(matcher); BungeeServerTracker.track(serverName); // Track this server. // Add it to tracked servers. - bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() { - - @Override - public String update() { - return BungeeServerTracker.getMotd1(serverName); - } + bungeeReplacers.put(matcher.group(), () -> { + return BungeeServerTracker.getMotd1(serverName); }); } @@ -259,19 +237,15 @@ public class PlaceholdersManager { while (matcher.find()) { if (bungeeReplacers == null) { - bungeeReplacers = Utils.newMap(); + bungeeReplacers = new HashMap<>(); } final String serverName = extractArgumentFromPlaceholder(matcher); BungeeServerTracker.track(serverName); // Track this server. // Add it to tracked servers. - bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() { - - @Override - public String update() { - return BungeeServerTracker.getMotd2(serverName); - } + bungeeReplacers.put(matcher.group(), () -> { + return BungeeServerTracker.getMotd2(serverName); }); } @@ -280,19 +254,15 @@ public class PlaceholdersManager { while (matcher.find()) { if (bungeeReplacers == null) { - bungeeReplacers = Utils.newMap(); + bungeeReplacers = new HashMap<>(); } final String serverName = extractArgumentFromPlaceholder(matcher); BungeeServerTracker.track(serverName); // Track this server. // Add it to tracked servers. - bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() { - - @Override - public String update() { - return BungeeServerTracker.getOnlineStatus(serverName); - } + bungeeReplacers.put(matcher.group(), () -> { + return BungeeServerTracker.getOnlineStatus(serverName); }); } @@ -308,7 +278,7 @@ public class PlaceholdersManager { if (animation != null) { if (animationsPlaceholders == null) { - animationsPlaceholders = Utils.newMap(); + animationsPlaceholders = new HashMap<>(); } animationsPlaceholders.put(matcher.group(), animation); diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/PlaceholdersRegister.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/PlaceholdersRegister.java index 94560775..31fd2ca4 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/PlaceholdersRegister.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/PlaceholdersRegister.java @@ -15,6 +15,7 @@ package com.gmail.filoghost.holographicdisplays.placeholder; import java.util.Date; +import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -23,47 +24,30 @@ import org.bukkit.ChatColor; import org.bukkit.plugin.Plugin; import com.gmail.filoghost.holographicdisplays.HolographicDisplays; -import com.gmail.filoghost.holographicdisplays.api.placeholder.PlaceholderReplacer; import com.gmail.filoghost.holographicdisplays.disk.Configuration; import com.gmail.filoghost.holographicdisplays.util.Utils; public class PlaceholdersRegister { - private static final Set placeholders = Utils.newSet(); + private static final Set placeholders = new HashSet<>(); // Register the default placeholders statically. static { - register(new Placeholder(HolographicDisplays.getInstance(), "{online}", 1.0, new PlaceholderReplacer() { - - @Override - public String update() { - return String.valueOf(Bukkit.getOnlinePlayers().size()); - } + register(new Placeholder(HolographicDisplays.getInstance(), "{online}", 1.0, () -> { + return String.valueOf(Bukkit.getOnlinePlayers().size()); })); - register(new Placeholder(HolographicDisplays.getInstance(), "{max_players}", 10.0, new PlaceholderReplacer() { - - @Override - public String update() { - return String.valueOf(Bukkit.getMaxPlayers()); - } + register(new Placeholder(HolographicDisplays.getInstance(), "{max_players}", 10.0, () -> { + return String.valueOf(Bukkit.getMaxPlayers()); })); - register(new Placeholder(HolographicDisplays.getInstance(), "{motd}", 60.0, new PlaceholderReplacer() { - - @Override - public String update() { - return Bukkit.getMotd(); - } + register(new Placeholder(HolographicDisplays.getInstance(), "{motd}", 60.0, () -> { + return Bukkit.getMotd(); })); - register(new Placeholder(HolographicDisplays.getInstance(), "{time}", 0.9, new PlaceholderReplacer() { - - @Override - public String update() { - return Configuration.timeFormat.format(new Date()); - } + register(new Placeholder(HolographicDisplays.getInstance(), "{time}", 0.9, () -> { + return Configuration.timeFormat.format(new Date()); })); register(new Placeholder(HolographicDisplays.getInstance(), "&u", 0.2, new CyclicPlaceholderReplacer(Utils.arrayToStrings( @@ -87,7 +71,7 @@ public class PlaceholdersRegister { } public static Set getTextPlaceholdersByPlugin(Plugin plugin) { - Set found = Utils.newSet(); + Set found = new HashSet<>(); for (Placeholder placeholder : placeholders) { if (placeholder.getOwner().equals(plugin)) { diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/RelativePlaceholder.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/RelativePlaceholder.java index a6fd6ace..b8d1c22b 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/RelativePlaceholder.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/placeholder/RelativePlaceholder.java @@ -15,13 +15,13 @@ package com.gmail.filoghost.holographicdisplays.placeholder; import java.util.Collection; -import org.bukkit.entity.Player; +import java.util.HashSet; -import com.gmail.filoghost.holographicdisplays.util.Utils; +import org.bukkit.entity.Player; public abstract class RelativePlaceholder { - private static final Collection registry = Utils.newSet(); + private static final Collection registry = new HashSet<>(); // The placeholder itself, something like {player}. private final String textPlaceholder; diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/task/WorldPlayerCounterTask.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/task/WorldPlayerCounterTask.java index b31c8bde..4207ab7a 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/task/WorldPlayerCounterTask.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/task/WorldPlayerCounterTask.java @@ -14,6 +14,7 @@ */ package com.gmail.filoghost.holographicdisplays.task; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -21,11 +22,9 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; -import com.gmail.filoghost.holographicdisplays.util.Utils; - public class WorldPlayerCounterTask implements Runnable { - private static Map worlds = Utils.newMap(); + private static Map worlds = new HashMap<>(); @Override public void run() { diff --git a/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/FileUtils.java b/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/FileUtils.java index bfa8fe63..8e6e3dcf 100644 --- a/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/FileUtils.java +++ b/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/FileUtils.java @@ -41,7 +41,7 @@ public class FileUtils { try { - List lines = new ArrayList(); + List lines = new ArrayList<>(); if (!file.exists()) { throw new FileNotFoundException(); diff --git a/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/ItemUtils.java b/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/ItemUtils.java index 7b4c71da..e6ac3696 100644 --- a/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/ItemUtils.java +++ b/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/ItemUtils.java @@ -27,7 +27,7 @@ public class ItemUtils { public static final String ANTISTACK_LORE = ChatColor.BLACK.toString() + Math.random(); // A map with formatted materials (lowercase and without symbols) for fast access. - private static final Map NAMES_TO_MATERIALS = new HashMap(); + private static final Map NAMES_TO_MATERIALS = new HashMap<>(); // The chars that will be ignored when matching materials. private static final Pattern STRIP_SPACING_SYMBOLS_PATTERN = Pattern.compile("[_ \\-]+"); diff --git a/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/Utils.java b/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/Utils.java index 5b857cf2..a09ee9f5 100644 --- a/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/Utils.java +++ b/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/Utils.java @@ -14,13 +14,6 @@ */ package com.gmail.filoghost.holographicdisplays.util; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.bukkit.ChatColor; public class Utils extends Object { @@ -59,19 +52,6 @@ public class Utils extends Object { } - public static Map newMap() { - return new HashMap(); - } - - public static List newList() { - return new ArrayList(); - } - - public static Set newSet() { - return new HashSet(); - } - - public static int floor(double num) { int floor = (int) num; return floor == num ? floor : floor - (int) (Double.doubleToRawLongBits(num) >>> 63); @@ -103,19 +83,6 @@ public class Utils extends Object { return result.toString(); } - - public static String join(String[] elements, String separator) { - return join(elements, separator, 0, elements.length); - } - - public static String join(List elements, String separator, int startIndex, int size) { - return join(elements.toArray(new String[elements.size()]), separator, startIndex, size); - } - - public static String join(List elements, String separator) { - return join(elements, separator, 0, elements.size()); - } - public static String sanitize(String s) { return s != null ? s : "null"; diff --git a/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/reflection/ReflectionUtils.java b/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/reflection/ReflectionUtils.java index 705c2036..998328aa 100644 --- a/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/reflection/ReflectionUtils.java +++ b/Utils/src/main/java/com/gmail/filoghost/holographicdisplays/util/reflection/ReflectionUtils.java @@ -15,7 +15,6 @@ package com.gmail.filoghost.holographicdisplays.util.reflection; import java.lang.StackWalker.StackFrame; -import java.util.function.Function; import java.util.logging.Level; import java.util.stream.Stream; @@ -26,8 +25,8 @@ public class ReflectionUtils { private static final boolean HAS_JAVA9_STACKWALKER = Utils.classExists("java.lang.StackWalker"); - private static final ReflectMethod GET_STACKTRACE_DEPTH_METHOD = new ReflectMethod(Throwable.class, "getStackTraceDepth"); - private static final ReflectMethod GET_STACKTRACE_ELEMENT_METHOD = new ReflectMethod(Throwable.class, "getStackTraceElement", int.class); + private static final ReflectMethod GET_STACKTRACE_DEPTH_METHOD = new ReflectMethod<>(Throwable.class, "getStackTraceDepth"); + private static final ReflectMethod GET_STACKTRACE_ELEMENT_METHOD = new ReflectMethod<>(Throwable.class, "getStackTraceElement", int.class); private static boolean stackTraceError; @@ -42,13 +41,8 @@ public class ReflectionUtils { try { if (HAS_JAVA9_STACKWALKER) { // Use the Java 9 StackWalker API - StackFrame result = StackWalker.getInstance().walk(new Function, StackFrame>() { - - @Override - public StackFrame apply(Stream stream) { - return stream.skip(index).limit(1).findFirst().orElse(null); - } - + StackFrame result = StackWalker.getInstance().walk((Stream stream) -> { + return stream.skip(index).limit(1).findFirst().orElse(null); }); return result != null ? result.toStackTraceElement() : null; diff --git a/pom.xml b/pom.xml index d41450af..c3025601 100644 --- a/pom.xml +++ b/pom.xml @@ -11,8 +11,8 @@ UTF-8 - 1.6 - 1.6 + 1.8 + 1.8 true 1.8-R0.1-SNAPSHOT