diff --git a/src/main/java/dansplugins/factionsystem/commands/HomeCommand.java b/src/main/java/dansplugins/factionsystem/commands/HomeCommand.java index 0d30ca634..c80fb0864 100644 --- a/src/main/java/dansplugins/factionsystem/commands/HomeCommand.java +++ b/src/main/java/dansplugins/factionsystem/commands/HomeCommand.java @@ -51,7 +51,6 @@ public void execute(Player player, String[] args, String key) { player.sendMessage(translate("&c" + getText("HomeClaimedByAnotherFaction"))); return; } - player.sendMessage(translate("&a" + getText("TeleportingAlert"))); Scheduler.getInstance().scheduleTeleport(player, faction.getFactionHome()); } diff --git a/src/main/java/dansplugins/factionsystem/services/LocalConfigService.java b/src/main/java/dansplugins/factionsystem/services/LocalConfigService.java index 43d57ac27..d5c132cd0 100644 --- a/src/main/java/dansplugins/factionsystem/services/LocalConfigService.java +++ b/src/main/java/dansplugins/factionsystem/services/LocalConfigService.java @@ -211,7 +211,8 @@ public void setConfigOption(String option, String value, CommandSender sender) { || option.equalsIgnoreCase("factionMaxNameLength") || option.equalsIgnoreCase("factionMaxNumberGates") || option.equalsIgnoreCase("factionMaxGateArea") - || option.equalsIgnoreCase("maxClaimRadius")) { + || option.equalsIgnoreCase("maxClaimRadius") + || option.equalsIgnoreCase("teleportDelay")) { getConfig().set(option, Integer.parseInt(value)); sender.sendMessage(ChatColor.GREEN + Locale.get("IntegerSet")); } else if (option.equalsIgnoreCase("mobsSpawnInFactionTerritory") @@ -235,8 +236,7 @@ public void setConfigOption(String option, String value, CommandSender sender) { || option.equalsIgnoreCase("limitLand") || option.equalsIgnoreCase("factionsCanSetPrefixColors") || option.equalsIgnoreCase("playersLosePowerOnDeath") - || option.equalsIgnoreCase("bonusPowerEnabled") - || option.equalsIgnoreCase("teleportDelay")) { + || option.equalsIgnoreCase("bonusPowerEnabled")) { getConfig().set(option, Boolean.parseBoolean(value)); sender.sendMessage(ChatColor.GREEN + Locale.get("BooleanSet")); } else if (option.equalsIgnoreCase("factionOwnerMultiplier") diff --git a/src/main/java/dansplugins/factionsystem/utils/extended/Scheduler.java b/src/main/java/dansplugins/factionsystem/utils/extended/Scheduler.java index 8ca9dd255..4ab3f91c4 100644 --- a/src/main/java/dansplugins/factionsystem/utils/extended/Scheduler.java +++ b/src/main/java/dansplugins/factionsystem/utils/extended/Scheduler.java @@ -4,6 +4,7 @@ */ package dansplugins.factionsystem.utils.extended; +import java.util.Random; import java.util.concurrent.TimeUnit; import org.bukkit.Bukkit; @@ -100,8 +101,15 @@ private boolean isFactionExceedingTheirDemesneLimit(Faction faction) { public void scheduleTeleport(Player player, Location destinationLocation) { final int teleport_delay = LocalConfigService.getInstance().getInt("teleportDelay"); + player.sendMessage(ChatColor.AQUA + "Teleporting in " + teleport_delay + " seconds..."); DelayedTeleportTask delayedTeleportTask = new DelayedTeleportTask(teleport_delay, player, destinationLocation); - delayedTeleportTask.runTaskLater(MedievalFactions.getInstance(), teleport_delay * 20); + delayedTeleportTask.runTaskLater(MedievalFactions.getInstance(), (long) (teleport_delay * getRandomNumberBetween(15, 25))); + } + + private int getRandomNumberBetween(int num1, int num2) { + Random random = new Random(); + int span = num2 - num1; + return random.nextInt(span) + num1; } private class DelayedTeleportTask extends BukkitRunnable {