Redo MinecraftVersion atOrAbove checking

This commit is contained in:
AlexTheCoder 2018-07-21 14:08:29 -04:00
parent 369b0e2c0a
commit 2d14acaa16
9 changed files with 21 additions and 20 deletions

View File

@ -7,6 +7,7 @@ import com.google.common.base.Preconditions;
*/
public enum MinecraftVersion
{
Version1_13("1.13", 393),
Version1_9("1.9", 48),
Version1_8("1.8", Integer.MIN_VALUE), //Any player will at minimum be 1.8, we can't handle anything below that
;

View File

@ -70,7 +70,7 @@ public class UtilTextTop
runnable.runTaskLater(UtilServer.getPlugin(), 20);
if (MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(player)))
if (UtilPlayer.getVersion(player).atOrAbove(MinecraftVersion.Version1_9))
{
sendBossBar(player, healthPercent, text);
@ -129,7 +129,7 @@ public class UtilTextTop
private static void deleteOld(Player player)
{
if (MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(player)))
if (UtilPlayer.getVersion(player).atOrAbove(MinecraftVersion.Version1_9))
{
PacketPlayOutBossBar bossBar = new PacketPlayOutBossBar();
@ -157,7 +157,7 @@ public class UtilTextTop
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
if (MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(event.getPlayer())))
if (UtilPlayer.getVersion(event.getPlayer()).atOrAbove(MinecraftVersion.Version1_9))
{
deleteOld(event.getPlayer());
}

View File

@ -477,7 +477,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
UtilPlayer.sendPacket(owner, spawnPacket);
if (MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(owner)))
if (UtilPlayer.getVersion(owner).atOrAbove(MinecraftVersion.Version1_9))
{
UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityId, new int[]
{
@ -507,7 +507,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
UtilPlayer.sendPacket(owner, spawnPacket);
if (MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(owner)))
if (UtilPlayer.getVersion(owner).atOrAbove(MinecraftVersion.Version1_9))
{
UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityIds[1], new int[]
{

View File

@ -1035,7 +1035,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (client.getHologram() == null)
{
double yAdd = 2.3;
if (!MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(player)))
if (!UtilPlayer.getVersion(player).atOrAbove(MinecraftVersion.Version1_9))
{
yAdd = 2.45;
}

View File

@ -112,7 +112,7 @@ public class OutfitReindeerAntlers extends OutfitReindeer implements IPacketHand
{
Player player = packetInfo.getPlayer();
if (MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(player)))
if (UtilPlayer.getVersion(player).atOrAbove(MinecraftVersion.Version1_9))
{
return;
}

View File

@ -359,7 +359,7 @@ public class MineplexGameManager extends MiniClientPlugin<Map<GameKit, PlayerKit
public void handle(PacketInfo packetInfo)
{
// Only need to handle this for 1.9+
if (!MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(packetInfo.getPlayer())))
if (!UtilPlayer.getVersion(packetInfo.getPlayer()).atOrAbove(MinecraftVersion.Version1_9))
{
return;
}

View File

@ -519,7 +519,7 @@ public class Hologram {
_playersTracking.add(player);
itel.remove();
UtilPlayer.sendPacket(player, (MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(player))) ? _packets1_9 : _packets1_8);
UtilPlayer.sendPacket(player, (UtilPlayer.getVersion(player).atOrAbove(MinecraftVersion.Version1_9)) ? _packets1_9 : _packets1_8);
}
}
@ -583,7 +583,7 @@ public class Hologram {
for (Player player : canSee)
{
if (MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(player)))
if (UtilPlayer.getVersion(player).atOrAbove(MinecraftVersion.Version1_9))
{
for (Packet packet : packets1_9)
{
@ -732,7 +732,7 @@ public class Hologram {
for (Player player : _playersTracking)
{
List<Packet> packets = (MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(player))) ? packets1_9 : packets1_8;
List<Packet> packets = (UtilPlayer.getVersion(player).atOrAbove(MinecraftVersion.Version1_9)) ? packets1_9 : packets1_8;
for (Packet packet : packets)
{
@ -791,7 +791,7 @@ public class Hologram {
for (Player player : _playersTracking)
{
UtilPlayer.sendPacket(player, (MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(player))) ? _packets1_9 : _packets1_8);
UtilPlayer.sendPacket(player, (UtilPlayer.getVersion(player).atOrAbove(MinecraftVersion.Version1_9)) ? _packets1_9 : _packets1_8);
}
}
@ -806,7 +806,7 @@ public class Hologram {
{
checkSpawnPackets();
return (MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(player))) ? _packets1_9 : _packets1_8;
return (UtilPlayer.getVersion(player).atOrAbove(MinecraftVersion.Version1_9)) ? _packets1_9 : _packets1_8;
}
/**

View File

@ -267,7 +267,7 @@ public class HideSeek extends TeamGame
final Player player = packetInfo.getPlayer();
Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> UtilPlayer.sendPacket(player, blockForm.getBlockPackets(MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(player)))));
Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> UtilPlayer.sendPacket(player, blockForm.getBlockPackets(UtilPlayer.getVersion(player).atOrAbove(MinecraftVersion.Version1_9))));
break;
}
}

View File

@ -117,7 +117,7 @@ public class BlockForm extends Form
packet1.uuid = UUID.randomUUID();
packets[0] = packet1;
if (MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(Player)))
if (UtilPlayer.getVersion(Player).atOrAbove(MinecraftVersion.Version1_9))
{
packets[2] = new PacketPlayOutNewAttachEntity(_fakeSilverfishId, new int[]
{
@ -292,7 +292,7 @@ public class BlockForm extends Form
_sawDiff = new Vector();
}
UtilPlayer.sendPacket(Player, packet[(MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(Player))) ? 1 : 0]);
UtilPlayer.sendPacket(Player, packet[(UtilPlayer.getVersion(Player).atOrAbove(MinecraftVersion.Version1_9)) ? 1 : 0]);
}
for (Player player : UtilServer.getPlayers())
@ -335,7 +335,7 @@ public class BlockForm extends Form
{
for (EntityPlayer entity : tracker.trackedPlayers)
{
UtilPlayer.sendPacket(entity.getBukkitEntity(), getBlockPackets(MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(entity.getBukkitEntity()))));
UtilPlayer.sendPacket(entity.getBukkitEntity(), getBlockPackets(UtilPlayer.getVersion(entity.getBukkitEntity()).atOrAbove(MinecraftVersion.Version1_9)));
}
}
}
@ -385,7 +385,7 @@ public class BlockForm extends Form
if (packet != null)
{
if (!MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(Player)) && packet[0] instanceof PacketPlayOutRelEntityMove)
if (!UtilPlayer.getVersion(Player).atOrAbove(MinecraftVersion.Version1_9) && packet[0] instanceof PacketPlayOutRelEntityMove)
{
PacketPlayOutRelEntityMove relPacket = (PacketPlayOutRelEntityMove) packet[0];
_sawDiff.subtract(new Vector(relPacket.b / 32D, relPacket.c / 32D, relPacket.d / 32D));
@ -395,7 +395,7 @@ public class BlockForm extends Form
_sawDiff = new Vector();
}
UtilPlayer.sendPacket(Player, packet[(MinecraftVersion.Version1_9.atOrAbove(UtilPlayer.getVersion(Player))) ? 1 : 0]);
UtilPlayer.sendPacket(Player, packet[(UtilPlayer.getVersion(Player).atOrAbove(MinecraftVersion.Version1_9)) ? 1 : 0]);
}
}
}