Better handling of plugin reloaders and /reload

This commit is contained in:
filoghost 2016-05-10 17:12:11 +02:00
parent 4a4661ef8d
commit 5f2ddc6ae1

View File

@ -3,6 +3,7 @@ package com.gmail.filoghost.holographicdisplays;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
import com.gmail.filoghost.holographicdisplays.SimpleUpdater.ResponseHandler;
@ -20,6 +21,8 @@ import com.gmail.filoghost.holographicdisplays.metrics.MetricsLite;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.NMSManager;
import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
import com.gmail.filoghost.holographicdisplays.object.PluginHologram;
import com.gmail.filoghost.holographicdisplays.object.PluginHologramManager;
import com.gmail.filoghost.holographicdisplays.placeholder.AnimationsRegister;
import com.gmail.filoghost.holographicdisplays.placeholder.PlaceholdersManager;
import com.gmail.filoghost.holographicdisplays.task.BungeeCleanupTask;
@ -56,12 +59,12 @@ public class HolographicDisplays extends JavaPlugin {
@Override
public void onEnable() {
// Blocks plugin reloaders and the /reload command.
if (instance != null) {
getLogger().warning("Please do not use /reload or plugin reloaders. Do \"/holograms reload\" instead.");
return;
// Warn about plugin reloaders and the /reload command.
if (instance != null || System.getProperty("HolographicDisplaysLoaded") != null) {
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[HolographicDisplays] Please do not use /reload or plugin reloaders. Use the command \"/holograms reload\" instead. You will receive no support for doing this operation.");
}
System.setProperty("HolographicDisplaysLoaded", "true");
instance = this;
// Load placeholders.yml.
@ -140,7 +143,7 @@ public class HolographicDisplays extends JavaPlugin {
"******************************************************",
" This version of HolographicDisplays can",
" only work on these server versions:",
" from 1.6.4 to 1.9.",
" from 1.6.4 to 1.9.2.",
" The plugin will be disabled.",
"******************************************************"
);
@ -173,7 +176,7 @@ public class HolographicDisplays extends JavaPlugin {
// ProtocolLib check.
try {
if (Bukkit.getPluginManager().isPluginEnabled("ProtocolLib")) {
ProtocolLibHook protocolLibHook;
ProtocolLibHook protocolLibHook;
if (is19orGreater) {
protocolLibHook = new com.gmail.filoghost.holographicdisplays.bridge.protocollib.current.ProtocolLibHookImpl();
@ -256,6 +259,9 @@ public class HolographicDisplays extends JavaPlugin {
for (NamedHologram hologram : NamedHologramManager.getHolograms()) {
hologram.despawnEntities();
}
for (PluginHologram hologram : PluginHologramManager.getHolograms()) {
hologram.despawnEntities();
}
}
public static NMSManager getNMSManager() {