Allow multi-word names in /ma addarena and /ma autogenerate.
Introduces support for multi-word arena names in the two commands. The approach is to simply join the arguments by spaces. Because of the new slug-based lookups, multi-word names are fairly straightforward.
This commit is contained in:
@@ -26,6 +26,7 @@ These changes will (most likely) be included in the next version.
|
|||||||
- Permissions for arenas and classes are now based on "slugs". It is now possible to configure permissions for arenas and classes with multi-word names (including "My Items"). Check the Permissions page on the wiki for details.
|
- Permissions for arenas and classes are now based on "slugs". It is now possible to configure permissions for arenas and classes with multi-word names (including "My Items"). Check the Permissions page on the wiki for details.
|
||||||
- Commands that resolve arena and/or class names now consistently resolve and tab complete "slugs" instead of arbitrarily "squashed" names. This greatly improves support for multi-word names.
|
- Commands that resolve arena and/or class names now consistently resolve and tab complete "slugs" instead of arbitrarily "squashed" names. This greatly improves support for multi-word names.
|
||||||
- The class signs generated by the `/ma autogenerate` command now use class names from the config-file instead of arbitrarily "squashed" names.
|
- The class signs generated by the `/ma autogenerate` command now use class names from the config-file instead of arbitrarily "squashed" names.
|
||||||
|
- The `/ma addarena` and `/ma autogenerate` commands now supports multi-word arena names.
|
||||||
- Leaderboards now use arena names from the config-file instead of arbitrarily "prettified" names.
|
- Leaderboards now use arena names from the config-file instead of arbitrarily "prettified" names.
|
||||||
- Using `spectate-on-death: true` no longer forces players out to their join location/exit warp before moving them to the spectator area. This should prevent "jumpy" behavior in multi-world setups.
|
- Using `spectate-on-death: true` no longer forces players out to their join location/exit warp before moving them to the spectator area. This should prevent "jumpy" behavior in multi-world setups.
|
||||||
- Players should now properly respawn at the spectator area rather than at world spawn on servers with plugins that override respawn locations.
|
- Players should now properly respawn at the spectator area rather than at world spawn on servers with plugins that override respawn locations.
|
||||||
|
|||||||
@@ -6,9 +6,13 @@ import com.garbagemule.MobArena.commands.CommandInfo;
|
|||||||
import com.garbagemule.MobArena.commands.Commands;
|
import com.garbagemule.MobArena.commands.Commands;
|
||||||
import com.garbagemule.MobArena.framework.Arena;
|
import com.garbagemule.MobArena.framework.Arena;
|
||||||
import com.garbagemule.MobArena.framework.ArenaMaster;
|
import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||||
|
import com.garbagemule.MobArena.util.Slugs;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@CommandInfo(
|
@CommandInfo(
|
||||||
name = "addarena",
|
name = "addarena",
|
||||||
pattern = "(add|new)arena",
|
pattern = "(add|new)arena",
|
||||||
@@ -26,18 +30,20 @@ public class AddArenaCommand implements Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Require an arena name
|
// Require an arena name
|
||||||
if (args.length != 1) return false;
|
if (args.length < 1) return false;
|
||||||
|
|
||||||
// Unwrap the sender.
|
// Unwrap the sender.
|
||||||
Player p = Commands.unwrap(sender);
|
Player p = Commands.unwrap(sender);
|
||||||
|
|
||||||
Arena arena = am.getArenaWithName(args[0]);
|
String name = String.join(" ", args);
|
||||||
|
String slug = Slugs.create(name);
|
||||||
|
Arena arena = am.getArenaWithName(slug);
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
am.getGlobalMessenger().tell(sender, "An arena with that name already exists.");
|
am.getGlobalMessenger().tell(sender, "An arena with that name already exists.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
am.createArenaNode(args[0], p.getWorld());
|
am.createArenaNode(name, p.getWorld());
|
||||||
am.getGlobalMessenger().tell(sender, "New arena with name '" + args[0] + "' created!");
|
am.getGlobalMessenger().tell(sender, "New arena with name '" + name + "' created!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.garbagemule.MobArena.commands.CommandInfo;
|
|||||||
import com.garbagemule.MobArena.commands.Commands;
|
import com.garbagemule.MobArena.commands.Commands;
|
||||||
import com.garbagemule.MobArena.framework.Arena;
|
import com.garbagemule.MobArena.framework.Arena;
|
||||||
import com.garbagemule.MobArena.framework.ArenaMaster;
|
import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||||
|
import com.garbagemule.MobArena.util.Slugs;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -27,24 +28,26 @@ public class AutoGenerateCommand implements Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Require an arena name
|
// Require an arena name
|
||||||
if (args.length != 1) return false;
|
if (args.length < 1) return false;
|
||||||
|
|
||||||
// Unwrap the sender.
|
// Unwrap the sender.
|
||||||
Player p = Commands.unwrap(sender);
|
Player p = Commands.unwrap(sender);
|
||||||
|
|
||||||
// Check if arena already exists.
|
// Check if arena already exists.
|
||||||
Arena arena = am.getArenaWithName(args[0]);
|
String name = String.join(" ", args);
|
||||||
|
String slug = Slugs.create(name);
|
||||||
|
Arena arena = am.getArenaWithName(slug);
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
am.getGlobalMessenger().tell(sender, "An arena with that name already exists.");
|
am.getGlobalMessenger().tell(sender, "An arena with that name already exists.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MAUtils.doooooItHippieMonster(p.getLocation(), 13, args[0], am.getPlugin())) {
|
if (!MAUtils.doooooItHippieMonster(p.getLocation(), 13, name, am.getPlugin())) {
|
||||||
am.getGlobalMessenger().tell(sender, "Could not auto-generate arena.");
|
am.getGlobalMessenger().tell(sender, "Could not auto-generate arena.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
am.getGlobalMessenger().tell(sender, "Arena with name '" + args[0] + "' generated.");
|
am.getGlobalMessenger().tell(sender, "Arena with name '" + name + "' generated.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user