Fixed player name references

This commit is contained in:
LemADEC 2015-07-27 01:30:45 +02:00
parent 23d4c85856
commit 1902b02b91
4 changed files with 25 additions and 24 deletions

View file

@ -112,7 +112,8 @@ public class SpaceEventHandler {
// Damage entity if in vacuum without protection
if (entity instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) entity;
air = player_airTank.get(player.getDisplayName());
String playerName = player.getCommandSenderName();
air = player_airTank.get(playerName);
boolean hasHelmet = false;
ItemStack helmetStack = player.getCurrentArmor(3);
@ -125,44 +126,44 @@ public class SpaceEventHandler {
hasHelmet = true;
if (air == null) {// new player in space =>
// grace period
player_airTank.put(player.getDisplayName(), airTicks);
player_airTank.put(playerName, airTicks);
} else if (air <= 1) {
if (breathHelmet.removeAir(player)) {
player_airTank.put(player.getDisplayName(), airTicks);
player_airTank.put(playerName, airTicks);
} else {
player_airTank.put(player.getDisplayName(), AIR_DROWN_TICKS);
player_airTank.put(playerName, AIR_DROWN_TICKS);
player.attackEntityFrom(DamageSource.drown, 2.0F);
}
} else {
player_airTank.put(player.getDisplayName(), air - 1);
player_airTank.put(playerName, air - 1);
}
}
} else if (WarpDriveConfig.spaceHelmets.contains(helmetStack)) {
hasHelmet = true;
if (air == null) {// new player in space => grace
// period
player_airTank.put(player.getDisplayName(), AIR_TANK_TICKS);
player_airTank.put(playerName, AIR_TANK_TICKS);
} else if (air <= 1) {
if (consumeO2(player.inventory.mainInventory, player)) {
player_airTank.put(player.getDisplayName(), AIR_TANK_TICKS);
player_airTank.put(playerName, AIR_TANK_TICKS);
} else {
player_airTank.put(player.getDisplayName(), AIR_DROWN_TICKS);
player_airTank.put(playerName, AIR_DROWN_TICKS);
entity.attackEntityFrom(DamageSource.drown, 2.0F);
}
} else {
player_airTank.put(player.getDisplayName(), air - 1);
player_airTank.put(playerName, air - 1);
}
}
}
if (!hasHelmet) {
if (air == null) {// new player in space => grace period
player_airTank.put(player.getDisplayName(), AIR_TANK_TICKS);
player_airTank.put(playerName, AIR_TANK_TICKS);
} else if (air <= 1) {
player_airTank.put(player.getDisplayName(), AIR_DROWN_TICKS);
player_airTank.put(playerName, AIR_DROWN_TICKS);
entity.attackEntityFrom(DamageSource.drown, 2.0F);
} else {
player_airTank.put(player.getDisplayName(), air - 1);
player_airTank.put(playerName, air - 1);
}
}
@ -184,19 +185,19 @@ public class SpaceEventHandler {
private void updatePlayerCloakState(EntityLivingBase entity) {
try {
EntityPlayerMP player = (EntityPlayerMP) entity;
Integer cloakTicks = player_cloakTicks.get(player.getDisplayName());
Integer cloakTicks = player_cloakTicks.get(player.getCommandSenderName());
if (cloakTicks == null) {
player_cloakTicks.put(player.getDisplayName(), 0);
player_cloakTicks.put(player.getCommandSenderName(), 0);
return;
}
if (cloakTicks >= CLOAK_CHECK_TIMEOUT_TICKS) {
player_cloakTicks.put(player.getDisplayName(), 0);
player_cloakTicks.put(player.getCommandSenderName(), 0);
WarpDrive.cloaks.updatePlayer(player);
} else {
player_cloakTicks.put(player.getDisplayName(), cloakTicks + 1);
player_cloakTicks.put(player.getCommandSenderName(), cloakTicks + 1);
}
} catch (Exception e) {
e.printStackTrace();

View file

@ -30,7 +30,7 @@ public class InvisibleCommand extends CommandBase {
// get an online player by name
List<EntityPlayer> onlinePlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
for (EntityPlayer onlinePlayer : onlinePlayers) {
if (onlinePlayer.getDisplayName().equalsIgnoreCase(astring[0])) {
if (onlinePlayer.getCommandSenderName().equalsIgnoreCase(astring[0])) {
player = onlinePlayer;
}
}

View file

@ -43,7 +43,7 @@ public class SpaceTpCommand extends CommandBase {
// get an online player by name
List<EntityPlayer> onlinePlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
for (EntityPlayer onlinePlayer : onlinePlayers) {
if (onlinePlayer.getDisplayName().equalsIgnoreCase(astring[0]) && onlinePlayer instanceof EntityPlayerMP) {
if (onlinePlayer.getCommandSenderName().equalsIgnoreCase(astring[0]) && onlinePlayer instanceof EntityPlayerMP) {
player = (EntityPlayerMP) onlinePlayer;
}
}
@ -56,7 +56,7 @@ public class SpaceTpCommand extends CommandBase {
}
WorldServer targetWorld = server.worldServerForDimension(targetDim);
WarpDrive.logger.info("/space: teleporting player " + player.getDisplayName() + " to " + targetDim + ":" + targetWorld.getWorldInfo().getWorldName());
WarpDrive.logger.info("/space: teleporting player " + player.getCommandSenderName() + " to " + targetDim + ":" + targetWorld.getWorldInfo().getWorldName());
SpaceTeleporter teleporter = new SpaceTeleporter(targetWorld, 0, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ));
server.getConfigurationManager().transferPlayerToDimension(player, targetDim, teleporter);
}

View file

@ -72,7 +72,7 @@ public class CloakedArea {
List<Entity> list = worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, this.aabb);
for (Entity e : list) {
if (e instanceof EntityPlayer) {
addPlayer(((EntityPlayer) e).getDisplayName());
addPlayer(((EntityPlayer) e).getCommandSenderName());
}
}
} catch (Exception e) {
@ -114,19 +114,19 @@ public class CloakedArea {
public void updatePlayer(EntityPlayer player) {
if (isEntityWithinArea(player)) {
if (!isPlayerListedInArea(player.getDisplayName())) {
if (!isPlayerListedInArea(player.getCommandSenderName())) {
// WarpDrive.debugPrint("" + this + " Player " + player.username
// + " has entered");
addPlayer(player.getDisplayName());
addPlayer(player.getCommandSenderName());
revealChunksToPlayer(player);
revealEntityToPlayer(player);
PacketHandler.sendCloakPacket(player, aabb, tier, false);
}
} else {
if (isPlayerListedInArea(player.getDisplayName())) {
if (isPlayerListedInArea(player.getCommandSenderName())) {
// WarpDrive.debugPrint("" + this + " Player " + player.username
// + " has left");
removePlayer(player.getDisplayName());
removePlayer(player.getCommandSenderName());
MinecraftServer
.getServer()
.getConfigurationManager()