Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
bd2e7faf3e
@ -6,6 +6,7 @@ import java.util.List;
|
||||
|
||||
import mineplex.core.common.DummyEntity;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.event.CustomTagEvent;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
@ -334,8 +335,12 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
||||
}
|
||||
}
|
||||
|
||||
private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, final String entityName, final PacketVerifier packetList)
|
||||
private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, String entityName, final PacketVerifier packetList)
|
||||
{
|
||||
CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
|
||||
_plugin.getServer().getPluginManager().callEvent(event);
|
||||
final String finalEntityName = event.getCustomName();
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
@ -412,7 +417,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
||||
|
||||
watcher.watch(10, Byte.valueOf(b1));
|
||||
|
||||
watcher.watch(2, entityName);
|
||||
watcher.watch(2, finalEntityName);
|
||||
watcher.watch(3, Byte.valueOf((byte)1));
|
||||
|
||||
packet.l = watcher;
|
||||
|
@ -0,0 +1,55 @@
|
||||
package mineplex.core.event;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 10/24/2014.
|
||||
*/
|
||||
public class CustomTagEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private int _entityId;
|
||||
private String _customName;
|
||||
|
||||
public CustomTagEvent(Player player, int entityId, String customName)
|
||||
{
|
||||
_player = player;
|
||||
_entityId = entityId;
|
||||
_customName = customName;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public String getCustomName()
|
||||
{
|
||||
return _customName;
|
||||
}
|
||||
|
||||
public void setCustomName(String customName)
|
||||
{
|
||||
_customName = customName;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public int getEntityId()
|
||||
{
|
||||
return _entityId;
|
||||
}
|
||||
}
|
@ -999,41 +999,4 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
if (!_gadgetsEnabled)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void debug(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (event.getMessage().contains("sheep"))
|
||||
{
|
||||
player.setPassenger(player.getWorld().spawn(player.getLocation(), Sheep.class));
|
||||
}
|
||||
if (event.getMessage().contains("drop"))
|
||||
{
|
||||
player.eject();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void damage(EntityDamageByEntityEvent event)
|
||||
{
|
||||
Entity ent = UtilEvent.GetDamagerEntity(event, false);
|
||||
if (ent != null && ent instanceof Player)
|
||||
System.out.println("DAMAGE");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void interactent(PlayerInteractEntityEvent event)
|
||||
{
|
||||
System.out.println("ENT INTERACT");
|
||||
|
||||
System.out.println(event.getPlayer().getTargetBlock(null, 0));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void interact(PlayerInteractEvent event)
|
||||
{
|
||||
System.out.println("INTERACT");
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilBlockText;
|
||||
import mineplex.core.common.util.UtilBlockText.TextAlign;
|
||||
@ -53,6 +54,7 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
|
||||
import mineplex.core.donation.Donor;
|
||||
import mineplex.core.event.CustomTagEvent;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.packethandler.PacketVerifier;
|
||||
@ -70,7 +72,9 @@ import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.KitAvailability;
|
||||
import nautilus.game.arcade.kit.KitSorter;
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
||||
import net.minecraft.server.v1_7_R4.WatchableObject;
|
||||
|
||||
public class GameLobbyManager implements Listener, IPacketHandler
|
||||
{
|
||||
@ -1079,21 +1083,47 @@ public class GameLobbyManager implements Listener, IPacketHandler
|
||||
return entityName;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void customEntityName(CustomTagEvent event)
|
||||
{
|
||||
// TODO: This needs to be changed when removing CustomTagFix
|
||||
|
||||
if (Manager.GetGame() != null)
|
||||
{
|
||||
String customName = null;
|
||||
|
||||
for (LobbyEnt ent : _kits.values())
|
||||
{
|
||||
if (ent.GetEnt().getEntityId() == event.getEntityId())
|
||||
{
|
||||
customName = GetKitCustomName(event.getPlayer(), Manager.GetGame(), ent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (customName != null)
|
||||
{
|
||||
event.setCustomName(customName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void handle(PacketInfo packetInfo)
|
||||
{
|
||||
if (_handlingPacket)
|
||||
// This only applies to 1.7 clients currently, 1.8 custom names are handled by customEntityName(CustomTagEvent event)
|
||||
if (_handlingPacket || UtilPlayer.is1_8(packetInfo.getPlayer()))
|
||||
return;
|
||||
|
||||
Packet packet = packetInfo.getPacket();
|
||||
Player owner = packetInfo.getPlayer();
|
||||
PacketVerifier packetVerifier = packetInfo.getVerifier();
|
||||
|
||||
|
||||
int entityId = -1;
|
||||
|
||||
if (packet instanceof PacketPlayOutSpawnEntityLiving)
|
||||
if (packet instanceof PacketPlayOutEntityMetadata)
|
||||
{
|
||||
entityId = ((PacketPlayOutSpawnEntityLiving)packet).a;
|
||||
entityId = ((PacketPlayOutEntityMetadata)packet).a;
|
||||
}
|
||||
|
||||
if (entityId != -1)
|
||||
@ -1114,16 +1144,37 @@ public class GameLobbyManager implements Listener, IPacketHandler
|
||||
{
|
||||
try
|
||||
{
|
||||
if (packet instanceof PacketPlayOutSpawnEntityLiving)
|
||||
if (packet instanceof PacketPlayOutEntityMetadata)
|
||||
{
|
||||
((PacketPlayOutSpawnEntityLiving)packet).l.watch(2, customName);
|
||||
((PacketPlayOutSpawnEntityLiving)packet).l.watch(10, customName);
|
||||
List<WatchableObject> watchables = new ArrayList<WatchableObject>();
|
||||
|
||||
for (WatchableObject watchableObject : (List<WatchableObject>)((PacketPlayOutEntityMetadata) packet).b)
|
||||
{
|
||||
WatchableObject newWatch = new WatchableObject(watchableObject.c(), watchableObject.a(), watchableObject.b());
|
||||
|
||||
if (newWatch.a() == 10)
|
||||
{
|
||||
newWatch.a(customName);
|
||||
}
|
||||
|
||||
watchables.add(newWatch);
|
||||
}
|
||||
|
||||
PacketPlayOutEntityMetadata newPacket = new PacketPlayOutEntityMetadata();
|
||||
newPacket.a = entityId;
|
||||
newPacket.b = watchables;
|
||||
|
||||
_handlingPacket = true;
|
||||
packetVerifier.process(newPacket);
|
||||
_handlingPacket = false;
|
||||
|
||||
packetInfo.setCancelled(true);
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user