From 0ea56fe5d29e87958f4534e74379801ea669b2ce Mon Sep 17 00:00:00 2001 From: DroppingAnvil Date: Tue, 12 May 2020 14:41:12 -0500 Subject: [PATCH] World now per range instead of global + CmdWild cleanup --- .../java/com/massivecraft/factions/cmd/wild/CmdWild.java | 7 ++++--- src/main/resources/config.yml | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java b/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java index 6a5d556d..f25ac123 100644 --- a/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java +++ b/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java @@ -20,6 +20,7 @@ import org.bukkit.potion.PotionEffectType; import java.util.HashMap; import java.util.HashSet; +import java.util.Objects; import java.util.Random; /** @@ -29,7 +30,6 @@ public class CmdWild extends FCommand implements WaitedTask { public static HashMap teleportRange; public static HashSet teleporting; public static CmdWild instance; - public static final String tpWorld = FactionsPlugin.getInstance().getConfig().getString("Wild.World", "World"); public CmdWild() { super(); @@ -55,11 +55,12 @@ public class CmdWild extends FCommand implements WaitedTask { int tries = 0; ConfigurationSection c = FactionsPlugin.getInstance().getConfig().getConfigurationSection("Wild.Zones." + teleportRange.get(p)); while (tries < 5) { + assert c != null; int x = new Random().nextInt((c.getInt("Range.MaxX") - c.getInt("Range.MinX")) + 1) + c.getInt("Range.MinX"); int z = new Random().nextInt((c.getInt("Range.MaxZ") - c.getInt("Range.MinZ")) + 1) + c.getInt("Range.MinZ"); if (Board.getInstance().getFactionAt(new FLocation(p.getWorld().getName(), x, z)).isWilderness()) { success = true; - FLocation loc = new FLocation(tpWorld, x, z); + FLocation loc = new FLocation(Objects.requireNonNull(c.getString("World", "World")), x, z); teleportRange.remove(p); if (!FPlayers.getInstance().getByPlayer(p).takeMoney(c.getInt("Cost"))) { p.sendMessage(TL.GENERIC_NOTENOUGHMONEY.toString()); @@ -91,7 +92,7 @@ public class CmdWild extends FCommand implements WaitedTask { public void applyEffects(Player p) { for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Arrival.Effects")) { - p.addPotionEffect(new PotionEffect(PotionEffectType.getByName(s), 40, 1)); + p.addPotionEffect(new PotionEffect(Objects.requireNonNull(PotionEffectType.getByName(s)), 40, 1)); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index d468e480..5a889bca 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1438,8 +1438,6 @@ Wild: Enabled: true # Time to wait in seconds # Wait: 5 - # World players will be teleported to # - World: 'World' # General GUI Settings # GUI: Name: 'Teleporter' @@ -1450,6 +1448,7 @@ Wild: Zones: # You may create your own zones here please just follow the original format # Close: + World: World Range: MinX: -200 MaxX: 200 @@ -1464,6 +1463,7 @@ Wild: Name: '&cLow Range' Slot: 1 Medium: + World: World Range: MinX: -400 MaxX: 400 @@ -1478,6 +1478,7 @@ Wild: Name: '&cMedium Range' Slot: 4 Far: + World: World Range: MinX: -800 MaxX: 800