worlds with spaces support implementation

This commit is contained in:
SuperRonanCraft 2020-11-03 00:12:57 -05:00
parent c41b3bd2c0
commit dbdf7d6a60
4 changed files with 25 additions and 17 deletions

View File

@ -6,7 +6,7 @@
<groupId>me.SuperRonanCraft</groupId> <groupId>me.SuperRonanCraft</groupId>
<artifactId>BetterRTP</artifactId> <artifactId>BetterRTP</artifactId>
<version>2.14.3</version> <version>2.14.4</version>
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>

View File

@ -25,10 +25,12 @@ public class CmdWorld implements RTPCommand, RTPCommandHelpable {
public List<String> tabComplete(CommandSender sendi, String[] args) { public List<String> tabComplete(CommandSender sendi, String[] args) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
if (args.length == 2) { if (args.length == 2) {
for (World w : Bukkit.getWorlds()) for (World w : Bukkit.getWorlds()) {
if (w.getName().startsWith(args[1]) && !Main.getInstance().getRTP().disabledWorlds().contains(w.getName()) && String _wName = w.getName().replace(" ", "_");
Main.getInstance().getPerms().getAWorld(sendi, w.getName())) if (w.getName().startsWith(args[1]) && !Main.getInstance().getRTP().disabledWorlds().contains(_wName)
list.add(w.getName()); && Main.getInstance().getPerms().getAWorld(sendi, _wName))
list.add(_wName);
}
} else if (args.length >= 3) { } else if (args.length >= 3) {
if (CommandTypes.BIOME.getCmd().permission(sendi)) if (CommandTypes.BIOME.getCmd().permission(sendi))
getCmd().addBiomes(list, args); getCmd().addBiomes(list, args);

View File

@ -116,18 +116,18 @@ public class RTP {
return disabledWorlds; return disabledWorlds;
} }
public WorldPlayer getPlayerWorld(CommandSender p, String worldName, List<String> biomes, boolean personal) { public WorldPlayer getPlayerWorld(CommandSender sendi, String world_name, List<String> biomes, boolean personal) {
WorldPlayer pWorld = new WorldPlayer(p, Bukkit.getWorld(worldName)); WorldPlayer pWorld = new WorldPlayer(sendi, Bukkit.getWorld(world_name));
// Set all methods // Set all methods
if (customWorlds.containsKey(worldName)) { if (customWorlds.containsKey(world_name)) {
RTPWorld cWorld = customWorlds.get(pWorld.getWorld().getName()); RTPWorld cWorld = customWorlds.get(pWorld.getWorld().getName());
pWorld.setup(cWorld, cWorld.getPrice(), biomes, personal); pWorld.setup(cWorld, cWorld.getPrice(), biomes, personal);
} else } else
pWorld.setup(defaultWorld, defaultWorld.getPrice(), biomes, personal); pWorld.setup(defaultWorld, defaultWorld.getPrice(), biomes, personal);
//World type //World type
WORLD_TYPE world_type = WORLD_TYPE.NORMAL; //World rtp type WORLD_TYPE world_type = WORLD_TYPE.NORMAL; //World rtp type
if (this.world_type.containsKey(worldName)) if (this.world_type.containsKey(world_name))
world_type = this.world_type.get(worldName); world_type = this.world_type.get(world_name);
pWorld.setWorldtype(world_type); pWorld.setWorldtype(world_type);
return pWorld; return pWorld;
} }
@ -138,8 +138,19 @@ public class RTP {
public void start(Player p, CommandSender sendi, String world_name, List<String> biomes, boolean delay) { public void start(Player p, CommandSender sendi, String world_name, List<String> biomes, boolean delay) {
// Check overrides // Check overrides
if (world_name == null) if (world_name == null) {
world_name = p.getWorld().getName(); 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)) if (overriden.containsKey(world_name))
world_name = overriden.get(world_name); world_name = overriden.get(world_name);
// Not forced and has 'betterrtp.world.<world>' // Not forced and has 'betterrtp.world.<world>'
@ -152,11 +163,6 @@ public class RTP {
getPl().getText().getDisabledWorld(sendi, world_name); getPl().getText().getDisabledWorld(sendi, world_name);
return; 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); WorldPlayer pWorld = getPlayerWorld(p, world_name, biomes, true);
// Economy // Economy
if (!getPl().getEco().hasBalance(sendi, pWorld)) { if (!getPl().getEco().hasBalance(sendi, pWorld)) {

View File

@ -1,5 +1,5 @@
main: me.SuperRonanCraft.BetterRTP.Main main: me.SuperRonanCraft.BetterRTP.Main
version: '2.14.3' version: '2.14.4'
name: BetterRTP name: BetterRTP
author: SuperRonanCraft author: SuperRonanCraft
softdepend: [Vault, WorldGuard, GriefPrevention, Towny, Factions, RedProtect, Lands, Residence] softdepend: [Vault, WorldGuard, GriefPrevention, Towny, Factions, RedProtect, Lands, Residence]