mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-12-23 08:46:31 +00:00
Add getWithRank() and getInGameUsernames(), also implement getOrdinal() and getPlural()
This commit is contained in:
parent
4c13ea79cc
commit
3eb979e36b
1 changed files with 46 additions and 4 deletions
|
@ -1,29 +1,36 @@
|
||||||
package me.StevenLawson.TotalFreedomMod.player;
|
package me.StevenLawson.TotalFreedomMod.player;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import me.StevenLawson.TotalFreedomMod.admin.Admin;
|
import me.StevenLawson.TotalFreedomMod.admin.Admin;
|
||||||
import me.StevenLawson.TotalFreedomMod.admin.AdminList;
|
import me.StevenLawson.TotalFreedomMod.admin.AdminList;
|
||||||
import me.StevenLawson.TotalFreedomMod.config.ConfigurationEntry;
|
import me.StevenLawson.TotalFreedomMod.config.ConfigurationEntry;
|
||||||
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static me.StevenLawson.TotalFreedomMod.util.Utilities.DEVELOPERS;
|
import static me.StevenLawson.TotalFreedomMod.util.Utilities.DEVELOPERS;
|
||||||
import static me.StevenLawson.TotalFreedomMod.util.Utilities.getPluginFile;
|
import static me.StevenLawson.TotalFreedomMod.util.Utilities.getPluginFile;
|
||||||
|
|
||||||
public enum PlayerRank
|
public enum PlayerRank implements Comparator<PlayerRank>, Comparable<PlayerRank>
|
||||||
{
|
{
|
||||||
IMPOSTOR("an " + ChatColor.YELLOW + ChatColor.UNDERLINE + "Impostor", ChatColor.YELLOW.toString() + ChatColor.UNDERLINE + "[IMP]", "Impostors", 0),
|
IMPOSTOR("an " + ChatColor.YELLOW + ChatColor.UNDERLINE + "Impostor", ChatColor.YELLOW.toString() + ChatColor.UNDERLINE + "[IMP]", "Impostors", 0),
|
||||||
NON_OP("a " + ChatColor.GREEN + "Non-OP", ChatColor.GREEN.toString(), "Non-Operators", 1),
|
NON_OP("a " + ChatColor.GREEN + "Non-OP", ChatColor.GREEN.toString(), "Non-Operators", 1),
|
||||||
OP("an " + ChatColor.RED + "OP", ChatColor.RED + "[OP]", "Operators" ,2),
|
OP("an " + ChatColor.RED + "OP", ChatColor.RED + "[OP]", "Operators" ,2),
|
||||||
SUPER("a " + ChatColor.GOLD + "Super Admin", ChatColor.GOLD + "[SA]", "Super Admins", 3),
|
SUPER("a " + ChatColor.GOLD + "Super Admin", ChatColor.GOLD + "[SA]", "Super Admins", 3),
|
||||||
DEVELOPER("a " + ChatColor.DARK_PURPLE + "Developer", ChatColor.DARK_PURPLE + "[Dev]", "Developers", 4),
|
TELNET("a " + ChatColor.DARK_GREEN + "Super Telnet Admin", ChatColor.DARK_GREEN + "[STA]", "Super Telnet Admins", 4),
|
||||||
TELNET("a " + ChatColor.DARK_GREEN + "Super Telnet Admin", ChatColor.DARK_GREEN + "[STA]", "Super Telnet Admins", 5),
|
SENIOR("a " + ChatColor.LIGHT_PURPLE + "Senior Admin", ChatColor.LIGHT_PURPLE + "[SrA]", "Senior Admins", 5),
|
||||||
SENIOR("a " + ChatColor.LIGHT_PURPLE + "Senior Admin", ChatColor.LIGHT_PURPLE + "[SrA]", "Senior Admins", 6),
|
DEVELOPER("a " + ChatColor.DARK_PURPLE + "Developer", ChatColor.DARK_PURPLE + "[Dev]", "Developers", 6),
|
||||||
OWNER("the " + ChatColor.BLUE + "Owner", ChatColor.BLUE + "[Owner]", "Owners", 7),
|
OWNER("the " + ChatColor.BLUE + "Owner", ChatColor.BLUE + "[Owner]", "Owners", 7),
|
||||||
CONSOLE("The " + ChatColor.DARK_PURPLE + "Console", ChatColor.DARK_PURPLE + "[Console]", 8);
|
CONSOLE("The " + ChatColor.DARK_PURPLE + "Console", ChatColor.DARK_PURPLE + "[Console]", 8);
|
||||||
private final String loginMessage;
|
private final String loginMessage;
|
||||||
private final String prefix;
|
private final String prefix;
|
||||||
|
|
||||||
private final String plural;
|
private final String plural;
|
||||||
private final int ordinal;
|
private final int ordinal;
|
||||||
|
|
||||||
|
@ -135,4 +142,39 @@ public enum PlayerRank
|
||||||
{
|
{
|
||||||
return loginMessage;
|
return loginMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getPlural() {
|
||||||
|
return plural;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOrdinal() {
|
||||||
|
return ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> getWithRank() {
|
||||||
|
List<Player> inGame = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
|
if(fromSender(onlinePlayer).equals(this)) inGame.add(onlinePlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ImmutableList.copyOf(inGame);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getInGameUsernames() {
|
||||||
|
List<String> inGame = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
|
if(fromSender(onlinePlayer).equals(this)) inGame.add(onlinePlayer.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ImmutableList.copyOf(inGame);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(PlayerRank o1, PlayerRank o2) {
|
||||||
|
return o1.ordinal - o2.ordinal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue