Update to Java 8

This commit is contained in:
filoghost 2019-06-03 14:42:24 +02:00
parent fa1f8d260e
commit 66fe72b0eb
70 changed files with 246 additions and 456 deletions

View File

@ -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())) {

View File

@ -30,7 +30,7 @@ import com.gmail.filoghost.holographicdisplays.util.FileUtils;
public class UnicodeSymbols {
private static Map<String, String> placeholders = new HashMap<String, String>();
private static Map<String, String> placeholders = new HashMap<>();
public static void load(Plugin plugin) {
placeholders.clear();

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
package java.util;
public class Optional<T> {
public T orElse(T other) {
return null;
}
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
package java.util.function;
public interface Function<T, R> {
R apply(T t);
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
package java.util.stream;
import java.util.Optional;
public interface Stream<T> {
public Stream<T> skip(long n);
public Stream<T> limit(long maxSize);
public Optional<T> findFirst();
}

View File

@ -44,7 +44,7 @@ import net.minecraft.server.v1_10_R1.World;
public class EntityNMSItem extends EntityItem implements NMSItem {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "au");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
private boolean lockTick;
private ItemLine parentPiece;

View File

@ -40,7 +40,7 @@ import net.minecraft.server.v1_10_R1.World;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "au");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -41,8 +41,8 @@ import net.minecraft.server.v1_10_R1.WorldServer;
public class NmsManagerImpl implements NMSManager {
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<Map<Class<?>, String>>(EntityTypes.class, "d");
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<Map<Class<?>, Integer>>(EntityTypes.class, "f");
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d");
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
private Method validateEntityMethod;

View File

@ -42,7 +42,7 @@ import net.minecraft.server.v1_11_R1.World;
public class EntityNMSItem extends EntityItem implements NMSItem {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "au");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
private boolean lockTick;
private ItemLine parentPiece;

View File

@ -38,7 +38,7 @@ import net.minecraft.server.v1_11_R1.World;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "au");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -42,8 +42,8 @@ import net.minecraft.server.v1_11_R1.WorldServer;
public class NmsManagerImpl implements NMSManager {
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = new ReflectField<RegistryID<Class<? extends Entity>>>(RegistryMaterials.class, "a");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<Object[]>(RegistryID.class, "d");
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
private Method validateEntityMethod;

View File

@ -42,7 +42,7 @@ import net.minecraft.server.v1_12_R1.World;
public class EntityNMSItem extends EntityItem implements NMSItem {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "au");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
private boolean lockTick;
private ItemLine parentPiece;

View File

@ -38,7 +38,7 @@ import net.minecraft.server.v1_12_R1.World;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "au");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "au");
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -42,8 +42,8 @@ import net.minecraft.server.v1_12_R1.WorldServer;
public class NmsManagerImpl implements NMSManager {
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = new ReflectField<RegistryID<Class<? extends Entity>>>(RegistryMaterials.class, "a");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<Object[]>(RegistryID.class, "d");
private static final ReflectField<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
private Method validateEntityMethod;

View File

@ -42,7 +42,7 @@ import net.minecraft.server.v1_13_R1.World;
public class EntityNMSItem extends EntityItem implements NMSItem {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "ax");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax");
private boolean lockTick;
private ItemLine parentPiece;

View File

@ -39,7 +39,7 @@ import net.minecraft.server.v1_13_R1.World;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "ax");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "ax");
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -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<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = new ReflectField<RegistryID<EntityTypes<?>>>(RegistryMaterials.class, "a");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<Object[]>(RegistryID.class, "d");
private static final ReflectField<List<Entity>> ENTITY_LIST_FIELD = new ReflectField<List<Entity>>(World.class, "entityList");
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
private static final ReflectField<List<Entity>> ENTITY_LIST_FIELD = new ReflectField<>(World.class, "entityList");
private Method validateEntityMethod;
@ -68,14 +66,7 @@ public class NmsManagerImpl implements NMSManager {
Object oldValue = idToClassMap[id];
// Register the EntityTypes object.
registryID.a(new EntityTypes<Entity>(entityClass, new Function<World, Entity>() {
@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;

View File

@ -42,7 +42,7 @@ import net.minecraft.server.v1_13_R2.World;
public class EntityNMSItem extends EntityItem implements NMSItem {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "vehicle");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "vehicle");
private boolean lockTick;
private ItemLine parentPiece;

View File

@ -39,7 +39,7 @@ import net.minecraft.server.v1_13_R2.World;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "vehicle");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "vehicle");
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -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<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = new ReflectField<RegistryID<EntityTypes<?>>>(RegistryMaterials.class, "b");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<Object[]>(RegistryID.class, "d");
private static final ReflectField<List<Entity>> ENTITY_LIST_FIELD = new ReflectField<List<Entity>>(World.class, "entityList");
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "b");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
private static final ReflectField<List<Entity>> ENTITY_LIST_FIELD = new ReflectField<>(World.class, "entityList");
private Method validateEntityMethod;
@ -69,14 +67,7 @@ public class NmsManagerImpl implements NMSManager {
Object oldValue = idToClassMap[id];
// Register the EntityTypes object.
registryID.a(new EntityTypes<Entity>(entityClass, new Function<World, Entity>() {
@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;

View File

@ -43,7 +43,7 @@ import net.minecraft.server.v1_14_R1.World;
public class EntityNMSItem extends EntityItem implements NMSItem {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "vehicle");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "vehicle");
private boolean lockTick;
private ItemLine parentPiece;

View File

@ -40,7 +40,7 @@ import net.minecraft.server.v1_14_R1.World;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "vehicle");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "vehicle");
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -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<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = new ReflectField<RegistryID<EntityTypes<?>>>(RegistryMaterials.class, "b");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<Object[]>(RegistryID.class, "d");
private static final ReflectMethod<Void> REGISTER_ENTITY_METHOD = new ReflectMethod<Void>(WorldServer.class, "registerEntity", Entity.class);
private static final ReflectField<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "b");
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
private static final ReflectMethod<Void> 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<Entity>(new EntityTypes.b<Entity>() {
@Override
public Entity create(EntityTypes<Entity> 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;

View File

@ -37,7 +37,7 @@ import net.minecraft.server.v1_8_R1.World;
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
private static final ReflectField<Integer> DISABLED_SLOTS_FIELD = new ReflectField<Integer>(EntityArmorStand.class, "bg");
private static final ReflectField<Integer> DISABLED_SLOTS_FIELD = new ReflectField<>(EntityArmorStand.class, "bg");
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R1.World;
public class EntityNMSItem extends EntityItem implements NMSItem {
private static final ReflectField<Double> RIDER_PITCH_DELTA = new ReflectField<Double>(Entity.class, "ap");
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<Double>(Entity.class, "aq");
private static final ReflectField<Double> RIDER_PITCH_DELTA = new ReflectField<>(Entity.class, "ap");
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "aq");
private boolean lockTick;
private ItemLine parentPiece;

View File

@ -37,8 +37,8 @@ import net.minecraft.server.v1_8_R1.World;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private static final ReflectField<Double> RIDER_PITCH_DELTA = new ReflectField<Double>(Entity.class, "ap");
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<Double>(Entity.class, "aq");
private static final ReflectField<Double> RIDER_PITCH_DELTA = new ReflectField<>(Entity.class, "ap");
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "aq");
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R1.WorldServer;
public class NmsManagerImpl implements NMSManager {
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<Map<Class<?>, String>>(EntityTypes.class, "d");
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<Map<Class<?>, Integer>>(EntityTypes.class, "f");
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d");
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
private Method validateEntityMethod;

View File

@ -41,8 +41,8 @@ import net.minecraft.server.v1_8_R2.World;
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
private static final ReflectField<Integer> DISABLED_SLOTS_FIELD = new ReflectField<Integer>(EntityArmorStand.class, "bi");
private static final ReflectMethod<Void> SET_MARKER_METHOD = new ReflectMethod<Void>(EntityArmorStand.class, "n", boolean.class);
private static final ReflectField<Integer> DISABLED_SLOTS_FIELD = new ReflectField<>(EntityArmorStand.class, "bi");
private static final ReflectMethod<Void> SET_MARKER_METHOD = new ReflectMethod<>(EntityArmorStand.class, "n", boolean.class);
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R2.World;
public class EntityNMSItem extends EntityItem implements NMSItem {
private static final ReflectField<Double> RIDER_PITCH_DELTA = new ReflectField<Double>(Entity.class, "ar");
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<Double>(Entity.class, "as");
private static final ReflectField<Double> RIDER_PITCH_DELTA = new ReflectField<>(Entity.class, "ar");
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "as");
private boolean lockTick;
private ItemLine parentPiece;

View File

@ -37,8 +37,8 @@ import net.minecraft.server.v1_8_R2.World;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private static final ReflectField<Double> RIDER_PITCH_DELTA = new ReflectField<Double>(Entity.class, "ar");
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<Double>(Entity.class, "as");
private static final ReflectField<Double> RIDER_PITCH_DELTA = new ReflectField<>(Entity.class, "ar");
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "as");
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R2.WorldServer;
public class NmsManagerImpl implements NMSManager {
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<Map<Class<?>, String>>(EntityTypes.class, "d");
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<Map<Class<?>, Integer>>(EntityTypes.class, "f");
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d");
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
private Method validateEntityMethod;

View File

@ -41,8 +41,8 @@ import net.minecraft.server.v1_8_R3.World;
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
private static final ReflectField<Integer> DISABLED_SLOTS_FIELD = new ReflectField<Integer>(EntityArmorStand.class, "bi");
private static final ReflectMethod<Void> SET_MARKER_METHOD = new ReflectMethod<Void>(EntityArmorStand.class, "n", boolean.class);
private static final ReflectField<Integer> DISABLED_SLOTS_FIELD = new ReflectField<>(EntityArmorStand.class, "bi");
private static final ReflectMethod<Void> SET_MARKER_METHOD = new ReflectMethod<>(EntityArmorStand.class, "n", boolean.class);
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R3.World;
public class EntityNMSItem extends EntityItem implements NMSItem {
private static final ReflectField<Double> RIDER_PITCH_DELTA = new ReflectField<Double>(Entity.class, "ar");
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<Double>(Entity.class, "as");
private static final ReflectField<Double> RIDER_PITCH_DELTA = new ReflectField<>(Entity.class, "ar");
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "as");
private boolean lockTick;
private ItemLine parentPiece;

View File

@ -37,8 +37,8 @@ import net.minecraft.server.v1_8_R3.World;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private static final ReflectField<Double> RIDER_PITCH_DELTA = new ReflectField<Double>(Entity.class, "ar");
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<Double>(Entity.class, "as");
private static final ReflectField<Double> RIDER_PITCH_DELTA = new ReflectField<>(Entity.class, "ar");
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "as");
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R3.WorldServer;
public class NmsManagerImpl implements NMSManager {
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<Map<Class<?>, String>>(EntityTypes.class, "d");
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<Map<Class<?>, Integer>>(EntityTypes.class, "f");
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d");
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
private Method validateEntityMethod;

View File

@ -40,7 +40,7 @@ import net.minecraft.server.v1_9_R1.World;
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
private static final ReflectField<Integer> DISABLED_SLOTS_FIELD = new ReflectField<Integer>(EntityArmorStand.class, "bz");
private static final ReflectField<Integer> DISABLED_SLOTS_FIELD = new ReflectField<>(EntityArmorStand.class, "bz");
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -44,7 +44,7 @@ import net.minecraft.server.v1_9_R1.World;
public class EntityNMSItem extends EntityItem implements NMSItem {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "as");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "as");
private boolean lockTick;
private ItemLine parentPiece;

View File

@ -40,7 +40,7 @@ import net.minecraft.server.v1_9_R1.World;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "as");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "as");
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -41,8 +41,8 @@ import net.minecraft.server.v1_9_R1.WorldServer;
public class NmsManagerImpl implements NMSManager {
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<Map<Class<?>, String>>(EntityTypes.class, "d");
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<Map<Class<?>, Integer>>(EntityTypes.class, "f");
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d");
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
private Method validateEntityMethod;

View File

@ -44,7 +44,7 @@ import net.minecraft.server.v1_9_R2.World;
public class EntityNMSItem extends EntityItem implements NMSItem {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "at");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "at");
private boolean lockTick;
private ItemLine parentPiece;

View File

@ -40,7 +40,7 @@ import net.minecraft.server.v1_9_R2.World;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<Entity>(Entity.class, "at");
private static final ReflectField<Entity> VEHICLE_FIELD = new ReflectField<>(Entity.class, "at");
private boolean lockTick;
private HologramLine parentPiece;

View File

@ -41,8 +41,8 @@ import net.minecraft.server.v1_9_R2.WorldServer;
public class NmsManagerImpl implements NMSManager {
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<Map<Class<?>, String>>(EntityTypes.class, "d");
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<Map<Class<?>, Integer>>(EntityTypes.class, "f");
private static final ReflectField<Map<Class<?>, String>> ENTITY_NAMES_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "d");
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
private Method validateEntityMethod;

View File

@ -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<String> notifiedPlugins = new HashSet<String>();
private static Set<String> 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<Player> whoCanSeeList = new ArrayList<Player>();
List<Player> 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<Player> whoCanSeeList = new ArrayList<Player>();
List<Player> 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<Hologram> pluginHolograms = Utils.newList();
List<Hologram> pluginHolograms = new ArrayList<>();;
for (PluginHologram pluginHologram : PluginHologramManager.getHolograms()) {
if (pluginHologram.getOwner().equals(plugin)) {
pluginHolograms.add(pluginHologram);

View File

@ -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) {
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");
}
});
}

View File

@ -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<String, BungeeServerInfo> trackedServers = new ConcurrentHashMap<String, BungeeServerInfo>();
private static Map<String, BungeeServerInfo> trackedServers = new ConcurrentHashMap<>();
private static int taskID = -1;
public static void resetTrackedServers() {
@ -153,23 +151,16 @@ 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() {
Bukkit.getScheduler().runTaskAsynchronously(HolographicDisplays.getInstance(), () -> {
@Override
public void run() {
for (Entry<String, ServerAddress> entry : Configuration.pingerServers.entrySet()) {
BungeeServerInfo serverInfo = getOrCreateServerInfo(entry.getKey());
boolean displayOffline = false;
@ -203,8 +194,7 @@ public class BungeeServerTracker {
serverInfo.setMotd(Configuration.pingerOfflineMotd);
}
}
}
}.runTaskAsynchronously(HolographicDisplays.getInstance());
});
} else {
for (String server : trackedServers.keySet()) {
@ -212,7 +202,6 @@ public class BungeeServerTracker {
}
}
}
}, 1, refreshSeconds * 20);
}
}

View File

@ -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<Integer> ids = Utils.newList();
List<Integer> 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<Integer> ids = Utils.newList();
List<Integer> ids = new ArrayList<>();
for (int id : line.getEntitiesIDs()) {
ids.add(id);
}

View File

@ -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<Class<? extends HologramSubCommand>, 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<HologramSubCommand> getSubCommands() {
return new ArrayList<HologramSubCommand>(subCommands);
return new ArrayList<>(subCommands);
}
public HologramSubCommand getSubCommand(Class<? extends HologramSubCommand> subCommandClass) {

View File

@ -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<String> help = Utils.newList();
List<String> 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 {

View File

@ -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<String> help = Utils.newList();
List<String> 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 {

View File

@ -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<NamedHologram> nearHolograms = Utils.newList();
List<NamedHologram> nearHolograms = new ArrayList<>();
for (NamedHologram hologram : NamedHologramManager.getHolograms()) {
if (hologram.getLocation().getWorld().equals(world) && hologram.getLocation().distanceSquared(player.getLocation()) <= radiusSquared) {

View File

@ -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<String> newArgs = Utils.newList();
List<String> newArgs = new ArrayList<>();
for (int i = 0; i < args.length; i++) {
if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-append")) {

View File

@ -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<String> lines = Utils.newList();
List<String> lines = new ArrayList<>();
for (CraftHologramLine line : hologram.getLinesUnsafe()) {

View File

@ -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<ChatColor, Color> colorsMap = Utils.newMap();
private static final Map<ChatColor, Color> graysMap = Utils.newMap();
private static final Map<ChatColor, Color> colorsMap = new HashMap<>();
private static final Map<ChatColor, Color> 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;
}

View File

@ -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<Player, Long> anticlickSpam = Utils.newMap();
private Map<Player, Long> 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));
}
}
}

View File

@ -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);

View File

@ -78,7 +78,7 @@ public class CraftVisibilityManager implements VisibilityManager {
if (playersVisibilityMap == null) {
// Lazy initialization
playersVisibilityMap = new ConcurrentHashMap<String, Boolean>();
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<String, Boolean>();
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<String> playerNames = new HashSet<String>(playersVisibilityMap.keySet());
Set<String> playerNames = new HashSet<>(playersVisibilityMap.keySet());
for (String playerName : playerNames) {
Player onlinePlayer = Bukkit.getPlayerExact(playerName);

View File

@ -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<NamedHologram> pluginHolograms = Utils.newList();
private static List<NamedHologram> pluginHolograms = new ArrayList<>();
public static void addHologram(NamedHologram hologram) {
pluginHolograms.add(hologram);
@ -40,7 +38,7 @@ public class NamedHologramManager {
}
public static List<NamedHologram> getHolograms() {
return new ArrayList<NamedHologram>(pluginHolograms);
return new ArrayList<>(pluginHolograms);
}
public static NamedHologram getHologram(String name) {
@ -75,7 +73,7 @@ public class NamedHologramManager {
}
public static void clearAll() {
List<NamedHologram> oldHolograms = new ArrayList<NamedHologram>(pluginHolograms);
List<NamedHologram> oldHolograms = new ArrayList<>(pluginHolograms);
pluginHolograms.clear();
for (NamedHologram hologram : oldHolograms) {

View File

@ -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<PluginHologram> pluginHolograms = Utils.newList();
private static List<PluginHologram> pluginHolograms = new ArrayList<>();
public static void addHologram(PluginHologram hologram) {
pluginHolograms.add(hologram);
@ -44,11 +44,11 @@ public class PluginHologramManager {
}
public static List<PluginHologram> getHolograms() {
return new ArrayList<PluginHologram>(pluginHolograms);
return new ArrayList<>(pluginHolograms);
}
public static Set<Hologram> getHolograms(Plugin plugin) {
Set<Hologram> ownedHolograms = Utils.newSet();
Set<Hologram> ownedHolograms = new HashSet<>();
for (PluginHologram hologram : pluginHolograms) {
if (hologram.getOwner().equals(plugin)) {
@ -78,7 +78,7 @@ public class PluginHologramManager {
}
public static void clearAll() {
List<PluginHologram> oldHolograms = new ArrayList<PluginHologram>(pluginHolograms);
List<PluginHologram> oldHolograms = new ArrayList<>(pluginHolograms);
pluginHolograms.clear();
for (PluginHologram hologram : oldHolograms) {

View File

@ -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);
}

View File

@ -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 {
// <fileName, lines>
private final static Map<String, Placeholder> animations = Utils.newMap();
private final static Map<String, Placeholder> animations = new HashMap<>();
public static void loadAnimations(Plugin plugin) {
animations.clear();

View File

@ -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() {

View File

@ -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<DynamicLineData> linesToUpdate = Utils.newSet();
protected static Set<DynamicLineData> linesToUpdate = new HashSet<>();
private static final Pattern BUNGEE_ONLINE_PATTERN = makePlaceholderWithArgsPattern("online");
private static final Pattern BUNGEE_MAX_PATTERN = makePlaceholderWithArgsPattern("max_players");
@ -56,10 +58,7 @@ public class PlaceholdersManager {
public static void load(Plugin plugin) {
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
for (Placeholder placeholder : PlaceholdersRegister.getPlaceholders()) {
if (elapsedTenthsOfSecond % placeholder.getTenthsToRefresh() == 0) {
@ -91,7 +90,6 @@ public class PlaceholdersManager {
}
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() {
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() {
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() {
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() {
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() {
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() {
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() {
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);

View File

@ -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<Placeholder> placeholders = Utils.newSet();
private static final Set<Placeholder> placeholders = new HashSet<>();
// Register the default placeholders statically.
static {
register(new Placeholder(HolographicDisplays.getInstance(), "{online}", 1.0, new PlaceholderReplacer() {
@Override
public String update() {
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() {
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() {
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() {
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<String> getTextPlaceholdersByPlugin(Plugin plugin) {
Set<String> found = Utils.newSet();
Set<String> found = new HashSet<>();
for (Placeholder placeholder : placeholders) {
if (placeholder.getOwner().equals(plugin)) {

View File

@ -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<RelativePlaceholder> registry = Utils.newSet();
private static final Collection<RelativePlaceholder> registry = new HashSet<>();
// The placeholder itself, something like {player}.
private final String textPlaceholder;

View File

@ -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<String, Integer> worlds = Utils.newMap();
private static Map<String, Integer> worlds = new HashMap<>();
@Override
public void run() {

View File

@ -41,7 +41,7 @@ public class FileUtils {
try {
List<String> lines = new ArrayList<String>();
List<String> lines = new ArrayList<>();
if (!file.exists()) {
throw new FileNotFoundException();

View File

@ -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<String, Material> NAMES_TO_MATERIALS = new HashMap<String, Material>();
private static final Map<String, Material> NAMES_TO_MATERIALS = new HashMap<>();
// The chars that will be ignored when matching materials.
private static final Pattern STRIP_SPACING_SYMBOLS_PATTERN = Pattern.compile("[_ \\-]+");

View File

@ -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 <T, V> Map<T, V> newMap() {
return new HashMap<T, V>();
}
public static <T> List<T> newList() {
return new ArrayList<T>();
}
public static <T> Set<T> newSet() {
return new HashSet<T>();
}
public static int floor(double num) {
int floor = (int) num;
return floor == num ? floor : floor - (int) (Double.doubleToRawLongBits(num) >>> 63);
@ -104,19 +84,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<String> elements, String separator, int startIndex, int size) {
return join(elements.toArray(new String[elements.size()]), separator, startIndex, size);
}
public static String join(List<String> elements, String separator) {
return join(elements, separator, 0, elements.size());
}
public static String sanitize(String s) {
return s != null ? s : "null";
}

View File

@ -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<Integer> GET_STACKTRACE_DEPTH_METHOD = new ReflectMethod<Integer>(Throwable.class, "getStackTraceDepth");
private static final ReflectMethod<StackTraceElement> GET_STACKTRACE_ELEMENT_METHOD = new ReflectMethod<StackTraceElement>(Throwable.class, "getStackTraceElement", int.class);
private static final ReflectMethod<Integer> GET_STACKTRACE_DEPTH_METHOD = new ReflectMethod<>(Throwable.class, "getStackTraceDepth");
private static final ReflectMethod<StackTraceElement> 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<Stream<StackFrame>, StackFrame>() {
@Override
public StackFrame apply(Stream<StackFrame> stream) {
StackFrame result = StackWalker.getInstance().walk((Stream<StackFrame> stream) -> {
return stream.skip(index).limit(1).findFirst().orElse(null);
}
});
return result != null ? result.toStackTraceElement() : null;

View File

@ -11,8 +11,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.test.skip>true</maven.test.skip>
<spigot-api.version>1.8-R0.1-SNAPSHOT</spigot-api.version>
</properties>