Deny arena joins if unable to teleport

This commit is contained in:
RobotoRaccoon 2020-04-23 19:17:41 +10:00
parent 8028d7a340
commit 8daedf2230
6 changed files with 13 additions and 3 deletions

View File

@ -96,6 +96,13 @@ public class ArenaHandler {
return;
}
}
boolean canWarp = PlayerHandler.teleport(player, arena.lobbyWarp);
if (!canWarp) {
MessageManager.sendFMessage(player, ConfigC.error_teleportFailed);
return;
}
System.out.println("[BlockHunt] " + player.getName() + " has joined " + arenaname);
arena.playersInArena.add(player);
JoinArenaEvent event = new JoinArenaEvent(player, arena);
@ -107,7 +114,6 @@ public class ArenaHandler {
MemoryStorage.pData.put(player, pad);
PlayerHandler.teleport(player, arena.lobbyWarp);
player.setGameMode(GameMode.SURVIVAL);
for (PotionEffect pe : player.getActivePotionEffects()) {
player.removePotionEffect(pe.getType());

View File

@ -104,6 +104,7 @@ public enum ConfigC {
"%TAG%EYou need more tokens before you can buy this item.", MemoryStorage.messages), error_shopMaxSeekersReached(
"%TAG%ESorry, the maximum amount of seekers has been reached!", MemoryStorage.messages), error_shopMaxHidersReached(
"%TAG%ESorry, the maximum amount of hiders has been reached!", MemoryStorage.messages),
error_teleportFailed("%TAG%EUnable to teleport you into the arena.", MemoryStorage.messages),
error_teleportBlocked("%TAG%EYou cannot teleport while playing!", MemoryStorage.messages);
public Object value;

View File

@ -4,8 +4,8 @@ import org.bukkit.Location;
import org.bukkit.entity.Player;
public class PlayerHandler {
public static void teleport(Player player, Location location) {
public static boolean teleport(Player player, Location location) {
MemoryStorage.teleportLoc.put(player, location);
player.teleport(location);
return player.teleport(location);
}
}

View File

@ -88,4 +88,5 @@ error-tokensUnknownsetting: '%TAG%E''%A%option%%E'' is not a known option!'
error-shopNeedMoreTokens: '%TAG%EYou need more tokens before you can buy this item.'
error-shopMaxSeekersReached: '%TAG%ESorry, the maximum amount of seekers has been reached!'
error-shopMaxHidersReached: '%TAG%ESorry, the maximum amount of hiders has been reached!'
error-teleportFailed: '%TAG%EUnable to teleport you into the arena.'
error-teleportBlocked: '%TAG%EYou cannot teleport while playing!'

View File

@ -88,4 +88,5 @@ error-tokensUnknownsetting: '%TAG%E''%A%option%%E'' is not a known option!'
error-shopNeedMoreTokens: '%TAG%EYou need more tokens before you can buy this item.'
error-shopMaxSeekersReached: '%TAG%ESorry, the maximum amount of seekers has been reached!'
error-shopMaxHidersReached: '%TAG%ESorry, the maximum amount of hiders has been reached!'
error-teleportFailed: '%TAG%EUnable to teleport you into the arena.'
error-teleportBlocked: '%TAG%EYou cannot teleport while playing!'

View File

@ -97,4 +97,5 @@ error:
shopNeedMoreTokens: '%TAG%EYou need more tokens before you can buy this item.'
shopMaxSeekersReached: '%TAG%ESorry, the maximum amount of seekers has been reached!'
shopMaxHidersReached: '%TAG%ESorry, the maximum amount of hiders has been reached!'
teleportFailed: '%TAG%EUnable to teleport you into the arena.'
teleportBlocked: '%TAG%EYou cannot teleport while playing!'