Added UUID lookup for saveRank call.
This commit is contained in:
parent
4017ec95c0
commit
838df3f57a
@ -337,7 +337,7 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveRank(final String name, Rank rank, boolean perm)
|
public void SaveRank(final String name, final UUID uuid, Rank rank, boolean perm)
|
||||||
{
|
{
|
||||||
_repository.saveRank(new Callback<Rank>()
|
_repository.saveRank(new Callback<Rank>()
|
||||||
{
|
{
|
||||||
@ -350,7 +350,7 @@ public class CoreClientManager extends MiniPlugin
|
|||||||
client.SetRank(newRank);
|
client.SetRank(newRank);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, name, rank, perm);
|
}, name, uuid, rank, perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkPlayerNameExact(final Callback<Boolean> callback, final String playerName)
|
public void checkPlayerNameExact(final Callback<Boolean> callback, final String playerName)
|
||||||
|
@ -2,6 +2,7 @@ package mineplex.core.account.command;
|
|||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -11,6 +12,7 @@ import mineplex.core.command.CommandBase;
|
|||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
public class UpdateRank extends CommandBase<CoreClientManager>
|
public class UpdateRank extends CommandBase<CoreClientManager>
|
||||||
@ -86,13 +88,18 @@ public class UpdateRank extends CommandBase<CoreClientManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UUID uuid = Plugin.loadUUIDFromDB(playerName);
|
||||||
|
|
||||||
|
if (uuid == null)
|
||||||
|
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||||
|
|
||||||
Plugin.getRepository().saveRank(new Callback<Rank>()
|
Plugin.getRepository().saveRank(new Callback<Rank>()
|
||||||
{
|
{
|
||||||
public void run(Rank rank)
|
public void run(Rank rank)
|
||||||
{
|
{
|
||||||
caller.sendMessage(F.main(Plugin.getName(), target + "'s rank has been updated to " + rank.Name + "!"));
|
caller.sendMessage(F.main(Plugin.getName(), target + "'s rank has been updated to " + rank.Name + "!"));
|
||||||
}
|
}
|
||||||
}, target, rank, true);
|
}, target, uuid, rank, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}, caller, playerName, true);
|
}, caller, playerName, true);
|
||||||
|
@ -166,7 +166,7 @@ public class AccountRepository extends RepositoryBase
|
|||||||
return uuids.size() == 1 ? uuids.get(0) : null;
|
return uuids.size() == 1 ? uuids.get(0) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveRank(final Callback<Rank> callback, final String name, final Rank rank, final boolean perm)
|
public void saveRank(final Callback<Rank> callback, final String name, final UUID uuid, final Rank rank, final boolean perm)
|
||||||
{
|
{
|
||||||
final RankUpdateToken token = new RankUpdateToken();
|
final RankUpdateToken token = new RankUpdateToken();
|
||||||
token.Name = name;
|
token.Name = name;
|
||||||
@ -180,16 +180,16 @@ public class AccountRepository extends RepositoryBase
|
|||||||
if (rank == Rank.ULTRA || rank == Rank.HERO || rank == Rank.LEGEND)
|
if (rank == Rank.ULTRA || rank == Rank.HERO || rank == Rank.LEGEND)
|
||||||
{
|
{
|
||||||
if (perm)
|
if (perm)
|
||||||
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
|
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||||
else
|
else
|
||||||
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
|
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (perm)
|
if (perm)
|
||||||
executeUpdate(UPDATE_ACCOUNT_RANK_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
|
executeUpdate(UPDATE_ACCOUNT_RANK_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||||
else
|
else
|
||||||
executeUpdate(UPDATE_ACCOUNT_RANK, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
|
executeUpdate(UPDATE_ACCOUNT_RANK, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package mineplex.core.reward.rewards;
|
package mineplex.core.reward.rewards;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.core.reward.Reward;
|
import mineplex.core.reward.Reward;
|
||||||
import mineplex.core.reward.RewardData;
|
import mineplex.core.reward.RewardData;
|
||||||
import mineplex.core.reward.RewardRarity;
|
import mineplex.core.reward.RewardRarity;
|
||||||
@ -21,7 +24,6 @@ public class RankReward extends Reward
|
|||||||
_clientManager = clientManager;
|
_clientManager = clientManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RewardData giveRewardCustom(Player player)
|
public RewardData giveRewardCustom(Player player)
|
||||||
{
|
{
|
||||||
@ -34,7 +36,7 @@ public class RankReward extends Reward
|
|||||||
return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER));
|
return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER));
|
||||||
|
|
||||||
_clientManager.Get(player).SetRank(rank);
|
_clientManager.Get(player).SetRank(rank);
|
||||||
_clientManager.getRepository().saveRank(null, player.getName(), rank, true);
|
_clientManager.getRepository().saveRank(null, player.getName(), player.getUniqueId(), rank, true);
|
||||||
|
|
||||||
return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR));
|
return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR));
|
||||||
}
|
}
|
||||||
|
@ -1,109 +0,0 @@
|
|||||||
package mineplex.serverdata;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class DedicatedServer
|
|
||||||
{
|
|
||||||
|
|
||||||
// The default amount of available CPU usage.
|
|
||||||
public static final int DEFAULT_CPU = 32;
|
|
||||||
|
|
||||||
// The default amount of available ram usage.
|
|
||||||
public static final int DEFAULT_RAM = 14000;
|
|
||||||
|
|
||||||
// The unique name representing this server
|
|
||||||
private String _name;
|
|
||||||
public String getName() { return _name; }
|
|
||||||
|
|
||||||
// The public I.P address used to connect to this server
|
|
||||||
private String _publicAddress;
|
|
||||||
public String getPublicAddress() { return _publicAddress; }
|
|
||||||
|
|
||||||
// The private I.P address of this server
|
|
||||||
private String _privateAddress;
|
|
||||||
public String getPrivateAddress() { return _privateAddress; }
|
|
||||||
|
|
||||||
// The geographical region that this dedicated server is located in
|
|
||||||
private Region _region;
|
|
||||||
public Region getRegion() { return _region; }
|
|
||||||
public boolean isUsRegion() { return _region == Region.US; }
|
|
||||||
|
|
||||||
// The amount of available CPU usage on this server box.
|
|
||||||
private int _availableCpu;
|
|
||||||
public int getAvailableCpu() { return _availableCpu; }
|
|
||||||
|
|
||||||
// The amount of available ram usage on this server box.
|
|
||||||
private int _availableRam;
|
|
||||||
public int getAvailableRam() { return _availableRam; }
|
|
||||||
|
|
||||||
// The amount of available CPU usage on this server box.
|
|
||||||
private int _maxCpu;
|
|
||||||
public int getMaxCpu() { return _maxCpu; }
|
|
||||||
|
|
||||||
// The amount of available ram usage on this server box.
|
|
||||||
private int _maxRam;
|
|
||||||
public int getMaxRam() { return _maxRam; }
|
|
||||||
|
|
||||||
// A mapping of server group names (Key) to the number of server instances (Value)
|
|
||||||
private Map<String, Integer> _serverCounts;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class constructor
|
|
||||||
* @param data - the set of serialized data values representing
|
|
||||||
* the internal state of this DedicatedServer.
|
|
||||||
*/
|
|
||||||
public DedicatedServer(Map<String, String> data)
|
|
||||||
{
|
|
||||||
_name = data.get("name");
|
|
||||||
_publicAddress = data.get("publicAddress");
|
|
||||||
_privateAddress = data.get("privateAddress");
|
|
||||||
_region = Region.valueOf(data.get("region").toUpperCase());
|
|
||||||
_availableCpu = Integer.valueOf(data.get("cpu"));
|
|
||||||
_availableRam = Integer.valueOf(data.get("ram"));
|
|
||||||
_maxCpu = Integer.valueOf(data.get("cpu"));
|
|
||||||
_maxRam = Integer.valueOf(data.get("ram"));
|
|
||||||
_serverCounts = new HashMap<String, Integer>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the number of {@link MinecraftServer} instances on this server
|
|
||||||
* for a specific {@link ServerGroup} type.
|
|
||||||
* @param serverGroup - the {@link ServerGroup} whose server instance count is being set.
|
|
||||||
* @param serverCount - the number of {@link MinecraftServer} instances active on this server.
|
|
||||||
*/
|
|
||||||
public void setServerCount(ServerGroup serverGroup, int serverCount)
|
|
||||||
{
|
|
||||||
if (_serverCounts.containsKey(serverGroup.getName()))
|
|
||||||
{
|
|
||||||
int currentAmount = _serverCounts.get(serverGroup.getName());
|
|
||||||
_availableCpu += serverGroup.getRequiredCpu() * currentAmount;
|
|
||||||
_availableRam += serverGroup.getRequiredRam() * currentAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
_serverCounts.put(serverGroup.getName(), serverCount);
|
|
||||||
_availableCpu -= serverGroup.getRequiredCpu() * serverCount;
|
|
||||||
_availableRam -= serverGroup.getRequiredRam() * serverCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param serverGroup - the server group whose server count on this dedicated server is being fetched.
|
|
||||||
* @return the number of active {@link MinecraftServer}s on this dedicated server
|
|
||||||
* that belong to {@code serverGroup}.
|
|
||||||
*/
|
|
||||||
public int getServerCount(ServerGroup serverGroup)
|
|
||||||
{
|
|
||||||
String groupName = serverGroup.getName();
|
|
||||||
return _serverCounts.containsKey(groupName) ? _serverCounts.get(groupName) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Increment the number of {@link MinecraftServer} instances on this server
|
|
||||||
* for a specific {@link ServerGroup} type by 1.
|
|
||||||
* @param serverGroup - the {@link ServerGroup} whose server instance count is being incremented
|
|
||||||
*/
|
|
||||||
public void incrementServerCount(ServerGroup serverGroup)
|
|
||||||
{
|
|
||||||
setServerCount(serverGroup, getServerCount(serverGroup) + 1);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,351 +0,0 @@
|
|||||||
package mineplex.serverdata;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ServerGroup
|
|
||||||
{
|
|
||||||
private HashMap<String, String> _dataMap = null;
|
|
||||||
|
|
||||||
private String _name;
|
|
||||||
private String _host;
|
|
||||||
private String _prefix;
|
|
||||||
|
|
||||||
private int _minPlayers;
|
|
||||||
private int _maxPlayers;
|
|
||||||
|
|
||||||
private int _requiredRam;
|
|
||||||
private int _requiredCpu;
|
|
||||||
private int _requiredTotalServers;
|
|
||||||
private int _requiredJoinableServers;
|
|
||||||
|
|
||||||
private boolean _arcadeGroup;
|
|
||||||
private String _worldZip;
|
|
||||||
private String _plugin;
|
|
||||||
private String _configPath;
|
|
||||||
private int _portSection;
|
|
||||||
|
|
||||||
private boolean _pvp;
|
|
||||||
private boolean _tournament;
|
|
||||||
private boolean _tournamentPoints;
|
|
||||||
private boolean _teamRejoin;
|
|
||||||
private boolean _teamAutoJoin;
|
|
||||||
private boolean _teamForceBalance;
|
|
||||||
|
|
||||||
private boolean _gameAutoStart;
|
|
||||||
private boolean _gameTimeout;
|
|
||||||
private boolean _rewardGems;
|
|
||||||
private boolean _rewardItems;
|
|
||||||
|
|
||||||
private boolean _rewardStats;
|
|
||||||
private boolean _rewardAchievements;
|
|
||||||
private boolean _hotbarInventory;
|
|
||||||
private boolean _hotbarHubClock;
|
|
||||||
private boolean _playerKickIdle;
|
|
||||||
private boolean _generateFreeVersions;
|
|
||||||
|
|
||||||
private String _games;
|
|
||||||
private String _serverType;
|
|
||||||
private boolean _addNoCheat;
|
|
||||||
private boolean _whitelist;
|
|
||||||
private boolean _staffOnly;
|
|
||||||
private String _resourcePack = "";
|
|
||||||
|
|
||||||
private Region _region;
|
|
||||||
|
|
||||||
private Set<MinecraftServer> _servers;
|
|
||||||
|
|
||||||
public ServerGroup(Map<String, String> data, Collection<MinecraftServer> serverStatuses)
|
|
||||||
{
|
|
||||||
_name = data.get("name");
|
|
||||||
_prefix = data.get("prefix");
|
|
||||||
_requiredRam = Integer.valueOf(data.get("ram"));
|
|
||||||
_requiredCpu = Integer.valueOf(data.get("cpu"));
|
|
||||||
_requiredTotalServers = Integer.valueOf(data.get("totalServers"));
|
|
||||||
_requiredJoinableServers = Integer.valueOf(data.get("joinableServers"));
|
|
||||||
_portSection = Integer.valueOf(data.get("portSection"));
|
|
||||||
_arcadeGroup = Boolean.valueOf(data.get("arcadeGroup"));
|
|
||||||
_worldZip = data.get("worldZip");
|
|
||||||
_plugin = data.get("plugin");
|
|
||||||
_configPath = data.get("configPath");
|
|
||||||
_minPlayers = Integer.valueOf(data.get("minPlayers"));
|
|
||||||
_maxPlayers = Integer.valueOf(data.get("maxPlayers"));
|
|
||||||
_pvp = Boolean.valueOf(data.get("pvp"));
|
|
||||||
_tournament = Boolean.valueOf(data.get("tournament"));
|
|
||||||
_tournamentPoints = Boolean.valueOf(data.get("tournamentPoints"));
|
|
||||||
_generateFreeVersions = Boolean.valueOf(data.get("generateFreeVersions"));
|
|
||||||
_games = data.get("games");
|
|
||||||
_serverType = data.get("serverType");
|
|
||||||
_addNoCheat = Boolean.valueOf(data.get("addNoCheat"));
|
|
||||||
_teamRejoin = Boolean.valueOf(data.get("teamRejoin"));
|
|
||||||
_teamAutoJoin = Boolean.valueOf(data.get("teamAutoJoin"));
|
|
||||||
_teamForceBalance = Boolean.valueOf(data.get("teamForceBalance"));
|
|
||||||
_gameAutoStart = Boolean.valueOf(data.get("gameAutoStart"));
|
|
||||||
_gameTimeout = Boolean.valueOf(data.get("gameTimeout"));
|
|
||||||
_rewardGems = Boolean.valueOf(data.get("rewardGems"));
|
|
||||||
_rewardItems = Boolean.valueOf(data.get("rewardItems"));
|
|
||||||
_rewardStats = Boolean.valueOf(data.get("rewardStats"));
|
|
||||||
_rewardAchievements = Boolean.valueOf(data.get("rewardAchievements"));
|
|
||||||
_hotbarInventory = Boolean.valueOf(data.get("hotbarInventory"));
|
|
||||||
_hotbarHubClock = Boolean.valueOf(data.get("hotbarHubClock"));
|
|
||||||
_playerKickIdle = Boolean.valueOf(data.get("playerKickIdle"));
|
|
||||||
_staffOnly = Boolean.valueOf(data.get("staffOnly"));
|
|
||||||
_whitelist = Boolean.valueOf(data.get("whitelist"));
|
|
||||||
_resourcePack = data.containsKey("resourcePack") ? data.get("resourcePack") : "";
|
|
||||||
_host = data.get("host");
|
|
||||||
_region = data.containsKey("region") ? Region.valueOf(data.get("region")) : Region.ALL;
|
|
||||||
|
|
||||||
if (serverStatuses != null)
|
|
||||||
parseServers(serverStatuses);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerGroup(String name, String prefix, String host, int ram, int cpu, int totalServers, int joinable, int portSection, boolean arcade, String worldZip, String plugin, String configPath
|
|
||||||
, int minPlayers, int maxPlayers, boolean pvp, boolean tournament, boolean tournamentPoints, String games, String serverType, boolean noCheat, boolean teamRejoin
|
|
||||||
, boolean teamAutoJoin, boolean teamForceBalance, boolean gameAutoStart, boolean gameTimeout, boolean rewardGems, boolean rewardItems, boolean rewardStats
|
|
||||||
, boolean rewardAchievements, boolean hotbarInventory, boolean hotbarHubClock, boolean playerKickIdle, boolean staffOnly, boolean whitelist, String resourcePack, Region region)
|
|
||||||
{
|
|
||||||
_name = name;
|
|
||||||
_prefix = prefix;
|
|
||||||
_host = host;
|
|
||||||
_requiredRam = ram;
|
|
||||||
_requiredCpu = cpu;
|
|
||||||
_requiredTotalServers = totalServers;
|
|
||||||
_requiredJoinableServers = joinable;
|
|
||||||
_portSection = portSection;
|
|
||||||
_arcadeGroup = arcade;
|
|
||||||
_worldZip = worldZip;
|
|
||||||
_plugin = plugin;
|
|
||||||
_configPath = configPath;
|
|
||||||
_minPlayers = minPlayers;
|
|
||||||
_maxPlayers = maxPlayers;
|
|
||||||
_pvp = pvp;
|
|
||||||
_tournament = tournament;
|
|
||||||
_tournamentPoints = tournamentPoints;
|
|
||||||
_games = games;
|
|
||||||
_serverType = serverType;
|
|
||||||
_addNoCheat = noCheat;
|
|
||||||
_teamRejoin = teamRejoin;
|
|
||||||
_teamAutoJoin = teamAutoJoin;
|
|
||||||
_teamForceBalance = teamForceBalance;
|
|
||||||
_gameAutoStart = gameAutoStart;
|
|
||||||
_gameTimeout = gameTimeout;
|
|
||||||
_rewardGems = rewardGems;
|
|
||||||
_rewardItems = rewardItems;
|
|
||||||
_rewardStats = rewardStats;
|
|
||||||
_rewardAchievements = rewardAchievements;
|
|
||||||
_hotbarInventory = hotbarInventory;
|
|
||||||
_hotbarHubClock = hotbarHubClock;
|
|
||||||
_playerKickIdle = playerKickIdle;
|
|
||||||
_staffOnly = staffOnly;
|
|
||||||
_whitelist = whitelist;
|
|
||||||
_resourcePack = resourcePack;
|
|
||||||
_region = region;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() { return _name; }
|
|
||||||
public String getHost() { return _host; }
|
|
||||||
public String getPrefix() { return _prefix; }
|
|
||||||
|
|
||||||
public int getMinPlayers() { return _minPlayers; }
|
|
||||||
public int getMaxPlayers() { return _maxPlayers; }
|
|
||||||
|
|
||||||
public int getRequiredRam() { return _requiredRam; }
|
|
||||||
public int getRequiredCpu() { return _requiredCpu; }
|
|
||||||
public int getRequiredTotalServers() { return _requiredTotalServers; }
|
|
||||||
public int getRequiredJoinableServers() { return _requiredJoinableServers; }
|
|
||||||
public int getPortSection() { return _portSection; }
|
|
||||||
|
|
||||||
public boolean getArcadeGroup() { return _arcadeGroup; }
|
|
||||||
public String getWorldZip() { return _worldZip; }
|
|
||||||
public String getPlugin() { return _plugin; }
|
|
||||||
public String getConfigPath() { return _configPath; }
|
|
||||||
|
|
||||||
public boolean getPvp() { return _pvp; }
|
|
||||||
public boolean getTournament() { return _tournament; }
|
|
||||||
public boolean getTournamentPoints() { return _tournamentPoints; }
|
|
||||||
public boolean getTeamRejoin() { return _teamRejoin; }
|
|
||||||
public boolean getTeamAutoJoin() { return _teamAutoJoin; }
|
|
||||||
|
|
||||||
public boolean getTeamForceBalance() { return _teamForceBalance; }
|
|
||||||
public boolean getGameAutoStart() { return _gameAutoStart; }
|
|
||||||
public boolean getGameTimeout() { return _gameTimeout; }
|
|
||||||
public boolean getRewardGems() { return _rewardGems; }
|
|
||||||
public boolean getRewardItems() { return _rewardItems; }
|
|
||||||
|
|
||||||
public boolean getRewardStats() { return _rewardStats; }
|
|
||||||
public boolean getRewardAchievements() { return _rewardAchievements; }
|
|
||||||
public boolean getHotbarInventory() { return _hotbarInventory; }
|
|
||||||
public boolean getHotbarHubClock() { return _hotbarHubClock; }
|
|
||||||
public boolean getPlayerKickIdle() { return _playerKickIdle; }
|
|
||||||
public boolean getGenerateFreeVersions() { return _generateFreeVersions; }
|
|
||||||
|
|
||||||
public String getGames() { return _games; }
|
|
||||||
public String getServerType() { return _serverType; }
|
|
||||||
public boolean getAddNoCheat() { return _addNoCheat; }
|
|
||||||
public boolean getWhitelist() { return _whitelist; }
|
|
||||||
public boolean getStaffOnly() { return _staffOnly; }
|
|
||||||
public String getResourcePack() { return _resourcePack; }
|
|
||||||
public Region getRegion() { return _region; }
|
|
||||||
|
|
||||||
public Set<MinecraftServer> getServers() { return _servers; }
|
|
||||||
|
|
||||||
public int getServerCount()
|
|
||||||
{
|
|
||||||
return _servers.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getJoinableCount()
|
|
||||||
{
|
|
||||||
int joinable = 0;
|
|
||||||
|
|
||||||
for (MinecraftServer server : _servers)
|
|
||||||
{
|
|
||||||
if (server.isJoinable())
|
|
||||||
{
|
|
||||||
joinable++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return joinable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPlayerCount()
|
|
||||||
{
|
|
||||||
int playerCount = 0;
|
|
||||||
|
|
||||||
for (MinecraftServer server : _servers)
|
|
||||||
{
|
|
||||||
playerCount += server.getPlayerCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
return playerCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxPlayerCount()
|
|
||||||
{
|
|
||||||
int maxPlayerCount = 0;
|
|
||||||
|
|
||||||
for (MinecraftServer server : _servers)
|
|
||||||
{
|
|
||||||
maxPlayerCount += server.getMaxPlayerCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
return maxPlayerCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<MinecraftServer> getEmptyServers()
|
|
||||||
{
|
|
||||||
Collection<MinecraftServer> emptyServers = new HashSet<MinecraftServer>();
|
|
||||||
|
|
||||||
for (MinecraftServer server : _servers)
|
|
||||||
{
|
|
||||||
if (server.isEmpty() && server.getUptime() >= 150) // Only return empty servers that have been online for >150 seconds
|
|
||||||
{
|
|
||||||
emptyServers.add(server);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return emptyServers;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void parseServers(Collection<MinecraftServer> servers)
|
|
||||||
{
|
|
||||||
_servers = new HashSet<MinecraftServer>();
|
|
||||||
|
|
||||||
for (MinecraftServer server : servers)
|
|
||||||
{
|
|
||||||
if (_name.equalsIgnoreCase(server.getGroup()))
|
|
||||||
{
|
|
||||||
_servers.add(server);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int generateUniqueId(int startId)
|
|
||||||
{
|
|
||||||
int id = startId;
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
boolean uniqueId = true;
|
|
||||||
|
|
||||||
for (MinecraftServer server : _servers)
|
|
||||||
{
|
|
||||||
String serverName = server.getName();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int serverNum = Integer.parseInt(serverName.split("-")[1]);
|
|
||||||
|
|
||||||
if (serverNum == id)
|
|
||||||
{
|
|
||||||
uniqueId = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uniqueId)
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
id++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String, String> getDataMap()
|
|
||||||
{
|
|
||||||
if (_dataMap == null)
|
|
||||||
{
|
|
||||||
_dataMap = new HashMap<String, String>();
|
|
||||||
|
|
||||||
_dataMap.put("name", _name);
|
|
||||||
_dataMap.put("prefix", _prefix);
|
|
||||||
_dataMap.put("ram", _requiredRam + "");
|
|
||||||
_dataMap.put("cpu", _requiredCpu + "");
|
|
||||||
_dataMap.put("totalServers", _requiredTotalServers + "");
|
|
||||||
_dataMap.put("joinableServers", _requiredJoinableServers + "");
|
|
||||||
_dataMap.put("portSection", _portSection + "");
|
|
||||||
_dataMap.put("arcadeGroup", _arcadeGroup + "");
|
|
||||||
_dataMap.put("worldZip", _worldZip);
|
|
||||||
_dataMap.put("plugin", _plugin);
|
|
||||||
_dataMap.put("configPath", _configPath);
|
|
||||||
_dataMap.put("minPlayers", _minPlayers + "");
|
|
||||||
_dataMap.put("maxPlayers", _maxPlayers + "");
|
|
||||||
_dataMap.put("pvp", _pvp + "");
|
|
||||||
_dataMap.put("tournament", _tournament + "");
|
|
||||||
_dataMap.put("tournamentPoints", _tournamentPoints + "");
|
|
||||||
_dataMap.put("games", _games);
|
|
||||||
_dataMap.put("serverType", _serverType);
|
|
||||||
_dataMap.put("addNoCheat", _addNoCheat + "");
|
|
||||||
_dataMap.put("teamRejoin", _teamRejoin + "");
|
|
||||||
_dataMap.put("teamAutoJoin", _teamAutoJoin + "");
|
|
||||||
_dataMap.put("teamForceBalance", _teamForceBalance + "");
|
|
||||||
_dataMap.put("gameAutoStart", _gameAutoStart + "");
|
|
||||||
_dataMap.put("gameTimeout", _gameTimeout + "");
|
|
||||||
_dataMap.put("rewardGems", _rewardGems + "");
|
|
||||||
_dataMap.put("rewardItems", _rewardItems + "");
|
|
||||||
_dataMap.put("rewardStats", _rewardStats + "");
|
|
||||||
_dataMap.put("rewardAchievements", _rewardAchievements + "");
|
|
||||||
_dataMap.put("hotbarInventory", _hotbarInventory + "");
|
|
||||||
_dataMap.put("hotbarHubClock", _hotbarHubClock + "");
|
|
||||||
_dataMap.put("playerKickIdle", _playerKickIdle + "");
|
|
||||||
_dataMap.put("staffOnly", _staffOnly + "");
|
|
||||||
_dataMap.put("whitelist", _whitelist + "");
|
|
||||||
_dataMap.put("resourcePack", _resourcePack);
|
|
||||||
_dataMap.put("host", _host);
|
|
||||||
_dataMap.put("region", _region.name());
|
|
||||||
}
|
|
||||||
|
|
||||||
return _dataMap;
|
|
||||||
}
|
|
||||||
}
|
|
@ -37,11 +37,12 @@ public class ItemCommand extends CommandBase<SalesPackageManager>
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String itemName = tempName;
|
final String itemName = tempName;
|
||||||
final UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName);
|
UUID uuidLookup = Plugin.getClientManager().loadUUIDFromDB(playerName);
|
||||||
|
|
||||||
if (uuid == null)
|
if (uuidLookup == null)
|
||||||
UUIDFetcher.getUUIDOf(playerName);
|
uuidLookup = UUIDFetcher.getUUIDOf(playerName);
|
||||||
|
|
||||||
|
final UUID uuid = uuidLookup;
|
||||||
final int amount = amountSpecified;
|
final int amount = amountSpecified;
|
||||||
|
|
||||||
if (!Plugin.getInventoryManager().validCategory(category))
|
if (!Plugin.getInventoryManager().validCategory(category))
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package mineplex.staffServer.salespackage.command;
|
package mineplex.staffServer.salespackage.command;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||||
|
|
||||||
public class RankCommand extends CommandBase<SalesPackageManager>
|
public class RankCommand extends CommandBase<SalesPackageManager>
|
||||||
@ -24,11 +27,16 @@ public class RankCommand extends CommandBase<SalesPackageManager>
|
|||||||
String rank = args[1];
|
String rank = args[1];
|
||||||
boolean perm = Boolean.parseBoolean(args[2]);
|
boolean perm = Boolean.parseBoolean(args[2]);
|
||||||
|
|
||||||
|
UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName);
|
||||||
|
|
||||||
|
if (uuid == null)
|
||||||
|
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||||
|
|
||||||
final Rank rankEnum = Rank.valueOf(rank);
|
final Rank rankEnum = Rank.valueOf(rank);
|
||||||
|
|
||||||
if (rankEnum == Rank.HERO || rankEnum == Rank.ULTRA || rankEnum == Rank.LEGEND || rankEnum == Rank.ALL)
|
if (rankEnum == Rank.HERO || rankEnum == Rank.ULTRA || rankEnum == Rank.LEGEND || rankEnum == Rank.ALL)
|
||||||
{
|
{
|
||||||
Plugin.getClientManager().SaveRank(playerName, mineplex.core.common.Rank.valueOf(rank), perm);
|
Plugin.getClientManager().SaveRank(playerName, uuid, mineplex.core.common.Rank.valueOf(rank), perm);
|
||||||
caller.sendMessage(F.main(Plugin.getName(), playerName + "'s rank has been updated to " + rank + "!"));
|
caller.sendMessage(F.main(Plugin.getName(), playerName + "'s rank has been updated to " + rank + "!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user