This commit is contained in:
Sam 2017-10-21 20:32:59 +01:00 committed by Alexander Meech
parent eb936662f1
commit 807d977434
3 changed files with 42 additions and 13 deletions

View File

@ -45,17 +45,6 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.DummyEntity;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.event.CustomTagEvent;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class CustomTagFix extends MiniPlugin implements IPacketHandler
{
private Map<UUID, Map<Integer, Integer[]>> _entityMap = new HashMap<>();

View File

@ -174,7 +174,8 @@ public abstract class Kit implements Listener
}
entity.setRemoveWhenFarAway(false);
entity.setCustomName(GetAvailability().GetColor() + GetName() + " Kit");
// Intercepted in LobbyManager
entity.setCustomName("");
entity.setCustomNameVisible(true);
entity.getEquipment().setItemInHand(_itemInHand);

View File

@ -3,6 +3,9 @@ package nautilus.game.arcade.managers.lobby;
import java.io.File;
import java.util.Map;
import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
@ -37,11 +40,14 @@ import mineplex.core.common.util.UtilBlockText;
import mineplex.core.common.util.UtilBlockText.TextAlign;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilLambda;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.donation.Donor;
import mineplex.core.event.CustomTagEvent;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.scoreboard.MineplexScoreboard;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -59,7 +65,7 @@ import nautilus.game.arcade.managers.LobbyEnt;
/**
*
*/
public abstract class LobbyManager implements Listener
public abstract class LobbyManager implements Listener, IPacketHandler
{
protected static final World WORLD = Bukkit.getWorld("world");
@ -126,6 +132,8 @@ public abstract class LobbyManager implements Listener
manager.getPluginManager().registerEvents(this, manager.getPlugin());
System.out.println("Using " + getClass().getSimpleName() + " as the lobby manager");
manager.getPacketHandler().addPacketHandler(this, PacketPlayOutEntityMetadata.class);
}
public abstract void createTeams(Game game);
@ -559,6 +567,37 @@ public abstract class LobbyManager implements Listener
return entityName;
}
@Override
public void handle(PacketInfo packetInfo)
{
// Only need to handle this for 1.9+
if (!UtilPlayer.is1_9(packetInfo.getPlayer()))
{
return;
}
PacketPlayOutEntityMetadata packet = (PacketPlayOutEntityMetadata) packetInfo.getPacket();
for (LobbyEnt ent : _kits.values())
{
if (ent.GetEnt().getEntityId() == packet.a)
{
String customName = GetKitCustomName(packetInfo.getPlayer(), _manager.GetGame(), ent);
System.out.println(packetInfo.getPlayer().getName() + " -> " + customName);
for (WatchableObject watchableObject : packet.b)
{
if (watchableObject.getIndex().equals(net.minecraft.server.v1_8_R3.Entity.META_CUSTOMNAME))
{
watchableObject.a(customName, customName);
}
}
return;
}
}
}
@EventHandler
public void customEntityName(CustomTagEvent event)
{