summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTravis Watkins <amaranth@ubuntu.com>2014-02-08 15:02:44 -0600
committerTravis Watkins <amaranth@ubuntu.com>2014-02-08 15:02:44 -0600
commit219f4e2c25ab8e0e0c79341d9ab49182c0c4f800 (patch)
tree2996bf073717e4f27451096e67876dd7dd6cc5de /src
parent553acdf0cdde1abe59399a83af5cc3deb78c188f (diff)
downloadcraftbukkit-219f4e2c25ab8e0e0c79341d9ab49182c0c4f800.tar
craftbukkit-219f4e2c25ab8e0e0c79341d9ab49182c0c4f800.tar.gz
craftbukkit-219f4e2c25ab8e0e0c79341d9ab49182c0c4f800.tar.lz
craftbukkit-219f4e2c25ab8e0e0c79341d9ab49182c0c4f800.tar.xz
craftbukkit-219f4e2c25ab8e0e0c79341d9ab49182c0c4f800.zip
Match old alias behavior when migrating.
Previously the alias system would pass all arguments from the alias to its command(s) implicitly. The new system requires arguments to be explicitly passed so server owners can have more control over where and how they are passed. To ensure this isn't a breaking change during the migration from bukkit.yml to commands.yml we now add the $1- argument to the alias commands to match the previous behavior.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 22f394d5..e6c85758 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -270,12 +270,25 @@ public final class CraftServer implements Server {
commandsConfiguration.options().copyDefaults(true);
commandsConfiguration.setDefaults(YamlConfiguration.loadConfiguration(getClass().getClassLoader().getResourceAsStream("configurations/commands.yml")));
saveCommandsConfig();
+
+ // Migrate aliases from old file and add previously implicit $1- to pass all arguments
if (legacyAlias != null) {
ConfigurationSection aliases = commandsConfiguration.createSection("aliases");
- for (Entry<String, Object> entry : legacyAlias.getValues(true).entrySet()) {
- aliases.set(entry.getKey(), entry.getValue());
+ for (String key : legacyAlias.getKeys(false)) {
+ ArrayList<String> commands = new ArrayList<String>();
+
+ if (legacyAlias.isList(key)) {
+ for (String command : legacyAlias.getStringList(key)) {
+ commands.add(command + " $1-");
+ }
+ } else {
+ commands.add(legacyAlias.getString(key) + " $1-");
+ }
+
+ aliases.set(key, commands);
}
}
+
saveCommandsConfig();
overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*");
((SimplePluginManager) pluginManager).useTimings(configuration.getBoolean("settings.plugin-profiling"));