Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
9cf0e4d1e8
@ -314,6 +314,33 @@
|
||||
<zipfileset src="../Libraries/commons-pool2-2.2.jar" />
|
||||
</jar>
|
||||
<copy file="../bin/ServerMonitor.jar" todir="../../Testing/ServerMonitor/"/>
|
||||
</target>
|
||||
<target name ="ChestConverter" description="ChestConverter">
|
||||
<jar jarfile="../bin/ChestConverter.jar">
|
||||
<fileset dir="../Mineplex.Core.Common/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.ChestConverter/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
|
||||
<zipfileset src="../Libraries/mysql.zip" />
|
||||
|
||||
<manifest>
|
||||
<attribute name="Main-Class"
|
||||
value="mineplex.chestConverter.ChestConverter"/>
|
||||
</manifest>
|
||||
|
||||
<zipfileset src="../Libraries/httpclient-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpcore-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpclient-cache-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpmime-4.2.jar" />
|
||||
<zipfileset src="../Libraries/gson-2.2.1.jar" />
|
||||
<zipfileset src="../Libraries/commons-logging-1.1.1.jar" />
|
||||
<zipfileset src="../Libraries/commons-codec-1.6.jar" />
|
||||
<zipfileset src="../Libraries/commons-pool2-2.2.jar" />
|
||||
</jar>
|
||||
<copy file="../bin/ChestConverter.jar" todir="../../Testing/ChestConverter/"/>
|
||||
</target>
|
||||
<target name ="Queuer" description="Queuer">
|
||||
<jar jarfile="../bin/Queuer.jar">
|
||||
|
@ -54,6 +54,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>();
|
||||
|
||||
private NautHashMap<UUID, Long> _exemptTimeMap = new NautHashMap<UUID, Long>();
|
||||
private NautHashMap<UUID, NautHashMap<CheckType, Long>> _doubleStrike = new NautHashMap<UUID, NautHashMap<CheckType, Long>>();
|
||||
|
||||
private Field _destroyId;
|
||||
|
||||
@ -76,6 +77,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
|
||||
NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
|
||||
NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
|
||||
NCPHookManager.addHook(CheckType.ALL, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -138,6 +140,24 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
for (Iterator<Entry<UUID, NautHashMap<CheckType, Long>>> iterator = _doubleStrike.entrySet().iterator(); iterator.hasNext();)
|
||||
{
|
||||
Entry<UUID, NautHashMap<CheckType, Long>> entry = iterator.next();
|
||||
|
||||
for (Iterator<Entry<CheckType, Long>> innerIterator = entry.getValue().entrySet().iterator(); innerIterator.hasNext();)
|
||||
{
|
||||
final Entry<CheckType, Long> entry2 = innerIterator.next();
|
||||
|
||||
if (System.currentTimeMillis() > entry2.getValue())
|
||||
{
|
||||
innerIterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.getValue() == null || entry.getValue().size() == 0)
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -556,11 +576,28 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
|
||||
@Override
|
||||
public boolean onCheckFailure(CheckType checkType, Player player, IViolationInfo violationInfo)
|
||||
{
|
||||
boolean failure = _exemptTimeMap.containsKey(player.getUniqueId());
|
||||
{
|
||||
boolean failure = false;
|
||||
|
||||
if (failure)
|
||||
MovingData.getData(player).clearFlyData();
|
||||
if (checkType == CheckType.MOVING_SURVIVALFLY || checkType == CheckType.MOVING_PASSABLE)
|
||||
{
|
||||
failure = _exemptTimeMap.containsKey(player.getUniqueId());
|
||||
|
||||
if (failure)
|
||||
MovingData.getData(player).clearFlyData();
|
||||
}
|
||||
|
||||
// This is the second strike system.
|
||||
if (!failure)
|
||||
{
|
||||
if (!_doubleStrike.containsKey(player.getUniqueId()) || !_doubleStrike.get(player.getUniqueId()).containsKey(checkType.getParent()))
|
||||
failure = true;
|
||||
|
||||
if (!_doubleStrike.containsKey(player.getUniqueId()))
|
||||
_doubleStrike.put(player.getUniqueId(), new NautHashMap<CheckType, Long>());
|
||||
|
||||
_doubleStrike.get(player.getUniqueId()).put(checkType.getParent(), System.currentTimeMillis() + 5000);
|
||||
}
|
||||
|
||||
return failure;
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ public final class DBPool
|
||||
source.setUrl(url);
|
||||
source.setUsername(username);
|
||||
source.setPassword(password);
|
||||
source.setMaxTotal(10);
|
||||
source.setMaxIdle(3);
|
||||
source.setMaxTotal(2);
|
||||
source.setMaxIdle(2);
|
||||
source.setTimeBetweenEvictionRunsMillis(180 * 1000);
|
||||
source.setSoftMinEvictableIdleTimeMillis(180 * 1000);
|
||||
|
||||
|
@ -8,6 +8,8 @@ import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.column.Column;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -33,6 +35,7 @@ public abstract class RepositoryBase implements Listener
|
||||
private String _password;
|
||||
|
||||
protected JavaPlugin Plugin;
|
||||
protected DataSource DataSource;
|
||||
|
||||
public RepositoryBase(JavaPlugin plugin, String connectionString, String username, String password)
|
||||
{
|
||||
@ -57,6 +60,26 @@ public abstract class RepositoryBase implements Listener
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public RepositoryBase(JavaPlugin plugin, DataSource dataSource)
|
||||
{
|
||||
Plugin = plugin;
|
||||
DataSource = dataSource;
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
initialize();
|
||||
update();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
protected abstract void initialize();
|
||||
|
||||
protected abstract void update();
|
||||
@ -73,7 +96,12 @@ public abstract class RepositoryBase implements Listener
|
||||
try
|
||||
{
|
||||
if (_connection == null || (validate && !_connection.isValid(2)))
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
{
|
||||
if (DataSource != null)
|
||||
_connection = DataSource.getConnection();
|
||||
else
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@ -97,8 +125,7 @@ public abstract class RepositoryBase implements Listener
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null)
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
getConnection(false);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
@ -114,18 +141,8 @@ public abstract class RepositoryBase implements Listener
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_connection.isValid(5))
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
executeInsert(query, callable, columns);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
getConnection(true);
|
||||
executeInsert(query, callable, columns);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -144,6 +161,16 @@ public abstract class RepositoryBase implements Listener
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (DataSource != null)
|
||||
_connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return affectedRows;
|
||||
@ -166,18 +193,8 @@ public abstract class RepositoryBase implements Listener
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_connection.isValid(5))
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
executeQuery(statement, callable, columns);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
getConnection(true);
|
||||
executeQuery(statement, callable, columns);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -196,6 +213,16 @@ public abstract class RepositoryBase implements Listener
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (DataSource != null)
|
||||
_connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,8 +232,7 @@ public abstract class RepositoryBase implements Listener
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null)
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
getConnection(false);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(query);
|
||||
|
||||
@ -214,18 +240,8 @@ public abstract class RepositoryBase implements Listener
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_connection.isValid(5))
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
executeQuery(query, callable, columns);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
getConnection(true);
|
||||
executeQuery(query, callable, columns);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -244,6 +260,16 @@ public abstract class RepositoryBase implements Listener
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (DataSource != null)
|
||||
_connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,18 +288,8 @@ public abstract class RepositoryBase implements Listener
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_connection.isValid(5))
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
executeUpdate(preparedStatement, columns);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
getConnection(true);
|
||||
executeUpdate(preparedStatement, columns);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -328,7 +344,7 @@ public abstract class RepositoryBase implements Listener
|
||||
@EventHandler
|
||||
public void validateConnection(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.MIN_02)
|
||||
if (event.getType() != UpdateType.MIN_02 || DataSource != null)
|
||||
return;
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Plugin, new Runnable()
|
||||
@ -337,15 +353,7 @@ public abstract class RepositoryBase implements Listener
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_connection == null || !_connection.isValid(5))
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
getConnection(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -5,6 +5,7 @@ import java.sql.SQLException;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
@ -16,7 +17,7 @@ public class EloRepository extends RepositoryBase
|
||||
|
||||
public EloRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
@ -22,7 +23,7 @@ public class FriendRepository extends RepositoryBase
|
||||
|
||||
public FriendRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package mineplex.core.ignore.data;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
@ -16,8 +17,7 @@ public class IgnoreRepository extends RepositoryBase
|
||||
|
||||
public IgnoreRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10",
|
||||
"root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,9 +66,9 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class,
|
||||
new AnnouncementHandler());
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, messageHandler);
|
||||
ServerCommandManager.getInstance()
|
||||
.registerCommandType("RedisMessageCallback", RedisMessageCallback.class, messageHandler);
|
||||
//ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, messageHandler);
|
||||
//ServerCommandManager.getInstance()
|
||||
// .registerCommandType("RedisMessageCallback", RedisMessageCallback.class, messageHandler);
|
||||
}
|
||||
|
||||
public void addCommands()
|
||||
|
@ -14,7 +14,7 @@ public class RefreshCommand extends CommandBase<NpcManager>
|
||||
{
|
||||
public RefreshCommand(NpcManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "refresh");
|
||||
super(plugin, Rank.SNR_MODERATOR, "refresh");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,8 +40,8 @@ public class PartyManager extends MiniPlugin
|
||||
_preferenceManager = preferenceManager;
|
||||
_serverName = getPlugin().getConfig().getString("serverstatus.name");
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("RedisPartyData", RedisPartyData.class,
|
||||
new RedisPartyHandler(this));
|
||||
//ServerCommandManager.getInstance().registerCommandType("RedisPartyData", RedisPartyData.class,
|
||||
// new RedisPartyHandler(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,28 +36,12 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
|
||||
{
|
||||
super("Preferences", plugin, clientManager);
|
||||
|
||||
setupConfigValues();
|
||||
|
||||
_repository = new PreferencesRepository(plugin, plugin.getConfig().getString("preferences.connectionurl"));
|
||||
_repository = new PreferencesRepository(plugin);
|
||||
_shop = new PreferencesShop(this, clientManager, donationManager);
|
||||
|
||||
addCommand(new PreferencesCommand(this));
|
||||
}
|
||||
|
||||
private void setupConfigValues()
|
||||
{
|
||||
try
|
||||
{
|
||||
getPlugin().getConfig().addDefault("preferences.connectionurl", "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10");
|
||||
getPlugin().getConfig().set("preferences.connectionurl", getPlugin().getConfig().getString("preferences.connectionurl"));
|
||||
getPlugin().saveConfig();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UserPreferences AddPlayer(String player)
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ import java.util.Map.Entry;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
@ -17,9 +18,9 @@ public class PreferencesRepository extends RepositoryBase
|
||||
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
|
||||
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ? WHERE uuid=?;";
|
||||
|
||||
public PreferencesRepository(JavaPlugin plugin, String connectionString)
|
||||
public PreferencesRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, connectionString, "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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;
|
||||
|
||||
|
@ -76,31 +76,31 @@ public class RewardManager
|
||||
// Gadgets
|
||||
addReward(new InventoryReward(inventoryManager, "Paintballs", "Paintball Gun",
|
||||
(int)(100*(minValue/500)), (int)(100*(maxValue/500)),
|
||||
new ItemStack(Material.GOLD_BARDING), rarity, 1));
|
||||
new ItemStack(Material.GOLD_BARDING), rarity, 10));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks",
|
||||
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
||||
new ItemStack(Material.FIREWORK), rarity, 1));
|
||||
new ItemStack(Material.FIREWORK), rarity, 10));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Melons", "Melon Launcher",
|
||||
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
||||
new ItemStack(Material.MELON_BLOCK), rarity, 1));
|
||||
new ItemStack(Material.MELON_BLOCK), rarity, 10));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Flesh Hooks", "Flesh Hook",
|
||||
(int)(40*(minValue/500)), (int)(40*(maxValue/500)),
|
||||
new ItemStack(Material.getMaterial(131)), rarity, 1));
|
||||
new ItemStack(Material.getMaterial(131)), rarity, 10));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Pearls", "Ethereal Pearl",
|
||||
(int)(30*(minValue/500)), (int)(30*(maxValue/500)),
|
||||
new ItemStack(Material.ENDER_PEARL), rarity, 1));
|
||||
new ItemStack(Material.ENDER_PEARL), rarity, 10));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Bat Swarms", "Bat Blaster",
|
||||
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
||||
new ItemStack(Material.IRON_BARDING), rarity, 1));
|
||||
new ItemStack(Material.IRON_BARDING), rarity, 10));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "TNT", "TNT",
|
||||
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
||||
new ItemStack(Material.TNT), rarity, 1));
|
||||
new ItemStack(Material.TNT), rarity, 10));
|
||||
}
|
||||
|
||||
public void addUncommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue)
|
||||
|
@ -5,22 +5,30 @@ import java.lang.reflect.Field;
|
||||
import net.minecraft.server.v1_7_R4.PlayerList;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.ServerGroup;
|
||||
import mineplex.serverdata.ServerManager;
|
||||
|
||||
public class ServerConfiguration extends MiniPlugin
|
||||
{
|
||||
private CoreClientManager _clientManager;
|
||||
|
||||
private Field _playerListMaxPlayers;
|
||||
private ServerGroup _serverGroup;
|
||||
|
||||
public ServerConfiguration(JavaPlugin plugin)
|
||||
public ServerConfiguration(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
{
|
||||
super("Server Configuration", plugin);
|
||||
|
||||
_clientManager = clientManager;
|
||||
Region region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
|
||||
String groupName = plugin.getConfig().getString("serverstatus.group");
|
||||
|
||||
@ -45,6 +53,13 @@ public class ServerConfiguration extends MiniPlugin
|
||||
((CraftServer)_plugin.getServer()).getServer().setTexturePack(_serverGroup.getResourcePack());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLogin(PlayerLoginEvent event)
|
||||
{
|
||||
if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.HELPER, false))
|
||||
event.disallow(Result.KICK_OTHER, "This is a staff only server.");
|
||||
}
|
||||
|
||||
public ServerGroup getServerGroup()
|
||||
{
|
||||
return _serverGroup;
|
||||
|
@ -111,7 +111,7 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
_statUploadQueue.get(player).put(statName, 0);
|
||||
}
|
||||
|
||||
_statUploadQueue.get(player).put(statName, value);
|
||||
_statUploadQueue.get(player).put(statName, _statUploadQueue.get(player).get(statName) + value);
|
||||
}
|
||||
|
||||
protected void saveStats()
|
||||
|
@ -42,8 +42,8 @@ public class TreasureManager extends MiniPlugin
|
||||
_rewardManager = new RewardManager(clientManager, donationManager, inventoryManager, petManager,
|
||||
100, 250,
|
||||
500, 1000,
|
||||
1500, 2500,
|
||||
6000, 12000,
|
||||
4000, 6000,
|
||||
12000, 32000,
|
||||
true);
|
||||
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
|
@ -60,7 +60,7 @@ public class Clans extends JavaPlugin
|
||||
|
||||
_donationManager = new DonationManager(this, _clientManager, webServerAddress);
|
||||
|
||||
new ServerConfiguration(this);
|
||||
new ServerConfiguration(this, _clientManager);
|
||||
|
||||
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
BlockRestore blockRestore = new BlockRestore(this);
|
||||
DonationManager donationManager = new DonationManager(this, clientManager, webServerAddress);
|
||||
|
||||
new ServerConfiguration(this);
|
||||
new ServerConfiguration(this, clientManager);
|
||||
|
||||
//Other Modules
|
||||
PacketHandler packetHandler = new PacketHandler(this);
|
||||
|
@ -8,6 +8,7 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
@ -28,7 +29,7 @@ public class PollRepository extends RepositoryBase
|
||||
|
||||
public PollRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ public enum GameType
|
||||
Other("Other"),
|
||||
Unknown("Unknown"),
|
||||
Lobby("Lobby"),
|
||||
Event("Event"),
|
||||
|
||||
BaconBrawl("Bacon Brawl"),
|
||||
Barbarians("A Barbarians Life"),
|
||||
@ -58,6 +59,7 @@ public enum GameType
|
||||
ZombieSurvival("Zombie Survival"),
|
||||
|
||||
Upload("Upload"),
|
||||
Submissions("Submissions"),
|
||||
InProgress("In Progress"),
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
@ -112,25 +113,15 @@ public class ServerCommandManager
|
||||
{
|
||||
Class<? extends ServerCommand> commandClazz = _commandTypes.get(commandType).getCommandType();
|
||||
final ServerCommand serverCommand = Utility.deserialize(serializedCommand, commandClazz);
|
||||
|
||||
if (!serverCommand.isTargetServer(_localServerName))
|
||||
return;
|
||||
|
||||
new Thread("Redis Command " + commandType)
|
||||
|
||||
// TODO: Run synchronously?
|
||||
CommandCallback callback = _commandTypes.get(commandType).getCallback();
|
||||
serverCommand.run(); // Run server command without callback
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
// TODO: Run synchronously?
|
||||
CommandCallback callback = _commandTypes.get(commandType).getCallback();
|
||||
serverCommand.run(); // Run server command without callback
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
callback.run(serverCommand); // Run callback
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
callback.run(serverCommand); // Run callback
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ public class ServerMonitor
|
||||
if (deadServer.getUptime() <= 10)
|
||||
continue;
|
||||
|
||||
if (deadServers.contains(deadServer.getName()))
|
||||
if (_count == 0 || deadServers.contains(deadServer.getName()))
|
||||
{
|
||||
killServer(deadServer.getName(), deadServer.getPublicAddress(), deadServer.getPlayerCount(), "[KILLED] [DEAD] " + deadServer.getName() + ":" + deadServer.getPublicAddress(), true);
|
||||
|
||||
@ -476,12 +476,12 @@ public class ServerMonitor
|
||||
|
||||
if (bestServer == null)
|
||||
{
|
||||
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!! NO DEDICATED SERVER AVAILABLE FOR GROUP " + serverGroup.getName() + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
log("!!!!!!!!!!!!!!!!!!!!!!!!!!!! NO DEDICATED SERVER AVAILABLE FOR GROUP " + serverGroup.getName() + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
break;
|
||||
}
|
||||
|
||||
if (serverTracker.containsKey(serverGroup.getPrefix() + "-" + serverNum))
|
||||
System.out.println("[WAITING] On " + serverGroup.getPrefix() + "-" + serverNum + " to finish starting...");
|
||||
log("[WAITING] On " + serverGroup.getPrefix() + "-" + serverNum + " to finish starting...");
|
||||
else
|
||||
{
|
||||
startServer(bestServer, serverGroup, serverNum, free);
|
||||
@ -540,7 +540,7 @@ public class ServerMonitor
|
||||
|
||||
try
|
||||
{
|
||||
pr.join(500);
|
||||
pr.join(50);
|
||||
}
|
||||
catch (InterruptedException e1)
|
||||
{
|
||||
@ -640,7 +640,7 @@ public class ServerMonitor
|
||||
|
||||
try
|
||||
{
|
||||
pr.join(500);
|
||||
pr.join(100);
|
||||
}
|
||||
catch (InterruptedException e1)
|
||||
{
|
||||
|
@ -74,9 +74,53 @@ public class StaffServer extends JavaPlugin
|
||||
Bukkit.getWorlds().get(0).setSpawnLocation(0, 102, 0);
|
||||
|
||||
((CraftServer)getServer()).setWhitelist(true);
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("NDrew").toString(), "NDrew").loadProfile());
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("Morena").toString(), "Morena").loadProfile());
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("Revolark").toString(), "Revolark").loadProfile());
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("EvilEsther").toString(), "EvilEsther").loadProfile());
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("NDrew").toString(), "NDrew").loadProfile());
|
||||
}
|
||||
}, 20L);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("Morena").toString(), "Morena").loadProfile());
|
||||
}
|
||||
}, 40L);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("Revolark").toString(), "Revolark").loadProfile());
|
||||
}
|
||||
}, 60L);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("EvilEsther").toString(), "EvilEsther").loadProfile());
|
||||
}
|
||||
}, 80L);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("Timmy48081_").toString(), "Timmy48081_").loadProfile());
|
||||
}
|
||||
}, 100L);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("issh").toString(), "issh").loadProfile());
|
||||
}
|
||||
}, 120L);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import mineplex.staffServer.salespackage.command.Sales;
|
||||
import mineplex.staffServer.salespackage.salespackages.AncientChest;
|
||||
import mineplex.staffServer.salespackage.salespackages.ApplyKits;
|
||||
import mineplex.staffServer.salespackage.salespackages.Coins;
|
||||
import mineplex.staffServer.salespackage.salespackages.DefaultRank;
|
||||
import mineplex.staffServer.salespackage.salespackages.FrostLord;
|
||||
import mineplex.staffServer.salespackage.salespackages.GemHunter;
|
||||
import mineplex.staffServer.salespackage.salespackages.LifetimeHero;
|
||||
@ -49,6 +50,7 @@ public class SalesPackageManager extends MiniPlugin
|
||||
AddSalesPackage(new Coins(this, 75000));
|
||||
AddSalesPackage(new MonthlyUltra(this));
|
||||
AddSalesPackage(new MonthlyHero(this));
|
||||
AddSalesPackage(new DefaultRank(this));
|
||||
AddSalesPackage(new LifetimeUltra(this));
|
||||
AddSalesPackage(new LifetimeHero(this));
|
||||
AddSalesPackage(new LifetimeLegend(this));
|
||||
|
@ -26,7 +26,7 @@ public class RankCommand extends CommandBase<SalesPackageManager>
|
||||
|
||||
final Rank rankEnum = Rank.valueOf(rank);
|
||||
|
||||
if (rankEnum == Rank.HERO || rankEnum == Rank.ULTRA || rankEnum == Rank.LEGEND)
|
||||
if (rankEnum == Rank.HERO || rankEnum == Rank.ULTRA || rankEnum == Rank.LEGEND || rankEnum == Rank.ALL)
|
||||
{
|
||||
Plugin.getClientManager().SaveRank(playerName, mineplex.core.common.Rank.valueOf(rank), perm);
|
||||
caller.sendMessage(F.main(Plugin.getName(), playerName + "'s rank has been updated to " + rank + "!"));
|
||||
|
@ -0,0 +1,20 @@
|
||||
package mineplex.staffServer.salespackage.salespackages;
|
||||
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DefaultRank extends SalesPackageBase
|
||||
{
|
||||
public DefaultRank(SalesPackageManager manager)
|
||||
{
|
||||
super(manager, "Default Rank");
|
||||
}
|
||||
|
||||
public void displayToAgent(Player agent, String playerName)
|
||||
{
|
||||
addButton(agent, "/sales rank " + playerName + " ALL false", " Default Rank.");
|
||||
agent.sendMessage(" ");
|
||||
addBackButton(agent, playerName);
|
||||
}
|
||||
}
|
@ -86,14 +86,13 @@ public class Arcade extends JavaPlugin
|
||||
|
||||
_donationManager = new DonationManager(this, _clientManager, webServerAddress);
|
||||
|
||||
_serverConfiguration = new ServerConfiguration(this);
|
||||
_serverConfiguration = new ServerConfiguration(this, _clientManager);
|
||||
|
||||
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
|
||||
|
||||
Creature creature = new Creature(this);
|
||||
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
|
||||
LeaderboardManager leaderboardManager = new LeaderboardManager(this, _clientManager);
|
||||
new Spawn(this, serverStatusManager.getCurrentServerName());
|
||||
Teleport teleport = new Teleport(this);
|
||||
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
|
||||
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
|
||||
|
@ -158,9 +158,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
private AchievementManager _achievementManager;
|
||||
private StatsManager _statsManager;
|
||||
private PartyManager _partyManager;
|
||||
private PreferencesManager _preferencesManager;
|
||||
|
||||
private TaskManager _taskManager;
|
||||
private ArcadeRepository _arcadeRepository;
|
||||
private PacketHandler _packetHandler;
|
||||
|
||||
|
||||
@ -192,6 +192,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
|
||||
_blood = blood;
|
||||
_preferencesManager = preferences;
|
||||
|
||||
_explosionManager = new Explosion(plugin, _blockRestore);
|
||||
_explosionManager.SetDebris(false);
|
||||
@ -261,7 +262,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
_idleManager = new IdleManager(this);
|
||||
//new HalloweenManager(this);
|
||||
|
||||
_arcadeRepository = new ArcadeRepository(plugin);
|
||||
// Game Addons
|
||||
new CompassAddon(plugin, this);
|
||||
new SoupAddon(plugin, this);
|
||||
@ -461,6 +461,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
return _gameWorldManager;
|
||||
}
|
||||
|
||||
public PreferencesManager getPreferences()
|
||||
{
|
||||
return _preferencesManager;
|
||||
}
|
||||
|
||||
public StatsManager GetStatsManager()
|
||||
{
|
||||
@ -641,7 +646,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
player.getOpenInventory().getType() != InventoryType.CREATIVE)
|
||||
return;
|
||||
|
||||
if (!UtilGear.isMat(player.getInventory().getItem(8), Material.WATCH))
|
||||
if (!UtilGear.isMat(player.getInventory().getItem(8), Material.WATCH) && !UtilGear.isMat(player.getInventory().getItem(8), Material.SPECKLED_MELON))
|
||||
{
|
||||
player.getInventory().setItem(
|
||||
8,
|
||||
@ -1030,18 +1035,16 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
}
|
||||
else if (event.GetState() == GameState.Prepare || event.GetState() == GameState.Loading || event.GetState() == GameState.Dead)
|
||||
{
|
||||
if (getCosmeticManager().isShowingInterface())
|
||||
if (event.GetGame().GadgetsDisabled)
|
||||
{
|
||||
getCosmeticManager().setActive(false);
|
||||
getCosmeticManager().disableItemsForGame();
|
||||
if (getCosmeticManager().isShowingInterface())
|
||||
{
|
||||
getCosmeticManager().setActive(false);
|
||||
getCosmeticManager().disableItemsForGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ArcadeRepository getArcadeRepository()
|
||||
{
|
||||
return _arcadeRepository;
|
||||
}
|
||||
|
||||
/*public void saveBasicStats(final Game game)
|
||||
{
|
||||
|
@ -1,107 +0,0 @@
|
||||
package nautilus.game.arcade;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.database.Tables;
|
||||
//import mineplex.database.tables.records.GamesRecord;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
public class ArcadeRepository extends RepositoryBase
|
||||
{
|
||||
private final String serverName;
|
||||
|
||||
public ArcadeRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
|
||||
serverName = plugin.getConfig().getString("serverstatus.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*public void saveBasicStats(GameType type, boolean tournament, int duration, Map<UUID, Boolean> players)
|
||||
{
|
||||
DSLContext context;
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
context = DSL.using(getConnection());
|
||||
}
|
||||
|
||||
GamesRecord record = context.newRecord(Tables.games);
|
||||
record.setDuration(duration);
|
||||
record.setTournament(tournament);
|
||||
record.setType(type.name());
|
||||
record.setServer(serverName);
|
||||
record.store();
|
||||
|
||||
List<Query> queryList = new ArrayList<>(players.size());
|
||||
|
||||
for (Map.Entry<UUID, Boolean> entry : players.entrySet())
|
||||
{
|
||||
Query query = context
|
||||
.insertInto(Tables.gamePlayers)
|
||||
.set(Tables.gamePlayers.gameId, record.getId())
|
||||
.set(Tables.gamePlayers.accountId, DSL.select(Tables.accounts.id)
|
||||
.from(Tables.accounts)
|
||||
.where(Tables.accounts.uuid.eq(entry.getKey().toString())))
|
||||
.set(Tables.gamePlayers.winner, entry.getValue());
|
||||
|
||||
queryList.add(query);
|
||||
}
|
||||
|
||||
context.batch(queryList).execute();
|
||||
}
|
||||
|
||||
public void saveLeaderboardStats(int tournamentId, int gameId, Map<UUID, Boolean> players)
|
||||
{
|
||||
DSLContext context;
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
context = DSL.using(getConnection());
|
||||
}
|
||||
|
||||
List<Query> queryList = new ArrayList<>(players.size());
|
||||
|
||||
for (Map.Entry<UUID, Boolean> entry : players.entrySet())
|
||||
{
|
||||
int winIncrement = entry.getValue() ? 1 : 0;
|
||||
|
||||
Query query = context
|
||||
.insertInto(Tables.tournamentLeaderboard)
|
||||
.set(Tables.tournamentLeaderboard.tournamentId, tournamentId)
|
||||
.set(Tables.tournamentLeaderboard.gameId, gameId)
|
||||
.set(Tables.tournamentLeaderboard.accountId, DSL.select(Tables.accounts.id)
|
||||
.from(Tables.accounts)
|
||||
.where(Tables.accounts.uuid.eq(entry.getKey().toString())))
|
||||
.set(Tables.tournamentLeaderboard.wins, winIncrement)
|
||||
.set(Tables.tournamentLeaderboard.total, 1)
|
||||
.onDuplicateKeyUpdate()
|
||||
.set(Tables.tournamentLeaderboard.wins, Tables.tournamentLeaderboard.wins.plus(winIncrement))
|
||||
.set(Tables.tournamentLeaderboard.total, Tables.tournamentLeaderboard.total.plus(1));
|
||||
|
||||
queryList.add(query);
|
||||
}
|
||||
|
||||
context.batch(queryList).execute();
|
||||
}*/
|
||||
}
|
@ -21,6 +21,7 @@ import nautilus.game.arcade.game.games.dragonriders.DragonRiders;
|
||||
import nautilus.game.arcade.game.games.dragons.Dragons;
|
||||
import nautilus.game.arcade.game.games.dragons.DragonsTeams;
|
||||
import nautilus.game.arcade.game.games.draw.Draw;
|
||||
import nautilus.game.arcade.game.games.event.EventGame;
|
||||
import nautilus.game.arcade.game.games.evolution.Evolution;
|
||||
import nautilus.game.arcade.game.games.gravity.Gravity;
|
||||
import nautilus.game.arcade.game.games.halloween.Halloween;
|
||||
@ -78,6 +79,7 @@ public class GameFactory
|
||||
else if (gameType == GameType.DragonEscapeTeams) return new DragonEscapeTeams(_manager);
|
||||
else if (gameType == GameType.DragonRiders) return new DragonRiders(_manager);
|
||||
else if (gameType == GameType.Draw) return new Draw(_manager);
|
||||
else if (gameType == GameType.Event) return new EventGame(_manager);
|
||||
else if (gameType == GameType.Evolution) return new Evolution(_manager);
|
||||
else if (gameType == GameType.Gravity) return new Gravity(_manager);
|
||||
else if (gameType == GameType.Halloween) return new Halloween(_manager);
|
||||
|
@ -53,7 +53,9 @@ public enum GameType
|
||||
UHC("Ultra Hardcore", Material.GOLDEN_APPLE, (byte)0, GameCategory.SURVIVAL, 46),
|
||||
WitherAssault("Wither Assault", Material.SKULL_ITEM, (byte)1, GameCategory.ARCADE, 47),
|
||||
Wizards("Wizards", Material.BLAZE_ROD, (byte)0, GameCategory.SURVIVAL, 48),
|
||||
ZombieSurvival("Zombie Survival", Material.SKULL_ITEM, (byte)2, GameCategory.SURVIVAL, 49);
|
||||
ZombieSurvival("Zombie Survival", Material.SKULL_ITEM, (byte)2, GameCategory.SURVIVAL, 49),
|
||||
|
||||
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999);
|
||||
|
||||
String _name;
|
||||
String _lobbyName;
|
||||
@ -106,6 +108,6 @@ public enum GameType
|
||||
|
||||
public static enum GameCategory
|
||||
{
|
||||
SURVIVAL, CLASSICS, CHAMPIONS, ARCADE;
|
||||
SURVIVAL, CLASSICS, CHAMPIONS, ARCADE, EVENT;
|
||||
}
|
||||
}
|
@ -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>();
|
||||
|
||||
@ -224,6 +226,10 @@ public abstract class Game implements Listener
|
||||
public boolean StrictAntiHack = false;
|
||||
|
||||
public boolean DisableKillCommand = true;
|
||||
|
||||
public boolean GadgetsDisabled = true;
|
||||
|
||||
public boolean TeleportsDisqualify = true;
|
||||
|
||||
//Addons
|
||||
public boolean CompassEnabled = false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,38 @@
|
||||
package nautilus.game.arcade.game.games.event.kits;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
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;
|
||||
|
||||
public class KitPlayer extends Kit
|
||||
{
|
||||
public KitPlayer(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Party Animal", KitAvailability.Free, 0,
|
||||
|
||||
new String[]
|
||||
{
|
||||
""
|
||||
},
|
||||
|
||||
new Perk[]
|
||||
{
|
||||
},
|
||||
EntityType.PIG,
|
||||
new ItemStack(Material.PORK));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void GiveItems(Player player)
|
||||
{
|
||||
((EventGame)Manager.GetGame()).giveItems(player);
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ public class GiveAdminPage extends PlayerPage
|
||||
@Override
|
||||
public boolean showPlayer(Player player)
|
||||
{
|
||||
return !_manager.isAdmin(player, true);
|
||||
return !_manager.isAdmin(player, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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)
|
||||
@ -874,6 +882,9 @@ public class GameFlagManager implements Listener
|
||||
|
||||
if (!game.IsLive())
|
||||
return;
|
||||
|
||||
if (!game.TeleportsDisqualify)
|
||||
return;
|
||||
|
||||
//Remove Kit
|
||||
game.RemoveTeamPreference(event.getPlayer());
|
||||
|
@ -118,7 +118,8 @@ public class GameHostManager implements Listener
|
||||
giveAdminItem(player);
|
||||
}
|
||||
|
||||
if (player.equals(_host))
|
||||
if (player.equals(_host) ||
|
||||
(isAdmin(player, false) && Manager.GetGame() != null && Manager.GetGame().GetType() == GameType.Event))
|
||||
_lastOnline = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
@ -208,21 +209,21 @@ public class GameHostManager implements Listener
|
||||
if (Manager.GetGame() == null)
|
||||
return;
|
||||
|
||||
if (UtilGear.isMat(player.getInventory().getItem(7), Material.SPECKLED_MELON))
|
||||
if (UtilGear.isMat(player.getInventory().getItem(8), Material.SPECKLED_MELON))
|
||||
return;
|
||||
|
||||
if (player.getOpenInventory().getType() != InventoryType.CRAFTING &&
|
||||
player.getOpenInventory().getType() != InventoryType.CREATIVE)
|
||||
return;
|
||||
|
||||
player.getInventory().setItem(7, ItemStackFactory.Instance.CreateStack(Material.SPECKLED_MELON, (byte)0, 1, C.cGreen + C.Bold + "/menu"));
|
||||
player.getInventory().setItem(8, ItemStackFactory.Instance.CreateStack(Material.SPECKLED_MELON, (byte)0, 1, C.cGreen + C.Bold + "/menu"));
|
||||
}
|
||||
|
||||
private void removeAdminItem(Player player)
|
||||
{
|
||||
if (player.getInventory().getItem(7).getType() == Material.SPECKLED_MELON)
|
||||
if (player.getInventory().getItem(8).getType() == Material.SPECKLED_MELON)
|
||||
{
|
||||
player.getInventory().setItem(7, null);
|
||||
player.getInventory().setItem(8, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,7 +399,22 @@ public class GameHostManager implements Listener
|
||||
{
|
||||
_blacklist.add(player.getName());
|
||||
|
||||
Manager.GetPortal().sendToHub(player, "You were kicked from this Mineplex Private Server.");
|
||||
Manager.GetPortal().sendToHub(player, "You were removed from this Mineplex Private Server.");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void kickBlacklist(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (_blacklist.contains(player.getName()))
|
||||
{
|
||||
Manager.GetPortal().sendToHub(player, "You were removed from this Mineplex Private Server.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void giveAdmin(Player player)
|
||||
|
@ -1248,7 +1248,7 @@ public class GameLobbyManager implements Listener, IPacketHandler
|
||||
if (Manager.GetGame() == null)
|
||||
return;
|
||||
|
||||
if (Manager.GetGame().GetState() != GameState.Recruit)
|
||||
if (Manager.GetGame().GetState() != GameState.Recruit && Manager.GetGame().GadgetsDisabled)
|
||||
return;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
|
@ -59,7 +59,7 @@ public class GameLootManager implements Listener
|
||||
|
||||
//Chest
|
||||
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Old Chest", "Old Chest", 1, 1,
|
||||
new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 1000));
|
||||
new ItemStack(Material.CHEST), RewardRarity.COMMON, 2));
|
||||
|
||||
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Ancient Chest", "Ancient Chest", 1, 1,
|
||||
new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 40));
|
||||
|
@ -201,7 +201,7 @@ public class GameManager implements Listener
|
||||
}
|
||||
else if (game.GetState() == GameState.Live)
|
||||
{
|
||||
if (UtilTime.elapsed(game.GetStateTime(), game.GameTimeout) && Manager.IsGameTimeout())
|
||||
if (game.GameTimeout != -1 && UtilTime.elapsed(game.GetStateTime(), game.GameTimeout) && Manager.IsGameTimeout())
|
||||
{
|
||||
game.HandleTimeout();
|
||||
}
|
||||
@ -229,7 +229,7 @@ public class GameManager implements Listener
|
||||
}
|
||||
|
||||
//Disabling Cosmetics
|
||||
if (game.GetCountdown() <= 5 && game.GetCountdown() >= 0)
|
||||
if (game.GetCountdown() <= 5 && game.GetCountdown() >= 0 && game.GadgetsDisabled)
|
||||
{
|
||||
if (Manager.getCosmeticManager().isShowingInterface())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user