Code cleanup

This commit is contained in:
LemADEC 2017-11-09 23:34:10 +01:00
parent 56c1e8b014
commit e92839ab02
2 changed files with 9 additions and 5 deletions

View file

@ -501,14 +501,14 @@ public class Commons {
public static EntityPlayerMP[] getOnlinePlayerByNameOrSelector(ICommandSender sender, final String playerNameOrSelector) {
@SuppressWarnings("unchecked")
List<EntityPlayer> onlinePlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
final List<EntityPlayer> onlinePlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
for (EntityPlayer onlinePlayer : onlinePlayers) {
if (onlinePlayer.getCommandSenderName().equalsIgnoreCase(playerNameOrSelector) && onlinePlayer instanceof EntityPlayerMP) {
return new EntityPlayerMP[]{ (EntityPlayerMP)onlinePlayer };
}
}
EntityPlayerMP[] entityPlayerMPs_found = PlayerSelector.matchPlayers(sender, playerNameOrSelector);
final EntityPlayerMP[] entityPlayerMPs_found = PlayerSelector.matchPlayers(sender, playerNameOrSelector);
if (entityPlayerMPs_found != null && entityPlayerMPs_found.length > 0) {
return entityPlayerMPs_found.clone();
}
@ -516,6 +516,10 @@ public class Commons {
return null;
}
public static EntityPlayerMP getOnlinePlayerByName(final String playerName) {
return MinecraftServer.getServer().getConfigurationManager().func_152612_a(playerName);
}
public static int colorARGBtoInt(final int alpha, final int red, final int green, final int blue) {
return (clamp(0, 255, alpha) << 24)
+ (clamp(0, 255, red ) << 16)

View file

@ -508,7 +508,7 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy implements ISta
for (int i = 0; i < tileEntityShipController.players.size(); i++) {
final String playerName = tileEntityShipController.players.get(i);
final EntityPlayerMP entityPlayerMP = MinecraftServer.getServer().getConfigurationManager().func_152612_a(playerName);
final EntityPlayerMP entityPlayerMP = Commons.getOnlinePlayerByName(playerName);
if ( entityPlayerMP != null
&& isOutsideBB(aabb, MathHelper.floor_double(entityPlayerMP.posX), MathHelper.floor_double(entityPlayerMP.posY), MathHelper.floor_double(entityPlayerMP.posZ)) ) {
@ -522,7 +522,7 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy implements ISta
for (int i = 0; i < tileEntityShipController.players.size(); i++) {
final String playerName = tileEntityShipController.players.get(i);
final EntityPlayerMP entityPlayerMP = MinecraftServer.getServer().getConfigurationManager().func_152612_a(playerName);
final EntityPlayerMP entityPlayerMP = Commons.getOnlinePlayerByName(playerName);
if ( entityPlayerMP != null && playerName.equals(nickname)
&& isOutsideBB(aabb, MathHelper.floor_double(entityPlayerMP.posX), MathHelper.floor_double(entityPlayerMP.posY), MathHelper.floor_double(entityPlayerMP.posZ)) ) {
@ -923,7 +923,7 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy implements ISta
// Consume energy
if (energy_consume(shipMovementCosts.energyRequired, false)) {
WarpDrive.logger.info(this + " Moving ship to a place around gate '" + targetGate.name + "' (" + destX + "; " + destY + "; " + destZ + ")");
JumpSequencer jump = new JumpSequencer(this, EnumShipMovementType.GATE_ACTIVATING, targetName, 0, 0, 0, (byte) 0, destX, destY, destZ);
final JumpSequencer jump = new JumpSequencer(this, EnumShipMovementType.GATE_ACTIVATING, targetName, 0, 0, 0, (byte) 0, destX, destY, destZ);
jump.enable();
} else {
messageToAllPlayersOnShip("Insufficient energy level");