Merge pull request #14 from Mineplex-LLC/Dual_1.9

1.9 Bugfixes + Ring game
This commit is contained in:
Shaun Bennett 2016-03-22 19:25:37 +11:00
commit 85cb065d5c
13 changed files with 586 additions and 160 deletions

View File

@ -789,4 +789,29 @@ public class UtilPlayer
return null;
}
public static boolean isGliding(Player player)
{
return ((CraftPlayer) player).getHandle().isGliding();
}
public static void setGliding(Player player, boolean gliding)
{
((CraftPlayer) player).getHandle().setGliding(gliding);
}
public static void setAutoDeploy(Player player, boolean autoDeploy)
{
((CraftPlayer) player).getHandle().setAutoWingsDeploy(autoDeploy);
}
public static void setGlidableWithoutWings(Player player, boolean glidableWithoutWings)
{
((CraftPlayer) player).getHandle().setGlidableWithoutWings(glidableWithoutWings);
}
public static void setAutoDeployDistance(Player player, float distance)
{
((CraftPlayer) player).getHandle().setWingsDeployAt(distance);
}
}

View File

@ -11,38 +11,40 @@ public class UtilShapes
{
private final static BlockFace[] radial =
{
BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH,
BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST
BlockFace.SOUTH,
BlockFace.SOUTH_WEST,
BlockFace.WEST,
BlockFace.NORTH_WEST,
BlockFace.NORTH,
BlockFace.NORTH_EAST,
BlockFace.EAST,
BlockFace.SOUTH_EAST
};
public static ArrayList<Location> getCircle(Location loc, boolean hollow, double radius)
{
return getCircleBlocks(loc, radius, 0, hollow, false);
return getSphereBlocks(loc, radius, 0, hollow);
}
public static ArrayList<Location> getSphereBlocks(Location loc, double radius, double height, boolean hollow)
{
return getCircleBlocks(loc, radius, height, hollow, true);
}
private static ArrayList<Location> getCircleBlocks(Location loc, double radius, double height, boolean hollow, boolean sphere)
public static ArrayList<Location> getSphereBlocks(Location loc, double width, double height, boolean hollow)
{
ArrayList<Location> circleblocks = new ArrayList<Location>();
double cx = loc.getBlockX();
double cy = loc.getBlockY();
double cz = loc.getBlockZ();
for (double y = (sphere ? cy - radius : cy); y < (sphere ? cy + radius : cy + height + 1); y++)
for (double y = height; y < height + 1; y++)
{
for (double x = cx - radius; x <= cx + radius; x++)
for (double x = -width; x <= width; x++)
{
for (double z = cz - radius; z <= cz + radius; z++)
for (double z = -width; z <= width; z++)
{
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0);
double dist = (x * x) + (z * z) + (y * y);
if (dist < radius * radius && !(hollow && dist < (radius - 1) * (radius - 1)))
if (dist < width * width
&& !(hollow && Math.abs(x) - width < 1 && Math.abs(z) - width < 1 && Math.abs(y) - height < 1))
{
Location l = new Location(loc.getWorld(), x, y, z);
Location l = new Location(loc.getWorld(), x + cx, y + cy, z + cz);
circleblocks.add(l);
}
}
@ -75,7 +77,8 @@ public class UtilShapes
right = radial[high];
return new BlockFace[]
{
left, right
left,
right
};
}
}
@ -87,13 +90,19 @@ public class UtilShapes
BlockFace[] faces = getSideBlockFaces(facing);
return new Block[]
{
b.getRelative(faces[0]), b.getRelative(faces[1])
b.getRelative(faces[0]),
b.getRelative(faces[1])
};
}
public static BlockFace getFacing(float yaw)
{
return radial[Math.round(yaw / 45f) & 0x7];
return radial[Math.round(yaw / 45f) % 8];
}
public static float getFacing(BlockFace face)
{
return UtilAlg.GetYaw(new Vector(face.getModX(), face.getModY(), face.getModZ()).normalize());
}
public static ArrayList<Location> getLinesDistancedPoints(Location startingPoint, Location endingPoint,
@ -133,6 +142,24 @@ public class UtilShapes
return locs;
}
/**
* Rotates the blocks around 0,0,0
*/
public static ArrayList<Location> rotate(ArrayList<Location> locs, double degree)
{
ArrayList<Location> rotated = new ArrayList<Location>();
for (Location loc : locs)
{
double xRot = Math.cos(degree) * (loc.getX()) - Math.sin(degree) * (loc.getZ());
double zRot = loc.getZ() + Math.sin(degree) * (loc.getX()) + Math.cos(degree) * (loc.getZ());
rotated.add(new Location(loc.getWorld(), xRot, loc.getY(), zRot));
}
return rotated;
}
public static ArrayList<Location> getDistancedCircle(Location center, double pointsDistance, double circleRadius)
{
return getPointsInCircle(center, (int) ((circleRadius * Math.PI * 2) / pointsDistance), circleRadius);
@ -157,12 +184,14 @@ public class UtilShapes
new int[]
{
allowDiagonal ? facing.getModX() : facing.getModZ(), allowDiagonal ? 0 : -facing.getModX()
allowDiagonal ? facing.getModX() : facing.getModZ(),
allowDiagonal ? 0 : -facing.getModX()
},
new int[]
{
allowDiagonal ? 0 : -facing.getModZ(), allowDiagonal ? facing.getModZ() : facing.getModX()
allowDiagonal ? 0 : -facing.getModZ(),
allowDiagonal ? facing.getModZ() : facing.getModX()
}
};
@ -189,7 +218,8 @@ public class UtilShapes
{
faces = new BlockFace[]
{
faces[1], faces[0]
faces[1],
faces[0]
};
}
@ -228,7 +258,8 @@ public class UtilShapes
return new Block[]
{
b.getRelative(faces[0]), b.getRelative(faces[1])
b.getRelative(faces[0]),
b.getRelative(faces[1])
};
}

View File

@ -28,6 +28,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_8_R3.PacketPlayOutNewAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
@ -67,12 +68,12 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
super("Custom Tag Fix", plugin);
packetHandler.addPacketHandler(this, true, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class,
PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class,
PacketPlayOutNamedEntitySpawn.class, PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class);
packetHandler.addPacketHandler(this, true, PacketPlayOutEntityDestroy.class, PacketPlayOutEntityMetadata.class,
PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutNamedEntitySpawn.class,
PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class, PacketPlayOutNewAttachEntity.class);
// NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
// NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
// NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
// NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
NCPHookManager.addHook(CheckType.ALL, this);
}
@ -257,15 +258,16 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
return;
}
int newId = UtilEnt.getNewEntityId();
Integer[] ids = new Integer[]
{
UtilEnt.getNewEntityId(),
UtilEnt.getNewEntityId()
};
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[]
{
newId
});
_entityMap.get(owner.getName()).put(spawnPacket.a, ids);
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true, -1);
sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids);
break;
}
}
@ -302,17 +304,16 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
return;
}
int newId = UtilEnt.getNewEntityId();
int newId2 = UtilEnt.getNewEntityId();
Integer[] ids = new Integer[]
{
UtilEnt.getNewEntityId(),
UtilEnt.getNewEntityId()
};
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[]
{
newId,
newId2
});
_entityMap.get(owner.getName()).put(spawnPacket.a, ids);
sendProtocolPackets(owner, spawnPacket.a, newId2, entityName, verifier, true, newId);
sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids);
break;
}
}
@ -332,13 +333,13 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
}
String newName = currentName;
boolean newDisplay = isDisplaying;
boolean displayName = isDisplaying;
for (WatchableObject watchable : (List<WatchableObject>) metaPacket.b)
{
if (watchable.a() == 3 && watchable.b() instanceof Byte)
{
newDisplay = ((Byte) watchable.b()) == 1;
displayName = ((Byte) watchable.b()) == 1;
}
if (watchable.a() == 2 && watchable.b() instanceof String)
@ -348,10 +349,10 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
}
// If the name has changed and the name should be showing, or the name display status has changed.
if ((!newName.equals(currentName) && newDisplay) || newDisplay != isDisplaying)
if ((!newName.equals(currentName) && displayName) || displayName != isDisplaying)
{
// If name is still being displayed
if (newDisplay)
if (displayName)
{
Integer[] newId;
@ -364,6 +365,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
newId = new Integer[]
{
UtilEnt.getNewEntityId(),
UtilEnt.getNewEntityId()
};
@ -371,7 +373,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
}
_entityNameMap.get(owner.getName()).put(metaPacket.a, newName);
sendProtocolPackets(owner, metaPacket.a, newId[0], newName, verifier, !isDisplaying, -1);
sendProtocolPackets(owner, metaPacket.a, newName, verifier, !isDisplaying, newId);
}
else
{ // Lets delete it
@ -452,9 +454,25 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
}
}
}
else if (packet instanceof PacketPlayOutAttachEntity)
else if (packet instanceof PacketPlayOutAttachEntity || packet instanceof PacketPlayOutNewAttachEntity)
{
PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet;
int vech = -1;
int rider = -1;
if (packet instanceof PacketPlayOutAttachEntity)
{
PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet;
vech = attachPacket.b;
rider = attachPacket.c;
}
else if (packet instanceof PacketPlayOutNewAttachEntity)
{
PacketPlayOutNewAttachEntity attachPacket = (PacketPlayOutNewAttachEntity) packet;
vech = attachPacket.a;
if (attachPacket.b.length > 0)
rider = attachPacket.b[0];
}
// c = rider, b = ridden
// When detaching, c is sent, b is -1
@ -473,27 +491,27 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
int vehicleId = -1;
if (_entityRiding.get(owner.getName()).containsKey(attachPacket.b))
if (_entityRiding.get(owner.getName()).containsKey(vech))
{
vehicleId = _entityRiding.get(owner.getName()).get(attachPacket.b);
vehicleId = _entityRiding.get(owner.getName()).get(vech);
}
if (attachPacket.c == -1 && _entityMap.get(owner.getName()).containsKey(vehicleId))
if (rider == -1 && _entityMap.get(owner.getName()).containsKey(vehicleId))
{
Integer[] ids = _entityMap.get(owner.getName()).get(vehicleId);
_entityRiding.get(owner.getName()).remove(attachPacket.b);
_entityRiding.get(owner.getName()).remove(vech);
sendProtocolPackets(owner, vehicleId, ids[ids.length - 1], _entityNameMap.get(owner.getName()).get(vehicleId),
verifier, true, ids.length > 1 ? ids[0] : -1);
sendProtocolPackets(owner, vehicleId, _entityNameMap.get(owner.getName()).get(vehicleId), verifier, true,
ids);
}
else
{
Integer[] ids = _entityMap.get(owner.getName()).get(attachPacket.c);
Integer[] ids = _entityMap.get(owner.getName()).get(rider);
if (ids != null && ids[0] != attachPacket.b)
if (ids != null && ids[1] != vech)
{
_entityRiding.get(owner.getName()).put(attachPacket.b, attachPacket.c);
_entityRiding.get(owner.getName()).put(vech, rider);
int[] newIds = new int[ids.length];
@ -509,8 +527,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
}
}
private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, String entityName,
final PacketVerifier packetList, final boolean newPacket, final int squidId)
private void sendProtocolPackets(final Player owner, final int entityId, String entityName, final PacketVerifier packetList,
final boolean newPacket, final Integer[] entityIds)
{
CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
_plugin.getServer().getPluginManager().callEvent(event);
@ -522,60 +540,81 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle()));
watcher.a(0, (byte) (0 | 1 << 5), Entity.META_ENTITYDATA, (byte) (0 | 1 << 5)); // Invisible
watcher.a(0, (byte) 32, Entity.META_ENTITYDATA, (byte) 32); // Invisible
watcher.a(1, Short.valueOf((short) 300), Entity.META_AIR, 0);
watcher.a(2, finalEntityName, Entity.META_CUSTOMNAME, finalEntityName);
watcher.a(3, (byte) 1, Entity.META_CUSTOMNAME_VISIBLE, true);
watcher.a(10, (byte) (0 | 0x1), EntityArmorStand.META_ARMOR_OPTION, (byte) (0 | 0x1)); // Small
watcher.a(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16); // Small
if (newPacket)
{
if (squidId >= 0)
{
watcher.watch(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16);
DataWatcher squidWatcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle()));
squidWatcher.a(0, (byte) (0 | 1 << 5), Entity.META_ENTITYDATA, (byte) (0 | 1 << 5));
squidWatcher.a(0, (byte) 32, Entity.META_ENTITYDATA, (byte) 32);
PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = squidId;
spawnPacket.a = entityIds[1];
spawnPacket.b = (byte) EntityType.SQUID.getTypeId();
spawnPacket.c = 1000000;
spawnPacket.c = owner.getLocation().getBlockX() * 32;
spawnPacket.d = -150;
spawnPacket.e = owner.getLocation().getBlockZ() * 32;
spawnPacket.l = squidWatcher;
spawnPacket.uuid = UUID.randomUUID();
UtilPlayer.sendPacket(owner, spawnPacket);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = spawnPacket.a;
vehiclePacket.c = entityId;
if (UtilPlayer.is1_9(owner))
{
UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityId, new int[]
{
entityIds[1]
}));
}
else
{
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = spawnPacket.a;
vehiclePacket.c = entityId;
UtilPlayer.sendPacket(owner, vehiclePacket);
UtilPlayer.sendPacket(owner, vehiclePacket);
}
}
PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = newEntityId;
spawnPacket.a = entityIds[0];
spawnPacket.b = (byte) 30;
spawnPacket.c = 1000000;
spawnPacket.c = owner.getLocation().getBlockX() * 32;
spawnPacket.d = -150;
spawnPacket.e = owner.getLocation().getBlockZ() * 32;
spawnPacket.l = watcher;
spawnPacket.uuid = UUID.randomUUID();
UtilPlayer.sendPacket(owner, spawnPacket);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = spawnPacket.a;
vehiclePacket.c = squidId >= 0 ? squidId : entityId;
if (UtilPlayer.is1_9(owner))
{
UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityIds[1], new int[]
{
entityIds[0]
}));
}
else
{
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = entityIds[0];
vehiclePacket.c = entityIds[1];
UtilPlayer.sendPacket(owner, vehiclePacket);
UtilPlayer.sendPacket(owner, vehiclePacket);
}
}
else
{
PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata();
entityMetadata.a = newEntityId;
entityMetadata.a = entityIds[0];
entityMetadata.b = watcher.c();
packetList.bypassProcess(entityMetadata);

View File

@ -917,7 +917,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (client.getHologram() == null)
{
double yAdd = 2.18;
double yAdd = 2.3;
hologram = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), "");
hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST);
hologram.addPlayer(player);

View File

@ -5,6 +5,8 @@ import net.minecraft.server.v1_8_R3.EntityWither;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import mineplex.core.common.util.UtilMath;
public class DisguiseWither extends DisguiseMonster
{
public DisguiseWither(org.bukkit.entity.Entity entity)
@ -24,6 +26,7 @@ public class DisguiseWither extends DisguiseMonster
public void setInvulTime(int i)
{
DataWatcher.watch(17, Integer.valueOf(i), EntityWither.META_INVUL_TIME, i);
DataWatcher.watch(20, Integer.valueOf(i), EntityWither.META_INVUL_TIME, i);
}

View File

@ -21,6 +21,7 @@ public enum GameDisplay
Dragons("Dragons", Material.ENDER_STONE, (byte)0, GameCategory.ARCADE, 13),
DragonsTeams("Dragons Teams", Material.DRAGON_EGG, (byte)0, GameCategory.TEAM_VARIANT, 14),
Draw("Draw My Thing", Material.BOOK_AND_QUILL, (byte)0, GameCategory.CLASSICS, 15),
ElytraRings("Elytra Rings", Material.ELYTRA, (byte) 0, GameCategory.CLASSICS, 61),
Evolution("Evolution", Material.EMERALD, (byte)0, GameCategory.ARCADE, 16),
Gravity("Gravity", Material.ENDER_PORTAL_FRAME, (byte)0, GameCategory.EXTRA, 18),
Halloween("Halloween Horror", Material.PUMPKIN, (byte)0, GameCategory.CLASSICS, 19),

View File

@ -216,7 +216,7 @@ public class Arcade extends JavaPlugin
for (String gameName : _serverConfiguration.getServerGroup().getGames().split(","))
{
try
{
{System.out.println(gameName);
GameType type = GameType.valueOf(gameName);
config.GameList.add(type);
}

View File

@ -105,6 +105,7 @@ import nautilus.game.arcade.managers.IdleManager;
import nautilus.game.arcade.managers.MiscManager;
import nautilus.game.arcade.player.ArcadePlayer;
import nautilus.game.arcade.shop.ArcadeShop;
import net.minecraft.server.v1_8_R3.EntityLiving;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -871,6 +872,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
UtilInv.Clear(player);
UtilPlayer.setAutoDeploy(player, false);
UtilPlayer.setGlidableWithoutWings(player, false);
UtilPlayer.setGliding(player, false);
UtilPlayer.setAutoDeployDistance(player, 1.15F);
((CraftEntity) player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0), EntityLiving.META_ENTITYDATA, (byte) 0);
player.setCustomName("");

View File

@ -41,6 +41,7 @@ import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.paintball.Paintball;
import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverTeams;
import nautilus.game.arcade.game.games.rings.ElytraRings;
import nautilus.game.arcade.game.games.runner.Runner;
import nautilus.game.arcade.game.games.searchanddestroy.SearchAndDestroy;
import nautilus.game.arcade.game.games.sheep.SheepGame;
@ -89,6 +90,7 @@ public enum GameType
Dragons(Dragons.class, GameDisplay.Dragons),
DragonsTeams(DragonsTeams.class, GameDisplay.DragonsTeams),
Draw(Draw.class, GameDisplay.Draw, "http://chivebox.com/mineplex/ResDrawMyThing.zip", true),
ElytraRings(ElytraRings.class, GameDisplay.ElytraRings),
Evolution(Evolution.class, GameDisplay.Evolution),
Gravity(Gravity.class, GameDisplay.Gravity),
Halloween(Halloween.class, GameDisplay.Halloween, "http://file.mineplex.com/ResHalloween.zip", true),

View File

@ -240,54 +240,45 @@ public class HideSeek extends TeamGame
for (Entry<Player, Form> entry : _forms.entrySet())
{
if (entry.getValue() instanceof BlockForm)
if (!(entry.getValue() instanceof BlockForm))
continue;
final BlockForm blockForm = (BlockForm) entry.getValue();
if (blockForm.Player.getEntityId() != id || blockForm.Player == packetInfo.getPlayer())
continue;
final Player player = packetInfo.getPlayer();
Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
{
final BlockForm blockForm = (BlockForm) entry
.getValue();
if (blockForm.Player.getEntityId() == id
&& blockForm.Player != packetInfo.getPlayer())
public void run()
{
final Player player = packetInfo.getPlayer();
Bukkit.getScheduler().scheduleSyncDelayedTask(
Manager.getPlugin(), new Runnable()
{
public void run()
{
UtilPlayer
.sendPacket(
player,
blockForm
.getBlockPackets(UtilPlayer.is1_9(player)));
}
});
break;
UtilPlayer.sendPacket(player, blockForm.getBlockPackets(UtilPlayer.is1_9(player)));
}
}
});
break;
}
}
else if (packetInfo.getPacket() instanceof PacketPlayOutEntityDestroy)
{
for (int i : ((PacketPlayOutEntityDestroy) packetInfo
.getPacket()).a)
for (int i : ((PacketPlayOutEntityDestroy) packetInfo.getPacket()).a)
{
for (Entry<Player, Form> entry : _forms.entrySet())
{
if (entry.getValue() instanceof BlockForm)
{
BlockForm blockForm = (BlockForm) entry.getValue();
if (!(entry.getValue() instanceof BlockForm))
continue;
if (blockForm.Player.getEntityId() == i)
BlockForm blockForm = (BlockForm) entry.getValue();
if (blockForm.Player.getEntityId() != i)
continue;
UtilPlayer.sendPacket(packetInfo.getPlayer(), new PacketPlayOutEntityDestroy(new int[]
{
UtilPlayer.sendPacket(packetInfo.getPlayer(),
new PacketPlayOutEntityDestroy(
new int[]
{
blockForm.getBlockId()
}));
}
}
blockForm.getBlockId()
}));
}
}
}

View File

@ -54,8 +54,8 @@ public class BlockForm extends Form
private int _entityId;
private Location _loc;
private int _selfEntityId1;
private int _selfEntityId2;
private int _fakeSilverfishId;
private int _fakeBlockId;
private Vector _lastSaw;
private Vector _sawDiff = new Vector();
private int _blockId = UtilEnt.getNewEntityId();
@ -66,8 +66,8 @@ public class BlockForm extends Form
_mat = mat;
_loc = player.getLocation();
_selfEntityId1 = UtilEnt.getNewEntityId();
_selfEntityId2 = UtilEnt.getNewEntityId();
_fakeSilverfishId = UtilEnt.getNewEntityId();
_fakeBlockId = UtilEnt.getNewEntityId();
System.out.println("Block Form: " + _mat + " " + _mat.getId());
}
@ -100,7 +100,7 @@ public class BlockForm extends Form
Packet[] packets = new Packet[3];
PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving();
packet1.a = _selfEntityId1;
packet1.a = _fakeSilverfishId;
packet1.b = EntityType.SILVERFISH.getTypeId();
packet1.c = (int) Math.floor(_lastSaw.getX() * 32);
packet1.d = (int) Math.floor(_lastSaw.getY() * 32);
@ -114,9 +114,9 @@ public class BlockForm extends Form
if (UtilPlayer.is1_9(Player))
{
packets[2] = new PacketPlayOutNewAttachEntity(_selfEntityId1, new int[]
packets[2] = new PacketPlayOutNewAttachEntity(_fakeSilverfishId, new int[]
{
_selfEntityId2
_fakeBlockId
});
}
@ -124,14 +124,14 @@ public class BlockForm extends Form
{
PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity();
packet3.b = _selfEntityId2;
packet3.c = _selfEntityId1;
packet3.b = _fakeBlockId;
packet3.c = _fakeSilverfishId;
packets[2] = packet3;
}
PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(player, 70, _mat.getId());
packet2.a = _selfEntityId2;
packet2.a = _fakeBlockId;
packet2.uuid = UUID.randomUUID();
packets[1] = packet2;
@ -140,16 +140,11 @@ public class BlockForm extends Form
// Inform
String blockName = F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false));
if (!blockName.contains("Block"))
UtilPlayer.message(
Player,
F.main("Game",
C.cWhite + "You are now a "
+ F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false) + " Block") + "!"));
UtilPlayer.message(Player, F.main("Game", C.cWhite + "You are now a "
+ F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false) + " Block") + "!"));
else
UtilPlayer.message(
Player,
F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false))
+ "!"));
UtilPlayer.message(Player, F.main("Game",
C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false)) + "!"));
// Give Item
Player.getInventory().setItem(8, new ItemStack(Host.GetItemEquivilent(_mat)));
@ -171,11 +166,11 @@ public class BlockForm extends Form
if (is19)
{
packets[2] = new PacketPlayOutNewAttachEntity(_blockId, new int[]
packets[1] = new PacketPlayOutNewAttachEntity(Player.getEntityId(), new int[]
{
Player.getEntityId()
});
_blockId
});
}
else
{
@ -203,8 +198,8 @@ public class BlockForm extends Form
UtilPlayer.sendPacket(Player, new PacketPlayOutEntityDestroy(new int[]
{
_selfEntityId1,
_selfEntityId2,
_fakeSilverfishId,
_fakeBlockId,
_blockId
}));
@ -214,8 +209,8 @@ public class BlockForm extends Form
public void SolidifyUpdate()
{
if (!Player.isSprinting())
((CraftEntity) Player).getHandle().getDataWatcher()
.watch(0, Byte.valueOf((byte) 32), Entity.META_ENTITYDATA, (byte) 32);
((CraftEntity) Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32), Entity.META_ENTITYDATA,
(byte) 32);
// Not a Block
if (_block == null)
@ -273,26 +268,26 @@ public class BlockForm extends Form
_sawDiff.add(blockLoc.clone().subtract(_lastSaw));
Packet packet = this.getPacket(_sawDiff, blockLoc);
Packet[] packet = this.getPacket(_sawDiff, blockLoc);
_lastSaw = Player.getLocation().toVector().subtract(new Vector(0, 0.15625, 0));
_sawDiff = _lastSaw.clone().subtract(blockLoc);
if (packet != null)
{
if (packet instanceof PacketPlayOutEntityTeleport)
if (packet[0] instanceof PacketPlayOutEntityTeleport)
{
_sawDiff = new Vector();
}
((CraftPlayer) Player).getHandle().playerConnection.sendPacket(packet);
UtilPlayer.sendPacket(Player, packet[UtilPlayer.is1_9(Player) ? 1 : 0]);
}
for (Player player : UtilServer.getPlayers())
{
UtilPlayer.sendPacket(player, new PacketPlayOutEntityDestroy(new int[]
{
getBlockId()
getBlockId()
}));
}
}
@ -321,8 +316,8 @@ public class BlockForm extends Form
MapUtil.QuickChangeBlockAt(_block.getLocation(), 0, (byte) 0);
_block = null;
EntityTrackerEntry tracker = (EntityTrackerEntry) ((WorldServer) ((CraftEntity) Player).getHandle().world).tracker.trackedEntities
.get(Player.getEntityId());
EntityTrackerEntry tracker = (EntityTrackerEntry) ((WorldServer) ((CraftEntity) Player)
.getHandle().world).tracker.trackedEntities.get(Player.getEntityId());
if (tracker != null)
{
@ -374,13 +369,13 @@ public class BlockForm extends Form
_lastSaw = Player.getLocation().subtract(0, 0.15625, 0).toVector();
Packet packet = this.getPacket(_sawDiff, _lastSaw);
Packet[] packet = this.getPacket(_sawDiff, _lastSaw);
if (packet != null)
{
if (packet instanceof PacketPlayOutRelEntityMove)
if (!UtilPlayer.is1_9(Player) && packet[0] instanceof PacketPlayOutRelEntityMove)
{
PacketPlayOutRelEntityMove relPacket = (PacketPlayOutRelEntityMove) packet;
PacketPlayOutRelEntityMove relPacket = (PacketPlayOutRelEntityMove) packet[0];
_sawDiff.subtract(new Vector(relPacket.b / 32D, relPacket.c / 32D, relPacket.d / 32D));
}
else
@ -388,12 +383,12 @@ public class BlockForm extends Form
_sawDiff = new Vector();
}
UtilPlayer.sendPacket(Player, packet);
UtilPlayer.sendPacket(Player, packet[UtilPlayer.is1_9(Player) ? 1 : 0]);
}
}
}
private Packet getPacket(Vector blocksFromNewPosition, Vector newPosition)
private Packet[] getPacket(Vector blocksFromNewPosition, Vector newPosition)
{
int x = (int) Math.floor(blocksFromNewPosition.getX() * 32);
int y = (int) Math.floor(blocksFromNewPosition.getY() * 32);
@ -401,26 +396,33 @@ public class BlockForm extends Form
if (x != 0 || y != 0 || z != 0)
{
Packet[] packets = new Packet[2];
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
{
PacketPlayOutRelEntityMove relMove = new PacketPlayOutRelEntityMove();
relMove.a = this._selfEntityId1;
relMove.a = this._fakeSilverfishId;
relMove.b = (byte) x;
relMove.c = (byte) y;
relMove.d = (byte) z;
return relMove;
packets[0] = relMove;
}
else
{
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
teleportPacket.a = _selfEntityId1;
teleportPacket.a = _fakeSilverfishId;
teleportPacket.b = (int) Math.floor(32 * newPosition.getX());
teleportPacket.c = (int) Math.floor(32 * newPosition.getY());
teleportPacket.d = (int) Math.floor(32 * newPosition.getZ());
return teleportPacket;
if (packets[0] == null)
packets[0] = teleportPacket;
packets[1] = teleportPacket;
}
return packets;
}
return null;

View File

@ -0,0 +1,253 @@
package nautilus.game.arcade.game.games.rings;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.uhc.KitUHC;
import nautilus.game.arcade.kit.Kit;
public class ElytraRings extends SoloGame
{
private HashMap<Integer, Ring> _rings = new HashMap<Integer, Ring>();
private HashMap<UUID, Integer> _goneThrough = new HashMap<UUID, Integer>();
private HashMap<UUID, Location> _lastLocation = new HashMap<UUID, Location>();
public ElytraRings(ArcadeManager manager)
{
super(manager, GameType.ElytraRings, new Kit[]
{
new KitElytraRings(manager)
}, new String[]
{
"Fly through the rings!"
});
DeathOut = false;
DeathMessages = false;
}
public void RespawnPlayer(final Player player)
{
player.eject();
if (_goneThrough.containsKey(player.getUniqueId()) && _rings.containsKey(_goneThrough.get(player.getUniqueId())))
{
Ring ring = _rings.get(_goneThrough.get(player.getUniqueId()));
player.teleport(ring.getCenter());
}
else if (_goneThrough.containsKey(player.getUniqueId()) && _rings.containsKey(_goneThrough.get(player.getUniqueId()) + 1))
{
Ring ring = _rings.get(_goneThrough.get(player.getUniqueId()) + 1);
player.teleport(ring.getCenter());
}
else
{
player.teleport(GetTeam(player).GetSpawn());
}
Manager.Clear(player);
// Event
PlayerGameRespawnEvent event = new PlayerGameRespawnEvent(this, player);
UtilServer.getServer().getPluginManager().callEvent(event);
// Re-Give Kit
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
{
public void run()
{
GetKit(player).ApplyKit(player);
}
}, 0);
}
@Override
public void ParseData()
{
Location loc = UtilAlg.getAverageLocation(GetTeamList().get(0).GetSpawns());
BlockFace currentDirection = BlockFace.values()[UtilMath.r(4)];
while (_rings.size() < 30)
{
int dist = UtilMath.r(40);
loc = loc.getBlock().getRelative(currentDirection, 20).getLocation();
generateRing(loc, currentDirection, 2 + UtilMath.r(2) + UtilMath.r(2));
}
loc = loc.getBlock().getRelative(currentDirection, 20).getLocation();
Ring ring = generateRing(loc, currentDirection, 7);
for (Block b : ring.getRing())
{
b.setType(Material.GOLD_BLOCK);
}
}
@EventHandler
public void onGameStart(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
return;
for (Player player : this.GetPlayers(true))
{
player.getInventory().setChestplate(new ItemStack(Material.ELYTRA));
}
}
@EventHandler
public void onMove(PlayerMoveEvent event)
{
if (event.isCancelled())
return;
if (!IsAlive(event.getPlayer()))
return;
Player player = event.getPlayer();
int current = 1;
if (_goneThrough.containsKey(player.getUniqueId()))
{
current = _goneThrough.get(player.getUniqueId()) + 1;
}
if (!_rings.containsKey(current))
{
return;
}
Ring ring = _rings.get(current);
if (!ring.isMoveThroughRing(event.getFrom(), event.getTo()))
{
return;
}
_goneThrough.put(player.getUniqueId(), current + 1);
Announce(player.getName() + " has gone through ring " + current + "!");
}
@EventHandler
public void onSpeedBoost(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : GetPlayers(true))
{
float exp = player.getExp();
exp += 0.02;
if (exp > 0.05 && _lastLocation.containsKey(player.getUniqueId()))
{
UtilAction.velocity(player, player.getLocation().getDirection().multiply(0.3));
if (!_goneThrough.containsKey(player.getUniqueId())
|| _rings.containsKey(_goneThrough.get(player.getUniqueId()) + 1))
{
exp -= 0.05;
}
for (Location loc : UtilShapes.getLinesDistancedPoints(_lastLocation.get(player.getUniqueId()),
player.getLocation(), 0.3))
{
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, loc, 0.2F, 0.2F, 0.2F, 0, 3, ViewDist.LONGER);
}
_lastLocation.put(player.getUniqueId(), player.getLocation());
}
player.setExp(Math.min(exp, 1));
}
}
@EventHandler
public void onToggleSneak(PlayerToggleSneakEvent event)
{
if (!IsAlive(event.getPlayer()))
{
return;
}
Player player = event.getPlayer();
if (event.isSneaking() && UtilPlayer.isGliding(player))
{
_lastLocation.put(player.getUniqueId(), player.getLocation());
}
else
{
_lastLocation.remove(player.getUniqueId());
}
}
private Ring generateRing(Location center, BlockFace direction, int size)
{
ArrayList<Block> blocks = new ArrayList<Block>();
ArrayList<Block> hole = new ArrayList<Block>();
for (Location loc : UtilShapes.rotate(UtilShapes.getSphereBlocks(center, size, size, true),
UtilShapes.getFacing(direction)))
{
blocks.add(loc.getBlock());
}
size--;
for (Location loc : UtilShapes.rotate(UtilShapes.getSphereBlocks(center, size, size, false),
UtilShapes.getFacing(direction)))
{
hole.add(loc.getBlock());
}
center.setDirection(new Vector(direction.getModX(), direction.getModY(), direction.getModZ()));
Ring ring = new Ring(blocks, hole, center.clone());
for (Block b : ring.getRing())
{
b.setTypeIdAndData(Material.STAINED_CLAY.getId(), (byte) 4, false);
}
_rings.put(_rings.size() + 1, ring);
return ring;
}
}

View File

@ -0,0 +1,73 @@
package nautilus.game.arcade.game.games.rings;
import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
public class Ring
{
private ArrayList<Block> _core = new ArrayList<Block>();
private ArrayList<Block> _ring = new ArrayList<Block>();
private Location _center;
public Ring(ArrayList<Block> blocks, ArrayList<Block> inside, Location center)
{
_core = inside;
_ring = blocks;
_center = center;
}
public Location getCenter()
{
return _center;
}
public ArrayList<Block> getRing()
{
return _ring;
}
public boolean isMoveThroughRing(Location from, Location to)
{
from = from.clone();
to = to.clone();
from.setX(from.getBlockX() + 0.5);
from.setY(from.getBlockY() + 0.5);
from.setZ(from.getBlockZ() + 0.5);
to.setX(to.getBlockX() + 0.5);
to.setY(to.getBlockY() + 0.5);
to.setZ(to.getBlockZ() + 0.5);
Vector vec = UtilAlg.getTrajectory(from, to).multiply(0.5);
double dist = UtilMath.offset(from, to);
while (dist > 0)
{
dist -= 0.5;
Location loc = from.getBlock().getLocation().add(0.5, 0.5, 0.5);
if (_core.contains(loc.getBlock()))
return true;
if (_core.contains(loc.clone().add(loc.getX() == 0 ? 0 : loc.getX() > 0 ? 1 : -1, 0, 0)))
return true;
if (_core.contains(loc.clone().add(0, loc.getY() == 0 ? 0 : loc.getY() > 0 ? 1 : -1, 0)))
return true;
if (_core.contains(loc.clone().add(0, 0, loc.getZ() == 0 ? 0 : loc.getZ() > 0 ? 1 : -1)))
return true;
from.add(vec);
}
return false;
}
}