From dbdf7d6a60c7ac7c971c9e995505d746e5de73c8 Mon Sep 17 00:00:00 2001 From: SuperRonanCraft Date: Tue, 3 Nov 2020 00:12:57 -0500 Subject: [PATCH] worlds with spaces support implementation --- pom.xml | 2 +- .../player/commands/types/CmdWorld.java | 10 ++++--- .../BetterRTP/player/rtp/RTP.java | 28 +++++++++++-------- src/main/resources/plugin.yml | 2 +- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index 80e3b0f..5fa1cfc 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.SuperRonanCraft BetterRTP - 2.14.3 + 2.14.4 1.8 diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/types/CmdWorld.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/types/CmdWorld.java index 34fe5f6..3385212 100644 --- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/types/CmdWorld.java +++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/types/CmdWorld.java @@ -25,10 +25,12 @@ public class CmdWorld implements RTPCommand, RTPCommandHelpable { public List tabComplete(CommandSender sendi, String[] args) { List list = new ArrayList<>(); if (args.length == 2) { - for (World w : Bukkit.getWorlds()) - if (w.getName().startsWith(args[1]) && !Main.getInstance().getRTP().disabledWorlds().contains(w.getName()) && - Main.getInstance().getPerms().getAWorld(sendi, w.getName())) - list.add(w.getName()); + for (World w : Bukkit.getWorlds()) { + String _wName = w.getName().replace(" ", "_"); + if (w.getName().startsWith(args[1]) && !Main.getInstance().getRTP().disabledWorlds().contains(_wName) + && Main.getInstance().getPerms().getAWorld(sendi, _wName)) + list.add(_wName); + } } else if (args.length >= 3) { if (CommandTypes.BIOME.getCmd().permission(sendi)) getCmd().addBiomes(list, args); diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java index 62ffd99..0a89239 100644 --- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java +++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java @@ -116,18 +116,18 @@ public class RTP { return disabledWorlds; } - public WorldPlayer getPlayerWorld(CommandSender p, String worldName, List biomes, boolean personal) { - WorldPlayer pWorld = new WorldPlayer(p, Bukkit.getWorld(worldName)); + public WorldPlayer getPlayerWorld(CommandSender sendi, String world_name, List biomes, boolean personal) { + WorldPlayer pWorld = new WorldPlayer(sendi, Bukkit.getWorld(world_name)); // Set all methods - if (customWorlds.containsKey(worldName)) { + if (customWorlds.containsKey(world_name)) { RTPWorld cWorld = customWorlds.get(pWorld.getWorld().getName()); pWorld.setup(cWorld, cWorld.getPrice(), biomes, personal); } else pWorld.setup(defaultWorld, defaultWorld.getPrice(), biomes, personal); //World type WORLD_TYPE world_type = WORLD_TYPE.NORMAL; //World rtp type - if (this.world_type.containsKey(worldName)) - world_type = this.world_type.get(worldName); + if (this.world_type.containsKey(world_name)) + world_type = this.world_type.get(world_name); pWorld.setWorldtype(world_type); return pWorld; } @@ -138,8 +138,19 @@ public class RTP { public void start(Player p, CommandSender sendi, String world_name, List biomes, boolean delay) { // Check overrides - if (world_name == null) + if (world_name == null) { world_name = p.getWorld().getName(); + } else { // Check if nulled or world doesnt exist + World _world = Bukkit.getWorld(world_name); + if (_world == null) { //Check if world has spaces instead of underscores + _world = Bukkit.getWorld(world_name.replace("_", " ")); + world_name = world_name.replace("_", ""); + } + if (_world == null) { + getPl().getText().getNotExist(sendi, world_name); + return; + } + } if (overriden.containsKey(world_name)) world_name = overriden.get(world_name); // Not forced and has 'betterrtp.world.' @@ -152,11 +163,6 @@ public class RTP { getPl().getText().getDisabledWorld(sendi, world_name); return; } - // Check if nulled or world doesnt exist - if (Bukkit.getWorld(world_name) == null) { - getPl().getText().getNotExist(sendi, world_name); - return; - } WorldPlayer pWorld = getPlayerWorld(p, world_name, biomes, true); // Economy if (!getPl().getEco().hasBalance(sendi, pWorld)) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b1b72ba..7e088cd 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ main: me.SuperRonanCraft.BetterRTP.Main -version: '2.14.3' +version: '2.14.4' name: BetterRTP author: SuperRonanCraft softdepend: [Vault, WorldGuard, GriefPrevention, Towny, Factions, RedProtect, Lands, Residence]