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 @@ -249,6 +250,9 @@ 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 String WARNING_MESSAGE = "It appears that /reload or another plugin reloaded Skript. This is not supported behaviour and may cause issues.";
private static final String RESTART_MESSAGE = "Please consider restarting the server instead.";
Asleeepp marked this conversation as resolved.
Show resolved Hide resolved

public static ServerPlatform getServerPlatform() {
if (classExists("net.glowstone.GlowServer")) {
return ServerPlatform.BUKKIT_GLOWSTONE; // Glowstone has timings too, so must check for it first
Expand Down Expand Up @@ -923,6 +927,24 @@ 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

for (Player player : Bukkit.getOnlinePlayers()) {
Asleeepp marked this conversation as resolved.
Show resolved Hide resolved
if (player.isOp()) {
player.sendMessage(ChatColor.YELLOW + WARNING_MESSAGE);
player.sendMessage(ChatColor.YELLOW + RESTART_MESSAGE);
}
}

Skript.warning(WARNING_MESSAGE);
Skript.warning(RESTART_MESSAGE);
}
}, this);

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