Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
21314afabe
@ -36,7 +36,7 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
loadLobbyServers();
|
||||
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 2L, 2L, TimeUnit.SECONDS);
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 200L, 200L, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -45,8 +45,6 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
if (!event.getTarget().getName().equalsIgnoreCase("Lobby"))
|
||||
return;
|
||||
|
||||
boolean sort = false;
|
||||
|
||||
synchronized (_serverLock)
|
||||
{
|
||||
if (_playersSentToBestServer >= _maxPlayersToSendToBestServer)
|
||||
@ -56,7 +54,7 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
while (_bestServerIndex < _sortedLobbies.size())
|
||||
{
|
||||
_bestServerIndex++;
|
||||
_maxPlayersToSendToBestServer = (_sortedLobbies.get(_bestServerIndex).MaxPlayers - _sortedLobbies.get(_bestServerIndex).Players) / 10;
|
||||
_maxPlayersToSendToBestServer = _sortedLobbies.get(_bestServerIndex).MaxPlayers - _sortedLobbies.get(_bestServerIndex).Players;
|
||||
|
||||
if (_maxPlayersToSendToBestServer > 0)
|
||||
break;
|
||||
@ -66,11 +64,6 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
{
|
||||
_bestServerIndex = 0;
|
||||
_maxPlayersToSendToBestServer = 1;
|
||||
|
||||
// Since we had to enter our dangerzone, update local data so if we have to enter it again we don't pick the same server over and over
|
||||
_sortedLobbies.get(_bestServerIndex).Players += 5;
|
||||
sort = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,10 +71,6 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
event.setTarget(_plugin.getProxy().getServerInfo(_sortedLobbies.get(_bestServerIndex).Name));
|
||||
|
||||
_playersSentToBestServer++;
|
||||
|
||||
// Only if we had to pick default regardless of the buffer safezone
|
||||
if (sort)
|
||||
Collections.sort(_sortedLobbies, new LobbySorter());
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,6 +85,7 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
|
||||
synchronized (_serverLock)
|
||||
{
|
||||
long startTime = System.currentTimeMillis();
|
||||
_sortedLobbies.clear();
|
||||
|
||||
for (ServerStatusData serverStatusData : serverStatusDataList)
|
||||
@ -120,8 +110,12 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
_playersSentToBestServer = 0;
|
||||
_bestServerIndex = 0;
|
||||
|
||||
if (_sortedLobbies.size() > 0)
|
||||
_maxPlayersToSendToBestServer = (_sortedLobbies.get(_bestServerIndex).MaxPlayers - _sortedLobbies.get(_bestServerIndex).Players) / 10;
|
||||
_maxPlayersToSendToBestServer = _sortedLobbies.get(_bestServerIndex).MaxPlayers - _sortedLobbies.get(_bestServerIndex).Players;
|
||||
|
||||
long timeSpentInLock = System.currentTimeMillis() - startTime;
|
||||
|
||||
if (timeSpentInLock > 50)
|
||||
System.out.println("[==] TIMING [==] Locked loading servers for " + timeSpentInLock + "ms");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
package mineplex.bungee.playerTracker;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
public class FindCommand extends Command
|
||||
{
|
||||
private Plugin _plugin;
|
||||
|
||||
public FindCommand(Plugin plugin)
|
||||
{
|
||||
super("mineplex.bungee.playertracker.find", "", "");
|
||||
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender arg0, String[] arg1)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package mineplex.bungee.playerTracker;
|
||||
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
public class PlayerTracker
|
||||
{
|
||||
private Plugin _plugin;
|
||||
private PlayerTrackerRepository _repository;
|
||||
|
||||
public PlayerTracker(Plugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
|
||||
_plugin.getProxy().getPluginManager().registerCommand(_plugin, new FindCommand(_plugin));
|
||||
|
||||
_repository = new PlayerTrackerRepository();
|
||||
_repository.initialize();
|
||||
}
|
||||
}
|
@ -1,253 +0,0 @@
|
||||
package mineplex.bungee.playerTracker;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class PlayerTrackerRepository
|
||||
{
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/PlayerTracker?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS PlayerTracker (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(16), server VARCHAR(255), PRIMARY KEY (id));";
|
||||
private static String INSERT_PLAYER_SERVER = "INSERT INTO PlayerTracker values(default, ?, ?);";
|
||||
private static String UPDATE_PLAYER_SERVER = "UPDATE PlayerTracker SET server = ? WHERE name = ?;";
|
||||
private static String DELETE_PLAYER = "DELETE FROM PlayerTracker WHERE name = ?;";
|
||||
private static String RETRIEVE_PLAYER_SERVER = "SELECT server FROM PlayerTracker WHERE name = ?;";
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
Connection connection = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = connection.prepareStatement(CREATE_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Initialized PlayerTracker.");
|
||||
}
|
||||
|
||||
public boolean updatePlayerServer(String name, String server)
|
||||
{
|
||||
Connection connection = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = connection.prepareStatement(UPDATE_PLAYER_SERVER);
|
||||
|
||||
preparedStatement.setString(1, server);
|
||||
preparedStatement.setString(2, name);
|
||||
|
||||
int affectedRows = preparedStatement.executeUpdate();
|
||||
|
||||
if (affectedRows == 0)
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(INSERT_PLAYER_SERVER);
|
||||
|
||||
preparedStatement.setString(1, name);
|
||||
preparedStatement.setString(2, server);
|
||||
|
||||
affectedRows = preparedStatement.executeUpdate();
|
||||
|
||||
if (affectedRows == 0)
|
||||
{
|
||||
throw new SQLException("Updating player server failed, no rows affected.");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String retrievePlayerServer(String name)
|
||||
{
|
||||
Connection connection = null;
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = connection.prepareStatement(RETRIEVE_PLAYER_SERVER);
|
||||
preparedStatement.setString(1, name);
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
return resultSet.getString(1);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "Lobby";
|
||||
}
|
||||
|
||||
public boolean removePlayer(String name)
|
||||
{
|
||||
Connection connection = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = connection.prepareStatement(DELETE_PLAYER);
|
||||
|
||||
preparedStatement.setString(1, name);
|
||||
|
||||
int affectedRows = preparedStatement.executeUpdate();
|
||||
|
||||
if (affectedRows == 0)
|
||||
{
|
||||
throw new SQLException("Updating player server failed, no rows affected.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package mineplex.hub.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
|
||||
public class NewsAddCommand extends CommandBase<HubManager>
|
||||
{
|
||||
public NewsAddCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "add");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, final String[] args)
|
||||
{
|
||||
if (args == null || args.length == 0 || args.length > 128)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewsManager newsMang = Plugin.GetNewsManager();
|
||||
|
||||
String newsEntry = "";
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
// Check for 256 character length for MySQL!
|
||||
if (newsEntry.length() > 256)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news entry is too long [> 256 characters]!"));
|
||||
return;
|
||||
}
|
||||
|
||||
newsMang.AddNewsEntry(newsEntry, new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
String newsEntry = "";
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry: " + C.cGold + newsEntry + C.cGray + " has been added to the database!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error adding the news entry to the database!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,215 +1,27 @@
|
||||
package mineplex.hub.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
|
||||
public class NewsCommand extends CommandBase<HubManager>
|
||||
public class NewsCommand extends MultiCommandBase<HubManager>
|
||||
{
|
||||
public NewsCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "news");
|
||||
|
||||
AddCommand(new NewsAddCommand(plugin));
|
||||
AddCommand(new NewsDeleteCommand(plugin));
|
||||
AddCommand(new NewsConfirmCommand(plugin));
|
||||
AddCommand(new NewsListCommand(plugin));
|
||||
AddCommand(new NewsSetCommand(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, final String[] args)
|
||||
protected void Help(Player caller, String args[])
|
||||
{
|
||||
final NewsManager newsMang = Plugin.GetNewsManager();
|
||||
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "Available news arguments for this command:"));
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news list" + C.cGray + " - Lists (numbered) stored news messages from database."));
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news add <newsEntry>" + C.cGray + " - Adds specified news entry string to database at end of table."));
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news delete #" + C.cGray + " - Removes specified (numbered) news entry string from database."));
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news set # <newsEntry>" + C.cGray + " - Updates specified (numbered) news entry string in database."));
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "*Please Note: " + C.cGray + "Updates to server news entries from the database are on a 4 minute refresh cycle!"));
|
||||
return;
|
||||
}
|
||||
else if (args.length == 1 && args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "Current server news messages:"));
|
||||
|
||||
newsMang.RetriveNewsEntries(new Callback<HashMap<String, String>>()
|
||||
{
|
||||
public void run(final HashMap<String, String> newsEntries)
|
||||
{
|
||||
// Order newsEntries set or its output by newsPosition, not hash order...
|
||||
newsMang.RetrieveMaxNewsPosition(new Callback<Integer>()
|
||||
{
|
||||
public void run(Integer maxPosition)
|
||||
{
|
||||
String[] newsStrings = new String[maxPosition];
|
||||
for (Iterator<String> iterator = newsEntries.keySet().iterator(); iterator.hasNext();)
|
||||
{
|
||||
String newsPosition = iterator.next();
|
||||
newsStrings[Integer.parseInt(newsPosition) - 1] = newsEntries.get(newsPosition);
|
||||
}
|
||||
|
||||
for (int i = 0; i < newsStrings.length; i++)
|
||||
{
|
||||
UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[DELETE] \", color:red, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news ¢¤₦₣¡₨₥ " + (i + 1) + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Deletes News Entry " + (i + 1) + " : " + newsStrings[i] + "\"}}, {\"text\":\"News " + (i + 1) + "\", color:gold}, {\"text\":\" : \", color:gray}, {\"text\":\"" + newsStrings[i] + "\", color:white}]}");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
else if (args.length >= 2 && args.length <= 128)
|
||||
{
|
||||
if (args[0].equals("¢¤₦₣¡₨₥") && args.length == 2)
|
||||
{
|
||||
int newsPosition;
|
||||
try
|
||||
{
|
||||
newsPosition = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!"));
|
||||
return;
|
||||
}
|
||||
|
||||
UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[CONFIRM] \", color:green, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news delete " + newsPosition + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Are you absolutely sure???\"}}, {\"text\":\"News Entry " + newsPosition + "\", color:gold}, {\"text\":\" deletion?\", color:gray}]}");
|
||||
return;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("delete") && args.length == 2)
|
||||
{
|
||||
final int newsPosition;
|
||||
try
|
||||
{
|
||||
newsPosition = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!"));
|
||||
return;
|
||||
}
|
||||
newsMang.DeleteNewsEntry(newsPosition, new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been deleted!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error deleting the news entry; likely the specified news position was invalid!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("add"))
|
||||
{
|
||||
String newsEntry = "";
|
||||
for (int i = 1; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
// Check for 256 character length for MySQL!
|
||||
if (newsEntry.length() > 256)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news entry is too long [> 256 characters]!"));
|
||||
return;
|
||||
}
|
||||
|
||||
newsMang.AddNewsEntry(newsEntry, new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
String newsEntry = "";
|
||||
for (int i = 1; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry: " + C.cGold + newsEntry + C.cGray + " has been added to the database!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error adding the news entry to the database!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("set") && args.length >= 3)
|
||||
{
|
||||
final int newsPosition;
|
||||
String newsEntry = "";
|
||||
for (int i = 2; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
// Check for 256 character length for MySQL!
|
||||
if (newsEntry.length() > 256)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news entry is too long [> 256 characters]!"));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newsPosition = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!"));
|
||||
return;
|
||||
}
|
||||
newsMang.SetNewsEntry(newsEntry, newsPosition, new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
String newsEntry = "";
|
||||
for (int i = 2; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been updated to: " + C.cGold + newsEntry + C.cGray + "!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error updating the news entry; likely the specified news position was invalid!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
Plugin.GetNewsManager().Help(caller);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
package mineplex.hub.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.hub.HubManager;
|
||||
|
||||
public class NewsConfirmCommand extends CommandBase<HubManager>
|
||||
{
|
||||
public NewsConfirmCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "¢¤₦₣¡₨₥");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length == 0 || args.length > 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
int newsPosition;
|
||||
try
|
||||
{
|
||||
newsPosition = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!"));
|
||||
return;
|
||||
}
|
||||
|
||||
UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[CONFIRM] \", color:green, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news delete " + newsPosition + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Are you absolutely sure???\"}}, {\"text\":\"News Entry " + newsPosition + "\", color:gold}, {\"text\":\" deletion?\", color:gray}]}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package mineplex.hub.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
|
||||
public class NewsDeleteCommand extends CommandBase<HubManager>
|
||||
{
|
||||
public NewsDeleteCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "delete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length == 0 || args.length > 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewsManager newsMang = Plugin.GetNewsManager();
|
||||
final int newsPosition;
|
||||
try
|
||||
{
|
||||
newsPosition = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!"));
|
||||
return;
|
||||
}
|
||||
newsMang.DeleteNewsEntry(newsPosition, new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been deleted!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error deleting the news entry; likely the specified news position was invalid!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package mineplex.hub.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
|
||||
public class NewsListCommand extends CommandBase<HubManager>
|
||||
{
|
||||
public NewsListCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
final NewsManager newsMang = Plugin.GetNewsManager();
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "Current server news messages:"));
|
||||
|
||||
newsMang.RetriveNewsEntries(new Callback<HashMap<String, String>>()
|
||||
{
|
||||
public void run(final HashMap<String, String> newsEntries)
|
||||
{
|
||||
// Order newsEntries set or its output by newsPosition, not hash order...
|
||||
newsMang.RetrieveMaxNewsPosition(new Callback<Integer>()
|
||||
{
|
||||
public void run(Integer maxPosition)
|
||||
{
|
||||
String[] newsStrings = new String[maxPosition];
|
||||
for (Iterator<String> iterator = newsEntries.keySet().iterator(); iterator.hasNext();)
|
||||
{
|
||||
String newsPosition = iterator.next();
|
||||
newsStrings[Integer.parseInt(newsPosition) - 1] = newsEntries.get(newsPosition);
|
||||
}
|
||||
|
||||
for (int i = 0; i < newsStrings.length; i++)
|
||||
{
|
||||
UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[DELETE] \", color:red, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news ¢¤₦₣¡₨₥ " + (i + 1) + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Deletes News Entry " + (i + 1) + " : " + newsStrings[i] + "\"}}, {\"text\":\"News " + (i + 1) + "\", color:gold}, {\"text\":\" : \", color:gray}, {\"text\":\"" + newsStrings[i] + "\", color:white}]}");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package mineplex.hub.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
|
||||
public class NewsSetCommand extends CommandBase<HubManager>
|
||||
{
|
||||
public NewsSetCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "set");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, final String[] args)
|
||||
{
|
||||
if (args == null || args.length < 2 || args.length > 128)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewsManager newsMang = Plugin.GetNewsManager();
|
||||
|
||||
final int newsPosition;
|
||||
String newsEntry = "";
|
||||
for (int i = 1; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
// Check for 256 character length for MySQL!
|
||||
if (newsEntry.length() > 256)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news entry is too long [> 256 characters]!"));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newsPosition = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!"));
|
||||
return;
|
||||
}
|
||||
newsMang.SetNewsEntry(newsEntry, newsPosition, new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
String newsEntry = "";
|
||||
for (int i = 1; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been updated to: " + C.cGold + newsEntry + C.cGray + "!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error updating the news entry; likely the specified news position was invalid!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -187,6 +188,24 @@ public class NewsManager extends MiniPlugin
|
||||
});
|
||||
}
|
||||
|
||||
public void Help(Player caller, String message)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Available news arguments for this command:"));
|
||||
UtilPlayer.message(caller, F.help(C.cGold + "/news list", "Lists (numbered) stored news messages from database.", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help(C.cGold + "/news add <newsEntry>", "Adds specified news entry string to database at end of table.", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help(C.cGold + "/news delete #", "Removes specified (numbered) news entry string from database.", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help(C.cGold + "/news set # <newsEntry>", "Updates specified (numbered) news entry string in database.", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("*Please Note:", "Updates to server news entries from the database are on a 4 minute refresh cycle!", Rank.ADMIN));
|
||||
|
||||
if (message != null)
|
||||
UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message));
|
||||
}
|
||||
|
||||
public void Help(Player caller)
|
||||
{
|
||||
Help(caller, null);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void NewsUpdate(UpdateEvent event)
|
||||
{
|
||||
|
@ -132,6 +132,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
if (serverConfig.Tournament)
|
||||
{
|
||||
AntiHack.Instance.SetEnabled(false);
|
||||
Bukkit.getServer().setWhitelist(true);
|
||||
}
|
||||
|
||||
//Modules
|
||||
@ -420,12 +421,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
@EventHandler
|
||||
public void MessageMOTD(ServerListPingEvent event)
|
||||
{
|
||||
if (this.IsTournamentServer())
|
||||
{
|
||||
event.setMotd(ChatColor.RED + "Twitch.tv "+ ChatColor.YELLOW + "Charity Event");
|
||||
return;
|
||||
}
|
||||
|
||||
String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName()) + "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName);
|
||||
|
||||
if (_game == null || _game.GetState() == GameState.Recruit)
|
||||
@ -496,6 +491,26 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
@EventHandler
|
||||
public void Login(PlayerLoginEvent event)
|
||||
{
|
||||
if (Bukkit.getServer().hasWhitelist())
|
||||
{
|
||||
if (_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.MODERATOR, false))
|
||||
{
|
||||
event.allow();
|
||||
event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
||||
|
||||
if (_serverConfig.Tournament)
|
||||
{
|
||||
event.getPlayer().setOp(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server Whitelisted!");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Reserved Slot Check
|
||||
if (Bukkit.getOnlinePlayers().length >= Bukkit.getServer().getMaxPlayers())
|
||||
{
|
||||
@ -512,6 +527,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
event.allow();
|
||||
event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
_ore = new OreHider();
|
||||
|
||||
// Flags
|
||||
GameTimeout = 96000000;
|
||||
GameTimeout = Manager.IsTournamentServer() ? 5400000 : 1800000;
|
||||
|
||||
DamageSelf = true;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins.kits;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.itemstack.*;
|
||||
import nautilus.game.arcade.*;
|
||||
import nautilus.game.arcade.kit.*;
|
||||
import nautilus.game.arcade.kit.perks.*;
|
||||
@ -19,6 +21,14 @@ public class KitRevealer extends SneakyAssassinKit
|
||||
{
|
||||
super.GiveItems(player);
|
||||
|
||||
player.getInventory().addItem(new ItemStack(Material.EMERALD, 3));
|
||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 3,
|
||||
C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Reveal Assassins",
|
||||
new String[]
|
||||
{
|
||||
ChatColor.RESET + "Throw a revealer.",
|
||||
ChatColor.RESET + "Players within 5 blocks",
|
||||
ChatColor.RESET + "get revealed for 5 seconds.",
|
||||
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -37,12 +37,20 @@ public class ArmorPowerUp extends PowerUp
|
||||
}
|
||||
|
||||
@Override
|
||||
public void powerUpPlayer(Player player)
|
||||
public boolean powerUpPlayer(Player player)
|
||||
{
|
||||
if(powerUpArmor(player) || powerUpArmor(player))
|
||||
if (powerUpArmor(player) || powerUpArmor(player))
|
||||
{
|
||||
player.sendMessage("Your armor was upgraded!");
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("Your armor is already fully upgraded!");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean powerUpArmor(Player player)
|
||||
|
@ -16,6 +16,8 @@ public abstract class PowerUp
|
||||
private final Location _location;
|
||||
private Location _effectLocation;
|
||||
private Block _beaconBlock;
|
||||
private BlockState _originalBeaconBlock;
|
||||
private BlockState[][] _originalBeaconBase = new BlockState[3][3];
|
||||
private Item _item;
|
||||
|
||||
public PowerUp(PowerUpManager powerUpManager, PowerUpType powerUpType, Location location)
|
||||
@ -39,12 +41,21 @@ public abstract class PowerUp
|
||||
|
||||
public void activate()
|
||||
{
|
||||
_beaconBlock = getLocation().getBlock();
|
||||
_beaconBlock = getLocation().getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
_originalBeaconBlock = _beaconBlock.getState();
|
||||
_beaconBlock.setType(Material.BEACON);
|
||||
|
||||
for (int x = -1; x <= 1; x++)
|
||||
for (int z = -1; z <= 1; z++)
|
||||
_beaconBlock.getRelative(x, -1, z).setType(Material.IRON_BLOCK);
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
for (int z = 0; z < 3; z++)
|
||||
{
|
||||
Block beaconBaseBlock = _beaconBlock.getRelative(x-1, -1, z-1);
|
||||
|
||||
_originalBeaconBase[x][z] = beaconBaseBlock.getState();
|
||||
beaconBaseBlock.setType(Material.IRON_BLOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpdate(UpdateEvent event)
|
||||
@ -103,10 +114,14 @@ public abstract class PowerUp
|
||||
_item = null;
|
||||
}
|
||||
|
||||
_beaconBlock.setType(Material.AIR);
|
||||
_originalBeaconBlock.update(true, false);
|
||||
|
||||
for (int x = 0; x < _originalBeaconBase.length; x++)
|
||||
for (int z = 0; z < _originalBeaconBase[0].length; z++)
|
||||
_originalBeaconBase[x][z].update(true, false);
|
||||
|
||||
getPowerUpManager().removePowerUp(this);
|
||||
}
|
||||
|
||||
public abstract void powerUpPlayer(Player player);
|
||||
public abstract boolean powerUpPlayer(Player player);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ public class PowerUpManager implements Listener
|
||||
private final List<PowerUp> _powerUps = new ArrayList<>();
|
||||
private Location _lastLocation = null;
|
||||
private int _nextSpawnCountdown = -1;
|
||||
private final Map<UUID, PowerUp> _powerUpPickUpCooldown = new HashMap<>();
|
||||
|
||||
public PowerUpManager(Game game, Random random, List<Location> spawnLocations)
|
||||
{
|
||||
@ -146,20 +147,39 @@ public class PowerUpManager implements Listener
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPickUpPowerUp(PlayerPickupItemEvent event)
|
||||
public void onPlayerPickUpPowerUp(final PlayerPickupItemEvent event)
|
||||
{
|
||||
if (getGame().GetTeam(event.getPlayer()) != null)
|
||||
{
|
||||
PowerUp powerUp = getPowerUpByItem(event.getItem());
|
||||
final PowerUp powerUp = getPowerUpByItem(event.getItem());
|
||||
|
||||
if (powerUp != null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
powerUp.powerUpPlayer(event.getPlayer());
|
||||
powerUp.remove();
|
||||
if (_powerUpPickUpCooldown.get(event.getPlayer().getUniqueId()) != powerUp)
|
||||
{
|
||||
if (powerUp.powerUpPlayer(event.getPlayer()))
|
||||
{
|
||||
powerUp.remove();
|
||||
|
||||
schedulePowerUpSpawn(10);
|
||||
schedulePowerUpSpawn(10);
|
||||
}
|
||||
else
|
||||
{
|
||||
_powerUpPickUpCooldown.put(event.getPlayer().getUniqueId(), powerUp);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_powerUpPickUpCooldown.get(event.getPlayer().getUniqueId()) == powerUp)
|
||||
_powerUpPickUpCooldown.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class WeaponPowerUp extends PowerUp
|
||||
}
|
||||
|
||||
@Override
|
||||
public void powerUpPlayer(Player player)
|
||||
public boolean powerUpPlayer(Player player)
|
||||
{
|
||||
for (int swordType = 0; swordType < SWORD_PROGRESSION.size(); swordType++)
|
||||
{
|
||||
@ -35,10 +35,12 @@ public class WeaponPowerUp extends PowerUp
|
||||
|
||||
player.sendMessage("You sword was upgraded!");
|
||||
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage("Your sword is already fully upgraded!");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -50,12 +50,6 @@ public abstract class Kit implements Listener
|
||||
|
||||
_kitAvailability = kitAvailability;
|
||||
|
||||
//Change to Free
|
||||
if (Manager.IsTournamentServer() && (kitAvailability == KitAvailability.Green || kitAvailability == KitAvailability.Blue))
|
||||
{
|
||||
_kitAvailability = KitAvailability.Free;
|
||||
}
|
||||
|
||||
_entityType = entityType;
|
||||
_itemInHand = itemInHand;
|
||||
|
||||
|
@ -33,27 +33,24 @@ public class PerkRevealer extends Perk implements IThrown
|
||||
|
||||
public PerkRevealer()
|
||||
{
|
||||
super("Revealer", new String[]
|
||||
{
|
||||
C.cYellow + "Right-Click" + C.cGray + " with Emerald to " + C.cGreen + "throw Revealer",
|
||||
});
|
||||
super("Revealer", new String[]{C.cYellow + "Right-Click" + C.cGray + " with Emerald to " + C.cGreen + "throw Revealer"});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerThrowRevealer(PlayerInteractEvent event)
|
||||
{
|
||||
if(event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
if(event.getPlayer().getItemInHand() == null)
|
||||
if (event.getPlayer().getItemInHand() == null)
|
||||
return;
|
||||
|
||||
if(event.getPlayer().getItemInHand().getType() != Material.EMERALD)
|
||||
if (event.getPlayer().getItemInHand().getType() != Material.EMERALD)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(!Kit.HasKit(player))
|
||||
if (!Kit.HasKit(player))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
@ -69,15 +66,15 @@ public class PerkRevealer extends Perk implements IThrown
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() == UpdateType.SEC)
|
||||
if (event.getType() == UpdateType.SEC)
|
||||
{
|
||||
for(Iterator<Map.Entry<Player, RevealedPlayerInfo>> it = getRevealedPlayers().entrySet().iterator(); it.hasNext();)
|
||||
for (Iterator<Map.Entry<Player, RevealedPlayerInfo>> it = getRevealedPlayers().entrySet().iterator(); it.hasNext(); )
|
||||
{
|
||||
Map.Entry<Player, RevealedPlayerInfo> entry = it.next();
|
||||
|
||||
if(!entry.getKey().isOnline())
|
||||
if (!entry.getKey().isOnline())
|
||||
it.remove();
|
||||
else if(entry.getValue()._expirationSeconds <= 0)
|
||||
else if (entry.getValue()._expirationSeconds <= 0)
|
||||
{
|
||||
it.remove();
|
||||
|
||||
@ -119,16 +116,16 @@ public class PerkRevealer extends Perk implements IThrown
|
||||
|
||||
UtilFirework.playFirework(data.GetThrown().getLocation(), effect);
|
||||
|
||||
for(Player player : Manager.GetGame().GetPlayers(true))
|
||||
for (Player player : Manager.GetGame().GetPlayers(true))
|
||||
{
|
||||
if(player == data.GetThrower())
|
||||
if (player == data.GetThrower())
|
||||
continue;
|
||||
|
||||
if(player.getLocation().getWorld() == data.GetThrown().getWorld() && player.getLocation().distanceSquared(data.GetThrown().getLocation()) <= 25)
|
||||
if (player.getLocation().getWorld() == data.GetThrown().getWorld() && player.getLocation().distanceSquared(data.GetThrown().getLocation()) <= 25)
|
||||
{
|
||||
RevealedPlayerInfo info = getRevealedPlayers().get(player);
|
||||
|
||||
if(info == null)
|
||||
if (info == null)
|
||||
{
|
||||
info = new RevealedPlayerInfo(Manager.GetDisguise().getDisguise(player));
|
||||
getRevealedPlayers().put(player, info);
|
||||
|
@ -104,7 +104,7 @@ public class GameChatManager implements Listener
|
||||
{
|
||||
Player receiver = recipientIterator.next();
|
||||
|
||||
if (Manager.GetClients().Get(receiver).GetRank().Has(Rank.MODERATOR))
|
||||
if (!Manager.GetServerConfig().Tournament && Manager.GetClients().Get(receiver).GetRank().Has(Rank.MODERATOR))
|
||||
continue;
|
||||
|
||||
GameTeam recTeam = Manager.GetGame().GetTeam(receiver);
|
||||
|
@ -708,28 +708,6 @@ public class GameLobbyManager implements IPacketRunnable, Listener
|
||||
return;
|
||||
}
|
||||
|
||||
if (Manager.IsTournamentServer())
|
||||
{
|
||||
if (_advertiseStage == 0)
|
||||
{
|
||||
WriteAdvertiseLine("TWITCH.TV", 0, 159, (byte)4);
|
||||
WriteAdvertiseLine("CHARITY EVENT", 1, 159, (byte)15);
|
||||
WriteAdvertiseLine(" ", 2, 159, (byte)15);
|
||||
WriteAdvertiseLine("PROUDLY SPONSORED BY", 3, 159, (byte)15);
|
||||
WriteAdvertiseLine("www.mineplex.com", 4, 159, (byte)4);
|
||||
}
|
||||
else if (_advertiseStage == 1)
|
||||
{
|
||||
WriteAdvertiseLine("Supporting", 0, 159, (byte)15);
|
||||
WriteAdvertiseLine("ChildsPlay", 1, 159, (byte)4);
|
||||
WriteAdvertiseLine("AbleGamers", 2, 159, (byte)4);
|
||||
WriteAdvertiseLine("Extra Life", 3, 159, (byte)4);
|
||||
WriteAdvertiseLine("Stand for the Silent", 4, 159, (byte)4);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_advertiseStage == 0)
|
||||
{
|
||||
WriteAdvertiseLine("MINEPLEX ULTRA RANK", 0, 159, (byte)4);
|
||||
|
@ -147,7 +147,7 @@ public class GameManager implements Listener
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (game.GetState() == GameState.Live && !Manager.IsTournamentServer())
|
||||
else if (game.GetState() == GameState.Live)
|
||||
{
|
||||
if (UtilTime.elapsed(game.GetStateTime(), game.GameTimeout))
|
||||
{
|
||||
@ -399,7 +399,7 @@ public class GameManager implements Listener
|
||||
{
|
||||
|
||||
}
|
||||
else if (!game.IsPlaying(player))
|
||||
else if (!game.IsPlaying(player) && !Manager.IsTournamentServer())
|
||||
{
|
||||
PlayerAdd(game, player, null);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user