Fixed for DisguiseManager

Rewrote packet handling
Fixed up CustomTagFix
Removed swapping kits in Block Hunt
Removed Stacked entities for 1.8 players.
This commit is contained in:
Jonathan Williams 2014-09-05 04:36:01 -07:00
parent b28fc8ee6b
commit 1c6790b611
30 changed files with 483 additions and 1234 deletions

View File

@ -49,7 +49,7 @@ public class UtilDisplay
mobPacket.j = (short) 0; //Y velocity
mobPacket.k = (short) 0; //Z velocity
DataWatcher watcher = getWatcher(text, healthPercent * 200, loc.getWorld());
DataWatcher watcher = getWatcher(text, 101 + healthPercent * 99, loc.getWorld());
mobPacket.l = watcher;
@ -132,11 +132,11 @@ public class UtilDisplay
hasHealthBar.put(player.getName(), true);
new BukkitRunnable(){
int health = (loadUp ? 0 : 200);
int health = (loadUp ? 100 : 200);
@Override
public void run(){
if((loadUp ? health < 200 : health > 0)){
if((loadUp ? health < 200 : health > 100)){
DataWatcher watcher = getWatcher(text, health, player.getWorld());
PacketPlayOutEntityMetadata metaPacket = getMetadataPacket(watcher);
@ -148,7 +148,7 @@ public class UtilDisplay
health -= healthAdd;
}
} else {
DataWatcher watcher = getWatcher(text, (loadUp ? 200 : 0), player.getWorld());
DataWatcher watcher = getWatcher(text, (loadUp ? 200 : 100), player.getWorld());
PacketPlayOutEntityMetadata metaPacket = getMetadataPacket(watcher);
PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();
@ -184,7 +184,7 @@ public class UtilDisplay
}
public static void displayLoadingBar(final String text, final String completeText, final Player player, final int secondsDelay, final boolean loadUp, JavaPlugin plugin){
final int healthChangePerSecond = 200 / secondsDelay;
final int healthChangePerSecond = 100 / secondsDelay;
displayLoadingBar(text, completeText, player, healthChangePerSecond, 20L, loadUp, plugin);
}

View File

@ -1,14 +1,12 @@
package mineplex.core;
import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.List;
import mineplex.core.common.DummyEntity;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.packethandler.IPacketRunnable;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PlayerPacketEvent;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.EnumEntitySize;
import net.minecraft.server.v1_7_R4.MathHelper;
@ -16,30 +14,29 @@ import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.WatchableObject;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.plugin.java.JavaPlugin;
public class CustomTagFix extends MiniPlugin implements IPacketRunnable
public class CustomTagFix extends MiniPlugin
{
private static int _fakeIdCounter = 455000;
private NautHashMap<Integer, Integer> _entityMap = new NautHashMap<Integer, Integer>();
private Field _destroyId;
public CustomTagFix(JavaPlugin plugin, PacketHandler packetHandler)
public CustomTagFix(JavaPlugin plugin)
{
super("Custom Tag Fix", plugin);
packetHandler.AddPacketRunnable(this);
try
{
@ -53,113 +50,51 @@ public class CustomTagFix extends MiniPlugin implements IPacketRunnable
}
}
@Override
public boolean run(Packet packet, final Player owner, final PacketVerifier packetList)
@SuppressWarnings("unchecked")
@EventHandler(priority = EventPriority.HIGHEST)
public void handlePackets(PlayerPacketEvent event)
{
Packet packet = event.getPacket();
Player owner = event.getPlayer();
PacketVerifier verifier = event.getVerifier();
if (((CraftPlayer)owner).getHandle().playerConnection.networkManager.getVersion() >= 47)
{
if (packet instanceof PacketPlayOutSpawnEntityLiving)
{
PacketPlayOutSpawnEntityLiving spawnPacket = (PacketPlayOutSpawnEntityLiving)packet;
final int entityId = spawnPacket.a;
final String entityName = spawnPacket.l.getString(10);
if (spawnPacket.l.getByte(11) == 1 || spawnPacket.l.getByte(3) == 1)
{
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
int newId = _fakeIdCounter++;
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier);
_entityMap.put(spawnPacket.a, newId);
}
}
else if (packet instanceof PacketPlayOutEntityMetadata)
{
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata)packet;
if (!_entityMap.containsKey(metaPacket.a) && metaPacket.a != 777777)
{
String entityName = "";
for (WatchableObject watchable : (List<WatchableObject>)metaPacket.b)
{
public void run()
if ((watchable.a() == 10 || watchable.a() == 2) && watchable.b() instanceof String)
{
final PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = _fakeIdCounter++;
packet.b = (byte) 30;
packet.c = (int)EnumEntitySize.SIZE_2.a(100);
packet.d = (int)MathHelper.floor(64 * 32.0D);
packet.e = (int)EnumEntitySize.SIZE_2.a(100);
packet.i = (byte) ((int) (0 * 256.0F / 360.0F));
packet.j = (byte) ((int) (0 * 256.0F / 360.0F));
packet.k = (byte) ((int) (0 * 256.0F / 360.0F));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
packet.f = (int)(var4 * 8000.0D);
packet.g = (int)(var6 * 8000.0D);
packet.h = (int)(var8 * 8000.0D);
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)owner.getWorld()).getHandle()));
watcher.a(0, Byte.valueOf((byte)0));
watcher.a(1, Short.valueOf((short)300));
watcher.a(2, "");
watcher.a(3, Byte.valueOf((byte) 0));
watcher.a(4, Byte.valueOf((byte)0));
watcher.a(7, Integer.valueOf(0));
watcher.a(8, Byte.valueOf((byte)0));
watcher.a(9, Byte.valueOf((byte)0));
watcher.a(6, Float.valueOf(1.0F));
watcher.a(10, Byte.valueOf((byte)0));
// Set invisible
int i1 = watcher.getInt(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
// Set small
byte b1 = watcher.getByte(10);
b1 = (byte)(b1 | 0x1);
watcher.watch(10, Byte.valueOf(b1));
watcher.watch(2, entityName);
watcher.watch(3, Byte.valueOf((byte)1));
packet.l = watcher;
packetList.forceProcess(packet);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = packet.a;
vehiclePacket.c = entityId;
packetList.forceProcess(vehiclePacket);
_entityMap.put(entityId, packet.a);
entityName = (String)watchable.b();
}
});
}
if (!entityName.isEmpty())
{
int newId = _fakeIdCounter++;
sendProtocolPackets(owner, metaPacket.a, newId, entityName, verifier);
_entityMap.put(metaPacket.a, newId);
}
}
}
else if (packet instanceof PacketPlayOutEntityDestroy)
@ -170,7 +105,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketRunnable
{
if (_entityMap.containsKey(id))
{
packetList.forceProcess(new PacketPlayOutEntityDestroy(_entityMap.get(id)));
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(id)));
_entityMap.remove(id);
}
}
}
@ -179,8 +115,197 @@ public class CustomTagFix extends MiniPlugin implements IPacketRunnable
exception.printStackTrace();
}
}
}
else if (packet instanceof PacketPlayOutAttachEntity)
{
PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity)packet;
return true;
if (attachPacket.c == owner.getEntityId())
{
event.setCancelled(true);
//verifier.bypassProcess(new PacketPlayOutEntityDestroy(attachPacket.b));
/*
System.out.println("Adding patch item.");
PacketPlayOutSpawnEntityLiving armorPacket = new PacketPlayOutSpawnEntityLiving();
armorPacket.a = _fakeIdCounter++;
armorPacket.b = (byte) EntityType.SLIME.getTypeId();
armorPacket.c = (int)EnumEntitySize.SIZE_2.a(100);
armorPacket.d = (int)MathHelper.floor(64 * 32.0D);
armorPacket.e = (int)EnumEntitySize.SIZE_2.a(100);
armorPacket.i = (byte) ((int) (0 * 256.0F / 360.0F));
armorPacket.j = (byte) ((int) (0 * 256.0F / 360.0F));
armorPacket.k = (byte) ((int) (0 * 256.0F / 360.0F));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
armorPacket.f = (int)(var4 * 8000.0D);
armorPacket.g = (int)(var6 * 8000.0D);
armorPacket.h = (int)(var8 * 8000.0D);
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)owner.getWorld()).getHandle()));
watcher.a(0, Byte.valueOf((byte)0));
watcher.a(1, Short.valueOf((short)300));
watcher.a(2, "");
watcher.a(3, Byte.valueOf((byte) 0));
watcher.a(4, Byte.valueOf((byte)0));
watcher.a(7, Integer.valueOf(0));
watcher.a(8, Byte.valueOf((byte)0));
watcher.a(9, Byte.valueOf((byte)0));
watcher.a(6, Float.valueOf(1.0F));
watcher.a(10, Byte.valueOf((byte)0));
// Set invisible
int i1 = watcher.getInt(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
// Set small
byte b1 = watcher.getByte(10);
b1 = (byte)(b1 | 0x1);
watcher.watch(10, Byte.valueOf(b1));
armorPacket.l = watcher;
verifier.bypassProcess(packet);
attachPacket.c = armorPacket.a;
PacketPlayOutAttachEntity attachPacket2 = new PacketPlayOutAttachEntity();
attachPacket2.c = owner.getEntityId();
attachPacket2.b = attachPacket.a;
attachPacket2.a = 0;
verifier.bypassProcess(packet);
*/
}
}
}
}
private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, final String entityName, final PacketVerifier packetList)
{
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
final PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = newEntityId;
packet.b = (byte) 30;
packet.c = (int)EnumEntitySize.SIZE_2.a(100);
packet.d = (int)MathHelper.floor(64 * 32.0D);
packet.e = (int)EnumEntitySize.SIZE_2.a(100);
packet.i = (byte) ((int) (0 * 256.0F / 360.0F));
packet.j = (byte) ((int) (0 * 256.0F / 360.0F));
packet.k = (byte) ((int) (0 * 256.0F / 360.0F));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
packet.f = (int)(var4 * 8000.0D);
packet.g = (int)(var6 * 8000.0D);
packet.h = (int)(var8 * 8000.0D);
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)owner.getWorld()).getHandle()));
watcher.a(0, Byte.valueOf((byte)0));
watcher.a(1, Short.valueOf((short)300));
watcher.a(2, "");
watcher.a(3, Byte.valueOf((byte) 0));
watcher.a(4, Byte.valueOf((byte)0));
watcher.a(7, Integer.valueOf(0));
watcher.a(8, Byte.valueOf((byte)0));
watcher.a(9, Byte.valueOf((byte)0));
watcher.a(6, Float.valueOf(1.0F));
watcher.a(10, Byte.valueOf((byte)0));
// Set invisible
int i1 = watcher.getInt(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
// Set small
byte b1 = watcher.getByte(10);
b1 = (byte)(b1 | 0x1);
watcher.watch(10, Byte.valueOf(b1));
watcher.watch(2, entityName);
watcher.watch(3, Byte.valueOf((byte)1));
packet.l = watcher;
packetList.bypassProcess(packet);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = packet.a;
vehiclePacket.c = entityId;
packetList.bypassProcess(vehiclePacket);
}
});
}
}

View File

@ -16,6 +16,7 @@ import mineplex.core.cosmetic.ui.button.ActivateGadgetButton;
import mineplex.core.cosmetic.ui.button.DeactivateGadgetButton;
import mineplex.core.cosmetic.ui.button.GadgetButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.gadgets.MorphNotch;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.ItemGadget;
@ -62,6 +63,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
protected void addGadget(Gadget gadget, int slot)
{
if (gadget instanceof MorphNotch)
{
setItem(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Disabled " + gadget.GetName(), new String[] { "Sorry! Currently disabled until fix is made for 1.8 players!" }, 1, false, false));
return;
}
List<String> itemLore = new ArrayList<String>();
if (gadget.GetCost(CurrencyType.Coins) >= 0)

View File

@ -3,6 +3,7 @@ package mineplex.core.disguise;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
@ -34,23 +35,19 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilMath;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.disguise.disguises.DisguiseInsentient;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.packethandler.IPacketRunnable;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PlayerPacketEvent;
import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class DisguiseManager extends MiniPlugin implements IPacketRunnable
public class DisguiseManager extends MiniPlugin
{
private NautHashMap<Integer, DisguiseBase> _spawnPacketMap = new NautHashMap<Integer, DisguiseBase>();
private NautHashMap<Integer, PacketPlayOutEntityVelocity> _movePacketMap = new NautHashMap<Integer, PacketPlayOutEntityVelocity>();
@ -61,17 +58,17 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
private HashSet<String> _delTempList = new HashSet<String>();
private NautHashMap<DisguiseBase, HashSet<Player>> _disguisePlayerMap = new NautHashMap<DisguiseBase, HashSet<Player>>();
private boolean _handlingPacket = false;
private Field _attributesA;
private Field _soundB;
private Field _soundC;
private Field _soundD;
public DisguiseManager(JavaPlugin plugin, PacketHandler packetHandler)
public DisguiseManager(JavaPlugin plugin)
{
super("Disguise Manager", plugin);
packetHandler.AddPacketRunnable(this);
try
{
_attributesA = PacketPlayOutUpdateAttributes.class.getDeclaredField("a");
@ -137,14 +134,13 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
if (!disguise.GetEntity().isAlive())
return;
if (players == null || players.length == 0)
if (players != null && players.length != 0)
{
players = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
disguise.Global = false;
}
_spawnPacketMap.put(disguise.GetEntityId(), disguise);
_disguisePlayerMap.put(disguise, new HashSet<Player>());
_disguisePlayerMap.get(disguise).addAll(Arrays.asList(players));
reApplyDisguise(disguise);
}
@ -158,7 +154,9 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
_movePacketMap.remove(entity.getEntityId());
_moveTempMap.remove(entity.getEntityId());
for (Player player : _disguisePlayerMap.get(disguise))
Collection<? extends Player> players = (disguise.Global ? Bukkit.getOnlinePlayers() : _disguisePlayerMap.get(disguise));
for (Player player : players)
{
if (entity == player)
continue;
@ -180,9 +178,17 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
public void reApplyDisguise(final DisguiseBase disguise)
{
reApplyDisguise(disguise, 1);
}
public void reApplyDisguise(final DisguiseBase disguise, long reapplyTime)
{
_handlingPacket = true;
PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(disguise.GetEntityId());
for (Player player : _disguisePlayerMap.get(disguise))
Collection<? extends Player> players = (disguise.Global ? Bukkit.getOnlinePlayers() : _disguisePlayerMap.get(disguise));
for (Player player : players)
{
if (disguise.GetEntity() == ((CraftPlayer)player).getHandle())
continue;
@ -205,25 +211,30 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
final List<Packet> armorPackets = tempArmor;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
Bukkit.getServer().getScheduler().runTaskLater(GetPlugin(), new Runnable()
{
public void run()
{
_handlingPacket = true;
Packet spawnPacket = disguise.GetSpawnPacket();
for (Player player : _disguisePlayerMap.get(disguise))
{
if (disguise.GetEntity() == ((CraftPlayer)player).getHandle())
continue;
EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
entityPlayer.playerConnection.sendPacket(disguise.GetSpawnPacket());
entityPlayer.playerConnection.sendPacket(spawnPacket);
for (Packet packet : armorPackets)
{
entityPlayer.playerConnection.sendPacket(packet);
}
}
_handlingPacket = false;
}
});
}, reapplyTime);
_handlingPacket = false;
}
public void reApplyDisguise(final DisguiseBase disguise, final Player player)
@ -267,7 +278,9 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
public void updateDisguise(DisguiseBase disguise)
{
for (Player player : _disguisePlayerMap.get(disguise))
Collection<? extends Player> players = (disguise.Global ? Bukkit.getOnlinePlayers() : _disguisePlayerMap.get(disguise));
for (Player player : players)
{
if (disguise.GetEntity() == ((CraftPlayer)player).getHandle())
continue;
@ -347,27 +360,34 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
}
}
@Override
public boolean run(final Packet packet, Player owner, final PacketVerifier packetList)
@EventHandler
public void handlePackets(PlayerPacketEvent event)
{
if (_handlingPacket)
return;
final Packet packet = event.getPacket();
Player owner = event.getPlayer();
final PacketVerifier packetVerifier = event.getVerifier();
if (packet instanceof PacketPlayOutNamedEntitySpawn)
{
int entityId = ((PacketPlayOutNamedEntitySpawn)packet).a;
if (_spawnPacketMap.containsKey(entityId) && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner))
if (_spawnPacketMap.containsKey(entityId) && (_spawnPacketMap.get(entityId).Global || _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner)))
{
packetList.forceProcess(_spawnPacketMap.get(entityId).GetSpawnPacket());
return false;
handlePacket(_spawnPacketMap.get(entityId).GetSpawnPacket(), packetVerifier);
event.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutSpawnEntity)
{
int entityId = ((PacketPlayOutSpawnEntity)packet).a;
if (_spawnPacketMap.containsKey(entityId) && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner))
if (_spawnPacketMap.containsKey(entityId) && (_spawnPacketMap.get(entityId).Global || _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner)))
{
packetList.forceProcess(_spawnPacketMap.get(entityId).GetSpawnPacket());
return false;
handlePacket(_spawnPacketMap.get(entityId).GetSpawnPacket(), packetVerifier);
event.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutUpdateAttributes)
@ -387,11 +407,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
e.printStackTrace();
}
if (_spawnPacketMap.containsKey(entityId) && owner.getEntityId() != entityId && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner))
if (_spawnPacketMap.containsKey(entityId) && owner.getEntityId() != entityId && (_spawnPacketMap.get(entityId).Global || _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner)))
{
// Crash clients with meta to a block id.
if (_spawnPacketMap.get(entityId) instanceof DisguiseBlock)
return false;
event.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutAnimation)
@ -400,7 +420,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
if (containsSpawnDisguise(owner, entityId) && owner.getEntityId() != entityId)
{
return false;
event.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutEntityMetadata)
@ -409,8 +429,8 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
if (containsSpawnDisguise(owner, entityId) && owner.getEntityId() != entityId)
{
packetList.forceProcess(_spawnPacketMap.get(entityId).GetMetaDataPacket());
return false;
handlePacket(_spawnPacketMap.get(entityId).GetMetaDataPacket(), packetVerifier);
event.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutEntityEquipment)
@ -421,7 +441,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
{
if (!((DisguiseInsentient)_spawnPacketMap.get(entityId)).armorVisible() && ((PacketPlayOutEntityEquipment)packet).b != 0)
{
return false;
event.setCancelled(true);
}
}
}
@ -437,11 +457,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
}
else if (velocityPacket.b == 0 && velocityPacket.c == 0 && velocityPacket.d == 0)
{
return true;
return;
}
else if (_spawnPacketMap.containsKey(velocityPacket.a))
{
return false;
event.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutRelEntityMove)
@ -450,7 +470,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
// Only for viewers
if (movePacket.a == owner.getEntityId())
return true;
return;
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c < 20)
{
@ -459,7 +479,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
}
if (!containsSpawnDisguise(owner, movePacket.a))
return true;
return;
final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity();
velocityPacket.a = movePacket.a;
@ -478,7 +498,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
_movePacketMap.put(movePacket.a, velocityPacket);
packetList.forceProcess(velocityPacket);
packetVerifier.bypassProcess(velocityPacket);
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20)
{
@ -486,7 +506,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
{
public void run()
{
packetList.forceProcess(velocityPacket);
packetVerifier.bypassProcess(velocityPacket);
}
});
}
@ -502,7 +522,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
// Only for viewers
if (movePacket.a == owner.getEntityId())
return true;
return;
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c <= 20)
{
@ -511,7 +531,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
}
if (!containsSpawnDisguise(owner, movePacket.a))
return true;
return;
final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity();
velocityPacket.a = movePacket.a;
@ -530,7 +550,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
_movePacketMap.put(movePacket.a, velocityPacket);
packetList.forceProcess(velocityPacket);
packetVerifier.bypassProcess(velocityPacket);
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20)
{
@ -538,7 +558,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
{
public void run()
{
packetList.forceProcess(velocityPacket);
packetVerifier.bypassProcess(velocityPacket);
}
});
}
@ -569,13 +589,18 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
}
}
*/
}
return true;
private void handlePacket(Packet packet, PacketVerifier verifier)
{
_handlingPacket = true;
verifier.process(packet);
_handlingPacket = false;
}
private boolean containsSpawnDisguise(Player owner, int entityId)
{
return _spawnPacketMap.containsKey(entityId) && (_disguisePlayerMap.containsKey(_spawnPacketMap.get(entityId)) && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner));
return _spawnPacketMap.containsKey(entityId) && (_spawnPacketMap.get(entityId).Global || (_disguisePlayerMap.containsKey(_spawnPacketMap.get(entityId)) && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner)));
}
public void PrepAddDisguise(Player caller, EntityType entityType)

View File

@ -20,6 +20,8 @@ public abstract class DisguiseBase
private DisguiseBase _soundDisguise;
public boolean Global = true;
public DisguiseBase(org.bukkit.entity.Entity entity)
{
Entity = ((CraftEntity)entity).getHandle();

View File

@ -42,7 +42,7 @@ public class DisguiseBlock extends DisguiseBase
packet.h = MathHelper.d(Entity.pitch * 256.0F / 360.0F);
packet.i = MathHelper.d(Entity.yaw * 256.0F / 360.0F);
packet.j = 70;
packet.k = _blockId | _blockData << 16;
packet.k = _blockId | _blockData << 12;
double d1 = Entity.motX;
double d2 = Entity.motY;

View File

@ -1,12 +1,15 @@
package mineplex.core.disguise.disguises;
import org.spigotmc.ProtocolData;
public abstract class DisguiseHuman extends DisguiseLiving
{
public DisguiseHuman(org.bukkit.entity.Entity entity)
{
super(entity);
DataWatcher.a(16, Byte.valueOf((byte)0));
DataWatcher.a(10, new ProtocolData.HiddenByte( (byte) 0 ) ); // Spigot - protocol patch, handle new metadata value
DataWatcher.a(16, new ProtocolData.DualByte( (byte) 0, (byte) 0 ) );
DataWatcher.a(17, Float.valueOf(0.0F));
DataWatcher.a(18, Integer.valueOf(0));
}

View File

@ -1,5 +1,7 @@
package mineplex.core.disguise.disguises;
import org.spigotmc.ProtocolData;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn;

View File

@ -1,315 +0,0 @@
package mineplex.core.fakeEntity;
import java.lang.reflect.Field;
import net.minecraft.server.v1_7_R4.BlockCloth;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.Entity;
import net.minecraft.server.v1_7_R4.EntityLiving;
import net.minecraft.server.v1_7_R4.EntitySlime;
import net.minecraft.server.v1_7_R4.EnumEntitySize;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.entity.EntityType;
public class FakeEntity
{
private static int _entityIdCounter = 50000;
private int _entityId;
private Location _location;
private EntityType _entityType;
private static Field _spawnDataWatcherField;
private static Field _spawnListField;
public FakeEntity(EntityType entityType, Location location)
{
_entityId = _entityIdCounter++;
_entityType = entityType;
_location = location;
SetSpawnDataWatcherField();
SetSpawnListField();
}
public int GetEntityId()
{
return _entityId;
}
public EntityType GetEntityType()
{
return _entityType;
}
public void SetLocation(Location location)
{
_location = location;
}
public Location GetLocation()
{
return _location;
}
public Packet Spawn()
{
return Spawn(_entityId);
}
public Packet Destroy()
{
return new PacketPlayOutEntityDestroy(new int[] { GetEntityId() });
}
public Packet Spawn(int id)
{
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = id;
packet.b = (byte) _entityType.getTypeId();
packet.c = (int)EnumEntitySize.SIZE_2.a(_location.getX());
packet.d = (int)MathHelper.floor(_location.getY() * 32.0D);
packet.e = (int)EnumEntitySize.SIZE_2.a(_location.getZ());
packet.i = (byte) ((int) (_location.getYaw() * 256.0F / 360.0F));
packet.j = (byte) ((int) (_location.getPitch() * 256.0F / 360.0F));
packet.k = (byte) ((int) (_location.getYaw() * 256.0F / 360.0F));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
packet.f = (int)(var4 * 8000.0D);
packet.g = (int)(var6 * 8000.0D);
packet.h = (int)(var8 * 8000.0D);
DataWatcher dataWatcher = new DataWatcher(new EntitySlime(((CraftWorld)Bukkit.getWorlds().get(0)).getHandle()));
UpdateDataWatcher(dataWatcher);
try
{
_spawnDataWatcherField.set(packet, dataWatcher);
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
try
{
_spawnListField.set(packet, dataWatcher.b());
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
return packet;
}
public Packet Hide()
{
return Hide(_entityId);
}
public Packet Hide(int entityId)
{
DataWatcher dataWatcher = new DataWatcher(new EntitySlime(((CraftWorld)Bukkit.getWorlds().get(0)).getHandle()));
UpdateDataWatcher(dataWatcher);
dataWatcher.watch(0, Byte.valueOf((byte) 32));
return new PacketPlayOutEntityMetadata(entityId, dataWatcher, false);
}
public Packet Show()
{
DataWatcher dataWatcher = new DataWatcher(new EntitySlime(((CraftWorld)Bukkit.getWorlds().get(0)).getHandle()));
UpdateDataWatcher(dataWatcher);
return new PacketPlayOutEntityMetadata(_entityId, dataWatcher, true);
}
public Packet SetVehicle(int vehicleId)
{
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = _entityId;
vehiclePacket.c = vehicleId;
return vehiclePacket;
}
public Packet SetPassenger(int passengerId)
{
return SetPassenger(passengerId, _entityId);
}
public Packet SetPassenger(int passengerId, int entityId)
{
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = passengerId;
vehiclePacket.c = entityId;
return vehiclePacket;
}
protected void UpdateDataWatcher(DataWatcher dataWatcher)
{
dataWatcher.a(0, Byte.valueOf((byte) 0));
dataWatcher.a(1, Short.valueOf((short)300));
dataWatcher.a(6, Float.valueOf(4.0F));
dataWatcher.a(7, Integer.valueOf(0));
dataWatcher.a(8, Byte.valueOf((byte)0));
dataWatcher.a(9, Byte.valueOf((byte) 0));
dataWatcher.a(10, " ");
dataWatcher.a(11, Byte.valueOf((byte)0));
switch (_entityType)
{
case BAT:
case BLAZE:
case PIG:
case SHEEP:
case IRON_GOLEM:
case GHAST:
dataWatcher.a(16, new Byte((byte) 0));
break;
case CREEPER:
dataWatcher.a(16, Byte.valueOf((byte) -1));
dataWatcher.a(17, Byte.valueOf((byte) 0));
break;
case ENDERMAN:
dataWatcher.a(16, new Byte((byte) 0));
dataWatcher.a(17, new Byte((byte) 0));
dataWatcher.a(18, new Byte((byte) 0));
break;
case PLAYER:
dataWatcher.a(16, Byte.valueOf((byte) 0));
dataWatcher.a(17, Byte.valueOf((byte) 0));
break;
case OCELOT:
case SPIDER:
dataWatcher.a(16, new Byte((byte) 0));
break;
case WOLF:
dataWatcher.a(18, new Integer(20));
dataWatcher.a(19, new Byte((byte) 0));
dataWatcher.a(20, new Byte((byte) BlockCloth.b(1)));
case SKELETON:
dataWatcher.a(13, new Byte((byte) 0));
break;
case SLIME:
dataWatcher.a(16, new Byte((byte) 1));
break;
case WITCH:
dataWatcher.a(21, Byte.valueOf((byte) 0));
break;
case WITHER:
dataWatcher.a(16, new Integer(100));
dataWatcher.a(17, new Integer(0));
dataWatcher.a(18, new Integer(0));
dataWatcher.a(19, new Integer(0));
dataWatcher.a(20, new Integer(0));
break;
case ZOMBIE:
dataWatcher.a(13, Byte.valueOf((byte) 0));
dataWatcher.a(14, Byte.valueOf((byte) 0));
break;
default:
break;
}
}
private void SetSpawnListField()
{
if (_spawnListField == null)
{
try
{
_spawnListField = PacketPlayOutSpawnEntityLiving.class.getDeclaredField("m");
_spawnListField.setAccessible(true);
}
catch (NoSuchFieldException e)
{
e.printStackTrace();
}
catch (SecurityException e)
{
e.printStackTrace();
}
}
}
private void SetSpawnDataWatcherField()
{
if (_spawnDataWatcherField == null)
{
try
{
_spawnDataWatcherField = PacketPlayOutSpawnEntityLiving.class.getDeclaredField("l");
_spawnDataWatcherField.setAccessible(true);
}
catch (NoSuchFieldException e)
{
e.printStackTrace();
}
catch (SecurityException e)
{
e.printStackTrace();
}
}
}
}

View File

@ -1,115 +0,0 @@
package mineplex.core.fakeEntity;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.server.v1_7_R4.Packet;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.packethandler.PacketHandler;
public class FakeEntityManager extends MiniPlugin
{
public static FakeEntityManager Instance;
private PacketHandler _packetHandler;
private NautHashMap<String, List<FakeEntity>> _playerFakeEntityMap;
public FakeEntityManager(JavaPlugin plugin)
{
super("Fake Entity Manager", plugin);
_playerFakeEntityMap = new NautHashMap<String, List<FakeEntity>>();
}
public static void Initialize(JavaPlugin plugin)
{
Instance = new FakeEntityManager(plugin);
}
public void AddFakeEntity(FakeEntity entity, String name)
{
if (!_playerFakeEntityMap.containsKey(name))
{
_playerFakeEntityMap.put(name, new ArrayList<FakeEntity>());
}
_playerFakeEntityMap.get(name).add(entity);
}
public void ClearFakes(String name)
{
_playerFakeEntityMap.remove(name);
}
public void ClearFakeFor(FakeEntity entity, String name)
{
if (!_playerFakeEntityMap.containsKey(name))
{
_playerFakeEntityMap.put(name, new ArrayList<FakeEntity>());
}
_playerFakeEntityMap.get(name).remove(entity);
}
public List<FakeEntity> GetFakesFor(String name)
{
if (!_playerFakeEntityMap.containsKey(name))
{
_playerFakeEntityMap.put(name, new ArrayList<FakeEntity>());
}
return _playerFakeEntityMap.get(name);
}
public void SetPacketHandler(PacketHandler packetHandler)
{
_packetHandler = packetHandler;
}
public void RemoveForward(Player viewer)
{
_packetHandler.RemoveForward(viewer);
}
public void ForwardMovement(Player viewer, Player traveller, int entityId)
{
_packetHandler.ForwardMovement(viewer, traveller.getEntityId(), entityId);
}
public void BlockMovement(Player otherPlayer, int entityId)
{
_packetHandler.BlockMovement(otherPlayer, entityId);
}
public void FakePassenger(Player viewer, int entityId, Packet attachPacket)
{
_packetHandler.FakePassenger(viewer, entityId, attachPacket);
}
public void RemoveFakePassenger(Player viewer, int entityId)
{
_packetHandler.RemoveFakePassenger(viewer, entityId);
}
public void FakeVehicle(Player viewer, int entityId, Packet attachPacket)
{
_packetHandler.FakeVehicle(viewer, entityId, attachPacket);
}
public void RemoveFakeVehicle(Player viewer, int entityId)
{
_packetHandler.RemoveFakeVehicle(viewer, entityId);
}
public void SendPacketTo(Packet packet, Player player)
{
((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -1,79 +0,0 @@
package mineplex.core.fakeEntity;
import net.minecraft.server.v1_7_R4.EnumEntitySize;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
public class FakeFallingBlock extends FakeEntity
{
private int _materialId;
private byte _data;
public FakeFallingBlock(int materialId, byte data, Location location)
{
super(EntityType.FALLING_BLOCK, location);
_materialId = materialId;
_data = data;
}
public Packet Spawn(int id)
{
PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity();
packet.a = id;
packet.b = (int)EnumEntitySize.SIZE_2.a(GetLocation().getX());
packet.c = (int)MathHelper.floor(GetLocation().getY() * 32.0D);
packet.d = (int)EnumEntitySize.SIZE_2.a(GetLocation().getZ());
double var4 = 0;
double var6 = .045;
double var8 = 0;
double var10 = 3.9D;
if (var4 < -var10)
{
var4 = -var10;
}
if (var6 < -var10)
{
var6 = -var10;
}
if (var8 < -var10)
{
var8 = -var10;
}
if (var4 > var10)
{
var4 = var10;
}
if (var6 > var10)
{
var6 = var10;
}
if (var8 > var10)
{
var8 = var10;
}
packet.e = (int)(var4 * 8000.0D);
packet.f = (int)(var6 * 8000.0D);
packet.g = (int)(var8 * 8000.0D);
packet.h = 0;
packet.i = 0;
packet.j = 70;
packet.k = _materialId | _data << 16;
System.out.println("Creating fake falling block with entityId " + GetEntityId());
return packet;
}
}

View File

@ -1,85 +0,0 @@
package mineplex.core.fakeEntity;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.ItemStack;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.entity.EntityType;
public class FakeItemDrop extends FakeEntity
{
private ItemStack _itemStack;
public FakeItemDrop(org.bukkit.inventory.ItemStack itemStack, Location location)
{
super(EntityType.DROPPED_ITEM, location);
_itemStack = CraftItemStack.asNMSCopy(itemStack);
}
public Packet Spawn()
{
PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity();
packet.a = GetEntityId();
packet.b = MathHelper.floor(GetLocation().getX() * 32.0D);
packet.c = MathHelper.floor(GetLocation().getY() * 32.0D);
packet.d = MathHelper.floor(GetLocation().getZ() * 32.0D);
packet.h = MathHelper.d(GetLocation().getYaw() * 256.0F / 360.0F);
packet.i = MathHelper.d(GetLocation().getPitch() * 256.0F / 360.0F);
packet.j = 2;
packet.k = 1;
double d0 = 0;
double d1 = 0;
double d2 = 0;
double d3 = 3.9D;
if (d0 < -d3) {
d0 = -d3;
}
if (d1 < -d3) {
d1 = -d3;
}
if (d2 < -d3) {
d2 = -d3;
}
if (d0 > d3) {
d0 = d3;
}
if (d1 > d3) {
d1 = d3;
}
if (d2 > d3) {
d2 = d3;
}
packet.e = (int) (d0 * 8000.0D);
packet.f = (int) (d1 * 8000.0D);
packet.g = (int) (d2 * 8000.0D);
return packet;
}
protected void UpdateDataWatcher(DataWatcher dataWatcher)
{
dataWatcher.a(0, Byte.valueOf((byte) 0));
dataWatcher.a(1, Short.valueOf((short)300));
dataWatcher.a(8, Integer.valueOf(0));
dataWatcher.a(9, Byte.valueOf((byte) 0));
dataWatcher.a(10, new net.minecraft.server.v1_7_R4.ItemStack(_itemStack.getItem(), _itemStack.count));
}
public void SetItemStack(org.bukkit.inventory.ItemStack itemStack)
{
_itemStack = CraftItemStack.asNMSCopy(itemStack);
}
}

View File

@ -1,50 +0,0 @@
package mineplex.core.fakeEntity;
import java.lang.reflect.Field;
import java.util.UUID;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.EntitySlime;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.entity.EntityType;
public class FakePlayer extends FakeEntity
{
private String _name;
private static Field _spawnDataWatcherField;
public FakePlayer(String name, Location location)
{
super(EntityType.PLAYER, location);
_name = name;
}
public Packet Spawn(int id)
{
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
packet.a = id;
packet.b = new GameProfile(UUID.randomUUID(), _name);
packet.c = MathHelper.floor(GetLocation().getX() * 32.0D);
packet.d = MathHelper.floor(GetLocation().getY() * 32.0D);
packet.e = MathHelper.floor(GetLocation().getZ() * 32.0D);
packet.f = (byte) ((int) (GetLocation().getYaw() * 256.0F / 360.0F));
packet.g = (byte) ((int) (GetLocation().getPitch() * 256.0F / 360.0F));
DataWatcher dataWatcher = new DataWatcher(new EntitySlime(((CraftWorld)Bukkit.getWorlds().get(0)).getHandle()));
UpdateDataWatcher(dataWatcher);
packet.i = dataWatcher;
return packet;
}
}

View File

@ -1,10 +0,0 @@
package mineplex.core.fakeEntity;
public class LeashData
{
public int LeashedID;
public int LeasherID;
public boolean LeashedOn;
public boolean LeasherOn;
}

View File

@ -1,6 +1,5 @@
package mineplex.core.friend;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
import org.bukkit.Bukkit;
@ -21,28 +20,24 @@ import mineplex.core.friend.command.DeleteFriend;
import mineplex.core.friend.data.FriendData;
import mineplex.core.friend.data.FriendRepository;
import mineplex.core.friend.ui.FriendTabList;
import mineplex.core.packethandler.IPacketRunnable;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PlayerPacketEvent;
import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class FriendManager extends MiniClientPlugin<FriendData> implements IPacketRunnable
public class FriendManager extends MiniClientPlugin<FriendData>
{
private FriendRepository _repository;
private NautHashMap<Player, FriendTabList> _playerTabMap;
private boolean _sendingPackets = false;
public FriendManager(JavaPlugin plugin, PacketHandler packetHandler)
public FriendManager(JavaPlugin plugin)
{
super("Friends", plugin);
_repository = new FriendRepository(plugin);
_playerTabMap = new NautHashMap<Player, FriendTabList>();
packetHandler.AddPacketRunnable(this);
}
@Override
@ -139,15 +134,16 @@ public class FriendManager extends MiniClientPlugin<FriendData> implements IPack
_playerTabMap.remove(event.getPlayer());
}
@Override
public boolean run(Packet packet, Player owner, PacketVerifier packetList)
@EventHandler
public void handleFriendPackets(PlayerPacketEvent event)
{
if (packet instanceof PacketPlayOutPlayerInfo)
{
return _sendingPackets;
}
if (event.isCancelled())
return;
return true;
if (event.getPacket() instanceof PacketPlayOutPlayerInfo)
{
event.setCancelled(_sendingPackets);
}
}
public void addFriend(final Player caller, final String name)

View File

@ -1,10 +0,0 @@
package mineplex.core.packethandler;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.Packet;
public interface IPacketRunnable
{
boolean run(Packet packet, Player owner, PacketVerifier packetList);
}

View File

@ -1,215 +0,0 @@
package mineplex.core.packethandler;
import java.util.ArrayList;
import java.util.HashSet;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.NautHashMap;
import net.minecraft.server.v1_7_R4.Packet;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class PacketHandler extends MiniPlugin
{
private NautHashMap<String, NautHashMap<Integer, Integer>> _forwardMap;
private NautHashMap<String, HashSet<Integer>> _blockMap;
private NautHashMap<String, NautHashMap<Integer, Packet>> _fakeVehicleMap;
private NautHashMap<String, NautHashMap<Integer, Packet>> _fakePassengerMap;
private ArrayList<IPacketRunnable> _packetRunnables;
public PacketHandler(JavaPlugin plugin)
{
super("PacketHandler", plugin);
_forwardMap = new NautHashMap<String, NautHashMap<Integer, Integer>>();
_blockMap = new NautHashMap<String, HashSet<Integer>>();
_fakeVehicleMap = new NautHashMap<String, NautHashMap<Integer, Packet>>();
_fakePassengerMap = new NautHashMap<String, NautHashMap<Integer, Packet>>();
_packetRunnables = new ArrayList<IPacketRunnable>();
}
public String GetDataType(int c)
{
switch (c)
{
case 0:
return "Byte";
case 1:
return "Short";
case 2:
return "Integer";
case 3:
return "Float";
case 4:
return "String";
case 5:
return "ItemStack";
case 6:
return "ChunkCoordinates";
}
return "Say what?";
}
public void AddPacketRunnable(IPacketRunnable runnable)
{
_packetRunnables.add(runnable);
}
public void RemovePacketRunnable(IPacketRunnable runnable)
{
_packetRunnables.remove(runnable);
}
public Packet GetFakeAttached(Player owner, int a)
{
return _fakeVehicleMap.get(owner.getName()).get(a);
}
public boolean IsFakeAttached(Player owner, int a)
{
return _fakeVehicleMap.containsKey(owner.getName()) && _fakeVehicleMap.get(owner.getName()).containsKey(a);
}
public Packet GetFakePassenger(Player owner, int a)
{
return _fakePassengerMap.get(owner.getName()).get(a);
}
public boolean IsFakePassenger(Player owner, int a)
{
return _fakePassengerMap.containsKey(owner.getName()) && _fakePassengerMap.get(owner.getName()).containsKey(a);
}
public boolean IsBlocked(Player owner, int a)
{
return _blockMap.containsKey(owner.getName()) && _blockMap.get(owner.getName()).contains(a);
}
public int GetForwardId(Player owner, int a)
{
return _forwardMap.get(owner.getName()).get(a);
}
public boolean IsForwarded(Player owner, int a)
{
return _forwardMap.get(owner.getName()).containsKey(a);
}
public boolean IsForwarding(Player owner)
{
return _forwardMap.containsKey(owner.getName());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event)
{
in(event.getPlayer());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event)
{
out(event.getPlayer());
}
public void in(Player player)
{
((CraftPlayer) player).getHandle().playerConnection.PacketVerifier.addPacketVerifier(new PacketVerifier(player, this));
}
public void out(Player player)
{
((CraftPlayer) player).getHandle().playerConnection.PacketVerifier.clearVerifiers();
}
public void shutdown()
{
for (final Player player : this._plugin.getServer().getOnlinePlayers())
{
if (player != null)
{
this.out(player);
}
}
}
public void ForwardMovement(Player viewer, int travellerId, int entityId)
{
if (!_forwardMap.containsKey(viewer.getName()))
{
_forwardMap.put(viewer.getName(), new NautHashMap<Integer, Integer>());
}
_forwardMap.get(viewer.getName()).put(travellerId, entityId);
}
public void BlockMovement(Player otherPlayer, int entityId)
{
if (!_blockMap.containsKey(otherPlayer.getName()))
{
_blockMap.put(otherPlayer.getName(), new HashSet<Integer>());
}
_blockMap.get(otherPlayer.getName()).add(entityId);
}
public void FakeVehicle(Player viewer, int entityId, Packet packet)
{
if (!_fakeVehicleMap.containsKey(viewer.getName()))
{
_fakeVehicleMap.put(viewer.getName(), new NautHashMap<Integer, Packet>());
}
_fakeVehicleMap.get(viewer.getName()).put(entityId, packet);
}
public void RemoveFakeVehicle(Player viewer, int entityId)
{
if (_fakeVehicleMap.containsKey(viewer.getName()))
{
_fakeVehicleMap.get(viewer.getName()).remove(entityId);
}
}
public void FakePassenger(Player viewer, int entityId, Packet packet)
{
if (!_fakePassengerMap.containsKey(viewer.getName()))
{
_fakePassengerMap.put(viewer.getName(), new NautHashMap<Integer, Packet>());
}
_fakePassengerMap.get(viewer.getName()).put(entityId, packet);
}
public void RemoveFakePassenger(Player viewer, int entityId)
{
if (_fakePassengerMap.containsKey(viewer.getName()))
{
_fakePassengerMap.get(viewer.getName()).remove(entityId);
}
}
public void RemoveForward(Player viewer)
{
_forwardMap.remove(viewer.getName());
}
public boolean FireRunnables(Packet o, Player owner, PacketVerifier packetList)
{
boolean addOriginal = true;
for (IPacketRunnable packetRunnable : _packetRunnables)
{
if (!packetRunnable.run(o, owner, packetList))
addOriginal = false;
}
return addOriginal;
}
}

View File

@ -2,33 +2,62 @@ package mineplex.core.packethandler;
import net.minecraft.server.v1_7_R4.IPacketVerifier;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutAnimation;
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityVelocity;
import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMove;
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMoveLook;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.PacketPlayOutUpdateAttributes;
import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class PacketVerifier implements IPacketVerifier
{
private Player _owner;
private PacketHandler _handler;
public PacketVerifier(Player owner, PacketHandler handler)
public PacketVerifier(Player owner)
{
_owner = owner;
_handler = handler;
}
@Override
public boolean verify(Packet o)
{
return _handler.FireRunnables(o, _owner, this);
if (o instanceof PacketPlayOutNamedEntitySpawn
|| o instanceof PacketPlayOutSpawnEntity
|| o instanceof PacketPlayOutSpawnEntityLiving
|| o instanceof PacketPlayOutUpdateAttributes
|| o instanceof PacketPlayOutAnimation
|| o instanceof PacketPlayOutEntityMetadata
|| o instanceof PacketPlayOutEntityEquipment
|| o instanceof PacketPlayOutEntityVelocity
|| o instanceof PacketPlayOutRelEntityMove
|| o instanceof PacketPlayOutRelEntityMoveLook
|| o instanceof PacketPlayOutPlayerInfo
|| o instanceof PacketPlayOutEntityDestroy
|| o instanceof PacketPlayOutAttachEntity)
{
PlayerPacketEvent event = new PlayerPacketEvent(_owner, o, this);
Bukkit.getServer().getPluginManager().callEvent(event);
return !event.isCancelled();
}
return true;
}
public void forceProcess(Packet packet)
public void bypassProcess(Packet packet)
{
((CraftPlayer)_owner).getHandle().playerConnection.networkManager.handle(packet, new GenericFutureListener[0]);
}
@ -37,4 +66,9 @@ public class PacketVerifier implements IPacketVerifier
{
_owner = null;
}
public void process(Packet packet)
{
((CraftPlayer)_owner).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -0,0 +1,60 @@
package mineplex.core.packethandler;
import net.minecraft.server.v1_7_R4.Packet;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerPacketEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private Packet _packet;
private PacketVerifier _verifier;
private boolean _cancelled = false;
public PlayerPacketEvent(Player player, Packet packet, PacketVerifier verifier)
{
_player = player;
_packet = packet;
_verifier = verifier;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Packet getPacket()
{
return _packet;
}
public Player getPlayer()
{
return _player;
}
public PacketVerifier getVerifier()
{
return _verifier;
}
public void setCancelled(boolean cancel)
{
_cancelled = cancel;
}
public boolean isCancelled()
{
return _cancelled;
}
}

View File

@ -1,27 +0,0 @@
package mineplex.core.sound;
import net.minecraft.server.v1_7_R4.Packet;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.packethandler.IPacketRunnable;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketVerifier;
public class SoundManager extends MiniPlugin implements IPacketRunnable
{
public SoundManager(JavaPlugin plugin, PacketHandler packetHandler)
{
super("Sound Manager", plugin);
packetHandler.AddPacketRunnable(this);
}
@Override
public boolean run(Packet packet, Player owner, PacketVerifier packetList)
{
return false;
}
}

View File

@ -1,7 +1,5 @@
package mineplex.hub;
import net.minecraft.server.v1_7_R4.MinecraftServer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -93,12 +91,12 @@ public class Hub extends JavaPlugin implements IRelation
//Main Modules
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager));
PacketHandler packetHandler = new PacketHandler(this);
//new FriendManager(this, packetHandler);
PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager);
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
AntiHack.Initialize(this, punish, portal);
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager);
DisguiseManager disguiseManager = new DisguiseManager(this);
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager);
new PlayerTracker(this, serverStatusManager.getCurrentServerName(), serverStatusManager.getUs());
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this), partyManager);
@ -107,14 +105,15 @@ public class Hub extends JavaPlugin implements IRelation
new Chat(this, clientManager, preferenceManager, serverStatusManager.getCurrentServerName());
new MemoryFix(this);
new FileUpdater(this, portal);
new CustomTagFix(this, packetHandler);
new CustomTagFix(this);
new PacketHandler(this);
CombatManager combatManager = new CombatManager(this);
BlockRestore blockRestore = new BlockRestore(this);
ProjectileManager throwManager = new ProjectileManager(this);
SkillConditionManager conditionManager = new SkillConditionManager(this);
DamageManager damage = new DamageManager(this, combatManager, npcManager, new DisguiseManager(this, packetHandler));
DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager);
Fire fire = new Fire(this, conditionManager, damage);
Teleport teleport = new Teleport(this, clientManager, new Spawn(this));
Energy energy = new Energy(this);

View File

@ -54,7 +54,6 @@ 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.treasure.TreasureManager;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.disguise.DisguiseManager;
@ -115,7 +114,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
private InventoryManager _inventoryManager;
private NewsManager _news;
private AchievementManager _achievementManager;
private PollManager _pollManager;
private Location _spawn;
private int _scoreboardTick = 0;
@ -164,7 +162,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
_partyManager = partyManager;
_preferences = preferences;
_pollManager = pollManager;
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);
_visibilityManager = new VisibilityManager(this);

View File

@ -42,6 +42,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
BuildPage();
}
@SuppressWarnings("deprecation")
@Override
protected void BuildPage()
{
@ -118,6 +119,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
ButtonMap.put(26, new SelectMINButton(this));
}
@SuppressWarnings("deprecation")
private void createMinigameCycle()
{
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(98, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []

View File

@ -25,7 +25,6 @@ import mineplex.hub.server.ui.button.JoinServerButton;
public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> implements IServerPage
{
// Shop Item Messages
private static final String MESSAGE_SHOP_URL = ChatColor.RESET + "www.mineplex.com/shop";
private static final String MESSAGE_BETA_GET_ULTRA = ChatColor.RESET + C.Line + "Get Ultra to join Beta servers!";
private static final String MESSAGE_JOIN = ChatColor.RESET + C.Line + "Click to Join";
private static final String MESSAGE_IN_PROGRESS = ChatColor.RESET + C.Line + "Game in Progress.";

View File

@ -8,6 +8,7 @@ import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import mineplex.core.CustomTagFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antistack.AntiStack;
@ -44,7 +45,6 @@ import mineplex.core.updater.Updater;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import nautilus.game.arcade.game.GameServerConfig;
import net.minecraft.server.*;
import net.minecraft.server.v1_7_R4.MinecraftServer;
import org.bukkit.entity.Player;
@ -97,8 +97,7 @@ public class Arcade extends JavaPlugin
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
new FileUpdater(this, portal);
PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
DisguiseManager disguiseManager = new DisguiseManager(this);
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager);
@ -116,9 +115,11 @@ public class Arcade extends JavaPlugin
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager);
CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, true);
cosmeticManager.setInterfaceSlot(7);
new CustomTagFix(this);
new PacketHandler(this);
//Arcade Manager
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, preferenceManager, inventoryManager, cosmeticManager, projectileManager, webServerAddress);
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, preferenceManager, inventoryManager, cosmeticManager, projectileManager, webServerAddress);
new PlayerTracker(this, serverStatusManager.getCurrentServerName(), serverStatusManager.getUs());
new MemoryFix(this);

View File

@ -63,13 +63,11 @@ import mineplex.core.chat.Chat;
import mineplex.core.common.Rank;
import mineplex.core.common.util.*;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.creature.Creature;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.movement.Movement;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.elo.EloManager;
import mineplex.core.energy.Energy;
import mineplex.core.explosion.Explosion;
@ -139,7 +137,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig,
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, AntiStack antistack,
Portal portal, PacketHandler packetHandler, PreferencesManager preferences, InventoryManager inventoryManager,
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager,
CosmeticManager cosmeticManager, ProjectileManager projectileManager, String webAddress)
{
super("Game Manager", plugin);
@ -227,7 +225,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_gameCreationManager = new GameCreationManager(this);
_gameGemManager = new GameGemManager(this);
_gameManager = new GameManager(this);
_gameLobbyManager = new GameLobbyManager(this, packetHandler);
_gameLobbyManager = new GameLobbyManager(this);
new GameFlagManager(this);
_gamePlayerManager = new GamePlayerManager(this);
new GameAchievementManager(this);

View File

@ -1,6 +1,11 @@
package nautilus.game.arcade.game.games.hideseek.kits;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -53,40 +58,6 @@ public class KitHiderQuick extends KitHider
slime.SetName(GetAvailability().GetColor() + GetName());
slime.SetCustomNameVisible(true);
DisguiseBlock block = new DisguiseBlock(ent, 46, 0);
ToBlock(block, slime);
}
public void ToBlock(final DisguiseBlock block, final DisguiseSlime slime)
{
if (Manager.GetGame() == null || Manager.GetGame().InProgress())
return;
Manager.GetDisguise().disguise(block);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
ToSlime(block, slime);
}
}, 60);
}
public void ToSlime(final DisguiseBlock block, final DisguiseSlime slime)
{
if (Manager.GetGame() == null || Manager.GetGame().InProgress())
return;
Manager.GetDisguise().disguise(slime);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
ToBlock(block, slime);
}
}, 60);
Manager.GetDisguise().disguise(new DisguiseBlock(ent, 46, 0));
}
}

View File

@ -1,6 +1,11 @@
package nautilus.game.arcade.game.games.hideseek.kits;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -53,40 +58,6 @@ public class KitHiderShocker extends KitHider
slime.SetName(GetAvailability().GetColor() + GetName());
slime.SetCustomNameVisible(true);
DisguiseBlock block = new DisguiseBlock(ent, 61, 0);
ToBlock(block, slime);
}
public void ToBlock(final DisguiseBlock block, final DisguiseSlime slime)
{
if (Manager.GetGame() == null || Manager.GetGame().InProgress())
return;
Manager.GetDisguise().disguise(block);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
ToSlime(block, slime);
}
}, 60);
}
public void ToSlime(final DisguiseBlock block, final DisguiseSlime slime)
{
if (Manager.GetGame() == null || Manager.GetGame().InProgress())
return;
Manager.GetDisguise().disguise(slime);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
ToBlock(block, slime);
}
}, 60);
Manager.GetDisguise().disguise(new DisguiseBlock(ent, 61, 0));
}
}

View File

@ -1,6 +1,11 @@
package nautilus.game.arcade.game.games.hideseek.kits;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -52,43 +57,11 @@ public class KitHiderSwapper extends KitHider
slime.SetName(GetAvailability().GetColor() + GetName());
slime.SetCustomNameVisible(true);
ToBlock(ent, slime);
}
public void ToBlock(final LivingEntity ent, final DisguiseSlime slime)
{
if (Manager.GetGame() == null || Manager.GetGame().InProgress())
return;
double r = Math.random();
if (r > 0.75) Manager.GetDisguise().disguise(new DisguiseBlock(ent, 54, 0));
else if (r > 0.5) Manager.GetDisguise().disguise(new DisguiseBlock(ent, 145, 0));
else if (r > 0.25) Manager.GetDisguise().disguise(new DisguiseBlock(ent, 140, 11));
else Manager.GetDisguise().disguise(new DisguiseBlock(ent, 47, 0));
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
ToSlime(ent, slime);
}
}, 60);
}
public void ToSlime(final LivingEntity ent, final DisguiseSlime slime)
{
if (Manager.GetGame() == null || Manager.GetGame().InProgress())
return;
Manager.GetDisguise().disguise(slime);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
ToBlock(ent, slime);
}
}, 60);
}
}

View File

@ -31,7 +31,6 @@ import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.scoreboard.DisplaySlot;
@ -44,23 +43,17 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilText.TextAlign;
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.itemstack.ItemStackFactory;
import mineplex.core.packethandler.IPacketRunnable;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PlayerPacketEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -79,7 +72,7 @@ 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 IPacketRunnable, Listener
public class GameLobbyManager implements Listener
{
public ArcadeManager Manager;
@ -112,10 +105,11 @@ public class GameLobbyManager implements IPacketRunnable, Listener
private int _oldPlayerCount = 0;
public GameLobbyManager(ArcadeManager manager, PacketHandler packetHandler)
private boolean _handlingPacket = false;
public GameLobbyManager(ArcadeManager manager)
{
Manager = manager;
packetHandler.AddPacketRunnable(this);
World world = UtilWorld.getWorld("world");
@ -1037,19 +1031,22 @@ public class GameLobbyManager implements IPacketRunnable, Listener
}
@SuppressWarnings("unchecked")
@Override
public boolean run(Packet packet, Player owner, PacketVerifier packetList)
@EventHandler
public void handlePacket(PlayerPacketEvent event)
{
if (_handlingPacket)
return;
Packet packet = event.getPacket();
Player owner = event.getPlayer();
PacketVerifier packetVerifier = event.getVerifier();
int entityId = -1;
if (packet instanceof PacketPlayOutEntityMetadata)
{
entityId = ((PacketPlayOutEntityMetadata)packet).a;
}
else if (packet instanceof PacketPlayOutSpawnEntityLiving)
{
//entityId = ((Packet24MobSpawn)packet).a;
}
if (entityId != -1)
{
@ -1089,15 +1086,11 @@ public class GameLobbyManager implements IPacketRunnable, Listener
newPacket.a = entityId;
newPacket.b = watchables;
packetList.forceProcess(newPacket);
_handlingPacket = true;
packetVerifier.process(newPacket);
_handlingPacket = false;
return false;
}
else if (packet instanceof PacketPlayOutSpawnEntityLiving)
{
DataWatcher watcher = ((PacketPlayOutSpawnEntityLiving)packet).l;
watcher.watch(10, customName);
watcher.watch(11, Byte.valueOf((byte)1));
event.setCancelled(true);
}
}
catch (IllegalArgumentException e)
@ -1106,8 +1099,6 @@ public class GameLobbyManager implements IPacketRunnable, Listener
}
}
}
return true;
}
public void AddPlayerToScoreboards(Player player, String teamName)