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.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,7 +30,6 @@ public class CmdWild extends FCommand implements WaitedTask {
|
|||||||
public static HashMap<Player, String> teleportRange;
|
public static HashMap<Player, String> teleportRange;
|
||||||
public static HashSet<Player> teleporting;
|
public static HashSet<Player> teleporting;
|
||||||
public static CmdWild instance;
|
public static CmdWild instance;
|
||||||
public static final String tpWorld = FactionsPlugin.getInstance().getConfig().getString("Wild.World", "World");
|
|
||||||
|
|
||||||
public CmdWild() {
|
public CmdWild() {
|
||||||
super();
|
super();
|
||||||
@ -55,11 +55,12 @@ public class CmdWild extends FCommand implements WaitedTask {
|
|||||||
int tries = 0;
|
int tries = 0;
|
||||||
ConfigurationSection c = FactionsPlugin.getInstance().getConfig().getConfigurationSection("Wild.Zones." + teleportRange.get(p));
|
ConfigurationSection c = FactionsPlugin.getInstance().getConfig().getConfigurationSection("Wild.Zones." + teleportRange.get(p));
|
||||||
while (tries < 5) {
|
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 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");
|
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()) {
|
if (Board.getInstance().getFactionAt(new FLocation(p.getWorld().getName(), x, z)).isWilderness()) {
|
||||||
success = true;
|
success = true;
|
||||||
FLocation loc = new FLocation(tpWorld, x, z);
|
FLocation loc = new FLocation(Objects.requireNonNull(c.getString("World", "World")), x, z);
|
||||||
teleportRange.remove(p);
|
teleportRange.remove(p);
|
||||||
if (!FPlayers.getInstance().getByPlayer(p).takeMoney(c.getInt("Cost"))) {
|
if (!FPlayers.getInstance().getByPlayer(p).takeMoney(c.getInt("Cost"))) {
|
||||||
p.sendMessage(TL.GENERIC_NOTENOUGHMONEY.toString());
|
p.sendMessage(TL.GENERIC_NOTENOUGHMONEY.toString());
|
||||||
@ -91,7 +92,7 @@ public class CmdWild extends FCommand implements WaitedTask {
|
|||||||
|
|
||||||
public void applyEffects(Player p) {
|
public void applyEffects(Player p) {
|
||||||
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Arrival.Effects")) {
|
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
|
Enabled: true
|
||||||
# Time to wait in seconds #
|
# Time to wait in seconds #
|
||||||
Wait: 5
|
Wait: 5
|
||||||
# World players will be teleported to #
|
|
||||||
World: 'World'
|
|
||||||
# General GUI Settings #
|
# General GUI Settings #
|
||||||
GUI:
|
GUI:
|
||||||
Name: 'Teleporter'
|
Name: 'Teleporter'
|
||||||
@ -1450,6 +1448,7 @@ Wild:
|
|||||||
Zones:
|
Zones:
|
||||||
# You may create your own zones here please just follow the original format #
|
# You may create your own zones here please just follow the original format #
|
||||||
Close:
|
Close:
|
||||||
|
World: World
|
||||||
Range:
|
Range:
|
||||||
MinX: -200
|
MinX: -200
|
||||||
MaxX: 200
|
MaxX: 200
|
||||||
@ -1464,6 +1463,7 @@ Wild:
|
|||||||
Name: '&cLow Range'
|
Name: '&cLow Range'
|
||||||
Slot: 1
|
Slot: 1
|
||||||
Medium:
|
Medium:
|
||||||
|
World: World
|
||||||
Range:
|
Range:
|
||||||
MinX: -400
|
MinX: -400
|
||||||
MaxX: 400
|
MaxX: 400
|
||||||
@ -1478,6 +1478,7 @@ Wild:
|
|||||||
Name: '&cMedium Range'
|
Name: '&cMedium Range'
|
||||||
Slot: 4
|
Slot: 4
|
||||||
Far:
|
Far:
|
||||||
|
World: World
|
||||||
Range:
|
Range:
|
||||||
MinX: -800
|
MinX: -800
|
||||||
MaxX: 800
|
MaxX: 800
|
||||||
|
Loading…
Reference in New Issue
Block a user