mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-04-04 19:03:15 +00:00
Mass Refractoring, now uses me.totalfreedom.totalfreedommod as package Uses Aero https://github.com/Pravian/Aero Revamped command system Remove all TFM_ prefixes Revamp rank system Use new service based system Cleanup
73 lines
1.5 KiB
Java
73 lines
1.5 KiB
Java
package me.totalfreedom.totalfreedommod.commandblocker;
|
|
|
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
import me.totalfreedom.totalfreedommod.permission.PlayerRank;
|
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
public enum CommandBlockerRank
|
|
{
|
|
ANYONE("a"),
|
|
OP("o"),
|
|
SUPER("s"),
|
|
TELNET("t"),
|
|
SENIOR("c"),
|
|
NOBODY("n");
|
|
//
|
|
private final String token;
|
|
|
|
private CommandBlockerRank(String token)
|
|
{
|
|
this.token = token;
|
|
}
|
|
|
|
public String getToken()
|
|
{
|
|
return this.token;
|
|
}
|
|
|
|
public boolean hasPermission(CommandSender sender)
|
|
{
|
|
return fromSender(sender).ordinal() >= ordinal();
|
|
}
|
|
|
|
public static CommandBlockerRank fromSender(CommandSender sender)
|
|
{
|
|
if (!(sender instanceof Player))
|
|
{
|
|
return TELNET;
|
|
}
|
|
|
|
Admin admin = TotalFreedomMod.plugin.al.getAdmin(sender);
|
|
if (admin != null)
|
|
{
|
|
if (admin.getRank() == PlayerRank.SENIOR_ADMIN)
|
|
{
|
|
return SENIOR;
|
|
}
|
|
return SUPER;
|
|
}
|
|
|
|
if (sender.isOp())
|
|
{
|
|
return OP;
|
|
}
|
|
|
|
return ANYONE;
|
|
|
|
}
|
|
|
|
public static CommandBlockerRank fromToken(String token)
|
|
{
|
|
for (CommandBlockerRank rank : CommandBlockerRank.values())
|
|
{
|
|
if (rank.getToken().equalsIgnoreCase(token))
|
|
{
|
|
return rank;
|
|
}
|
|
}
|
|
return ANYONE;
|
|
}
|
|
}
|