Merge branch 'clans/beta' of https://github.com/Mineplex-LLC/Minecraft-PC into clans/beta

This commit is contained in:
Ben 2016-03-24 08:59:09 +00:00
commit 7920f2729b
61 changed files with 2550 additions and 544 deletions

View File

@ -48,13 +48,6 @@ public class PlayerCache
try try
{ {
PlayerInfo playerInfo = _repository.getElement(uuid.toString()); 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; return playerInfo;
} }
catch (Exception exception) catch (Exception exception)
@ -65,7 +58,18 @@ public class PlayerCache
return null; 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() public void clean()
{ {
_repository.clean(); _repository.clean();

View File

@ -10,30 +10,52 @@ import org.bukkit.Location;
public class DataLocationMap public class DataLocationMap
{ {
private EnumMap<DyeColor, List<Location>> _dataMap; private EnumMap<DyeColor, List<Location>> _goldDataMap;
private EnumMap<DyeColor, List<Location>> _ironDataMap;
public DataLocationMap() public DataLocationMap()
{ {
_dataMap = new EnumMap<>(DyeColor.class); _goldDataMap = new EnumMap<>(DyeColor.class);
_ironDataMap = new EnumMap<>(DyeColor.class);
} }
public List<Location> getLocations(DyeColor color) public List<Location> getGoldLocations(DyeColor color)
{ {
List<Location> list = _dataMap.get(color); List<Location> list = _goldDataMap.get(color);
return list == null ? Collections.emptyList() : list; return list == null ? Collections.emptyList() : list;
} }
public void addLocation(DyeColor color, Location location) public void addGoldLocation(DyeColor color, Location location)
{ {
if (_dataMap.containsKey(color)) if (_goldDataMap.containsKey(color))
{ {
_dataMap.get(color).add(location); _goldDataMap.get(color).add(location);
} }
else else
{ {
List<Location> list = new ArrayList<>(); List<Location> list = new ArrayList<>();
list.add(location); list.add(location);
_dataMap.put(color, list); _goldDataMap.put(color, list);
}
}
public List<Location> getIronLocations(DyeColor color)
{
List<Location> list = _ironDataMap.get(color);
return list == null ? Collections.emptyList() : list;
}
public void addIronLocation(DyeColor color, Location location)
{
if (_ironDataMap.containsKey(color))
{
_ironDataMap.get(color).add(location);
}
else
{
List<Location> list = new ArrayList<>();
list.add(location);
_ironDataMap.put(color, list);
} }
} }

View File

@ -3,9 +3,9 @@ package mineplex.core.common.block.schematic;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import mineplex.core.common.block.DataLocationMap; import mineplex.core.common.block.DataLocationMap;
import mineplex.core.common.util.UtilBlock;
public class Schematic public class Schematic
{ {
@ -24,7 +24,7 @@ public class Schematic
_blockData = blockData; _blockData = blockData;
} }
public DataLocationMap paste(Location originLocation) public DataLocationMap paste(Location originLocation, boolean ignoreAir)
{ {
DataLocationMap locationMap = new DataLocationMap(); DataLocationMap locationMap = new DataLocationMap();
@ -43,31 +43,34 @@ public class Schematic
// not sure why but the math.abs is my simple fix // not sure why but the math.abs is my simple fix
int materialId = Math.abs(_blocks[index]); int materialId = Math.abs(_blocks[index]);
Material material = Material.getMaterial(materialId); if (ignoreAir && materialId == 0) // Air
if (material == null)
{ {
System.err.println("Schematic: Could not find Material [id: " + materialId + " data: " + _blockData[index] + "]");
continue; continue;
} }
else if (material == Material.GOLD_PLATE) else if (materialId == 147) // Gold Plate
{ {
// Check for data wool at location below the gold plate // Check for data wool at location below the gold plate
if (addDataWool(locationMap, originLocation, x, y - 1, z)) if (addDataWool(locationMap, true, originLocation, x, y - 1, z))
continue; continue;
} }
else if (material == Material.WOOL) else if (materialId == 148) // Iron Plate
{
// Check for data wool at location below the gold plate
if (addDataWool(locationMap, false, originLocation, x, y - 1, z))
continue;
}
else if (materialId == 35)
{ {
// Check if this is a dataloc so we can skip setting the block // Check if this is a dataloc so we can skip setting the block
int aboveIndex = getIndex(x, y + 1, z); int aboveIndex = getIndex(x, y + 1, z);
if (hasIndex(aboveIndex)) if (hasIndex(aboveIndex))
{ {
if (Math.abs(_blocks[aboveIndex]) == Material.GOLD_PLATE.getId()) if (Math.abs(_blocks[aboveIndex]) == Material.GOLD_PLATE.getId() || Math.abs(_blocks[aboveIndex]) == Material.IRON_PLATE.getId())
continue; continue;
} }
} }
Block block = originLocation.getWorld().getBlockAt(startX + x, startY + y, startZ + z); UtilBlock.setQuick(originLocation.getWorld(), startX + x, startY + y, startZ + z, materialId, _blockData[index]);
block.setTypeIdAndData(materialId, _blockData[index], false);
} }
} }
} }
@ -80,7 +83,7 @@ public class Schematic
* *
* @return true if a location was added to the DataLocationMap * @return true if a location was added to the DataLocationMap
*/ */
private boolean addDataWool(DataLocationMap map, Location origin, int x, int y, int z) private boolean addDataWool(DataLocationMap map, boolean gold, Location origin, int x, int y, int z)
{ {
int index = getIndex(x, y, z); int index = getIndex(x, y, z);
if (hasIndex(index)) if (hasIndex(index))
@ -92,7 +95,14 @@ public class Schematic
DyeColor color = DyeColor.getByWoolData(data); DyeColor color = DyeColor.getByWoolData(data);
if (color != null) if (color != null)
{ {
map.addLocation(color, origin.clone().add(x + 0.5, y + 0.5, z + 0.5)); if (gold)
{
map.addGoldLocation(color, origin.clone().add(x, y, z));
}
else
{
map.addIronLocation(color, origin.clone().add(x, y, z));
}
return true; return true;
} }
} }

View File

@ -24,16 +24,18 @@ public abstract class Objective<Plugin, Data extends ObjectiveData> implements L
private JavaPlugin _javaPlugin; private JavaPlugin _javaPlugin;
private String _name; private String _name;
private String _description; private String _description;
private String _extraDescription;
private HashMap<UUID, Data> _active; private HashMap<UUID, Data> _active;
private List<ObjectiveListener> _listeners; private List<ObjectiveListener> _listeners;
public Objective(Plugin plugin, JavaPlugin javaPlugin, String name, String description) public Objective(Plugin plugin, JavaPlugin javaPlugin, String name, String description, String extraDescription)
{ {
_plugin = plugin; _plugin = plugin;
_javaPlugin = javaPlugin; _javaPlugin = javaPlugin;
_name = name; _name = name;
_description = description; _description = description;
_extraDescription = extraDescription;
_active = new HashMap<>(); _active = new HashMap<>();
_listeners = new LinkedList<>(); _listeners = new LinkedList<>();
@ -41,6 +43,11 @@ public abstract class Objective<Plugin, Data extends ObjectiveData> implements L
javaPlugin.getServer().getPluginManager().registerEvents(this, javaPlugin); javaPlugin.getServer().getPluginManager().registerEvents(this, javaPlugin);
} }
public Objective(Plugin plugin, JavaPlugin javaPlugin, String name, String description)
{
this(plugin, javaPlugin, name, description, null);
}
public Plugin getPlugin() public Plugin getPlugin()
{ {
return _plugin; return _plugin;
@ -54,7 +61,7 @@ public abstract class Objective<Plugin, Data extends ObjectiveData> implements L
/** /**
* Get the name of this Objective * Get the name of this Objective
*/ */
public String getName() public String getName(Player player)
{ {
return _name; return _name;
} }
@ -62,11 +69,20 @@ public abstract class Objective<Plugin, Data extends ObjectiveData> implements L
/** /**
* Get the description of this Objective * Get the description of this Objective
*/ */
public String getDescription() public String getDescription(Player player)
{ {
return _description; return _description;
} }
/**
* Get the extra description for this Objective
* Extra description should be any additional useful information that isn't required to complete the objective
*/
public String getExtraDescription(Player player)
{
return _extraDescription;
}
/** /**
* Add an ObjectiveListener to this Objective * Add an ObjectiveListener to this Objective
* @param listener * @param listener
@ -92,7 +108,7 @@ public abstract class Objective<Plugin, Data extends ObjectiveData> implements L
*/ */
public void start(Player player) public void start(Player player)
{ {
System.out.println(String.format("Tutorial> [%s] started objective [%s]", player.getName(), getName())); System.out.println(String.format("Tutorial> [%s] started objective [%s]", player.getName(), getName(player)));
Data data = createDataObject(player); Data data = createDataObject(player);
_active.put(player.getUniqueId(), data); _active.put(player.getUniqueId(), data);
@ -138,7 +154,7 @@ public abstract class Objective<Plugin, Data extends ObjectiveData> implements L
protected final void finish(Player player) protected final void finish(Player player)
{ {
System.out.println(String.format("Tutorial> [%s] finished objective [%s]", player.getName(), getName())); System.out.println(String.format("Tutorial> [%s] finished objective [%s]", player.getName(), getName(player)));
_active.remove(player.getUniqueId()); _active.remove(player.getUniqueId());
@ -147,6 +163,11 @@ public abstract class Objective<Plugin, Data extends ObjectiveData> implements L
_listeners.forEach(listener -> listener.onObjectiveFinish(player, this)); _listeners.forEach(listener -> listener.onObjectiveFinish(player, this));
} }
protected final void notifyUpdate(Player player)
{
_listeners.forEach(listener -> listener.onObjectivePlayerUpdate(player, this));
}
protected abstract void customFinish(Player player); protected abstract void customFinish(Player player);
public boolean contains(Player player) public boolean contains(Player player)

View File

@ -7,32 +7,44 @@ import java.util.UUID;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
public abstract class ObjectiveGoal implements Listener public abstract class ObjectiveGoal <T extends Objective> implements Listener
{ {
private Objective _objective; private T _objective;
private HashSet<UUID> _active; private HashSet<UUID> _active;
private String _name; private String _name;
private String _description; private String _description;
private String _extraDescription;
public ObjectiveGoal(Objective objective, String name, String description) public ObjectiveGoal(T objective, String name, String description)
{
this(objective, name, description, null);
}
public ObjectiveGoal(T objective, String name, String description, String extraDescription)
{ {
_objective = objective; _objective = objective;
_active = new HashSet<>(); _active = new HashSet<>();
_name = name; _name = name;
_description = description; _description = description;
_extraDescription = extraDescription;
} }
public String getName() public String getName(Player player)
{ {
return _name; return _name;
} }
public String getDescription() public String getDescription(Player player)
{ {
return _description; return _description;
} }
public String getExtraDescription(Player player)
{
return _extraDescription;
}
public Set<UUID> getActivePlayers() public Set<UUID> getActivePlayers()
{ {
@ -51,7 +63,7 @@ public abstract class ObjectiveGoal implements Listener
public final void start(Player player) public final void start(Player player)
{ {
System.out.println(String.format("Tutorial> [%s] started objective goal [%s]", player.getName(), getName())); System.out.println(String.format("Tutorial> [%s] started objective goal [%s]", player.getName(), getName(player)));
_active.add(player.getUniqueId()); _active.add(player.getUniqueId());
customStart(player); customStart(player);
@ -65,7 +77,7 @@ public abstract class ObjectiveGoal implements Listener
{ {
if (_active.contains(player.getUniqueId())) if (_active.contains(player.getUniqueId()))
{ {
System.out.println(String.format("Tutorial> [%s] finished objective goal [%s]", player.getName(), getName())); System.out.println(String.format("Tutorial> [%s] finished objective goal [%s]", player.getName(), getName(player)));
_active.remove(player.getUniqueId()); _active.remove(player.getUniqueId());
customFinish(player); customFinish(player);
@ -74,4 +86,9 @@ public abstract class ObjectiveGoal implements Listener
} }
} }
public T getObjective()
{
return _objective;
}
} }

View File

@ -4,7 +4,20 @@ import org.bukkit.entity.Player;
public interface ObjectiveListener public interface ObjectiveListener
{ {
/**
* Called when a player starts an objective
*/
public void onObjectiveStart(Player player, Objective objective); public void onObjectiveStart(Player player, Objective objective);
/**
* Called when a player progresses in an objective
* For example, in an OrderedObjective this will be called when the player
* moves to the next ObjectiveGoal
*/
public void onObjectivePlayerUpdate(Player player, Objective objective);
/**
* Called when a player finishes an objective
*/
public void onObjectiveFinish(Player player, Objective objective); public void onObjectiveFinish(Player player, Objective objective);
} }

View File

@ -13,13 +13,18 @@ public abstract class OrderedObjective<Plugin> extends Objective<Plugin, Ordered
{ {
private List<ObjectiveGoal> _goals; private List<ObjectiveGoal> _goals;
public OrderedObjective(Plugin plugin, JavaPlugin javaPlugin, String name, String description) public OrderedObjective(Plugin plugin, JavaPlugin javaPlugin, String name, String description, String extraDescription)
{ {
super(plugin, javaPlugin, name, description); super(plugin, javaPlugin, name, description, extraDescription);
_goals = new ArrayList<>(); _goals = new ArrayList<>();
} }
public OrderedObjective(Plugin plugin, JavaPlugin javaPlugin, String name, String description)
{
this(plugin, javaPlugin, name, description, null);
}
protected void addGoal(ObjectiveGoal goal) protected void addGoal(ObjectiveGoal goal)
{ {
_goals.add(goal); _goals.add(goal);
@ -48,9 +53,34 @@ public abstract class OrderedObjective<Plugin> extends Objective<Plugin, Ordered
else else
{ {
setGoal(player, data.getIndex() + 1); setGoal(player, data.getIndex() + 1);
notifyUpdate(player);
} }
} }
@Override
public String getName(Player player)
{
OrderedObjectiveData data = getData(player);
int index = data == null ? 0 : data.getIndex();
return _goals.get(index).getName(player);
}
@Override
public String getDescription(Player player)
{
OrderedObjectiveData data = getData(player);
int index = data == null ? 0 : data.getIndex();
return _goals.get(index).getDescription(player);
}
@Override
public String getExtraDescription(Player player)
{
OrderedObjectiveData data = getData(player);
int index = data == null ? 0 : data.getIndex();
return _goals.get(index).getExtraDescription(player);
}
@Override @Override
protected void customStart(Player player) protected void customStart(Player player)
{ {
@ -77,7 +107,7 @@ public abstract class OrderedObjective<Plugin> extends Objective<Plugin, Ordered
if (contains(player)) if (contains(player))
{ {
OrderedObjectiveData data = getData(player); OrderedObjectiveData data = getData(player);
lines.add(" " + getName()); // lines.add(" " + getName());
for (int i = 0; i < _goals.size(); i++) for (int i = 0; i < _goals.size(); i++)
{ {
@ -90,7 +120,7 @@ public abstract class OrderedObjective<Plugin> extends Objective<Plugin, Ordered
else else
prefix = ChatColor.GREEN.toString(); prefix = ChatColor.GREEN.toString();
lines.add(" " + prefix + _goals.get(i).getName()); lines.add(" " + prefix + _goals.get(i).getName(player));
} }
} }
} }

View File

@ -10,13 +10,18 @@ public abstract class SingleObjective<Plugin> extends Objective<Plugin, Objectiv
{ {
private final ObjectiveData _nullData; private final ObjectiveData _nullData;
public SingleObjective(Plugin plugin, JavaPlugin javaPlugin, String name, String description) public SingleObjective(Plugin plugin, JavaPlugin javaPlugin, String name, String description, String extraDescription)
{ {
super(plugin, javaPlugin, name, description); super(plugin, javaPlugin, name, description, extraDescription);
_nullData = new ObjectiveData(); _nullData = new ObjectiveData();
} }
public SingleObjective(Plugin plugin, JavaPlugin javaPlugin, String name, String description)
{
this(plugin, javaPlugin, name, description, null);
}
@Override @Override
protected ObjectiveData createDataObject(Player player) protected ObjectiveData createDataObject(Player player)
{ {
@ -40,7 +45,7 @@ public abstract class SingleObjective<Plugin> extends Objective<Plugin, Objectiv
{ {
if (contains(player)) if (contains(player))
{ {
lines.add(" " + getName()); lines.add(" " + getName(player));
} }
} }
} }

View File

@ -3,6 +3,7 @@ package mineplex.core.common.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Queue;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -30,6 +31,7 @@ import org.bukkit.material.Bed;
import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks; import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.EnumDirection; import net.minecraft.server.v1_8_R3.EnumDirection;
import net.minecraft.server.v1_8_R3.IBlockData;
import net.minecraft.server.v1_8_R3.Item; import net.minecraft.server.v1_8_R3.Item;
import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.MinecraftKey; import net.minecraft.server.v1_8_R3.MinecraftKey;
@ -1463,4 +1465,19 @@ public class UtilBlock
return state.update(false, false); return state.update(false, false);
} }
public static void setQuick(World world, int x, int y, int z, int type, byte data)
{
int cx = x >> 4;
int cz = z >> 4;
if (!world.isChunkLoaded(cx, cz))
{
world.loadChunk(cx, cz, true);
}
net.minecraft.server.v1_8_R3.Chunk chunk = ((CraftWorld) world).getHandle().getChunkAt(x >> 4, z >> 4);
BlockPosition pos = new BlockPosition(x, y, z);
IBlockData ibd = net.minecraft.server.v1_8_R3.Block.getById(type).fromLegacyData(data);
chunk.a(pos, ibd);
}
} }

View File

@ -789,4 +789,29 @@ public class UtilPlayer
return null; 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 = private final static BlockFace[] radial =
{ {
BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, BlockFace.SOUTH,
BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST 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) 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) public static ArrayList<Location> getSphereBlocks(Location loc, double width, 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)
{ {
ArrayList<Location> circleblocks = new ArrayList<Location>(); ArrayList<Location> circleblocks = new ArrayList<Location>();
double cx = loc.getBlockX(); double cx = loc.getBlockX();
double cy = loc.getBlockY(); double cy = loc.getBlockY();
double cz = loc.getBlockZ(); 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); circleblocks.add(l);
} }
} }
@ -75,7 +77,8 @@ public class UtilShapes
right = radial[high]; right = radial[high];
return new BlockFace[] return new BlockFace[]
{ {
left, right left,
right
}; };
} }
} }
@ -87,13 +90,19 @@ public class UtilShapes
BlockFace[] faces = getSideBlockFaces(facing); BlockFace[] faces = getSideBlockFaces(facing);
return new Block[] 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) 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, public static ArrayList<Location> getLinesDistancedPoints(Location startingPoint, Location endingPoint,
@ -133,6 +142,24 @@ public class UtilShapes
return locs; 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) public static ArrayList<Location> getDistancedCircle(Location center, double pointsDistance, double circleRadius)
{ {
return getPointsInCircle(center, (int) ((circleRadius * Math.PI * 2) / pointsDistance), circleRadius); return getPointsInCircle(center, (int) ((circleRadius * Math.PI * 2) / pointsDistance), circleRadius);
@ -157,12 +184,14 @@ public class UtilShapes
new int[] new int[]
{ {
allowDiagonal ? facing.getModX() : facing.getModZ(), allowDiagonal ? 0 : -facing.getModX() allowDiagonal ? facing.getModX() : facing.getModZ(),
allowDiagonal ? 0 : -facing.getModX()
}, },
new int[] 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 = new BlockFace[]
{ {
faces[1], faces[0] faces[1],
faces[0]
}; };
} }
@ -228,7 +258,8 @@ public class UtilShapes
return new Block[] 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.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; 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.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; 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); super("Custom Tag Fix", plugin);
packetHandler.addPacketHandler(this, true, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class, packetHandler.addPacketHandler(this, true, PacketPlayOutEntityDestroy.class, PacketPlayOutEntityMetadata.class,
PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutNamedEntitySpawn.class,
PacketPlayOutNamedEntitySpawn.class, PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class); PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class, PacketPlayOutNewAttachEntity.class);
// NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this); // NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
// NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this); // NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
NCPHookManager.addHook(CheckType.ALL, this); NCPHookManager.addHook(CheckType.ALL, this);
} }
@ -121,7 +122,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
@EventHandler @EventHandler
public void ncpExemptVelocity(final PlayerVelocityEvent event) 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())) if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId()))
{ {
_exemptTimeMap.put(event.getPlayer().getUniqueId(), _exemptTimeMap.put(event.getPlayer().getUniqueId(),
@ -256,15 +258,16 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
return; return;
} }
int newId = UtilEnt.getNewEntityId(); Integer[] ids = new Integer[]
{
UtilEnt.getNewEntityId(),
UtilEnt.getNewEntityId()
};
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[] _entityMap.get(owner.getName()).put(spawnPacket.a, ids);
{
newId
});
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true, -1); sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids);
break; break;
} }
} }
@ -301,17 +304,16 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
return; return;
} }
int newId = UtilEnt.getNewEntityId(); Integer[] ids = new Integer[]
int newId2 = UtilEnt.getNewEntityId(); {
UtilEnt.getNewEntityId(),
UtilEnt.getNewEntityId()
};
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[] _entityMap.get(owner.getName()).put(spawnPacket.a, ids);
{
newId,
newId2
});
sendProtocolPackets(owner, spawnPacket.a, newId2, entityName, verifier, true, newId); sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids);
break; break;
} }
} }
@ -331,13 +333,13 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
} }
String newName = currentName; String newName = currentName;
boolean newDisplay = isDisplaying; boolean displayName = isDisplaying;
for (WatchableObject watchable : (List<WatchableObject>) metaPacket.b) for (WatchableObject watchable : (List<WatchableObject>) metaPacket.b)
{ {
if (watchable.a() == 3 && watchable.b() instanceof Byte) 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) 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 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 name is still being displayed
if (newDisplay) if (displayName)
{ {
Integer[] newId; Integer[] newId;
@ -363,6 +365,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
newId = new Integer[] newId = new Integer[]
{ {
UtilEnt.getNewEntityId(),
UtilEnt.getNewEntityId() UtilEnt.getNewEntityId()
}; };
@ -370,7 +373,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
} }
_entityNameMap.get(owner.getName()).put(metaPacket.a, newName); _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 else
{ // Lets delete it { // 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 // c = rider, b = ridden
// When detaching, c is sent, b is -1 // When detaching, c is sent, b is -1
@ -472,27 +491,27 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
int vehicleId = -1; 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); 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), sendProtocolPackets(owner, vehicleId, _entityNameMap.get(owner.getName()).get(vehicleId), verifier, true,
verifier, true, ids.length > 1 ? ids[0] : -1); ids);
} }
else 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]; 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, private void sendProtocolPackets(final Player owner, final int entityId, String entityName, final PacketVerifier packetList,
final PacketVerifier packetList, final boolean newPacket, final int squidId) final boolean newPacket, final Integer[] entityIds)
{ {
CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName); CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
_plugin.getServer().getPluginManager().callEvent(event); _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())); 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(1, Short.valueOf((short) 300), Entity.META_AIR, 0);
watcher.a(2, finalEntityName, Entity.META_CUSTOMNAME, finalEntityName); watcher.a(2, finalEntityName, Entity.META_CUSTOMNAME, finalEntityName);
watcher.a(3, (byte) 1, Entity.META_CUSTOMNAME_VISIBLE, true); 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 (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())); 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(); PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = squidId; spawnPacket.a = entityIds[1];
spawnPacket.b = (byte) EntityType.SQUID.getTypeId(); 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.l = squidWatcher;
spawnPacket.uuid = UUID.randomUUID(); spawnPacket.uuid = UUID.randomUUID();
UtilPlayer.sendPacket(owner, spawnPacket); UtilPlayer.sendPacket(owner, spawnPacket);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); if (UtilPlayer.is1_9(owner))
vehiclePacket.a = 0; {
vehiclePacket.b = spawnPacket.a; UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityId, new int[]
vehiclePacket.c = entityId; {
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(); PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = newEntityId; spawnPacket.a = entityIds[0];
spawnPacket.b = (byte) 30; 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.l = watcher;
spawnPacket.uuid = UUID.randomUUID(); spawnPacket.uuid = UUID.randomUUID();
UtilPlayer.sendPacket(owner, spawnPacket); UtilPlayer.sendPacket(owner, spawnPacket);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); if (UtilPlayer.is1_9(owner))
vehiclePacket.a = 0; {
vehiclePacket.b = spawnPacket.a; UtilPlayer.sendPacket(owner, new PacketPlayOutNewAttachEntity(entityIds[1], new int[]
vehiclePacket.c = squidId >= 0 ? squidId : entityId; {
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 else
{ {
PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(); PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata();
entityMetadata.a = newEntityId; entityMetadata.a = entityIds[0];
entityMetadata.b = watcher.c(); entityMetadata.b = watcher.c();
packetList.bypassProcess(entityMetadata); packetList.bypassProcess(entityMetadata);

View File

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

View File

@ -1,8 +1,8 @@
package mineplex.core.account; package mineplex.core.account;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@ -49,9 +49,8 @@ public class CoreClientManager extends MiniPlugin
private NautHashMap<String, CoreClient> _clientList; private NautHashMap<String, CoreClient> _clientList;
private HashSet<String> _duplicateLoginGlitchPreventionList; private HashSet<String> _duplicateLoginGlitchPreventionList;
private NautHashMap<String, ILoginProcessor> _loginProcessors = new NautHashMap<String, ILoginProcessor>(); private List<ILoginProcessor> _loginProcessors = new ArrayList<>();
private LinkedList<IQuerylessLoginProcessor> _querylessLoginProcessors = new LinkedList<IQuerylessLoginProcessor>();
private Object _clientLock = new Object(); private Object _clientLock = new Object();
private static AtomicInteger _clientsConnecting = new AtomicInteger(0); private static AtomicInteger _clientsConnecting = new AtomicInteger(0);
@ -260,7 +259,7 @@ public class CoreClientManager extends MiniPlugin
CoreClient client = Add(playerName); CoreClient client = Add(playerName);
client.SetRank(Rank.valueOf(token.Rank), false); 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 // JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
@ -332,7 +331,7 @@ public class CoreClientManager extends MiniPlugin
CoreClient client = Add(playerName); CoreClient client = Add(playerName);
client.SetRank(Rank.valueOf(token.Rank), false); 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 // JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
@ -373,12 +372,12 @@ public class CoreClientManager extends MiniPlugin
_clientLoginLock.put(client.GetPlayerName(), new Object()); _clientLoginLock.put(client.GetPlayerName(), new Object());
ClientToken token = null; ClientToken token = null;
Gson gson = new Gson(); Gson gson = new Gson();
runAsync(new Runnable() runAsync(new Runnable()
{ {
public void run() 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()); _clientLoginLock.remove(client.GetPlayerName());
} }
}); });
@ -386,7 +385,8 @@ public class CoreClientManager extends MiniPlugin
TimingManager.start(client.GetPlayerName() + " GetClient."); TimingManager.start(client.GetPlayerName() + " GetClient.");
String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress); String response = _repository.GetClient(client.GetPlayerName(), uuid, ipAddress);
TimingManager.stop(client.GetPlayerName() + " GetClient."); TimingManager.stop(client.GetPlayerName() + " GetClient.");
TimingManager.start(client.GetPlayerName() + " Event.");
token = gson.fromJson(response, ClientToken.class); token = gson.fromJson(response, ClientToken.class);
client.SetRank(Rank.valueOf(token.Rank), false); client.SetRank(Rank.valueOf(token.Rank), false);
@ -395,7 +395,9 @@ public class CoreClientManager extends MiniPlugin
// JSON sql response // JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); 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) while (_clientLoginLock.containsKey(client.GetPlayerName()) && System.currentTimeMillis() - timeStart < 15000)
{ {
try try
@ -407,6 +409,7 @@ public class CoreClientManager extends MiniPlugin
e.printStackTrace(); e.printStackTrace();
} }
} }
TimingManager.stop(client.GetPlayerName() + " While Loop.");
if (_clientLoginLock.containsKey(client.GetPlayerName())) if (_clientLoginLock.containsKey(client.GetPlayerName()))
{ {
@ -646,14 +649,9 @@ public class CoreClientManager extends MiniPlugin
public void addStoredProcedureLoginProcessor(ILoginProcessor processor) 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) public boolean hasRank(Player player, Rank rank)
{ {
CoreClient client = Get(player); CoreClient client = Get(player);
@ -662,10 +660,4 @@ public class CoreClientManager extends MiniPlugin
return client.GetRank().has(rank); 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.Statement;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import com.google.gson.reflect.TypeToken;
import org.bukkit.plugin.java.JavaPlugin; 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.ILoginProcessor;
import mineplex.core.account.IQuerylessLoginProcessor;
import mineplex.core.account.repository.token.LoginToken; import mineplex.core.account.repository.token.LoginToken;
import mineplex.core.account.repository.token.RankUpdateToken; import mineplex.core.account.repository.token.RankUpdateToken;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback; 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.database.MinecraftRepository;
import mineplex.core.server.remotecall.JsonWebCall; import mineplex.core.server.remotecall.JsonWebCall;
import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.DBPool;
@ -60,100 +57,66 @@ public class AccountRepository extends MinecraftRepository
//executeUpdate(CREATE_ACCOUNT_TABLE); //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; int accountId = -1;
try (
Connection connection = getConnection(); try (Connection connection = getConnection(); Statement statement = connection.createStatement())
Statement statement = connection.createStatement()
)
{ {
statement.execute("SELECT id FROM accounts WHERE accounts.uuid = '" + uuid + "' LIMIT 1;"); int cachedId = PlayerCache.getInstance().getAccountId(uuid);
ResultSet resultSet = statement.getResultSet(); if (cachedId > 0)
while (resultSet.next())
{ {
accountId = resultSet.getInt(1); accountId = cachedId;
System.out.println("Loaded Account ID From Cache [" + name + " - " + accountId + "]");
} }
else
if (accountId == -1)
{ {
final List<Integer> tempList = new ArrayList<Integer>(1); // 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;");
executeInsert(ACCOUNT_LOGIN_NEW, new ResultSetCallable() ResultSet resultSet = statement.getResultSet();
{
@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 + "';"
);
*/
String loginString = "UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE id = '" + accountId + "';"; if (resultSet.next())
for (ILoginProcessor loginProcessor : loginProcessors.values())
{
loginString += loginProcessor.getQuery(accountId, uuid, name);
}
statement.execute(loginString);
/*
while (true)
{
if (statementStatus)
{ {
System.out.println("ResultSet : " + statement.getResultSet().getMetaData().getColumnCount() + " columns:"); accountId = resultSet.getInt(1);
for (int i = 0; i < statement.getResultSet().getMetaData().getColumnCount(); i++)
{
System.out.println(statement.getResultSet().getMetaData().getColumnName(i + 1));
}
} }
else else
{ {
if (statement.getUpdateCount() == -1) // Player doesn't exist in our database, add them to the accounts table
break; 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.getUpdateCount();
statement.getMoreResults(); 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) catch (Exception exception)
@ -190,7 +153,7 @@ public class AccountRepository extends MinecraftRepository
public UUID getClientUUID(String name) 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() executeQuery(SELECT_ACCOUNT_UUID_BY_NAME, new ResultSetCallable()
{ {
@ -199,12 +162,15 @@ public class AccountRepository extends MinecraftRepository
{ {
while (resultSet.next()) while (resultSet.next())
{ {
uuid.Set(UUID.fromString(resultSet.getString(1))); uuids.add(UUID.fromString(resultSet.getString(1)));
} }
} }
}, new ColumnVarChar("name", 100, name)); }, 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) 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) if (client.getHologram() == null)
{ {
double yAdd = 2.18; double yAdd = 2.3;
hologram = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), ""); hologram = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), "");
hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST); hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST);
hologram.addPlayer(player); 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.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import mineplex.core.common.util.UtilMath;
public class DisguiseWither extends DisguiseMonster public class DisguiseWither extends DisguiseMonster
{ {
public DisguiseWither(org.bukkit.entity.Entity entity) public DisguiseWither(org.bukkit.entity.Entity entity)
@ -24,6 +26,7 @@ public class DisguiseWither extends DisguiseMonster
public void setInvulTime(int i) 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); 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.F;
import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
public class GemCommand extends CommandBase<DonationManager> public class GemCommand extends CommandBase<DonationManager>
@ -32,7 +33,11 @@ public class GemCommand extends CommandBase<DonationManager>
String gemsString = args[1]; String gemsString = args[1];
Player target = UtilPlayer.searchExact(targetName); Player target = UtilPlayer.searchExact(targetName);
if (target == null) if (targetName.equalsIgnoreCase("@a"))
{
rewardAllGems(caller, gemsString);
}
else if (target == null)
{ {
UUID uuid = UUIDFetcher.getUUIDOf(targetName); UUID uuid = UUIDFetcher.getUUIDOf(targetName);
if (uuid != null) 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) private void rewardGems(final Player caller, final Player target, final String targetName, final UUID uuid, String gemsString)
{ {
try try

View File

@ -6,8 +6,8 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class ShardCommand extends CommandBase<DonationManager> public class ShardCommand extends CommandBase<DonationManager>
@ -30,7 +30,11 @@ public class ShardCommand extends CommandBase<DonationManager>
final String coinsString = args[1]; final String coinsString = args[1];
Player target = UtilPlayer.searchExact(targetName); 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() 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) private void rewardCoins(final Player caller, final Player target, final String targetName, final int accountId, String coinsString)
{ {
try try

View File

@ -21,6 +21,7 @@ public enum GameDisplay
Dragons("Dragons", Material.ENDER_STONE, (byte)0, GameCategory.ARCADE, 13), Dragons("Dragons", Material.ENDER_STONE, (byte)0, GameCategory.ARCADE, 13),
DragonsTeams("Dragons Teams", Material.DRAGON_EGG, (byte)0, GameCategory.TEAM_VARIANT, 14), 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), 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), Evolution("Evolution", Material.EMERALD, (byte)0, GameCategory.ARCADE, 16),
Gravity("Gravity", Material.ENDER_PORTAL_FRAME, (byte)0, GameCategory.EXTRA, 18), Gravity("Gravity", Material.ENDER_PORTAL_FRAME, (byte)0, GameCategory.EXTRA, 18),
Halloween("Halloween Horror", Material.PUMPKIN, (byte)0, GameCategory.CLASSICS, 19), 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.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.inventory.InventoryManager; import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.data.Item; 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!")); 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) else if (player != null)
{ {
Plugin.addItemToInventory(player, item.Name, amount); Plugin.addItemToInventory(player, item.Name, amount);

View File

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

View File

@ -109,7 +109,7 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
if (_resourcePackRequired) if (_resourcePackRequired)
{ {
if (event.getStatus() == Status.ACCEPTED) if (event.getStatus() == Status.ACCEPTED || event.getStatus() == Status.SUCCESSFULLY_LOADED)
{ {
_resourcePackNoResponse.remove(player.getName()); _resourcePackNoResponse.remove(player.getName());
} }

View File

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

View File

@ -4,6 +4,7 @@ import java.util.List;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
@ -101,12 +102,6 @@ public class TreasureLocation implements Listener
return; return;
} }
if (!chargeAccount(player, treasureType))
{
player.sendMessage(F.main("Treasure", "You dont have any chests to open!"));
return;
}
TreasureStartEvent event = new TreasureStartEvent(player); TreasureStartEvent event = new TreasureStartEvent(player);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
@ -115,48 +110,73 @@ public class TreasureLocation implements Listener
return; return;
} }
// Treasure is now being opened chargeAccount(player, treasureType, new Callback<Boolean>()
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))
{ {
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()); int itemCount = _inventoryManager.Get(player).getItemCount(treasureType.getItemName());
if (itemCount > 0) if (itemCount > 0)
{ {
_inventoryManager.addItemToInventory(player, treasureType.getItemName(), -1); // Should always handle the callback for us
return true; _inventoryManager.addItemToInventory(callback, player, treasureType.getItemName(), -1);
}
else
{
callback.run(false);
} }
return false;
} }
private void setHoloChestVisible(boolean visible) private void setHoloChestVisible(boolean visible)

View File

@ -16,6 +16,7 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.event.ClanCreatedEvent; import mineplex.game.clans.clans.event.ClanCreatedEvent;
import mineplex.game.clans.clans.event.ClanCreationCompleteEvent;
import mineplex.game.clans.clans.event.ClanDeleteEvent; import mineplex.game.clans.clans.event.ClanDeleteEvent;
import mineplex.game.clans.clans.event.ClanJoinEvent; import mineplex.game.clans.clans.event.ClanJoinEvent;
import mineplex.game.clans.clans.event.ClanLeaveEvent; import mineplex.game.clans.clans.event.ClanLeaveEvent;
@ -195,6 +196,9 @@ public class ClansDataAccessLayer
} }
if (callback != null) callback.run(clanInfo); if (callback != null) callback.run(clanInfo);
ClanCreationCompleteEvent event = new ClanCreationCompleteEvent(token, Bukkit.getPlayer(creator));
UtilServer.getServer().getPluginManager().callEvent(event);
} }
}); });
} }

View File

@ -170,6 +170,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
private DonationManager _donationManager; private DonationManager _donationManager;
private NetherManager _netherManager; private NetherManager _netherManager;
private DamageManager _damageManager; private DamageManager _damageManager;
private SiegeManager _siegeManager;
private ClansBlacklist _blacklist; private ClansBlacklist _blacklist;
@ -403,7 +404,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict"); Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict");
new SiegeManager(this); _siegeManager = new SiegeManager(this);
// _netherManager = new NetherManager(this); // _netherManager = new NetherManager(this);
} }
@ -1305,4 +1306,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{ {
return _blacklist; return _blacklist;
} }
public SiegeManager getSiegeManager()
{
return _siegeManager;
}
} }

View File

@ -0,0 +1,194 @@
package mineplex.game.clans.clans.event;
import java.sql.Timestamp;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.game.clans.core.repository.tokens.ClanToken;
public class ClanCreationCompleteEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _founder;
private int _id;
private String _name;
private String _description;
private String _home;
private boolean _admin;
private int _energy;
private int _kills;
private int _murders;
private int _deaths;
private int _warWins;
private int _warLosses;
private Timestamp _dateCreated;
private Timestamp _lastOnline;
public ClanCreationCompleteEvent(ClanToken token, Player founder)
{
_founder = founder;
_id = token.Id;
_name = token.Name;
_description = token.Description;
_home = token.Home;
_admin = token.Admin;
_energy = token.Energy;
_kills = token.Kills;
_murders = token.Murder;
_deaths = token.Deaths;
_warWins = token.WarWins;
_warLosses = token.WarLosses;
_dateCreated = token.DateCreated;
_lastOnline = token.LastOnline;
}
public Player getFounder()
{
return _founder;
}
public int getId()
{
return _id;
}
public void setId(int id)
{
_id = id;
}
public String getName()
{
return _name;
}
public void setName(String name)
{
_name = name;
}
public String getDescription()
{
return _description;
}
public void setDescription(String description)
{
_description = description;
}
public String getHome()
{
return _home;
}
public void setHome(String home)
{
_home = home;
}
public boolean isAdmin()
{
return _admin;
}
public void setAdmin(boolean admin)
{
_admin = admin;
}
public int getEnergy()
{
return _energy;
}
public void setEnergy(int energy)
{
_energy = energy;
}
public int getKills()
{
return _kills;
}
public void setKills(int kills)
{
_kills = kills;
}
public int getMurders()
{
return _murders;
}
public void setMurders(int murders)
{
_murders = murders;
}
public int getDeaths()
{
return _deaths;
}
public void setDeaths(int deaths)
{
_deaths = deaths;
}
public int getWarWins()
{
return _warWins;
}
public void setWarWins(int warWins)
{
_warWins = warWins;
}
public int getWarLosses()
{
return _warLosses;
}
public void setWarLosses(int warLosses)
{
_warLosses = warLosses;
}
public Timestamp getDateCreated()
{
return _dateCreated;
}
public void setDateCreated(Timestamp dateCreated)
{
_dateCreated = dateCreated;
}
public Timestamp getLastOnline()
{
return _lastOnline;
}
public void setLastOnline(Timestamp lastOnline)
{
_lastOnline = lastOnline;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -19,13 +19,15 @@ public class ClansBlacklist extends MiniPlugin
public ClansBlacklist(JavaPlugin plugin) public ClansBlacklist(JavaPlugin plugin)
{ {
super("Clan Name Blacklist", plugin); super("Clan Name Blacklist", plugin);
_repository = new ClanNameBlacklistRepository(plugin, this);
} }
// Fetch new blacklisted clans every 16 seconds (in case someone blacklists a clan name on a different server) // Fetch new blacklisted clans every 16 seconds (in case someone blacklists a clan name on a different server)
@EventHandler @EventHandler
public void update(UpdateEvent event) public void update(UpdateEvent event)
{ {
if (event.getType() != UpdateType.SLOWER) if (event.getType() == UpdateType.SLOWER)
{ {
runAsync(() -> _repository.loadNames(this::setBlacklist)); runAsync(() -> _repository.loadNames(this::setBlacklist));
} }

View File

@ -133,10 +133,18 @@ public abstract class Tutorial implements Listener, ObjectiveListener
@Override @Override
public void onObjectiveStart(Player player, Objective objective) public void onObjectiveStart(Player player, Objective objective)
{ {
String title = objective.getName(); String title = objective.getName(player);
String desc = objective.getDescription(); String desc = objective.getDescription(player);
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f); player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f);
_message.setMessage(player, title, desc, 100, true); _message.setMessage(player, title, desc, 20, true);
}
@Override
public void onObjectivePlayerUpdate(Player player, Objective objective)
{
String desc = objective.getDescription(player);
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f);
_message.setMessage(player, "", desc, 20, true);
} }
private void finish(Player player) private void finish(Player player)
@ -217,6 +225,11 @@ public abstract class Tutorial implements Listener, ObjectiveListener
_worldManager = worldManager; _worldManager = worldManager;
} }
public TutorialWorldManager getWorldManager()
{
return _worldManager;
}
public TutorialRegion getRegion(Player player) public TutorialRegion getRegion(Player player)
{ {
return _playerSessionMap.get(player).getRegion(); return _playerSessionMap.get(player).getRegion();

View File

@ -33,7 +33,7 @@ public class TutorialRegion
private void pasteSchematic() private void pasteSchematic()
{ {
_locationMap = _schematic.paste(getOrigin()); _locationMap = _schematic.paste(getOrigin(), true);
} }
/** /**

View File

@ -56,14 +56,16 @@ public class TutorialWorldManager extends MiniPlugin
_regionStack = new Stack<>(); _regionStack = new Stack<>();
// Populate the stack with 100 available tutorial regions // Populate the stack with 100 available tutorial regions
for (int x = 0; x < 10; x++) for (int x = 0; x < 1; x++)
{ {
for (int z = 0; z < 10; z++) for (int z = 0; z < 1; z++)
{ {
double xLoc = (x - 5) * 100; // 100x100 regions long time = System.currentTimeMillis();
double zLoc = (z - 5) * 100; double xLoc = (x) * 1000; // 1000x1000 regions
double zLoc = (z) * 1000;
_regionStack.add(new TutorialRegion(_schematic, new Location(_tutorialWorld, xLoc, 64, zLoc))); _regionStack.add(new TutorialRegion(_schematic, new Location(_tutorialWorld, xLoc, 64, zLoc)));
System.out.println("Finished Generating Region: " + ((x * 10) + z) + ". Took " + (System.currentTimeMillis() - time) + " ms");
} }
} }
} }
@ -88,13 +90,8 @@ public class TutorialWorldManager extends MiniPlugin
log("Returned " + region.toString()); log("Returned " + region.toString());
} }
@EventHandler public World getTutorialWorld()
public void onCommand(PlayerCommandPreprocessEvent event)
{ {
if (event.getPlayer().getName().contains("Phinary") && event.getMessage().contains("tw")) return _tutorialWorld;
{
event.getPlayer().teleport(new Location(_tutorialWorld, 0, 64, 0));
}
} }
} }

View File

@ -0,0 +1,721 @@
package mineplex.game.clans.tutorial.map;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.base.Objects;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.Iterables;
import com.google.common.collect.Multisets;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.portal.ServerTransferEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.IBlockData;
import net.minecraft.server.v1_8_R3.MaterialMapColor;
import net.minecraft.server.v1_8_R3.PersistentCollection;
public class TutorialMapManager extends MiniPlugin
{
private int _blocksScan = 16;
private Comparator<Entry<Integer, Integer>> _comparator;
private int _halfMapSize;
private int[][] _heightMap;
private boolean _loadWorld = true;
private HashMap<Integer, Byte[][]> _map = new HashMap<Integer, Byte[][]>();
private short _mapId = (short) UtilMath.r(Short.MAX_VALUE);
private ArrayList<Entry<Integer, Integer>> _scanList = new ArrayList<Entry<Integer, Integer>>();
private World _world;
private int _centerX;
private int _centerZ;
private int _scale;
public TutorialMapManager(JavaPlugin plugin, World world, int minX, int minZ, int maxX, int maxZ)
{
super("TutorialMapManager", plugin);
_centerX = minX + ((maxX - minX) / 2);
_centerZ = minZ + ((maxZ - minZ) / 2);
_centerX = (int) (Math.round(_centerX / 16D) * 16);
_centerZ = (int) (Math.round(_centerZ / 16D) * 16);
_halfMapSize = (int) (Math.ceil(Math.max((maxX - minX) / 2D, (maxZ - minZ) / 2D) / 16D) * 16);
ArrayList<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer, Integer>>();
for (int scale = 1; scale <= 16; scale++)
{
int s = _halfMapSize;
if ((s / scale) > 127)
continue;
while (s < 10000 && (s % 16 != 0 || s % scale != 0))
{
s += 16;
}
if (s < 10000)
{
list.add(new HashMap.SimpleEntry(scale, s));
}
}
if (list.isEmpty())
{
_scale = 16;
_halfMapSize = 127 * 8;
}
else
{
Collections.sort(list, new Comparator<Entry<Integer, Integer>>()
{
@Override
public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2)
{
return Integer.compare(o1.getValue(), o2.getValue());
}
});
_scale = list.get(0).getKey();
_halfMapSize = list.get(0).getValue();
System.out.print(
"Using scale " + _scale + ", Size: " + _halfMapSize + ", CenterX: " + _centerX + ", CenterZ: " + _centerZ);
}
_heightMap = new int[(_halfMapSize * 2) + 16][];
_comparator = new Comparator<Entry<Integer, Integer>>()
{
@Override
public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2)
{
// Render the places outside the map first to speed up visual errors fixing
int outsideMap = Boolean.compare(o1.getValue() < -_halfMapSize, o2.getValue() < -_halfMapSize);
if (outsideMap != 0)
{
return -outsideMap;
}
double dist1 = 0;
double dist2 = 0;
for (Player player : UtilServer.getPlayers())
{
dist1 += getDistance(o1, player.getLocation().getX(), player.getLocation().getZ());
dist2 += getDistance(o2, player.getLocation().getX(), player.getLocation().getZ());
}
if (dist1 != dist2)
{
return Double.compare(dist1, dist2);
}
dist1 = getDistance(o1, 0, 0);
dist2 = getDistance(o2, 0, 0);
return Double.compare(dist1, dist2);
}
};
for (int x = -_halfMapSize; x < _halfMapSize; x += _blocksScan)
{
for (int z = -_halfMapSize - 16; z < _halfMapSize; z += (z < -_halfMapSize ? 16 : _blocksScan))
{
_scanList.add(new HashMap.SimpleEntry(x, z));
}
}
for (int s = 1; s <= 2; s++)
{
if (s == 2)
{
s = getScale();
if (s == 1)
break;
}
int size = (_halfMapSize * 2) / s;
Byte[][] bytes = new Byte[size][];
for (int i = 0; i < size; i++)
{
bytes[i] = new Byte[size];
}
_map.put(s, bytes);
}
for (int i = 0; i < _heightMap.length; i++)
{
_heightMap[i] = new int[_heightMap.length];
}
_world = world;
try
{
File foundFile = null;
for (File f : new File("world/data").listFiles())
{
if (f.getName().startsWith("map_"))
{
foundFile = f;
break;
}
}
if (foundFile == null)
{
PersistentCollection collection = ((CraftWorld) _world).getHandle().worldMaps;
Field f = collection.getClass().getDeclaredField("d");
f.setAccessible(true);
((HashMap) f.get(collection)).put("map", (short) 0);
}
MapView view = Bukkit.createMap(_world);
_mapId = view.getId();
setupRenderer(view);
for (int i = 0; i < 100; i++)
{
setupRenderer(Bukkit.createMap(_world));// Ensures the following 100 maps are unused
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
rebuildScan();
}
private void setupRenderer(MapView view)
{
for (MapRenderer renderer : view.getRenderers())
{
view.removeRenderer(renderer);
}
view.addRenderer(new TutorialMapRenderer(this));
}
public int getScale()
{
return _scale;
}
public int getX()
{
return _centerX;
}
public int getZ()
{
return _centerZ;
}
@EventHandler
public void preventMapInItemFrame(PlayerInteractEntityEvent event)
{
if (!(event.getRightClicked() instanceof ItemFrame))
return;
ItemStack item = event.getPlayer().getItemInHand();
if (item == null || item.getType() != Material.MAP || item.getDurability() < _mapId || item.getDurability() != _mapId)
return;
event.setCancelled(true);
}
/**
* Get the center of the map.
*/
public int calcMapCenter(int zoom, int cord)
{
int mapSize = _halfMapSize / zoom; // This is how large the map is in pixels
int mapCord = cord / zoom; // This is pixels from true center of map, not held map
int fDiff = mapSize - -mapCord;
int sDiff = mapSize - mapCord;
double chunkBlock = cord & 0xF;
cord -= chunkBlock;
chunkBlock /= zoom;
/*if ((fDiff < 64 || sDiff < 64) && (Math.abs(fDiff - sDiff) > 1))
{
cord += (fDiff > sDiff ? Math.floor(chunkBlock) : Math.ceil(chunkBlock));
}
else*/
{
cord += (int) Math.floor(chunkBlock) * zoom;
}
while ((fDiff < 64 || sDiff < 64) && (Math.abs(fDiff - sDiff) > 1))
{
int change = (fDiff > sDiff ? -zoom : zoom);
cord += change;
mapCord = cord / zoom;
fDiff = mapSize - -mapCord;
sDiff = mapSize - mapCord;
}
return cord;
}
private void colorWorldHeight(int zoom, int startingX, int startingZ)
{
if (zoom == 0)
zoom = 1;
Byte[][] map = _map.get(zoom);
for (int x = startingX; x < startingX + _blocksScan; x += zoom)
{
double d0 = 0;
// Prevents ugly lines for the first line of Z
for (int addX = 0; addX < zoom; addX++)
{
for (int addZ = 0; addZ < zoom; addZ++)
{
int hX = x + addX + _halfMapSize;
int hZ = (startingZ - zoom) + addZ + _halfMapSize;
if (hX >= _halfMapSize * 2 || hZ >= _halfMapSize * 2)
{
continue;
}
d0 += _heightMap[hX + 16][hZ + 16] / (zoom * zoom);
}
}
for (int z = startingZ; z < startingZ + _blocksScan; z += zoom)
{
// Water depth colors not included
double d1 = 0;
for (int addX = 0; addX < zoom; addX++)
{
for (int addZ = 0; addZ < zoom; addZ++)
{
int hX = x + addX + _halfMapSize;
int hZ = z + addZ + _halfMapSize;
if (hX >= _halfMapSize * 2 || hZ >= _halfMapSize * 2)
{
continue;
}
d1 += _heightMap[hX + 16][hZ + 16] / (zoom * zoom);
}
}
double d2 = (d1 - d0) * 4.0D / (zoom + 4) + ((x + z & 0x1) - 0.5D) * 0.4D;
byte b0 = 1;
d0 = d1;
if (d2 > 0.6D)
{
b0 = 2;
}
else if (d2 > 1.2D)
{
b0 = 3;
}
else if (d2 < -0.6D)
{
b0 = 0;
}
int origColor = map[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] - 1;
/*if (color < 4)
{
d2 = waterDepth * 0.1D + (k1 + j2 & 0x1) * 0.2D;
b0 = 1;
if (d2 < 0.5D)
{
b0 = 2;
}
if (d2 > 0.9D)
{
b0 = 0;
}
}*/
byte color = (byte) (origColor + b0);
map[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color;
}
}
}
private void drawWorldScale(int zoom, int startingX, int startingZ)
{
Byte[][] first = _map.get(1);
Byte[][] second = _map.get(zoom);
for (int x = startingX; x < startingX + _blocksScan; x += zoom)
{
for (int z = startingZ; z < startingZ + _blocksScan; z += zoom)
{
HashMultiset<Byte> hashmultiset = HashMultiset.create();
for (int addX = 0; addX < zoom; addX++)
{
for (int addZ = 0; addZ < zoom; addZ++)
{
int pX = x + addX + _halfMapSize;
int pZ = z + addZ + _halfMapSize;
if (pX >= first.length || pZ >= first.length)
{
continue;
}
Byte b = first[pX][pZ];
if (b == null)
continue;
hashmultiset.add(b);
}
}
Byte color = Iterables.getFirst(Multisets.copyHighestCountFirst(hashmultiset), (byte) 0);
second[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color;
}
}
}
@EventHandler
public void dropItem(ItemSpawnEvent event)
{
ItemStack item = event.getEntity().getItemStack();
if (item != null && item.getType() == Material.MAP && item.getDurability() == _mapId)
{
event.getEntity().remove();
}
}
private double getDistance(double x1, double z1, double x2, double z2)
{
x1 = (x1 - x2);
z1 = (z1 - z2);
return (x1 * x1) + (z1 * z1);
}
private double getDistance(Entry<Integer, Integer> entry, double x1, double z1)
{
return getDistance(x1 + _centerX, z1 + _centerZ, entry.getKey() + (_blocksScan / 2),
entry.getValue() + (_blocksScan / 2));
}
public Byte[][] getMap(int scale)
{
return _map.get(scale);
}
public int getMapSize()
{
return _halfMapSize;
}
@EventHandler
public void preventMapMoveInventories(InventoryClickEvent event)
{
Inventory inv = event.getClickedInventory();
if (inv == null)
return;
// Yeah, the loop looks a little weird..
for (ItemStack item : new ItemStack[]
{
event.getCurrentItem(),
event.getCursor()
})
{
if (item == null || item.getType() != Material.MAP || item.getDurability() != _mapId)
continue;
if (inv.getHolder() instanceof Player ? !event.isShiftClick() : Objects.equal(event.getCurrentItem(), item))
continue;
event.setCancelled(true);
UtilPlayer.message(event.getWhoClicked(),
F.main("Inventory", "You cannot move " + F.item("Clans Map") + " between inventories."));
return;
}
}
private void rebuildScan()
{
for (int x = -_halfMapSize; x < _halfMapSize; x += _blocksScan)
{
for (int z = -_halfMapSize - 16; z < _halfMapSize; z += (z < -_halfMapSize ? 16 : _blocksScan))
{
_scanList.add(new HashMap.SimpleEntry(x, z));
}
}
if (!_loadWorld)
{
Iterator<Entry<Integer, Integer>> itel = _scanList.iterator();
while (itel.hasNext())
{
Entry<Integer, Integer> entry = itel.next();
boolean removeEntry = true;
for (Player player : UtilServer.getPlayers())
{
if (Math.sqrt(getDistance(entry, player.getLocation().getX(), player.getLocation().getZ())) < 200)
{
removeEntry = false;
break;
}
}
if (removeEntry)
{
itel.remove();
}
}
}
Collections.sort(_scanList, _comparator);
}
@EventHandler
public void renderMap(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
return;
if (_scanList.isEmpty())
{
if (_loadWorld)
{
_loadWorld = false;
}
if (UtilServer.getPlayers().length == 0)
return;
rebuildScan();
}
else if (_scanList.size() % 20 == 0)
{
Collections.sort(_scanList, _comparator);
}
Entry<Integer, Integer> entry = _scanList.remove(0);
int startingX = entry.getKey();
int startingZ = entry.getValue();
boolean outsideMap = startingZ < -_halfMapSize;
scanWorldMap(startingX, startingZ, !outsideMap);
if (outsideMap)
{
return;
}
for (int s = 1; s <= 2; s++)
{
if (s == 2)
{
s = getScale();
if (s == 1)
break;
}
if (s == 13 && _loadWorld)
continue;
if (!outsideMap)
{
drawWorldScale(s, startingX, startingZ);
}
colorWorldHeight(s, startingX, startingZ);
}
colorWorldHeight(0, startingX, startingZ);
}
public void scanWorldMap(int startingX, int startingZ, boolean setColors)
{
Byte[][] map = _map.get(1);
for (int beginX = startingX; beginX < startingX + _blocksScan; beginX += 16)
{
for (int beginZ = startingZ - (startingZ > -_halfMapSize ? 16 : 0); beginZ < startingZ
+ (setColors ? _blocksScan : 16); beginZ += 16)
{
Chunk chunk = _world.getChunkAt((beginX + _centerX) / 16, (beginZ + _centerZ) / 16);
boolean loaded = false;
if (!chunk.isLoaded())
{
if (_loadWorld)
{
loaded = chunk.load();
}
else
{
continue;
}
}
net.minecraft.server.v1_8_R3.Chunk nmsChunk = ((CraftChunk) chunk).getHandle();
for (int x = beginX; x < beginX + 16; x++)
{
for (int z = beginZ; z < beginZ + 16; z++)
{
int color = 0;
if (!nmsChunk.isEmpty())
{
int k3 = x & 0xF;
int l3 = z & 0xF;
int l4 = nmsChunk.b(k3, l3) + 1;
IBlockData iblockdata = Blocks.AIR.getBlockData();
if (l4 > 1)
{
do
{
l4--;
iblockdata = nmsChunk.getBlockData(new BlockPosition(k3, l4, l3));
}
while (iblockdata.getBlock().g(iblockdata) == MaterialMapColor.b && (l4 > 0));
if ((l4 > 0) && (iblockdata.getBlock().getMaterial().isLiquid()))
{
int j5 = l4 - 1;
Block block1;
do
{
block1 = nmsChunk.getType(new BlockPosition(k3, j5--, l3));
}
while ((j5 > 0) && (block1.getMaterial().isLiquid()));
}
}
_heightMap[x + _halfMapSize + 16][z + _halfMapSize + 16] = l4;
if (setColors)
{
// color = block.f(i5).M;
IBlockData data = nmsChunk.getBlockData(new BlockPosition(k3, l4, l3));
color = data.getBlock().g(data).M;
color = (byte) ((color * 4) + 1);
}
}
if (setColors && beginZ >= startingZ)
{
map[x + _halfMapSize][z + _halfMapSize] = (byte) color;
}
}
if (loaded)
{
chunk.unload();
}
}
}
}
}
public void setMap(Player player)
{
for (ItemStack item : UtilInv.getItems(player))
{
if (item.getType() == Material.MAP && item.getDurability() == _mapId)
{
return;
}
}
ItemStack item = new ItemBuilder(Material.MAP, 1, _mapId).setTitle("Tutorial Map").build();
int slot = player.getInventory().firstEmpty();
if (slot >= 0)
{
ItemStack mapSlot = player.getInventory().getItem(8);
if (mapSlot == null || mapSlot.getType() == Material.AIR)
{
slot = 8;
}
player.getInventory().setItem(slot, item);
}
}
}

View File

@ -0,0 +1,100 @@
package mineplex.game.clans.tutorial.map;
import mineplex.core.recharge.Recharge;
import mineplex.game.clans.tutorial.TutorialRegion;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapCursor;
import org.bukkit.map.MapCursorCollection;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
public class TutorialMapRenderer extends MapRenderer
{
private TutorialMapManager _manager;
public TutorialMapRenderer(TutorialMapManager itemMapManager)
{
super(true);
_manager = itemMapManager;
}
@Override
public void render(MapView mapView, MapCanvas canvas, Player player)
{
int zoom = _manager.getScale();
Byte[][] map = _manager.getMap(zoom);
int centerX = 0;
int centerZ = 0;
// We have this cooldown to squeeze out every single bit of performance from the server.
if (Recharge.Instance.use(player, "Draw Map", 4000, false, false))
{
for (int mapX = 0; mapX < 128; mapX++)
{
for (int mapZ = 0; mapZ < 128; mapZ++)
{
int blockX = centerX + (mapX - 64);
int blockZ = centerZ + (mapZ - 64);
int pixelX = blockX + (map.length / 2);
int pixelZ = blockZ + (map.length / 2);
Byte color;
if (!(pixelX < 0 || pixelZ < 0 || pixelX >= map.length || pixelZ >= map.length)
&& map[pixelX][pixelZ] != null)
{
color = map[pixelX][pixelZ];
blockX *= zoom;
blockZ *= zoom;
}
else
{
color = (byte) 0;
}
/* TODO Figure out if you want to colorize this pixel
{
color = MapPalette.matchColor(r, g, b);
}*/
canvas.setPixel(mapX, mapZ, color);
}
}
player.sendMap(mapView);
}
MapCursorCollection cursors = canvas.getCursors();
while (cursors.size() > 0)
{
cursors.removeCursor(cursors.getCursor(0));
}
Location l = player.getLocation();
double mapX = (l.getX() - _manager.getX()) / zoom;
double mapZ = (l.getZ() - _manager.getZ()) / zoom;
if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64)
{
byte b0 = (byte) (int) Math.min(127, (double) (mapX * 2.0F) + 0.5D);
byte b1 = (byte) (int) Math.max(-127, (double) (mapZ * 2.0F) + 0.5D);
byte rotation = (byte) (int) ((l.getYaw() * 16D) / 360D);
MapCursor cursor = new MapCursor(b0, b1, (byte) (rotation & 0xF), MapCursor.Type.WHITE_POINTER.getValue(), true);
cursors.addCursor(cursor);
}
}
}

View File

@ -4,11 +4,15 @@ import java.io.IOException;
import java.util.List; import java.util.List;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -20,6 +24,7 @@ import mineplex.game.clans.message.ClansMessageManager;
import mineplex.game.clans.tutorial.Tutorial; import mineplex.game.clans.tutorial.Tutorial;
import mineplex.game.clans.tutorial.TutorialRegion; import mineplex.game.clans.tutorial.TutorialRegion;
import mineplex.game.clans.tutorial.TutorialWorldManager; import mineplex.game.clans.tutorial.TutorialWorldManager;
import mineplex.game.clans.tutorial.map.TutorialMapManager;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClassesObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.ClassesObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.FieldsObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.FieldsObjective;
@ -29,6 +34,8 @@ import mineplex.game.clans.tutorial.tutorials.clans.objective.ShopsObjective;
public class ClansMainTutorial extends Tutorial public class ClansMainTutorial extends Tutorial
{ {
private TutorialMapManager _mapManager;
public ClansMainTutorial(JavaPlugin plugin, ClansMessageManager message) public ClansMainTutorial(JavaPlugin plugin, ClansMessageManager message)
{ {
super(plugin, message, "Clans Tutorial", "Clans.MainTutorial", Material.DIAMOND_SWORD, (byte) 0); super(plugin, message, "Clans Tutorial", "Clans.MainTutorial", Material.DIAMOND_SWORD, (byte) 0);
@ -42,6 +49,8 @@ public class ClansMainTutorial extends Tutorial
e.printStackTrace(); e.printStackTrace();
} }
_mapManager = new TutorialMapManager(plugin, getWorldManager().getTutorialWorld(), -10, 0, 117, 127);
addObjective(new LeaveSpawnObjective(this, plugin)); addObjective(new LeaveSpawnObjective(this, plugin));
addObjective(new ClanObjective(this, plugin)); addObjective(new ClanObjective(this, plugin));
addObjective(new ShopsObjective(this, plugin)); addObjective(new ShopsObjective(this, plugin));
@ -59,17 +68,100 @@ public class ClansMainTutorial extends Tutorial
@Override @Override
protected void onStart(Player player) protected void onStart(Player player)
{ {
player.teleport(getRegion(player).getLocationMap().getLocations(DyeColor.RED).get(0)); TutorialRegion region = getRegion(player);
player.teleport(getSpawn(region));
spawnFences(region, DyeColor.BLACK); // Fields
spawnFences(region, DyeColor.BROWN); // Shops
spawnFences(region, DyeColor.RED); // Middle
player.setGameMode(GameMode.SURVIVAL);
player.getInventory().clear(); player.getInventory().clear();
ClansManager.getInstance().getItemMapManager().setMap(player); ClansManager.getInstance().getItemMapManager().setMap(player);
_mapManager.setMap(player);
} }
@Override @Override
protected void onQuit(Player player) protected void onQuit(Player player)
{ {
} }
public Location getPoint(TutorialRegion region, Point point)
{
return region.getLocationMap().getGoldLocations(point.getDataLocColor()).get(0).clone();
}
public boolean isIn(Location location, TutorialRegion region, Bounds bounds)
{
List<Location> locs = region.getLocationMap().getGoldLocations(bounds.getDataLocColor());
return UtilAlg.inBoundingBox(location, locs.get(0), locs.get(1));
}
public boolean isIn(Player player, Bounds bounds)
{
TutorialRegion region = getRegion(player);
if (region != null)
{
return isIn(player.getLocation(), region, bounds);
}
return false;
}
public Location getSpawn(TutorialRegion region)
{
Location location = region.getLocationMap().getGoldLocations(Point.SPAWN.getDataLocColor()).get(0).clone();
location.setYaw(180);
return location;
}
public enum Bounds
{
LAND_CLAIM(DyeColor.LIGHT_BLUE), // Should be 16x16
ENEMY_LAND(DyeColor.RED), // Should be 16x16
SPAWN(DyeColor.GREEN), // Spawn Platform
FIELDS(DyeColor.PURPLE), // Boulders for ores to spawn in?
SHOPS(DyeColor.YELLOW); // Little shop areas similar to Shops in clans map
// Gray Wool - Cannon Location
// Magenta Wool - Spawn
// Lime Wool - Farming Shop
// Purple Wool - Pvp Shop
// Light Gray Wool - Energy Shop
private DyeColor _dataLocColor;
Bounds(DyeColor dataLocColor)
{
_dataLocColor = dataLocColor;
}
public DyeColor getDataLocColor()
{
return _dataLocColor;
}
}
public enum Point
{
SPAWN(DyeColor.MAGENTA),
FARMING_SHOP(DyeColor.LIME),
PVP_SHOP(DyeColor.PURPLE),
ENERGY_SHOP(DyeColor.SILVER);
private DyeColor _dataLocColor;
Point(DyeColor dataLocColor)
{
_dataLocColor = dataLocColor;
}
public DyeColor getDataLocColor()
{
return _dataLocColor;
}
}
@EventHandler @EventHandler
public void dropItem(PlayerDropItemEvent event) public void dropItem(PlayerDropItemEvent event)
{ {
@ -78,7 +170,7 @@ public class ClansMainTutorial extends Tutorial
event.setCancelled(true); event.setCancelled(true);
} }
} }
@EventHandler @EventHandler
public void breakBlock(BlockBreakEvent event) public void breakBlock(BlockBreakEvent event)
{ {
@ -88,6 +180,57 @@ public class ClansMainTutorial extends Tutorial
} }
} }
@EventHandler
public void blockDamage(EntityDamageEvent event)
{
if (event.getEntity() instanceof Player)
{
if (isInTutorial((Player)event.getEntity()))
event.setCancelled(true);
}
}
// Fences
// Black = fields
// Brown = shops
public void spawnFence(Block startBlock)
{
Block block = startBlock;
int count = 0;
while (block.getType() == Material.AIR && count < 100)
{
block.setType(Material.FENCE);
block = block.getRelative(BlockFace.UP);
count++;
}
}
public void destroyFence(Block startBlock)
{
Block block = startBlock;
int count = 0;
while (block.getType() == Material.FENCE && count < 100)
{
block.setType(Material.AIR);
block = block.getRelative(BlockFace.UP);
count++;
}
}
public void spawnFences(TutorialRegion region, DyeColor dataLoc)
{
List<Location> locations = region.getLocationMap().getIronLocations(dataLoc);
locations.stream().map(Location::getBlock).forEach(this::spawnFence);
}
public void destroyFences(TutorialRegion region, DyeColor dataLoc)
{
List<Location> locations = region.getLocationMap().getIronLocations(dataLoc);
locations.stream().map(Location::getBlock).forEach(this::spawnFence);
}
@EventHandler @EventHandler
public void checkInRegion(UpdateEvent event) public void checkInRegion(UpdateEvent event)
{ {
@ -96,39 +239,11 @@ public class ClansMainTutorial extends Tutorial
for (Player player : getPlayers()) for (Player player : getPlayers())
{ {
TutorialRegion region = getRegion(player); if (player.getLocation().getWorld() != getWorldManager().getTutorialWorld())
if (!isInRegion(player.getLocation(), region))
{ {
TutorialRegion region = getRegion(player);
player.teleport(getSpawn(region)); player.teleport(getSpawn(region));
} }
} }
} }
public Location getSpawn(TutorialRegion region)
{
return region.getLocationMap().getLocations(DyeColor.RED).get(0);
}
public boolean isInSpawn(Player player)
{
return isInSpawn(player.getLocation(), getRegion(player));
}
public boolean isInSpawn(Location location, TutorialRegion region)
{
List<Location> locs = region.getLocationMap().getLocations(DyeColor.ORANGE);
return UtilAlg.inBoundingBox(location, locs.get(0), locs.get(1));
}
public boolean isInRegion(Player player)
{
return isInRegion(player.getLocation(), getRegion(player));
}
public boolean isInRegion(Location location, TutorialRegion region)
{
List<Location> locs = region.getLocationMap().getLocations(DyeColor.GREEN);
return UtilAlg.inBoundingBox(location, locs.get(0), locs.get(1));
}
} }

View File

@ -1,5 +1,7 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective; package mineplex.game.clans.tutorial.tutorials.clans.objective;
import java.util.Optional;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -39,7 +41,7 @@ public class LeaveSpawnObjective extends SingleObjective<ClansMainTutorial>
for (Player player : getActivePlayers()) for (Player player : getActivePlayers())
{ {
if (!getPlugin().isInSpawn(player)) if (!getPlugin().isIn(player, ClansMainTutorial.Bounds.SPAWN))
{ {
finish(player); finish(player);
} }

View File

@ -1,11 +1,14 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan; package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.objective.Objective; import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal; import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent;
public class AttackEnemyGoal extends ObjectiveGoal public class AttackEnemyGoal extends ObjectiveGoal
@ -18,8 +21,8 @@ public class AttackEnemyGoal extends ObjectiveGoal
@Override @Override
protected void customStart(Player player) protected void customStart(Player player)
{ {
// give tnt (For cannon) player.getInventory().addItem(new ItemStack(Material.TNT, 20));
// and place cannon? finish(player);
} }
// use this event for figuring out if the cannon hit the base // use this event for figuring out if the cannon hit the base

View File

@ -19,8 +19,11 @@ import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.tutorial.TutorialRegion;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
public class BuildHouseGoal extends ObjectiveGoal public class BuildHouseGoal extends ObjectiveGoal<ClanObjective>
{ {
private List<ItemStack> _items = Lists.newArrayList( private List<ItemStack> _items = Lists.newArrayList(
new ItemStack(Material.SMOOTH_BRICK, 54), new ItemStack(Material.SMOOTH_BRICK, 54),
@ -29,7 +32,7 @@ public class BuildHouseGoal extends ObjectiveGoal
); );
public BuildHouseGoal(Objective objective) public BuildHouseGoal(ClanObjective objective)
{ {
super(objective, "Build House", "Build a Stone Brick house. (Place all your blocks)"); super(objective, "Build House", "Build a Stone Brick house. (Place all your blocks)");
} }
@ -55,7 +58,7 @@ public class BuildHouseGoal extends ObjectiveGoal
return; return;
} }
if (!isInBuildArea(event.getBlock())) if (!isInBuildArea(event.getPlayer(), event.getBlock()))
{ {
return; return;
} }
@ -82,7 +85,7 @@ public class BuildHouseGoal extends ObjectiveGoal
return; return;
} }
if (isInBuildArea(event.getBlock())) if (isInBuildArea(event.getPlayer(), event.getBlock()))
{ {
// Run 1 tick later because inventory doesn't get updated instantly // Run 1 tick later because inventory doesn't get updated instantly
ClansManager.getInstance().runSync(() -> { ClansManager.getInstance().runSync(() -> {
@ -110,8 +113,9 @@ public class BuildHouseGoal extends ObjectiveGoal
} }
} }
private boolean isInBuildArea(Block block) private boolean isInBuildArea(Player player, Block block)
{ {
return true; // TODO TutorialRegion region = getObjective().getPlugin().getRegion(player);
return getObjective().getPlugin().isIn(block.getLocation(), region, ClansMainTutorial.Bounds.LAND_CLAIM);
} }
} }

View File

@ -5,11 +5,15 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.objective.Objective; import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal; import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
public class ClaimLandGoal extends ObjectiveGoal public class ClaimLandGoal extends ObjectiveGoal<ClanObjective>
{ {
public ClaimLandGoal(Objective objective) public ClaimLandGoal(ClanObjective objective)
{ {
super(objective, "Claim Land", "Claim land with /c claim"); super(objective, "Claim Land", "Claim land with /c claim");
} }
@ -29,8 +33,16 @@ public class ClaimLandGoal extends ObjectiveGoal
{ {
if (contains(event.getClaimer())) if (contains(event.getClaimer()))
{ {
if (getObjective().getPlugin().isIn(event.getClaimer(), ClansMainTutorial.Bounds.LAND_CLAIM))
{
finish(event.getClaimer());
}
else
{
UtilPlayer.message(event.getClaimer(), F.main("Tutorial", "You must claim the land inside the blue outline"));
}
event.setCancelled(true); event.setCancelled(true);
finish(event.getClaimer());
} }
} }
} }

View File

@ -3,13 +3,15 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal; import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
public class ClanDetailsGoal extends ObjectiveGoal public class ClanDetailsGoal extends ObjectiveGoal<ClanObjective>
{ {
public ClanDetailsGoal(Objective objective) public ClanDetailsGoal(ClanObjective objective)
{ {
super(objective, "View Clan Details", "View Clan Details with /c"); super(objective, "View Clan Details", "View Clan Details with /c");
} }
@ -24,6 +26,13 @@ public class ClanDetailsGoal extends ObjectiveGoal
{ {
} }
@Override
public String getDescription(Player player)
{
ClanInfo clan = ClansManager.getInstance().getClan(player);
return "View Clan Details with /c " + clan.getName();
}
@EventHandler @EventHandler
public void onClanInfo(ClansCommandExecutedEvent event) public void onClanInfo(ClansCommandExecutedEvent event)
{ {

View File

@ -6,10 +6,12 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.objective.Objective; import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal; import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.game.clans.clans.event.ClanCreatedEvent; import mineplex.game.clans.clans.event.ClanCreatedEvent;
import mineplex.game.clans.clans.event.ClanCreationCompleteEvent;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
public class CreateClanGoal extends ObjectiveGoal public class CreateClanGoal extends ObjectiveGoal<ClanObjective>
{ {
public CreateClanGoal(Objective objective) public CreateClanGoal(ClanObjective objective)
{ {
super(objective, "Create a Clan", "Create a Clan"); super(objective, "Create a Clan", "Create a Clan");
} }
@ -27,7 +29,7 @@ public class CreateClanGoal extends ObjectiveGoal
} }
@EventHandler @EventHandler
public void onClanCreate(ClanCreatedEvent event) public void onClanCreate(ClanCreationCompleteEvent event)
{ {
if (contains(event.getFounder())) if (contains(event.getFounder()))
{ {

View File

@ -5,11 +5,15 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.objective.Objective; import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal; import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.event.ClanSetHomeEvent; import mineplex.game.clans.clans.event.ClanSetHomeEvent;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
public class SetHomeGoal extends ObjectiveGoal public class SetHomeGoal extends ObjectiveGoal<ClanObjective>
{ {
public SetHomeGoal(Objective objective) public SetHomeGoal(ClanObjective objective)
{ {
super(objective, "Set Home", "Set your Clan's home by typing /c sethome"); super(objective, "Set Home", "Set your Clan's home by typing /c sethome");
} }
@ -29,7 +33,16 @@ public class SetHomeGoal extends ObjectiveGoal
{ {
if (contains(event.getPlayer())) if (contains(event.getPlayer()))
{ {
if (getObjective().getPlugin().isIn(event.getPlayer(), ClansMainTutorial.Bounds.LAND_CLAIM))
{
finish(event.getPlayer());
}
else
{
UtilPlayer.message(event.getPlayer(), F.main("Tutorial", "You must set your home in your own land claim"));
}
finish(event.getPlayer()); finish(event.getPlayer());
event.setCancelled(true);
} }
} }
} }

View File

@ -17,7 +17,7 @@ public class StealEnemyPotatoesGoal extends ObjectiveGoal
@Override @Override
protected void customStart(Player player) protected void customStart(Player player)
{ {
finish(player);
} }
@Override @Override

View File

@ -1,16 +1,23 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.shops; package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.shops;
import java.util.UUID;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import mineplex.core.common.objective.Objective; import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal; import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.event.ClanCreatedEvent; import mineplex.game.clans.clans.event.ClanCreatedEvent;
import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ShopsObjective;
public class GoToShopsGoal extends ObjectiveGoal public class GoToShopsGoal extends ObjectiveGoal<ShopsObjective>
{ {
public GoToShopsGoal(Objective objective) public GoToShopsGoal(ShopsObjective objective)
{ {
super(objective, "Go to the Shops", "Head over to the Shops (use your map)"); super(objective, "Go to the Shops", "Head over to the Shops (use your map)");
} }
@ -26,21 +33,20 @@ public class GoToShopsGoal extends ObjectiveGoal
{ {
} }
@EventHandler @EventHandler
public void enterRegion(PlayerEnterTerritoryEvent event) public void checkRegion(UpdateEvent event)
{ {
if (!contains(event.getPlayer())) if (event.getType() != UpdateType.FAST)
{
return; return;
}
for (UUID uuid : getActivePlayers())
// This "reverse" equals is to prevent an NPE
if (!"Shops".equals(event.getNewTerritory()))
{ {
return; Player player = UtilPlayer.searchExact(uuid);
if (getObjective().getPlugin().isIn(player, ClansMainTutorial.Bounds.SHOPS))
{
finish(player);
}
} }
finish(event.getPlayer());
} }
} }

View File

@ -6,6 +6,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.Random; import java.util.Random;
import mineplex.core.reward.RewardManager; import mineplex.core.reward.RewardManager;
@ -1076,4 +1077,27 @@ public class HubManager extends MiniClientPlugin<HubClient>
{ {
playNextSong(); 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() 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); _tempStackShift.remove(fThroweeStack);
} }
}, 2); }, 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(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()) + ".")); 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); 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(",")) for (String gameName : _serverConfiguration.getServerGroup().getGames().split(","))
{ {
try try
{ {System.out.println(gameName);
GameType type = GameType.valueOf(gameName); GameType type = GameType.valueOf(gameName);
config.GameList.add(type); config.GameList.add(type);
} }

View File

@ -4,34 +4,6 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; 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.MiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager; import mineplex.core.achievement.AchievementManager;
@ -136,6 +108,35 @@ import nautilus.game.arcade.player.ArcadePlayer;
import nautilus.game.arcade.shop.ArcadeShop; import nautilus.game.arcade.shop.ArcadeShop;
import net.minecraft.server.v1_8_R3.EntityLiving; 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 public class ArcadeManager extends MiniPlugin implements IRelation
{ {
// Modules // Modules
@ -609,7 +610,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return true; return true;
} }
@EventHandler @EventHandler
public void StaffIncognito(IncognitoStatusChangeEvent event) public void StaffIncognito(IncognitoStatusChangeEvent event)
{ {
@ -619,7 +620,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (event.getNewState()) if (event.getNewState())
{ {
UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName())); UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName()));
@ -699,10 +700,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation
event.setJoinMessage(null); event.setJoinMessage(null);
return; return;
} }
if (event.getJoinMessage() == null) if (event.getJoinMessage() == null)
return; return;
if (_game != null && _game.AnnounceJoinQuit) if (_game != null && _game.AnnounceJoinQuit)
event.setJoinMessage(F.sys("Join", GetColor(event.getPlayer()) + name)); event.setJoinMessage(F.sys("Join", GetColor(event.getPlayer()) + name));
@ -718,12 +719,12 @@ public class ArcadeManager extends MiniPlugin implements IRelation
event.setQuitMessage(null); event.setQuitMessage(null);
return; return;
} }
String name = event.getPlayer().getName(); String name = event.getPlayer().getName();
if (event.getQuitMessage() == null) if (event.getQuitMessage() == null)
return; return;
if (_game == null || _game.AnnounceJoinQuit) if (_game == null || _game.AnnounceJoinQuit)
event.setQuitMessage(F.sys("Quit", GetColor(event.getPlayer()) + name)); event.setQuitMessage(F.sys("Quit", GetColor(event.getPlayer()) + name));
else else
@ -910,6 +911,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
UtilInv.Clear(player); 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); ((CraftEntity) player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0), EntityLiving.META_ENTITYDATA, (byte) 0);
player.setCustomName(""); player.setCustomName("");
@ -1121,10 +1127,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{ {
_specList.add(player); _specList.add(player);
} }
return _specList.contains(player); return _specList.contains(player);
} }
public boolean IsTournamentServer() public boolean IsTournamentServer()
{ {
return _serverConfig.Tournament; 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.paintball.Paintball;
import nautilus.game.arcade.game.games.quiver.Quiver; import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverTeams; 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.runner.Runner;
import nautilus.game.arcade.game.games.searchanddestroy.SearchAndDestroy; import nautilus.game.arcade.game.games.searchanddestroy.SearchAndDestroy;
import nautilus.game.arcade.game.games.sheep.SheepGame; import nautilus.game.arcade.game.games.sheep.SheepGame;
@ -89,6 +90,7 @@ public enum GameType
Dragons(Dragons.class, GameDisplay.Dragons), Dragons(Dragons.class, GameDisplay.Dragons),
DragonsTeams(DragonsTeams.class, GameDisplay.DragonsTeams), DragonsTeams(DragonsTeams.class, GameDisplay.DragonsTeams),
Draw(Draw.class, GameDisplay.Draw, "http://chivebox.com/mineplex/ResDrawMyThing.zip", true), Draw(Draw.class, GameDisplay.Draw, "http://chivebox.com/mineplex/ResDrawMyThing.zip", true),
ElytraRings(ElytraRings.class, GameDisplay.ElytraRings),
Evolution(Evolution.class, GameDisplay.Evolution), Evolution(Evolution.class, GameDisplay.Evolution),
Gravity(Gravity.class, GameDisplay.Gravity), Gravity(Gravity.class, GameDisplay.Gravity),
Halloween(Halloween.class, GameDisplay.Halloween, "http://file.mineplex.com/ResHalloween.zip", true), 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)) while (!UtilBlock.airFoliage(block))
{ {
block = block.getRelative(BlockFace.UP); block = block.getRelative(BlockFace.UP);
if (block.getY() >= 256)
break;
} }
while (UtilBlock.airFoliage(block)) while (UtilBlock.airFoliage(block))
{ {
block = block.getRelative(BlockFace.DOWN); block = block.getRelative(BlockFace.DOWN);
if (block.getY() <= 0)
break;
} }
block = block.getRelative(BlockFace.UP); block = block.getRelative(BlockFace.UP);
@ -1943,4 +1949,10 @@ public class Bridge extends TeamGame implements OreObsfucation
{ {
event.setCancelled(true); 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.UtilServer;
import mineplex.core.common.util.UtilSystem; import mineplex.core.common.util.UtilSystem;
import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv;
import mineplex.core.creature.event.CreatureKillEntitiesEvent; import mineplex.core.creature.event.CreatureKillEntitiesEvent;
import mineplex.core.event.StackerEvent; import mineplex.core.event.StackerEvent;
import mineplex.core.gadget.gadgets.morph.MorphBlock; 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 mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.PlayerDeathOutEvent; import nautilus.game.arcade.events.PlayerDeathOutEvent;
import nautilus.game.arcade.game.games.bridge.Bridge;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; 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!")); 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) public void listSettings(Player player)

View File

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

View File

@ -54,8 +54,8 @@ public class BlockForm extends Form
private int _entityId; private int _entityId;
private Location _loc; private Location _loc;
private int _selfEntityId1; private int _fakeSilverfishId;
private int _selfEntityId2; private int _fakeBlockId;
private Vector _lastSaw; private Vector _lastSaw;
private Vector _sawDiff = new Vector(); private Vector _sawDiff = new Vector();
private int _blockId = UtilEnt.getNewEntityId(); private int _blockId = UtilEnt.getNewEntityId();
@ -66,8 +66,8 @@ public class BlockForm extends Form
_mat = mat; _mat = mat;
_loc = player.getLocation(); _loc = player.getLocation();
_selfEntityId1 = UtilEnt.getNewEntityId(); _fakeSilverfishId = UtilEnt.getNewEntityId();
_selfEntityId2 = UtilEnt.getNewEntityId(); _fakeBlockId = UtilEnt.getNewEntityId();
System.out.println("Block Form: " + _mat + " " + _mat.getId()); System.out.println("Block Form: " + _mat + " " + _mat.getId());
} }
@ -100,7 +100,7 @@ public class BlockForm extends Form
Packet[] packets = new Packet[3]; Packet[] packets = new Packet[3];
PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving();
packet1.a = _selfEntityId1; packet1.a = _fakeSilverfishId;
packet1.b = EntityType.SILVERFISH.getTypeId(); packet1.b = EntityType.SILVERFISH.getTypeId();
packet1.c = (int) Math.floor(_lastSaw.getX() * 32); packet1.c = (int) Math.floor(_lastSaw.getX() * 32);
packet1.d = (int) Math.floor(_lastSaw.getY() * 32); packet1.d = (int) Math.floor(_lastSaw.getY() * 32);
@ -114,9 +114,9 @@ public class BlockForm extends Form
if (UtilPlayer.is1_9(Player)) 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(); PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity();
packet3.b = _selfEntityId2; packet3.b = _fakeBlockId;
packet3.c = _selfEntityId1; packet3.c = _fakeSilverfishId;
packets[2] = packet3; packets[2] = packet3;
} }
PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(player, 70, _mat.getId()); PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(player, 70, _mat.getId());
packet2.a = _selfEntityId2; packet2.a = _fakeBlockId;
packet2.uuid = UUID.randomUUID(); packet2.uuid = UUID.randomUUID();
packets[1] = packet2; packets[1] = packet2;
@ -140,16 +140,11 @@ public class BlockForm extends Form
// Inform // Inform
String blockName = F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false)); String blockName = F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false));
if (!blockName.contains("Block")) if (!blockName.contains("Block"))
UtilPlayer.message( UtilPlayer.message(Player, F.main("Game", C.cWhite + "You are now a "
Player, + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false) + " Block") + "!"));
F.main("Game",
C.cWhite + "You are now a "
+ F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false) + " Block") + "!"));
else else
UtilPlayer.message( UtilPlayer.message(Player, F.main("Game",
Player, C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false)) + "!"));
F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false))
+ "!"));
// Give Item // Give Item
Player.getInventory().setItem(8, new ItemStack(Host.GetItemEquivilent(_mat))); Player.getInventory().setItem(8, new ItemStack(Host.GetItemEquivilent(_mat)));
@ -171,11 +166,11 @@ public class BlockForm extends Form
if (is19) if (is19)
{ {
packets[2] = new PacketPlayOutNewAttachEntity(_blockId, new int[] packets[1] = new PacketPlayOutNewAttachEntity(Player.getEntityId(), new int[]
{ {
Player.getEntityId() _blockId
});
});
} }
else else
{ {
@ -203,8 +198,8 @@ public class BlockForm extends Form
UtilPlayer.sendPacket(Player, new PacketPlayOutEntityDestroy(new int[] UtilPlayer.sendPacket(Player, new PacketPlayOutEntityDestroy(new int[]
{ {
_selfEntityId1, _fakeSilverfishId,
_selfEntityId2, _fakeBlockId,
_blockId _blockId
})); }));
@ -214,8 +209,8 @@ public class BlockForm extends Form
public void SolidifyUpdate() public void SolidifyUpdate()
{ {
if (!Player.isSprinting()) if (!Player.isSprinting())
((CraftEntity) Player).getHandle().getDataWatcher() ((CraftEntity) Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32), Entity.META_ENTITYDATA,
.watch(0, Byte.valueOf((byte) 32), Entity.META_ENTITYDATA, (byte) 32); (byte) 32);
// Not a Block // Not a Block
if (_block == null) if (_block == null)
@ -273,26 +268,26 @@ public class BlockForm extends Form
_sawDiff.add(blockLoc.clone().subtract(_lastSaw)); _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)); _lastSaw = Player.getLocation().toVector().subtract(new Vector(0, 0.15625, 0));
_sawDiff = _lastSaw.clone().subtract(blockLoc); _sawDiff = _lastSaw.clone().subtract(blockLoc);
if (packet != null) if (packet != null)
{ {
if (packet instanceof PacketPlayOutEntityTeleport) if (packet[0] instanceof PacketPlayOutEntityTeleport)
{ {
_sawDiff = new Vector(); _sawDiff = new Vector();
} }
((CraftPlayer) Player).getHandle().playerConnection.sendPacket(packet); UtilPlayer.sendPacket(Player, packet[UtilPlayer.is1_9(Player) ? 1 : 0]);
} }
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
UtilPlayer.sendPacket(player, new PacketPlayOutEntityDestroy(new int[] 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); MapUtil.QuickChangeBlockAt(_block.getLocation(), 0, (byte) 0);
_block = null; _block = null;
EntityTrackerEntry tracker = (EntityTrackerEntry) ((WorldServer) ((CraftEntity) Player).getHandle().world).tracker.trackedEntities EntityTrackerEntry tracker = (EntityTrackerEntry) ((WorldServer) ((CraftEntity) Player)
.get(Player.getEntityId()); .getHandle().world).tracker.trackedEntities.get(Player.getEntityId());
if (tracker != null) if (tracker != null)
{ {
@ -374,13 +369,13 @@ public class BlockForm extends Form
_lastSaw = Player.getLocation().subtract(0, 0.15625, 0).toVector(); _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 != 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)); _sawDiff.subtract(new Vector(relPacket.b / 32D, relPacket.c / 32D, relPacket.d / 32D));
} }
else else
@ -388,12 +383,12 @@ public class BlockForm extends Form
_sawDiff = new Vector(); _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 x = (int) Math.floor(blocksFromNewPosition.getX() * 32);
int y = (int) Math.floor(blocksFromNewPosition.getY() * 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) 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) if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
{ {
PacketPlayOutRelEntityMove relMove = new PacketPlayOutRelEntityMove(); PacketPlayOutRelEntityMove relMove = new PacketPlayOutRelEntityMove();
relMove.a = this._selfEntityId1; relMove.a = this._fakeSilverfishId;
relMove.b = (byte) x; relMove.b = (byte) x;
relMove.c = (byte) y; relMove.c = (byte) y;
relMove.d = (byte) z; relMove.d = (byte) z;
return relMove; packets[0] = relMove;
} }
else
{ {
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(); PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
teleportPacket.a = _selfEntityId1; teleportPacket.a = _fakeSilverfishId;
teleportPacket.b = (int) Math.floor(32 * newPosition.getX()); teleportPacket.b = (int) Math.floor(32 * newPosition.getX());
teleportPacket.c = (int) Math.floor(32 * newPosition.getY()); teleportPacket.c = (int) Math.floor(32 * newPosition.getY());
teleportPacket.d = (int) Math.floor(32 * newPosition.getZ()); teleportPacket.d = (int) Math.floor(32 * newPosition.getZ());
return teleportPacket; if (packets[0] == null)
packets[0] = teleportPacket;
packets[1] = teleportPacket;
} }
return packets;
} }
return null; 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.EntityCreature;
import net.minecraft.server.v1_8_R3.Navigation; 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.C;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock; 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.GamePrepareCountdownCommence;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.SoloGame; 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.KitInvulnerable;
import nautilus.game.arcade.game.games.snake.kits.KitReverser; import nautilus.game.arcade.game.games.snake.kits.KitReverser;
import nautilus.game.arcade.game.games.snake.kits.KitSpeed; 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 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 double _maxSpeed = 180;
private HashMap<Player, ArrayList<Creature>> _tail = new HashMap<Player, ArrayList<Creature>>(); 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 //On Own
Block block = event.getBlock().getRelative(BlockFace.DOWN); Block block = event.getBlock().getRelative(BlockFace.DOWN);
while (block.getTypeId() == 0) while (block.getTypeId() == 0 && block.getY() > 0)
block = block.getRelative(BlockFace.DOWN); block = block.getRelative(BlockFace.DOWN);
if (block.getData() != team.GetColorData()) if (block.getData() != team.GetColorData())

View File

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

View File

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