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

This commit is contained in:
Tim Ziankoski 2015-03-09 16:43:00 -04:00
commit 2e06a272b4
14 changed files with 829 additions and 185 deletions

View File

@ -2,6 +2,8 @@ package mineplex.core.gadget.types;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
@ -29,4 +31,10 @@ public abstract class MorphGadget extends Gadget
if (_active.remove(player))
UtilPlayer.message(player, F.main("Gadget", "You unmorphed from " + F.elem(GetName()) + "."));
}
@EventHandler
public void playerDeath(PlayerDeathEvent event)
{
Disable(event.getEntity());
}
}

View File

@ -12,6 +12,7 @@ import mineplex.core.report.command.ReportNotification;
import mineplex.serverdata.DataRepository;
import mineplex.serverdata.RedisDataRepository;
import mineplex.serverdata.Region;
import mineplex.serverdata.Utility;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -189,7 +190,7 @@ public class ReportManager {
*/
public int generateReportId()
{
JedisPool pool = ((RedisDataRepository<Report>) reportRepository).getJedisPool();
JedisPool pool = Utility.getPool(true);
Jedis jedis = pool.getResource();
long uniqueReportId = -1;

View File

@ -9,12 +9,14 @@ import java.util.Set;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import mineplex.serverdata.ConnectionData;
import mineplex.serverdata.DataRepository;
import mineplex.serverdata.MinecraftServer;
import mineplex.serverdata.RedisDataRepository;
import mineplex.serverdata.Region;
import mineplex.serverdata.ServerManager;
import mineplex.serverdata.ServerRepository;
import mineplex.serverdata.Utility;
import mineplex.serverdata.transfers.ServerTransfer;
import mineplex.serverdata.transfers.TransferCommand;
@ -29,9 +31,9 @@ public class QueueRepository
* @param port - the designated port of the QueueRepository database
* @param region - the region of server queues to manage
*/
public QueueRepository(String host, int port, Region region)
public QueueRepository(ConnectionData connectionData, Region region)
{
this._partyRepository = new RedisDataRepository<QueueParty>(host, port, region,
this._partyRepository = new RedisDataRepository<QueueParty>(connectionData, region,
QueueParty.class, "queue-parties");
}
@ -43,7 +45,7 @@ public class QueueRepository
*/
public QueueRepository(Region region)
{
this(ServerManager.DEFAULT_REDIS_HOST, ServerManager.DEFAULT_REDIS_PORT, region);
this(ServerManager.getMasterConnection(), region);
}
public QueueParty getQueueParty(int partyId)

View File

@ -0,0 +1,27 @@
package mineplex.serverdata;
/**
* ConnectionData stores information relevant for initiating a connection to a repository.
* @author MrTwiggy
*
*/
public class ConnectionData
{
private String _host; // The host URL to connect to repository
public String getHost() { return _host; }
private int _port; // The port to connect to repository
public int getPort() { return _port; }
/**
* Constructor
* @param host - the host URL defining the repository
* @param port - the port used for connection to repository
*/
public ConnectionData(String host, int port)
{
_host = host;
_port = port;
}
}

View File

@ -21,8 +21,8 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
public final char KEY_DELIMITER = '.';
// The pool used to retrieve jedis instances.
private JedisPool _jedisPool;
public JedisPool getJedisPool() { return _jedisPool; }
private JedisPool _writePool;
private JedisPool _readPool;
// The geographical region of the servers stored by this ServerRepository
private Region _region;
@ -33,22 +33,30 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
/**
* Class constructor
* @param writeConn
* @param readConn
* @param host
* @param port
* @param region
*/
public RedisDataRepository(String host, int port, Region region,
public RedisDataRepository(ConnectionData writeConn, ConnectionData readConn, Region region,
Class<T> elementType, String elementLabel)
{
_jedisPool = new JedisPool(new JedisPoolConfig(), host, port);
_writePool = Utility.generatePool(writeConn);
_readPool = (writeConn == readConn) ? _writePool : Utility.generatePool(readConn);
_region = region;
_elementType = elementType;
_elementLabel = elementLabel;
}
public RedisDataRepository(ConnectionData conn, Region region, Class<T> elementType, String elementLabel)
{
this(conn, conn, region, elementType, elementLabel);
}
public RedisDataRepository(Region region, Class<T> elementType, String elementLabel)
{
this(ServerManager.DEFAULT_REDIS_HOST, ServerManager.DEFAULT_REDIS_PORT, region,
this(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), region,
elementType, elementLabel);
}
@ -71,7 +79,7 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
public Collection<T> getElements()
{
Collection<T> elements = new HashSet<T>();
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _readPool.getResource();
try
{
@ -99,14 +107,14 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_readPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_readPool.returnResource(jedis);
}
}
@ -117,7 +125,7 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
public T getElement(String dataId)
{
T element = null;
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _readPool.getResource();
try
{
@ -128,14 +136,14 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_readPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_readPool.returnResource(jedis);
}
}
@ -145,7 +153,7 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
@Override
public void addElement(T element, int timeout)
{
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _writePool.getResource();
try
{
@ -163,14 +171,14 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_writePool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_writePool.returnResource(jedis);
}
}
}
@ -190,7 +198,7 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
@Override
public void removeElement(String dataId)
{
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _writePool.getResource();
try
{
@ -205,14 +213,14 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_writePool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_writePool.returnResource(jedis);
}
}
}
@ -226,7 +234,7 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
@Override
public int clean()
{
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _writePool.getResource();
try
{
@ -243,14 +251,14 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_writePool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_writePool.returnResource(jedis);
}
}
@ -260,7 +268,7 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
protected Set<String> getActiveElements()
{
Set<String> dataIds = new HashSet<String>();
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _readPool.getResource();
try
{
@ -271,14 +279,14 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_readPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_readPool.returnResource(jedis);
}
}
@ -288,7 +296,7 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
protected Set<String> getDeadElements()
{
Set<String> dataIds = new HashSet<String>();
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _readPool.getResource();
try
{
@ -299,14 +307,14 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_readPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_readPool.returnResource(jedis);
}
}

View File

@ -31,7 +31,8 @@ public class RedisServerRepository implements ServerRepository
public final char KEY_DELIMITER = '.';
// The pool used to retrieve jedis instances.
private JedisPool _jedisPool;
private JedisPool _writePool;
private JedisPool _readPool;
// The geographical region of the servers stored by this ServerRepository
private Region _region;
@ -41,17 +42,18 @@ public class RedisServerRepository implements ServerRepository
* @param host
* @param port
*/
public RedisServerRepository(String host, int port, Region region)
public RedisServerRepository(ConnectionData writeConn, ConnectionData readConn, Region region)
{
this._jedisPool = new JedisPool(new JedisPoolConfig(), host, port);
this._region = region;
_writePool = Utility.generatePool(writeConn);
_readPool = (writeConn == readConn) ? _writePool : Utility.generatePool(readConn);
_region = region;
}
@Override
public Collection<MinecraftServer> getServerStatuses()
{
Collection<MinecraftServer> servers = new HashSet<MinecraftServer>();
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _readPool.getResource();
try
{
@ -81,14 +83,14 @@ public class RedisServerRepository implements ServerRepository
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_readPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_readPool.returnResource(jedis);
}
}
@ -115,7 +117,7 @@ public class RedisServerRepository implements ServerRepository
public MinecraftServer getServerStatus(String serverName)
{
MinecraftServer server = null;
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _readPool.getResource();
try
{
@ -127,14 +129,14 @@ public class RedisServerRepository implements ServerRepository
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_readPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_readPool.returnResource(jedis);
}
}
@ -144,7 +146,7 @@ public class RedisServerRepository implements ServerRepository
@Override
public void updataServerStatus(MinecraftServer serverData, int timeout)
{
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _writePool.getResource();
try
{
@ -162,14 +164,14 @@ public class RedisServerRepository implements ServerRepository
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_writePool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_writePool.returnResource(jedis);
}
}
}
@ -177,7 +179,7 @@ public class RedisServerRepository implements ServerRepository
@Override
public void removeServerStatus(MinecraftServer serverData)
{
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _writePool.getResource();
try
{
@ -193,14 +195,14 @@ public class RedisServerRepository implements ServerRepository
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_writePool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_writePool.returnResource(jedis);
}
}
}
@ -215,7 +217,7 @@ public class RedisServerRepository implements ServerRepository
public Collection<DedicatedServer> getDedicatedServers()
{
Collection<DedicatedServer> servers = new HashSet<DedicatedServer>();
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _readPool.getResource();
try
{
@ -254,14 +256,14 @@ public class RedisServerRepository implements ServerRepository
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_readPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_readPool.returnResource(jedis);
}
}
@ -272,7 +274,7 @@ public class RedisServerRepository implements ServerRepository
public Collection<ServerGroup> getServerGroups(Collection<MinecraftServer> serverStatuses)
{
Collection<ServerGroup> servers = new HashSet<ServerGroup>();
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _readPool.getResource();
try
{
@ -311,14 +313,14 @@ public class RedisServerRepository implements ServerRepository
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_readPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_readPool.returnResource(jedis);
}
}
@ -333,7 +335,7 @@ public class RedisServerRepository implements ServerRepository
protected Set<String> getActiveNames(String key)
{
Set<String> names = new HashSet<String>();
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _readPool.getResource();
try
{
@ -344,14 +346,14 @@ public class RedisServerRepository implements ServerRepository
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_readPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_readPool.returnResource(jedis);
}
}
@ -365,7 +367,7 @@ public class RedisServerRepository implements ServerRepository
protected Set<String> getDeadNames(String key)
{
Set<String> names = new HashSet<String>();
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _readPool.getResource();
try
{
@ -376,14 +378,14 @@ public class RedisServerRepository implements ServerRepository
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_readPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_readPool.returnResource(jedis);
}
}
@ -404,7 +406,7 @@ public class RedisServerRepository implements ServerRepository
public Collection<MinecraftServer> getDeadServers()
{
Set<MinecraftServer> servers = new HashSet<MinecraftServer>();
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _readPool.getResource();
try
{
@ -434,14 +436,14 @@ public class RedisServerRepository implements ServerRepository
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_readPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_readPool.returnResource(jedis);
}
}
@ -451,7 +453,7 @@ public class RedisServerRepository implements ServerRepository
@Override
public void updateServerGroup(ServerGroup serverGroup)
{
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _writePool.getResource();
try
{
@ -469,14 +471,14 @@ public class RedisServerRepository implements ServerRepository
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_writePool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_writePool.returnResource(jedis);
}
}
}
@ -484,7 +486,7 @@ public class RedisServerRepository implements ServerRepository
@Override
public void removeServerGroup(ServerGroup serverGroup)
{
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _writePool.getResource();
try
{
@ -500,14 +502,14 @@ public class RedisServerRepository implements ServerRepository
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_writePool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_writePool.returnResource(jedis);
}
}
}
@ -516,7 +518,7 @@ public class RedisServerRepository implements ServerRepository
public ServerGroup getServerGroup(String serverGroup)
{
ServerGroup server = null;
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _readPool.getResource();
try
{
String key = concatenate("servergroups", serverGroup);
@ -527,14 +529,14 @@ public class RedisServerRepository implements ServerRepository
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
_readPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
_readPool.returnResource(jedis);
}
}

View File

@ -15,7 +15,8 @@ public class ServerCommandManager
public final String SERVER_COMMANDS_CHANNEL = "commands.server";
private JedisPool _jedisPool;
private JedisPool _writePool;
private JedisPool _readPool;
private Map<String, CommandType> _commandTypes;
private String _localServerName;
@ -27,8 +28,8 @@ public class ServerCommandManager
*/
private ServerCommandManager()
{
_jedisPool = new JedisPool(new JedisPoolConfig(), ServerManager.DEFAULT_REDIS_HOST,
ServerManager.DEFAULT_REDIS_PORT);
_writePool = Utility.generatePool(ServerManager.getPubSubConnection()); // Hardcoded connection to standalone redis instance
_readPool = _writePool;
_commandTypes = new HashMap<String, CommandType>();
initialize();
@ -40,7 +41,7 @@ public class ServerCommandManager
*/
private void initialize()
{
final Jedis jedis = _jedisPool.getResource();
final Jedis jedis = _readPool.getResource();
// Spin up a new thread and subscribe to the Redis pubsub network
Thread thread = new Thread("Redis Manager")
@ -57,7 +58,7 @@ public class ServerCommandManager
}
finally
{
_jedisPool.returnResource(jedis);
_readPool.returnResource(jedis);
}
}
};
@ -75,7 +76,7 @@ public class ServerCommandManager
{
public void run()
{
Jedis jedis = _jedisPool.getResource();
Jedis jedis = _writePool.getResource();
try
{
@ -89,7 +90,7 @@ public class ServerCommandManager
}
finally
{
_jedisPool.returnResource(jedis);
_writePool.returnResource(jedis);
}
}
}).start();

View File

@ -2,6 +2,7 @@ package mineplex.serverdata;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
/**
* ServerManager handles the creation/management of {@link ServerRepository}s for use.
@ -10,11 +11,9 @@ import java.util.Map;
*/
public class ServerManager
{
// The host of the default redis database used for server repository
public final static String DEFAULT_REDIS_HOST = "10.33.53.16";
// The default port used by redis databases
public final static int DEFAULT_REDIS_PORT = 6379;
// Ports associated with slave redis instances
private static final int[] SLAVE_PORTS = {6378, 6380, 6381};
private static Random random = new Random();
// The cached repository instances
private static Map<Region, ServerRepository> repositories = new HashMap<Region, ServerRepository>();
@ -25,11 +24,11 @@ public class ServerManager
* @param region - the geographical region of the {@link ServerRepository}.
* @return a newly instanced (or cached) {@link ServerRepository} for the specified {@code region}.
*/
public static ServerRepository getServerRepository(String host, int port, Region region)
public static ServerRepository getServerRepository(ConnectionData writeConn, ConnectionData readConn, Region region)
{
if (repositories.containsKey(region)) return repositories.get(region);
ServerRepository repository = new RedisServerRepository(host, port, region);
ServerRepository repository = new RedisServerRepository(writeConn, readConn, region);
repositories.put(region, repository);
return repository;
}
@ -42,7 +41,32 @@ public class ServerManager
*/
public static ServerRepository getServerRepository(Region region)
{
return getServerRepository(DEFAULT_REDIS_HOST, DEFAULT_REDIS_PORT, region);
return getServerRepository(getMasterConnection(), getSlaveConnection(), region);
}
/**
* @return the {@link ConnectionData} associated with the master instance connection.
*/
public static ConnectionData getMasterConnection()
{
return new ConnectionData("10.33.53.16", 6379);
}
/**
* Non-Deterministic: Generates random slave instance connection.
* @return the {@link ConnectionData} associated with a random slave connection.
*/
public static ConnectionData getSlaveConnection()
{
int port = SLAVE_PORTS[random.nextInt(SLAVE_PORTS.length)];
return new ConnectionData("10.33.53.16", port);
}
/**
* @return the {@link ConnectionData} associated with the dedicated PubSub instance.
*/
public static ConnectionData getPubSubConnection()
{
return new ConnectionData("10.33.53.16", 6377);
}
}

View File

@ -20,7 +20,8 @@ public class Utility
public static Gson getGson() { return _gson; }
// Public static jedis pool for interacting with central default jedis repo.
private static JedisPool _jedisPool;
private static JedisPool _masterPool;
private static JedisPool _slavePool;
/**
* @param object - the (non-null) object to serialize
@ -66,7 +67,8 @@ public class Utility
public static long currentTimeSeconds()
{
long currentTime = 0;
Jedis jedis = getPool().getResource();
JedisPool pool = getPool(false);
Jedis jedis = pool.getResource();
try
{
@ -74,7 +76,7 @@ public class Utility
}
finally
{
getPool().returnResource(jedis);
pool.returnResource(jedis);
}
return currentTime;
@ -87,7 +89,8 @@ public class Utility
public static long currentTimeMillis()
{
long currentTime = 0;
Jedis jedis = getPool().getResource();
JedisPool pool = getPool(false);
Jedis jedis = pool.getResource();
try
{
@ -95,20 +98,44 @@ public class Utility
}
finally
{
getPool().returnResource(jedis);
pool.returnResource(jedis);
}
return currentTime * 1000;
}
public static JedisPool getPool()
/**
* @param connData - the connection data specifying the database to be connected to.
* @return a newly instantiated {@link JedisPool} connected to the provided {@link ConnectionData} repository.
*/
public static JedisPool generatePool(ConnectionData connData)
{
if (_jedisPool == null)
return new JedisPool(new JedisPoolConfig(), connData.getHost(), connData.getPort());
}
/**
* @param writeable - whether or not the Jedis connections returned should be writeable to.
* @return a globally available {@link JedisPool}
*/
public static JedisPool getPool(boolean writeable)
{
if (writeable)
{
_jedisPool = new JedisPool(new JedisPoolConfig(),
ServerManager.DEFAULT_REDIS_HOST, ServerManager.DEFAULT_REDIS_PORT);
if (_masterPool == null)
{
_masterPool = generatePool(ServerManager.getMasterConnection());
}
return _masterPool;
}
else
{
if (_slavePool == null)
{
_slavePool = generatePool(ServerManager.getSlaveConnection());
}
return _slavePool;
}
return _jedisPool;
}
}

View File

@ -155,10 +155,12 @@ public abstract class Game implements Listener
public boolean DamageTeamOther = true;
public boolean BlockBreak = false;
public boolean BlockBreakCreative = false;
public HashSet<Integer> BlockBreakAllow = new HashSet<Integer>();
public HashSet<Integer> BlockBreakDeny = new HashSet<Integer>();
public boolean BlockPlace = false;
public boolean BlockPlaceCreative = false;
public HashSet<Integer> BlockPlaceAllow = new HashSet<Integer>();
public HashSet<Integer> BlockPlaceDeny = new HashSet<Integer>();

View File

@ -1,20 +1,39 @@
package nautilus.game.arcade.game.games.event;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Wolf;
import org.bukkit.entity.Zombie;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -23,6 +42,7 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
@ -32,10 +52,12 @@ import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.disguise.disguises.DisguiseEnderman;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.event.kits.*;
import nautilus.game.arcade.ArcadeManager;
@ -56,6 +78,8 @@ public class EventGame extends SoloGame
private boolean _gadgetsEnabled = true;
private NautHashMap<String, Integer> _radius = new NautHashMap<String, Integer>();
private NautHashMap<Material, Integer> _kitItems = new NautHashMap<Material, Integer>();
public EventGame(ArcadeManager manager)
{
super(manager, GameType.Event,
@ -83,7 +107,10 @@ public class EventGame extends SoloGame
this.TeleportsDisqualify = false;
this.PrepareFreeze = false;
this.BlockPlaceCreative = true;
this.BlockBreakCreative = true;
//Dont timeout
this.GameTimeout = -1;
@ -97,29 +124,29 @@ public class EventGame extends SoloGame
if (InProgress())
joinTeam(event.getPlayer());
}
// @EventHandler
// public void specToTeam(UpdateEvent event)
// {
// if (!InProgress())
// return;
//
// if (event.getType() != UpdateType.FAST)
// return;
//
// for (Player player : UtilServer.getPlayers())
// {
// if (!GetTeamList().get(0).HasPlayer(player))
// {
// joinTeam(player);
// }
// }
// }
// @EventHandler
// public void specToTeam(UpdateEvent event)
// {
// if (!InProgress())
// return;
//
// if (event.getType() != UpdateType.FAST)
// return;
//
// for (Player player : UtilServer.getPlayers())
// {
// if (!GetTeamList().get(0).HasPlayer(player))
// {
// joinTeam(player);
// }
// }
// }
public void joinTeam(Player player)
{
Announce(C.cRed + C.Bold + player.getName() + " joined " + GetTeamList().get(0).GetName());
//Set Team
SetPlayerTeam(player, GetTeamList().get(0), true);
@ -133,10 +160,10 @@ public class EventGame extends SoloGame
other.hidePlayer(player);
other.showPlayer(player);
}
//Spawn
GetTeamList().get(0).SpawnTeleport(player);
//GameMode
player.setGameMode(GameMode.SURVIVAL);
}
@ -158,13 +185,32 @@ public class EventGame extends SoloGame
UtilPlayer.message(player, F.value("/e scoreboard <Line #> [Text]", "Sets Scoreboard Text"));
}
private void commandHelpSettings(Player player)
{
UtilPlayer.message(player, F.main("Event", "Displaying Settings Commands;"));
UtilPlayer.message(player, F.value("/e damage all", "Toggles All Damage"));
UtilPlayer.message(player, F.value("/e damage pvp", "Toggles PvP Damage"));
UtilPlayer.message(player, F.value("/e damage pve", "Toggles PvE Damage"));
UtilPlayer.message(player, F.value("/e damage pve", "Toggles EvP Damage"));
UtilPlayer.message(player, F.value("/e health <-1 to 20>", "Locks Players Health"));
UtilPlayer.message(player, F.value("/e hunger <-1 to 20>", "Locks Players Hunger"));
UtilPlayer.message(player, F.value("/e item drop", "Toggles Item Drop"));
UtilPlayer.message(player, F.value("/e item pickup", "Toggles Item Pickup"));
UtilPlayer.message(player, F.value("/e blockplace", "Toggles Block Placing (On/Off)"));
UtilPlayer.message(player, F.value("/e blockplace whitelist <id>", "Whitelists Block Place"));
UtilPlayer.message(player, F.value("/e blockplace blacklist <id>", "Whitelists Block Place"));
UtilPlayer.message(player, F.value("/e blockbreak", "Toggles Block Breaking (On/Off)"));
UtilPlayer.message(player, F.value("/e blockbreak whitelist <id>", "Whitelists Block Break"));
UtilPlayer.message(player, F.value("/e blockbreak blacklist <id>", "Blacklists Block Break"));
}
//Command Handler
@EventHandler(priority = EventPriority.LOWEST)
public void commandHandler(PlayerCommandPreprocessEvent event)
{
if (!InProgress())
return;
if (!event.getMessage().toLowerCase().startsWith("/e "))
return;
@ -176,10 +222,16 @@ public class EventGame extends SoloGame
//Trim off /e and split to args
String[] args = event.getMessage().substring(3, event.getMessage().length()).split(" ");
if (args.length == 0)
if (args.length == 0 || args[0].equalsIgnoreCase("help"))
{
commandHelp(event.getPlayer());
}
else if (args[0].equalsIgnoreCase("settings"))
{
commandHelpSettings(event.getPlayer());
}
//XXX Commands
else if (args[0].equalsIgnoreCase("tp"))
{
commandTeleport(event.getPlayer(), args);
@ -208,6 +260,221 @@ public class EventGame extends SoloGame
{
commandScoreboard(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("whitelist"))
{
commandWhitelist(event.getPlayer(), args);
}
//XXX Settings
else if (event.getMessage().toLowerCase().equals("/e damage all"))
{
Damage = !Damage;
Announce(F.main("Event Settings", F.value("Damage All", F.tf(Damage))));
}
else if (event.getMessage().toLowerCase().equals("/e damage pvp"))
{
DamagePvP = !DamagePvP;
Announce(F.main("Event Settings", F.value("Damage PvP", F.tf(DamagePvP))));
}
else if (event.getMessage().toLowerCase().equals("/e damage pve"))
{
DamagePvE = !DamagePvE;
Announce(F.main("Event Settings", F.value("Damage PvE", F.tf(DamagePvE))));
}
else if (event.getMessage().toLowerCase().equals("/e damage evp"))
{
DamageEvP = !DamageEvP;
Announce(F.main("Event Settings", F.value("Damage EvP", F.tf(DamageEvP))));
}
else if (args[0].equalsIgnoreCase("health"))
{
commandHealth(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("hunger"))
{
commandHunger(event.getPlayer(), args);
}
else if (event.getMessage().toLowerCase().equals("/e item drop"))
{
ItemDrop = !ItemDrop;
Announce(F.main("Event Settings", F.value("Item Drop", F.tf(ItemDrop))));
}
else if (event.getMessage().toLowerCase().equals("/e item pickup"))
{
ItemPickup = !ItemPickup;
Announce(F.main("Event Settings", F.value("Item Pickup", F.tf(ItemPickup))));
}
else if (event.getMessage().toLowerCase().equals("/e blockplace"))
{
BlockPlace = !BlockPlace;
Announce(F.main("Event Settings", F.value("Block Place", F.tf(BlockPlace))));
}
else if (args.length >= 4 && args[0].equalsIgnoreCase("blockplace")
&& (args[1].equalsIgnoreCase("whitelist") || args[1].equalsIgnoreCase("blacklist"))
&& (args[2].equalsIgnoreCase("add") || args[2].equalsIgnoreCase("remove")))
{
commandBlockPlace(event.getPlayer(), args, args[1].equalsIgnoreCase("whitelist"), args[2].equalsIgnoreCase("add"));
}
else if (event.getMessage().toLowerCase().equals("/e blockbreak"))
{
BlockBreak = !BlockBreak;
Announce(F.main("Event Settings", F.value("Block Break", F.tf(BlockBreak))));
}
else if (args.length >= 4 && args[0].equalsIgnoreCase("blockbreak")
&& (args[1].equalsIgnoreCase("whitelist") || args[1].equalsIgnoreCase("blacklist"))
&& (args[2].equalsIgnoreCase("add") || args[2].equalsIgnoreCase("remove")))
{
commandBlockBreak(event.getPlayer(), args, args[1].equalsIgnoreCase("whitelist"), args[2].equalsIgnoreCase("add"));
}
}
private void commandBlockPlace(Player player, String[] args, boolean whitelist, boolean add)
{
try
{
int blockId = Integer.parseInt(args[3]);
if (whitelist)
{
if (add)
{
BlockPlaceAllow.add(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", "Added " + blockId)));
}
else
{
BlockPlaceAllow.remove(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", "Removed " + blockId)));
}
}
else
{
if (add)
{
BlockPlaceDeny.add(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", "Added " + blockId)));
}
else
{
BlockPlaceDeny.remove(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", "Removed " + blockId)));
}
}
return;
}
catch (Exception e)
{
}
commandHelpSettings(player);
}
private void commandBlockBreak(Player player, String[] args, boolean whitelist, boolean add)
{
try
{
int blockId = Integer.parseInt(args[3]);
if (whitelist)
{
if (add)
{
BlockBreakAllow.add(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", "Added " + blockId)));
}
else
{
BlockBreakAllow.remove(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", "Removed " + blockId)));
}
}
else
{
if (add)
{
BlockBreakDeny.add(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", "Added " + blockId)));
}
else
{
BlockBreakDeny.remove(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", "Removed " + blockId)));
}
}
return;
}
catch (Exception e)
{
}
commandHelpSettings(player);
}
private void commandHealth(Player player, String[] args)
{
try
{
if (args.length >= 2)
{
int health = Integer.parseInt(args[1]);
if (health <= 0)
health = -1;
if (health > 20)
health = 20;
HealthSet = health;
if (HealthSet == -1)
Announce(F.main("Event Settings", F.value("Health Set", "Disabled")));
else
Announce(F.main("Event Settings", F.value("Health Set", HealthSet + "")));
return;
}
}
catch (Exception e)
{
}
commandHelpSettings(player);
}
private void commandHunger(Player player, String[] args)
{
try
{
if (args.length >= 2)
{
int hunger = Integer.parseInt(args[1]);
if (hunger <= 0)
hunger = -1;
if (hunger > 20)
hunger = 20;
HungerSet = hunger;
if (HungerSet == -1)
Announce(F.main("Event Settings", F.value("Hunger Set", "Disabled")));
else
Announce(F.main("Event Settings", F.value("Hunger Set", HungerSet + "")));
return;
}
}
catch (Exception e)
{
}
commandHelpSettings(player);
}
//Teleport Command (To, Here, All)
@ -258,17 +525,17 @@ public class EventGame extends SoloGame
public void commandGadget(Player player, String[] args)
{
_gadgetsEnabled = !_gadgetsEnabled;
if (!_gadgetsEnabled)
{
Manager.getCosmeticManager().getMountManager().DisableAll();
Manager.getCosmeticManager().getGadgetManager().DisableAll();
}
for (Player other : UtilServer.getPlayers())
other.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(_gadgetsEnabled ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled"));
}
//Silence
@EventHandler
public void commandSilence(Player player, String[] args)
@ -359,13 +626,6 @@ public class EventGame extends SoloGame
}
//Game Settings - PvP, Blocks, etc
@EventHandler
public void commandSetting(Player player, String[] args)
{
}
//Double Jump
@EventHandler
public void commandDoubleJump(Player player, String[] args)
@ -448,6 +708,255 @@ public class EventGame extends SoloGame
}
}
@EventHandler
public void commandWhitelist(Player player, String[] args)
{
//On and Off
if (args.length >= 2)
{
if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("of"))
{
UtilServer.getServer().setWhitelist(args[1].equalsIgnoreCase("on"));
return;
}
}
//Add and Remove
if (args.length >= 3)
{
if (args[1].equalsIgnoreCase("add") || args[1].equalsIgnoreCase("remove"))
{
OfflinePlayer target = Bukkit.getOfflinePlayer(args[2]);
if (args[1].equalsIgnoreCase("add"))
UtilServer.getServer().getWhitelistedPlayers().add(target);
else
UtilServer.getServer().getWhitelistedPlayers().remove(target);
return;
}
}
commandHelp(player);
}
@EventHandler
protected void commandMob(Player caller, String[] args)
{
if (args.length == 1)
{
HashMap<EntityType, Integer> entMap = new HashMap<EntityType, Integer>();
int count = 0;
for (World world : UtilServer.getServer().getWorlds())
{
for (Entity ent : world.getEntities())
{
if (!entMap.containsKey(ent.getType()))
entMap.put(ent.getType(), 0);
entMap.put(ent.getType(), 1 + entMap.get(ent.getType()));
count++;
}
}
UtilPlayer.message(caller, F.main("Creature", "Listing Entities:"));
for (EntityType cur : entMap.keySet())
{
UtilPlayer.message(caller, F.desc(UtilEnt.getName(cur), entMap.get(cur)+""));
}
UtilPlayer.message(caller, F.desc("Total", count+""));
}
else
{
EntityType type = UtilEnt.searchEntity(caller, args[1], true);
if (type == null)
return;
UtilPlayer.message(caller, F.main("Creature", "Spawning Creature(s);"));
//Store Args
HashSet<String> argSet = new HashSet<String>();
for (int i = 2 ; i < args.length ; i++)
if (args[i].length() > 0)
argSet.add(args[i]);
//Search Count
int count = 1;
HashSet<String> argHandle = new HashSet<String>();
for (String arg : argSet)
{
try
{
int newCount = Integer.parseInt(arg);
if (newCount <= 0)
continue;
//Set Count
count = newCount;
UtilPlayer.message(caller, F.desc("Amount", count+""));
//Flag Arg
argHandle.add(arg);
break;
}
catch (Exception e)
{
//None
}
}
for (String arg : argHandle)
argSet.remove(arg);
//Spawn
HashSet<Entity> entSet = new HashSet<Entity>();
for (int i = 0 ; i < count ; i++)
{
CreatureAllowOverride = true;
entSet.add(Manager.GetCreature().SpawnEntity(caller.getTargetBlock(null, 0).getLocation().add(0.5, 1, 0.5), type));
CreatureAllowOverride = false;
}
//Search Vars
for (String arg : argSet)
{
if (arg.length() == 0)
continue;
//Baby
else if (arg.equalsIgnoreCase("baby") || arg.equalsIgnoreCase("b"))
{
for (Entity ent : entSet)
{
if (ent instanceof Ageable)
((Ageable)ent).setBaby();
else if (ent instanceof Zombie)
((Zombie)ent).setBaby(true);
}
UtilPlayer.message(caller, F.desc("Baby", "True"));
argHandle.add(arg);
}
//Lock
else if (arg.equalsIgnoreCase("age") || arg.equalsIgnoreCase("lock"))
{
for (Entity ent : entSet)
if (ent instanceof Ageable)
{
((Ageable)ent).setAgeLock(true);
UtilPlayer.message(caller, F.desc("Age", "False"));
}
argHandle.add(arg);
}
//Angry
else if (arg.equalsIgnoreCase("angry") || arg.equalsIgnoreCase("a"))
{
for (Entity ent : entSet)
if (ent instanceof Wolf)
((Wolf)ent).setAngry(true);
for (Entity ent : entSet)
if (ent instanceof Skeleton)
((Skeleton)ent).setSkeletonType(SkeletonType.WITHER);
UtilPlayer.message(caller, F.desc("Angry", "True"));
argHandle.add(arg);
}
//Profession
else if (arg.toLowerCase().charAt(0) == 'p')
{
try
{
String prof = arg.substring(1, arg.length());
Profession profession = null;
for (Profession cur : Profession.values())
if (cur.name().toLowerCase().contains(prof.toLowerCase()))
profession = cur;
UtilPlayer.message(caller, F.desc("Profession", profession.name()));
for (Entity ent : entSet)
if (ent instanceof Villager)
((Villager)ent).setProfession(profession);
}
catch (Exception e)
{
UtilPlayer.message(caller, F.desc("Profession", "Invalid [" + arg + "] on " + type.name()));
}
argHandle.add(arg);
}
//Size
else if (arg.toLowerCase().charAt(0) == 's')
{
try
{
String size = arg.substring(1, arg.length());
UtilPlayer.message(caller, F.desc("Size", Integer.parseInt(size)+""));
for (Entity ent : entSet)
if (ent instanceof Slime)
((Slime)ent).setSize(Integer.parseInt(size));
}
catch (Exception e)
{
UtilPlayer.message(caller, F.desc("Size", "Invalid [" + arg + "] on " + type.name()));
}
argHandle.add(arg);
}
else if (arg.toLowerCase().charAt(0) == 'n' && arg.length() > 1)
{
try
{
String name = "";
for (char c : arg.substring(1, arg.length()).toCharArray())
{
if (c != '_')
name += c;
else
name += " ";
}
for (Entity ent : entSet)
{
if (ent instanceof CraftLivingEntity)
{
CraftLivingEntity cEnt = (CraftLivingEntity)ent;
cEnt.setCustomName(name);
cEnt.setCustomNameVisible(true);
}
}
}
catch (Exception e)
{
UtilPlayer.message(caller, F.desc("Size", "Invalid [" + arg + "] on " + type.name()));
}
argHandle.add(arg);
}
}
for (String arg : argHandle)
argSet.remove(arg);
for (String arg : argSet)
UtilPlayer.message(caller, F.desc("Unhandled", arg));
//Inform
UtilPlayer.message(caller, F.main("Creature", "Spawned " + count + " " + UtilEnt.getName(type) + "."));
}
}
@EventHandler
public void doubleJumpTrigger(PlayerToggleFlightEvent event)
{
@ -483,7 +992,7 @@ public class EventGame extends SoloGame
{
if (!_doubleJump)
return;
if (event.getType() != UpdateType.TICK)
return;
@ -506,20 +1015,20 @@ public class EventGame extends SoloGame
if (!_gadgetsEnabled)
event.setCancelled(true);
}
@EventHandler
public void mountActivate(MountActivateEvent event)
{
if (!_gadgetsEnabled)
event.setCancelled(true);
}
@EventHandler
public void forcefieldUpdate(UpdateEvent event)
{
if (!InProgress())
return;
if (event.getType() != UpdateType.FASTER)
return;
@ -547,7 +1056,7 @@ public class EventGame extends SoloGame
Entity bottom = other;
while (bottom.getVehicle() != null)
bottom = bottom.getVehicle();
UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(player, bottom), 1.6, true, 0.8, 0, 10, true);
other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f);
}
@ -555,48 +1064,54 @@ public class EventGame extends SoloGame
}
}
}
// @EventHandler
// public void updateVisibility(UpdateEvent event)
// {
// if (!InProgress())
// return;
//
// if (event.getType() != UpdateType.FAST)
// return;
//
// for (Player player : UtilServer.getPlayers())
// {
// if (!Manager.getPreferences().Get(player).ShowPlayers)
// {
// for (Player other : UtilServer.getPlayers())
// {
// if (player.equals(other))
// continue;
//
// ((CraftPlayer)player).hidePlayer(other, true, false);
// }
// }
// else
// {
// for (Player other : UtilServer.getPlayers())
// {
// if (player.equals(other))
// continue;
//
// if ((Manager.getPreferences().Get(player).Invisibility && _mps.isAdmin(player, false)) || )
// {
// ((CraftPlayer)other).hidePlayer(player, true, false);
// }
// else
// {
// other.showPlayer(player);
// }
// }
// }
// }
// }
@EventHandler(priority = EventPriority.LOW)
public void explosionBlocks(EntityExplodeEvent event)
{
event.blockList().clear();
}
// @EventHandler
// public void updateVisibility(UpdateEvent event)
// {
// if (!InProgress())
// return;
//
// if (event.getType() != UpdateType.FAST)
// return;
//
// for (Player player : UtilServer.getPlayers())
// {
// if (!Manager.getPreferences().Get(player).ShowPlayers)
// {
// for (Player other : UtilServer.getPlayers())
// {
// if (player.equals(other))
// continue;
//
// ((CraftPlayer)player).hidePlayer(other, true, false);
// }
// }
// else
// {
// for (Player other : UtilServer.getPlayers())
// {
// if (player.equals(other))
// continue;
//
// if ((Manager.getPreferences().Get(player).Invisibility && _mps.isAdmin(player, false)) || )
// {
// ((CraftPlayer)other).hidePlayer(player, true, false);
// }
// else
// {
// other.showPlayer(player);
// }
// }
// }
// }
// }
@Override
public void EndCheck()
{
@ -627,12 +1142,23 @@ public class EventGame extends SoloGame
Scoreboard.Draw();
}
//This re-enables cosmetic hotbar, because MPS disables it
@EventHandler(priority = EventPriority.MONITOR)
public void fixHotbarItemTemp(PlayerCommandPreprocessEvent event)
public void fixHotbarItemTemp(GameStateChangeEvent event)
{
if (event.getMessage().toLowerCase().startsWith("/sethost"))
Manager.GetServerConfig().HotbarInventory = true;
Manager.GetServerConfig().HotbarInventory = true;
}
public void giveItems(Player player)
{
UtilInv.Clear(player);
for (Material mat : _kitItems.keySet())
{
int amount = _kitItems.get(mat);
player.getInventory().addItem(new ItemStack(mat, amount));
}
}
}

View File

@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.event.EventGame;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
@ -32,6 +33,6 @@ public class KitPlayer extends Kit
@Override
public void GiveItems(Player player)
{
((EventGame)Manager.GetGame()).giveItems(player);
}
}

View File

@ -7,6 +7,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.party.Party;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.Game.GameState;
@ -68,11 +69,17 @@ public class GameChatManager implements Listener
//Rank Prefix & MPS Host Prefix
if (Manager.GetGameHostManager().isHost(event.getPlayer()))
{
rankStr = C.cDGreen + C.Bold + "MPS Host ";
if (Manager.GetGame() != null && Manager.GetGame().GetType() == GameType.Event)
rankStr = C.cDGreen + C.Bold + "Event Host ";
else
rankStr = C.cDGreen + C.Bold + "MPS Host ";
}
else if (Manager.GetGameHostManager().isAdmin(event.getPlayer(), false))
{
rankStr = C.cDGreen + C.Bold + "MPS Admin ";
if (Manager.GetGame() != null && Manager.GetGame().GetType() == GameType.Event)
rankStr = C.cDGreen + C.Bold + "Event Admin ";
else
rankStr = C.cDGreen + C.Bold + "MPS Admin ";
}
else
{

View File

@ -319,6 +319,10 @@ public class GameFlagManager implements Listener
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
event.setCancelled(true);
}
else if (game.BlockPlaceCreative && player.getGameMode() == GameMode.CREATIVE) // Event Server Allowance
{
return;
}
else
{
if (game.BlockPlace)
@ -356,6 +360,10 @@ public class GameFlagManager implements Listener
{
event.setCancelled(true);
}
else if (game.BlockBreakCreative && player.getGameMode() == GameMode.CREATIVE) // Event Server Allowance
{
return;
}
else
{
if (game.BlockBreak)