Merge branch 'develop' into clans/beta

# Conflicts:
#	Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java
#	Plugins/Mineplex.Core/src/mineplex/core/MiniPlugin.java
#	Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java
#	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java
This commit is contained in:
Shaun Bennett 2016-03-23 11:02:20 +11:00
commit e8dcc4a3e2
33 changed files with 1086 additions and 418 deletions

View File

@ -48,13 +48,6 @@ public class PlayerCache
try
{
PlayerInfo playerInfo = _repository.getElement(uuid.toString());
if (playerInfo != null)
{
System.out.println("Got playerInfo: " + playerInfo);
System.out.println("account id: " + playerInfo.getAccountId());
System.out.println("name: " + playerInfo.getName());
}
return playerInfo;
}
catch (Exception exception)
@ -65,7 +58,18 @@ public class PlayerCache
return null;
}
/**
* Attempts to grab a player's account ID from the cache
* @param uuid Minecraft Account UUID
* @return The account id of the player, or -1 if the player is not in the cache
*/
public int getAccountId(UUID uuid)
{
PlayerInfo info = getPlayer(uuid);
return info == null ? -1 : info.getAccountId();
}
public void clean()
{
_repository.clean();

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);
}
@ -121,7 +122,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
@EventHandler
public void ncpExemptVelocity(final PlayerVelocityEvent event)
{
long ignoreTime = System.currentTimeMillis() + (long) (event.getVelocity().length() * 2000);
long ignoreTime = System.currentTimeMillis() + (long) (event.getVelocity().length() * 1500);
if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId()))
{
_exemptTimeMap.put(event.getPlayer().getUniqueId(),
@ -256,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;
}
}
@ -301,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;
}
}
@ -331,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)
@ -347,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;
@ -363,6 +365,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
newId = new Integer[]
{
UtilEnt.getNewEntityId(),
UtilEnt.getNewEntityId()
};
@ -370,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
@ -451,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
@ -472,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];
@ -508,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);
@ -521,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

@ -1,5 +1,8 @@
package mineplex.core;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
@ -7,6 +10,7 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import mineplex.core.command.CommandCenter;
import mineplex.core.command.ICommand;
import mineplex.core.common.util.F;
@ -16,19 +20,22 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
public abstract class MiniPlugin implements Listener
{
private static final ExecutorService threadPool = Executors.newCachedThreadPool(
new ThreadFactoryBuilder().setNameFormat("MiniPlugin Async %1$d").build());
protected String _moduleName = "Default";
protected JavaPlugin _plugin;
protected NautHashMap<String, ICommand> _commands;
protected long _initializedTime;
public MiniPlugin(String moduleName, JavaPlugin plugin)
public MiniPlugin(String moduleName, JavaPlugin plugin)
{
_moduleName = moduleName;
_plugin = plugin;
_initializedTime = System.currentTimeMillis();
_commands = new NautHashMap<String, ICommand>();
onEnable();
@ -110,7 +117,8 @@ public abstract class MiniPlugin implements Listener
public void runAsync(Runnable runnable)
{
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, runnable);
// Instead of using
threadPool.execute(runnable);
}
public void runAsync(Runnable runnable, long time)

View File

@ -1,8 +1,8 @@
package mineplex.core.account;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
@ -49,9 +49,8 @@ public class CoreClientManager extends MiniPlugin
private NautHashMap<String, CoreClient> _clientList;
private HashSet<String> _duplicateLoginGlitchPreventionList;
private NautHashMap<String, ILoginProcessor> _loginProcessors = new NautHashMap<String, ILoginProcessor>();
private LinkedList<IQuerylessLoginProcessor> _querylessLoginProcessors = new LinkedList<IQuerylessLoginProcessor>();
private List<ILoginProcessor> _loginProcessors = new ArrayList<>();
private Object _clientLock = new Object();
private static AtomicInteger _clientsConnecting = new AtomicInteger(0);
@ -260,7 +259,7 @@ public class CoreClientManager extends MiniPlugin
CoreClient client = Add(playerName);
client.SetRank(Rank.valueOf(token.Rank), false);
client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName()));
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
@ -332,7 +331,7 @@ public class CoreClientManager extends MiniPlugin
CoreClient client = Add(playerName);
client.SetRank(Rank.valueOf(token.Rank), false);
client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName()));
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
@ -373,12 +372,12 @@ public class CoreClientManager extends MiniPlugin
_clientLoginLock.put(client.GetPlayerName(), new Object());
ClientToken token = null;
Gson gson = new Gson();
runAsync(new Runnable()
{
public void run()
{
client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName()));
client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName()));
_clientLoginLock.remove(client.GetPlayerName());
}
});
@ -386,7 +385,8 @@ public class CoreClientManager extends MiniPlugin
TimingManager.start(client.GetPlayerName() + " GetClient.");
String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress);
TimingManager.stop(client.GetPlayerName() + " GetClient.");
TimingManager.start(client.GetPlayerName() + " Event.");
token = gson.fromJson(response, ClientToken.class);
client.SetRank(Rank.valueOf(token.Rank), false);
@ -395,7 +395,9 @@ public class CoreClientManager extends MiniPlugin
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
TimingManager.stop(client.GetPlayerName() + " Event.");
TimingManager.start(client.GetPlayerName() + " While Loop.");
while (_clientLoginLock.containsKey(client.GetPlayerName()) && System.currentTimeMillis() - timeStart < 15000)
{
try
@ -407,6 +409,7 @@ public class CoreClientManager extends MiniPlugin
e.printStackTrace();
}
}
TimingManager.stop(client.GetPlayerName() + " While Loop.");
if (_clientLoginLock.containsKey(client.GetPlayerName()))
{
@ -646,14 +649,9 @@ public class CoreClientManager extends MiniPlugin
public void addStoredProcedureLoginProcessor(ILoginProcessor processor)
{
_loginProcessors.put(processor.getName(), processor);
_loginProcessors.add(processor);
}
public void addStoredProcedureLoginProcessor(IQuerylessLoginProcessor processor)
{
_querylessLoginProcessors.add(processor);
}
public boolean hasRank(Player player, Rank rank)
{
CoreClient client = Get(player);
@ -662,10 +660,4 @@ public class CoreClientManager extends MiniPlugin
return client.GetRank().has(rank);
}
public int getCachedClientAccountId(UUID uuid)
{
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
return playerInfo == null ? -1 : playerInfo.getAccountId();
}
}

View File

@ -6,23 +6,20 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import com.google.gson.reflect.TypeToken;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.gson.reflect.TypeToken;
import mineplex.cache.player.PlayerCache;
import mineplex.core.account.ILoginProcessor;
import mineplex.core.account.IQuerylessLoginProcessor;
import mineplex.core.account.repository.token.LoginToken;
import mineplex.core.account.repository.token.RankUpdateToken;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.EnclosedObject;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.database.MinecraftRepository;
import mineplex.core.server.remotecall.JsonWebCall;
import mineplex.serverdata.database.DBPool;
@ -60,100 +57,66 @@ public class AccountRepository extends MinecraftRepository
//executeUpdate(CREATE_ACCOUNT_TABLE);
}
public int login(NautHashMap<String, ILoginProcessor> loginProcessors, LinkedList<IQuerylessLoginProcessor> querylessLoginProcessors, String uuid, String name)
public int login(final List<ILoginProcessor> loginProcessors, final UUID uuid, final String name)
{
// First we try to grab the account id from cache - this saves an extra trip to database
int accountId = -1;
try (
Connection connection = getConnection();
Statement statement = connection.createStatement()
)
try (Connection connection = getConnection(); Statement statement = connection.createStatement())
{
statement.execute("SELECT id FROM accounts WHERE accounts.uuid = '" + uuid + "' LIMIT 1;");
ResultSet resultSet = statement.getResultSet();
while (resultSet.next())
int cachedId = PlayerCache.getInstance().getAccountId(uuid);
if (cachedId > 0)
{
accountId = resultSet.getInt(1);
accountId = cachedId;
System.out.println("Loaded Account ID From Cache [" + name + " - " + accountId + "]");
}
if (accountId == -1)
else
{
final List<Integer> tempList = new ArrayList<Integer>(1);
executeInsert(ACCOUNT_LOGIN_NEW, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
tempList.add(resultSet.getInt(1));
}
}
},new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 100, name));
accountId = tempList.get(0);
}
/*
boolean statementStatus = statement.execute(
"UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE accounts.uuid = '" + uuid + "';"
+ "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;"
+ "SELECT items.name, ic.name as category, count FROM accountInventory AS ai INNER JOIN items ON items.id = ai.itemId INNER JOIN itemCategories AS ic ON ic.id = items.categoryId INNER JOIN accounts ON accounts.id = ai.accountId WHERE accounts.uuid = '" + uuid + "';"
+ "SELECT benefit FROM rankBenefits WHERE rankBenefits.uuid = '" + uuid + "';"
+ "SELECT stats.name, value FROM accountStats INNER JOIN stats ON stats.id = accountStats.statId INNER JOIN accounts ON accountStats.accountId = accounts.id WHERE accounts.uuid = '" + uuid + "';"
+ "SELECT tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = '" + uuid + "';"
+ "SELECT gameType, elo FROM eloRating WHERE uuid = '" + uuid + "';"
);
*/
// Player was not found in cache, we need to grab the account id from database
statement.execute("SELECT id FROM accounts WHERE accounts.uuid = '" + uuid + "' LIMIT 1;");
ResultSet resultSet = statement.getResultSet();
String loginString = "UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE id = '" + accountId + "';";
for (ILoginProcessor loginProcessor : loginProcessors.values())
{
loginString += loginProcessor.getQuery(accountId, uuid, name);
}
statement.execute(loginString);
/*
while (true)
{
if (statementStatus)
if (resultSet.next())
{
System.out.println("ResultSet : " + statement.getResultSet().getMetaData().getColumnCount() + " columns:");
for (int i = 0; i < statement.getResultSet().getMetaData().getColumnCount(); i++)
{
System.out.println(statement.getResultSet().getMetaData().getColumnName(i + 1));
}
accountId = resultSet.getInt(1);
}
else
{
if (statement.getUpdateCount() == -1)
break;
// Player doesn't exist in our database, add them to the accounts table
final List<Integer> tempList = new ArrayList<Integer>(1);
System.out.println("Update statement : " + statement.getUpdateCount() + " rows affected.");
executeInsert(ACCOUNT_LOGIN_NEW, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
tempList.add(resultSet.getInt(1));
}
}
}, new ColumnVarChar("uuid", 100, uuid.toString()), new ColumnVarChar("name", 100, name));
accountId = tempList.get(0);
}
statementStatus = statement.getMoreResults();
}
System.out.println("Done");
*/
final int finalId = accountId;
final String uuidString = uuid.toString();
String loginString = "UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE id = '" + accountId + "';";
// We can use a parallel stream because they will be in the correct order when we collect
loginString += loginProcessors.parallelStream().map(processor -> processor.getQuery(finalId, uuidString, name)).collect(Collectors.joining());
statement.execute(loginString);
statement.getUpdateCount();
statement.getMoreResults();
for (ILoginProcessor loginProcessor : loginProcessors.values())
{
loginProcessor.processLoginResultSet(name, accountId, statement.getResultSet());
statement.getMoreResults();
}
for (IQuerylessLoginProcessor loginProcessor : querylessLoginProcessors)
for (ILoginProcessor loginProcessor : loginProcessors)
{
loginProcessor.processLogin(name, accountId);
loginProcessor.processLoginResultSet(name, finalId, statement.getResultSet());
statement.getMoreResults();
}
}
catch (Exception exception)
@ -190,7 +153,7 @@ public class AccountRepository extends MinecraftRepository
public UUID getClientUUID(String name)
{
EnclosedObject<UUID> uuid = new EnclosedObject<>();
final List<UUID> uuids = new ArrayList<UUID>();
executeQuery(SELECT_ACCOUNT_UUID_BY_NAME, new ResultSetCallable()
{
@ -199,12 +162,15 @@ public class AccountRepository extends MinecraftRepository
{
while (resultSet.next())
{
uuid.Set(UUID.fromString(resultSet.getString(1)));
uuids.add(UUID.fromString(resultSet.getString(1)));
}
}
}, new ColumnVarChar("name", 100, name));
return uuid.Get();
if (uuids.size() > 0)
return uuids.get(0);
else
return null;
}
public void saveRank(final Callback<Rank> callback, final String name, final UUID uuid, final Rank rank, final boolean perm)

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

@ -10,6 +10,7 @@ import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager;
public class GemCommand extends CommandBase<DonationManager>
@ -32,7 +33,11 @@ public class GemCommand extends CommandBase<DonationManager>
String gemsString = args[1];
Player target = UtilPlayer.searchExact(targetName);
if (target == null)
if (targetName.equalsIgnoreCase("@a"))
{
rewardAllGems(caller, gemsString);
}
else if (target == null)
{
UUID uuid = UUIDFetcher.getUUIDOf(targetName);
if (uuid != null)
@ -50,6 +55,42 @@ public class GemCommand extends CommandBase<DonationManager>
}
}
private void rewardAllGems(Player caller, String gemsString)
{
try
{
int gems = Integer.parseInt(gemsString);
if (gems > 1000)
{
UtilPlayer.message(caller, F.main("Gem", "You can only give everybody 1000 gems at a time."));
return;
}
rewardAllGems(caller, gems);
}
catch (Exception e)
{
UtilPlayer.message(caller, F.main("Gem", "Invalid gems Amount"));
}
}
private void rewardAllGems(Player caller, int gems)
{
for (Player player : UtilServer.getPlayers())
{
Plugin.RewardGems(new Callback<Boolean>()
{
public void run(Boolean completed)
{
}
}, caller.getName(), player.getName(), player.getUniqueId(), gems);
}
UtilPlayer.message(caller, F.main("Gem", "Gave everyone " + F.elem(gems + " gems")));
}
private void rewardGems(final Player caller, final Player target, final String targetName, final UUID uuid, String gemsString)
{
try

View File

@ -6,8 +6,8 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager;
import org.bukkit.entity.Player;
public class ShardCommand extends CommandBase<DonationManager>
@ -30,7 +30,11 @@ public class ShardCommand extends CommandBase<DonationManager>
final String coinsString = args[1];
Player target = UtilPlayer.searchExact(targetName);
if (target == null)
if (targetName.equalsIgnoreCase("@a"))
{
rewardAllShards(caller, coinsString);
}
else if (target == null)
{
Plugin.getClientManager().loadClientByName(targetName, new Runnable()
{
@ -53,6 +57,44 @@ public class ShardCommand extends CommandBase<DonationManager>
}
}
private void rewardAllShards(Player caller, String shardsString)
{
try
{
int shards = Integer.parseInt(shardsString);
if (shards > 1000)
{
UtilPlayer.message(caller, F.main("Shards", "You can only give everybody 1000 shards at a time."));
return;
}
rewardAllShards(caller, shards);
}
catch (Exception e)
{
UtilPlayer.message(caller, F.main("Shards", "Invalid Shards Amount"));
}
}
private void rewardAllShards(Player caller, int shards)
{
for (Player player : UtilServer.getPlayers())
{
CoreClient client = Plugin.getClientManager().Get(player);
Plugin.RewardCoins(new Callback<Boolean>()
{
public void run(Boolean completed)
{
}
}, caller.getName(), player.getName(), client.getAccountId(), shards);
}
UtilPlayer.message(caller, F.main("Shards", "Gave everyone " + F.elem(shards + " Treasure Shards")));
}
private void rewardCoins(final Player caller, final Player target, final String targetName, final int accountId, String coinsString)
{
try

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

@ -9,6 +9,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.data.Item;
@ -47,6 +48,15 @@ public class GiveItemCommand extends CommandBase<InventoryManager>
{
UtilPlayer.message(caller, F.main("Item", "Item with the name " + F.item(itemName) + " not found!"));
}
else if (playerName.equalsIgnoreCase("@a"))
{
for (Player pl : UtilServer.getPlayers())
{
Plugin.addItemToInventory(pl, item.Name, amount);
}
UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to everyone"));
}
else if (player != null)
{
Plugin.addItemToInventory(player, item.Name, amount);

View File

@ -131,7 +131,11 @@ public class PersonalServerManager extends MiniPlugin
}
if (eventServer)
{
ram = 4096;
cpu = 8;
createGroup(player, "EVENT", ram, cpu, 40, 80, "Event", eventServer);
}
else
createGroup(player, serverName, ram, cpu, 40, 80, "Smash", eventServer);
}

View File

@ -36,7 +36,7 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
private NautHashMap<String, Long> _errorThrottling;
private NautHashMap<String, Long> _purchaseBlock;
private List<CurrencyType> _availableCurrencyTypes;
private List<CurrencyType> _availableCurrencyTypes = new ArrayList<CurrencyType>();
private PluginType _plugin;
private CoreClientManager _clientManager;
@ -57,8 +57,8 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
_errorThrottling = new NautHashMap<String, Long>();
_purchaseBlock = new NautHashMap<String, Long>();
_availableCurrencyTypes = new ArrayList<CurrencyType>();
_availableCurrencyTypes.addAll(Arrays.asList(currencyTypes));
if (currencyTypes != null && currencyTypes.length > 0)
_availableCurrencyTypes.addAll(Arrays.asList(currencyTypes));
_plugin.registerEvents(this);
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
@ -101,12 +102,6 @@ public class TreasureLocation implements Listener
return;
}
if (!chargeAccount(player, treasureType))
{
player.sendMessage(F.main("Treasure", "You dont have any chests to open!"));
return;
}
TreasureStartEvent event = new TreasureStartEvent(player);
Bukkit.getPluginManager().callEvent(event);
@ -115,48 +110,73 @@ public class TreasureLocation implements Listener
return;
}
// Treasure is now being opened
setHoloChestVisible(false);
if (treasureType == TreasureType.ANCIENT)
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening an " + treasureType.getName()));
if (treasureType == TreasureType.MYTHICAL)
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + treasureType.getName()));
if (treasureType == TreasureType.CHRISTMAS)
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + treasureType.getName()));
Reward[] rewards = _treasureManager.getRewards(player, treasureType.getRewardPool(), treasureType.getRewardType());
Treasure treasure = new Treasure(player, rewards, treasureType.getRewardType(), _chestBlock, _chestSpawns, treasureType, _treasureManager.getBlockRestore(), _hologramManager, _statusManager);
_currentTreasure = treasure;
UtilTextMiddle.display(treasureType.getName(), "Choose 4 Chests To Open", 20, 180, 20, player);
UtilPlayer.message(player, F.main("Treasure", "Choose 4 Chests To Open"));
Location teleportLocation = treasure.getCenterBlock().getLocation().add(0.5, 0, 0.5);
teleportLocation.setPitch(player.getLocation().getPitch());
teleportLocation.setYaw(player.getLocation().getYaw());
for (Entity entity : player.getNearbyEntities(3, 3, 3))
chargeAccount(player, treasureType, new Callback<Boolean>()
{
UtilAction.velocity(entity, UtilAlg.getTrajectory(entity.getLocation(), treasure.getCenterBlock().getLocation()).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
}
@Override
public void run(Boolean success)
{
if (!success)
{
player.sendMessage(F.main("Treasure", "You dont have any chests to open!"));
}
else
{
if (isTreasureInProgress())
{
// Need to check again because of callback. Add item back
player.sendMessage(F.main("Treasure", "Please wait for the current chest to be opened"));
_inventoryManager.addItemToInventory(player, treasureType.getItemName(), 1);
return;
}
player.teleport(teleportLocation);
// Treasure is now being opened
setHoloChestVisible(false);
_treasureManager.addOpenStat(player, treasureType);
if (treasureType == TreasureType.ANCIENT)
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening an " + treasureType.getName()));
if (treasureType == TreasureType.MYTHICAL)
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + treasureType.getName()));
if (treasureType == TreasureType.CHRISTMAS)
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + treasureType.getName()));
Reward[] rewards = _treasureManager.getRewards(player, treasureType.getRewardPool(), treasureType.getRewardType());
Treasure treasure = new Treasure(player, rewards, treasureType.getRewardType(), _chestBlock, _chestSpawns, treasureType, _treasureManager.getBlockRestore(), _hologramManager, _statusManager);
_currentTreasure = treasure;
UtilTextMiddle.display(treasureType.getName(), "Choose 4 Chests To Open", 20, 180, 20, player);
UtilPlayer.message(player, F.main("Treasure", "Choose 4 Chests To Open"));
Location teleportLocation = treasure.getCenterBlock().getLocation().add(0.5, 0, 0.5);
teleportLocation.setPitch(player.getLocation().getPitch());
teleportLocation.setYaw(player.getLocation().getYaw());
for (Entity entity : player.getNearbyEntities(3, 3, 3))
{
UtilAction.velocity(entity, UtilAlg.getTrajectory(entity.getLocation(), treasure.getCenterBlock().getLocation()).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
}
player.teleport(teleportLocation);
_treasureManager.addOpenStat(player, treasureType);
}
}
});
}
private boolean chargeAccount(Player player, TreasureType treasureType)
private void chargeAccount(Player player, TreasureType treasureType, Callback<Boolean> callback)
{
int itemCount = _inventoryManager.Get(player).getItemCount(treasureType.getItemName());
if (itemCount > 0)
{
_inventoryManager.addItemToInventory(player, treasureType.getItemName(), -1);
return true;
// Should always handle the callback for us
_inventoryManager.addItemToInventory(callback, player, treasureType.getItemName(), -1);
}
else
{
callback.run(false);
}
return false;
}
private void setHoloChestVisible(boolean visible)

View File

@ -6,6 +6,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
import mineplex.core.reward.RewardManager;
@ -1076,4 +1077,27 @@ public class HubManager extends MiniClientPlugin<HubClient>
{
playNextSong();
}
@EventHandler
public void trackPortalDelayPlayers(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Iterator<String> playerNameIterator = _portalTime.keySet().iterator(); playerNameIterator.hasNext();)
{
String playerName = playerNameIterator.next();
if (UtilTime.elapsed(_portalTime.get(playerName), 5000))
{
playerNameIterator.remove();
continue;
}
Player player = Bukkit.getPlayerExact(playerName);
if (player != null)
System.out.println(playerName + "'s location: " + player.getLocation().toString());
}
}
}

View File

@ -257,7 +257,12 @@ public class StackerManager extends MiniPlugin implements IThrown
{
public void run()
{
fThrower.setPassenger(fThroweeStack);
if ((fThrower instanceof Player && !((Player)fThrower).isOnline())
|| (fThroweeStack instanceof Player && !((Player)fThroweeStack).isOnline()))
{
fThrower.setPassenger(fThroweeStack);
}
_tempStackShift.remove(fThroweeStack);
}
}, 2);
@ -273,7 +278,7 @@ public class StackerManager extends MiniPlugin implements IThrown
UtilPlayer.message(thrower, F.main("Stacker", "You threw " + F.name(UtilEnt.getName(throwee)) + "."));
UtilPlayer.message(throwee, F.main("Stacker", "You were thrown by " + F.name(thrower.getName()) + "."));
System.out.println("Stacker throw.");
System.out.println("Stacker throw (" + thrower.getName() + ") -> (" + UtilEnt.getName(throwee) + ")");
UtilAction.velocity(throwee, thrower.getLocation().getDirection(), 1.8, false, 0, 0.3, 2, false);

View File

@ -219,7 +219,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

@ -4,34 +4,6 @@ import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.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.event.HandlerList;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.util.Vector;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
@ -136,6 +108,35 @@ 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;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.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.event.HandlerList;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.EntityLiving;
public class ArcadeManager extends MiniPlugin implements IRelation
{
// Modules
@ -609,7 +610,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return true;
}
@EventHandler
public void StaffIncognito(IncognitoStatusChangeEvent event)
{
@ -619,7 +620,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
event.setCancelled(true);
return;
}
if (event.getNewState())
{
UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName()));
@ -699,10 +700,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation
event.setJoinMessage(null);
return;
}
if (event.getJoinMessage() == null)
return;
if (_game != null && _game.AnnounceJoinQuit)
event.setJoinMessage(F.sys("Join", GetColor(event.getPlayer()) + name));
@ -718,12 +719,12 @@ public class ArcadeManager extends MiniPlugin implements IRelation
event.setQuitMessage(null);
return;
}
String name = event.getPlayer().getName();
if (event.getQuitMessage() == null)
return;
if (_game == null || _game.AnnounceJoinQuit)
event.setQuitMessage(F.sys("Quit", GetColor(event.getPlayer()) + name));
else
@ -910,6 +911,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("");
@ -1121,10 +1127,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
_specList.add(player);
}
return _specList.contains(player);
}
public boolean IsTournamentServer()
{
return _serverConfig.Tournament;

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

@ -1118,11 +1118,17 @@ public class Bridge extends TeamGame implements OreObsfucation
while (!UtilBlock.airFoliage(block))
{
block = block.getRelative(BlockFace.UP);
if (block.getY() >= 256)
break;
}
while (UtilBlock.airFoliage(block))
{
block = block.getRelative(BlockFace.DOWN);
if (block.getY() <= 0)
break;
}
block = block.getRelative(BlockFace.UP);
@ -1943,4 +1949,10 @@ public class Bridge extends TeamGame implements OreObsfucation
{
event.setCancelled(true);
}
public void setBridgeTime(int time)
{
_bridgeTime = time;
}
}

View File

@ -17,7 +17,9 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilSystem;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv;
import mineplex.core.creature.event.CreatureKillEntitiesEvent;
import mineplex.core.event.StackerEvent;
import mineplex.core.gadget.gadgets.morph.MorphBlock;
@ -30,6 +32,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.PlayerDeathOutEvent;
import nautilus.game.arcade.game.games.bridge.Bridge;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -452,6 +455,84 @@ public class EventModule extends MiniPlugin
}
UtilPlayer.message(event.getPlayer(), F.main("Event", "You gave the gadget " + F.item(gadget) + " to all Players!"));
}
else if (args[0].equalsIgnoreCase("announce"))
{
String text = args[1];
for (int i = 2; i < args.length; i++)
{
text += " " + args[i];
}
UtilTextMiddle.display(C.cDGreenB + "Announcement", text);
UtilServer.broadcast(F.main("Event Announcement", text));
}
else if (args[0].equalsIgnoreCase("clear"))
{
String playerName = args[1];
if (playerName.equalsIgnoreCase("@a"))
{
for (Player player : UtilServer.getPlayers())
{
UtilInv.Clear(player);
}
UtilPlayer.message(event.getPlayer(), F.main("Event", "Cleared everyone's inventory!"));
}
else
{
Player player = Bukkit.getPlayer(args[1]);
if (player == null)
{
UtilPlayer.message(event.getPlayer(), "No matches for: " + F.elem(args[1]));
}
else
{
UtilInv.Clear(player);
UtilPlayer.message(event.getPlayer(), F.main("Event", "Cleared " + F.elem(player.getName() + "'s") + " inventory!"));
}
}
}
else if (args[0].equalsIgnoreCase("bridge"))
{
if (!(Manager.GetGame() instanceof Bridge))
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "You can only drop the bridges in Bridges!"));
return;
}
if (((Bridge) Manager.GetGame()).isBridgesDown())
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "The bridges have already dropped!"));
return;
}
int seconds = 10;
if (args.length > 1)
{
try
{
seconds = Integer.parseInt(args[1]);
}
catch (NumberFormatException e)
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "Invalid integer for seconds!"));
return;
}
}
if (seconds < 0)
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "Seconds must be greater than 0!"));
return;
}
((Bridge) Manager.GetGame()).setBridgeTime((int) ((System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + seconds * 1000));
UtilPlayer.message(event.getPlayer(), F.main("Event", "Bridges will drop in " + F.elem(seconds + " Seconds") + "!"));
}
}
public void listSettings(Player player)

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;
}
}

View File

@ -29,6 +29,7 @@ import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.EntityCreature;
import net.minecraft.server.v1_8_R3.Navigation;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
@ -52,6 +53,9 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GamePrepareCountdownCommence;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.snake.events.SlimeUpgradeEvent;
import nautilus.game.arcade.game.games.snake.events.TailGrowEvent;
import nautilus.game.arcade.game.games.snake.kits.KitInvulnerable;
import nautilus.game.arcade.game.games.snake.kits.KitReverser;
import nautilus.game.arcade.game.games.snake.kits.KitSpeed;
@ -63,57 +67,6 @@ import nautilus.game.arcade.stats.SlimySheepStatTracker;
public class Snake extends SoloGame
{
public static class TailGrowEvent extends PlayerEvent
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
private final int _length;
public TailGrowEvent(Player who, int length)
{
super(who);
_length = length;
}
public int getLength()
{
return _length;
}
}
public static class SlimeUpgradeEvent extends PlayerEvent
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
public SlimeUpgradeEvent(Player who)
{
super(who);
}
}
private double _maxSpeed = 180;
private HashMap<Player, ArrayList<Creature>> _tail = new HashMap<Player, ArrayList<Creature>>();
@ -730,4 +683,22 @@ public class Snake extends SoloGame
}
}
}
@EventHandler
public void handleInteractEntityPacket(GameStateChangeEvent event)
{
if (event.GetState() == GameState.Dead)
{
_tail.clear();
_food.clear();
_color.clear();
_invul.clear();
_speed.clear();
_reverse.clear();
_move.clear();
_moveTime.clear();
HandlerList.unregisterAll(this);
}
}
}

View File

@ -0,0 +1,26 @@
package nautilus.game.arcade.game.games.snake.events;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class SlimeUpgradeEvent extends PlayerEvent
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
public SlimeUpgradeEvent(Player who)
{
super(who);
}
}

View File

@ -0,0 +1,35 @@
package nautilus.game.arcade.game.games.snake.events;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class TailGrowEvent extends PlayerEvent
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
private final int _length;
public TailGrowEvent(Player who, int length)
{
super(who);
_length = length;
}
public int getLength()
{
return _length;
}
}

View File

@ -369,7 +369,7 @@ public class TurfForts extends TeamGame
//On Own
Block block = event.getBlock().getRelative(BlockFace.DOWN);
while (block.getTypeId() == 0)
while (block.getTypeId() == 0 && block.getY() > 0)
block = block.getRelative(BlockFace.DOWN);
if (block.getData() != team.GetColorData())

View File

@ -4,7 +4,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.snake.Snake;
import nautilus.game.arcade.game.games.snake.events.TailGrowEvent;
public class ChooChooStatTracker extends StatTracker<Game>
{
@ -14,7 +14,7 @@ public class ChooChooStatTracker extends StatTracker<Game>
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onTailGrow(Snake.TailGrowEvent event)
public void onTailGrow(TailGrowEvent event)
{
if (getGame().GetState() != Game.GameState.Live)
return;

View File

@ -8,7 +8,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.snake.Snake;
import nautilus.game.arcade.game.games.snake.events.SlimeUpgradeEvent;
public class SlimySheepStatTracker extends StatTracker<Game>
{
@ -20,7 +20,7 @@ public class SlimySheepStatTracker extends StatTracker<Game>
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onSlimeUpgrade(Snake.SlimeUpgradeEvent event)
public void onSlimeUpgrade(SlimeUpgradeEvent event)
{
if (getGame().GetState() != Game.GameState.Live)
return;