Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
ef86fe6948
@ -3,6 +3,8 @@
|
||||
<component name="ProjectCodeStyleSettingsManager">
|
||||
<option name="PER_PROJECT_SETTINGS">
|
||||
<value>
|
||||
<option name="FIELD_NAME_PREFIX" value="_" />
|
||||
<option name="STATIC_FIELD_NAME_PREFIX" value="_" />
|
||||
<option name="USE_SINGLE_CLASS_IMPORTS" value="false" />
|
||||
<XML>
|
||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||
@ -15,13 +17,6 @@
|
||||
<option name="WHILE_ON_NEW_LINE" value="true" />
|
||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_TRY_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_SYNCHRONIZED_PARENTHESES" value="false" />
|
||||
<option name="ENUM_CONSTANTS_WRAP" value="2" />
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
|
@ -1,103 +1,20 @@
|
||||
package mineplex.bungee;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mineplex.bungee.lobbyBalancer.LobbyBalancer;
|
||||
import mineplex.bungee.motd.MotdManager;
|
||||
import mineplex.bungee.playerCount.PlayerCount;
|
||||
import mineplex.bungee.playerStats.PlayerStats;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.conf.YamlConfig;
|
||||
|
||||
public class Mineplexer extends Plugin
|
||||
{
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
//_dynamicServers = new GlobalServer(this);
|
||||
|
||||
/*
|
||||
try
|
||||
{
|
||||
Field config = YamlConfig.class.getDeclaredField("config");
|
||||
config.setAccessible(true);
|
||||
Map configMap = (Map)config.get(getProxy().getConfigurationAdapter());
|
||||
|
||||
System.out.println("Printing groups.");
|
||||
for (String playerName : ((HashMap<String, List<String>>)configMap.get("groups")).keySet())
|
||||
{
|
||||
System.out.println(playerName);
|
||||
|
||||
for (String rank : ((HashMap<String, List<String>>)configMap.get("groups")).get(playerName))
|
||||
{
|
||||
System.out.println("-" + rank);
|
||||
}
|
||||
}
|
||||
|
||||
((HashMap<String, List<String>>)configMap.get("groups")).clear();
|
||||
((HashMap<String, List<String>>)configMap.get("groups")).put("defek7", Arrays.asList("admin", "owner"));
|
||||
|
||||
config.set(getProxy().getConfigurationAdapter(), configMap);
|
||||
System.out.println("Printing groups.");
|
||||
for (String playerName : ((HashMap<String, List<String>>)configMap.get("groups")).keySet())
|
||||
{
|
||||
System.out.println(playerName);
|
||||
|
||||
for (String rank : ((HashMap<String, List<String>>)configMap.get("groups")).get(playerName))
|
||||
{
|
||||
System.out.println("-" + rank);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
|
||||
new MotdManager(this);
|
||||
new LobbyBalancer(this);
|
||||
new PlayerCount(this);
|
||||
new FileUpdater(this);
|
||||
new PlayerStats(this);
|
||||
}
|
||||
|
||||
protected String readString(DataInputStream dataInputStream, int maxLength) throws IOException
|
||||
{
|
||||
short length = dataInputStream.readShort();
|
||||
|
||||
if (length > maxLength)
|
||||
{
|
||||
throw new IOException("Received string length longer than maximum allowed (" + length + " > " + maxLength + ")");
|
||||
}
|
||||
else if (length < 0)
|
||||
{
|
||||
throw new IOException("Received string length is less than zero! Weird string!");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
stringBuilder.append(dataInputStream.readChar());
|
||||
}
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeString(String string, DataOutputStream dataOutputStream) throws IOException
|
||||
{
|
||||
dataOutputStream.writeShort(string.length());
|
||||
dataOutputStream.writeChars(string);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package mineplex.core.account;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -16,6 +17,7 @@ import mineplex.core.account.repository.token.ClientToken;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -250,6 +252,50 @@ public class CoreClientManager extends MiniPlugin
|
||||
}, name, rank, perm);
|
||||
}
|
||||
|
||||
public void checkPlayerName(final Player caller, final String playerName, final Callback<Boolean> callback)
|
||||
{
|
||||
_repository.MatchPlayerName(new Callback<List<String>>()
|
||||
{
|
||||
public void run(List<String> matches)
|
||||
{
|
||||
boolean matchedExact = false;
|
||||
|
||||
for (String match : matches)
|
||||
{
|
||||
if (match.equalsIgnoreCase(playerName))
|
||||
{
|
||||
matchedExact = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedExact)
|
||||
{
|
||||
for (Iterator<String> matchIterator = matches.iterator(); matchIterator.hasNext();)
|
||||
{
|
||||
if (!matchIterator.next().equalsIgnoreCase(playerName))
|
||||
{
|
||||
matchIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UtilPlayer.searchOffline(matches, new Callback<String>()
|
||||
{
|
||||
public void run(final String target)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
callback.run(false);
|
||||
return;
|
||||
}
|
||||
|
||||
callback.run(true);
|
||||
}
|
||||
}, caller, playerName, true);
|
||||
}
|
||||
}, playerName);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void cleanGlitchedClients(UpdateEvent event)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ import mineplex.core.mysql.RepositoryBase;
|
||||
|
||||
public class MysqlAccountRepository extends RepositoryBase
|
||||
{
|
||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS Accounts (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id));";
|
||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS Accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), );";
|
||||
|
||||
public MysqlAccountRepository(JavaPlugin plugin)
|
||||
{
|
||||
|
@ -0,0 +1,19 @@
|
||||
package mineplex.core.friend;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.friend.data.FriendRepository;
|
||||
|
||||
public class FriendManager extends MiniPlugin
|
||||
{
|
||||
private FriendRepository _repository;
|
||||
|
||||
public FriendManager(JavaPlugin plugin)
|
||||
{
|
||||
super("Friends", plugin);
|
||||
|
||||
_repository = new FriendRepository();
|
||||
_repository.initialize();
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package mineplex.core.friend.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FriendRepository
|
||||
{
|
||||
public void initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public boolean addFriend(String name)
|
||||
{
|
||||
boolean success = true;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public boolean removeFriend(String name)
|
||||
{
|
||||
boolean success = true;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public List<FriendStatus> getFriends(String uuid)
|
||||
{
|
||||
List<FriendStatus> friends = new ArrayList<FriendStatus>();
|
||||
|
||||
return friends;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package mineplex.core.friend.data;
|
||||
|
||||
public class FriendStatus
|
||||
{
|
||||
public String Name;
|
||||
public String ServerName;
|
||||
public long LastSeenOnline;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package mineplex.core.friend.ui;
|
||||
|
||||
public class FriendPage
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package mineplex.core.friend.ui;
|
||||
|
||||
public class FriendShop
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package mineplex.core.friend.ui;
|
||||
|
||||
public class InvitesPage
|
||||
{
|
||||
|
||||
}
|
@ -3,16 +3,19 @@ package mineplex.core.logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Logger
|
||||
{
|
||||
public static Logger Instance;
|
||||
|
||||
private static JavaPlugin _plugin;
|
||||
private LoggerRepository _repository;
|
||||
|
||||
public static void initialize(JavaPlugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
Instance = new Logger(plugin);
|
||||
}
|
||||
|
||||
@ -47,14 +50,20 @@ public class Logger
|
||||
}
|
||||
}
|
||||
|
||||
public void log(String message)
|
||||
public void log(final String message)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.saveLog(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void log(Throwable exception)
|
||||
{
|
||||
List<String> messages = new ArrayList<String>();
|
||||
final List<String> messages = new ArrayList<String>();
|
||||
|
||||
messages.add("[Exception Start]" + exception.getMessage());
|
||||
|
||||
@ -65,6 +74,12 @@ public class Logger
|
||||
|
||||
messages.add("[Exception End]");
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.saveLog(messages.toArray(new String[0]));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.core.playerTracker;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -20,14 +21,26 @@ public class PlayerTracker extends MiniPlugin
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void trackPlayer(PlayerJoinEvent event)
|
||||
public void trackPlayer(final PlayerJoinEvent event)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.updatePlayerServer(event.getPlayer().getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void untrackPlayer(ClientUnloadEvent event)
|
||||
public void untrackPlayer(final ClientUnloadEvent event)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.deleteServerTransfers(event.GetName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,115 +1,67 @@
|
||||
package mineplex.core.portal.Commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.*;
|
||||
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.portal.Portal;
|
||||
|
||||
public class SendCommand extends CommandBase<Portal>
|
||||
{
|
||||
private Portal _portal;
|
||||
|
||||
public SendCommand(Portal plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "snd","send");
|
||||
|
||||
_portal = plugin;
|
||||
}
|
||||
|
||||
private void SendPlayerToServerWithMessage(Player player, String serverName)
|
||||
{
|
||||
_portal.AddTransferRecord(player.getName(), serverName);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.PORTAL, 0.5f, 2f);
|
||||
|
||||
UtilPlayer.message(player, F.main("SEND", C.cYellow + "You are being sent to server: " + C.cGold + serverName + C.cYellow + "!"));
|
||||
super(plugin, Rank.ADMIN, "send");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player player, final String[] args)
|
||||
{
|
||||
Rank playerRank = CommandCenter.GetClientManager().Get(player).GetRank();
|
||||
|
||||
if(args == null || args.length == 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else if(args.length == 1)
|
||||
{
|
||||
if((playerRank == Rank.OWNER) || (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN))
|
||||
{
|
||||
Player sendPlayer;
|
||||
|
||||
try
|
||||
{
|
||||
sendPlayer = CommandCenter.GetClientManager().Get(args[0]).GetPlayer();
|
||||
}
|
||||
catch(NullPointerException npe)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified player, " + C.cGold + args[0] + C.cPurple + ", does not exist!"));
|
||||
return;
|
||||
}
|
||||
String currentServer = sendPlayer.getServer().getPluginManager().getPlugin("Arcade").getConfig().getString("serverstatus.name");
|
||||
UtilPlayer.message(player, F.main("SEND", C.cGold + args[0] + C.cPurple + " is currently on server: " + C.cGold + currentServer + C.cPurple + "!"));
|
||||
return;
|
||||
}
|
||||
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your arguments are not allowed for this command!"));
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else if(args.length == 2)
|
||||
{
|
||||
if((playerRank == Rank.OWNER) || (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN))
|
||||
{
|
||||
_portal.DoesServerExist(args[1]);
|
||||
Bukkit.getScheduler().runTaskLater(Plugin.GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Player sendPlayer;
|
||||
final String playerTarget = args[0];
|
||||
final String serverTarget = args[1];
|
||||
|
||||
try
|
||||
CommandCenter.GetClientManager().checkPlayerName(player, playerTarget, new Callback<Boolean>()
|
||||
{
|
||||
sendPlayer = CommandCenter.GetClientManager().Get(args[0]).GetPlayer();
|
||||
}
|
||||
catch(NullPointerException npe)
|
||||
public void run(Boolean playerExists)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified player, " + C.cGold + args[0] + C.cPurple + ", does not exist!"));
|
||||
if(!_portal.GetServerExists())
|
||||
if (!playerExists)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified server, " + C.cGold + args[1] + C.cPurple + ", does not exist!"));
|
||||
}
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cGray + "Player " + C.cGold + playerTarget + C.cGray + " does not exist!"));
|
||||
return;
|
||||
}
|
||||
if(!_portal.GetServerExists())
|
||||
|
||||
Plugin.DoesServerExist(serverTarget, new Callback<Boolean>()
|
||||
{
|
||||
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified server, " + C.cGold + args[1] + C.cPurple + ", does not exist!"));
|
||||
return;
|
||||
}
|
||||
if(sendPlayer.getServer().getPluginManager().getPlugin("Arcade").getConfig().getString("serverstatus.name").equalsIgnoreCase(args[1]))
|
||||
public void run(Boolean serverExists)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("SEND", C.cGold + args[0] + C.cPurple + " is already on server: " + C.cGold + args[1] + C.cPurple + "!"));
|
||||
if (!serverExists)
|
||||
{
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cGray + "Server " + C.cGold + serverTarget + C.cGray + " does not exist!"));
|
||||
return;
|
||||
}
|
||||
SendPlayerToServerWithMessage(sendPlayer, args[1]);
|
||||
UtilPlayer.message(player, F.main("SEND", C.cYellow + "You have sent player: " + C.cGold + args[0] + C.cYellow + " to server: " + C.cGold + args[1] + C.cYellow + "!"));
|
||||
|
||||
Plugin.AddTransferRecord(playerTarget, serverTarget);
|
||||
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cGray + "You have sent player: " + C.cGold + playerTarget + C.cGray + " to server: " + C.cGold + serverTarget + C.cGray + "!"));
|
||||
return;
|
||||
}
|
||||
}, 20);
|
||||
return;
|
||||
});
|
||||
}
|
||||
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your arguments are not allowed for this command!"));
|
||||
return;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your arguments are inappropriate for this command!"));
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +1,20 @@
|
||||
package mineplex.core.portal.Commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.*;
|
||||
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.portal.Portal;
|
||||
|
||||
public class ServerCommand extends CommandBase<Portal>
|
||||
{
|
||||
private Portal _portal;
|
||||
|
||||
public ServerCommand(Portal plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "srv","server");
|
||||
|
||||
_portal = plugin;
|
||||
}
|
||||
|
||||
private void SendPlayerToServerWithMessage(Player player, String serverName)
|
||||
{
|
||||
_portal.SendPlayerToServer(player, serverName);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.PORTAL, 0.5f, 2f);
|
||||
|
||||
UtilPlayer.message(player, F.main("SERVER", C.cYellow + "You have been sent to server: " + C.cGold + serverName + C.cYellow + "!"));
|
||||
super(plugin, Rank.ALL, "server");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -39,70 +25,84 @@ public class ServerCommand extends CommandBase<Portal>
|
||||
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("SERVER", C.cYellow + "You are currently on server: " + C.cGold + serverName));
|
||||
UtilPlayer.message(player,
|
||||
F.main(Plugin.GetName(), C.cGray + "You are currently on server: " + C.cGold + serverName));
|
||||
return;
|
||||
}
|
||||
else if (args.length == 1)
|
||||
{
|
||||
_portal.DoesServerExist(args[0]);
|
||||
Bukkit.getServer().getScheduler().runTaskLater(Plugin.GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (serverName.equalsIgnoreCase(args[0]))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "You are already on server: " + C.cGold + serverName + C.cPurple + "!"));
|
||||
return;
|
||||
}
|
||||
if(!_portal.GetServerExists())
|
||||
{
|
||||
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "Your specified server, " + C.cGold + args[0] + C.cPurple + ", does not exist!"));
|
||||
return;
|
||||
}
|
||||
String servUp = args[0].toUpperCase();
|
||||
if(!(servUp.contains("HERO") || servUp.contains("ULTRA") || servUp.contains("BETA")
|
||||
|| servUp.contains("STAFF") || servUp.contains("TEST")))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
if(servUp.contains("HERO") && ((playerRank == Rank.OWNER)
|
||||
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|
||||
|| (playerRank == Rank.HELPER) || (playerRank == Rank.MAPDEV) || (playerRank == Rank.YOUTUBE)
|
||||
|| (playerRank == Rank.ULTRA) || (playerRank == Rank.HERO)))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
if((servUp.contains("ULTRA") || servUp.contains("BETA")) && ((playerRank == Rank.OWNER)
|
||||
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|
||||
|| (playerRank == Rank.HELPER) || (playerRank == Rank.MAPDEV) || (playerRank == Rank.YOUTUBE)
|
||||
|| (playerRank == Rank.ULTRA)))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
if(servUp.contains("STAFF") && ((playerRank == Rank.OWNER)
|
||||
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|
||||
|| (playerRank == Rank.HELPER)))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
if(servUp.contains("TEST") && ((playerRank == Rank.OWNER)
|
||||
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "Your arguments are not allowed for this command!"));
|
||||
return;
|
||||
}
|
||||
}, 20);
|
||||
UtilPlayer.message(
|
||||
player,
|
||||
F.main(Plugin.GetName(), "You are already on " + C.cGold + serverName + C.cGray
|
||||
+ "!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "Your arguments are inappropriate for this command!"));
|
||||
Plugin.DoesServerExist(args[0], new Callback<Boolean>()
|
||||
{
|
||||
public void run(final Boolean serverExists)
|
||||
{
|
||||
if (!serverExists)
|
||||
{
|
||||
UtilPlayer.message(
|
||||
player,
|
||||
F.main(Plugin.GetName(), "Server " + C.cGold + args[0]
|
||||
+ C.cGray + " does not exist!"));
|
||||
return;
|
||||
}
|
||||
|
||||
boolean deniedAccess = false;
|
||||
String servUp = args[0].toUpperCase();
|
||||
|
||||
if (servUp.contains("HERO"))
|
||||
{
|
||||
if (playerRank.Has(Rank.HERO))
|
||||
Plugin.SendPlayerToServerWithMessage(player, args[0]);
|
||||
else
|
||||
deniedAccess = true;
|
||||
}
|
||||
else if (servUp.contains("ULTRA") || servUp.contains("BETA"))
|
||||
{
|
||||
if (playerRank.Has(Rank.ULTRA))
|
||||
Plugin.SendPlayerToServerWithMessage(player, args[0]);
|
||||
else
|
||||
deniedAccess = true;
|
||||
}
|
||||
else if (servUp.contains("STAFF"))
|
||||
{
|
||||
if (playerRank.Has(Rank.HELPER))
|
||||
Plugin.SendPlayerToServerWithMessage(player, args[0]);
|
||||
else
|
||||
deniedAccess = true;
|
||||
}
|
||||
else if (servUp.contains("TEST"))
|
||||
{
|
||||
if (playerRank.Has(Rank.MODERATOR))
|
||||
Plugin.SendPlayerToServerWithMessage(player, args[0]);
|
||||
else
|
||||
deniedAccess = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.SendPlayerToServerWithMessage(player, args[0]);
|
||||
}
|
||||
|
||||
if (deniedAccess)
|
||||
{
|
||||
UtilPlayer.message(
|
||||
player,
|
||||
F.main(Plugin.GetName(), C.cRed + "You don't have permission to join " + C.cGold + args[0]));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player,
|
||||
F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -9,13 +9,18 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.portal.Commands.*;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -30,8 +35,6 @@ public class Portal extends MiniPlugin
|
||||
private List<String> _transfers = new ArrayList<String>();
|
||||
private boolean _retrieve = true;
|
||||
|
||||
private boolean _serverExists = false;
|
||||
|
||||
public Portal(JavaPlugin plugin)
|
||||
{
|
||||
super("Portal", plugin);
|
||||
@ -49,6 +52,19 @@ public class Portal extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void SendPlayerToServerWithMessage(Player player, String serverName)
|
||||
{
|
||||
SendPlayerToServer(player, serverName);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.PORTAL, 0.5f, 2f);
|
||||
|
||||
UtilPlayer
|
||||
.message(
|
||||
player,
|
||||
F.main(GetName(), C.cGray + "You have been sent to server: " + C.cGold + serverName
|
||||
+ C.cGray + "!"));
|
||||
}
|
||||
|
||||
public void SendPlayerToServer(final Player player, String serverName)
|
||||
{
|
||||
if (_connectingPlayers.contains(player.getName()))
|
||||
@ -91,8 +107,6 @@ public class Portal extends MiniPlugin
|
||||
}
|
||||
|
||||
public void AddTransferRecord(final String playerName, final String serverName)
|
||||
{
|
||||
synchronized (_transferLock)
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
{
|
||||
@ -102,25 +116,27 @@ public class Portal extends MiniPlugin
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void DoesServerExist(final String serverName)
|
||||
{
|
||||
synchronized (_transferLock)
|
||||
public void DoesServerExist(final String serverName, final Callback<Boolean> callback)
|
||||
{
|
||||
if (callback == null)
|
||||
return;
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_serverExists = _repository.doesServerExist(serverName);
|
||||
final boolean serverExists = _repository.doesServerExist(serverName);
|
||||
|
||||
Bukkit.getScheduler().runTask(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
callback.run(serverExists);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public boolean GetServerExists()
|
||||
{
|
||||
return _serverExists;
|
||||
});
|
||||
}
|
||||
|
||||
public void AddCommands()
|
||||
|
6
Plugins/Mineplex.DDoSProtectionSwitcher/.classpath
Normal file
6
Plugins/Mineplex.DDoSProtectionSwitcher/.classpath
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
17
Plugins/Mineplex.DDoSProtectionSwitcher/.project
Normal file
17
Plugins/Mineplex.DDoSProtectionSwitcher/.project
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Mineplex.DDoSProtectionSwitcher</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
@ -0,0 +1,116 @@
|
||||
package mineplex.ddos;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class DDoSProtectionSwitcher
|
||||
{
|
||||
public static void main (String args[])
|
||||
{
|
||||
SchemeRegistry schemeRegistry = new SchemeRegistry();
|
||||
schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
|
||||
|
||||
PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(schemeRegistry);
|
||||
connectionManager.setMaxTotal(200);
|
||||
connectionManager.setDefaultMaxPerRoute(20);
|
||||
|
||||
HttpClient httpClient = new DefaultHttpClient(connectionManager);
|
||||
InputStream in = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
HttpGet request = new HttpGet("http://api.dnsmadeeasy.com/V2.0/dns/managed/962728/records/");
|
||||
|
||||
String timeStamp = getServerTime();
|
||||
SecretKeySpec keySpec = new SecretKeySpec("8c9af8cc-d306-4df3-8de8-944deafa8239".getBytes(), "HmacSHA1");
|
||||
Mac mac = Mac.getInstance("HmacSHA1");
|
||||
mac.init(keySpec);
|
||||
byte[] hashBytes = mac.doFinal((timeStamp + "").getBytes());
|
||||
Hex.encodeHexString(hashBytes);
|
||||
|
||||
request.addHeader("x-dnsme-apiKey", "610e21ee-4250-4b55-b637-a1fcc3847850");
|
||||
request.addHeader("x-dnsme-requestDate", timeStamp + "");
|
||||
request.addHeader("x-dnsme-hmac", Hex.encodeHexString(hashBytes));
|
||||
request.addHeader("Content-Type", "application/json");
|
||||
|
||||
HttpResponse response = httpClient.execute(request);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
in = response.getEntity().getContent();
|
||||
System.out.println(convertStreamToString(in));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("JsonWebCall.Execute() Error:\n" + ex.getMessage());
|
||||
|
||||
for (StackTraceElement trace : ex.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getServerTime()
|
||||
{
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
return dateFormat.format(calendar.getTime());
|
||||
}
|
||||
|
||||
private static String convertStreamToString(InputStream is)
|
||||
{
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String line = null;
|
||||
try
|
||||
{
|
||||
while ((line = reader.readLine()) != null)
|
||||
{
|
||||
sb.append(line + "\n");
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
is.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -22,9 +22,9 @@ public class DynamicServerSorter implements Comparator<DynamicServerData>
|
||||
if (first.AvailableCPU > second.AvailableCPU)
|
||||
return -1;
|
||||
|
||||
if (second.AvailableCPU < first.AvailableCPU)
|
||||
if (second.AvailableCPU > first.AvailableCPU)
|
||||
return 1;
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.updater.*;
|
||||
import mineplex.core.updater.event.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.*;
|
||||
|
||||
public class PowerUp
|
||||
{
|
||||
private final PowerUpManager powerUpManager;
|
||||
private final Location location;
|
||||
private Location effectLocation;
|
||||
|
||||
public PowerUp(PowerUpManager powerUpManager, Location location)
|
||||
{
|
||||
this.powerUpManager = powerUpManager;
|
||||
this.location = location;
|
||||
effectLocation = getLocation().getBlock().getLocation().add(0.5, 0, 0.5);
|
||||
effectLocation.setY(250);
|
||||
}
|
||||
|
||||
public PowerUpManager getPowerUpManager()
|
||||
{
|
||||
return powerUpManager;
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return location;
|
||||
}
|
||||
|
||||
public void activate()
|
||||
{
|
||||
Block block = getLocation().getBlock();
|
||||
|
||||
block.setType(Material.BEACON);
|
||||
for(int x = -1; x <= 1; x++)
|
||||
for(int z = -1; z <= 1; z++)
|
||||
block.getRelative(x, -1, z).setType(Material.IRON_BLOCK);
|
||||
}
|
||||
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() == UpdateType.FASTEST && effectLocation != null)
|
||||
{
|
||||
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(FireworkEffect.Type.BURST).trail(false).build();
|
||||
UtilFirework.playFirework(effectLocation, effect);
|
||||
|
||||
effectLocation.setY(effectLocation.getY() - 2);
|
||||
|
||||
if(effectLocation.getY() - getLocation().getY() < 2)
|
||||
{
|
||||
effect = FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(FireworkEffect.Type.BALL_LARGE).trail(true).build();
|
||||
UtilFirework.playFirework(effectLocation, effect);
|
||||
|
||||
effectLocation = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,122 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins;
|
||||
|
||||
import mineplex.core.updater.*;
|
||||
import mineplex.core.updater.event.*;
|
||||
import nautilus.game.arcade.events.*;
|
||||
import nautilus.game.arcade.game.*;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.plugin.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class PowerUpManager implements Listener
|
||||
{
|
||||
private final Game game;
|
||||
private final Random random;
|
||||
private final List<Location> spawnLocations;
|
||||
private final Set<PowerUp> powerUps = new HashSet<>();
|
||||
private Location lastLocation = null;
|
||||
private int nextSpawnCountdown = -1;
|
||||
|
||||
public PowerUpManager(Game game, Random random, List<Location> spawnLocations)
|
||||
{
|
||||
this.game = game;
|
||||
this.random = random;
|
||||
this.spawnLocations = spawnLocations;
|
||||
|
||||
getPlugin().getServer().getPluginManager().registerEvents(this, getPlugin());
|
||||
}
|
||||
|
||||
public Random getRandom()
|
||||
{
|
||||
return random;
|
||||
}
|
||||
|
||||
public List<Location> getSpawnLocations()
|
||||
{
|
||||
return spawnLocations;
|
||||
}
|
||||
|
||||
public Location nextLocation()
|
||||
{
|
||||
if(spawnLocations.size() == 1)
|
||||
lastLocation = spawnLocations.get(0);
|
||||
else if(spawnLocations.size() > 1)
|
||||
{
|
||||
int index = getRandom().nextInt(spawnLocations.size());
|
||||
|
||||
if(lastLocation != null)
|
||||
{
|
||||
while(spawnLocations.get(index).equals(lastLocation))
|
||||
index = getRandom().nextInt(spawnLocations.size());
|
||||
}
|
||||
|
||||
lastLocation = spawnLocations.get(index);
|
||||
}
|
||||
|
||||
return lastLocation;
|
||||
}
|
||||
|
||||
public Plugin getPlugin()
|
||||
{
|
||||
return getGame().Manager.GetPlugin();
|
||||
}
|
||||
|
||||
public void spawnNextPowerUp()
|
||||
{
|
||||
PowerUp powerUp = new PowerUp(this, nextLocation());
|
||||
getPowerUps().add(powerUp);
|
||||
|
||||
powerUp.activate();
|
||||
}
|
||||
|
||||
public Set<PowerUp> getPowerUps()
|
||||
{
|
||||
return powerUps;
|
||||
}
|
||||
|
||||
public void schedulePowerUpSpawn(int seconds)
|
||||
{
|
||||
nextSpawnCountdown = seconds;
|
||||
}
|
||||
|
||||
public Game getGame()
|
||||
{
|
||||
return game;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onGameStateChange(GameStateChangeEvent event)
|
||||
{
|
||||
if(event.GetGame() == getGame() && event.GetState() == Game.GameState.Live)
|
||||
schedulePowerUpSpawn(5);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() == UpdateType.SEC && getGame().GetState() == Game.GameState.Live && nextSpawnCountdown >= 0)
|
||||
{
|
||||
if(nextSpawnCountdown == 0)
|
||||
spawnNextPowerUp();
|
||||
|
||||
nextSpawnCountdown--;
|
||||
}
|
||||
|
||||
for(PowerUp powerUp : getPowerUps())
|
||||
powerUp.onUpdate(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void deregisterSelf(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
if (game.GetState() == GameState.Dead)
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins;
|
||||
|
||||
import org.bukkit.block.*;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class PowerUpSpawn
|
||||
{
|
||||
private Block beaconBlock;
|
||||
private Item item;
|
||||
}
|
@ -1,18 +1,33 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.updater.*;
|
||||
import mineplex.core.updater.event.*;
|
||||
import nautilus.game.arcade.*;
|
||||
import nautilus.game.arcade.events.*;
|
||||
import nautilus.game.arcade.game.*;
|
||||
import nautilus.game.arcade.game.games.sneakyassassins.kits.*;
|
||||
import nautilus.game.arcade.game.games.sneakyassassins.powerups.*;
|
||||
import nautilus.game.arcade.kit.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.event.entity.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SneakyAssassins extends SoloGame
|
||||
{
|
||||
private PowerUpManager powerUpManager;
|
||||
private static final Map<Material, Double> SWORD_DAMAGE = new EnumMap<>(Material.class);
|
||||
|
||||
static
|
||||
{
|
||||
SWORD_DAMAGE.put(Material.WOOD_SWORD, 3.0);
|
||||
SWORD_DAMAGE.put(Material.STONE_SWORD, 4.0);
|
||||
SWORD_DAMAGE.put(Material.GOLD_SWORD, 5.0);
|
||||
SWORD_DAMAGE.put(Material.IRON_SWORD, 6.0);
|
||||
SWORD_DAMAGE.put(Material.DIAMOND_SWORD, 7.0);
|
||||
}
|
||||
|
||||
private PowerUpManager _powerUpManager;
|
||||
|
||||
public SneakyAssassins(ArcadeManager manager)
|
||||
{
|
||||
@ -35,11 +50,45 @@ public class SneakyAssassins extends SoloGame
|
||||
@Override
|
||||
public void ParseData()
|
||||
{
|
||||
powerUpManager = new PowerUpManager(this, UtilMath.random, WorldData.GetDataLocs("RED"));
|
||||
_powerUpManager = new PowerUpManager(this, UtilMath.random, WorldData.GetDataLocs("RED"));
|
||||
}
|
||||
|
||||
public PowerUpManager getPowerUpManager()
|
||||
{
|
||||
return powerUpManager;
|
||||
return _powerUpManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onGameStateChange(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetGame() == this)
|
||||
{
|
||||
switch (event.GetState())
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerAttackWithSword(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!(event.getDamager() instanceof Player))
|
||||
return;
|
||||
|
||||
Player damager = (Player) event.getDamager();
|
||||
|
||||
if (GetTeam(damager) == null)
|
||||
return;
|
||||
|
||||
if (damager.getItemInHand() == null)
|
||||
return;
|
||||
|
||||
Double damage = SWORD_DAMAGE.get(damager.getItemInHand().getType());
|
||||
|
||||
if (damage == null)
|
||||
return;
|
||||
|
||||
event.setDamage(damage);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,13 @@ public abstract class SneakyAssassinKit extends Kit
|
||||
{
|
||||
Manager.GetDisguise().disguise(new DisguiseVillager(player));
|
||||
|
||||
player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD));
|
||||
player.getInventory().setArmorContents(new ItemStack[]{
|
||||
new ItemStack(Material.LEATHER_BOOTS),
|
||||
new ItemStack(Material.LEATHER_LEGGINGS),
|
||||
new ItemStack(Material.LEATHER_CHESTPLATE),
|
||||
new ItemStack(Material.LEATHER_HELMET)
|
||||
});
|
||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.INK_SACK, (byte) 0, 1,
|
||||
C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Smoke Bomb",
|
||||
new String[]
|
||||
|
@ -0,0 +1,72 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins.powerups;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ArmorPowerUp extends PowerUp
|
||||
{
|
||||
private static final List<List<Material>> ARMOR_PROGRESSION = Arrays.asList(
|
||||
Arrays.asList(
|
||||
Material.LEATHER_BOOTS,
|
||||
Material.CHAINMAIL_BOOTS,
|
||||
Material.IRON_BOOTS
|
||||
),
|
||||
Arrays.asList(
|
||||
Material.LEATHER_LEGGINGS,
|
||||
Material.CHAINMAIL_LEGGINGS,
|
||||
Material.IRON_LEGGINGS
|
||||
),
|
||||
Arrays.asList(
|
||||
Material.LEATHER_CHESTPLATE,
|
||||
Material.CHAINMAIL_CHESTPLATE,
|
||||
Material.IRON_CHESTPLATE
|
||||
),
|
||||
Arrays.asList(
|
||||
Material.LEATHER_HELMET,
|
||||
Material.CHAINMAIL_HELMET,
|
||||
Material.IRON_HELMET
|
||||
)
|
||||
);
|
||||
|
||||
public ArmorPowerUp(PowerUpManager powerUpManager, Location location)
|
||||
{
|
||||
super(powerUpManager, PowerUpType.ARMOR, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void powerUpPlayer(Player player)
|
||||
{
|
||||
powerUpArmor(player);
|
||||
powerUpArmor(player);
|
||||
}
|
||||
|
||||
private void powerUpArmor(Player player)
|
||||
{
|
||||
ItemStack[] armor = player.getInventory().getArmorContents();
|
||||
|
||||
List<Integer> upgradeable = new ArrayList<>();
|
||||
|
||||
for (int level = 0; level < ARMOR_PROGRESSION.get(0).size(); level++)
|
||||
{
|
||||
for (int kind = 0; kind < armor.length; kind++)
|
||||
{
|
||||
if (ARMOR_PROGRESSION.get(kind).get(level) == armor[kind].getType())
|
||||
upgradeable.add(kind);
|
||||
}
|
||||
|
||||
if (!upgradeable.isEmpty())
|
||||
{
|
||||
int choice = upgradeable.get(getPowerUpManager().getRandom().nextInt(upgradeable.size()));
|
||||
int nextLevel = Math.min(ARMOR_PROGRESSION.get(choice).size() - 1, level + 1);
|
||||
|
||||
armor[choice] = new ItemStack(ARMOR_PROGRESSION.get(choice).get(nextLevel));
|
||||
player.getInventory().setArmorContents(armor);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins.powerups;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.updater.*;
|
||||
import mineplex.core.updater.event.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.util.*;
|
||||
|
||||
public abstract class PowerUp
|
||||
{
|
||||
private final PowerUpManager _powerUpManager;
|
||||
private final PowerUpType _powerUpType;
|
||||
private final Location _location;
|
||||
private Location _effectLocation;
|
||||
private Block _beaconBlock;
|
||||
private Item _item;
|
||||
|
||||
public PowerUp(PowerUpManager powerUpManager, PowerUpType powerUpType, Location location)
|
||||
{
|
||||
_powerUpManager = powerUpManager;
|
||||
_powerUpType = powerUpType;
|
||||
_location = location;
|
||||
_effectLocation = getLocation().getBlock().getLocation().add(0.5, 0, 0.5);
|
||||
_effectLocation.setY(250);
|
||||
}
|
||||
|
||||
public PowerUpManager getPowerUpManager()
|
||||
{
|
||||
return _powerUpManager;
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public void activate()
|
||||
{
|
||||
_beaconBlock = getLocation().getBlock();
|
||||
_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);
|
||||
}
|
||||
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() == UpdateType.FASTEST && _effectLocation != null)
|
||||
{
|
||||
FireworkEffect effect = FireworkEffect
|
||||
.builder()
|
||||
.flicker(false)
|
||||
.withColor(getPowerUpType().getColor())
|
||||
.with(FireworkEffect.Type.BURST)
|
||||
.trail(false)
|
||||
.build();
|
||||
|
||||
UtilFirework.playFirework(_effectLocation, effect);
|
||||
|
||||
_effectLocation.setY(_effectLocation.getY() - 2);
|
||||
|
||||
if (_effectLocation.getY() - getLocation().getY() < 2)
|
||||
{
|
||||
_effectLocation = null;
|
||||
|
||||
Location itemLocation = _beaconBlock.getLocation().add(0.5, 1.5, 0.5);
|
||||
|
||||
effect = FireworkEffect
|
||||
.builder()
|
||||
.flicker(false)
|
||||
.withColor(getPowerUpType().getColor())
|
||||
.with(FireworkEffect.Type.BALL_LARGE)
|
||||
.trail(true)
|
||||
.build();
|
||||
|
||||
UtilFirework.playFirework(itemLocation, effect);
|
||||
|
||||
_item = itemLocation.getWorld().dropItem(itemLocation, new ItemStack(getPowerUpType().getItemType()));
|
||||
_item.setVelocity(new Vector(0, 0.15, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Item getItem()
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
|
||||
public PowerUpType getPowerUpType()
|
||||
{
|
||||
return _powerUpType;
|
||||
}
|
||||
|
||||
public void remove()
|
||||
{
|
||||
if (getItem() != null)
|
||||
{
|
||||
getItem().remove();
|
||||
_item = null;
|
||||
}
|
||||
|
||||
_beaconBlock.setType(Material.AIR);
|
||||
|
||||
getPowerUpManager().removePowerUp(this);
|
||||
}
|
||||
|
||||
public abstract void powerUpPlayer(Player player);
|
||||
}
|
@ -0,0 +1,180 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins.powerups;
|
||||
|
||||
import mineplex.core.updater.*;
|
||||
import mineplex.core.updater.event.*;
|
||||
import nautilus.game.arcade.events.*;
|
||||
import nautilus.game.arcade.game.*;
|
||||
import nautilus.game.arcade.game.Game.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.plugin.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class PowerUpManager implements Listener
|
||||
{
|
||||
private final Game _game;
|
||||
private final Random _random;
|
||||
private final List<Location> _spawnLocations;
|
||||
private final List<PowerUp> _powerUps = new ArrayList<>();
|
||||
private Location _lastLocation = null;
|
||||
private int _nextSpawnCountdown = -1;
|
||||
|
||||
public PowerUpManager(Game game, Random random, List<Location> spawnLocations)
|
||||
{
|
||||
_game = game;
|
||||
_random = random;
|
||||
_spawnLocations = spawnLocations;
|
||||
|
||||
getPlugin().getServer().getPluginManager().registerEvents(this, getPlugin());
|
||||
}
|
||||
|
||||
public Random getRandom()
|
||||
{
|
||||
return _random;
|
||||
}
|
||||
|
||||
public List<Location> getSpawnLocations()
|
||||
{
|
||||
return _spawnLocations;
|
||||
}
|
||||
|
||||
public Location nextLocation()
|
||||
{
|
||||
if (getSpawnLocations().size() == 1)
|
||||
_lastLocation = getSpawnLocations().get(0);
|
||||
else if (getSpawnLocations().size() > 1)
|
||||
{
|
||||
int index = getRandom().nextInt(getSpawnLocations().size());
|
||||
|
||||
if (_lastLocation != null)
|
||||
{
|
||||
while (getSpawnLocations().get(index).equals(_lastLocation))
|
||||
index = getRandom().nextInt(getSpawnLocations().size());
|
||||
}
|
||||
|
||||
_lastLocation = getSpawnLocations().get(index);
|
||||
}
|
||||
|
||||
return _lastLocation;
|
||||
}
|
||||
|
||||
public Plugin getPlugin()
|
||||
{
|
||||
return getGame().Manager.GetPlugin();
|
||||
}
|
||||
|
||||
public void spawnNextPowerUp()
|
||||
{
|
||||
PowerUp powerUp = PowerUpType.values()[getRandom().nextInt(PowerUpType.values().length)].spawn(this, nextLocation());
|
||||
getPowerUps().add(powerUp);
|
||||
|
||||
powerUp.activate();
|
||||
}
|
||||
|
||||
public List<PowerUp> getPowerUps()
|
||||
{
|
||||
return _powerUps;
|
||||
}
|
||||
|
||||
boolean removePowerUp(PowerUp powerUp)
|
||||
{
|
||||
return _powerUps.remove(powerUp);
|
||||
}
|
||||
|
||||
public void schedulePowerUpSpawn(int seconds)
|
||||
{
|
||||
_nextSpawnCountdown = seconds;
|
||||
}
|
||||
|
||||
public Game getGame()
|
||||
{
|
||||
return _game;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onGameStateChange(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetGame() == getGame())
|
||||
{
|
||||
switch (event.GetState())
|
||||
{
|
||||
case Live:
|
||||
schedulePowerUpSpawn(20);
|
||||
break;
|
||||
|
||||
case Dead:
|
||||
HandlerList.unregisterAll(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() == UpdateType.SEC && getGame().GetState() == Game.GameState.Live && _nextSpawnCountdown >= 0)
|
||||
{
|
||||
if (_nextSpawnCountdown == 0)
|
||||
spawnNextPowerUp();
|
||||
|
||||
_nextSpawnCountdown--;
|
||||
}
|
||||
|
||||
for (PowerUp powerUp : getPowerUps())
|
||||
powerUp.onUpdate(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void deregisterSelf(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
if (_game.GetState() == GameState.Dead)
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPowerUpDespawn(ItemDespawnEvent event)
|
||||
{
|
||||
if (getPowerUpByItem(event.getEntity()) != null)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPickUpPowerUp(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (getGame().GetTeam(event.getPlayer()) != null)
|
||||
{
|
||||
PowerUp powerUp = getPowerUpByItem(event.getItem());
|
||||
|
||||
if (powerUp != null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
powerUp.powerUpPlayer(event.getPlayer());
|
||||
powerUp.remove();
|
||||
|
||||
schedulePowerUpSpawn(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PowerUp getPowerUpByItem(Item item)
|
||||
{
|
||||
if (item == null)
|
||||
return null;
|
||||
|
||||
for (PowerUp powerUp : getPowerUps())
|
||||
{
|
||||
if (powerUp.getItem() != null && powerUp.getItem().equals(item))
|
||||
return powerUp;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins.powerups;
|
||||
|
||||
import org.bukkit.*;
|
||||
|
||||
public enum PowerUpType
|
||||
{
|
||||
WEAPON(Material.DIAMOND_SWORD, Color.RED),
|
||||
ARMOR(Material.IRON_CHESTPLATE, Color.BLUE);
|
||||
|
||||
private final Material _itemType;
|
||||
private final Color _color;
|
||||
|
||||
PowerUpType(Material type, Color color)
|
||||
{
|
||||
_itemType = type;
|
||||
_color = color;
|
||||
}
|
||||
|
||||
public Material getItemType()
|
||||
{
|
||||
return _itemType;
|
||||
}
|
||||
|
||||
public Color getColor()
|
||||
{
|
||||
return _color;
|
||||
}
|
||||
|
||||
public PowerUp spawn(PowerUpManager powerUpManager, Location location)
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case WEAPON:
|
||||
return new WeaponPowerUp(powerUpManager, location);
|
||||
|
||||
case ARMOR:
|
||||
return new ArmorPowerUp(powerUpManager, location);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins.powerups;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class WeaponPowerUp extends PowerUp
|
||||
{
|
||||
private static final List<Material> SWORD_PROGRESSION = Arrays.asList(
|
||||
Material.WOOD_SWORD,
|
||||
Material.STONE_SWORD,
|
||||
Material.IRON_SWORD,
|
||||
Material.GOLD_SWORD,
|
||||
Material.DIAMOND_SWORD
|
||||
);
|
||||
|
||||
public WeaponPowerUp(PowerUpManager powerUpManager, Location location)
|
||||
{
|
||||
super(powerUpManager, PowerUpType.WEAPON, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void powerUpPlayer(Player player)
|
||||
{
|
||||
for (int swordType = 0; swordType < SWORD_PROGRESSION.size(); swordType++)
|
||||
{
|
||||
int swordSlot = player.getInventory().first(SWORD_PROGRESSION.get(swordType));
|
||||
|
||||
if (swordSlot != -1)
|
||||
{
|
||||
int newSwordType = Math.min(SWORD_PROGRESSION.size() - 1, swordType + 1);
|
||||
player.getInventory().setItem(swordSlot, new ItemStack(SWORD_PROGRESSION.get(newSwordType)));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -88,6 +88,13 @@
|
||||
edited = true;
|
||||
}
|
||||
|
||||
// Update account name if changed
|
||||
if (!String.Equals(account.Name, loginToken.Name))
|
||||
{
|
||||
account.Name = loginToken.Name;
|
||||
edited = true;
|
||||
}
|
||||
|
||||
// Expire ranks
|
||||
if ((account.Rank.Name == "ULTRA") && !account.RankPerm && DateTime.Now.CompareTo(account.RankExpire) >= 0)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in New Issue
Block a user