1
0
mirror of https://e.coding.net/circlecloud/Residence.git synced 2025-11-26 22:06:07 +00:00

remove static class...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092
2015-09-24 18:11:35 +08:00
parent 6b0f5ac789
commit 1cffbc7687
48 changed files with 4273 additions and 5120 deletions

View File

@@ -14,34 +14,38 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandRc extends BaseCommand {
Residence plugin;
public CommandRc(Residence plugin) {
public CommandRc(final Residence plugin) {
super("rc");
this.plugin = plugin;
setOnlyPlayerExecutable(true);
}
@Override
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
String pname = sender.getName();
if (Residence.getConfigManager().chatEnabled()) {
if (args.length == 0)
Residence.getPlayerListener().tooglePlayerResidenceChat((Player) sender);
else {
String area = Residence.getPlayerListener().getCurrentResidenceName(pname);
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
final String pname = sender.getName();
if (plugin.getConfigManager().chatEnabled()) {
if (args.length == 0) {
plugin.getPlayerListener().tooglePlayerResidenceChat((Player) sender);
} else {
final String area = plugin.getPlayerListener().getCurrentResidenceName(pname);
if (area != null) {
ChatChannel channel = Residence.getChatManager().getChannel(area);
final ChatChannel channel = plugin.getChatManager().getChannel(area);
if (channel != null) {
String message = "";
for (String arg : args)
for (final String arg : args) {
message = message + " " + arg;
}
channel.chat(pname, message);
} else
sender.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("InvalidChannel"));
} else
sender.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NotInResidence"));
} else {
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidChannel"));
}
} else {
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotInResidence"));
}
}
} else
sender.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("ChatDisabled"));
} else {
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ChatDisabled"));
}
}
}

View File

@@ -7,79 +7,155 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.commandsub.CommandArea;
import com.bekvon.bukkit.residence.commandsub.CommandBank;
import com.bekvon.bukkit.residence.commandsub.CommandCheck;
import com.bekvon.bukkit.residence.commandsub.CommandClearFlags;
import com.bekvon.bukkit.residence.commandsub.CommandCompass;
import com.bekvon.bukkit.residence.commandsub.CommandConfirm;
import com.bekvon.bukkit.residence.commandsub.CommandCreate;
import com.bekvon.bukkit.residence.commandsub.CommandCurrent;
import com.bekvon.bukkit.residence.commandsub.CommandDefault;
import com.bekvon.bukkit.residence.commandsub.CommandGive;
import com.bekvon.bukkit.residence.commandsub.CommandGset;
import com.bekvon.bukkit.residence.commandsub.CommandInfo;
import com.bekvon.bukkit.residence.commandsub.CommandKick;
import com.bekvon.bukkit.residence.commandsub.CommandLease;
import com.bekvon.bukkit.residence.commandsub.CommandLimits;
import com.bekvon.bukkit.residence.commandsub.CommandList;
import com.bekvon.bukkit.residence.commandsub.CommandListAll;
import com.bekvon.bukkit.residence.commandsub.CommandListAllHidden;
import com.bekvon.bukkit.residence.commandsub.CommandListHidden;
import com.bekvon.bukkit.residence.commandsub.CommandLists;
import com.bekvon.bukkit.residence.commandsub.CommandLset;
import com.bekvon.bukkit.residence.commandsub.CommandMarket;
import com.bekvon.bukkit.residence.commandsub.CommandMaterial;
import com.bekvon.bukkit.residence.commandsub.CommandMessage;
import com.bekvon.bukkit.residence.commandsub.CommandMirror;
import com.bekvon.bukkit.residence.commandsub.CommandPset;
import com.bekvon.bukkit.residence.commandsub.CommandRemove;
import com.bekvon.bukkit.residence.commandsub.CommandRemoveAll;
import com.bekvon.bukkit.residence.commandsub.CommandRename;
import com.bekvon.bukkit.residence.commandsub.CommandRenameArea;
import com.bekvon.bukkit.residence.commandsub.CommandSelect;
import com.bekvon.bukkit.residence.commandsub.CommandServer;
import com.bekvon.bukkit.residence.commandsub.CommandSet;
import com.bekvon.bukkit.residence.commandsub.CommandSetOwner;
import com.bekvon.bukkit.residence.commandsub.CommandSubList;
import com.bekvon.bukkit.residence.commandsub.CommandSubZone;
import com.bekvon.bukkit.residence.commandsub.CommandTool;
import com.bekvon.bukkit.residence.commandsub.CommandTp;
import com.bekvon.bukkit.residence.commandsub.CommandTpSet;
import com.bekvon.bukkit.residence.commandsub.CommandUnStuck;
import com.bekvon.bukkit.residence.commandsub.CommandVersion;
import cn.citycraft.PluginHelper.commands.BaseCommand;
import cn.citycraft.PluginHelper.commands.HandlerSubCommand;
public class CommandRes extends BaseCommand {
Residence plugin;
HandlerSubCommand hdsubcmd;
public CommandRes(Residence plugin) {
Residence plugin;
public CommandRes(final Residence plugin) {
super("res", "residence", "resadmin");
this.plugin = plugin;
hdsubcmd = new HandlerSubCommand(plugin);
hdsubcmd.registerCommand(new CommandConfirm(plugin));
hdsubcmd.registerCommand(new CommandRemove(plugin));
hdsubcmd.registerCommand(new CommandVersion(plugin));
hdsubcmd.registerCommand(new CommandSetOwner(plugin));
// Player player = null;
// boolean resadmin = (command != null);
// ResidenceManager rmanager = Residence.getResidenceManager();
// Map<String, String> deleteConfirm = plugin.deleteConfirm;
// Language language = Residence.getLanguage();
hdsubcmd.registerCommand(new CommandArea(plugin));
hdsubcmd.registerCommand(new CommandBank(plugin));
hdsubcmd.registerCommand(new CommandCheck(plugin));
hdsubcmd.registerCommand(new CommandClearFlags(plugin));
hdsubcmd.registerCommand(new CommandCompass(plugin));
hdsubcmd.registerCommand(new CommandConfirm(plugin));
hdsubcmd.registerCommand(new CommandCreate(plugin));
hdsubcmd.registerCommand(new CommandCurrent(plugin));
hdsubcmd.registerCommand(new CommandDefault(plugin));
hdsubcmd.registerCommand(new CommandGive(plugin));
hdsubcmd.registerCommand(new CommandGset(plugin));
hdsubcmd.registerCommand(new CommandInfo(plugin));
hdsubcmd.registerCommand(new CommandKick(plugin));
hdsubcmd.registerCommand(new CommandLease(plugin));
hdsubcmd.registerCommand(new CommandLimits(plugin));
hdsubcmd.registerCommand(new CommandList(plugin));
hdsubcmd.registerCommand(new CommandListAll(plugin));
hdsubcmd.registerCommand(new CommandListAllHidden(plugin));
hdsubcmd.registerCommand(new CommandListHidden(plugin));
hdsubcmd.registerCommand(new CommandLists(plugin));
hdsubcmd.registerCommand(new CommandLset(plugin));
hdsubcmd.registerCommand(new CommandMarket(plugin));
hdsubcmd.registerCommand(new CommandMaterial(plugin));
hdsubcmd.registerCommand(new CommandMessage(plugin));
hdsubcmd.registerCommand(new CommandMirror(plugin));
hdsubcmd.registerCommand(new CommandPset(plugin));
hdsubcmd.registerCommand(new CommandRemove(plugin));
hdsubcmd.registerCommand(new CommandRemoveAll(plugin));
hdsubcmd.registerCommand(new CommandRename(plugin));
hdsubcmd.registerCommand(new CommandRenameArea(plugin));
hdsubcmd.registerCommand(new CommandSelect(plugin));
hdsubcmd.registerCommand(new CommandServer(plugin));
hdsubcmd.registerCommand(new CommandSet(plugin));
hdsubcmd.registerCommand(new CommandSetOwner(plugin));
hdsubcmd.registerCommand(new CommandSubList(plugin));
hdsubcmd.registerCommand(new CommandSubZone(plugin));
hdsubcmd.registerCommand(new CommandTool(plugin));
hdsubcmd.registerCommand(new CommandTp(plugin));
hdsubcmd.registerCommand(new CommandTpSet(plugin));
hdsubcmd.registerCommand(new CommandUnStuck(plugin));
hdsubcmd.registerCommand(new CommandVersion(plugin));
plugin.getCommand("residence").setTabCompleter(hdsubcmd);
}
@Override
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
boolean resadmin = false;
if (sender instanceof Player) {
if (label.equalsIgnoreCase("resadmin"))
if (Residence.getPermissionManager().isResidenceAdmin((Player) sender))
if (label.equalsIgnoreCase("resadmin")) {
if (plugin.getPermissionManager().isResidenceAdmin((Player) sender)) {
resadmin = true;
else
sender.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NonAdmin"));
} else
} else {
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NonAdmin"));
}
}
} else {
resadmin = true;
}
if (args.length > 0 && args[args.length - 1].equalsIgnoreCase("?") || args.length > 1 && args[args.length - 2].equals("?")) {
commandHelp(args, resadmin, sender);
return;
}
if (Residence.getConfigManager().allowAdminsOnly())
if (plugin.getConfigManager().allowAdminsOnly()) {
if (!resadmin) {
sender.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("AdminOnly"));
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("AdminOnly"));
return;
}
if (args.length == 0)
}
if (args.length == 0) {
return;
}
hdsubcmd.onCommand(sender, resadmin ? command : null, label, args);
}
private boolean commandHelp(String[] args, boolean resadmin, CommandSender sender) {
if (Residence.helppages != null) {
private boolean commandHelp(final String[] args, final boolean resadmin, final CommandSender sender) {
if (plugin.getHelppages() != null) {
String helppath = "res";
for (String arg : args) {
if (arg.equalsIgnoreCase("?"))
for (final String arg : args) {
if (arg.equalsIgnoreCase("?")) {
break;
}
helppath = helppath + "." + arg;
}
int page = 1;
if (!args[args.length - 1].equalsIgnoreCase("?"))
if (!args[args.length - 1].equalsIgnoreCase("?")) {
try {
page = Integer.parseInt(args[args.length - 1]);
} catch (Exception ex) {
sender.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("InvalidHelp"));
} catch (final Exception ex) {
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
}
if (Residence.helppages.containesEntry(helppath)) {
Residence.helppages.printHelp(sender, page, helppath);
}
if (plugin.getHelppages().containesEntry(helppath)) {
plugin.getHelppages().printHelp(sender, page, helppath);
return true;
}
}

View File

@@ -16,22 +16,23 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandResLoad extends BaseCommand {
Residence plugin;
public CommandResLoad(Residence plugin) {
public CommandResLoad(final Residence plugin) {
super("resreload");
this.plugin = plugin;
}
@Override
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
if (!(sender instanceof Player) || Residence.getPermissionManager().isResidenceAdmin((Player) sender))
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
if (!(sender instanceof Player) || plugin.getPermissionManager().isResidenceAdmin((Player) sender)) {
try {
plugin.loadYml();
sender.sendMessage(ChatColor.GREEN + "[Residence] 从配置保存文件重新载入数据...");
} catch (Exception ex) {
} catch (final Exception ex) {
sender.sendMessage(ChatColor.RED + "[Residence] 无法从配置保存文件重新载入数据, 请查看控制台异常信息!");
sender.sendMessage(ChatColor.RED + "[Residence] 异常: " + ex.getMessage());
Logger.getLogger(Residence.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}

View File

@@ -13,23 +13,23 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandResReload extends BaseCommand {
Residence plugin;
public CommandResReload(Residence plugin) {
public CommandResReload(final Residence plugin) {
super("resreload");
this.plugin = plugin;
}
@Override
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
if (sender instanceof Player) {
Player player = (Player) sender;
if (Residence.getPermissionManager().isResidenceAdmin(player)) {
final Player player = (Player) sender;
if (plugin.getPermissionManager().isResidenceAdmin(player)) {
plugin.reloadPlugin();
sender.sendMessage(ChatColor.GREEN + "[Residence] 重载配置文件.");
System.out.println("[Residence] 重载 by " + player.getName() + ".");
plugin.getLogger().info("重载 by " + player.getName() + ".");
}
} else {
plugin.reloadPlugin();
System.out.println("[Residence] 重载 by 控制台.");
plugin.getLogger().info("重载 by 控制台.");
}
}

View File

@@ -13,7 +13,7 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
public class CommandResWorld extends BaseCommand {
Residence plugin;
public CommandResWorld(Residence plugin) {
public CommandResWorld(final Residence plugin) {
super("resworld");
this.plugin = plugin;
setMinimumArguments(2);
@@ -21,12 +21,14 @@ public class CommandResWorld extends BaseCommand {
}
@Override
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
if (args[0].equalsIgnoreCase("remove"))
if (sender instanceof ConsoleCommandSender)
Residence.getResidenceManager().removeAllFromWorld(sender, args[1]);
else
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
if (args[0].equalsIgnoreCase("remove")) {
if (sender instanceof ConsoleCommandSender) {
plugin.getResidenceManager().removeAllFromWorld(sender, args[1]);
} else {
sender.sendMessage(ChatColor.RED + "当前命令必须从控制台执行.");
}
}
}
}