mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-11 21:43:54 +00:00
removal of aero
This commit is contained in:
@ -1,45 +1,48 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import net.pravian.aero.command.handler.SimpleCommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CommandLoader extends FreedomService
|
||||
{
|
||||
|
||||
@Getter
|
||||
private final SimpleCommandHandler<TotalFreedomMod> handler;
|
||||
private final List<FreedomCommand> commands;
|
||||
|
||||
public CommandLoader(TotalFreedomMod plugin)
|
||||
public CommandLoader()
|
||||
{
|
||||
super(plugin);
|
||||
|
||||
handler = new SimpleCommandHandler<>(plugin);
|
||||
commands = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
public void onStart()
|
||||
{
|
||||
handler.clearCommands();
|
||||
handler.setExecutorFactory(new FreedomCommandExecutor.FreedomExecutorFactory(plugin));
|
||||
handler.setCommandClassPrefix("Command_");
|
||||
handler.setPermissionMessage(ChatColor.RED + "You do not have permission to use this command.");
|
||||
handler.setOnlyConsoleMessage(ChatColor.RED + "This command can only be used from the console.");
|
||||
handler.setOnlyPlayerMessage(ChatColor.RED + "This command can only be used by players.");
|
||||
|
||||
handler.loadFrom(FreedomCommand.class.getPackage());
|
||||
handler.registerAll(plugin.getDescription().getName(), true);
|
||||
|
||||
FLog.info("Loaded " + handler.getExecutors().size() + " commands.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
public void onStop()
|
||||
{
|
||||
handler.clearCommands();
|
||||
}
|
||||
|
||||
public void add(FreedomCommand command)
|
||||
{
|
||||
commands.add(command);
|
||||
command.register();
|
||||
}
|
||||
|
||||
public FreedomCommand getByName(String name)
|
||||
{
|
||||
for (FreedomCommand command : commands)
|
||||
{
|
||||
if (name.equals(command.getName()))
|
||||
return command;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getCommandAmount()
|
||||
{
|
||||
return commands.size();
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ public class Command_announce extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -82,7 +81,7 @@ public class Command_ban extends FreedomCommand
|
||||
final PlayerData entry = plugin.pl.getData(player);
|
||||
username = player.getName();
|
||||
//ips.addAll(entry.getIps());/
|
||||
ips.add(Ips.getIp(player));
|
||||
ips.add(FUtil.getIp(player));
|
||||
|
||||
// Deop
|
||||
player.setOp(false);
|
||||
@ -152,7 +151,7 @@ public class Command_ban extends FreedomCommand
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (Ips.getIp(p).equals(Ips.getIp(player)))
|
||||
if (FUtil.getIp(p).equals(FUtil.getIp(player)))
|
||||
{
|
||||
p.kickPlayer(ChatColor.RED + "You've been kicked because someone on your IP has been banned.");
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class Command_clearinventory extends FreedomCommand
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (args.length == 1 && plugin.al.isAdmin(playerSender))
|
||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||
{
|
||||
List<String> players = FUtil.getPlayerList();
|
||||
players.add("-a");
|
||||
|
@ -7,8 +7,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -100,7 +98,7 @@ public class Command_doom extends FreedomCommand
|
||||
final String kickReason = (reason == null ? "FUCKOFF, and get your shit together!" : reason);
|
||||
|
||||
// Log doom
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.DOOM, reason));
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.DOOM, reason));
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
|
@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -16,7 +15,7 @@ import org.bukkit.entity.Player;
|
||||
public class Command_kick extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
@ -53,7 +52,7 @@ public class Command_kick extends FreedomCommand
|
||||
|
||||
player.kickPlayer(builder.toString());
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.KICK, reason));
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.KICK, reason));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import org.bukkit.entity.Player;
|
||||
public class Command_links extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
YamlConfiguration config = plugin.config.configuration;
|
||||
ConfigurationSection section = config.getConfigurationSection("social_links");
|
||||
|
@ -7,7 +7,6 @@ import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "seth's personal command", usage = "/<command> <players>")
|
||||
@CommandParameters(description = "seth's personal command", usage = "/<command> <players>", aliases = "genocide")
|
||||
public class Command_massmurder extends FreedomCommand
|
||||
{
|
||||
|
||||
|
@ -9,7 +9,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -153,7 +152,7 @@ public class Command_mute extends FreedomCommand
|
||||
msg(player, "You have been muted by " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
|
||||
msg("Muted " + player.getName());
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.MUTE, reason));
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.MUTE, reason));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -9,7 +9,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -22,7 +21,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@ -60,7 +59,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
}
|
||||
}
|
||||
|
||||
final String targetIp = Ips.getIp(targetPlayer);
|
||||
final String targetIp = FUtil.getIp(targetPlayer);
|
||||
|
||||
switch (args[0])
|
||||
{
|
||||
@ -285,7 +284,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
if (args[0].equals("clearip"))
|
||||
{
|
||||
List<String> ips = plugin.al.getAdmin(sender).getIps();
|
||||
ips.remove(Ips.getIp(playerSender));
|
||||
ips.remove(FUtil.getIp((Player) sender));
|
||||
return ips;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ public class Command_permban extends FreedomCommand
|
||||
}
|
||||
|
||||
msg("Reloading permban list...", ChatColor.RED);
|
||||
plugin.pm.stop();
|
||||
plugin.pm.start();
|
||||
plugin.pm.onStop();
|
||||
plugin.pm.onStart();
|
||||
msg("Reloaded permban list.");
|
||||
msg(plugin.pm.getPermbannedIps().size() + " IPs and "
|
||||
+ plugin.pm.getPermbannedNames().size() + " usernames loaded.");
|
||||
|
@ -6,7 +6,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -17,7 +17,7 @@ import org.bukkit.entity.Player;
|
||||
public class Command_playerverification extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
PlayerData target = plugin.pl.getData(playerSender);
|
||||
|
||||
@ -31,14 +31,14 @@ public class Command_playerverification extends FreedomCommand
|
||||
int cleared = 0;
|
||||
for (String ip : ips)
|
||||
{
|
||||
if (!ip.equals(Ips.getIp(playerSender)))
|
||||
if (!ip.equals(FUtil.getIp(playerSender)))
|
||||
{
|
||||
target.removeIp(ip);
|
||||
cleared++;
|
||||
}
|
||||
}
|
||||
|
||||
msg("Cleared all IP's except your current IP \"" + Ips.getIp(playerSender) + "\"");
|
||||
msg("Cleared all IP's except your current IP \"" + FUtil.getIp(playerSender) + "\"");
|
||||
msg("Cleared " + cleared + " IP's.");
|
||||
plugin.pl.save(target);
|
||||
plugin.pl.syncIps(target);
|
||||
|
@ -106,12 +106,6 @@ public class Command_ride extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player.getName().equals("Catholic_Mario"))
|
||||
{
|
||||
msg("no", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerData.getRideMode().equals("ask") && !FUtil.isExecutive(playerSender.getName()))
|
||||
{
|
||||
msg("Sent a request to the player.", ChatColor.GREEN);
|
||||
@ -120,7 +114,7 @@ public class Command_ride extends FreedomCommand
|
||||
player.sendMessage(ChatColor.AQUA + "Type " + ChatColor.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission.");
|
||||
player.sendMessage(ChatColor.AQUA + "Request will expire after 30 seconds.");
|
||||
RIDE_REQUESTS.put(player, playerSender);
|
||||
FreedomCommandExecutor.timer.schedule(new TimerTask()
|
||||
timer.schedule(new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
|
@ -10,7 +10,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -175,7 +174,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
Admin admin = null;
|
||||
for (Admin loopAdmin : plugin.al.getAllAdmins())
|
||||
{
|
||||
if (loopAdmin.getName().equalsIgnoreCase(name) || loopAdmin.getIps().contains(Ips.getIp(player)))
|
||||
if (loopAdmin.getName().equalsIgnoreCase(name) || loopAdmin.getIps().contains(FUtil.getIp(player)))
|
||||
{
|
||||
admin = loopAdmin;
|
||||
break;
|
||||
@ -212,7 +211,7 @@ public class Command_saconfig extends FreedomCommand
|
||||
if (oldName != player.getName())
|
||||
admin.setName(player.getName());
|
||||
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||
admin.addIp(Ips.getIp(player));
|
||||
admin.addIp(FUtil.getIp(player));
|
||||
}
|
||||
|
||||
admin.setActive(true);
|
||||
|
@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -60,7 +59,7 @@ public class Command_smite extends FreedomCommand
|
||||
|
||||
smite(sender, player, reason, silent);
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.SMITE, reason));
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.SMITE, reason));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class Command_spawnmob extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
|
@ -10,7 +10,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Location;
|
||||
@ -97,7 +96,7 @@ public class Command_tempban extends FreedomCommand
|
||||
plugin.bm.addBan(ban);
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
@ -34,8 +35,11 @@ public class Command_totalfreedommod extends FreedomCommand
|
||||
}
|
||||
|
||||
plugin.config.load();
|
||||
plugin.services.stop();
|
||||
plugin.services.start();
|
||||
for (FreedomService service : plugin.fsh.getServices())
|
||||
{
|
||||
service.onStop();
|
||||
service.onStart();
|
||||
}
|
||||
|
||||
final String message = String.format("%s v%s reloaded.",
|
||||
TotalFreedomMod.pluginName,
|
||||
|
@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -50,7 +49,7 @@ public class Command_verify extends FreedomCommand
|
||||
{
|
||||
String code = plugin.dc.generateCode(10);
|
||||
plugin.dc.addVerificationCode(code, playerData);
|
||||
plugin.dc.bot.getUserById(discordId).openPrivateChannel().complete().sendMessage("A user with the IP `" + Ips.getIp(playerSender) + "` has sent a verification request. Please run the following in-game command: `/verify " + code + "`").complete();
|
||||
plugin.dc.bot.getUserById(discordId).openPrivateChannel().complete().sendMessage("A user with the IP `" + FUtil.getIp(playerSender) + "` has sent a verification request. Please run the following in-game command: `/verify " + code + "`").complete();
|
||||
msg("A verification code has been sent to your account, please copy the code and run /verify <code>", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.Ips;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -39,7 +38,7 @@ public class Command_verifynoadmin extends FreedomCommand
|
||||
{
|
||||
plugin.al.verifiedNoAdmins.add(player.getName());
|
||||
}
|
||||
String ip = Ips.getIp(player);
|
||||
String ip = FUtil.getIp(player);
|
||||
if (!plugin.al.verifiedNoAdminIps.containsKey(player.getName()))
|
||||
{
|
||||
List<String> ips = new ArrayList<>();
|
||||
|
@ -30,17 +30,20 @@ public class Command_wildcard extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
Command runCmd = server.getPluginCommand(args[0]);
|
||||
if (runCmd == null)
|
||||
FreedomCommand command = plugin.cl.getByName(args[0]);
|
||||
if (command == null)
|
||||
{
|
||||
msg("Unknown command: " + args[0], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (BLOCKED_COMMANDS.contains(runCmd.getName()))
|
||||
for (String blockedCommand : BLOCKED_COMMANDS)
|
||||
{
|
||||
msg("Did you really think that was going to work?", ChatColor.RED);
|
||||
return true;
|
||||
if (blockedCommand.equals(command.getName()) || command.getAliases().contains(blockedCommand))
|
||||
{
|
||||
msg("Did you really think that was going to work?", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
String baseCommand = StringUtils.join(args, " ");
|
||||
|
@ -1,7 +1,13 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
@ -9,90 +15,225 @@ import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.command.AbstractCommandBase;
|
||||
import net.pravian.aero.util.Players;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.spigotmc.SpigotConfig;
|
||||
|
||||
public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod>
|
||||
public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
{
|
||||
public static final String COMMAND_PREFIX = "Command_";
|
||||
|
||||
@Getter
|
||||
private static CommandMap commandMap;
|
||||
@Getter
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String usage;
|
||||
@Getter
|
||||
private final String aliases;
|
||||
private final Rank level;
|
||||
private final SourceType source;
|
||||
private final boolean blockHostConsole;
|
||||
private final int cooldown;
|
||||
private final CommandParameters params;
|
||||
@Getter
|
||||
private final CommandPermissions perms;
|
||||
|
||||
protected CommandSender sender;
|
||||
|
||||
protected final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
|
||||
protected final Server server = plugin.getServer();
|
||||
|
||||
public static final String UNKNOWN_COMMAND = ChatColor.WHITE + SpigotConfig.unknownCommandMessage;
|
||||
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
|
||||
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
||||
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
|
||||
//
|
||||
@Getter
|
||||
private final CommandParameters params;
|
||||
@Getter
|
||||
private final CommandPermissions perms;
|
||||
//
|
||||
public static final String ONLY_CONSOLE = ChatColor.RED + "Only console senders may execute this command!";
|
||||
public static final String ONLY_IN_GAME = ChatColor.RED + "Only in-game players may execute this command!";
|
||||
public static final String NO_PERMISSION = ChatColor.RED + "You do not have permission to execute this command.";
|
||||
|
||||
public FreedomCommand()
|
||||
public static final Timer timer = new Timer();
|
||||
public static final Map<CommandSender, FreedomCommand> COOLDOWN_TIMERS = new HashMap<>();
|
||||
|
||||
FreedomCommand()
|
||||
{
|
||||
this.params = getClass().getAnnotation(CommandParameters.class);
|
||||
if (params == null)
|
||||
{
|
||||
FLog.warning("Ignoring command usage for command " + getClass().getSimpleName() + ". Command is not annotated!");
|
||||
}
|
||||
|
||||
this.perms = getClass().getAnnotation(CommandPermissions.class);
|
||||
if (perms == null)
|
||||
{
|
||||
FLog.warning("Ignoring permissions for command " + getClass().getSimpleName() + ". Command is not annotated!");
|
||||
}
|
||||
params = getClass().getAnnotation(CommandParameters.class);
|
||||
perms = getClass().getAnnotation(CommandPermissions.class);
|
||||
this.name = getClass().getSimpleName().replace(COMMAND_PREFIX, "").toLowerCase();
|
||||
this.description = params.description();
|
||||
this.usage = params.usage();
|
||||
this.aliases = params.aliases();
|
||||
this.level = perms.level();
|
||||
this.source = perms.source();
|
||||
this.blockHostConsole = perms.blockHostConsole();
|
||||
this.cooldown = perms.cooldown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean runCommand(final CommandSender sender, final Command command, final String label, final String[] args)
|
||||
public void register()
|
||||
{
|
||||
setVariables(sender, command, label, args);
|
||||
|
||||
try
|
||||
{
|
||||
return run(sender, playerSender, command, label, args, isConsole());
|
||||
}
|
||||
catch (CommandFailException ex)
|
||||
{
|
||||
msg(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLog.severe("Uncaught exception executing command: " + command.getName());
|
||||
FLog.severe(ex);
|
||||
sender.sendMessage(ChatColor.RED + "Command error: " + (ex.getMessage() == null ? "Unknown cause" : ex.getMessage()));
|
||||
return true;
|
||||
}
|
||||
FCommand cmd = new FCommand(this.name);
|
||||
if (this.aliases != null) cmd.setAliases(Arrays.asList(StringUtils.split(this.aliases, ",")));
|
||||
if (this.description != null) cmd.setDescription(this.description);
|
||||
if (this.usage != null) cmd.setUsage(this.usage);
|
||||
getCommandMap().register("", cmd);
|
||||
cmd.setExecutor(this);
|
||||
}
|
||||
|
||||
protected List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return null;
|
||||
public static final CommandMap getCommandMap()
|
||||
{
|
||||
if (commandMap == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Field f = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||
f.setAccessible(true);
|
||||
commandMap = (CommandMap) f.get(Bukkit.getServer());
|
||||
return getCommandMap();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else if (commandMap != null)
|
||||
{
|
||||
return commandMap;
|
||||
}
|
||||
return getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, Command command, String alias, String[] args)
|
||||
private final class FCommand extends Command
|
||||
{
|
||||
List<String> options = getTabCompleteOptions(sender, command, alias, args);
|
||||
if (options == null)
|
||||
private FreedomCommand cmd = null;
|
||||
private FCommand(String command)
|
||||
{
|
||||
super(command);
|
||||
}
|
||||
public void setExecutor(FreedomCommand cmd)
|
||||
{
|
||||
this.cmd = cmd;
|
||||
}
|
||||
|
||||
public boolean execute(CommandSender sender, String commandLabel, String[] args)
|
||||
{
|
||||
if (cmd != null)
|
||||
{
|
||||
cmd.sender = sender;
|
||||
|
||||
if (COOLDOWN_TIMERS.containsKey(sender) && COOLDOWN_TIMERS.containsValue(cmd))
|
||||
{
|
||||
msg(ChatColor.RED + "You are on cooldown for this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.blockHostConsole() && FUtil.isFromHostConsole(sender.getName()))
|
||||
{
|
||||
msg(ChatColor.RED + "Host console is not allowed to use this command!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.rm.getRank(sender).isAtLeast(perms.level()))
|
||||
{
|
||||
msg(NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.source() == SourceType.ONLY_CONSOLE && sender instanceof Player)
|
||||
{
|
||||
msg(ONLY_CONSOLE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.source() == SourceType.ONLY_IN_GAME && sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
msg(ONLY_IN_GAME);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (perms.cooldown() != 0 && !isAdmin(sender))
|
||||
{
|
||||
COOLDOWN_TIMERS.put(sender, cmd);
|
||||
timer.schedule(new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
COOLDOWN_TIMERS.remove(sender);
|
||||
}
|
||||
}, perms.cooldown() * 1000);
|
||||
}
|
||||
return cmd.onCommand(sender, this, commandLabel, args);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args)
|
||||
{
|
||||
if (cmd != null)
|
||||
{
|
||||
return cmd.onTabComplete(sender, this, alias, args);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.<String>newArrayList());
|
||||
}
|
||||
|
||||
protected abstract boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole);
|
||||
protected void msg(CommandSender sender, String message)
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + message);
|
||||
}
|
||||
|
||||
protected void msg(Player player, String message)
|
||||
{
|
||||
player.sendMessage(ChatColor.GRAY + message);
|
||||
}
|
||||
|
||||
protected void msg(Player player, String message, ChatColor color)
|
||||
{
|
||||
player.sendMessage(color + message);
|
||||
}
|
||||
|
||||
protected void msg(String message)
|
||||
{
|
||||
msg(sender, message);
|
||||
}
|
||||
|
||||
protected void msg(String message, ChatColor color)
|
||||
{
|
||||
msg(color + message);
|
||||
}
|
||||
|
||||
protected void msg(String message, net.md_5.bungee.api.ChatColor color)
|
||||
{
|
||||
msg(color + message);
|
||||
}
|
||||
|
||||
protected boolean isAdmin(Player player)
|
||||
{
|
||||
return plugin.al.isAdmin(player);
|
||||
}
|
||||
|
||||
protected boolean isAdmin(CommandSender sender)
|
||||
{
|
||||
return plugin.al.isAdmin(sender);
|
||||
}
|
||||
|
||||
protected void checkConsole()
|
||||
{
|
||||
if (!isConsole())
|
||||
{
|
||||
throw new CommandFailException(getHandler().getOnlyConsoleMessage());
|
||||
throw new CommandFailException(ONLY_CONSOLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,15 +241,7 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
|
||||
{
|
||||
if (isConsole())
|
||||
{
|
||||
throw new CommandFailException(getHandler().getOnlyPlayerMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkNotHostConsole()
|
||||
{
|
||||
if (isConsole() && FUtil.isFromHostConsole(sender.getName()))
|
||||
{
|
||||
throw new CommandFailException("This command can not be used from the host console.");
|
||||
throw new CommandFailException(ONLY_IN_GAME);
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,72 +253,67 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean noPerms()
|
||||
protected void checkNotHostConsole()
|
||||
{
|
||||
throw new CommandFailException(getHandler().getPermissionMessage());
|
||||
if (isConsole() && FUtil.isFromHostConsole(sender.getName()))
|
||||
{
|
||||
throw new CommandFailException("This command can not be used from the host console.");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
boolean run = run(sender, sender instanceof ConsoleCommandSender ? null : (Player) sender, cmd, commandLabel, args, sender instanceof ConsoleCommandSender);
|
||||
if (!run)
|
||||
{
|
||||
msg(ChatColor.WHITE + cmd.getUsage().replace("<command>", cmd.getLabel()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (CommandFailException ex)
|
||||
{
|
||||
msg(ChatColor.RED + ex.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
List<String> options = getTabCompleteOptions(sender, command, alias, args);
|
||||
if (options == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.newArrayList());
|
||||
}
|
||||
|
||||
public abstract boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole);
|
||||
|
||||
protected List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean isConsole()
|
||||
{
|
||||
return !(sender instanceof Player);
|
||||
return sender instanceof ConsoleCommandSender;
|
||||
}
|
||||
|
||||
protected Player getPlayer(String name)
|
||||
{
|
||||
return Players.getPlayer(name);
|
||||
return Bukkit.getPlayer(name);
|
||||
}
|
||||
|
||||
protected Player getPlayer(String name, Boolean nullVanished)
|
||||
{
|
||||
Player player = Players.getPlayer(name);
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
if (nullVanished && plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return Players.getPlayer(name);
|
||||
}
|
||||
|
||||
protected void msg(final CommandSender sender, final String message, final ChatColor color)
|
||||
{
|
||||
if (sender == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(color + message);
|
||||
}
|
||||
|
||||
protected void msg(final CommandSender sender, final String message, final net.md_5.bungee.api.ChatColor color)
|
||||
{
|
||||
if (sender == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(color + message);
|
||||
}
|
||||
|
||||
protected void msg(final String message, final net.md_5.bungee.api.ChatColor color)
|
||||
{
|
||||
msg(sender, message, color);
|
||||
}
|
||||
|
||||
protected void msg(final String message, final ChatColor color)
|
||||
{
|
||||
msg(sender, message, color);
|
||||
}
|
||||
|
||||
protected void msg(final CommandSender sender, final String message)
|
||||
{
|
||||
msg(sender, message, ChatColor.GRAY);
|
||||
}
|
||||
|
||||
protected void msg(final String message)
|
||||
{
|
||||
msg(sender, message);
|
||||
}
|
||||
|
||||
protected boolean isAdmin(CommandSender sender)
|
||||
{
|
||||
return plugin.al.isAdmin(sender);
|
||||
return player;
|
||||
}
|
||||
|
||||
protected Admin getAdmin(CommandSender sender)
|
||||
@ -203,12 +331,16 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
|
||||
return plugin.pl.getData(player);
|
||||
}
|
||||
|
||||
protected boolean noPerms()
|
||||
{
|
||||
throw new CommandFailException(NO_PERMISSION);
|
||||
}
|
||||
|
||||
public static FreedomCommand getFrom(Command command)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (FreedomCommand)((FreedomCommandExecutor)(((PluginCommand)command).getExecutor())).getCommandBase();
|
||||
return (FreedomCommand) (((PluginCommand) command).getExecutor());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,221 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.command.AeroCommandBase;
|
||||
import net.pravian.aero.command.executor.AbstractCommandExecutor;
|
||||
import net.pravian.aero.command.executor.AeroCommandExecutor;
|
||||
import net.pravian.aero.command.executor.AeroCommandExecutorFactory;
|
||||
import net.pravian.aero.command.handler.AeroCommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FreedomCommandExecutor<C extends AeroCommandBase<?>> extends AbstractCommandExecutor<C>
|
||||
{
|
||||
|
||||
private final TotalFreedomMod plugin;
|
||||
//
|
||||
public static Map<CommandSender, FreedomCommand> commandCooldown = new HashMap<>();
|
||||
public static final Timer timer = new Timer();
|
||||
|
||||
public FreedomCommandExecutor(TotalFreedomMod plugin, AeroCommandHandler<?> handler, String name, C command)
|
||||
{
|
||||
super(handler, name, command);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
protected FreedomCommand getCommand()
|
||||
{
|
||||
return commandBase instanceof FreedomCommand ? (FreedomCommand)commandBase : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupCommand(PluginCommand pluginCommand)
|
||||
{
|
||||
final FreedomCommand command = getCommand();
|
||||
if (command == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final CommandParameters params = command.getParams();
|
||||
if (params == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String aliasString = params.aliases();
|
||||
|
||||
if (aliasString.length() > 0)
|
||||
{
|
||||
pluginCommand.setAliases(Arrays.asList(params.aliases().split(",")));
|
||||
}
|
||||
pluginCommand.setDescription(params.description());
|
||||
pluginCommand.setUsage(params.usage());
|
||||
|
||||
// Check if permisions are correctly set up
|
||||
CommandPermissions perms = command.getPerms();
|
||||
if (perms != null)
|
||||
{
|
||||
if (perms.level().isConsole())
|
||||
{
|
||||
FLog.warning("[Command] " + pluginCommand.getName() + " - permission is set to a console rank, "
|
||||
+ "should be set to player variant with 'source = SourceType.ONLY_CONSOLE'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (!hasPermission(sender, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isOnCooldown(sender))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
boolean run = commandBase.runCommand(sender, command, label, args);
|
||||
FreedomCommand c = getCommand();
|
||||
CommandPermissions perms = c.getPerms();
|
||||
if (perms.cooldown() > 0 && !plugin.al.isAdmin(sender))
|
||||
{
|
||||
commandCooldown.put(sender, c);
|
||||
timer.schedule(new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
commandCooldown.remove(sender);
|
||||
}
|
||||
}, perms.cooldown() * 1000);
|
||||
}
|
||||
return run;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// If this is ever ran, TFM failed :
|
||||
FLog.severe("Unhandled command exception: " + command.getName());
|
||||
FLog.severe(ex);
|
||||
sender.sendMessage(ChatColor.RED + "Unhandled Command Error: " + command.getName());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender, boolean sendMsg)
|
||||
{
|
||||
final FreedomCommand command = getCommand();
|
||||
if (command == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
final CommandPermissions perms = command.getPerms();
|
||||
if (perms == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Block host console
|
||||
if (FUtil.isFromHostConsole(sender.getName())
|
||||
&& perms.blockHostConsole())
|
||||
{
|
||||
if (sendMsg)
|
||||
{
|
||||
sender.sendMessage(handler.getPermissionMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = sender instanceof Player ? (Player)sender : null;
|
||||
|
||||
// Only console
|
||||
if (perms.source() == SourceType.ONLY_CONSOLE
|
||||
&& player != null)
|
||||
{
|
||||
if (sendMsg)
|
||||
{
|
||||
sender.sendMessage(handler.getOnlyConsoleMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only in game
|
||||
if (perms.source() == SourceType.ONLY_IN_GAME
|
||||
&& player == null)
|
||||
{
|
||||
if (sendMsg)
|
||||
{
|
||||
sender.sendMessage(handler.getOnlyPlayerMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Player permissions
|
||||
if (player != null)
|
||||
{
|
||||
Rank rank = plugin.rm.getRank(player);
|
||||
boolean result = rank.isAtLeast(perms.level());
|
||||
if (!result && sendMsg)
|
||||
{
|
||||
sender.sendMessage(handler.getPermissionMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Console permissions
|
||||
Rank rank = plugin.rm.getRank(sender);
|
||||
boolean result = rank.isAtLeast(perms.level());
|
||||
if (!result && sendMsg)
|
||||
{
|
||||
sender.sendMessage(handler.getPermissionMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isOnCooldown(CommandSender sender)
|
||||
{
|
||||
final FreedomCommand command = getCommand();
|
||||
if (commandCooldown.containsKey(sender) && commandCooldown.containsValue(command))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You're on cooldown for this command.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class FreedomExecutorFactory implements AeroCommandExecutorFactory
|
||||
{
|
||||
|
||||
private final TotalFreedomMod plugin;
|
||||
|
||||
public FreedomExecutorFactory(TotalFreedomMod plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AeroCommandExecutor<? extends AeroCommandBase<?>> newExecutor(AeroCommandHandler<?> handler, String name, AeroCommandBase<?> command)
|
||||
{
|
||||
return new FreedomCommandExecutor<>(plugin, handler, name, command);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user