mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-18 23:07:34 +01:00
Update to Java 8
This commit is contained in:
parent
fa1f8d260e
commit
66fe72b0eb
@ -18,6 +18,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
@ -29,7 +30,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just a bunch of static varibles to hold the settings.
|
* Just a bunch of static varibles to hold the settings.
|
||||||
@ -112,13 +112,12 @@ public class Configuration {
|
|||||||
|
|
||||||
|
|
||||||
if (needsSave) {
|
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/",
|
". Read the tutorial at: http://dev.bukkit.org/bukkit-plugins/holographic-displays/",
|
||||||
".",
|
".",
|
||||||
". Plugin created by filoghost.",
|
". Plugin created by filoghost.",
|
||||||
"."},
|
"."));
|
||||||
"\n"));
|
|
||||||
config.options().copyHeader(true);
|
config.options().copyHeader(true);
|
||||||
try {
|
try {
|
||||||
config.save(configFile);
|
config.save(configFile);
|
||||||
@ -153,7 +152,7 @@ public class Configuration {
|
|||||||
pingerTimeout = 10000;
|
pingerTimeout = 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
pingerServers = Utils.newMap();
|
pingerServers = new HashMap<>();
|
||||||
|
|
||||||
if (pingerEnable) {
|
if (pingerEnable) {
|
||||||
for (String singleServer : config.getStringList(ConfigNode.BUNGEE_PINGER_SERVERS.getPath())) {
|
for (String singleServer : config.getStringList(ConfigNode.BUNGEE_PINGER_SERVERS.getPath())) {
|
||||||
|
@ -30,7 +30,7 @@ import com.gmail.filoghost.holographicdisplays.util.FileUtils;
|
|||||||
|
|
||||||
public class UnicodeSymbols {
|
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) {
|
public static void load(Plugin plugin) {
|
||||||
placeholders.clear();
|
placeholders.clear();
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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);
|
|
||||||
|
|
||||||
}
|
|
@ -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();
|
|
||||||
|
|
||||||
}
|
|
@ -44,7 +44,7 @@ import net.minecraft.server.v1_10_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
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 boolean lockTick;
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
|
@ -40,7 +40,7 @@ import net.minecraft.server.v1_10_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
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 boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -41,8 +41,8 @@ import net.minecraft.server.v1_10_R1.WorldServer;
|
|||||||
|
|
||||||
public class NmsManagerImpl implements NMSManager {
|
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<?>, 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<Map<Class<?>, Integer>>(EntityTypes.class, "f");
|
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ import net.minecraft.server.v1_11_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
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 boolean lockTick;
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
|
@ -38,7 +38,7 @@ import net.minecraft.server.v1_11_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
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 boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -42,8 +42,8 @@ import net.minecraft.server.v1_11_R1.WorldServer;
|
|||||||
|
|
||||||
public class NmsManagerImpl implements NMSManager {
|
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<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
|
||||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<Object[]>(RegistryID.class, "d");
|
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ import net.minecraft.server.v1_12_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
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 boolean lockTick;
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
|
@ -38,7 +38,7 @@ import net.minecraft.server.v1_12_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
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 boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -42,8 +42,8 @@ import net.minecraft.server.v1_12_R1.WorldServer;
|
|||||||
|
|
||||||
public class NmsManagerImpl implements NMSManager {
|
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<RegistryID<Class<? extends Entity>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
|
||||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<Object[]>(RegistryID.class, "d");
|
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<>(RegistryID.class, "d");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ import net.minecraft.server.v1_13_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
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 boolean lockTick;
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
|
@ -39,7 +39,7 @@ import net.minecraft.server.v1_13_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
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 boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -16,8 +16,6 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_13_R1;
|
|||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_13_R1.CraftWorld;
|
import org.bukkit.craftbukkit.v1_13_R1.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity;
|
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 {
|
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<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "a");
|
||||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<Object[]>(RegistryID.class, "d");
|
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<List<Entity>>(World.class, "entityList");
|
private static final ReflectField<List<Entity>> ENTITY_LIST_FIELD = new ReflectField<>(World.class, "entityList");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
@ -68,14 +66,7 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
Object oldValue = idToClassMap[id];
|
Object oldValue = idToClassMap[id];
|
||||||
|
|
||||||
// Register the EntityTypes object.
|
// Register the EntityTypes object.
|
||||||
registryID.a(new EntityTypes<Entity>(entityClass, new Function<World, Entity>() {
|
registryID.a(new EntityTypes<>(entityClass, world -> null, true, true, null), id);
|
||||||
|
|
||||||
@Override
|
|
||||||
public Entity apply(World world) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}, true, true, null), id);
|
|
||||||
|
|
||||||
// Restore the ID -> EntityTypes mapping.
|
// Restore the ID -> EntityTypes mapping.
|
||||||
idToClassMap[id] = oldValue;
|
idToClassMap[id] = oldValue;
|
||||||
|
@ -42,7 +42,7 @@ import net.minecraft.server.v1_13_R2.World;
|
|||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
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 boolean lockTick;
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
|
@ -39,7 +39,7 @@ import net.minecraft.server.v1_13_R2.World;
|
|||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
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 boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -16,8 +16,6 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_13_R2;
|
|||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
|
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 {
|
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<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "b");
|
||||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<Object[]>(RegistryID.class, "d");
|
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<List<Entity>>(World.class, "entityList");
|
private static final ReflectField<List<Entity>> ENTITY_LIST_FIELD = new ReflectField<>(World.class, "entityList");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
@ -69,14 +67,7 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
Object oldValue = idToClassMap[id];
|
Object oldValue = idToClassMap[id];
|
||||||
|
|
||||||
// Register the EntityTypes object.
|
// Register the EntityTypes object.
|
||||||
registryID.a(new EntityTypes<Entity>(entityClass, new Function<World, Entity>() {
|
registryID.a(new EntityTypes<>(entityClass, world -> null, true, true, null), id);
|
||||||
|
|
||||||
@Override
|
|
||||||
public Entity apply(World world) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}, true, true, null), id);
|
|
||||||
|
|
||||||
// Restore the ID -> EntityTypes mapping.
|
// Restore the ID -> EntityTypes mapping.
|
||||||
idToClassMap[id] = oldValue;
|
idToClassMap[id] = oldValue;
|
||||||
|
@ -43,7 +43,7 @@ import net.minecraft.server.v1_14_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
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 boolean lockTick;
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
|
@ -40,7 +40,7 @@ import net.minecraft.server.v1_14_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
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 boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -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.MathHelper;
|
||||||
import net.minecraft.server.v1_14_R1.RegistryID;
|
import net.minecraft.server.v1_14_R1.RegistryID;
|
||||||
import net.minecraft.server.v1_14_R1.RegistryMaterials;
|
import net.minecraft.server.v1_14_R1.RegistryMaterials;
|
||||||
import net.minecraft.server.v1_14_R1.World;
|
|
||||||
import net.minecraft.server.v1_14_R1.WorldServer;
|
import net.minecraft.server.v1_14_R1.WorldServer;
|
||||||
|
|
||||||
public class NmsManagerImpl implements NMSManager {
|
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<RegistryID<EntityTypes<?>>> REGISTRY_ID_FIELD = new ReflectField<>(RegistryMaterials.class, "b");
|
||||||
private static final ReflectField<Object[]> ID_TO_CLASS_MAP_FIELD = new ReflectField<Object[]>(RegistryID.class, "d");
|
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<Void>(WorldServer.class, "registerEntity", Entity.class);
|
private static final ReflectMethod<Void> REGISTER_ENTITY_METHOD = new ReflectMethod<>(WorldServer.class, "registerEntity", Entity.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
@ -62,14 +61,7 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
Object oldValue = idToClassMap[id];
|
Object oldValue = idToClassMap[id];
|
||||||
|
|
||||||
// Register the EntityTypes object.
|
// Register the EntityTypes object.
|
||||||
registryID.a(new EntityTypes<Entity>(new EntityTypes.b<Entity>() {
|
registryID.a(new EntityTypes<>((entityType, world) -> null, EnumCreatureType.MONSTER, true, true, false, null, EntitySize.b(2.04f, 2.04f)), id);
|
||||||
|
|
||||||
@Override
|
|
||||||
public Entity create(EntityTypes<Entity> entityType, World world) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}, EnumCreatureType.MONSTER, true, true, false, null, EntitySize.b(2.04f, 2.04f)), id);
|
|
||||||
|
|
||||||
// Restore the ID -> EntityTypes mapping.
|
// Restore the ID -> EntityTypes mapping.
|
||||||
idToClassMap[id] = oldValue;
|
idToClassMap[id] = oldValue;
|
||||||
|
@ -37,7 +37,7 @@ import net.minecraft.server.v1_8_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
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 boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
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_PITCH_DELTA = new ReflectField<>(Entity.class, "ap");
|
||||||
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<Double>(Entity.class, "aq");
|
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "aq");
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
|
@ -37,8 +37,8 @@ import net.minecraft.server.v1_8_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
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_PITCH_DELTA = new ReflectField<>(Entity.class, "ap");
|
||||||
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<Double>(Entity.class, "aq");
|
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "aq");
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R1.WorldServer;
|
|||||||
|
|
||||||
public class NmsManagerImpl implements NMSManager {
|
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<?>, 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<Map<Class<?>, Integer>>(EntityTypes.class, "f");
|
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ import net.minecraft.server.v1_8_R2.World;
|
|||||||
|
|
||||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
||||||
|
|
||||||
private static final ReflectField<Integer> DISABLED_SLOTS_FIELD = new ReflectField<Integer>(EntityArmorStand.class, "bi");
|
private static final ReflectField<Integer> DISABLED_SLOTS_FIELD = new ReflectField<>(EntityArmorStand.class, "bi");
|
||||||
private static final ReflectMethod<Void> SET_MARKER_METHOD = new ReflectMethod<Void>(EntityArmorStand.class, "n", boolean.class);
|
private static final ReflectMethod<Void> SET_MARKER_METHOD = new ReflectMethod<>(EntityArmorStand.class, "n", boolean.class);
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R2.World;
|
|||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
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_PITCH_DELTA = new ReflectField<>(Entity.class, "ar");
|
||||||
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<Double>(Entity.class, "as");
|
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "as");
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
|
@ -37,8 +37,8 @@ import net.minecraft.server.v1_8_R2.World;
|
|||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
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_PITCH_DELTA = new ReflectField<>(Entity.class, "ar");
|
||||||
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<Double>(Entity.class, "as");
|
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "as");
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R2.WorldServer;
|
|||||||
|
|
||||||
public class NmsManagerImpl implements NMSManager {
|
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<?>, 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<Map<Class<?>, Integer>>(EntityTypes.class, "f");
|
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ import net.minecraft.server.v1_8_R3.World;
|
|||||||
|
|
||||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
||||||
|
|
||||||
private static final ReflectField<Integer> DISABLED_SLOTS_FIELD = new ReflectField<Integer>(EntityArmorStand.class, "bi");
|
private static final ReflectField<Integer> DISABLED_SLOTS_FIELD = new ReflectField<>(EntityArmorStand.class, "bi");
|
||||||
private static final ReflectMethod<Void> SET_MARKER_METHOD = new ReflectMethod<Void>(EntityArmorStand.class, "n", boolean.class);
|
private static final ReflectMethod<Void> SET_MARKER_METHOD = new ReflectMethod<>(EntityArmorStand.class, "n", boolean.class);
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R3.World;
|
|||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
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_PITCH_DELTA = new ReflectField<>(Entity.class, "ar");
|
||||||
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<Double>(Entity.class, "as");
|
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "as");
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
|
@ -37,8 +37,8 @@ import net.minecraft.server.v1_8_R3.World;
|
|||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
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_PITCH_DELTA = new ReflectField<>(Entity.class, "ar");
|
||||||
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<Double>(Entity.class, "as");
|
private static final ReflectField<Double> RIDER_YAW_DELTA = new ReflectField<>(Entity.class, "as");
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -42,8 +42,8 @@ import net.minecraft.server.v1_8_R3.WorldServer;
|
|||||||
|
|
||||||
public class NmsManagerImpl implements NMSManager {
|
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<?>, 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<Map<Class<?>, Integer>>(EntityTypes.class, "f");
|
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ import net.minecraft.server.v1_9_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand {
|
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 boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -44,7 +44,7 @@ import net.minecraft.server.v1_9_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
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 boolean lockTick;
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
|
@ -40,7 +40,7 @@ import net.minecraft.server.v1_9_R1.World;
|
|||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
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 boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -41,8 +41,8 @@ import net.minecraft.server.v1_9_R1.WorldServer;
|
|||||||
|
|
||||||
public class NmsManagerImpl implements NMSManager {
|
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<?>, 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<Map<Class<?>, Integer>>(EntityTypes.class, "f");
|
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ import net.minecraft.server.v1_9_R2.World;
|
|||||||
|
|
||||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
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 boolean lockTick;
|
||||||
private ItemLine parentPiece;
|
private ItemLine parentPiece;
|
||||||
|
@ -40,7 +40,7 @@ import net.minecraft.server.v1_9_R2.World;
|
|||||||
|
|
||||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
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 boolean lockTick;
|
||||||
private HologramLine parentPiece;
|
private HologramLine parentPiece;
|
||||||
|
@ -41,8 +41,8 @@ import net.minecraft.server.v1_9_R2.WorldServer;
|
|||||||
|
|
||||||
public class NmsManagerImpl implements NMSManager {
|
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<?>, 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<Map<Class<?>, Integer>>(EntityTypes.class, "f");
|
private static final ReflectField<Map<Class<?>, Integer>> ENTITY_IDS_BY_CLASS_FIELD = new ReflectField<>(EntityTypes.class, "f");
|
||||||
|
|
||||||
private Method validateEntityMethod;
|
private Method validateEntityMethod;
|
||||||
|
|
||||||
|
@ -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.CraftHologram;
|
||||||
import com.gmail.filoghost.holographicdisplays.object.PluginHologram;
|
import com.gmail.filoghost.holographicdisplays.object.PluginHologram;
|
||||||
import com.gmail.filoghost.holographicdisplays.object.PluginHologramManager;
|
import com.gmail.filoghost.holographicdisplays.object.PluginHologramManager;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,7 +42,7 @@ import com.gmail.filoghost.holographicdisplays.util.Validator;
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public class HolographicDisplaysAPI {
|
public class HolographicDisplaysAPI {
|
||||||
|
|
||||||
private static Set<String> notifiedPlugins = new HashSet<String>();
|
private static Set<String> notifiedPlugins = new HashSet<>();
|
||||||
|
|
||||||
private static void notifyOldAPI(Plugin plugin) {
|
private static void notifyOldAPI(Plugin plugin) {
|
||||||
if (notifiedPlugins.add(plugin.getName())) {
|
if (notifiedPlugins.add(plugin.getName())) {
|
||||||
@ -76,7 +75,7 @@ public class HolographicDisplaysAPI {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, Player whoCanSee, String... lines) {
|
public static Hologram createIndividualHologram(Plugin plugin, Location source, Player whoCanSee, String... lines) {
|
||||||
notifyOldAPI(plugin);
|
notifyOldAPI(plugin);
|
||||||
List<Player> whoCanSeeList = new ArrayList<Player>();
|
List<Player> whoCanSeeList = new ArrayList<>();
|
||||||
whoCanSeeList.add(whoCanSee);
|
whoCanSeeList.add(whoCanSee);
|
||||||
return createIndividualHologram(plugin, source, whoCanSeeList, lines);
|
return createIndividualHologram(plugin, source, whoCanSeeList, lines);
|
||||||
}
|
}
|
||||||
@ -107,7 +106,7 @@ public class HolographicDisplaysAPI {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, Player whoCanSee, ItemStack itemstack) {
|
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, Player whoCanSee, ItemStack itemstack) {
|
||||||
notifyOldAPI(plugin);
|
notifyOldAPI(plugin);
|
||||||
List<Player> whoCanSeeList = new ArrayList<Player>();
|
List<Player> whoCanSeeList = new ArrayList<>();
|
||||||
whoCanSeeList.add(whoCanSee);
|
whoCanSeeList.add(whoCanSee);
|
||||||
return createIndividualFloatingItem(plugin, source, whoCanSeeList, itemstack);
|
return createIndividualFloatingItem(plugin, source, whoCanSeeList, itemstack);
|
||||||
}
|
}
|
||||||
@ -139,7 +138,7 @@ public class HolographicDisplaysAPI {
|
|||||||
notifyOldAPI(plugin);
|
notifyOldAPI(plugin);
|
||||||
Validator.notNull(plugin, "plugin cannot be null");
|
Validator.notNull(plugin, "plugin cannot be null");
|
||||||
|
|
||||||
List<Hologram> pluginHolograms = Utils.newList();
|
List<Hologram> pluginHolograms = new ArrayList<>();;
|
||||||
for (PluginHologram pluginHologram : PluginHologramManager.getHolograms()) {
|
for (PluginHologram pluginHologram : PluginHologramManager.getHolograms()) {
|
||||||
if (pluginHologram.getOwner().equals(plugin)) {
|
if (pluginHologram.getOwner().equals(plugin)) {
|
||||||
pluginHolograms.add(pluginHologram);
|
pluginHolograms.add(pluginHologram);
|
||||||
|
@ -24,7 +24,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
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.api.internal.BackendAPI;
|
||||||
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.BungeeServerTracker;
|
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.BungeeServerTracker;
|
||||||
import com.gmail.filoghost.holographicdisplays.bridge.protocollib.ProtocolLibHook;
|
import com.gmail.filoghost.holographicdisplays.bridge.protocollib.ProtocolLibHook;
|
||||||
@ -87,16 +86,11 @@ public class HolographicDisplays extends JavaPlugin {
|
|||||||
Configuration.load(this);
|
Configuration.load(this);
|
||||||
|
|
||||||
if (Configuration.updateNotification) {
|
if (Configuration.updateNotification) {
|
||||||
new SimpleUpdater(this, 75097).checkForUpdates(new ResponseHandler() {
|
new SimpleUpdater(this, 75097).checkForUpdates(newVersion -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdateFound(final String newVersion) {
|
|
||||||
|
|
||||||
HolographicDisplays.newVersion = newVersion;
|
HolographicDisplays.newVersion = newVersion;
|
||||||
ConsoleLogger.log(Level.INFO, "Found a new version available: " + newVersion);
|
ConsoleLogger.log(Level.INFO, "Found a new version available: " + newVersion);
|
||||||
ConsoleLogger.log(Level.INFO, "Download it on Bukkit Dev:");
|
ConsoleLogger.log(Level.INFO, "Download it on Bukkit Dev:");
|
||||||
ConsoleLogger.log(Level.INFO, "dev.bukkit.org/bukkit-plugins/holographic-displays");
|
ConsoleLogger.log(Level.INFO, "dev.bukkit.org/bukkit-plugins/holographic-displays");
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,8 +23,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
|
import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
|
||||||
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.PingResponse;
|
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.PingResponse;
|
||||||
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.ServerPinger;
|
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.ServerPinger;
|
||||||
@ -34,7 +32,7 @@ import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
|||||||
|
|
||||||
public class BungeeServerTracker {
|
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;
|
private static int taskID = -1;
|
||||||
|
|
||||||
public static void resetTrackedServers() {
|
public static void resetTrackedServers() {
|
||||||
@ -153,23 +151,16 @@ public class BungeeServerTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void startTask(int refreshSeconds) {
|
public static void startTask(int refreshSeconds) {
|
||||||
|
|
||||||
if (taskID != -1) {
|
if (taskID != -1) {
|
||||||
Bukkit.getScheduler().cancelTask(taskID);
|
Bukkit.getScheduler().cancelTask(taskID);
|
||||||
}
|
}
|
||||||
|
|
||||||
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(HolographicDisplays.getInstance(), new Runnable() {
|
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(HolographicDisplays.getInstance(), () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
if (Configuration.pingerEnable) {
|
if (Configuration.pingerEnable) {
|
||||||
new BukkitRunnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(HolographicDisplays.getInstance(), () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
for (Entry<String, ServerAddress> entry : Configuration.pingerServers.entrySet()) {
|
for (Entry<String, ServerAddress> entry : Configuration.pingerServers.entrySet()) {
|
||||||
|
|
||||||
BungeeServerInfo serverInfo = getOrCreateServerInfo(entry.getKey());
|
BungeeServerInfo serverInfo = getOrCreateServerInfo(entry.getKey());
|
||||||
boolean displayOffline = false;
|
boolean displayOffline = false;
|
||||||
|
|
||||||
@ -203,8 +194,7 @@ public class BungeeServerTracker {
|
|||||||
serverInfo.setMotd(Configuration.pingerOfflineMotd);
|
serverInfo.setMotd(Configuration.pingerOfflineMotd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}.runTaskAsynchronously(HolographicDisplays.getInstance());
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (String server : trackedServers.keySet()) {
|
for (String server : trackedServers.keySet()) {
|
||||||
@ -212,7 +202,6 @@ public class BungeeServerTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}, 1, refreshSeconds * 20);
|
}, 1, refreshSeconds * 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.filoghost.holographicdisplays.bridge.protocollib.current;
|
package com.gmail.filoghost.holographicdisplays.bridge.protocollib.current;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
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.object.line.CraftTouchableLine;
|
||||||
import com.gmail.filoghost.holographicdisplays.placeholder.RelativePlaceholder;
|
import com.gmail.filoghost.holographicdisplays.placeholder.RelativePlaceholder;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.NMSVersion;
|
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.
|
* This is for the ProtocolLib versions containing the WrappedDataWatcher.WrappedDataWatcherObject class.
|
||||||
@ -255,7 +255,7 @@ public class ProtocolLibHookImpl implements ProtocolLibHook {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendDestroyEntitiesPacket(Player player, CraftHologram hologram) {
|
public void sendDestroyEntitiesPacket(Player player, CraftHologram hologram) {
|
||||||
List<Integer> ids = Utils.newList();
|
List<Integer> ids = new ArrayList<>();
|
||||||
for (CraftHologramLine line : hologram.getLinesUnsafe()) {
|
for (CraftHologramLine line : hologram.getLinesUnsafe()) {
|
||||||
if (line.isSpawned()) {
|
if (line.isSpawned()) {
|
||||||
for (int id : line.getEntitiesIDs()) {
|
for (int id : line.getEntitiesIDs()) {
|
||||||
@ -278,7 +278,7 @@ public class ProtocolLibHookImpl implements ProtocolLibHook {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Integer> ids = Utils.newList();
|
List<Integer> ids = new ArrayList<>();
|
||||||
for (int id : line.getEntitiesIDs()) {
|
for (int id : line.getEntitiesIDs()) {
|
||||||
ids.add(id);
|
ids.add(id);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ package com.gmail.filoghost.holographicdisplays.commands.main;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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.SetlineCommand;
|
||||||
import com.gmail.filoghost.holographicdisplays.commands.main.subs.TeleportCommand;
|
import com.gmail.filoghost.holographicdisplays.commands.main.subs.TeleportCommand;
|
||||||
import com.gmail.filoghost.holographicdisplays.exception.CommandException;
|
import com.gmail.filoghost.holographicdisplays.exception.CommandException;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|
||||||
|
|
||||||
public class HologramsCommandHandler implements CommandExecutor {
|
public class HologramsCommandHandler implements CommandExecutor {
|
||||||
|
|
||||||
@ -53,8 +53,8 @@ public class HologramsCommandHandler implements CommandExecutor {
|
|||||||
private Map<Class<? extends HologramSubCommand>, HologramSubCommand> subCommandsByClass;
|
private Map<Class<? extends HologramSubCommand>, HologramSubCommand> subCommandsByClass;
|
||||||
|
|
||||||
public HologramsCommandHandler() {
|
public HologramsCommandHandler() {
|
||||||
subCommands = Utils.newList();
|
subCommands = new ArrayList<>();
|
||||||
subCommandsByClass = Utils.newMap();
|
subCommandsByClass = new HashMap<>();
|
||||||
|
|
||||||
registerSubCommand(new AddlineCommand());
|
registerSubCommand(new AddlineCommand());
|
||||||
registerSubCommand(new CreateCommand());
|
registerSubCommand(new CreateCommand());
|
||||||
@ -84,7 +84,7 @@ public class HologramsCommandHandler implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<HologramSubCommand> getSubCommands() {
|
public List<HologramSubCommand> getSubCommands() {
|
||||||
return new ArrayList<HologramSubCommand>(subCommands);
|
return new ArrayList<>(subCommands);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HologramSubCommand getSubCommand(Class<? extends HologramSubCommand> subCommandClass) {
|
public HologramSubCommand getSubCommand(Class<? extends HologramSubCommand> subCommandClass) {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.filoghost.holographicdisplays.commands.main.subs;
|
package com.gmail.filoghost.holographicdisplays.commands.main.subs;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
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.exception.CommandException;
|
||||||
import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
|
import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
|
||||||
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
|
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
@ -79,7 +79,7 @@ public class EditCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
if (CommandValidator.isPlayerSender(sender)) {
|
if (CommandValidator.isPlayerSender(sender)) {
|
||||||
|
|
||||||
List<String> help = Utils.newList();
|
List<String> help = new ArrayList<>();
|
||||||
help.add(Colors.PRIMARY + usage);
|
help.add(Colors.PRIMARY + usage);
|
||||||
for (String tutLine : subCommand.getTutorial()) {
|
for (String tutLine : subCommand.getTutorial()) {
|
||||||
help.add(Colors.SECONDARY_SHADOW + tutLine);
|
help.add(Colors.SECONDARY_SHADOW + tutLine);
|
||||||
@ -88,7 +88,7 @@ public class EditCommand extends HologramSubCommand {
|
|||||||
((Player) sender).spigot().sendMessage(new ComponentBuilder(usage)
|
((Player) sender).spigot().sendMessage(new ComponentBuilder(usage)
|
||||||
.color(ChatColor.AQUA)
|
.color(ChatColor.AQUA)
|
||||||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, usage))
|
.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());
|
.create());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.filoghost.holographicdisplays.commands.main.subs;
|
package com.gmail.filoghost.holographicdisplays.commands.main.subs;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
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.Strings;
|
||||||
import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand;
|
import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand;
|
||||||
import com.gmail.filoghost.holographicdisplays.exception.CommandException;
|
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.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
@ -62,7 +61,7 @@ public class HelpCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
if (CommandValidator.isPlayerSender(sender)) {
|
if (CommandValidator.isPlayerSender(sender)) {
|
||||||
|
|
||||||
List<String> help = Utils.newList();
|
List<String> help = new ArrayList<>();
|
||||||
help.add(Colors.PRIMARY + usage);
|
help.add(Colors.PRIMARY + usage);
|
||||||
for (String tutLine : subCommand.getTutorial()) {
|
for (String tutLine : subCommand.getTutorial()) {
|
||||||
help.add(Colors.SECONDARY_SHADOW + tutLine);
|
help.add(Colors.SECONDARY_SHADOW + tutLine);
|
||||||
@ -71,7 +70,7 @@ public class HelpCommand extends HologramSubCommand {
|
|||||||
((Player) sender).spigot().sendMessage(new ComponentBuilder(usage)
|
((Player) sender).spigot().sendMessage(new ComponentBuilder(usage)
|
||||||
.color(ChatColor.AQUA)
|
.color(ChatColor.AQUA)
|
||||||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, usage))
|
.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());
|
.create());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.filoghost.holographicdisplays.commands.main.subs;
|
package com.gmail.filoghost.holographicdisplays.commands.main.subs;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
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.exception.CommandException;
|
||||||
import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
|
import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
|
||||||
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
|
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|
||||||
|
|
||||||
public class NearCommand extends HologramSubCommand {
|
public class NearCommand extends HologramSubCommand {
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ public class NearCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
int radiusSquared = radius * radius;
|
int radiusSquared = radius * radius;
|
||||||
List<NamedHologram> nearHolograms = Utils.newList();
|
List<NamedHologram> nearHolograms = new ArrayList<>();
|
||||||
|
|
||||||
for (NamedHologram hologram : NamedHologramManager.getHolograms()) {
|
for (NamedHologram hologram : NamedHologramManager.getHolograms()) {
|
||||||
if (hologram.getLocation().getWorld().equals(world) && hologram.getLocation().distanceSquared(player.getLocation()) <= radiusSquared) {
|
if (hologram.getLocation().getWorld().equals(world) && hologram.getLocation().distanceSquared(player.getLocation()) <= radiusSquared) {
|
||||||
|
@ -20,6 +20,7 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
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.NamedHologram;
|
||||||
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
|
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.FileUtils;
|
import com.gmail.filoghost.holographicdisplays.util.FileUtils;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|
||||||
|
|
||||||
public class ReadimageCommand extends HologramSubCommand {
|
public class ReadimageCommand extends HologramSubCommand {
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public class ReadimageCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
boolean append = false;
|
boolean append = false;
|
||||||
|
|
||||||
List<String> newArgs = Utils.newList();
|
List<String> newArgs = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-append")) {
|
if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("-append")) {
|
||||||
|
@ -16,6 +16,7 @@ package com.gmail.filoghost.holographicdisplays.disk;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
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.object.line.CraftTextLine;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
|
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|
||||||
|
|
||||||
public class HologramDatabase {
|
public class HologramDatabase {
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ public class HologramDatabase {
|
|||||||
ConfigurationSection configSection = config.isConfigurationSection(hologram.getName()) ? config.getConfigurationSection(hologram.getName()) : config.createSection(hologram.getName());
|
ConfigurationSection configSection = config.isConfigurationSection(hologram.getName()) ? config.getConfigurationSection(hologram.getName()) : config.createSection(hologram.getName());
|
||||||
|
|
||||||
configSection.set("location", LocationSerializer.locationToString(hologram.getLocation()));
|
configSection.set("location", LocationSerializer.locationToString(hologram.getLocation()));
|
||||||
List<String> lines = Utils.newList();
|
List<String> lines = new ArrayList<>();
|
||||||
|
|
||||||
for (CraftHologramLine line : hologram.getLinesUnsafe()) {
|
for (CraftHologramLine line : hologram.getLinesUnsafe()) {
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import java.awt.Color;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
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.disk.Configuration;
|
||||||
import com.gmail.filoghost.holographicdisplays.exception.TooWideException;
|
import com.gmail.filoghost.holographicdisplays.exception.TooWideException;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Huge thanks to bobacadodl for this awesome library!
|
* Huge thanks to bobacadodl for this awesome library!
|
||||||
@ -35,10 +35,8 @@ public class ImageMessage {
|
|||||||
|
|
||||||
public static final int MAX_WIDTH = 150;
|
public static final int MAX_WIDTH = 150;
|
||||||
|
|
||||||
private static final Map<ChatColor, Color> colorsMap = Utils.newMap();
|
private static final Map<ChatColor, Color> colorsMap = new HashMap<>();
|
||||||
|
private static final Map<ChatColor, Color> graysMap = new HashMap<>();
|
||||||
private static final Map<ChatColor, Color> graysMap = Utils.newMap();
|
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
colorsMap.put(ChatColor.DARK_BLUE, new Color(0, 0, 170));
|
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 {
|
private ChatColor[][] toChatColorArray(BufferedImage image, int width) throws TooWideException {
|
||||||
double ratio = (double) image.getHeight() / image.getWidth();
|
double ratio = (double) image.getHeight() / image.getWidth();
|
||||||
int height = (int) (((double)width) * ratio);
|
int height = (int) ((width) * ratio);
|
||||||
if (height == 0) {
|
if (height == 0) {
|
||||||
height = 1;
|
height = 1;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.filoghost.holographicdisplays.listener;
|
package com.gmail.filoghost.holographicdisplays.listener;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
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.PluginHologramManager;
|
||||||
import com.gmail.filoghost.holographicdisplays.object.line.CraftTouchSlimeLine;
|
import com.gmail.filoghost.holographicdisplays.object.line.CraftTouchSlimeLine;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|
||||||
|
|
||||||
public class MainListener implements Listener, ItemPickupManager {
|
public class MainListener implements Listener, ItemPickupManager {
|
||||||
|
|
||||||
private NMSManager nmsManager;
|
private NMSManager nmsManager;
|
||||||
|
|
||||||
private Map<Player, Long> anticlickSpam = Utils.newMap();
|
private Map<Player, Long> anticlickSpam = new HashMap<>();
|
||||||
|
|
||||||
public MainListener(NMSManager nmsManager) {
|
public MainListener(NMSManager nmsManager) {
|
||||||
this.nmsManager = nmsManager;
|
this.nmsManager = nmsManager;
|
||||||
@ -86,12 +86,7 @@ public class MainListener implements Listener, ItemPickupManager {
|
|||||||
if (Bukkit.isPrimaryThread()) {
|
if (Bukkit.isPrimaryThread()) {
|
||||||
processChunkLoad(chunk);
|
processChunkLoad(chunk);
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getScheduler().runTask(HolographicDisplays.getInstance(), new Runnable() {
|
Bukkit.getScheduler().runTask(HolographicDisplays.getInstance(), () -> processChunkLoad(chunk));
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
processChunkLoad(chunk);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.filoghost.holographicdisplays.object;
|
package com.gmail.filoghost.holographicdisplays.object;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@ -57,7 +58,7 @@ public class CraftHologram implements Hologram, com.gmail.filoghost.holograms.ap
|
|||||||
Validator.notNull(location, "location");
|
Validator.notNull(location, "location");
|
||||||
updateLocation(location.getWorld(), location.getX(), location.getY(), location.getZ());
|
updateLocation(location.getWorld(), location.getX(), location.getY(), location.getZ());
|
||||||
|
|
||||||
lines = Utils.newList();
|
lines = new ArrayList<>();
|
||||||
allowPlaceholders = false;
|
allowPlaceholders = false;
|
||||||
creationTimestamp = System.currentTimeMillis();
|
creationTimestamp = System.currentTimeMillis();
|
||||||
visibilityManager = new CraftVisibilityManager(this);
|
visibilityManager = new CraftVisibilityManager(this);
|
||||||
|
@ -78,7 +78,7 @@ public class CraftVisibilityManager implements VisibilityManager {
|
|||||||
|
|
||||||
if (playersVisibilityMap == null) {
|
if (playersVisibilityMap == null) {
|
||||||
// Lazy initialization
|
// Lazy initialization
|
||||||
playersVisibilityMap = new ConcurrentHashMap<String, Boolean>();
|
playersVisibilityMap = new ConcurrentHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
playersVisibilityMap.put(player.getName().toLowerCase(), true);
|
playersVisibilityMap.put(player.getName().toLowerCase(), true);
|
||||||
@ -97,7 +97,7 @@ public class CraftVisibilityManager implements VisibilityManager {
|
|||||||
|
|
||||||
if (playersVisibilityMap == null) {
|
if (playersVisibilityMap == null) {
|
||||||
// Lazy initialization
|
// Lazy initialization
|
||||||
playersVisibilityMap = new ConcurrentHashMap<String, Boolean>();
|
playersVisibilityMap = new ConcurrentHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
playersVisibilityMap.put(player.getName().toLowerCase(), false);
|
playersVisibilityMap.put(player.getName().toLowerCase(), false);
|
||||||
@ -147,7 +147,7 @@ public class CraftVisibilityManager implements VisibilityManager {
|
|||||||
if (playersVisibilityMap != null) {
|
if (playersVisibilityMap != null) {
|
||||||
|
|
||||||
// We need to refresh all the players
|
// 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) {
|
for (String playerName : playerNames) {
|
||||||
Player onlinePlayer = Bukkit.getPlayerExact(playerName);
|
Player onlinePlayer = Bukkit.getPlayerExact(playerName);
|
||||||
|
@ -19,14 +19,12 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.Chunk;
|
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.
|
* This class is only used by the plugin itself. Other plugins should just use the API.
|
||||||
*/
|
*/
|
||||||
public class NamedHologramManager {
|
public class NamedHologramManager {
|
||||||
|
|
||||||
private static List<NamedHologram> pluginHolograms = Utils.newList();
|
private static List<NamedHologram> pluginHolograms = new ArrayList<>();
|
||||||
|
|
||||||
public static void addHologram(NamedHologram hologram) {
|
public static void addHologram(NamedHologram hologram) {
|
||||||
pluginHolograms.add(hologram);
|
pluginHolograms.add(hologram);
|
||||||
@ -40,7 +38,7 @@ public class NamedHologramManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<NamedHologram> getHolograms() {
|
public static List<NamedHologram> getHolograms() {
|
||||||
return new ArrayList<NamedHologram>(pluginHolograms);
|
return new ArrayList<>(pluginHolograms);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NamedHologram getHologram(String name) {
|
public static NamedHologram getHologram(String name) {
|
||||||
@ -75,7 +73,7 @@ public class NamedHologramManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void clearAll() {
|
public static void clearAll() {
|
||||||
List<NamedHologram> oldHolograms = new ArrayList<NamedHologram>(pluginHolograms);
|
List<NamedHologram> oldHolograms = new ArrayList<>(pluginHolograms);
|
||||||
pluginHolograms.clear();
|
pluginHolograms.clear();
|
||||||
|
|
||||||
for (NamedHologram hologram : oldHolograms) {
|
for (NamedHologram hologram : oldHolograms) {
|
||||||
|
@ -16,6 +16,7 @@ package com.gmail.filoghost.holographicdisplays.object;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -23,14 +24,13 @@ import org.bukkit.Chunk;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
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.
|
* This class is only used by the plugin itself. Other plugins should just use the API.
|
||||||
*/
|
*/
|
||||||
public class PluginHologramManager {
|
public class PluginHologramManager {
|
||||||
|
|
||||||
private static List<PluginHologram> pluginHolograms = Utils.newList();
|
private static List<PluginHologram> pluginHolograms = new ArrayList<>();
|
||||||
|
|
||||||
public static void addHologram(PluginHologram hologram) {
|
public static void addHologram(PluginHologram hologram) {
|
||||||
pluginHolograms.add(hologram);
|
pluginHolograms.add(hologram);
|
||||||
@ -44,11 +44,11 @@ public class PluginHologramManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<PluginHologram> getHolograms() {
|
public static List<PluginHologram> getHolograms() {
|
||||||
return new ArrayList<PluginHologram>(pluginHolograms);
|
return new ArrayList<>(pluginHolograms);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<Hologram> getHolograms(Plugin plugin) {
|
public static Set<Hologram> getHolograms(Plugin plugin) {
|
||||||
Set<Hologram> ownedHolograms = Utils.newSet();
|
Set<Hologram> ownedHolograms = new HashSet<>();
|
||||||
|
|
||||||
for (PluginHologram hologram : pluginHolograms) {
|
for (PluginHologram hologram : pluginHolograms) {
|
||||||
if (hologram.getOwner().equals(plugin)) {
|
if (hologram.getOwner().equals(plugin)) {
|
||||||
@ -78,7 +78,7 @@ public class PluginHologramManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void clearAll() {
|
public static void clearAll() {
|
||||||
List<PluginHologram> oldHolograms = new ArrayList<PluginHologram>(pluginHolograms);
|
List<PluginHologram> oldHolograms = new ArrayList<>(pluginHolograms);
|
||||||
pluginHolograms.clear();
|
pluginHolograms.clear();
|
||||||
|
|
||||||
for (PluginHologram hologram : oldHolograms) {
|
for (PluginHologram hologram : oldHolograms) {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.filoghost.holographicdisplays.object.line;
|
package com.gmail.filoghost.holographicdisplays.object.line;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
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.PlaceholdersManager;
|
||||||
import com.gmail.filoghost.holographicdisplays.placeholder.RelativePlaceholder;
|
import com.gmail.filoghost.holographicdisplays.placeholder.RelativePlaceholder;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Offsets;
|
import com.gmail.filoghost.holographicdisplays.util.Offsets;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|
||||||
|
|
||||||
public class CraftTextLine extends CraftTouchableLine implements TextLine {
|
public class CraftTextLine extends CraftTouchableLine implements TextLine {
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ public class CraftTextLine extends CraftTouchableLine implements TextLine {
|
|||||||
for (RelativePlaceholder relativePlaceholder : RelativePlaceholder.getRegistry()) {
|
for (RelativePlaceholder relativePlaceholder : RelativePlaceholder.getRegistry()) {
|
||||||
if (text.contains(relativePlaceholder.getTextPlaceholder())) {
|
if (text.contains(relativePlaceholder.getTextPlaceholder())) {
|
||||||
if (relativePlaceholders == null) {
|
if (relativePlaceholders == null) {
|
||||||
relativePlaceholders = Utils.newList();
|
relativePlaceholders = new ArrayList<>();
|
||||||
}
|
}
|
||||||
relativePlaceholders.add(relativePlaceholder);
|
relativePlaceholders.add(relativePlaceholder);
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
package com.gmail.filoghost.holographicdisplays.placeholder;
|
package com.gmail.filoghost.holographicdisplays.placeholder;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
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.disk.StringConverter;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.FileUtils;
|
import com.gmail.filoghost.holographicdisplays.util.FileUtils;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|
||||||
|
|
||||||
public class AnimationsRegister {
|
public class AnimationsRegister {
|
||||||
|
|
||||||
// <fileName, lines>
|
// <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) {
|
public static void loadAnimations(Plugin plugin) {
|
||||||
animations.clear();
|
animations.clear();
|
||||||
|
@ -14,12 +14,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.filoghost.holographicdisplays.placeholder;
|
package com.gmail.filoghost.holographicdisplays.placeholder;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.gmail.filoghost.holographicdisplays.api.placeholder.PlaceholderReplacer;
|
import com.gmail.filoghost.holographicdisplays.api.placeholder.PlaceholderReplacer;
|
||||||
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSNameable;
|
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSNameable;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||||
|
|
||||||
public class DynamicLineData {
|
public class DynamicLineData {
|
||||||
@ -36,9 +37,9 @@ public class DynamicLineData {
|
|||||||
|
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.originalName = originalName;
|
this.originalName = originalName;
|
||||||
placeholders = Utils.newSet();
|
placeholders = new HashSet<>();
|
||||||
animations = Utils.newMap();
|
animations = new HashMap<>();
|
||||||
replacers = Utils.newMap();
|
replacers = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public NMSNameable getEntity() {
|
public NMSNameable getEntity() {
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.filoghost.holographicdisplays.placeholder;
|
package com.gmail.filoghost.holographicdisplays.placeholder;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@ -36,7 +38,7 @@ import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|||||||
public class PlaceholdersManager {
|
public class PlaceholdersManager {
|
||||||
|
|
||||||
private static long elapsedTenthsOfSecond;
|
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_ONLINE_PATTERN = makePlaceholderWithArgsPattern("online");
|
||||||
private static final Pattern BUNGEE_MAX_PATTERN = makePlaceholderWithArgsPattern("max_players");
|
private static final Pattern BUNGEE_MAX_PATTERN = makePlaceholderWithArgsPattern("max_players");
|
||||||
@ -56,10 +58,7 @@ public class PlaceholdersManager {
|
|||||||
|
|
||||||
|
|
||||||
public static void load(Plugin plugin) {
|
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()) {
|
for (Placeholder placeholder : PlaceholdersRegister.getPlaceholders()) {
|
||||||
if (elapsedTenthsOfSecond % placeholder.getTenthsToRefresh() == 0) {
|
if (elapsedTenthsOfSecond % placeholder.getTenthsToRefresh() == 0) {
|
||||||
@ -91,7 +90,6 @@ public class PlaceholdersManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
elapsedTenthsOfSecond++;
|
elapsedTenthsOfSecond++;
|
||||||
}
|
|
||||||
|
|
||||||
}, 2L, 2L);
|
}, 2L, 2L);
|
||||||
}
|
}
|
||||||
@ -142,7 +140,7 @@ public class PlaceholdersManager {
|
|||||||
if (name.contains(placeholder.getTextPlaceholder())) {
|
if (name.contains(placeholder.getTextPlaceholder())) {
|
||||||
|
|
||||||
if (normalPlaceholders == null) {
|
if (normalPlaceholders == null) {
|
||||||
normalPlaceholders = Utils.newSet();
|
normalPlaceholders = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
normalPlaceholders.add(placeholder);
|
normalPlaceholders.add(placeholder);
|
||||||
@ -155,16 +153,12 @@ public class PlaceholdersManager {
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
|
|
||||||
if (worldsOnlinePlayersReplacers == null) {
|
if (worldsOnlinePlayersReplacers == null) {
|
||||||
worldsOnlinePlayersReplacers = Utils.newMap();
|
worldsOnlinePlayersReplacers = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
final String worldName = extractArgumentFromPlaceholder(matcher);
|
final String worldName = extractArgumentFromPlaceholder(matcher);
|
||||||
worldsOnlinePlayersReplacers.put(matcher.group(), new PlaceholderReplacer() {
|
worldsOnlinePlayersReplacers.put(matcher.group(), () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String update() {
|
|
||||||
return WorldPlayerCounterTask.getCount(worldName);
|
return WorldPlayerCounterTask.getCount(worldName);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +167,7 @@ public class PlaceholdersManager {
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
|
|
||||||
if (bungeeReplacers == null) {
|
if (bungeeReplacers == null) {
|
||||||
bungeeReplacers = Utils.newMap();
|
bungeeReplacers = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
final String serverName = extractArgumentFromPlaceholder(matcher);
|
final String serverName = extractArgumentFromPlaceholder(matcher);
|
||||||
@ -189,25 +183,17 @@ public class PlaceholdersManager {
|
|||||||
final String[] serversToTrack = split;
|
final String[] serversToTrack = split;
|
||||||
|
|
||||||
// Add it to tracked servers.
|
// Add it to tracked servers.
|
||||||
bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() {
|
bungeeReplacers.put(matcher.group(), () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String update() {
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (String serverToTrack : serversToTrack) {
|
for (String serverToTrack : serversToTrack) {
|
||||||
count += BungeeServerTracker.getPlayersOnline(serverToTrack);
|
count += BungeeServerTracker.getPlayersOnline(serverToTrack);
|
||||||
}
|
}
|
||||||
return String.valueOf(count);
|
return String.valueOf(count);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Normal, single tracked server.
|
// Normal, single tracked server.
|
||||||
bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() {
|
bungeeReplacers.put(matcher.group(), () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String update() {
|
|
||||||
return String.valueOf(BungeeServerTracker.getPlayersOnline(serverName));
|
return String.valueOf(BungeeServerTracker.getPlayersOnline(serverName));
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -217,19 +203,15 @@ public class PlaceholdersManager {
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
|
|
||||||
if (bungeeReplacers == null) {
|
if (bungeeReplacers == null) {
|
||||||
bungeeReplacers = Utils.newMap();
|
bungeeReplacers = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
final String serverName = extractArgumentFromPlaceholder(matcher);
|
final String serverName = extractArgumentFromPlaceholder(matcher);
|
||||||
BungeeServerTracker.track(serverName); // Track this server.
|
BungeeServerTracker.track(serverName); // Track this server.
|
||||||
|
|
||||||
// Add it to tracked servers.
|
// Add it to tracked servers.
|
||||||
bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() {
|
bungeeReplacers.put(matcher.group(), () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String update() {
|
|
||||||
return BungeeServerTracker.getMaxPlayers(serverName);
|
return BungeeServerTracker.getMaxPlayers(serverName);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,19 +220,15 @@ public class PlaceholdersManager {
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
|
|
||||||
if (bungeeReplacers == null) {
|
if (bungeeReplacers == null) {
|
||||||
bungeeReplacers = Utils.newMap();
|
bungeeReplacers = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
final String serverName = extractArgumentFromPlaceholder(matcher);
|
final String serverName = extractArgumentFromPlaceholder(matcher);
|
||||||
BungeeServerTracker.track(serverName); // Track this server.
|
BungeeServerTracker.track(serverName); // Track this server.
|
||||||
|
|
||||||
// Add it to tracked servers.
|
// Add it to tracked servers.
|
||||||
bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() {
|
bungeeReplacers.put(matcher.group(), () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String update() {
|
|
||||||
return BungeeServerTracker.getMotd1(serverName);
|
return BungeeServerTracker.getMotd1(serverName);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,19 +237,15 @@ public class PlaceholdersManager {
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
|
|
||||||
if (bungeeReplacers == null) {
|
if (bungeeReplacers == null) {
|
||||||
bungeeReplacers = Utils.newMap();
|
bungeeReplacers = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
final String serverName = extractArgumentFromPlaceholder(matcher);
|
final String serverName = extractArgumentFromPlaceholder(matcher);
|
||||||
BungeeServerTracker.track(serverName); // Track this server.
|
BungeeServerTracker.track(serverName); // Track this server.
|
||||||
|
|
||||||
// Add it to tracked servers.
|
// Add it to tracked servers.
|
||||||
bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() {
|
bungeeReplacers.put(matcher.group(), () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String update() {
|
|
||||||
return BungeeServerTracker.getMotd2(serverName);
|
return BungeeServerTracker.getMotd2(serverName);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,19 +254,15 @@ public class PlaceholdersManager {
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
|
|
||||||
if (bungeeReplacers == null) {
|
if (bungeeReplacers == null) {
|
||||||
bungeeReplacers = Utils.newMap();
|
bungeeReplacers = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
final String serverName = extractArgumentFromPlaceholder(matcher);
|
final String serverName = extractArgumentFromPlaceholder(matcher);
|
||||||
BungeeServerTracker.track(serverName); // Track this server.
|
BungeeServerTracker.track(serverName); // Track this server.
|
||||||
|
|
||||||
// Add it to tracked servers.
|
// Add it to tracked servers.
|
||||||
bungeeReplacers.put(matcher.group(), new PlaceholderReplacer() {
|
bungeeReplacers.put(matcher.group(), () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String update() {
|
|
||||||
return BungeeServerTracker.getOnlineStatus(serverName);
|
return BungeeServerTracker.getOnlineStatus(serverName);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +278,7 @@ public class PlaceholdersManager {
|
|||||||
if (animation != null) {
|
if (animation != null) {
|
||||||
|
|
||||||
if (animationsPlaceholders == null) {
|
if (animationsPlaceholders == null) {
|
||||||
animationsPlaceholders = Utils.newMap();
|
animationsPlaceholders = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
animationsPlaceholders.put(matcher.group(), animation);
|
animationsPlaceholders.put(matcher.group(), animation);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
package com.gmail.filoghost.holographicdisplays.placeholder;
|
package com.gmail.filoghost.holographicdisplays.placeholder;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -23,47 +24,30 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
|
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.disk.Configuration;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
||||||
|
|
||||||
public class PlaceholdersRegister {
|
public class PlaceholdersRegister {
|
||||||
|
|
||||||
private static final Set<Placeholder> placeholders = Utils.newSet();
|
private static final Set<Placeholder> placeholders = new HashSet<>();
|
||||||
|
|
||||||
// Register the default placeholders statically.
|
// Register the default placeholders statically.
|
||||||
static {
|
static {
|
||||||
|
|
||||||
register(new Placeholder(HolographicDisplays.getInstance(), "{online}", 1.0, new PlaceholderReplacer() {
|
register(new Placeholder(HolographicDisplays.getInstance(), "{online}", 1.0, () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String update() {
|
|
||||||
return String.valueOf(Bukkit.getOnlinePlayers().size());
|
return String.valueOf(Bukkit.getOnlinePlayers().size());
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
register(new Placeholder(HolographicDisplays.getInstance(), "{max_players}", 10.0, new PlaceholderReplacer() {
|
register(new Placeholder(HolographicDisplays.getInstance(), "{max_players}", 10.0, () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String update() {
|
|
||||||
return String.valueOf(Bukkit.getMaxPlayers());
|
return String.valueOf(Bukkit.getMaxPlayers());
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
register(new Placeholder(HolographicDisplays.getInstance(), "{motd}", 60.0, new PlaceholderReplacer() {
|
register(new Placeholder(HolographicDisplays.getInstance(), "{motd}", 60.0, () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String update() {
|
|
||||||
return Bukkit.getMotd();
|
return Bukkit.getMotd();
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
register(new Placeholder(HolographicDisplays.getInstance(), "{time}", 0.9, new PlaceholderReplacer() {
|
register(new Placeholder(HolographicDisplays.getInstance(), "{time}", 0.9, () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String update() {
|
|
||||||
return Configuration.timeFormat.format(new Date());
|
return Configuration.timeFormat.format(new Date());
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
register(new Placeholder(HolographicDisplays.getInstance(), "&u", 0.2, new CyclicPlaceholderReplacer(Utils.arrayToStrings(
|
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) {
|
public static Set<String> getTextPlaceholdersByPlugin(Plugin plugin) {
|
||||||
Set<String> found = Utils.newSet();
|
Set<String> found = new HashSet<>();
|
||||||
|
|
||||||
for (Placeholder placeholder : placeholders) {
|
for (Placeholder placeholder : placeholders) {
|
||||||
if (placeholder.getOwner().equals(plugin)) {
|
if (placeholder.getOwner().equals(plugin)) {
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
package com.gmail.filoghost.holographicdisplays.placeholder;
|
package com.gmail.filoghost.holographicdisplays.placeholder;
|
||||||
|
|
||||||
import java.util.Collection;
|
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 {
|
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}.
|
// The placeholder itself, something like {player}.
|
||||||
private final String textPlaceholder;
|
private final String textPlaceholder;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.filoghost.holographicdisplays.task;
|
package com.gmail.filoghost.holographicdisplays.task;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -21,11 +22,9 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Utils;
|
|
||||||
|
|
||||||
public class WorldPlayerCounterTask implements Runnable {
|
public class WorldPlayerCounterTask implements Runnable {
|
||||||
|
|
||||||
private static Map<String, Integer> worlds = Utils.newMap();
|
private static Map<String, Integer> worlds = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -41,7 +41,7 @@ public class FileUtils {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
List<String> lines = new ArrayList<String>();
|
List<String> lines = new ArrayList<>();
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
throw new FileNotFoundException();
|
throw new FileNotFoundException();
|
||||||
|
@ -27,7 +27,7 @@ public class ItemUtils {
|
|||||||
public static final String ANTISTACK_LORE = ChatColor.BLACK.toString() + Math.random();
|
public static final String ANTISTACK_LORE = ChatColor.BLACK.toString() + Math.random();
|
||||||
|
|
||||||
// A map with formatted materials (lowercase and without symbols) for fast access.
|
// 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.
|
// The chars that will be ignored when matching materials.
|
||||||
private static final Pattern STRIP_SPACING_SYMBOLS_PATTERN = Pattern.compile("[_ \\-]+");
|
private static final Pattern STRIP_SPACING_SYMBOLS_PATTERN = Pattern.compile("[_ \\-]+");
|
||||||
|
@ -14,13 +14,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.filoghost.holographicdisplays.util;
|
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;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
public class Utils extends Object {
|
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) {
|
public static int floor(double num) {
|
||||||
int floor = (int) num;
|
int floor = (int) num;
|
||||||
return floor == num ? floor : floor - (int) (Double.doubleToRawLongBits(num) >>> 63);
|
return floor == num ? floor : floor - (int) (Double.doubleToRawLongBits(num) >>> 63);
|
||||||
@ -104,19 +84,6 @@ public class Utils extends Object {
|
|||||||
return result.toString();
|
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) {
|
public static String sanitize(String s) {
|
||||||
return s != null ? s : "null";
|
return s != null ? s : "null";
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
package com.gmail.filoghost.holographicdisplays.util.reflection;
|
package com.gmail.filoghost.holographicdisplays.util.reflection;
|
||||||
|
|
||||||
import java.lang.StackWalker.StackFrame;
|
import java.lang.StackWalker.StackFrame;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Stream;
|
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 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<Integer> GET_STACKTRACE_DEPTH_METHOD = new ReflectMethod<>(Throwable.class, "getStackTraceDepth");
|
||||||
private static final ReflectMethod<StackTraceElement> GET_STACKTRACE_ELEMENT_METHOD = new ReflectMethod<StackTraceElement>(Throwable.class, "getStackTraceElement", int.class);
|
private static final ReflectMethod<StackTraceElement> GET_STACKTRACE_ELEMENT_METHOD = new ReflectMethod<>(Throwable.class, "getStackTraceElement", int.class);
|
||||||
|
|
||||||
private static boolean stackTraceError;
|
private static boolean stackTraceError;
|
||||||
|
|
||||||
@ -42,13 +41,8 @@ public class ReflectionUtils {
|
|||||||
try {
|
try {
|
||||||
if (HAS_JAVA9_STACKWALKER) {
|
if (HAS_JAVA9_STACKWALKER) {
|
||||||
// Use the Java 9 StackWalker API
|
// Use the Java 9 StackWalker API
|
||||||
StackFrame result = StackWalker.getInstance().walk(new Function<Stream<StackFrame>, StackFrame>() {
|
StackFrame result = StackWalker.getInstance().walk((Stream<StackFrame> stream) -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public StackFrame apply(Stream<StackFrame> stream) {
|
|
||||||
return stream.skip(index).limit(1).findFirst().orElse(null);
|
return stream.skip(index).limit(1).findFirst().orElse(null);
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
return result != null ? result.toStackTraceElement() : null;
|
return result != null ? result.toStackTraceElement() : null;
|
||||||
|
|
||||||
|
4
pom.xml
4
pom.xml
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>1.6</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.6</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<maven.test.skip>true</maven.test.skip>
|
<maven.test.skip>true</maven.test.skip>
|
||||||
<spigot-api.version>1.8-R0.1-SNAPSHOT</spigot-api.version>
|
<spigot-api.version>1.8-R0.1-SNAPSHOT</spigot-api.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
Loading…
Reference in New Issue
Block a user