World now per range instead of global + CmdWild cleanup
This commit is contained in:
parent
ece5dd0bb7
commit
0ea56fe5d2
@ -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<Player, String> teleportRange;
|
||||
public static HashSet<Player> 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user