Multiversion support (but not used)
This commit is contained in:
parent
54f59c6a4d
commit
8421aad59c
@ -2,8 +2,8 @@ package mineplex.core.titles;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -21,6 +21,8 @@ import net.minecraft.server.v1_8_R3.EntityPlayer;
|
|||||||
import net.minecraft.server.v1_8_R3.EntitySlime;
|
import net.minecraft.server.v1_8_R3.EntitySlime;
|
||||||
import net.minecraft.server.v1_8_R3.Items;
|
import net.minecraft.server.v1_8_R3.Items;
|
||||||
import net.minecraft.server.v1_8_R3.MathHelper;
|
import net.minecraft.server.v1_8_R3.MathHelper;
|
||||||
|
import net.minecraft.server.v1_8_R3.Packet;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutHeldItemSlot;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutHeldItemSlot;
|
||||||
@ -50,7 +52,6 @@ import mineplex.core.ReflectivelyCreateMiniPlugin;
|
|||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.book.BookBuilder;
|
import mineplex.core.book.BookBuilder;
|
||||||
import mineplex.core.common.DummyEntity;
|
import mineplex.core.common.DummyEntity;
|
||||||
import mineplex.core.common.MinecraftVersion;
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.LineFormat;
|
import mineplex.core.common.util.LineFormat;
|
||||||
@ -570,13 +571,13 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
|||||||
TrackTier nextTier = track.getRequirements().getNextTier(player);
|
TrackTier nextTier = track.getRequirements().getNextTier(player);
|
||||||
|
|
||||||
trackHover
|
trackHover
|
||||||
.append("Progress: ")
|
.append("Progress: ")
|
||||||
.color(ChatColor.YELLOW)
|
.color(ChatColor.YELLOW)
|
||||||
.append(String.valueOf(nextTier.get(player)), ComponentBuilder.FormatRetention.NONE)
|
.append(String.valueOf(nextTier.get(player)), ComponentBuilder.FormatRetention.NONE)
|
||||||
.color(ChatColor.WHITE)
|
.color(ChatColor.WHITE)
|
||||||
.append("/")
|
.append("/")
|
||||||
.append(String.valueOf(nextTier.getGoal()))
|
.append(String.valueOf(nextTier.getGoal()))
|
||||||
.append("\n\n");
|
.append("\n\n");
|
||||||
}
|
}
|
||||||
trackHover
|
trackHover
|
||||||
.append("Click to view this track", ComponentBuilder.FormatRetention.NONE)
|
.append("Click to view this track", ComponentBuilder.FormatRetention.NONE)
|
||||||
@ -613,29 +614,17 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
|||||||
if (_disabled)
|
if (_disabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_armorStandIds.getOrDefault(player.getEntityId(), Collections.emptyMap()).forEach((uuid, entityId) ->
|
Map<UUID, Integer> map = _armorStandIds.get(player.getEntityId());
|
||||||
|
|
||||||
|
if (map == null) return;
|
||||||
|
|
||||||
|
map.forEach((uuid, entityId) ->
|
||||||
{
|
{
|
||||||
DataWatcher armorStandWatcher = new DataWatcher(new DummyEntity(((CraftWorld) player.getWorld()).getHandle()));
|
Player other = Bukkit.getPlayer(uuid);
|
||||||
armorStandWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
if (other == null)
|
||||||
armorStandWatcher.a(1, (short) 300, net.minecraft.server.v1_8_R3.Entity.META_AIR, 0);
|
return;
|
||||||
if (track != null && track.getRequirements().getTier(player) != null)
|
|
||||||
{
|
|
||||||
TrackTier currentTier = track.getRequirements().getTier(player);
|
|
||||||
armorStandWatcher.a(2, currentTier.getDisplayName(), net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME, currentTier.getDisplayName());
|
|
||||||
armorStandWatcher.a(3, (byte) 1, net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME_VISIBLE, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
armorStandWatcher.a(2, "", net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME, "");
|
|
||||||
armorStandWatcher.a(3, (byte) 0, net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME_VISIBLE, false);
|
|
||||||
}
|
|
||||||
armorStandWatcher.a(10, (byte) 0x10, EntityArmorStand.META_ARMOR_OPTION, (byte) 0x10); // Small
|
|
||||||
|
|
||||||
PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata();
|
updateArmorStand(other, track, entityId);
|
||||||
entityMetadata.a = entityId;
|
|
||||||
entityMetadata.b = armorStandWatcher.c();
|
|
||||||
|
|
||||||
((CraftPlayer) Bukkit.getPlayer(uuid)).getHandle().playerConnection.networkManager.handle(entityMetadata);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,9 +640,7 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
|||||||
if (packetInfo.getPacket() instanceof PacketPlayOutNamedEntitySpawn)
|
if (packetInfo.getPacket() instanceof PacketPlayOutNamedEntitySpawn)
|
||||||
{
|
{
|
||||||
PacketPlayOutNamedEntitySpawn packet = (PacketPlayOutNamedEntitySpawn) packetInfo.getPacket();
|
PacketPlayOutNamedEntitySpawn packet = (PacketPlayOutNamedEntitySpawn) packetInfo.getPacket();
|
||||||
|
summonForEntity(packetInfo.getPlayer(), (Player) UtilEnt.getEntityById(packet.a));
|
||||||
Player player = (Player) UtilEnt.getEntityById(packet.a);
|
|
||||||
summonForEntity(packetInfo.getPlayer(), player);
|
|
||||||
}
|
}
|
||||||
else if (packetInfo.getPacket() instanceof PacketPlayOutEntityDestroy)
|
else if (packetInfo.getPacket() instanceof PacketPlayOutEntityDestroy)
|
||||||
{
|
{
|
||||||
@ -667,14 +654,26 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
|||||||
|
|
||||||
private void summonForEntity(Player receiver, Player player)
|
private void summonForEntity(Player receiver, Player player)
|
||||||
{
|
{
|
||||||
if (UtilPlayer.getVersion(receiver) == MinecraftVersion.Version1_8)
|
switch (UtilPlayer.getVersion(receiver))
|
||||||
{
|
{
|
||||||
// don't display to 1.8 players.
|
case Version1_9:
|
||||||
return;
|
summonForEntity19(receiver, player);
|
||||||
|
break;
|
||||||
|
case Version1_8:
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
|
case ALL:
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void summonForEntity19(Player receiver, Player player)
|
||||||
|
{
|
||||||
World world = ((CraftWorld) receiver.getWorld()).getHandle();
|
World world = ((CraftWorld) receiver.getWorld()).getHandle();
|
||||||
Track existingTitle = getActiveTrack(player);
|
|
||||||
|
DataWatcher armorStandWatcher = getArmorStandWatcher(player, getActiveTrack(player));
|
||||||
|
armorStandWatcher.a(10, (byte) 0x10, EntityArmorStand.META_ARMOR_OPTION, (byte) 0x10); // Small
|
||||||
|
|
||||||
DataWatcher squidWatcher = new DataWatcher(new DummyEntity(world));
|
DataWatcher squidWatcher = new DataWatcher(new DummyEntity(world));
|
||||||
squidWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
squidWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
||||||
@ -683,20 +682,6 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
|||||||
slimeWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
slimeWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
||||||
slimeWatcher.a(16, -1, EntitySlime.META_SIZE, -1);
|
slimeWatcher.a(16, -1, EntitySlime.META_SIZE, -1);
|
||||||
|
|
||||||
DataWatcher armorStandWatcher = new DataWatcher(new DummyEntity(world));
|
|
||||||
armorStandWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
|
||||||
armorStandWatcher.a(1, (short) 300, net.minecraft.server.v1_8_R3.Entity.META_AIR, 0);
|
|
||||||
if (existingTitle != null)
|
|
||||||
{
|
|
||||||
TrackTier currentTier = existingTitle.getRequirements().getTier(player);
|
|
||||||
if (currentTier != null)
|
|
||||||
{
|
|
||||||
armorStandWatcher.a(2, currentTier.getDisplayName(), net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME, currentTier.getDisplayName());
|
|
||||||
armorStandWatcher.a(3, (byte) 1, net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME_VISIBLE, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
armorStandWatcher.a(10, (byte) 0x10, EntityArmorStand.META_ARMOR_OPTION, (byte) 0x10); // Small
|
|
||||||
|
|
||||||
PacketPlayOutSpawnEntityLiving spawnSlime = new PacketPlayOutSpawnEntityLiving();
|
PacketPlayOutSpawnEntityLiving spawnSlime = new PacketPlayOutSpawnEntityLiving();
|
||||||
spawnSlime.a = UtilEnt.getNewEntityId();
|
spawnSlime.a = UtilEnt.getNewEntityId();
|
||||||
spawnSlime.b = EntityType.SLIME.getTypeId();
|
spawnSlime.b = EntityType.SLIME.getTypeId();
|
||||||
@ -760,6 +745,148 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unused, but I've put my heart and soul into it and so it's staying here
|
||||||
|
private void summonForEntity18(Player receiver, Player player)
|
||||||
|
{
|
||||||
|
World world = ((CraftWorld) receiver.getWorld()).getHandle();
|
||||||
|
|
||||||
|
DataWatcher armorStandWatcher = getArmorStandWatcher(player, getActiveTrack(player));
|
||||||
|
|
||||||
|
List<Integer> entityIds = new ArrayList<>();
|
||||||
|
|
||||||
|
entityIds.add(player.getEntityId());
|
||||||
|
|
||||||
|
List<Packet> packets = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < 11; i++)
|
||||||
|
{
|
||||||
|
DataWatcher slimeWatcher0 = new DataWatcher(new DummyEntity(world));
|
||||||
|
slimeWatcher0.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
||||||
|
slimeWatcher0.a(16, (byte) -1, EntitySlime.META_SIZE, -1);
|
||||||
|
|
||||||
|
DataWatcher silverfishWatcher0 = new DataWatcher(new DummyEntity(world));
|
||||||
|
silverfishWatcher0.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
||||||
|
|
||||||
|
PacketPlayOutSpawnEntityLiving spawnSlime = new PacketPlayOutSpawnEntityLiving();
|
||||||
|
spawnSlime.a = UtilEnt.getNewEntityId();
|
||||||
|
spawnSlime.b = EntityType.SLIME.getTypeId();
|
||||||
|
spawnSlime.c = MathHelper.floor(player.getLocation().getX() * 32.0D);
|
||||||
|
spawnSlime.d = -150;
|
||||||
|
spawnSlime.e = MathHelper.floor(player.getLocation().getZ() * 32.0D);
|
||||||
|
spawnSlime.i = 0;
|
||||||
|
spawnSlime.j = 0;
|
||||||
|
spawnSlime.k = 0;
|
||||||
|
spawnSlime.f = 0;
|
||||||
|
spawnSlime.g = 0;
|
||||||
|
spawnSlime.h = 0;
|
||||||
|
spawnSlime.uuid = UUID.randomUUID();
|
||||||
|
spawnSlime.l = slimeWatcher0;
|
||||||
|
|
||||||
|
PacketPlayOutSpawnEntityLiving spawnSilverfish = new PacketPlayOutSpawnEntityLiving();
|
||||||
|
spawnSilverfish.a = UtilEnt.getNewEntityId();
|
||||||
|
spawnSilverfish.b = EntityType.SILVERFISH.getTypeId();
|
||||||
|
spawnSilverfish.c = MathHelper.floor(player.getLocation().getX() * 32.0D);
|
||||||
|
spawnSilverfish.d = -150;
|
||||||
|
spawnSilverfish.e = MathHelper.floor(player.getLocation().getZ() * 32.0D);
|
||||||
|
spawnSilverfish.i = 0;
|
||||||
|
spawnSilverfish.j = 0;
|
||||||
|
spawnSilverfish.k = 0;
|
||||||
|
spawnSilverfish.f = 0;
|
||||||
|
spawnSilverfish.g = 0;
|
||||||
|
spawnSilverfish.h = 0;
|
||||||
|
spawnSilverfish.uuid = UUID.randomUUID();
|
||||||
|
spawnSilverfish.l = silverfishWatcher0;
|
||||||
|
|
||||||
|
entityIds.add(spawnSlime.a);
|
||||||
|
entityIds.add(spawnSilverfish.a);
|
||||||
|
|
||||||
|
packets.add(spawnSlime);
|
||||||
|
packets.add(spawnSilverfish);
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketPlayOutSpawnEntityLiving spawnArmorStand = new PacketPlayOutSpawnEntityLiving();
|
||||||
|
spawnArmorStand.a = UtilEnt.getNewEntityId();
|
||||||
|
spawnArmorStand.b = EntityType.ARMOR_STAND.getTypeId();
|
||||||
|
spawnArmorStand.c = MathHelper.floor(player.getLocation().getX() * 32.0D);
|
||||||
|
spawnArmorStand.d = -150;
|
||||||
|
spawnArmorStand.e = MathHelper.floor(player.getLocation().getZ() * 32.0D);
|
||||||
|
spawnArmorStand.i = 0;
|
||||||
|
spawnArmorStand.j = 0;
|
||||||
|
spawnArmorStand.k = 0;
|
||||||
|
spawnArmorStand.f = 0;
|
||||||
|
spawnArmorStand.g = 0;
|
||||||
|
spawnArmorStand.h = 0;
|
||||||
|
spawnArmorStand.uuid = UUID.randomUUID();
|
||||||
|
spawnArmorStand.l = armorStandWatcher;
|
||||||
|
packets.add(spawnArmorStand);
|
||||||
|
entityIds.add(spawnArmorStand.a);
|
||||||
|
|
||||||
|
for (int i = 0; i < entityIds.size() - 1; i++)
|
||||||
|
{
|
||||||
|
int a = entityIds.get(i);
|
||||||
|
int b = entityIds.get(i + 1);
|
||||||
|
|
||||||
|
PacketPlayOutAttachEntity attachSlimeToPlayer = new PacketPlayOutAttachEntity();
|
||||||
|
attachSlimeToPlayer.a = 0;
|
||||||
|
attachSlimeToPlayer.b = b;
|
||||||
|
attachSlimeToPlayer.c = a;
|
||||||
|
|
||||||
|
packets.add(attachSlimeToPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
entityIds.remove(player.getEntityId());
|
||||||
|
|
||||||
|
_armorStandIds.computeIfAbsent(player.getEntityId(), key -> new HashMap<>()).put(receiver.getUniqueId(), spawnArmorStand.a);
|
||||||
|
_allIds.computeIfAbsent(player.getEntityId(), key -> new HashMap<>()).put(receiver.getUniqueId(), entityIds);
|
||||||
|
|
||||||
|
runSync(() ->
|
||||||
|
{
|
||||||
|
for (Packet p : packets)
|
||||||
|
{
|
||||||
|
((CraftPlayer) receiver).getHandle().playerConnection.networkManager.handle(p);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateArmorStand(Player receiver, Track currentTrack, int entityId)
|
||||||
|
{
|
||||||
|
switch (UtilPlayer.getVersion(receiver))
|
||||||
|
{
|
||||||
|
case Version1_9:
|
||||||
|
updateArmorStand19(receiver, currentTrack, entityId);
|
||||||
|
break;
|
||||||
|
case Version1_8:
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
|
case ALL:
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateArmorStand19(Player player, Track track, int entityId)
|
||||||
|
{
|
||||||
|
DataWatcher armorStandWatcher = getArmorStandWatcher(player, track);
|
||||||
|
armorStandWatcher.a(10, (byte) 0x10, EntityArmorStand.META_ARMOR_OPTION, (byte) 0x10); // Small
|
||||||
|
|
||||||
|
PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata();
|
||||||
|
entityMetadata.a = entityId;
|
||||||
|
entityMetadata.b = armorStandWatcher.c();
|
||||||
|
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.networkManager.handle(entityMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateArmorStand18(Player player, Track track, int entityId)
|
||||||
|
{
|
||||||
|
DataWatcher armorStandWatcher = getArmorStandWatcher(player, track);
|
||||||
|
|
||||||
|
PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata();
|
||||||
|
entityMetadata.a = entityId;
|
||||||
|
entityMetadata.b = armorStandWatcher.c();
|
||||||
|
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.networkManager.handle(entityMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
private void destroyForEntity(Player receiver, int id)
|
private void destroyForEntity(Player receiver, int id)
|
||||||
{
|
{
|
||||||
Map<UUID, Integer> innerMap = _armorStandIds.get(id);
|
Map<UUID, Integer> innerMap = _armorStandIds.get(id);
|
||||||
@ -793,6 +920,29 @@ public class Titles extends MiniDbClientPlugin<TitleData> implements IPacketHand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DataWatcher getArmorStandWatcher(Player player, Track existingTitle)
|
||||||
|
{
|
||||||
|
World world = ((CraftWorld) player.getWorld()).getHandle();
|
||||||
|
|
||||||
|
DataWatcher armorStandWatcher = new DataWatcher(new DummyEntity(world));
|
||||||
|
armorStandWatcher.a(0, (byte) 0x20, net.minecraft.server.v1_8_R3.Entity.META_ENTITYDATA, (byte) 0x20);
|
||||||
|
armorStandWatcher.a(1, (short) 300, net.minecraft.server.v1_8_R3.Entity.META_AIR, 0);
|
||||||
|
|
||||||
|
if (existingTitle != null && existingTitle.getRequirements().getTier(player) != null)
|
||||||
|
{
|
||||||
|
TrackTier currentTier = existingTitle.getRequirements().getTier(player);
|
||||||
|
armorStandWatcher.a(2, currentTier.getDisplayName(), net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME, currentTier.getDisplayName());
|
||||||
|
armorStandWatcher.a(3, (byte) 1, net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME_VISIBLE, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
armorStandWatcher.a(2, "", net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME, "");
|
||||||
|
armorStandWatcher.a(3, (byte) 0, net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME_VISIBLE, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return armorStandWatcher;
|
||||||
|
}
|
||||||
|
|
||||||
public void forceEnable()
|
public void forceEnable()
|
||||||
{
|
{
|
||||||
if (_disabled)
|
if (_disabled)
|
||||||
|
Loading…
Reference in New Issue
Block a user