mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-11 13:33:54 +00:00
Eliminated the need to add commands to the plugin.yml file.
Now all command configuration is handled by annotations in the command classes themselves.
This commit is contained in:
@ -0,0 +1,14 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CommandParameters
|
||||
{
|
||||
String description();
|
||||
|
||||
String usage();
|
||||
|
||||
String aliases() default ""; // "alias1,alias2,alias3" - no spaces
|
||||
}
|
@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandParameters(description = "Close server to non-superadmins.", usage = "/<command> [on | off]")
|
||||
public class Command_adminmode extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Block all commands for a specific player.", usage = "/<command> <purge | <partialname>>", aliases = "blockcommands,blockcommand")
|
||||
public class Command_blockcmd extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -1,40 +0,0 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
public class Command_blockcommand extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Player p;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
|
||||
playerdata.setCommandsBlocked(!playerdata.allCommandsBlocked());
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + p.getName(), true);
|
||||
TFM_Util.playerMsg(sender, (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locked all commands.");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Place a cage around someone.", usage = "/<command> <partialname> <off | [[outermaterial] [innermaterial]]>")
|
||||
public class Command_cage extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "For the people that are still alive.", usage = "/<command>")
|
||||
public class Command_cake extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Sit in nearest minecart. If target is in a minecart already, they will disembark.", usage = "/<command> [partialname]")
|
||||
public class Command_cartsit extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Removes all entities, nicks and disguises.", usage = "/<command>")
|
||||
public class Command_clearall extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -13,6 +13,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Show all commands for all server plugins.", usage = "/<command>")
|
||||
public class Command_cmdlist extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Spy on commands", usage = "/<command>")
|
||||
public class Command_cmdspy extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -1,38 +0,0 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.util.Random;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
public class Command_cookie extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
StringBuilder output = new StringBuilder();
|
||||
Random randomGenerator = new Random();
|
||||
|
||||
String[] words = TotalFreedomMod.CAKE_LYRICS.replaceAll("cake", "cookies").split(" ");
|
||||
for (String word : words)
|
||||
{
|
||||
String color_code = Integer.toHexString(1 + randomGenerator.nextInt(14));
|
||||
output.append(ChatColor.COLOR_CHAR).append(color_code).append(word).append(" ");
|
||||
}
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
|
||||
p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem);
|
||||
}
|
||||
|
||||
TFM_Util.bcastMsg(output.toString());
|
||||
return true;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Quickly change your own gamemode to creative, or define someone's username to change theirs.", usage = "/<command> [partialname]")
|
||||
public class Command_creative extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "Telnet command - Send a chat message with chat formatting over telnet.", usage = "/<command> <message...>")
|
||||
public class Command_csay extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, block_host_console = true)
|
||||
@CommandParameters(description = "Make some noise.", usage = "/<command>")
|
||||
public class Command_deafen extends TFM_Command
|
||||
{
|
||||
private static final Random random = new Random();
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Deop a player.", usage = "/<command> <playername>")
|
||||
public class Command_deop extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Deop everyone on the server.", usage = "/<command>")
|
||||
public class Command_deopall extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Fill nearby dispensers with a set of items of your choice.", usage = "/<command> <radius> <comma,separated,items>")
|
||||
public class Command_dispfill extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "For the bad Superadmins.", usage = "/<command> <playername>")
|
||||
public class Command_doom extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Enchant items.", usage = "/<command> <list | addall | reset | add <name> | remove <name>>")
|
||||
public class Command_enchant extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Goto the ender / \"The End\".", usage = "/<command>")
|
||||
public class Command_ender extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Push people away from you.", usage = "/<command> [radius] [strength]")
|
||||
public class Command_expel extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Enable/disable explosives and set effect radius.", usage = "/<command> <on | off> [radius]")
|
||||
public class Command_explosives extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Enable/disable fire placement.", usage = "/<command> <on | off>")
|
||||
public class Command_fireplace extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Enable/disable fire spread.", usage = "/<command> <on | off>")
|
||||
public class Command_firespread extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Goto the flatlands.", usage = "/<command>")
|
||||
public class Command_flatlands extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Enable/disable fluid spread.", usage = "/<command> <on | off>")
|
||||
public class Command_fluidspread extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Freeze players (toggles on and off).", usage = "/<command> [target | purge]")
|
||||
public class Command_fr extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "You'll never even see it coming.", usage = "/<command>")
|
||||
public class Command_fuckoff extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -10,6 +10,9 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(
|
||||
description = "Use admin commands on someone by hash. Use mode 'list' to get a player's hash. Other modes are kick, nameban, ipban, ban, op, deop, ci",
|
||||
usage = "/<command> [list | [<kick | nameban | ipban | ban | op | deop | ci> <targethash>] ]")
|
||||
public class Command_gadmin extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Send a command as someone else.", usage = "/<command> <fromname> <outcommand>")
|
||||
public class Command_gcmd extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -13,6 +13,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Ban/Unban any player, even those who are not logged in anymore.", usage = "/<command> <purge | <ban | unban> <username>>")
|
||||
public class Command_glist extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Makes someone GTFO (deop and ip ban by username).", usage = "/<command> <partialname>")
|
||||
public class Command_gtfo extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Halts a player", usage = "/<command> <<partialname> | all | purge | list>")
|
||||
public class Command_halt extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "View ticks-per-second", usage = "/<command>")
|
||||
public class Command_health extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, block_host_console = true)
|
||||
@CommandParameters(description = "Kick all non-superadmins on server.", usage = "/<command>")
|
||||
public class Command_kicknoob extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Set a landmine trap.", usage = "/<command>")
|
||||
public class Command_landmine extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -1,13 +1,13 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Show the last command that someone used.", usage = "/<command> <player>")
|
||||
public class Command_lastcmd extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Enable/disable lava damage.", usage = "/<command> <on | off>")
|
||||
public class Command_lavadmg extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Enable/disable lava placement.", usage = "/<command> <on | off>")
|
||||
public class Command_lavaplace extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command>", aliases = "who")
|
||||
public class Command_list extends TFM_Command
|
||||
{
|
||||
private static enum ListFilter
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandParameters(description = "Download the superadmin and permban lists from the main TotalFreedom server.", usage = "/<command>")
|
||||
public class Command_listsync extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandParameters(description = "Block target's minecraft input. This is evil, and I never should have wrote it.", usage = "/<command> <all | purge | <<partialname> on | off>>")
|
||||
public class Command_lockup extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "Control mob rezzing parameters.", usage = "/<command> <on|off|setmax <count>|dragon|giant|ghast|slime>")
|
||||
public class Command_moblimiter extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Purge all mobs in all worlds.", usage = "/<command>")
|
||||
public class Command_mp extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Modern weaponry, FTW. Use 'draw' to start firing, 'sling' to stop firing.", usage = "/<command> <draw | sling>")
|
||||
public class Command_mp44 extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Goto the nether.", usage = "/<command>")
|
||||
public class Command_nether extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandParameters(description = "Attempt to detect \"invisible griefers\" and \"nukers\".", usage = "/<command> <on | off> [range] [blockrate]")
|
||||
public class Command_nonuke extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -8,6 +8,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(
|
||||
description = "AdminChat - Talk privately with other admins. Using <command> itself will toggle AdminChat on and off for all messages.",
|
||||
usage = "/<command> [message...]",
|
||||
aliases = "adminchat")
|
||||
public class Command_o extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandParameters(description = "Switch server online-mode on and off.", usage = "/<command> <on | off>")
|
||||
public class Command_onlinemode extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Makes a player operator", usage = "/<command> <playername>")
|
||||
public class Command_op extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Op everyone on the server, optionally change everyone's gamemode at the same time.", usage = "/<command> [-c | -s]")
|
||||
public class Command_opall extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Automatically ops user.", usage = "/<command>")
|
||||
public class Command_opme extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Manage operators", usage = "/<command> <count | list | purge>")
|
||||
public class Command_ops extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "POW!!! Right in the kisser! One of these days Alice, straight to the Moon!", usage = "/<command> <target> [power]")
|
||||
public class Command_orbit extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandParameters(description = "Manage permanently banned players and IPs.", usage = "/<command> <list | reload>")
|
||||
public class Command_permban extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Enable / disable plugins.", usage = "/<command> < <enable | disable> <pluginname> | list >")
|
||||
public class Command_plugincontrol extends TFM_Command
|
||||
{
|
||||
private enum CommandMode
|
||||
|
@ -14,6 +14,9 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(
|
||||
description = "Manipulate potion effects. Duration is measured in server ticks (~20 ticks per second).",
|
||||
usage = "/<command> <list | clear [target_name] | add <type> <duration> <amplifier> [target_name]>")
|
||||
public class Command_potion extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,9 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandParameters(
|
||||
description = "Enable/disable the command prelogger. When this is on, logs will be filled with many duplicate messages.",
|
||||
usage = "/<command> <on | off>")
|
||||
public class Command_prelog extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -8,6 +8,9 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(
|
||||
description = "Protect areas so that only superadmins can directly modify blocks in those areas. WorldEdit and other such plugins might bypass this.",
|
||||
usage = "/<command> <list | clear | remove <label> | add <label> <radius>>")
|
||||
public class Command_protectarea extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Quick De-Op - deop someone based on a partial name.", usage = "/<command> <partialname>")
|
||||
public class Command_qdeop extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Quick Op - op someone based on a partial name.", usage = "/<command> <partialname>")
|
||||
public class Command_qop extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Shows nearby people sorted by distance.", usage = "/<command> [range]")
|
||||
public class Command_radar extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows your rank.", usage = "/<command>")
|
||||
public class Command_rank extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandParameters(description = "Broadcasts the given message with no extra formatting.", usage = "/<command> <message>")
|
||||
public class Command_rawsay extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command> <carts>")
|
||||
public class Command_rd extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = false)
|
||||
@CommandParameters(description = "Remove all blocks of a certain type in the radius of certain players.", usage = "/<command> <block> [radius (default=50)] [player]")
|
||||
public class Command_ro extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Manage superadmins.", usage = "/<command> <list | clean | <add|delete|info> <username>>")
|
||||
public class Command_saconfig extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Broadcasts the given message as the console, includes sender name.", usage = "/<command> <message>")
|
||||
public class Command_say extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Sets your expierence level.", usage = "/<command> [level]")
|
||||
public class Command_setlevel extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Set world spawnpoint.", usage = "/<command>")
|
||||
public class Command_setspawnworld extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> [playername]")
|
||||
public class Command_smite extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -22,6 +22,7 @@ import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Show misc. server info.", usage = "/<command>")
|
||||
public class Command_status extends TFM_Command
|
||||
{
|
||||
public static final Map<String, String> SERVICE_MAP = new HashMap<String, String>();
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> [<player> | list | purge | all]", aliases = "mute")
|
||||
public class Command_stfu extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Kicks everyone and stops the server.", usage = "/<command>")
|
||||
public class Command_stop extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Quickly change your own gamemode to survival, or define someone's username to change theirs.", usage = "/<command> [partialname]")
|
||||
public class Command_survival extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Temporarily ban someone.", usage = "/<command> [playername] [duration] [reason]")
|
||||
public class Command_tempban extends TFM_Command
|
||||
{
|
||||
private static final SimpleDateFormat date_format = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||
|
@ -1,35 +0,0 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_RunSystemCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
public class Command_terminal extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
String command;
|
||||
try
|
||||
{
|
||||
StringBuilder command_bldr = new StringBuilder();
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
command_bldr.append(args[i]).append(" ");
|
||||
}
|
||||
command = command_bldr.toString().trim();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
playerMsg("Error building command: " + ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
playerMsg("Running system command: " + command);
|
||||
server.getScheduler().runTaskAsynchronously(plugin, new TFM_RunSystemCommand(command, plugin));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows all banned player names. Superadmins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
||||
public class Command_tfbanlist extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows all banned IPs. Superadmins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
||||
public class Command_tfipbanlist extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandParameters(description = "Update server files.", usage = "/<command>")
|
||||
public class Command_tfupdate extends TFM_Command
|
||||
{
|
||||
public static final String[] FILES =
|
||||
|
@ -13,6 +13,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Throw a mob in the direction you are facing when you left click with a stick.", usage = "/<command> <mobtype [speed] | off | list>")
|
||||
public class Command_tossmob extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Manage your twitter.", usage = "/<command> <set [twitter] | info | enable | disable>")
|
||||
public class Command_twitter extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Undisguises all players", usage = "/<command>")
|
||||
public class Command_uall extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Enable/disable water placement.", usage = "/<command> <on | off>")
|
||||
public class Command_waterplace extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Manage the whitelist.", usage = "/<command> <on | off | list | count | add <player> | remove <player> | addall | purge>")
|
||||
public class Command_whitelist extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Run any command on all users, username placeholder = ?.", usage = "/<command> [fluff] ? [fluff] ?")
|
||||
public class Command_wildcard extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandParameters(description = "Wipe the flatlands map. Requires manual restart after command is used.", usage = "/<command>")
|
||||
public class Command_wipeflatlands extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
|
@ -1,77 +0,0 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
public class Command_ziptool extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length <= 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("zip"))
|
||||
{
|
||||
File directory = new File("./" + args[1]);
|
||||
|
||||
if (!directory.isDirectory())
|
||||
{
|
||||
playerMsg(directory.getPath() + " is not a directory.");
|
||||
return true;
|
||||
}
|
||||
|
||||
File output = new File(directory.getParent() + "/" + directory.getName() + ".zip");
|
||||
|
||||
playerMsg("Zipping '" + directory.getPath() + "' to '" + output.getPath() + "'.");
|
||||
|
||||
try
|
||||
{
|
||||
TFM_Util.zip(directory, output, true, sender);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
|
||||
playerMsg("Zip finished.");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("unzip"))
|
||||
{
|
||||
File output = new File(args[1]);
|
||||
|
||||
if (!output.exists() || !output.isFile())
|
||||
{
|
||||
playerMsg(output.getPath() + " is not a file.");
|
||||
return true;
|
||||
}
|
||||
|
||||
playerMsg("Unzipping '" + output.getPath() + "'.");
|
||||
|
||||
try
|
||||
{
|
||||
TFM_Util.unzip(output, output.getParentFile());
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
|
||||
playerMsg("Unzip finished.");
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,227 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.CodeSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginIdentifiableCommand;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TFM_CommandLoader
|
||||
{
|
||||
public static Pattern COMMAND_CLASS_PATTERN = Pattern.compile(TotalFreedomMod.COMMAND_PATH.replace('.', '/') + "/(" + TotalFreedomMod.COMMAND_PREFIX + "[^\\$]+)\\.class");
|
||||
private List<TFM_CommandInfo> commandList = null;
|
||||
|
||||
private TFM_CommandLoader()
|
||||
{
|
||||
}
|
||||
|
||||
public void scan()
|
||||
{
|
||||
CommandMap commandMap = TFM_ServerInterface.getCommandMap();
|
||||
if (commandMap == null)
|
||||
{
|
||||
TFM_Log.severe("Error loading command map.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (commandList == null)
|
||||
{
|
||||
commandList = getCommands();
|
||||
}
|
||||
|
||||
for (TFM_CommandInfo commandInfo : commandList)
|
||||
{
|
||||
String description = commandInfo.getDescription();
|
||||
switch (commandInfo.getLevel())
|
||||
{
|
||||
case SENIOR:
|
||||
description = "Senior " + (commandInfo.getSource() == SourceType.ONLY_CONSOLE ? "Console" : "") + " Command - " + description;
|
||||
break;
|
||||
case SUPER:
|
||||
description = "Superadmin Command - " + description;
|
||||
break;
|
||||
case OP:
|
||||
description = "OP Command - " + description;
|
||||
break;
|
||||
}
|
||||
TFM_DynamicCommand dynamicCommand = new TFM_DynamicCommand(commandInfo.getCommandName(), description, commandInfo.getUsage(), commandInfo.getAliases());
|
||||
commandMap.register(TotalFreedomMod.plugin.getDescription().getName(), dynamicCommand);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<TFM_CommandInfo> getCommands()
|
||||
{
|
||||
List<TFM_CommandInfo> commandList = new ArrayList<TFM_CommandInfo>();
|
||||
|
||||
try
|
||||
{
|
||||
CodeSource codeSource = TotalFreedomMod.class.getProtectionDomain().getCodeSource();
|
||||
if (codeSource != null)
|
||||
{
|
||||
ZipInputStream zip = new ZipInputStream(codeSource.getLocation().openStream());
|
||||
ZipEntry zipEntry;
|
||||
while ((zipEntry = zip.getNextEntry()) != null)
|
||||
{
|
||||
String entryName = zipEntry.getName();
|
||||
Matcher matcher = COMMAND_CLASS_PATTERN.matcher(entryName);
|
||||
if (matcher.find())
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<?> commandClass = Class.forName(TotalFreedomMod.COMMAND_PATH + "." + matcher.group(1));
|
||||
|
||||
CommandPermissions commandPermissions = (CommandPermissions) commandClass.getAnnotation(CommandPermissions.class);
|
||||
CommandParameters commandParameters = (CommandParameters) commandClass.getAnnotation(CommandParameters.class);
|
||||
|
||||
if (commandPermissions != null && commandParameters != null)
|
||||
{
|
||||
TFM_CommandInfo commandInfo = new TFM_CommandInfo(
|
||||
commandClass,
|
||||
matcher.group(1).split("_")[1],
|
||||
commandPermissions.level(),
|
||||
commandPermissions.source(),
|
||||
commandPermissions.block_host_console(),
|
||||
commandParameters.description(),
|
||||
commandParameters.usage(),
|
||||
commandParameters.aliases());
|
||||
|
||||
commandList.add(commandInfo);
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
|
||||
return commandList;
|
||||
}
|
||||
|
||||
private static class TFM_CommandInfo
|
||||
{
|
||||
private final String commandName;
|
||||
private final Class<?> commandClass;
|
||||
private final AdminLevel level;
|
||||
private final SourceType source;
|
||||
private final boolean blockHostConsole;
|
||||
private final String description;
|
||||
private final String usage;
|
||||
private final List<String> aliases;
|
||||
|
||||
public TFM_CommandInfo(Class<?> commandClass, String commandName, AdminLevel level, SourceType source, boolean blockHostConsole, String description, String usage, String aliases)
|
||||
{
|
||||
this.commandName = commandName;
|
||||
this.commandClass = commandClass;
|
||||
this.level = level;
|
||||
this.source = source;
|
||||
this.blockHostConsole = blockHostConsole;
|
||||
this.description = description;
|
||||
this.usage = usage;
|
||||
this.aliases = Arrays.asList(aliases.split(","));
|
||||
}
|
||||
|
||||
public List<String> getAliases()
|
||||
{
|
||||
return aliases;
|
||||
}
|
||||
|
||||
public Class<?> getCommandClass()
|
||||
{
|
||||
return commandClass;
|
||||
}
|
||||
|
||||
public String getCommandName()
|
||||
{
|
||||
return commandName;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public AdminLevel getLevel()
|
||||
{
|
||||
return level;
|
||||
}
|
||||
|
||||
public SourceType getSource()
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
public String getUsage()
|
||||
{
|
||||
return usage;
|
||||
}
|
||||
|
||||
public boolean getBlockHostConsole()
|
||||
{
|
||||
return blockHostConsole;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("commandName: ").append(commandName);
|
||||
sb.append("\ncommandClass: ").append(commandClass.getName());
|
||||
sb.append("\nlevel: ").append(level);
|
||||
sb.append("\nsource: ").append(source);
|
||||
sb.append("\nblock_host_console: ").append(blockHostConsole);
|
||||
sb.append("\ndescription: ").append(description);
|
||||
sb.append("\nusage: ").append(usage);
|
||||
sb.append("\naliases: ").append(aliases);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private class TFM_DynamicCommand extends Command implements PluginIdentifiableCommand
|
||||
{
|
||||
public TFM_DynamicCommand(String commandName, String description, String usage, List<String> aliases)
|
||||
{
|
||||
super(commandName, description, usage, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String commandLabel, String[] args)
|
||||
{
|
||||
return getPlugin().onCommand(sender, this, commandLabel, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin getPlugin()
|
||||
{
|
||||
return TotalFreedomMod.plugin;
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_CommandLoader getInstance()
|
||||
{
|
||||
return TFM_CommandScannerHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_CommandScannerHolder
|
||||
{
|
||||
private static final TFM_CommandLoader INSTANCE = new TFM_CommandLoader();
|
||||
}
|
||||
}
|
@ -10,8 +10,10 @@ import net.minecraft.server.v1_5_R2.BanList;
|
||||
import net.minecraft.server.v1_5_R2.MinecraftServer;
|
||||
import net.minecraft.server.v1_5_R2.PlayerList;
|
||||
import net.minecraft.server.v1_5_R2.PropertyManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
|
||||
@ -119,6 +121,12 @@ public class TFM_ServerInterface
|
||||
return size;
|
||||
}
|
||||
|
||||
public static CommandMap getCommandMap()
|
||||
{
|
||||
CommandMap commandMap = TFM_Util.getField(Bukkit.getServer().getPluginManager(), "commandMap");
|
||||
return commandMap;
|
||||
}
|
||||
|
||||
public static void handlePlayerLogin(PlayerLoginEvent event)
|
||||
{
|
||||
// this should supersede all other onPlayerLogin authentication on the TFM server.
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
@ -984,4 +985,28 @@ public class TFM_Util
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
//getField: Borrowed from WorldEdit
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getField(Object from, String name)
|
||||
{
|
||||
Class<?> checkClass = from.getClass();
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
Field field = checkClass.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
return (T) field.get(from);
|
||||
}
|
||||
catch (NoSuchFieldException ex)
|
||||
{
|
||||
}
|
||||
catch (IllegalAccessException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||
import me.StevenLawson.TotalFreedomMod.Listener.TFM_BlockListener;
|
||||
import me.StevenLawson.TotalFreedomMod.Listener.TFM_EntityListener;
|
||||
import me.StevenLawson.TotalFreedomMod.Listener.TFM_PlayerListener;
|
||||
@ -103,6 +104,8 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
|
||||
server.getScheduler().scheduleSyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
|
||||
|
||||
TFM_CommandLoader.getInstance().scan();
|
||||
|
||||
// metrics @ http://mcstats.org/plugin/TotalFreedomMod
|
||||
try
|
||||
{
|
||||
|
Reference in New Issue
Block a user