mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-26 09:42:06 -07:00
Only namespaced reload (#12773)
This commit is contained in:
@@ -31,7 +31,9 @@ public class SimpleCommandMap implements CommandMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaultCommands() {
|
private void setDefaultCommands() {
|
||||||
register("bukkit", new ReloadCommand("reload"));
|
final ReloadCommand reload = new ReloadCommand("reload");
|
||||||
|
this.knownCommands.put("bukkit:reload", reload);
|
||||||
|
this.knownCommands.put("bukkit:rl", reload);
|
||||||
register("bukkit", new co.aikar.timings.TimingsCommand("timings"));
|
register("bukkit", new co.aikar.timings.TimingsCommand("timings"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,6 +9,8 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.text.Component.text;
|
||||||
|
|
||||||
public class ReloadCommand extends BukkitCommand {
|
public class ReloadCommand extends BukkitCommand {
|
||||||
public ReloadCommand(@NotNull String name) {
|
public ReloadCommand(@NotNull String name) {
|
||||||
super(name);
|
super(name);
|
||||||
@@ -25,34 +27,32 @@ public class ReloadCommand extends BukkitCommand {
|
|||||||
public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { // Paper
|
public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { // Paper
|
||||||
if (!testPermission(sender)) return true;
|
if (!testPermission(sender)) return true;
|
||||||
|
|
||||||
// Paper start - Reload permissions.yml & require confirm
|
|
||||||
boolean confirmed = System.getProperty("LetMeReload") != null;
|
boolean confirmed = System.getProperty("LetMeReload") != null;
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (args[0].equalsIgnoreCase("permissions")) {
|
if (args[0].equalsIgnoreCase("permissions")) {
|
||||||
Bukkit.getServer().reloadPermissions();
|
Bukkit.getServer().reloadPermissions();
|
||||||
Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Permissions successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN));
|
Command.broadcastCommandMessage(sender, text("Permissions successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN));
|
||||||
return true;
|
return true;
|
||||||
} else if ("commands".equalsIgnoreCase(args[0])) {
|
} else if ("commands".equalsIgnoreCase(args[0])) {
|
||||||
if (Bukkit.getServer().reloadCommandAliases()) {
|
if (Bukkit.getServer().reloadCommandAliases()) {
|
||||||
Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Command aliases successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN));
|
Command.broadcastCommandMessage(sender, text("Command aliases successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN));
|
||||||
} else {
|
} else {
|
||||||
Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("An error occurred while trying to reload command aliases.", net.kyori.adventure.text.format.NamedTextColor.RED));
|
Command.broadcastCommandMessage(sender, text("An error occurred while trying to reload command aliases.", net.kyori.adventure.text.format.NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if ("confirm".equalsIgnoreCase(args[0])) {
|
} else if ("confirm".equalsIgnoreCase(args[0])) {
|
||||||
confirmed = true;
|
confirmed = true;
|
||||||
} else {
|
} else {
|
||||||
Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Usage: " + usageMessage, net.kyori.adventure.text.format.NamedTextColor.RED));
|
Command.broadcastCommandMessage(sender, text("Usage: " + usageMessage, net.kyori.adventure.text.format.NamedTextColor.RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!confirmed) {
|
if (!confirmed) {
|
||||||
Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Are you sure you wish to reload your server? Doing so may cause bugs and memory leaks. It is recommended to restart instead of using /reload. To confirm, please type ", net.kyori.adventure.text.format.NamedTextColor.RED).append(net.kyori.adventure.text.Component.text("/reload confirm", net.kyori.adventure.text.format.NamedTextColor.YELLOW)));
|
Command.broadcastCommandMessage(sender, text("Are you sure you wish to reload your server? This command will be removed soon. Doing so may cause bugs and memory leaks. It is recommended to restart instead of using /bukkit:reload. To confirm, please type ", net.kyori.adventure.text.format.NamedTextColor.RED).append(text("/bukkit:reload confirm", net.kyori.adventure.text.format.NamedTextColor.YELLOW)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Paper end
|
|
||||||
|
|
||||||
Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues when using some plugins.");
|
Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported, may cause issues when using some plugins, and will be removed soon.");
|
||||||
Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
||||||
// Paper start - lifecycle events
|
// Paper start - lifecycle events
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user