More changes

This commit is contained in:
libraryaddict 2015-10-16 22:10:13 +13:00
parent 3dda9352e7
commit 70c76d976f
11 changed files with 57 additions and 148 deletions

Binary file not shown.

View File

@ -247,23 +247,7 @@ public class MapUtil
System.out.println("Error removing world from bukkit master list: " + ex.getMessage()); System.out.println("Error removing world from bukkit master list: " + ex.getMessage());
} }
MinecraftServer ms = null; MinecraftServer ms = server.getServer();
try
{
Field f = server.getClass().getDeclaredField("console");
f.setAccessible(true);
ms = (MinecraftServer) f.get(server);
f.setAccessible(false);
}
catch (IllegalAccessException ex)
{
System.out.println("Error getting minecraftserver variable: " + ex.getMessage());
}
catch (NoSuchFieldException ex)
{
System.out.println("Error getting minecraftserver variable: " + ex.getMessage());
}
ms.worlds.remove(ms.worlds.indexOf(craftWorld.getHandle())); ms.worlds.remove(ms.worlds.indexOf(craftWorld.getHandle()));
} }

View File

@ -155,7 +155,7 @@ public class UtilEnt
if (_bsRestrictionGoal == null) if (_bsRestrictionGoal == null)
{ {
_bsRestrictionGoal = EntityCreature.class.getDeclaredField("bs"); _bsRestrictionGoal = EntityCreature.class.getDeclaredField("c");
_bsRestrictionGoal.setAccessible(true); _bsRestrictionGoal.setAccessible(true);
} }

View File

@ -84,9 +84,12 @@ public class UtilFirework
firework.setFireworkMeta(data); firework.setFireworkMeta(data);
((CraftFirework) firework).getHandle().expectedLifespan = 1; ((CraftFirework) firework).getHandle().expectedLifespan = 1;
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(firework.getEntityId()); PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[]
{
firework.getEntityId()
});
for (Player viewing : UtilServer.getPlayers()) for (Player viewing : UtilServer.getPlayers())
{ {
if (player == viewing) if (player == viewing)

View File

@ -68,15 +68,21 @@ public class UtilTextTop
private static void deleteOld(Player player) private static void deleteOld(Player player)
{ {
//Delete Dragon (All Clients) // Delete Dragon (All Clients)
PacketPlayOutEntityDestroy destroyDragonPacket = new PacketPlayOutEntityDestroy(EntityDragonId); PacketPlayOutEntityDestroy destroyDragonPacket = new PacketPlayOutEntityDestroy(new int[]
((CraftPlayer)player).getHandle().playerConnection.sendPacket(destroyDragonPacket); {
EntityDragonId
//Delete Wither (1.8+ Only) });
((CraftPlayer) player).getHandle().playerConnection.sendPacket(destroyDragonPacket);
// Delete Wither (1.8+ Only)
if (UtilPlayer.is1_8(player)) if (UtilPlayer.is1_8(player))
{ {
PacketPlayOutEntityDestroy destroyWitherPacket = new PacketPlayOutEntityDestroy(EntityWitherId); PacketPlayOutEntityDestroy destroyWitherPacket = new PacketPlayOutEntityDestroy(new int[]
((CraftPlayer)player).getHandle().playerConnection.sendPacket(destroyWitherPacket); {
EntityWitherId
});
((CraftPlayer) player).getHandle().playerConnection.sendPacket(destroyWitherPacket);
} }
} }
@ -143,13 +149,11 @@ public class UtilTextTop
watcher.a(0, (Byte) (byte) 0); //Flags, 0x20 = invisible watcher.a(0, (Byte) (byte) 0); //Flags, 0x20 = invisible
watcher.a(6, (Float) (float) health); watcher.a(6, (Float) (float) health);
watcher.a(2, (String) text); //Entity name watcher.a(2, (String) text); //Entity name
watcher.a(10, (String) text); //Entity name
watcher.a(3, (Byte) (byte) 0); //Show name, 1 = show, 0 = don't show watcher.a(3, (Byte) (byte) 0); //Show name, 1 = show, 0 = don't show
watcher.a(11, (Byte) (byte) 0); //Show name, 1 = show, 0 = don't show
watcher.a(16, (Integer) (int) health); //Health watcher.a(16, (Integer) (int) health); //Health
watcher.a(20, (Integer) (int) 881); //Inv watcher.a(20, (Integer) (int) 881); //Inv
int i1 = watcher.getInt(0); int i1 = watcher.getByte(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5))); watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
return watcher; return watcher;

View File

@ -83,6 +83,7 @@ public class WorldUtil
WorldData worldData = new WorldData(new WorldSettings(creator.seed(), WorldSettings.EnumGamemode.getById(server.getDefaultGameMode().getValue()), generateStructures, hardcore, type), name); WorldData worldData = new WorldData(new WorldSettings(creator.seed(), WorldSettings.EnumGamemode.getById(server.getDefaultGameMode().getValue()), generateStructures, hardcore, type), name);
WorldServer internal = new WorldServer(server.getServer(), new ServerNBTManager(server.getWorldContainer(), name, true), worldData, dimension, server.getServer().methodProfiler, creator.environment(), generator); WorldServer internal = new WorldServer(server.getServer(), new ServerNBTManager(server.getWorldContainer(), name, true), worldData, dimension, server.getServer().methodProfiler, creator.environment(), generator);
internal.b();
boolean containsWorld = false; boolean containsWorld = false;
for (World otherWorld : server.getWorlds()) for (World otherWorld : server.getWorlds())

View File

@ -174,7 +174,15 @@ public class ZipUtil
int size; int size;
byte[] buffer = new byte[2048]; byte[] buffer = new byte[2048];
fileOutputStream = new FileOutputStream(outputDirectory + File.separator + entry.getName()); String fileName = outputDirectory + File.separator + entry.getName();
if (fileName.endsWith("/"))
{
new File(fileName).mkdirs();
continue;
}
fileOutputStream = new FileOutputStream(fileName);
bufferedOutputStream = new BufferedOutputStream(fileOutputStream, buffer.length); bufferedOutputStream = new BufferedOutputStream(fileOutputStream, buffer.length);
while ((size = zipInputStream.read(buffer, 0, buffer.length)) != -1) while ((size = zipInputStream.read(buffer, 0, buffer.length)) != -1)

View File

@ -222,9 +222,9 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
for (WatchableObject watchable : (List<WatchableObject>)spawnPacket.l.c()) for (WatchableObject watchable : (List<WatchableObject>)spawnPacket.l.c())
{ {
if ((watchable.a() == 11 || watchable.a() == 3) && watchable.b() instanceof Byte && ((Byte)watchable.b()) == 1) if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte)watchable.b()) == 1)
{ {
final String entityName = spawnPacket.l.getString(10); final String entityName = spawnPacket.l.getString(2);
if (entityName.isEmpty()) if (entityName.isEmpty())
{ {
@ -234,7 +234,10 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a)) if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a))
{ {
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner.getName()).get(spawnPacket.a))); verifier.bypassProcess(new PacketPlayOutEntityDestroy(new int[]
{
_entityMap.get(owner.getName()).get(spawnPacket.a)
}));
} }
int newId = UtilEnt.getNewEntityId(); int newId = UtilEnt.getNewEntityId();
@ -257,13 +260,13 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
for (WatchableObject watchable : (List<WatchableObject>)metaPacket.b) for (WatchableObject watchable : (List<WatchableObject>)metaPacket.b)
{ {
if ((watchable.a() == 11 || watchable.a() == 3) && watchable.b() instanceof Byte && ((Byte)watchable.b()) == 1) if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1)
{ {
nameShowing = true; nameShowing = true;
} }
if ((watchable.a() == 10 || watchable.a() == 2) && watchable.b() instanceof String) if (watchable.a() == 2 && watchable.b() instanceof String)
{ {
entityName = (String)watchable.b(); entityName = (String) watchable.b();
} }
} }
@ -288,7 +291,10 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
if (_entityMap.get(owner.getName()).containsKey(id)) if (_entityMap.get(owner.getName()).containsKey(id))
{ {
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner.getName()).get(id))); verifier.bypassProcess(new PacketPlayOutEntityDestroy(new int[]
{
_entityMap.get(owner.getName()).get(id)
}));
_entityMap.get(owner.getName()).remove(id); _entityMap.get(owner.getName()).remove(id);
_entityVehicleMap.get(owner.getName()).remove(id); _entityVehicleMap.get(owner.getName()).remove(id);
_entityNameMap.get(owner.getName()).remove(id); _entityNameMap.get(owner.getName()).remove(id);
@ -520,7 +526,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
watcher.a(10, Byte.valueOf((byte)0)); watcher.a(10, Byte.valueOf((byte)0));
// Set invisible // Set invisible
int i1 = watcher.getInt(0); int i1 = watcher.getByte(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5))); watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
// Set small // Set small

View File

@ -10,6 +10,7 @@ import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
import net.minecraft.server.v1_8_R3.Block; import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Chunk; import net.minecraft.server.v1_8_R3.Chunk;
import net.minecraft.server.v1_8_R3.ChunkSection; import net.minecraft.server.v1_8_R3.ChunkSection;
import net.minecraft.server.v1_8_R3.EntityTrackerEntry; import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
@ -41,8 +42,6 @@ import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -92,18 +91,8 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
private boolean _handlingPacket = false; private boolean _handlingPacket = false;
private Field _attributesA;
private Field _attributesB;
private Field _soundB;
private Field _soundC;
private Field _soundD;
private Field _bedA;
private Field _bedB;
private Field _bedD;
private Field _xChunk; private Field _xChunk;
private Field _zChunk; private Field _zChunk;
private Field _eStatusId;
private Field _eStatusState;
private Chunk _bedChunk; private Chunk _bedChunk;
private boolean _bedPackets; private boolean _bedPackets;
@ -123,33 +112,12 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
try try
{ {
_attributesA = PacketPlayOutUpdateAttributes.class.getDeclaredField("a");
_attributesA.setAccessible(true);
_attributesB = PacketPlayOutUpdateAttributes.class.getDeclaredField("b");
_attributesB.setAccessible(true);
_soundB = PacketPlayOutNamedSoundEffect.class.getDeclaredField("b");
_soundB.setAccessible(true);
_soundC = PacketPlayOutNamedSoundEffect.class.getDeclaredField("c");
_soundC.setAccessible(true);
_soundD = PacketPlayOutNamedSoundEffect.class.getDeclaredField("d");
_soundD.setAccessible(true);
_bedA = PacketPlayOutBed.class.getDeclaredField("a");
_bedA.setAccessible(true);
_bedB = PacketPlayOutBed.class.getDeclaredField("b");
_bedB.setAccessible(true);
_bedD = PacketPlayOutBed.class.getDeclaredField("d");
_bedD.setAccessible(true);
_eStatusId = PacketPlayOutEntityStatus.class.getDeclaredField("a");
_eStatusId.setAccessible(true);
_eStatusState = PacketPlayOutEntityStatus.class.getDeclaredField("b");
_eStatusState.setAccessible(true);
_bedChunk = new Chunk(null, 0, 0); _bedChunk = new Chunk(null, 0, 0);
Field cSection = Chunk.class.getDeclaredField("sections"); Field cSection = Chunk.class.getDeclaredField("sections");
cSection.setAccessible(true); cSection.setAccessible(true);
ChunkSection chunkSection = new ChunkSection(0, false); ChunkSection chunkSection = new ChunkSection(0, false);
Block block = Block.getById(Material.BED_BLOCK.getId()); // Block block = Block.getById(Material.BED_BLOCK.getId());
// block = ((Object[]) ReflectionManager.getNmsField(ReflectionManager.getNmsClass("Block"),"byId") // block = ((Object[]) ReflectionManager.getNmsField(ReflectionManager.getNmsClass("Block"),"byId")
// .get(null))[Material.BED_BLOCK.getId()]; // .get(null))[Material.BED_BLOCK.getId()];
@ -461,13 +429,13 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
{ {
PacketPlayOutBed bedPacket = new PacketPlayOutBed(); PacketPlayOutBed bedPacket = new PacketPlayOutBed();
_bedA.set(bedPacket, playerDisguise.GetEntityId()); bedPacket.a = playerDisguise.GetEntityId();
int chunkX = getChunk(recieving.getX()); int chunkX = getChunk(recieving.getX());
int chunkZ = getChunk(recieving.getZ()); int chunkZ = getChunk(recieving.getZ());
_bedB.set(bedPacket, (chunkX * 16) + 1 + playerDisguise.getSleepingDirection().getModX()); bedPacket.b = new BlockPosition((chunkX * 16) + 1 + playerDisguise.getSleepingDirection().getModX(), 0, (chunkZ * 16)
_bedD.set(bedPacket, (chunkZ * 16) + 1 + playerDisguise.getSleepingDirection().getModZ()); + 1 + playerDisguise.getSleepingDirection().getModZ());
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(playerDisguise.GetEntity()); PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(playerDisguise.GetEntity());
@ -590,17 +558,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
rabbitHops.put(owner.getEntityId(), System.currentTimeMillis()); rabbitHops.put(owner.getEntityId(), System.currentTimeMillis());
PacketPlayOutEntityStatus entityStatus = new PacketPlayOutEntityStatus(); PacketPlayOutEntityStatus entityStatus = new PacketPlayOutEntityStatus();
try
{
_eStatusId.set(entityStatus, entityId);
_eStatusState.set(entityStatus, (byte) 1);
handlePacket(entityStatus, packetVerifier); entityStatus.a = entityId;
} entityStatus.b = (byte) 1;
catch (Exception ex)
{ handlePacket(entityStatus, packetVerifier);
ex.printStackTrace();
}
} }
} }
} }
@ -660,20 +622,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
} }
else if (packet instanceof PacketPlayOutUpdateAttributes) else if (packet instanceof PacketPlayOutUpdateAttributes)
{ {
int entityId = -1; int entityId = ((PacketPlayOutUpdateAttributes) packet).a;
try
{
entityId = (int) _attributesA.get((PacketPlayOutUpdateAttributes) packet);
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
if (_spawnPacketMap.containsKey(entityId) if (_spawnPacketMap.containsKey(entityId)
&& owner.getEntityId() != entityId && owner.getEntityId() != entityId

View File

@ -56,7 +56,7 @@ public class BlockMap implements Listener
{ {
// Make sure the world doesn't change the mapcount information // Make sure the world doesn't change the mapcount information
PersistentCollection collection = ((CraftWorld) corner1.getWorld()).getHandle().worldMaps; PersistentCollection collection = ((CraftWorld) corner1.getWorld()).getHandle().worldMaps;
Field f = collection.getClass().getDeclaredField("a"); Field f = collection.getClass().getDeclaredField("b");
f.setAccessible(true); f.setAccessible(true);
f.set(collection, null); f.set(collection, null);
} }

View File

@ -352,52 +352,6 @@ public class HoleInTheWall extends SoloGame
_wallHeight += Math.abs(tnt1.getY() - tnt2.getY()); _wallHeight += Math.abs(tnt1.getY() - tnt2.getY());
} }
private void setField(Object obj, String fieldName, Object value)
{
try
{
Field field = _fields.get(fieldName);
if (field == null)
{
field = obj.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
_fields.put(fieldName, field);
}
field.set(obj, value);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
private int getField(String fieldName, Object obj)
{
try
{
Field field = _fields.get(fieldName);
if (field == null)
{
field = obj.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
_fields.put(fieldName, field);
}
return field.getInt(obj);
}
catch (Exception ex)
{
ex.printStackTrace();
}
return 0;
}
@EventHandler @EventHandler
public void SpawnWall(UpdateEvent event) public void SpawnWall(UpdateEvent event)
{ {