Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning when reloading Skript. #6958

Merged
merged 12 commits into from
Oct 13, 2024
22 changes: 22 additions & 0 deletions src/main/java/ch/njol/skript/Skript.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,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;
Expand Down Expand Up @@ -923,6 +924,27 @@ 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;
Asleeepp marked this conversation as resolved.
Show resolved Hide resolved

String warningMessage = "It appears that /reload or another plugin reloaded Skript. This is not supported behaviour and may cause issues.";
String restartMessage = "Please consider restarting the server instead.";
Asleeepp marked this conversation as resolved.
Show resolved Hide resolved

for (Player player : Bukkit.getOnlinePlayers()) {
Asleeepp marked this conversation as resolved.
Show resolved Hide resolved
if (!player.isOp()) return;
Asleeepp marked this conversation as resolved.
Show resolved Hide resolved

player.sendMessage(ChatColor.RED + warningMessage);
player.sendMessage(ChatColor.RED + restartMessage);
Asleeepp marked this conversation as resolved.
Show resolved Hide resolved
}

Skript.warning(warningMessage);
Skript.warning(restartMessage);
}
}, this);

// Tell Timings that we are here!
SkriptTimings.setSkript(this);
}
Expand Down