geforkt von Mirrors/Paper
Merge pull request #628 from willies952002/feature/reloadCommands
Don't Display Success Message on Alias Reload Fail
Dieser Commit ist enthalten in:
Commit
1471ac1b64
@ -6,7 +6,7 @@ Subject: [PATCH] Allow Reloading of Command Aliases
|
|||||||
Reload the aliases stored in commands.yml
|
Reload the aliases stored in commands.yml
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index f5af400d..1f663fa1 100644
|
||||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
@@ -0,0 +0,0 @@ public final class Bukkit {
|
@@ -0,0 +0,0 @@ public final class Bukkit {
|
||||||
@ -17,14 +17,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ /**
|
+ /**
|
||||||
+ * Reload the Command Aliases in commands.yml
|
+ * Reload the Command Aliases in commands.yml
|
||||||
+ */
|
+ */
|
||||||
+ public static void reloadCommandAliases() {
|
+ public static boolean reloadCommandAliases() {
|
||||||
+ server.reloadCommandAliases();
|
+ return server.reloadCommandAliases();
|
||||||
+ }
|
+ }
|
||||||
// Paper end
|
// Paper end
|
||||||
|
|
||||||
public static Server.Spigot spigot()
|
public static Server.Spigot spigot()
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 2df83245..4a90d581 100644
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient {
|
@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient {
|
||||||
@ -32,10 +32,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
|
|
||||||
void reloadPermissions(); // Paper
|
void reloadPermissions(); // Paper
|
||||||
+
|
+
|
||||||
+ void reloadCommandAliases(); // Paper
|
+ boolean reloadCommandAliases(); // Paper
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/command/CommandMap.java b/src/main/java/org/bukkit/command/CommandMap.java
|
diff --git a/src/main/java/org/bukkit/command/CommandMap.java b/src/main/java/org/bukkit/command/CommandMap.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 30d60247..d8a75607 100644
|
||||||
--- a/src/main/java/org/bukkit/command/CommandMap.java
|
--- a/src/main/java/org/bukkit/command/CommandMap.java
|
||||||
+++ b/src/main/java/org/bukkit/command/CommandMap.java
|
+++ b/src/main/java/org/bukkit/command/CommandMap.java
|
||||||
@@ -0,0 +0,0 @@ public interface CommandMap {
|
@@ -0,0 +0,0 @@ public interface CommandMap {
|
||||||
@ -52,7 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ // Paper end
|
+ // Paper end
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 08976cd4..2e232fd1 100644
|
||||||
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||||
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||||
@@ -0,0 +0,0 @@ public class SimpleCommandMap implements CommandMap {
|
@@ -0,0 +0,0 @@ public class SimpleCommandMap implements CommandMap {
|
||||||
@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ // Paper end
|
+ // Paper end
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
|
diff --git a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 040509c1..0069bcc0 100644
|
||||||
--- a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
|
--- a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
|
||||||
+++ b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
|
+++ b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
|
||||||
@@ -0,0 +0,0 @@ public class ReloadCommand extends BukkitCommand {
|
@@ -0,0 +0,0 @@ public class ReloadCommand extends BukkitCommand {
|
||||||
@ -84,8 +84,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Permissions successfully reloaded.");
|
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Permissions successfully reloaded.");
|
||||||
return true;
|
return true;
|
||||||
+ } else if ("commands".equalsIgnoreCase(args[0])) {
|
+ } else if ("commands".equalsIgnoreCase(args[0])) {
|
||||||
+ Bukkit.getServer().reloadCommandAliases();
|
+ if (Bukkit.getServer().reloadCommandAliases()) {
|
||||||
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Command aliases successfully reloaded.");
|
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Command aliases successfully reloaded.");
|
||||||
|
+ } else {
|
||||||
|
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "An error occurred while trying to reload command aliases.");
|
||||||
|
+ }
|
||||||
+ return true;
|
+ return true;
|
||||||
} else if ("confirm".equalsIgnoreCase(args[0])) {
|
} else if ("confirm".equalsIgnoreCase(args[0])) {
|
||||||
confirmed = true;
|
confirmed = true;
|
||||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] Allow Reloading of Command Aliases
|
|||||||
Reload the aliases stored in commands.yml
|
Reload the aliases stored in commands.yml
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
index 1bbce7a78..31c9a66b6 100644
|
index 1bbce7a78..225e118dc 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||||
@ -15,13 +15,22 @@ index 1bbce7a78..31c9a66b6 100644
|
|||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void reloadCommandAliases() {
|
+ public boolean reloadCommandAliases() {
|
||||||
+ Set<String> removals = getCommandAliases().keySet().stream()
|
+ Set<String> removals = getCommandAliases().keySet().stream()
|
||||||
+ .map(key -> key.toLowerCase(java.util.Locale.ENGLISH))
|
+ .map(key -> key.toLowerCase(java.util.Locale.ENGLISH))
|
||||||
+ .collect(java.util.stream.Collectors.toSet());
|
+ .collect(java.util.stream.Collectors.toSet());
|
||||||
+ getCommandMap().getKnownCommands().keySet().removeIf(removals::contains);
|
+ getCommandMap().getKnownCommands().keySet().removeIf(removals::contains);
|
||||||
+ commandsConfiguration = YamlConfiguration.loadConfiguration(getCommandsConfigFile());
|
+ File file = getCommandsConfigFile();
|
||||||
|
+ try {
|
||||||
|
+ commandsConfiguration.load(file);
|
||||||
|
+ } catch (FileNotFoundException ex) {
|
||||||
|
+ return false;
|
||||||
|
+ } catch (IOException | org.bukkit.configuration.InvalidConfigurationException ex) {
|
||||||
|
+ Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
+ commandMap.registerServerAliases();
|
+ commandMap.registerServerAliases();
|
||||||
|
+ return true;
|
||||||
+ }
|
+ }
|
||||||
// Paper end
|
// Paper end
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren