diff --git a/src/main/java/ch/njol/skript/Skript.java b/src/main/java/ch/njol/skript/Skript.java index dc4c742ce58..3bac50a805d 100644 --- a/src/main/java/ch/njol/skript/Skript.java +++ b/src/main/java/ch/njol/skript/Skript.java @@ -29,6 +29,7 @@ import ch.njol.skript.lang.Trigger; import ch.njol.skript.lang.TriggerItem; import ch.njol.skript.lang.util.SimpleExpression; +import ch.njol.skript.localization.ArgsMessage; import ch.njol.skript.localization.Language; import ch.njol.skript.localization.Message; import ch.njol.skript.localization.PluralizingArgsMessage; @@ -74,10 +75,8 @@ import com.google.gson.Gson; import org.bstats.bukkit.Metrics; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Server; +import org.bstats.charts.SimplePie; +import org.bukkit.*; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.entity.Player; @@ -88,6 +87,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.ServerCommandEvent; +import org.bukkit.event.server.ServerLoadEvent; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; @@ -235,6 +235,17 @@ public static Version getVersion() { m_no_scripts = new Message("skript.no scripts"); private static final PluralizingArgsMessage m_scripts_loaded = new PluralizingArgsMessage("skript.scripts loaded"); + private static final Message WARNING_MESSAGE = new Message("skript.warning message"); + private static final Message RESTART_MESSAGE = new Message("skript.restart message"); + + public static String getWarningMessage() { + return WARNING_MESSAGE.getValueOrDefault("It appears that /reload or another plugin reloaded Skript. This is not supported behaviour and may cause issues."); + } + + public static String getRestartMessage() { + return RESTART_MESSAGE.getValueOrDefault("Please consider restarting the server instead."); + } + public static ServerPlatform getServerPlatform() { if (classExists("net.glowstone.GlowServer")) { return ServerPlatform.BUKKIT_GLOWSTONE; // Glowstone has timings too, so must check for it first @@ -863,6 +874,25 @@ public void run() { } }, this); + // Send a warning to console when the plugin is reloaded + Bukkit.getPluginManager().registerEvents(new Listener() { + @EventHandler + public void onServerReload(ServerLoadEvent event) { + if ((event.getType() != ServerLoadEvent.LoadType.RELOAD)) + return; + + for (OfflinePlayer player : Bukkit.getOperators()) { + if (player.isOnline()) { + player.getPlayer().sendMessage(ChatColor.YELLOW + getWarningMessage()); + player.getPlayer().sendMessage(ChatColor.YELLOW + getRestartMessage()); + } + } + + Skript.warning(getWarningMessage()); + Skript.warning(getRestartMessage()); + } + }, this); + // Tell Timings that we are here! SkriptTimings.setSkript(this); } diff --git a/src/main/resources/lang/english.lang b/src/main/resources/lang/english.lang index 3bb49c855dc..ad2b1eb8ef9 100644 --- a/src/main/resources/lang/english.lang +++ b/src/main/resources/lang/english.lang @@ -17,6 +17,8 @@ skript: no errors: All scripts loaded without errors. scripts loaded: Loaded %s script¦¦s¦ with a total of %s structure¦¦s¦ in %s finished loading: Finished loading. + warning message: It appears that /reload or another plugin reloaded Skript. This is not supported behaviour and may cause issues. + restart message: Please consider restarting the server instead. # -- Skript command -- skript command: