Work around setFlying() throwing exceptions

This commit is contained in:
JeromSar 2015-05-12 20:17:38 +02:00
parent 68f972c562
commit b18aeb2d38
6 changed files with 32 additions and 28 deletions

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Tue May 12 17:17:52 CEST 2015
build.number=1015
#Tue May 12 20:14:59 CEST 2015
build.number=1022

View File

@ -2,6 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Location;
import org.bukkit.command.Command;
@ -67,7 +68,7 @@ public class Command_expel extends TFM_Command
if (inRange)
{
player.getWorld().createExplosion(targetPos, 0.0f, false);
player.setFlying(false);
TFM_Util.setFlying(player, false);
player.setVelocity(targetPosVec.subtract(senderPos).normalize().multiply(strength));
pushedPlayers.add(player.getName());
}

View File

@ -325,7 +325,7 @@ public class TFM_PlayerListener implements Listener
{
if (targetPosVec.distanceSquared(playerLocVec) < (RADIUS_HIT * RADIUS_HIT))
{
target.setFlying(false);
TFM_Util.setFlying(player, false);
target.setVelocity(targetPosVec.subtract(playerLocVec).normalize().multiply(STRENGTH));
didHit = true;
}
@ -389,7 +389,7 @@ public class TFM_PlayerListener implements Listener
if (!TFM_AdminList.isSuperAdmin(player) && playerdata.isFrozen())
{
player.setFlying(true);
TFM_Util.setFlying(player, true);
event.setTo(playerdata.getFreezeLocation());
return; // Don't process adminworld validation
}
@ -456,7 +456,7 @@ public class TFM_PlayerListener implements Listener
// Freeze
if (!TFM_AdminList.isSuperAdmin(player) && playerdata.isFrozen())
{
player.setFlying(true);
TFM_Util.setFlying(player, true);
event.setTo(playerdata.getFreezeLocation());
}
@ -710,7 +710,7 @@ public class TFM_PlayerListener implements Listener
}
// Blocked commands
if (TFM_CommandBlocker.isCommandBlocked(command, event.getPlayer(), true))
if (TFM_CommandBlocker.isCommandBlocked(command, player, true))
{
// CommandBlocker handles messages and broadcasts
event.setCancelled(true);
@ -885,8 +885,6 @@ public class TFM_PlayerListener implements Listener
{
}
player.setAllowFlight(true);
new BukkitRunnable()
{
@Override

View File

@ -223,27 +223,27 @@ public class TFM_CommandBlocker
public static CommandBlockerRank fromSender(CommandSender sender)
{
if (!TFM_AdminList.isSuperAdmin(sender))
if (!(sender instanceof Player))
{
return TELNET;
}
if (TFM_AdminList.isSuperAdmin(sender))
{
if (TFM_AdminList.isSeniorAdmin(sender))
{
return SENIOR;
}
return SUPER;
}
if (sender.isOp())
{
return OP;
}
return ANYONE;
}
if (TFM_AdminList.isSeniorAdmin(sender))
{
return SENIOR;
}
if (!(sender instanceof Player))
{
return TELNET;
}
return SUPER;
}
public static CommandBlockerRank fromToken(String token)

View File

@ -218,7 +218,7 @@ public class TFM_PlayerData
if (player.getGameMode() != GameMode.CREATIVE)
{
player.setFlying(false);
TFM_Util.setFlying(player, false);
}
if (!freeze)
@ -227,7 +227,7 @@ public class TFM_PlayerData
}
freezeLocation = player.getLocation(); // Blockify location
player.setFlying(true); // Avoid infinite falling
TFM_Util.setFlying(player, true); // Avoid infinite falling
unfreezeTask = new BukkitRunnable()
{
@ -410,7 +410,7 @@ public class TFM_PlayerData
{
player.setOp(false);
player.setGameMode(GameMode.SURVIVAL);
player.setFlying(false);
TFM_Util.setFlying(player, false);
TFM_EssentialsBridge.setNickname(player.getName(), player.getName());
player.closeInventory();
player.setTotalExperience(0);

View File

@ -142,6 +142,11 @@ public class TFM_Util
TFM_Util.playerMsg(sender, message, ChatColor.GRAY);
}
public static void setFlying(Player player, boolean flying) {
player.setAllowFlight(true);
player.setFlying(flying);
}
public static void adminAction(String adminName, String action, boolean isRed)
{
TFM_Util.bcastMsg(adminName + " - " + action, (isRed ? ChatColor.RED : ChatColor.AQUA));