mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2025-11-24 21:46:16 +00:00
@@ -0,0 +1,47 @@
|
||||
package com.bekvon.bukkit.residence.commandmain;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.chat.ChatChannel;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
|
||||
public class CommandRc extends BaseCommand {
|
||||
Residence plugin;
|
||||
|
||||
public CommandRc(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);
|
||||
if (area != null) {
|
||||
ChatChannel channel = Residence.getChatManager().getChannel(area);
|
||||
if (channel != null) {
|
||||
String message = "";
|
||||
for (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 + Residence.getLanguage().getPhrase("ChatDisabled"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.bekvon.bukkit.residence.commandmain;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandConfirm;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandRemove;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandSetOwner;
|
||||
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) {
|
||||
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();
|
||||
|
||||
plugin.getCommand("residence").setTabCompleter(hdsubcmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
|
||||
boolean resadmin = false;
|
||||
if (sender instanceof Player) {
|
||||
if (label.equalsIgnoreCase("resadmin"))
|
||||
if (Residence.getPermissionManager().isResidenceAdmin((Player) sender))
|
||||
resadmin = true;
|
||||
else
|
||||
sender.sendMessage(ChatColor.RED + Residence.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 (!resadmin) {
|
||||
sender.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("AdminOnly"));
|
||||
return;
|
||||
}
|
||||
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) {
|
||||
String helppath = "res";
|
||||
for (String arg : args) {
|
||||
if (arg.equalsIgnoreCase("?"))
|
||||
break;
|
||||
helppath = helppath + "." + arg;
|
||||
}
|
||||
int page = 1;
|
||||
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"));
|
||||
}
|
||||
if (Residence.helppages.containesEntry(helppath)) {
|
||||
Residence.helppages.printHelp(sender, page, helppath);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.bekvon.bukkit.residence.commandmain;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
|
||||
public class CommandResLoad extends BaseCommand {
|
||||
Residence plugin;
|
||||
|
||||
public CommandResLoad(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))
|
||||
try {
|
||||
plugin.loadYml();
|
||||
sender.sendMessage(ChatColor.GREEN + "[Residence] 从配置保存文件重新载入数据...");
|
||||
} catch (Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + "[Residence] 无法从配置保存文件重新载入数据, 请查看控制台异常信息!");
|
||||
sender.sendMessage(ChatColor.RED + "[Residence] 异常: " + ex.getMessage());
|
||||
Logger.getLogger(Residence.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.bekvon.bukkit.residence.commandmain;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
|
||||
public class CommandResReload extends BaseCommand {
|
||||
Residence plugin;
|
||||
|
||||
public CommandResReload(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) {
|
||||
Player player = (Player) sender;
|
||||
if (Residence.getPermissionManager().isResidenceAdmin(player)) {
|
||||
plugin.reloadPlugin();
|
||||
sender.sendMessage(ChatColor.GREEN + "[Residence] 重载配置文件.");
|
||||
System.out.println("[Residence] 重载 by " + player.getName() + ".");
|
||||
}
|
||||
} else {
|
||||
plugin.reloadPlugin();
|
||||
System.out.println("[Residence] 重载 by 控制台.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.bekvon.bukkit.residence.commandmain;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
|
||||
public class CommandResWorld extends BaseCommand {
|
||||
Residence plugin;
|
||||
|
||||
public CommandResWorld(Residence plugin) {
|
||||
super("resworld");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setPossibleArguments("remove <世界名称>");
|
||||
}
|
||||
|
||||
@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
|
||||
sender.sendMessage(ChatColor.RED + "当前命令必须从控制台执行.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.bekvon.bukkit.residence.commandsub;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.protection.ResidenceManager;
|
||||
import com.bekvon.bukkit.residence.text.Language;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
|
||||
public class CommandConfirm extends BaseCommand {
|
||||
Residence plugin;
|
||||
|
||||
public CommandConfirm(Residence plugin) {
|
||||
super("?", "help");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
|
||||
Player player = null;
|
||||
boolean resadmin = (command != null);
|
||||
ResidenceManager rmanager = Residence.getResidenceManager();
|
||||
Map<String, String> deleteConfirm = plugin.deleteConfirm;
|
||||
Language language = Residence.getLanguage();
|
||||
String name = "Console";
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
name = player.getName();
|
||||
}
|
||||
if (args.length == 1) {
|
||||
String area = deleteConfirm.get(name);
|
||||
if (area == null)
|
||||
sender.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
else {
|
||||
rmanager.removeResidence(player, area, resadmin);
|
||||
deleteConfirm.remove(name);
|
||||
if (player == null)
|
||||
sender.sendMessage(ChatColor.GREEN + Residence.getLanguage().getPhrase("ResidenceRemove", ChatColor.YELLOW + name + ChatColor.GREEN));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.bekvon.bukkit.residence.commandsub;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
import com.bekvon.bukkit.residence.protection.ResidenceManager;
|
||||
import com.bekvon.bukkit.residence.text.Language;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
|
||||
public class CommandRemove extends BaseCommand {
|
||||
Residence plugin;
|
||||
|
||||
public CommandRemove(Residence plugin) {
|
||||
super("remove", "delete");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
|
||||
Player player = null;
|
||||
boolean resadmin = (command != null);
|
||||
ResidenceManager rmanager = Residence.getResidenceManager();
|
||||
Map<String, String> deleteConfirm = plugin.deleteConfirm;
|
||||
Language language = Residence.getLanguage();
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
if (args.length == 1) {
|
||||
String area = rmanager.getNameByLoc(player.getLocation());
|
||||
if (area != null) {
|
||||
ClaimedResidence res = rmanager.getByName(area);
|
||||
if (res.getParent() != null) {
|
||||
String[] split = area.split("\\.");
|
||||
String words = split[split.length - 1];
|
||||
if (!deleteConfirm.containsKey(player.getName()) || !area.equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteSubzoneConfirm", ChatColor.YELLOW + words + ChatColor.RED));
|
||||
deleteConfirm.put(player.getName(), area);
|
||||
} else
|
||||
rmanager.removeResidence(player, area, resadmin);
|
||||
return;
|
||||
} else {
|
||||
if (!deleteConfirm.containsKey(player.getName()) || !area.equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + area + ChatColor.RED));
|
||||
deleteConfirm.put(player.getName(), area);
|
||||
} else
|
||||
rmanager.removeResidence(player, area, resadmin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args.length != 2)
|
||||
return;
|
||||
if (player != null) {
|
||||
if (!deleteConfirm.containsKey(player.getName()) || !args[1].equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
|
||||
String words = null;
|
||||
if (rmanager.getByName(args[1]) != null) {
|
||||
ClaimedResidence res = rmanager.getByName(args[1]);
|
||||
if (res.getParent() != null) {
|
||||
String[] split = args[1].split("\\.");
|
||||
words = split[split.length - 1];
|
||||
}
|
||||
}
|
||||
if (words == null)
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + args[1] + ChatColor.RED));
|
||||
else
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteSubzoneConfirm", ChatColor.YELLOW + words + ChatColor.RED));
|
||||
deleteConfirm.put(player.getName(), args[1]);
|
||||
} else
|
||||
rmanager.removeResidence(player, args[1], resadmin);
|
||||
} else if (!deleteConfirm.containsKey("Console") || !args[1].equalsIgnoreCase(deleteConfirm.get("Console"))) {
|
||||
String words = null;
|
||||
if (rmanager.getByName(args[1]) != null) {
|
||||
ClaimedResidence res = rmanager.getByName(args[1]);
|
||||
if (res.getParent() != null) {
|
||||
String[] split = args[1].split("\\.");
|
||||
words = split[split.length - 1];
|
||||
}
|
||||
}
|
||||
if (words == null)
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + args[1] + ChatColor.RED));
|
||||
else
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + language.getPhrase("DeleteSubzoneConfirm", ChatColor.YELLOW + words + ChatColor.RED));
|
||||
deleteConfirm.put("Console", args[1]);
|
||||
} else
|
||||
rmanager.removeResidence(args[1]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.bekvon.bukkit.residence.commandsub;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
import com.bekvon.bukkit.residence.protection.ResidenceManager;
|
||||
import com.bekvon.bukkit.residence.text.Language;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
|
||||
public class CommandSetOwner extends BaseCommand {
|
||||
Residence plugin;
|
||||
|
||||
public CommandSetOwner(Residence plugin) {
|
||||
super("setowner");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
|
||||
boolean resadmin = (command != null);
|
||||
ResidenceManager rmanager = Residence.getResidenceManager();
|
||||
Language language = Residence.getLanguage();
|
||||
|
||||
if (!resadmin)
|
||||
sender.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
ClaimedResidence area = rmanager.getByName(args[1]);
|
||||
if (area != null) {
|
||||
area.getPermissions().setOwner(args[2], true);
|
||||
if (area.getParent() == null)
|
||||
sender.sendMessage(
|
||||
ChatColor.GREEN + language.getPhrase("ResidenceOwnerChange", ChatColor.YELLOW + " " + args[1] + " " + ChatColor.GREEN + "." + ChatColor.YELLOW + args[2] + ChatColor.GREEN));
|
||||
else
|
||||
sender.sendMessage(ChatColor.GREEN + language.getPhrase("SubzoneOwnerChange",
|
||||
ChatColor.YELLOW + " " + args[1].split("\\.")[args[1].split("\\.").length - 1] + " " + ChatColor.GREEN + "." + ChatColor.YELLOW + args[2] + ChatColor.GREEN));
|
||||
} else
|
||||
sender.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.bekvon.bukkit.residence.commandsub;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
|
||||
public class CommandVersion extends BaseCommand {
|
||||
Residence plugin;
|
||||
|
||||
public CommandVersion(Residence plugin) {
|
||||
super("version");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
|
||||
sender.sendMessage(ChatColor.GRAY + "------------------------------------");
|
||||
sender.sendMessage(ChatColor.RED + "当前服务器运行的 " + ChatColor.GOLD + "Residence" + ChatColor.RED + " 版本: " + ChatColor.BLUE + plugin.getDescription().getVersion());
|
||||
sender.sendMessage(ChatColor.GREEN + "创建者: " + ChatColor.YELLOW + "bekvon");
|
||||
sender.sendMessage(ChatColor.GREEN + "升级到 1.8 by: " + ChatColor.YELLOW + "DartCZ");
|
||||
sender.sendMessage(ChatColor.RED + "升级到最新无UUID版本 by: " + ChatColor.YELLOW + "喵♂呜");
|
||||
String names = null;
|
||||
List<String> authlist = plugin.getDescription().getAuthors();
|
||||
for (String auth : authlist)
|
||||
if (names == null)
|
||||
names = auth;
|
||||
else
|
||||
names = names + ", " + auth;
|
||||
sender.sendMessage(ChatColor.GREEN + "作者: " + ChatColor.YELLOW + names);
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + "插件命令列表,帮助, 请查看wiki:");
|
||||
sender.sendMessage(ChatColor.GREEN + "http://residencebukkitmod.wikispaces.com/");
|
||||
sender.sendMessage(ChatColor.AQUA + "重制版本请查看Jenkins:");
|
||||
sender.sendMessage(ChatColor.BLUE + plugin.getDescription().getWebsite());
|
||||
sender.sendMessage(ChatColor.GRAY + "------------------------------------");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user