Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

This commit is contained in:
CoderTim 2014-08-19 21:16:44 -04:00
commit 18ca7d5656
28 changed files with 434 additions and 127 deletions

View File

@ -146,7 +146,7 @@ public class MapUtil
if (changeChunkBlock(x & 15, y, z & 15, ((CraftWorld) world).getHandle().getChunkAt(x >> 4, z >> 4),
Block.getById(id), data))
{
((CraftWorld) world).getHandle().notify(x, y, z);
//((CraftWorld) world).getHandle().notify(x, y, z);
}
}

View File

@ -1,7 +1,5 @@
package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

View File

@ -9,7 +9,7 @@ public class UtilServer
{
public static Player[] getPlayers()
{
return getServer().getOnlinePlayers().toArray(new Player[0]);
return getServer().getOnlinePlayers();
}
public static Server getServer()

View File

@ -217,7 +217,7 @@ public class CoreClientManager extends MiniPlugin
client.SetPlayer(event.getPlayer());
// Reserved Slot Check
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers())
if (Bukkit.getOnlinePlayers().length >= Bukkit.getServer().getMaxPlayers())
{
if (client.GetRank().Has(event.getPlayer(), Rank.ULTRA, false))
{

View File

@ -357,7 +357,7 @@ public class AntiHack extends MiniPlugin
UtilServer.broadcast(F.main("MAC", player.getName() + " was kicked for suspicious movement."));
ServerListPingEvent event = new ServerListPingEvent(null, Bukkit.getServer().getMotd(), Bukkit.getServer().getOnlinePlayers().size(), Bukkit.getServer().getMaxPlayers());
ServerListPingEvent event = new ServerListPingEvent(null, Bukkit.getServer().getMotd(), Bukkit.getServer().getOnlinePlayers().length, Bukkit.getServer().getMaxPlayers());
GetPluginManager().callEvent(event);
String motd = event.getMotd();

View File

@ -94,7 +94,7 @@ public class FriendManager extends MiniClientPlugin<FriendData> implements IPack
@EventHandler
public void updateFriends(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW || Bukkit.getOnlinePlayers().size() == 0)
if (event.getType() != UpdateType.SLOW || Bukkit.getOnlinePlayers().length == 0)
return;
Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()

View File

@ -153,7 +153,7 @@ public class Portal extends MiniPlugin
@EventHandler
public void checkForServerTransfers(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || Bukkit.getOnlinePlayers().size() == 0)
if (event.getType() != UpdateType.SEC || Bukkit.getOnlinePlayers().length == 0)
return;
_retrieve = !_retrieve;

View File

@ -131,11 +131,11 @@ public class ServerStatusManager extends MiniPlugin
*/
private MinecraftServer generateServerSnapshot()
{
ServerListPingEvent event = new ServerListPingEvent(null, GetPlugin().getServer().getMotd(), GetPlugin().getServer().getOnlinePlayers().size(), GetPlugin().getServer().getMaxPlayers());
ServerListPingEvent event = new ServerListPingEvent(null, GetPlugin().getServer().getMotd(), GetPlugin().getServer().getOnlinePlayers().length, GetPlugin().getServer().getMaxPlayers());
GetPluginManager().callEvent(event);
String motd = event.getMotd();
int playerCount = Bukkit.getOnlinePlayers().size();
int playerCount = Bukkit.getOnlinePlayers().length;
int maxPlayerCount = event.getMaxPlayers();
int tps = (int) _lagMeter.getTicksPerSecond();
String address = Bukkit.getServer().getIp().isEmpty() ? "localhost" : Bukkit.getServer().getIp();

View File

@ -447,7 +447,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
CoreClient client = _clientManager.Get(event.getPlayer().getName());
// Reserved Slot Check
if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20)
if (Bukkit.getOnlinePlayers().length - Bukkit.getServer().getMaxPlayers() >= 20)
{
if (!client.GetRank().Has(Rank.ULTRA))
{
@ -466,6 +466,15 @@ public class HubManager extends MiniClientPlugin<HubClient>
event.allow();
}
@EventHandler(priority = EventPriority.LOW)
public void AdminOP(PlayerJoinEvent event)
{
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.ADMIN))
event.getPlayer().setOp(true);
else
event.getPlayer().setOp(false);
}
@EventHandler(priority = EventPriority.LOW)
public void PlayerJoin(PlayerJoinEvent event)
{

View File

@ -42,6 +42,8 @@ import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import mineplex.hub.modules.parkour.ParkourData;
import mineplex.hub.modules.parkour.ParkourSnake;
public class ParkourManager extends MiniPlugin
{
@ -51,6 +53,7 @@ public class ParkourManager extends MiniPlugin
private HashSet<ParkourData> _parkour = new HashSet<ParkourData>();
private Location _snakeParkourReturn;
private Location _lavaParkourReturn;
private WeakHashMap<Player, Location> _lavaLocation = new WeakHashMap<Player, Location>();
private WeakHashMap<Player, Long> _lavaTimer = new WeakHashMap<Player, Long>();
@ -85,9 +88,20 @@ public class ParkourManager extends MiniPlugin
"or you will die in flames!"
}, 4000, new Location(Manager.GetSpawn().getWorld(), -93,67,38),
new Location(Manager.GetSpawn().getWorld(), -86,100,42), new Location(Manager.GetSpawn().getWorld(), -120,50,-17)));
_parkour.add(new ParkourSnake("Snake Parkour", new String[]
{
"This parkour requires incredible timing",
"and great agility! Some say it was created",
"by the devil as a cruel joke!"
}, 8000, new Location(Manager.GetSpawn().getWorld(), 22,70,-54),
new Location(Manager.GetSpawn().getWorld(), 28,-50,-88), new Location(Manager.GetSpawn().getWorld(), -24,90,-46)));
_lavaParkourReturn = new Location(Manager.GetSpawn().getWorld(), -89.5,68,36.5);
_lavaParkourReturn.setYaw(90);
_snakeParkourReturn = new Location(Manager.GetSpawn().getWorld(), 16.5,72,-52.5);
_snakeParkourReturn.setYaw(180);
}
public boolean isParkourMode(Player player)
@ -145,7 +159,7 @@ public class ParkourManager extends MiniPlugin
for (ParkourData data : _parkour)
if (UtilMath.offset(player.getLocation(), data.NPC) < 6)
if (Recharge.Instance.use(player, data.Name+" Info", 60000, false, false))
if (Recharge.Instance.use(player, data.Name+" Info", 300000, false, false))
data.Inform(player);
}
}
@ -229,6 +243,25 @@ public class ParkourManager extends MiniPlugin
event.getEntity().leaveVehicle();
event.getEntity().teleport(_lavaParkourReturn);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void snakeReturn(EntityDamageEvent event)
{
if (event.getCause() != DamageCause.VOID)
return;
if (!(event.getEntity() instanceof Player))
return;
Player player = (Player)event.getEntity();
if (!isParkourMode(player))
return;
event.getEntity().eject();
event.getEntity().leaveVehicle();
event.getEntity().teleport(_snakeParkourReturn);
}
@EventHandler
public void lavaBlockReturn(UpdateEvent event)
@ -385,4 +418,16 @@ public class ParkourManager extends MiniPlugin
return false;
}
@EventHandler
public void snakeUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
return;
for (ParkourData parkour : _parkour)
if (parkour instanceof ParkourSnake)
((ParkourSnake)parkour).Update();
}
}

View File

@ -5,11 +5,16 @@ import java.util.Iterator;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -25,7 +30,9 @@ import org.bukkit.entity.Boat;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
@ -42,6 +49,7 @@ import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;

View File

@ -1,4 +1,4 @@
package mineplex.hub.modules;
package mineplex.hub.modules.parkour;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilPlayer;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.entity.Player;
public class ParkourData
@ -55,4 +56,9 @@ public class ParkourData
{
return (UtilAlg.inBoundingBox(loc, CornerA, CornerB));
}
public World getWorld()
{
return CornerA.getWorld();
}
}

View File

@ -0,0 +1,213 @@
package mineplex.hub.modules.parkour;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import org.bukkit.Location;
import mineplex.core.common.util.UtilMath;
public class ParkourSnake extends ParkourData
{
private ArrayList<SnakePart> _snakes;
public ParkourSnake(String name, String[] desc, int gems, Location npc, Location cornerA, Location cornerB)
{
super(name, desc, gems, npc, cornerA, cornerB);
//THIS SHOULD BE COMMENTED OUT
//parseSnakes();
loadSnakes();
}
public void loadSnakes()
{
_snakes = new ArrayList<SnakePart>();
try
{
BufferedReader br = new BufferedReader(new FileReader("SnakeRoutes.dat"));
try
{
String line = br.readLine();
while (line != null)
{
if (line.length() > 6)
_snakes.add(loadSnake(line));
line = br.readLine();
}
}
finally
{
br.close();
}
}
catch (Exception e)
{
e.printStackTrace();
}
System.out.println("Done");
}
public SnakePart loadSnake(String locString)
{
ArrayList<Location> locs = new ArrayList<Location>();
for (String cur : locString.split(":"))
{
String[] tokens = cur.split(",");
try
{
Location loc = new Location(getWorld(), Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]), Integer.parseInt(tokens[2]));
if (InBoundary(loc))
locs.add(loc);
}
catch (Exception e)
{
System.out.println("Invalid Hub Snake Location: " + cur);
}
}
return new SnakePart(locs);
}
public void parseSnakes()
{
String locString = "-22,78,-72:-22,79,-72:-22,80,-72:-22,80,-71:-22,80,-70:-22,80,-69:-22,78,-68:-22,79,-68:-22,80,-68:-22,79,-57:-22,79,-56:-22,79,-55:-22,79,-54:-22,79,-53:-21,75,-78:-21,76,-78:-21,77,-78:-21,75,-77:-21,75,-76:-21,75,-75:-21,75,-74:-21,76,-74:-21,77,-74:-21,78,-74:-21,78,-73:-21,78,-72:-21,76,-68:-21,77,-68:-21,78,-68:-21,76,-67:-21,76,-66:-21,76,-65:-21,76,-64:-21,77,-64:-21,78,-64:-21,79,-64:-21,79,-63:-21,77,-62:-21,78,-62:-21,79,-62:-21,79,-57:-21,79,-56:-21,79,-55:-21,79,-54:-21,79,-53:-20,77,-78:-20,77,-62:-20,79,-57:-20,79,-56:-20,79,-55:-20,79,-54:-20,79,-53:-19,75,-78:-19,76,-78:-19,77,-78:-19,75,-77:-19,75,-76:-19,75,-75:-19,75,-74:-19,77,-74:-19,78,-74:-19,79,-74:-19,75,-73:-19,76,-73:-19,77,-73:-19,77,-62:-18,79,-74:-18,77,-62:-17,79,-74:-17,77,-62:-16,79,-74:-16,77,-62:-15,77,-74:-15,78,-74:-15,79,-74:-15,75,-73:-15,76,-73:-15,77,-73:-15,75,-72:-15,75,-71:-15,75,-70:-15,75,-69:-15,76,-69:-15,77,-69:-15,77,-68:-15,77,-67:-15,77,-66:-15,77,-65:-15,77,-64:-15,77,-63:-15,77,-62:-11,77,-68:-11,78,-68:-11,79,-68:-11,77,-67:-11,77,-66:-11,77,-65:-11,78,-65:-11,79,-65:-10,79,-68:-10,79,-65:-9,79,-68:-9,79,-65:-8,77,-68:-8,78,-68:-8,79,-68:-8,77,-67:-8,77,-66:-8,77,-65:-8,78,-65:-8,79,-65:-7,75,-75:-7,75,-74:-7,75,-73:-7,76,-73:-7,77,-73:-7,73,-71:-7,74,-71:-7,75,-71:-7,73,-70:-7,73,-69:-7,72,-66:-7,73,-66:-7,74,-66:-7,72,-65:-7,72,-64:-7,72,-63:-7,73,-63:-7,74,-63:-7,75,-63:-6,71,-79:-6,72,-79:-6,73,-79:-6,74,-79:-6,75,-79:-6,75,-78:-6,76,-78:-6,77,-78:-6,75,-75:-6,77,-73:-6,75,-71:-6,73,-69:-6,74,-66:-6,75,-63:-5,71,-79:-5,77,-78:-5,75,-75:-5,75,-74:-5,75,-73:-5,76,-73:-5,77,-73:-5,73,-71:-5,74,-71:-5,75,-71:-5,73,-70:-5,73,-69:-5,77,-69:-5,77,-68:-5,77,-67:-5,74,-66:-5,75,-66:-5,76,-66:-5,77,-66:-5,72,-63:-5,73,-63:-5,74,-63:-5,75,-63:-4,71,-79:-4,77,-78:-4,77,-69:-4,72,-63:-3,71,-79:-3,77,-78:-3,77,-69:-3,72,-63:-2,71,-79:-2,73,-79:-2,74,-79:-2,75,-79:-2,75,-78:-2,76,-78:-2,77,-78:-2,74,-69:-2,75,-69:-2,76,-69:-2,77,-69:-2,74,-68:-2,74,-67:-2,74,-66:-2,74,-65:-2,75,-65:-2,76,-65:-2,76,-64:-2,72,-63:-2,73,-63:-2,74,-63:-2,75,-63:-2,76,-63:-1,71,-79:-1,73,-79:0,71,-79:0,73,-79:1,71,-79:1,73,-79:1,74,-79:1,75,-79:1,75,-78:1,76,-78:1,77,-78:2,71,-79:2,77,-78:3,71,-79:3,77,-78:4,71,-79:4,73,-79:4,74,-79:4,75,-79:4,75,-78:4,76,-78:4,77,-78:5,71,-79:5,73,-79:6,71,-79:6,73,-79:7,71,-79:7,73,-79:7,74,-79:7,75,-79:7,75,-78:7,76,-78:7,77,-78:7,69,-67:7,70,-67:7,71,-67:7,71,-66:7,71,-65:7,69,-64:7,70,-64:7,71,-64:8,71,-79:8,77,-78:8,66,-74:8,67,-74:8,68,-74:8,68,-73:8,68,-72:8,68,-71:8,68,-70:8,68,-69:8,69,-69:8,70,-69:8,71,-69:8,69,-67:8,69,-64:9,71,-79:9,77,-78:9,66,-74:9,71,-69:9,69,-67:9,69,-64:10,71,-79:10,72,-79:10,73,-79:10,74,-79:10,75,-79:10,75,-78:10,76,-78:10,77,-78:10,66,-74:10,68,-74:10,69,-74:10,70,-74:10,71,-74:10,71,-73:10,69,-72:10,70,-72:10,71,-72:10,69,-71:10,69,-70:10,69,-69:10,70,-69:10,71,-69:10,69,-67:10,70,-67:10,71,-67:10,71,-66:10,71,-65:10,69,-64:10,70,-64:10,71,-64:11,66,-74:11,68,-74:12,66,-74:12,68,-74:13,75,-80:13,76,-80:13,77,-80:13,75,-79:13,75,-78:13,75,-77:13,76,-77:13,77,-77:13,66,-74:13,68,-74:13,69,-74:13,70,-74:13,71,-74:13,72,-74:13,71,-67:13,71,-66:13,71,-65:13,69,-64:13,70,-64:13,71,-64:13,69,-63:13,69,-62:13,69,-61:13,69,-60:13,69,-59:13,69,-58:14,77,-80:14,77,-77:14,66,-74:14,72,-74:14,71,-67:14,69,-58:15,77,-80:15,77,-77:15,66,-74:15,71,-74:15,72,-74:15,69,-67:15,70,-67:15,71,-67:15,69,-58:16,75,-80:16,76,-80:16,77,-80:16,75,-79:16,75,-78:16,75,-77:16,76,-77:16,77,-77:16,66,-74:16,71,-74:16,69,-67:16,69,-58:17,66,-74:17,71,-74:17,69,-67:17,69,-58:18,66,-74:18,71,-74:18,72,-74:18,73,-74:18,69,-67:18,70,-67:18,69,-58:19,74,-79:19,74,-78:19,74,-77:19,66,-74:19,73,-74:19,70,-67:19,67,-62:19,68,-62:19,69,-62:19,69,-61:19,69,-60:19,69,-59:19,69,-58:20,74,-79:20,74,-77:20,66,-74:20,67,-74:20,68,-74:20,69,-74:20,70,-74:20,71,-74:20,72,-74:20,73,-74:20,68,-67:20,69,-67:20,70,-67:20,67,-62:21,72,-79:21,73,-79:21,74,-79:21,72,-78:21,72,-77:21,73,-77:21,74,-77:21,68,-67:21,67,-62:22,68,-67:22,69,-67:22,70,-67:22,70,-66:22,69,-65:22,70,-65:22,69,-64:22,69,-63:22,67,-62:22,68,-62:22,69,-62:";
ArrayList<Location> locs = new ArrayList<Location>();
for (String cur : locString.split(":"))
{
String[] tokens = cur.split(",");
try
{
Location loc = new Location(getWorld(), Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]), Integer.parseInt(tokens[2]));
if (InBoundary(loc))
locs.add(loc);
}
catch (Exception e)
{
System.out.println("Invalid Hub Snake Location: " + cur);
}
}
ArrayList<ArrayList<Location>> snakes = new ArrayList<ArrayList<Location>>();
//Get Blacks
Iterator<Location> locIterator = locs.iterator();
while (locIterator.hasNext())
{
Location loc = locIterator.next();
if (loc.getBlock().getData() != 0)
continue;
ArrayList<Location> newSnake = new ArrayList<Location>();
newSnake.add(loc);
snakes.add(newSnake);
locIterator.remove();
}
//Get Body
int partsAdded = 1;
while (partsAdded > 0)
{
partsAdded = 0;
locIterator = locs.iterator();
while (locIterator.hasNext())
{
Location loc = locIterator.next();
if (loc.getBlock().getData() == 15)
continue;
for (ArrayList<Location> snake : snakes)
{
if (UtilMath.offset(loc, snake.get(snake.size() - 1)) != 1)
continue;
snake.add(loc);
locIterator.remove();
partsAdded++;
}
}
}
//Get Tail
try
{
locIterator = locs.iterator();
while (locIterator.hasNext())
{
Location loc = locIterator.next();
for (ArrayList<Location> snake : snakes)
{
if (UtilMath.offset(loc, snake.get(snake.size() - 1)) != 1)
continue;
snake.add(loc);
locIterator.remove();
partsAdded++;
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
//Write
try
{
File file = new File("SnakeRoutes.dat");
if (!file.exists())
file.createNewFile();
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
for (ArrayList<Location> snake : snakes)
{
String out = "";
for (Location loc : snake)
out += loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ() + ":";
bw.write(out + "\n\n\n");
}
bw.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void Update()
{
for (SnakePart snake : _snakes)
snake.Update();
}
}

View File

@ -0,0 +1,99 @@
package mineplex.hub.modules.parkour;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
public class SnakePart
{
private ArrayList<Location> _path = new ArrayList<Location>();
private byte _color = 0;
private int _index = 0;
private boolean _colorTick = false;
private int _pathId = 39;
public SnakePart(ArrayList<Location> path)
{
_path = path;
_color = path.get(1).getBlock().getData();
for (Location loc : path)
MapUtil.QuickChangeBlockAt(loc, 35, _color);
}
public void Update()
{
if (_path.isEmpty())
return;
//Set Block
sendBlock(_path.get(_index), 35, GetColor());
int back = _index - 10;
while (back < 0)
back += _path.size();
//Unset Tail
sendBlock(_path.get(back), _pathId, (byte) 0);
//ALT
if (_path.size() > 50)
{
int newIndex = (_index + (_path.size()/2))%_path.size();
//Set Block
sendBlock(_path.get(newIndex), 35, GetColor());
back = newIndex - 10;
if (back < 0)
back += _path.size();
//Unset Tail
sendBlock(_path.get(back), _pathId, (byte) 0);
}
_index = (_index+1)%_path.size();
_colorTick = !_colorTick;
/*
for (Location loc : _path)
if (loc.getBlock().getType() == Material.AIR)
UtilParticle.PlayParticle(ParticleType.CRIT, loc, 0, 0, 0, 0, 1);
*/
}
public void sendBlock(Location loc, int id, byte data)
{
MapUtil.ChunkBlockChange(loc, id, data);
for (Player player : UtilServer.getPlayers())
{
if (UtilMath.offset(player.getLocation(), loc) < 64)
{
player.sendBlockChange(loc, Material.getMaterial(id), data);
}
}
}
public byte GetColor()
{
if (_colorTick)
return _color;
return _color;
}
}

View File

@ -19,13 +19,13 @@ public class MapData
public String MapName = "null";
public String MapCreator = "null";
public HashSet<String> BuildList;
public HashSet<String> AdminList;
public MapData(String mapFolder)
{
MapFolder = mapFolder;
BuildList = new HashSet<String>();
AdminList = new HashSet<String>();
if ((new File(MapFolder + File.separator + "Map.dat")).exists())
Read();
@ -66,10 +66,10 @@ public class MapData
{
GameType = GameType.valueOf(tokens[1] == null ? "Null" : tokens[1]);
}
else if (tokens[0].equalsIgnoreCase("BUILD_LIST"))
else if (tokens[0].equalsIgnoreCase("ADMIN_LIST"))
{
for (String cur : tokens[1].split(","))
BuildList.add(cur);
AdminList.add(cur);
}
}
@ -96,12 +96,12 @@ public class MapData
out.write("\n");
out.write("GAME_TYPE:"+GameType);
String buildList = "";
for (String cur : BuildList)
buildList += cur + ",";
String adminList = "";
for (String cur : AdminList)
adminList += cur + ",";
out.write("\n");
out.write("BUILD_LIST:"+buildList);
out.write("ADMIN_LIST:"+adminList);
out.close();
}
@ -111,9 +111,9 @@ public class MapData
}
}
public boolean CanBuild(Player player)
public boolean HasAccess(Player player)
{
return BuildList.contains(player.getName()) || player.isOp();
return AdminList.contains(player.getName()) || player.isOp();
}
public boolean CanJoin(Player player)

View File

@ -39,7 +39,7 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.mapparser.command.AuthorCommand;
import mineplex.mapparser.command.BaseCommand;
import mineplex.mapparser.command.BuildCommand;
import mineplex.mapparser.command.AdminCommand;
import mineplex.mapparser.command.CopyCommand;
import mineplex.mapparser.command.CopySchematicsCommand;
import mineplex.mapparser.command.CreateCommand;
@ -77,7 +77,7 @@ public class MapParser extends JavaPlugin implements Listener
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Ticker(this), 1, 1);
_commands.add(new AuthorCommand(this));
_commands.add(new BuildCommand(this));
_commands.add(new AdminCommand(this));
_commands.add(new CopySchematicsCommand(this));
_commands.add(new CreateCommand(this));
_commands.add(new DeleteCommand(this));
@ -117,19 +117,19 @@ public class MapParser extends JavaPlugin implements Listener
UtilPlayer.message(player, F.value("Parameters", "Parameters: <?> = Required, [?] = Optional"));
UtilPlayer.message(player, F.value("/hub", "Return to hub world"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, F.value("/create <name> [gametype]", "Creates a new map"));
UtilPlayer.message(player, F.value("/delete <name> [gametype]", "Deletes an existing map"));
UtilPlayer.message(player, F.value("/map <name> [gametype]", "Teleport to a map"));
UtilPlayer.message(player, F.value("/list", "List maps"));
UtilPlayer.message(player, F.value("/parse", "Parse your current map!"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, F.value("/join <name>", "Toggle join for player on map"));
UtilPlayer.message(player, F.value("/build <name>", "Toggle build for player on map"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, F.value("/name <name>", "Set name for current map"));
UtilPlayer.message(player, F.value("/author <name>", "Set author for current map"));
UtilPlayer.message(player, F.value("/gametype <type>", "Set gametype for current map"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, F.value("/admin <name>", "Toggle admin for player on map"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, F.value("/create <name> [gametype]", "Creates a new map"));
UtilPlayer.message(player, F.value("/delete <name> [gametype]", "Deletes an existing map"));
UtilPlayer.message(player, F.value("/copy <name> <copy name>", "Copies an existing map"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, F.value("/list", "List maps"));
UtilPlayer.message(player, F.value("/map <name> [gametype]", "Teleport to a map"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cYellow + "Documentation: " + C.cGreen + "http://tinyurl.com/mpxmaps");
}
@ -404,12 +404,13 @@ public class MapParser extends JavaPlugin implements Listener
public void ResetInventory(Player player)
{
UtilInv.Clear(player);
UtilInv.Clear(player);
player.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
player.getInventory().addItem(new ItemStack(Material.STONE_SPADE));
player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE));
player.getInventory().addItem(new ItemStack(Material.STONE_AXE));
player.getInventory().addItem(new ItemStack(Material.WOOD_AXE));
}
public WorldManager getWorldManager()
@ -432,7 +433,7 @@ public class MapParser extends JavaPlugin implements Listener
String name = C.cYellow + event.getPlayer().getName();
if (GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
if (GetData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
name = C.cGreen + event.getPlayer().getName();
String grayName = C.cBlue + event.getPlayer().getName();
@ -458,7 +459,7 @@ public class MapParser extends JavaPlugin implements Listener
public void InteractCancel(PlayerInteractEvent event)
{
//Permission
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
if (!GetData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
{
event.setCancelled(true);
}
@ -470,7 +471,7 @@ public class MapParser extends JavaPlugin implements Listener
if (event.getMessage().startsWith("//"))
{
//Permission
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
if (!GetData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "You do not have Build-Access for this Map."));
event.setCancelled(true);

View File

@ -8,7 +8,6 @@ import java.util.HashMap;
import java.util.HashSet;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
@ -18,7 +17,6 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.material.Wool;
public class Parse
@ -29,7 +27,7 @@ public class Parse
private String[] _args;
private Location _callLoc;
private int _size = 500;
private int _size = 600;
private int _x = 0;
private int _y = 0;
private int _z = 0;

View File

@ -41,7 +41,7 @@ public class AuthorCommand extends BaseCommand
}
//Permission
if (!getPlugin().GetData(world.getName()).CanBuild(player))
if (!getPlugin().GetData(world.getName()).HasAccess(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;

View File

@ -1,68 +0,0 @@
package mineplex.mapparser.command;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class BuildCommand extends BaseCommand
{
public BuildCommand(MapParser plugin)
{
super(plugin, "build");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length != 1)
{
message(player, "Invalid Input. " + F.elem("/build <Name>"));
return true;
}
World world = player.getWorld();
if (world.getName().equals("world"))
{
message(player, "Cannot change Build-List for Lobby.");
return true;
}
//Permission
if (!getPlugin().GetData(world.getName()).CanBuild(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;
}
Player other = UtilPlayer.searchOnline(player, args[0], true);
if (player != null)
{
MapData data = getPlugin().GetData(world.getName());
if (data.BuildList.contains(other.getName()))
{
data.BuildList.remove(other.getName());
data.Write();
getPlugin().Announce("Build-List for " + F.elem(world.getName()) + " (" + other.getName() + " = " + F.tf(false) + ")");
}
else
{
data.BuildList.add(other.getName());
data.Write();
getPlugin().Announce("Build-List for " + F.elem(world.getName()) + " (" + other.getName() + " = " + F.tf(true) + ")");
}
}
return true;
}
}

View File

@ -28,7 +28,7 @@ public class CreateCommand extends BaseCommand
{
if (args.length < 2)
{
message(player, "Invalid Input. " + F.elem("/create <MapName>"));
message(player, "Invalid Input. " + F.elem("/create <MapName> <GameType>"));
return true;
}
@ -66,7 +66,7 @@ public class CreateCommand extends BaseCommand
//Give Access
MapData mapData = getPlugin().GetData(worldName);
mapData.BuildList.add(player.getName());
mapData.AdminList.add(player.getName());
mapData.GameType = gameType;
mapData.Write();

View File

@ -50,7 +50,7 @@ public class DeleteCommand extends BaseCommand
return true;
}
if (!getPlugin().GetData(worldName).CanBuild(player))
if (!getPlugin().GetData(worldName).HasAccess(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;

View File

@ -41,7 +41,7 @@ public class GameTypeCommand extends BaseCommand
}
//Permission
if (!getPlugin().GetData(world.getName()).CanBuild(player))
if (!getPlugin().GetData(world.getName()).HasAccess(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;

View File

@ -43,7 +43,7 @@ public class NameCommand extends BaseCommand
mapName = mapName.trim();
//Permission
if (!getPlugin().GetData(world.getName()).CanBuild(player))
if (!getPlugin().GetData(world.getName()).HasAccess(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;

View File

@ -1,12 +1,10 @@
package mineplex.mapparser.command;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
import mineplex.mapparser.Parse;
@ -24,6 +22,12 @@ public class ParseCommand extends BaseCommand
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (!player.isOp())
{
message(player, "Only OPs can parse maps!");
return true;
}
Location parseLoc = player.getLocation();
World world = parseLoc.getWorld();

View File

@ -52,7 +52,7 @@ public class SaveCommand extends BaseCommand
if (world != null)
{
if (!getPlugin().GetData(worldName).CanBuild(player))
if (!getPlugin().GetData(worldName).HasAccess(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;

View File

@ -565,7 +565,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
}
// Reserved Slot Check
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers())
if (Bukkit.getOnlinePlayers().length >= Bukkit.getServer().getMaxPlayers())
{
if (_serverStatusManager.getCurrentServerName().contains("BETA"))
{

View File

@ -2,15 +2,9 @@ package nautilus.game.arcade.game;
import java.util.*;
import mineplex.core.common.util.*;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager;

View File

@ -226,7 +226,7 @@ public class PowerUpManager implements Listener
if (getGame().GetState() != GameState.Live)
return;
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
Player[] players = Bukkit.getOnlinePlayers();
for (Player player : players)
{