mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2026-05-01 18:50:27 +00:00
File diff suppressed because it is too large
Load Diff
@@ -23,50 +23,50 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
*/
|
||||
public class ChatChannel {
|
||||
|
||||
protected List<String> members;
|
||||
protected final String name;
|
||||
protected final ResidenceMain plugin;
|
||||
protected final PluginManager pm;
|
||||
protected List<String> members;
|
||||
protected final String name;
|
||||
protected final ResidenceMain plugin;
|
||||
protected final PluginManager pm;
|
||||
|
||||
public ChatChannel(final ResidenceMain plugin, final String channelName) {
|
||||
this.plugin = plugin;
|
||||
pm = plugin.getServer().getPluginManager();
|
||||
name = channelName;
|
||||
members = new ArrayList<String>();
|
||||
}
|
||||
public ChatChannel(final ResidenceMain plugin, final String channelName) {
|
||||
this.plugin = plugin;
|
||||
pm = plugin.getServer().getPluginManager();
|
||||
name = channelName;
|
||||
members = new ArrayList<String>();
|
||||
}
|
||||
|
||||
public void chat(final String sourcePlayer, final String message) {
|
||||
final Server serv = plugin.getServer();
|
||||
final ChatColor color = plugin.getConfigManager().getChatColor();
|
||||
final ResidenceChatEvent cevent = new ResidenceChatEvent(plugin.getResidenceManager().getByName(name), serv.getPlayer(sourcePlayer), message, color);
|
||||
pm.callEvent(cevent);
|
||||
if (cevent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
for (final String member : members) {
|
||||
final Player player = serv.getPlayer(member);
|
||||
if (player != null) {
|
||||
player.sendMessage(cevent.getColor() + sourcePlayer + ": " + cevent.getChatMessage());
|
||||
}
|
||||
}
|
||||
plugin.getLogger().info("ResidentialChat[" + name + "] - " + sourcePlayer + ": " + cevent.getChatMessage());
|
||||
}
|
||||
public void chat(final String sourcePlayer, final String message) {
|
||||
final Server serv = plugin.getServer();
|
||||
final ChatColor color = plugin.getConfigManager().getChatColor();
|
||||
final ResidenceChatEvent cevent = new ResidenceChatEvent(plugin.getResidenceManager().getByName(name), serv.getPlayer(sourcePlayer), message, color);
|
||||
pm.callEvent(cevent);
|
||||
if (cevent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
for (final String member : members) {
|
||||
final Player player = serv.getPlayer(member);
|
||||
if (player != null) {
|
||||
player.sendMessage(cevent.getColor() + sourcePlayer + ": " + cevent.getChatMessage());
|
||||
}
|
||||
}
|
||||
plugin.getLogger().info("ResidentialChat[" + name + "] - " + sourcePlayer + ": " + cevent.getChatMessage());
|
||||
}
|
||||
|
||||
public boolean hasMember(final String player) {
|
||||
return members.contains(player);
|
||||
}
|
||||
public boolean hasMember(final String player) {
|
||||
return members.contains(player);
|
||||
}
|
||||
|
||||
public void join(final String player) {
|
||||
if (!members.contains(player)) {
|
||||
members.add(player);
|
||||
}
|
||||
}
|
||||
public void join(final String player) {
|
||||
if (!members.contains(player)) {
|
||||
members.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void leave(final String player) {
|
||||
members.remove(player);
|
||||
}
|
||||
public void leave(final String player) {
|
||||
members.remove(player);
|
||||
}
|
||||
|
||||
public int memberCount() {
|
||||
return members.size();
|
||||
}
|
||||
public int memberCount() {
|
||||
return members.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,36 +16,36 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
*/
|
||||
public class ChatManager {
|
||||
|
||||
protected Map<String, ChatChannel> channelmap;
|
||||
protected final ResidenceMain plugin;
|
||||
protected Map<String, ChatChannel> channelmap;
|
||||
protected final ResidenceMain plugin;
|
||||
|
||||
public ChatManager(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
channelmap = new HashMap<String, ChatChannel>();
|
||||
}
|
||||
public ChatManager(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
channelmap = new HashMap<String, ChatChannel>();
|
||||
}
|
||||
|
||||
public ChatChannel getChannel(final String channel) {
|
||||
return channelmap.get(channel);
|
||||
}
|
||||
public ChatChannel getChannel(final String channel) {
|
||||
return channelmap.get(channel);
|
||||
}
|
||||
|
||||
public ChatChannel getPlayerChannel(final String player) {
|
||||
for (final ChatChannel chan : channelmap.values())
|
||||
if (chan.hasMember(player))
|
||||
return chan;
|
||||
return null;
|
||||
}
|
||||
public ChatChannel getPlayerChannel(final String player) {
|
||||
for (final ChatChannel chan : channelmap.values())
|
||||
if (chan.hasMember(player))
|
||||
return chan;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void removeFromChannel(final String player) {
|
||||
for (final ChatChannel chan : channelmap.values())
|
||||
if (chan.hasMember(player))
|
||||
chan.leave(player);
|
||||
}
|
||||
public void removeFromChannel(final String player) {
|
||||
for (final ChatChannel chan : channelmap.values())
|
||||
if (chan.hasMember(player))
|
||||
chan.leave(player);
|
||||
}
|
||||
|
||||
public void setChannel(final String player, final String channel) {
|
||||
this.removeFromChannel(player);
|
||||
if (!channelmap.containsKey(channel))
|
||||
channelmap.put(channel, new ChatChannel(plugin, channel));
|
||||
channelmap.get(channel).join(player);
|
||||
}
|
||||
public void setChannel(final String player, final String channel) {
|
||||
this.removeFromChannel(player);
|
||||
if (!channelmap.containsKey(channel))
|
||||
channelmap.put(channel, new ChatChannel(plugin, channel));
|
||||
channelmap.get(channel).join(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,40 +11,40 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.chat.ChatChannel;
|
||||
|
||||
public class CommandRc extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandRc(final ResidenceMain plugin) {
|
||||
super("rc");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandRc(final ResidenceMain plugin) {
|
||||
super("rc");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
final ChatChannel channel = plugin.getChatManager().getChannel(area);
|
||||
if (channel != null) {
|
||||
String message = "";
|
||||
for (final String arg : args) {
|
||||
message = message + " " + arg;
|
||||
}
|
||||
channel.chat(pname, message);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidChannel"));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotInResidence"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ChatDisabled"));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
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) {
|
||||
final ChatChannel channel = plugin.getChatManager().getChannel(area);
|
||||
if (channel != null) {
|
||||
String message = "";
|
||||
for (final String arg : args) {
|
||||
message = message + " " + arg;
|
||||
}
|
||||
channel.chat(pname, message);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidChannel"));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotInResidence"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ChatDisabled"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,115 +54,115 @@ import cn.citycraft.Residence.commandsub.CommandUnStuck;
|
||||
import cn.citycraft.Residence.commandsub.CommandVersion;
|
||||
|
||||
public class CommandRes extends BaseCommand implements DefaultCommand {
|
||||
HandlerSubCommand hdsubcmd;
|
||||
HandlerSubCommand hdsubcmd;
|
||||
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandRes(final ResidenceMain plugin) {
|
||||
super("res", "residence", "resadmin");
|
||||
this.plugin = plugin;
|
||||
hdsubcmd = new HandlerSubCommand(plugin);
|
||||
public CommandRes(final ResidenceMain plugin) {
|
||||
super("res", "residence", "resadmin");
|
||||
this.plugin = plugin;
|
||||
hdsubcmd = new HandlerSubCommand(plugin);
|
||||
|
||||
hdsubcmd.registerCommand(new CommandArea(plugin));
|
||||
hdsubcmd.registerCommand(new CommandBank(plugin));
|
||||
hdsubcmd.registerCommand(new CommandCheck(plugin));
|
||||
hdsubcmd.registerCommand(new CommandCheckSelf(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));
|
||||
hdsubcmd.registerCommand(new CommandArea(plugin));
|
||||
hdsubcmd.registerCommand(new CommandBank(plugin));
|
||||
hdsubcmd.registerCommand(new CommandCheck(plugin));
|
||||
hdsubcmd.registerCommand(new CommandCheckSelf(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));
|
||||
|
||||
hdsubcmd.setDefaultCommand(this);
|
||||
hdsubcmd.setDefaultCommand(this);
|
||||
|
||||
plugin.getCommand("residence").setTabCompleter(hdsubcmd);
|
||||
}
|
||||
plugin.getCommand("residence").setTabCompleter(hdsubcmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultExecute(final CommandSender sender, final Command command, final String label) throws CommandException {
|
||||
commandHelp(new String[] { "?" }, true, sender);
|
||||
}
|
||||
@Override
|
||||
public void defaultExecute(final CommandSender sender, final Command command, final String label) throws CommandException {
|
||||
commandHelp(new String[] { "?" }, true, sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
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 (plugin.getPermissionManager().isResidenceAdmin((Player) sender)) {
|
||||
resadmin = true;
|
||||
} 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 (plugin.getConfigManager().allowAdminsOnly()) {
|
||||
if (!resadmin) {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("AdminOnly"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
hdsubcmd.onCommand(sender, resadmin ? command : null, label, args);
|
||||
}
|
||||
@Override
|
||||
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 (plugin.getPermissionManager().isResidenceAdmin((Player) sender)) {
|
||||
resadmin = true;
|
||||
} 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 (plugin.getConfigManager().allowAdminsOnly()) {
|
||||
if (!resadmin) {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("AdminOnly"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
hdsubcmd.onCommand(sender, resadmin ? command : null, label, args);
|
||||
}
|
||||
|
||||
private void commandHelp(final String[] args, final boolean resadmin, final CommandSender sender) {
|
||||
if (plugin.getHelppages() != null) {
|
||||
String helppath = "res";
|
||||
for (final 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 (final Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
|
||||
}
|
||||
}
|
||||
if (plugin.getHelppages().containesEntry(helppath)) {
|
||||
plugin.getHelppages().printHelp(sender, page, helppath);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void commandHelp(final String[] args, final boolean resadmin, final CommandSender sender) {
|
||||
if (plugin.getHelppages() != null) {
|
||||
String helppath = "res";
|
||||
for (final 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 (final Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
|
||||
}
|
||||
}
|
||||
if (plugin.getHelppages().containesEntry(helppath)) {
|
||||
plugin.getHelppages().printHelp(sender, page, helppath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,26 +13,26 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class CommandResLoad extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandResLoad(final ResidenceMain plugin) {
|
||||
super("resload");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public CommandResLoad(final ResidenceMain plugin) {
|
||||
super("resload");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
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.reloadConfig();
|
||||
plugin.loadYml();
|
||||
sender.sendMessage(ChatColor.GREEN + "[Residence] 从配置保存文件重新载入数据...");
|
||||
} catch (final Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + "[Residence] 无法从配置保存文件重新载入数据, 请查看控制台异常信息!");
|
||||
sender.sendMessage(ChatColor.RED + "[Residence] 异常: " + ex.getMessage());
|
||||
Logger.getLogger(ResidenceMain.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
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.reloadConfig();
|
||||
plugin.loadYml();
|
||||
sender.sendMessage(ChatColor.GREEN + "[Residence] 从配置保存文件重新载入数据...");
|
||||
} catch (final Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + "[Residence] 无法从配置保存文件重新载入数据, 请查看控制台异常信息!");
|
||||
sender.sendMessage(ChatColor.RED + "[Residence] 异常: " + ex.getMessage());
|
||||
Logger.getLogger(ResidenceMain.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,26 +10,26 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class CommandResReload extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandResReload(final ResidenceMain plugin) {
|
||||
super("resreload");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public CommandResReload(final ResidenceMain plugin) {
|
||||
super("resreload");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
if (sender instanceof Player) {
|
||||
final Player player = (Player) sender;
|
||||
if (plugin.getPermissionManager().isResidenceAdmin(player)) {
|
||||
plugin.reloadPlugin();
|
||||
sender.sendMessage(ChatColor.GREEN + "[Residence] 重载配置文件.");
|
||||
plugin.getLogger().info("重载 by " + player.getName() + ".");
|
||||
}
|
||||
} else {
|
||||
plugin.reloadPlugin();
|
||||
plugin.getLogger().info("重载 by 控制台.");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
if (sender instanceof Player) {
|
||||
final Player player = (Player) sender;
|
||||
if (plugin.getPermissionManager().isResidenceAdmin(player)) {
|
||||
plugin.reloadPlugin();
|
||||
sender.sendMessage(ChatColor.GREEN + "[Residence] 重载配置文件.");
|
||||
plugin.getLogger().info("重载 by " + player.getName() + ".");
|
||||
}
|
||||
} else {
|
||||
plugin.reloadPlugin();
|
||||
plugin.getLogger().info("重载 by 控制台.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,24 +10,24 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class CommandResWorld extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandResWorld(final ResidenceMain plugin) {
|
||||
super("resworld");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setPossibleArguments("remove <世界名称>");
|
||||
}
|
||||
public CommandResWorld(final ResidenceMain plugin) {
|
||||
super("resworld");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setPossibleArguments("remove <世界名称>");
|
||||
}
|
||||
|
||||
@Override
|
||||
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 + "当前命令必须从控制台执行.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
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 + "当前命令必须从控制台执行.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,76 +18,76 @@ import cn.citycraft.Residence.selection.SelectionManager;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandArea extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandArea(final ResidenceMain plugin) {
|
||||
super("area");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(3);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<list|listall|add|remove|replace> <领地名称> [区域名称]");
|
||||
}
|
||||
public CommandArea(final ResidenceMain plugin) {
|
||||
super("area");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(3);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<list|listall|add|remove|replace> <领地名称> [区域名称]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final SelectionManager smanager = plugin.getSelectionManager();
|
||||
final WorldEditPlugin wep = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final SelectionManager smanager = plugin.getSelectionManager();
|
||||
final WorldEditPlugin wep = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
|
||||
final String subcmd = args[0];
|
||||
final String subcmd = args[0];
|
||||
|
||||
final ClaimedResidence res = rmanager.getByName(args[1]);
|
||||
final ClaimedResidence res = rmanager.getByName(args[1]);
|
||||
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (wep != null) {
|
||||
if (wep.getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
||||
smanager.worldEdit(player);
|
||||
}
|
||||
}
|
||||
if (args.length == 2) {
|
||||
switch (subcmd) {
|
||||
case "list":
|
||||
res.printAreaList(player, page);
|
||||
return;
|
||||
case "listall":
|
||||
res.printAdvancedAreaList(player, page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (args.length == 3) {
|
||||
switch (subcmd) {
|
||||
case "add":
|
||||
if (smanager.hasPlacedBoth(player.getName())) {
|
||||
res.addArea(player, new CuboidArea(smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName())), args[2], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
||||
}
|
||||
return;
|
||||
case "remove":
|
||||
res.removeArea(player, args[2], resadmin);
|
||||
return;
|
||||
case "replace":
|
||||
if (smanager.hasPlacedBoth(player.getName())) {
|
||||
res.replaceArea(player, new CuboidArea(smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName())), args[2], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (wep != null) {
|
||||
if (wep.getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
||||
smanager.worldEdit(player);
|
||||
}
|
||||
}
|
||||
if (args.length == 2) {
|
||||
switch (subcmd) {
|
||||
case "list":
|
||||
res.printAreaList(player, page);
|
||||
return;
|
||||
case "listall":
|
||||
res.printAdvancedAreaList(player, page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (args.length == 3) {
|
||||
switch (subcmd) {
|
||||
case "add":
|
||||
if (smanager.hasPlacedBoth(player.getName())) {
|
||||
res.addArea(player, new CuboidArea(smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName())), args[2], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
||||
}
|
||||
return;
|
||||
case "remove":
|
||||
res.removeArea(player, args[2], resadmin);
|
||||
return;
|
||||
case "replace":
|
||||
if (smanager.hasPlacedBoth(player.getName())) {
|
||||
res.replaceArea(player, new CuboidArea(smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName())), args[2], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,41 +14,41 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandBank extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandBank(final ResidenceMain plugin) {
|
||||
super("bank");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("[deposit(存入)|withdraw(取出)] 金额");
|
||||
}
|
||||
public CommandBank(final ResidenceMain plugin) {
|
||||
super("bank");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("[deposit(存入)|withdraw(取出)] 金额");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final ClaimedResidence res = rmanager.getByName(plugin.getPlayerListener().getCurrentResidenceName(player.getName()));
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NotInResidence"));
|
||||
return;
|
||||
}
|
||||
int amount = 0;
|
||||
try {
|
||||
amount = Integer.parseInt(args[1]);
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidAmount"));
|
||||
return;
|
||||
}
|
||||
final String subcmd = args[0];
|
||||
switch (subcmd) {
|
||||
case "deposit":
|
||||
res.getBank().deposit(player, amount, resadmin);
|
||||
case "withdraw":
|
||||
res.getBank().withdraw(player, amount, resadmin);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final ClaimedResidence res = rmanager.getByName(plugin.getPlayerListener().getCurrentResidenceName(player.getName()));
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NotInResidence"));
|
||||
return;
|
||||
}
|
||||
int amount = 0;
|
||||
try {
|
||||
amount = Integer.parseInt(args[1]);
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidAmount"));
|
||||
return;
|
||||
}
|
||||
final String subcmd = args[0];
|
||||
switch (subcmd) {
|
||||
case "deposit":
|
||||
res.getBank().deposit(player, amount, resadmin);
|
||||
case "withdraw":
|
||||
res.getBank().withdraw(player, amount, resadmin);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,41 +14,41 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandCheck extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandCheck(final ResidenceMain plugin) {
|
||||
super("check");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名称> <权限> [玩家]");
|
||||
}
|
||||
public CommandCheck(final ResidenceMain plugin) {
|
||||
super("check");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名称> <权限> [玩家]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
String pname = player.getName();
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
String pname = player.getName();
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
if (args.length == 2 || args.length == 3) {
|
||||
if (args.length == 3) {
|
||||
pname = args[2];
|
||||
}
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (!res.getPermissions().hasApplicableFlag(pname, args[1])) {
|
||||
player.sendMessage(language.getPhrase("FlagCheckFalse",
|
||||
ChatColor.YELLOW + args[0] + ChatColor.RED + "." + ChatColor.YELLOW + pname + ChatColor.RED + "." + ChatColor.YELLOW + args[0] + ChatColor.RED));
|
||||
} else {
|
||||
player.sendMessage(language.getPhrase("FlagCheckTrue",
|
||||
ChatColor.GREEN + args[0] + ChatColor.YELLOW + "." + ChatColor.GREEN + pname + ChatColor.YELLOW + "." + ChatColor.YELLOW + args[0] + ChatColor.RED + "."
|
||||
+ (res.getPermissions().playerHas(pname, res.getPermissions().getWorld(), args[1], false) ? ChatColor.GREEN + "TRUE" : ChatColor.RED + "FALSE")));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args.length == 2 || args.length == 3) {
|
||||
if (args.length == 3) {
|
||||
pname = args[2];
|
||||
}
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (!res.getPermissions().hasApplicableFlag(pname, args[1])) {
|
||||
player.sendMessage(language.getPhrase("FlagCheckFalse",
|
||||
ChatColor.YELLOW + args[0] + ChatColor.RED + "." + ChatColor.YELLOW + pname + ChatColor.RED + "." + ChatColor.YELLOW + args[0] + ChatColor.RED));
|
||||
} else {
|
||||
player.sendMessage(language.getPhrase("FlagCheckTrue",
|
||||
ChatColor.GREEN + args[0] + ChatColor.YELLOW + "." + ChatColor.GREEN + pname + ChatColor.YELLOW + "." + ChatColor.YELLOW + args[0] + ChatColor.RED + "."
|
||||
+ (res.getPermissions().playerHas(pname, res.getPermissions().getWorld(), args[1], false) ? ChatColor.GREEN + "TRUE" : ChatColor.RED + "FALSE")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,29 +11,29 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class CommandCheckSelf extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandCheckSelf(final ResidenceMain plugin) {
|
||||
super("checkself");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("[权限]");
|
||||
}
|
||||
public CommandCheckSelf(final ResidenceMain plugin) {
|
||||
super("checkself");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("[权限]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final FlagPermissions perm = plugin.getPermsByLocForPlayer(player.getLocation(), player);
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
player.sendMessage("§e权限列表: ");
|
||||
perm.printFlags(player);
|
||||
return;
|
||||
case 1:
|
||||
final String flag = args[0];
|
||||
player.sendMessage("§e权限检查: §a" + flag + " " + (perm.checkValidFlag(flag, false) ? "§atrue" : "§cfalse"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final FlagPermissions perm = plugin.getPermsByLocForPlayer(player.getLocation(), player);
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
player.sendMessage("§e权限列表: ");
|
||||
perm.printFlags(player);
|
||||
return;
|
||||
case 1:
|
||||
final String flag = args[0];
|
||||
player.sendMessage("§e权限检查: §a" + flag + " " + (perm.checkValidFlag(flag, false) ? "§atrue" : "§cfalse"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,34 +14,34 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandClearFlags extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandClearFlags(final ResidenceMain plugin) {
|
||||
super("clearflags");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名称>");
|
||||
}
|
||||
public CommandClearFlags(final ResidenceMain plugin) {
|
||||
super("clearflags");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名称>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
if (!resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence area = rmanager.getByName(args[1]);
|
||||
if (area != null) {
|
||||
area.getPermissions().clearFlags();
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagsCleared"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
}
|
||||
if (!resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence area = rmanager.getByName(args[1]);
|
||||
if (area != null) {
|
||||
area.getPermissions().clearFlags();
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagsCleared"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,40 +14,40 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandCompass extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandCompass(final ResidenceMain plugin) {
|
||||
super("compass", "cp");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
setDescription("切换指南针方向");
|
||||
setPossibleArguments("[领地名称]");
|
||||
}
|
||||
public CommandCompass(final ResidenceMain plugin) {
|
||||
super("compass", "cp");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
setDescription("切换指南针方向");
|
||||
setPossibleArguments("[领地名称]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
if (args.length != 1) {
|
||||
player.setCompassTarget(player.getWorld().getSpawnLocation());
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("CompassTargetReset"));
|
||||
return;
|
||||
}
|
||||
final String resname = args[0];
|
||||
if (args.length != 1) {
|
||||
player.setCompassTarget(player.getWorld().getSpawnLocation());
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("CompassTargetReset"));
|
||||
return;
|
||||
}
|
||||
final String resname = args[0];
|
||||
|
||||
if (rmanager.getByName(resname) != null) {
|
||||
if (rmanager.getByName(resname).getWorld().equalsIgnoreCase(player.getWorld().getName())) {
|
||||
final Location low = rmanager.getByName(resname).getArea("main").getLowLoc();
|
||||
final Location high = rmanager.getByName(resname).getArea("main").getHighLoc();
|
||||
final Location mid = new Location(low.getWorld(), (low.getBlockX() + high.getBlockX()) / 2, (low.getBlockY() + high.getBlockY()) / 2, (low.getBlockZ() + high.getBlockZ()) / 2);
|
||||
player.setCompassTarget(mid);
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("CompassTargetSet", ChatColor.YELLOW + resname + ChatColor.GREEN));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
}
|
||||
if (rmanager.getByName(resname) != null) {
|
||||
if (rmanager.getByName(resname).getWorld().equalsIgnoreCase(player.getWorld().getName())) {
|
||||
final Location low = rmanager.getByName(resname).getArea("main").getLowLoc();
|
||||
final Location high = rmanager.getByName(resname).getArea("main").getHighLoc();
|
||||
final Location mid = new Location(low.getWorld(), (low.getBlockX() + high.getBlockX()) / 2, (low.getBlockY() + high.getBlockY()) / 2, (low.getBlockZ() + high.getBlockZ()) / 2);
|
||||
player.setCompassTarget(mid);
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("CompassTargetSet", ChatColor.YELLOW + resname + ChatColor.GREEN));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,35 +15,35 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandConfirm extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandConfirm(final ResidenceMain plugin) {
|
||||
super("confirm");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public CommandConfirm(final ResidenceMain plugin) {
|
||||
super("confirm");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
Player player = null;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Map<String, String> deleteConfirm = plugin.getDeleteConfirm();
|
||||
final Language language = plugin.getLanguage();
|
||||
String name = "Console";
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
name = player.getName();
|
||||
}
|
||||
final 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 + language.getPhrase("ResidenceRemove", ChatColor.YELLOW + name + ChatColor.GREEN));
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
Player player = null;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Map<String, String> deleteConfirm = plugin.getDeleteConfirm();
|
||||
final Language language = plugin.getLanguage();
|
||||
String name = "Console";
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
name = player.getName();
|
||||
}
|
||||
final 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 + language.getPhrase("ResidenceRemove", ChatColor.YELLOW + name + ChatColor.GREEN));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,34 +15,34 @@ import cn.citycraft.Residence.selection.SelectionManager;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandCreate extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandCreate(final ResidenceMain plugin) {
|
||||
super("create", "new");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名称>");
|
||||
}
|
||||
public CommandCreate(final ResidenceMain plugin) {
|
||||
super("create", "new");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名称>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final SelectionManager smanager = plugin.getSelectionManager();
|
||||
final WorldEditPlugin wep = (WorldEditPlugin) plugin.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
if (wep != null) {
|
||||
if (wep.getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
||||
smanager.worldEdit(player);
|
||||
}
|
||||
}
|
||||
if (smanager.hasPlacedBoth(player.getName())) {
|
||||
rmanager.addResidence(player, args[0], smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName()), resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final SelectionManager smanager = plugin.getSelectionManager();
|
||||
final WorldEditPlugin wep = (WorldEditPlugin) plugin.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
if (wep != null) {
|
||||
if (wep.getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
||||
smanager.worldEdit(player);
|
||||
}
|
||||
}
|
||||
if (smanager.hasPlacedBoth(player.getName())) {
|
||||
rmanager.addResidence(player, args[0], smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName()), resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,25 +13,25 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandCurrent extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandCurrent(final ResidenceMain plugin) {
|
||||
super("current");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandCurrent(final ResidenceMain plugin) {
|
||||
super("current");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final String res = rmanager.getNameByLoc(player.getLocation());
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NotInResidence"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("InResidence", ChatColor.YELLOW + res + ChatColor.GREEN));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final String res = rmanager.getNameByLoc(player.getLocation());
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NotInResidence"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("InResidence", ChatColor.YELLOW + res + ChatColor.GREEN));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,23 +12,23 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class CommandDefault extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandDefault(final ResidenceMain plugin) {
|
||||
super("default");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名称>");
|
||||
}
|
||||
public CommandDefault(final ResidenceMain plugin) {
|
||||
super("default");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名称>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
res.getPermissions().applyDefaultFlags(player, resadmin);
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
res.getPermissions().applyDefaultFlags(player, resadmin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,23 +11,23 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class CommandGive extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandGive(final ResidenceMain plugin) {
|
||||
super("give");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<目标玩家> <赠送的领地>");
|
||||
}
|
||||
public CommandGive(final ResidenceMain plugin) {
|
||||
super("give");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<目标玩家> <赠送的领地>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
|
||||
rmanager.giveResidence(player, args[1], args[0], resadmin);
|
||||
}
|
||||
rmanager.giveResidence(player, args[1], args[0], resadmin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,40 +14,40 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandGset extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandGset(final ResidenceMain plugin) {
|
||||
super("gset");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(3);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名称(不写则为所在领地)> <组名称> <权限> <权限状态>");
|
||||
}
|
||||
public CommandGset(final ResidenceMain plugin) {
|
||||
super("gset");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(3);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名称(不写则为所在领地)> <组名称> <权限> <权限状态>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
if (args.length == 3) {
|
||||
final ClaimedResidence area = rmanager.getByLoc(player.getLocation());
|
||||
if (area != null) {
|
||||
area.getPermissions().setGroupFlag(player, args[0], args[1], args[2], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidArea"));
|
||||
}
|
||||
return;
|
||||
} else if (args.length == 4) {
|
||||
final ClaimedResidence area = rmanager.getByName(args[0]);
|
||||
if (area != null) {
|
||||
area.getPermissions().setGroupFlag(player, args[1], args[2], args[3], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (args.length == 3) {
|
||||
final ClaimedResidence area = rmanager.getByLoc(player.getLocation());
|
||||
if (area != null) {
|
||||
area.getPermissions().setGroupFlag(player, args[0], args[1], args[2], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidArea"));
|
||||
}
|
||||
return;
|
||||
} else if (args.length == 4) {
|
||||
final ClaimedResidence area = rmanager.getByName(args[0]);
|
||||
if (area != null) {
|
||||
area.getPermissions().setGroupFlag(player, args[1], args[2], args[3], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,33 +13,33 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandInfo extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandInfo(final ResidenceMain plugin) {
|
||||
super("info");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandInfo(final ResidenceMain plugin) {
|
||||
super("info");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
if (args.length == 0) {
|
||||
final String area = rmanager.getNameByLoc(player.getLocation());
|
||||
if (area != null) {
|
||||
rmanager.printAreaInfo(area, player);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
} else {
|
||||
if (args.length == 1) {
|
||||
rmanager.printAreaInfo(args[0], player);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args.length == 0) {
|
||||
final String area = rmanager.getNameByLoc(player.getLocation());
|
||||
if (area != null) {
|
||||
rmanager.printAreaInfo(area, player);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
} else {
|
||||
if (args.length == 1) {
|
||||
rmanager.printAreaInfo(args[0], player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,43 +16,43 @@ import cn.citycraft.Residence.permissions.PermissionGroup;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandKick extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandKick(final ResidenceMain plugin) {
|
||||
super("kick");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<目标玩家>");
|
||||
setDescription("把玩家T出当前领地!");
|
||||
}
|
||||
public CommandKick(final ResidenceMain plugin) {
|
||||
super("kick");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<目标玩家>");
|
||||
setDescription("把玩家T出当前领地!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
|
||||
final Player targetplayer = Bukkit.getPlayer(args[0]);
|
||||
if (targetplayer == null) {
|
||||
return;
|
||||
}
|
||||
if (!group.hasKickAccess()) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = rmanager.getByLoc(targetplayer.getLocation());
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (res.getOwner().equals(player.getName())) {
|
||||
if (res.getPlayersInResidence().contains(targetplayer)) {
|
||||
targetplayer.teleport(res.getOutsideFreeLoc(player.getLocation()));
|
||||
targetplayer.sendMessage(ChatColor.RED + language.getPhrase("Kicked") + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
final Player targetplayer = Bukkit.getPlayer(args[0]);
|
||||
if (targetplayer == null) {
|
||||
return;
|
||||
}
|
||||
if (!group.hasKickAccess()) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = rmanager.getByLoc(targetplayer.getLocation());
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (res.getOwner().equals(player.getName())) {
|
||||
if (res.getPlayersInResidence().contains(targetplayer)) {
|
||||
targetplayer.teleport(res.getOutsideFreeLoc(player.getLocation()));
|
||||
targetplayer.sendMessage(ChatColor.RED + language.getPhrase("Kicked") + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,81 +15,81 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandLease extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandLease(final ResidenceMain plugin) {
|
||||
super("lease");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("[renew/cost] [领地名]");
|
||||
}
|
||||
public CommandLease(final ResidenceMain plugin) {
|
||||
super("lease");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("[renew/cost] [领地名]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final LeaseManager leasemanager = plugin.getLeaseManager();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final LeaseManager leasemanager = plugin.getLeaseManager();
|
||||
|
||||
if (args.length == 1 || args.length == 2) {
|
||||
if (args[0].equals("renew")) {
|
||||
if (args.length == 2) {
|
||||
leasemanager.renewArea(args[1], player);
|
||||
} else {
|
||||
leasemanager.renewArea(rmanager.getNameByLoc(player.getLocation()), player);
|
||||
}
|
||||
return;
|
||||
} else if (args[0].equals("cost")) {
|
||||
if (args.length == 2) {
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(args[1]);
|
||||
if (res == null || leasemanager.leaseExpires(args[1])) {
|
||||
final int cost = leasemanager.getRenewCost(res);
|
||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("LeaseRenewalCost", ChatColor.RED + args[1] + ChatColor.YELLOW + "." + ChatColor.RED + cost + ChatColor.YELLOW));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
||||
}
|
||||
} else {
|
||||
final String area = rmanager.getNameByLoc(player.getLocation());
|
||||
final ClaimedResidence res = rmanager.getByName(area);
|
||||
if (area == null || res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidArea"));
|
||||
return;
|
||||
}
|
||||
if (leasemanager.leaseExpires(area)) {
|
||||
final int cost = leasemanager.getRenewCost(res);
|
||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("LeaseRenewalCost", ChatColor.RED + area + ChatColor.YELLOW + "." + ChatColor.RED + cost + ChatColor.YELLOW));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (args.length == 3) {
|
||||
if (args[0].equals("set")) {
|
||||
if (!resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
if (args[2].equals("infinite")) {
|
||||
if (leasemanager.leaseExpires(args[1])) {
|
||||
leasemanager.removeExpireTime(args[1]);
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("LeaseInfinite"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
||||
}
|
||||
} else {
|
||||
int days;
|
||||
try {
|
||||
days = Integer.parseInt(args[2]);
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidDays"));
|
||||
return;
|
||||
}
|
||||
leasemanager.setExpireTime(player, args[1], days);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args.length == 1 || args.length == 2) {
|
||||
if (args[0].equals("renew")) {
|
||||
if (args.length == 2) {
|
||||
leasemanager.renewArea(args[1], player);
|
||||
} else {
|
||||
leasemanager.renewArea(rmanager.getNameByLoc(player.getLocation()), player);
|
||||
}
|
||||
return;
|
||||
} else if (args[0].equals("cost")) {
|
||||
if (args.length == 2) {
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(args[1]);
|
||||
if (res == null || leasemanager.leaseExpires(args[1])) {
|
||||
final int cost = leasemanager.getRenewCost(res);
|
||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("LeaseRenewalCost", ChatColor.RED + args[1] + ChatColor.YELLOW + "." + ChatColor.RED + cost + ChatColor.YELLOW));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
||||
}
|
||||
} else {
|
||||
final String area = rmanager.getNameByLoc(player.getLocation());
|
||||
final ClaimedResidence res = rmanager.getByName(area);
|
||||
if (area == null || res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidArea"));
|
||||
return;
|
||||
}
|
||||
if (leasemanager.leaseExpires(area)) {
|
||||
final int cost = leasemanager.getRenewCost(res);
|
||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("LeaseRenewalCost", ChatColor.RED + area + ChatColor.YELLOW + "." + ChatColor.RED + cost + ChatColor.YELLOW));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (args.length == 3) {
|
||||
if (args[0].equals("set")) {
|
||||
if (!resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
if (args[2].equals("infinite")) {
|
||||
if (leasemanager.leaseExpires(args[1])) {
|
||||
leasemanager.removeExpireTime(args[1]);
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("LeaseInfinite"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
||||
}
|
||||
} else {
|
||||
int days;
|
||||
try {
|
||||
days = Integer.parseInt(args[2]);
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidDays"));
|
||||
return;
|
||||
}
|
||||
leasemanager.setExpireTime(player, args[1], days);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,19 +10,19 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.permissions.PermissionManager;
|
||||
|
||||
public class CommandLimits extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandLimits(final ResidenceMain plugin) {
|
||||
super("limits");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandLimits(final ResidenceMain plugin) {
|
||||
super("limits");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final PermissionManager gmanager = plugin.getPermissionManager();
|
||||
gmanager.getGroup(player).printLimits(player);
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final PermissionManager gmanager = plugin.getPermissionManager();
|
||||
gmanager.getGroup(player).printLimits(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,41 +11,41 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class CommandList extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandList(final ResidenceMain plugin) {
|
||||
super("list");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandList(final ResidenceMain plugin) {
|
||||
super("list");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
rmanager.listResidences(player);
|
||||
return;
|
||||
case 1:
|
||||
try {
|
||||
Integer.parseInt(args[0]);
|
||||
rmanager.listResidences(player, page);
|
||||
} catch (final Exception ex) {
|
||||
rmanager.listResidences(player, args[0]);
|
||||
}
|
||||
return;
|
||||
case 2:
|
||||
rmanager.listResidences(player, args[0], page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
rmanager.listResidences(player);
|
||||
return;
|
||||
case 1:
|
||||
try {
|
||||
Integer.parseInt(args[0]);
|
||||
rmanager.listResidences(player, page);
|
||||
} catch (final Exception ex) {
|
||||
rmanager.listResidences(player, args[0]);
|
||||
}
|
||||
return;
|
||||
case 2:
|
||||
rmanager.listResidences(player, args[0], page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,26 +11,26 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class CommandListAll extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandListAll(final ResidenceMain plugin) {
|
||||
super("listall");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandListAll(final ResidenceMain plugin) {
|
||||
super("listall");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
rmanager.listAllResidences(player, page);
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
rmanager.listAllResidences(player, page);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,34 +13,34 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandListAllHidden extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandListAllHidden(final ResidenceMain plugin) {
|
||||
super("listallhidden");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandListAllHidden(final ResidenceMain plugin) {
|
||||
super("listallhidden");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
|
||||
if (!resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
rmanager.listAllResidences(player, page, true);
|
||||
}
|
||||
if (!resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
rmanager.listAllResidences(player, page, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,42 +13,42 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandListHidden extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandListHidden(final ResidenceMain plugin) {
|
||||
super("listhidden");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandListHidden(final ResidenceMain plugin) {
|
||||
super("listhidden");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
|
||||
if (!resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
if (!resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
rmanager.listResidences(player, 1, true);
|
||||
return;
|
||||
case 2:
|
||||
rmanager.listResidences(player, args[1], page, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
rmanager.listResidences(player, 1, true);
|
||||
return;
|
||||
case 2:
|
||||
rmanager.listResidences(player, args[1], page, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,67 +14,67 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandLists extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandLists(final ResidenceMain plugin) {
|
||||
super("lists");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("用法: /res lists ? 查看帮助");
|
||||
}
|
||||
public CommandLists(final ResidenceMain plugin) {
|
||||
super("lists");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("用法: /res lists ? 查看帮助");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final Language language = plugin.getLanguage();
|
||||
final PermissionListManager pmanager = plugin.getPermissionListManager();
|
||||
final String listname = args[1];
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final Language language = plugin.getLanguage();
|
||||
final PermissionListManager pmanager = plugin.getPermissionListManager();
|
||||
final String listname = args[1];
|
||||
|
||||
switch (args[0]) {
|
||||
case "list":
|
||||
pmanager.printLists(player);
|
||||
return;
|
||||
case "add":
|
||||
if (args.length == 2) {
|
||||
pmanager.makeList(player, listname);
|
||||
}
|
||||
return;
|
||||
case "remove":
|
||||
if (args.length == 2) {
|
||||
pmanager.removeList(player, listname);
|
||||
}
|
||||
return;
|
||||
case "apply":
|
||||
if (args.length == 3) {
|
||||
pmanager.applyListToResidence(player, listname, args[2], resadmin);
|
||||
}
|
||||
return;
|
||||
case "set":
|
||||
if (args.length == 4) {
|
||||
pmanager.getList(player.getName(), listname).setFlag(args[2], FlagPermissions.stringToFlagState(args[3]));
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagSet"));
|
||||
}
|
||||
return;
|
||||
case "pset":
|
||||
if (args.length == 5) {
|
||||
pmanager.getList(player.getName(), listname).setGroupFlag(args[2], args[3], FlagPermissions.stringToFlagState(args[4]));
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagSet"));
|
||||
}
|
||||
return;
|
||||
case "gset":
|
||||
if (args.length == 5) {
|
||||
pmanager.getList(player.getName(), listname).setPlayerFlag(args[2], args[3], FlagPermissions.stringToFlagState(args[4]));
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagSet"));
|
||||
}
|
||||
return;
|
||||
case "view":
|
||||
if (args.length == 2) {
|
||||
pmanager.printList(player, listname);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
switch (args[0]) {
|
||||
case "list":
|
||||
pmanager.printLists(player);
|
||||
return;
|
||||
case "add":
|
||||
if (args.length == 2) {
|
||||
pmanager.makeList(player, listname);
|
||||
}
|
||||
return;
|
||||
case "remove":
|
||||
if (args.length == 2) {
|
||||
pmanager.removeList(player, listname);
|
||||
}
|
||||
return;
|
||||
case "apply":
|
||||
if (args.length == 3) {
|
||||
pmanager.applyListToResidence(player, listname, args[2], resadmin);
|
||||
}
|
||||
return;
|
||||
case "set":
|
||||
if (args.length == 4) {
|
||||
pmanager.getList(player.getName(), listname).setFlag(args[2], FlagPermissions.stringToFlagState(args[3]));
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagSet"));
|
||||
}
|
||||
return;
|
||||
case "pset":
|
||||
if (args.length == 5) {
|
||||
pmanager.getList(player.getName(), listname).setGroupFlag(args[2], args[3], FlagPermissions.stringToFlagState(args[4]));
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagSet"));
|
||||
}
|
||||
return;
|
||||
case "gset":
|
||||
if (args.length == 5) {
|
||||
pmanager.getList(player.getName(), listname).setPlayerFlag(args[2], args[3], FlagPermissions.stringToFlagState(args[4]));
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagSet"));
|
||||
}
|
||||
return;
|
||||
case "view":
|
||||
if (args.length == 2) {
|
||||
pmanager.printList(player, listname);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,60 +15,60 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandLset extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandLset(final ResidenceMain plugin) {
|
||||
super("lset");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名称> [blacklist(bl)/ignorelist(il)||info] [material]");
|
||||
}
|
||||
public CommandLset(final ResidenceMain plugin) {
|
||||
super("lset");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名称> [blacklist(bl)/ignorelist(il)||info] [material]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
|
||||
Material mat = null;
|
||||
Material mat = null;
|
||||
|
||||
if (args.length == 3) {
|
||||
try {
|
||||
mat = Material.valueOf(args[3].toUpperCase());
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidMaterial"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (args.length == 3) {
|
||||
try {
|
||||
mat = Material.valueOf(args[3].toUpperCase());
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidMaterial"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final String subcmd = args[1];
|
||||
final String subcmd = args[1];
|
||||
|
||||
switch (subcmd) {
|
||||
switch (subcmd) {
|
||||
|
||||
case "info":
|
||||
player.sendMessage(ChatColor.RED + "Blacklist:");
|
||||
res.getItemBlacklist().printList(player);
|
||||
player.sendMessage(ChatColor.GREEN + "Ignorelist:");
|
||||
res.getItemIgnoreList().printList(player);
|
||||
return;
|
||||
case "bl":
|
||||
case "blacklist":
|
||||
res.getItemBlacklist().playerListChange(player, mat, resadmin);
|
||||
return;
|
||||
case "il":
|
||||
case "ignorelist":
|
||||
res.getItemIgnoreList().playerListChange(player, mat, resadmin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
case "info":
|
||||
player.sendMessage(ChatColor.RED + "Blacklist:");
|
||||
res.getItemBlacklist().printList(player);
|
||||
player.sendMessage(ChatColor.GREEN + "Ignorelist:");
|
||||
res.getItemIgnoreList().printList(player);
|
||||
return;
|
||||
case "bl":
|
||||
case "blacklist":
|
||||
res.getItemBlacklist().playerListChange(player, mat, resadmin);
|
||||
return;
|
||||
case "il":
|
||||
case "ignorelist":
|
||||
res.getItemIgnoreList().playerListChange(player, mat, resadmin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,207 +18,207 @@ import cn.citycraft.Residence.selection.SelectionManager;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandMarket extends BaseCommand {
|
||||
ConfigManager cmanager;
|
||||
PermissionManager gmanager;
|
||||
Language language;
|
||||
ResidenceMain plugin;
|
||||
RentManager rentmanager;
|
||||
ResidenceManager rmanager;
|
||||
SelectionManager smanager;
|
||||
TransactionManager tmanager;
|
||||
ConfigManager cmanager;
|
||||
PermissionManager gmanager;
|
||||
Language language;
|
||||
ResidenceMain plugin;
|
||||
RentManager rentmanager;
|
||||
ResidenceManager rmanager;
|
||||
SelectionManager smanager;
|
||||
TransactionManager tmanager;
|
||||
|
||||
public CommandMarket(final ResidenceMain plugin) {
|
||||
super("market");
|
||||
this.plugin = plugin;
|
||||
rmanager = plugin.getResidenceManager();
|
||||
language = plugin.getLanguage();
|
||||
smanager = plugin.getSelectionManager();
|
||||
gmanager = plugin.getPermissionManager();
|
||||
rentmanager = plugin.getRentManager();
|
||||
cmanager = plugin.getConfigManager();
|
||||
tmanager = plugin.getTransactionManager();
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandMarket(final ResidenceMain plugin) {
|
||||
super("market");
|
||||
this.plugin = plugin;
|
||||
rmanager = plugin.getResidenceManager();
|
||||
language = plugin.getLanguage();
|
||||
smanager = plugin.getSelectionManager();
|
||||
gmanager = plugin.getPermissionManager();
|
||||
rentmanager = plugin.getRentManager();
|
||||
cmanager = plugin.getConfigManager();
|
||||
tmanager = plugin.getTransactionManager();
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
|
||||
final String cmd = args[0].toLowerCase();
|
||||
if (cmd.equals("list")) {
|
||||
commandResMarketList(args, resadmin, player, page);
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("autorenew")) {
|
||||
commandResMarketAutorenew(args, resadmin, player, page);
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("rentable")) {
|
||||
commandResMarketRentable(args, resadmin, player, page);
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("rent")) {
|
||||
commandResMarketRent(args, resadmin, player, page);
|
||||
return;
|
||||
}
|
||||
final String cmd = args[0].toLowerCase();
|
||||
if (cmd.equals("list")) {
|
||||
commandResMarketList(args, resadmin, player, page);
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("autorenew")) {
|
||||
commandResMarketAutorenew(args, resadmin, player, page);
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("rentable")) {
|
||||
commandResMarketRentable(args, resadmin, player, page);
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("rent")) {
|
||||
commandResMarketRent(args, resadmin, player, page);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd.equals("release")) {
|
||||
if (args.length != 2) {
|
||||
return;
|
||||
}
|
||||
if (rentmanager.isRented(args[1])) {
|
||||
rentmanager.removeFromForRent(player, args[1], resadmin);
|
||||
} else {
|
||||
rentmanager.unrent(player, args[1], resadmin);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("info")) {
|
||||
if (args.length == 1) {
|
||||
final String areaname = rmanager.getNameByLoc(player.getLocation());
|
||||
tmanager.viewSaleInfo(areaname, player);
|
||||
if (cmanager.enabledRentSystem() && rentmanager.isForRent(areaname)) {
|
||||
rentmanager.printRentInfo(player, areaname);
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
tmanager.viewSaleInfo(args[1], player);
|
||||
if (cmanager.enabledRentSystem() && rentmanager.isForRent(args[1])) {
|
||||
rentmanager.printRentInfo(player, args[1]);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("buy")) {
|
||||
if (args.length != 2) {
|
||||
return;
|
||||
}
|
||||
tmanager.buyPlot(args[1], player, resadmin);
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("unsell")) {
|
||||
if (args.length != 2) {
|
||||
return;
|
||||
}
|
||||
tmanager.removeFromSale(player, args[1], resadmin);
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("sell")) {
|
||||
if (args.length != 3) {
|
||||
return;
|
||||
}
|
||||
int amount;
|
||||
try {
|
||||
amount = Integer.parseInt(args[2]);
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidAmount"));
|
||||
return;
|
||||
}
|
||||
tmanager.putForSale(args[1], player, amount, resadmin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (cmd.equals("release")) {
|
||||
if (args.length != 2) {
|
||||
return;
|
||||
}
|
||||
if (rentmanager.isRented(args[1])) {
|
||||
rentmanager.removeFromForRent(player, args[1], resadmin);
|
||||
} else {
|
||||
rentmanager.unrent(player, args[1], resadmin);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("info")) {
|
||||
if (args.length == 1) {
|
||||
final String areaname = rmanager.getNameByLoc(player.getLocation());
|
||||
tmanager.viewSaleInfo(areaname, player);
|
||||
if (cmanager.enabledRentSystem() && rentmanager.isForRent(areaname)) {
|
||||
rentmanager.printRentInfo(player, areaname);
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
tmanager.viewSaleInfo(args[1], player);
|
||||
if (cmanager.enabledRentSystem() && rentmanager.isForRent(args[1])) {
|
||||
rentmanager.printRentInfo(player, args[1]);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("buy")) {
|
||||
if (args.length != 2) {
|
||||
return;
|
||||
}
|
||||
tmanager.buyPlot(args[1], player, resadmin);
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("unsell")) {
|
||||
if (args.length != 2) {
|
||||
return;
|
||||
}
|
||||
tmanager.removeFromSale(player, args[1], resadmin);
|
||||
return;
|
||||
}
|
||||
if (cmd.equals("sell")) {
|
||||
if (args.length != 3) {
|
||||
return;
|
||||
}
|
||||
int amount;
|
||||
try {
|
||||
amount = Integer.parseInt(args[2]);
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidAmount"));
|
||||
return;
|
||||
}
|
||||
tmanager.putForSale(args[1], player, amount, resadmin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean commandResMarketAutorenew(final String[] args, final boolean resadmin, final Player player, final int page) {
|
||||
if (!cmanager.enableEconomy()) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("MarketDisabled"));
|
||||
return true;
|
||||
}
|
||||
if (args.length != 3) {
|
||||
return true;
|
||||
}
|
||||
boolean value;
|
||||
if (args[2].equalsIgnoreCase("true") || args[2].equalsIgnoreCase("t")) {
|
||||
value = true;
|
||||
} else if (args[2].equalsIgnoreCase("false") || args[2].equalsIgnoreCase("f")) {
|
||||
value = false;
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidBoolean"));
|
||||
return true;
|
||||
}
|
||||
if (rentmanager.isRented(args[1]) && rentmanager.getRentingPlayer(args[1]).equalsIgnoreCase(player.getName())) {
|
||||
rentmanager.setRentedRepeatable(player, args[1], value, resadmin);
|
||||
} else if (rentmanager.isForRent(args[1])) {
|
||||
rentmanager.setRentRepeatable(player, args[1], value, resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("RentReleaseInvalid", ChatColor.YELLOW + args[1] + ChatColor.RED));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private boolean commandResMarketAutorenew(final String[] args, final boolean resadmin, final Player player, final int page) {
|
||||
if (!cmanager.enableEconomy()) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("MarketDisabled"));
|
||||
return true;
|
||||
}
|
||||
if (args.length != 3) {
|
||||
return true;
|
||||
}
|
||||
boolean value;
|
||||
if (args[2].equalsIgnoreCase("true") || args[2].equalsIgnoreCase("t")) {
|
||||
value = true;
|
||||
} else if (args[2].equalsIgnoreCase("false") || args[2].equalsIgnoreCase("f")) {
|
||||
value = false;
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidBoolean"));
|
||||
return true;
|
||||
}
|
||||
if (rentmanager.isRented(args[1]) && rentmanager.getRentingPlayer(args[1]).equalsIgnoreCase(player.getName())) {
|
||||
rentmanager.setRentedRepeatable(player, args[1], value, resadmin);
|
||||
} else if (rentmanager.isForRent(args[1])) {
|
||||
rentmanager.setRentRepeatable(player, args[1], value, resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("RentReleaseInvalid", ChatColor.YELLOW + args[1] + ChatColor.RED));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean commandResMarketList(final String[] args, final boolean resadmin, final Player player, final int page) {
|
||||
if (!cmanager.enableEconomy()) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("MarketDisabled"));
|
||||
return true;
|
||||
}
|
||||
player.sendMessage(ChatColor.BLUE + "---" + language.getPhrase("MarketList") + "---");
|
||||
tmanager.printForSaleResidences(player);
|
||||
if (cmanager.enabledRentSystem()) {
|
||||
rentmanager.printRentableResidences(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private boolean commandResMarketList(final String[] args, final boolean resadmin, final Player player, final int page) {
|
||||
if (!cmanager.enableEconomy()) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("MarketDisabled"));
|
||||
return true;
|
||||
}
|
||||
player.sendMessage(ChatColor.BLUE + "---" + language.getPhrase("MarketList") + "---");
|
||||
tmanager.printForSaleResidences(player);
|
||||
if (cmanager.enabledRentSystem()) {
|
||||
rentmanager.printRentableResidences(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean commandResMarketRent(final String[] args, final boolean resadmin, final Player player, final int page) {
|
||||
if (args.length < 2 || args.length > 3) {
|
||||
return false;
|
||||
}
|
||||
boolean repeat = false;
|
||||
if (args.length == 3) {
|
||||
if (args[2].equalsIgnoreCase("t") || args[2].equalsIgnoreCase("true")) {
|
||||
repeat = true;
|
||||
} else if (!args[2].equalsIgnoreCase("f") && !args[2].equalsIgnoreCase("false")) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidBoolean"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
rentmanager.rent(player, args[1], repeat, resadmin);
|
||||
return true;
|
||||
}
|
||||
private boolean commandResMarketRent(final String[] args, final boolean resadmin, final Player player, final int page) {
|
||||
if (args.length < 2 || args.length > 3) {
|
||||
return false;
|
||||
}
|
||||
boolean repeat = false;
|
||||
if (args.length == 3) {
|
||||
if (args[2].equalsIgnoreCase("t") || args[2].equalsIgnoreCase("true")) {
|
||||
repeat = true;
|
||||
} else if (!args[2].equalsIgnoreCase("f") && !args[2].equalsIgnoreCase("false")) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidBoolean"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
rentmanager.rent(player, args[1], repeat, resadmin);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean commandResMarketRentable(final String[] args, final boolean resadmin, final Player player, final int page) {
|
||||
if (args.length < 4 || args.length > 5) {
|
||||
return false;
|
||||
}
|
||||
if (!cmanager.enabledRentSystem()) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("RentDisabled"));
|
||||
return true;
|
||||
}
|
||||
int days;
|
||||
int cost;
|
||||
try {
|
||||
cost = Integer.parseInt(args[2]);
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidCost"));
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
days = Integer.parseInt(args[3]);
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidDays"));
|
||||
return true;
|
||||
}
|
||||
boolean repeat = false;
|
||||
if (args.length == 5) {
|
||||
final String state = args[4];
|
||||
if (state.equalsIgnoreCase("t") || state.equalsIgnoreCase("true")) {
|
||||
repeat = true;
|
||||
} else if (!state.equalsIgnoreCase("f") && !state.equalsIgnoreCase("false")) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidBoolean"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
rentmanager.setForRent(player, args[1], cost, days, repeat, resadmin);
|
||||
return true;
|
||||
}
|
||||
private boolean commandResMarketRentable(final String[] args, final boolean resadmin, final Player player, final int page) {
|
||||
if (args.length < 4 || args.length > 5) {
|
||||
return false;
|
||||
}
|
||||
if (!cmanager.enabledRentSystem()) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("RentDisabled"));
|
||||
return true;
|
||||
}
|
||||
int days;
|
||||
int cost;
|
||||
try {
|
||||
cost = Integer.parseInt(args[2]);
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidCost"));
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
days = Integer.parseInt(args[3]);
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidDays"));
|
||||
return true;
|
||||
}
|
||||
boolean repeat = false;
|
||||
if (args.length == 5) {
|
||||
final String state = args[4];
|
||||
if (state.equalsIgnoreCase("t") || state.equalsIgnoreCase("true")) {
|
||||
repeat = true;
|
||||
} else if (!state.equalsIgnoreCase("f") && !state.equalsIgnoreCase("false")) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidBoolean"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
rentmanager.setForRent(player, args[1], cost, days, repeat, resadmin);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,28 +12,28 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandMaterial extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandMaterial(final ResidenceMain plugin) {
|
||||
super("material");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandMaterial(final ResidenceMain plugin) {
|
||||
super("material");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
|
||||
final Language language = plugin.getLanguage();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
try {
|
||||
player.sendMessage(ChatColor.GREEN
|
||||
+ language.getPhrase("MaterialGet", ChatColor.GOLD + args[0] + ChatColor.GREEN + "." + ChatColor.RED + Material.getMaterial(Integer.parseInt(args[0])).name() + ChatColor.GREEN));
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidMaterial"));
|
||||
}
|
||||
}
|
||||
try {
|
||||
player.sendMessage(ChatColor.GREEN
|
||||
+ language.getPhrase("MaterialGet", ChatColor.GOLD + args[0] + ChatColor.GREEN + "." + ChatColor.RED + Material.getMaterial(Integer.parseInt(args[0])).name() + ChatColor.GREEN));
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidMaterial"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,36 +15,36 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandMessage extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandMessage(final ResidenceMain plugin) {
|
||||
super("message");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("[enter|leave] [消息(移除则留空)]");
|
||||
}
|
||||
public CommandMessage(final ResidenceMain plugin) {
|
||||
super("message");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("[enter|leave] [消息(移除则留空)]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final ClaimedResidence res = rmanager.getByLoc(player.getLocation());
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
String message = null;
|
||||
if (args.length != 1) {
|
||||
message = StringUtil.consolidateStrings(args, 1);
|
||||
}
|
||||
boolean enter = false;
|
||||
if (args[0].equalsIgnoreCase("enter")) {
|
||||
enter = true;
|
||||
}
|
||||
res.setEnterLeaveMessage(player, message, enter, resadmin);
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final ClaimedResidence res = rmanager.getByLoc(player.getLocation());
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
String message = null;
|
||||
if (args.length != 1) {
|
||||
message = StringUtil.consolidateStrings(args, 1);
|
||||
}
|
||||
boolean enter = false;
|
||||
if (args[0].equalsIgnoreCase("enter")) {
|
||||
enter = true;
|
||||
}
|
||||
res.setEnterLeaveMessage(player, message, enter, resadmin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,21 +11,21 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class CommandMirror extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandMirror(final ResidenceMain plugin) {
|
||||
super("mirror");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandMirror(final ResidenceMain plugin) {
|
||||
super("mirror");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
rmanager.mirrorPerms(player, args[1], args[0], resadmin);
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
rmanager.mirrorPerms(player, args[1], args[0], resadmin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,56 +14,56 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandPset extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandPset(final ResidenceMain plugin) {
|
||||
super("pset");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<residence> [player] [flag|removeall] [true/false/remove]");
|
||||
}
|
||||
public CommandPset(final ResidenceMain plugin) {
|
||||
super("pset");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<residence> [player] [flag|removeall] [true/false/remove]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
if (args.length == 2 && args[1].equalsIgnoreCase("removeall")) {
|
||||
final ClaimedResidence area = rmanager.getByLoc(player.getLocation());
|
||||
if (area != null) {
|
||||
area.getPermissions().removeAllPlayerFlags(player, args[1], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
return;
|
||||
} else if (args.length == 3 && args[2].equalsIgnoreCase("removeall")) {
|
||||
final ClaimedResidence area = rmanager.getByName(args[0]);
|
||||
if (area != null) {
|
||||
area.getPermissions().removeAllPlayerFlags(player, args[2], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
return;
|
||||
} else if (args.length == 3) {
|
||||
final ClaimedResidence area = rmanager.getByLoc(player.getLocation());
|
||||
if (area != null) {
|
||||
area.getPermissions().setPlayerFlag(player, args[0], args[1], args[2], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
return;
|
||||
} else if (args.length == 4) {
|
||||
final ClaimedResidence area = rmanager.getByName(args[0]);
|
||||
if (area != null) {
|
||||
area.getPermissions().setPlayerFlag(player, args[1], args[2], args[3], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (args.length == 2 && args[1].equalsIgnoreCase("removeall")) {
|
||||
final ClaimedResidence area = rmanager.getByLoc(player.getLocation());
|
||||
if (area != null) {
|
||||
area.getPermissions().removeAllPlayerFlags(player, args[1], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
return;
|
||||
} else if (args.length == 3 && args[2].equalsIgnoreCase("removeall")) {
|
||||
final ClaimedResidence area = rmanager.getByName(args[0]);
|
||||
if (area != null) {
|
||||
area.getPermissions().removeAllPlayerFlags(player, args[2], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
return;
|
||||
} else if (args.length == 3) {
|
||||
final ClaimedResidence area = rmanager.getByLoc(player.getLocation());
|
||||
if (area != null) {
|
||||
area.getPermissions().setPlayerFlag(player, args[0], args[1], args[2], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
return;
|
||||
} else if (args.length == 4) {
|
||||
final ClaimedResidence area = rmanager.getByName(args[0]);
|
||||
if (area != null) {
|
||||
area.getPermissions().setPlayerFlag(player, args[1], args[2], args[3], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,85 +17,85 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandRemove extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandRemove(final ResidenceMain plugin) {
|
||||
super("remove", "delete");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public CommandRemove(final ResidenceMain plugin) {
|
||||
super("remove", "delete");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
Player player = null;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Map<String, String> deleteConfirm = plugin.getDeleteConfirm();
|
||||
final Language language = plugin.getLanguage();
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
final String area = rmanager.getNameByLoc(player.getLocation());
|
||||
if (area != null) {
|
||||
final ClaimedResidence res = rmanager.getByName(area);
|
||||
if (res.getParent() != null) {
|
||||
final String[] split = area.split("\\.");
|
||||
final 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);
|
||||
}
|
||||
} 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 != 1) {
|
||||
return;
|
||||
}
|
||||
if (player != null) {
|
||||
if (!deleteConfirm.containsKey(player.getName()) || !args[0].equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
|
||||
String words = null;
|
||||
if (rmanager.getByName(args[0]) != null) {
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
if (res.getParent() != null) {
|
||||
final String[] split = args[0].split("\\.");
|
||||
words = split[split.length - 1];
|
||||
}
|
||||
}
|
||||
if (words == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + args[0] + ChatColor.RED));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteSubzoneConfirm", ChatColor.YELLOW + words + ChatColor.RED));
|
||||
}
|
||||
deleteConfirm.put(player.getName(), args[0]);
|
||||
} else {
|
||||
rmanager.removeResidence(player, args[0], resadmin);
|
||||
}
|
||||
} else if (!deleteConfirm.containsKey("Console") || !args[0].equalsIgnoreCase(deleteConfirm.get("Console"))) {
|
||||
String words = null;
|
||||
if (rmanager.getByName(args[0]) != null) {
|
||||
final ClaimedResidence res = rmanager.getByName(args[1]);
|
||||
if (res.getParent() != null) {
|
||||
final String[] split = args[0].split("\\.");
|
||||
words = split[split.length - 1];
|
||||
}
|
||||
}
|
||||
if (words == null) {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + args[0] + ChatColor.RED));
|
||||
} else {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + language.getPhrase("DeleteSubzoneConfirm", ChatColor.YELLOW + words + ChatColor.RED));
|
||||
}
|
||||
deleteConfirm.put("Console", args[0]);
|
||||
} else {
|
||||
rmanager.removeResidence(args[0]);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
Player player = null;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Map<String, String> deleteConfirm = plugin.getDeleteConfirm();
|
||||
final Language language = plugin.getLanguage();
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
final String area = rmanager.getNameByLoc(player.getLocation());
|
||||
if (area != null) {
|
||||
final ClaimedResidence res = rmanager.getByName(area);
|
||||
if (res.getParent() != null) {
|
||||
final String[] split = area.split("\\.");
|
||||
final 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);
|
||||
}
|
||||
} 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 != 1) {
|
||||
return;
|
||||
}
|
||||
if (player != null) {
|
||||
if (!deleteConfirm.containsKey(player.getName()) || !args[0].equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
|
||||
String words = null;
|
||||
if (rmanager.getByName(args[0]) != null) {
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
if (res.getParent() != null) {
|
||||
final String[] split = args[0].split("\\.");
|
||||
words = split[split.length - 1];
|
||||
}
|
||||
}
|
||||
if (words == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + args[0] + ChatColor.RED));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteSubzoneConfirm", ChatColor.YELLOW + words + ChatColor.RED));
|
||||
}
|
||||
deleteConfirm.put(player.getName(), args[0]);
|
||||
} else {
|
||||
rmanager.removeResidence(player, args[0], resadmin);
|
||||
}
|
||||
} else if (!deleteConfirm.containsKey("Console") || !args[0].equalsIgnoreCase(deleteConfirm.get("Console"))) {
|
||||
String words = null;
|
||||
if (rmanager.getByName(args[0]) != null) {
|
||||
final ClaimedResidence res = rmanager.getByName(args[1]);
|
||||
if (res.getParent() != null) {
|
||||
final String[] split = args[0].split("\\.");
|
||||
words = split[split.length - 1];
|
||||
}
|
||||
}
|
||||
if (words == null) {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + args[0] + ChatColor.RED));
|
||||
} else {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + language.getPhrase("DeleteSubzoneConfirm", ChatColor.YELLOW + words + ChatColor.RED));
|
||||
}
|
||||
deleteConfirm.put("Console", args[0]);
|
||||
} else {
|
||||
rmanager.removeResidence(args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,29 +13,29 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandRemoveAll extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandRemoveAll(final ResidenceMain plugin) {
|
||||
super("removeall");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandRemoveAll(final ResidenceMain plugin) {
|
||||
super("removeall");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final String pname = player.getName();
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
if (resadmin || args[0].endsWith(pname)) {
|
||||
rmanager.removeAllByOwner(player, args[0]);
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("RemovePlayersResidences", ChatColor.YELLOW + args[1] + ChatColor.GREEN));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final String pname = player.getName();
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
if (resadmin || args[0].endsWith(pname)) {
|
||||
rmanager.removeAllByOwner(player, args[0]);
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("RemovePlayersResidences", ChatColor.YELLOW + args[1] + ChatColor.GREEN));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,22 +11,22 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class CommandRename extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandRename(final ResidenceMain plugin) {
|
||||
super("rename");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandRename(final ResidenceMain plugin) {
|
||||
super("rename");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
|
||||
rmanager.renameResidence(player, args[0], args[1], resadmin);
|
||||
}
|
||||
rmanager.renameResidence(player, args[0], args[1], resadmin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,28 +14,28 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandRenameArea extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandRenameArea(final ResidenceMain plugin) {
|
||||
super("renamearea");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(3);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandRenameArea(final ResidenceMain plugin) {
|
||||
super("renamearea");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(3);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
res.renameArea(player, args[1], args[2], resadmin);
|
||||
}
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
res.renameArea(player, args[1], args[2], resadmin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,147 +21,147 @@ import cn.citycraft.Residence.selection.SelectionManager;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandSelect extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandSelect(final ResidenceMain plugin) {
|
||||
super("select");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPermission("residence.select");
|
||||
setPossibleArguments("请使用/res select ? 查看帮助");
|
||||
}
|
||||
public CommandSelect(final ResidenceMain plugin) {
|
||||
super("select");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPermission("residence.select");
|
||||
setPossibleArguments("请使用/res select ? 查看帮助");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
final SelectionManager smanager = plugin.getSelectionManager();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
final SelectionManager smanager = plugin.getSelectionManager();
|
||||
|
||||
if (!group.selectCommandAccess() && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectDiabled"));
|
||||
return;
|
||||
}
|
||||
if (!group.canCreateResidences() && group.getMaxSubzoneDepth() <= 0 && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectDiabled"));
|
||||
return;
|
||||
}
|
||||
if (!group.selectCommandAccess() && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectDiabled"));
|
||||
return;
|
||||
}
|
||||
if (!group.canCreateResidences() && group.getMaxSubzoneDepth() <= 0 && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectDiabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
final String subcmd = args[0];
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
switch (subcmd) {
|
||||
case "size":
|
||||
case "cost":
|
||||
if (smanager.hasPlacedBoth(player.getName())) {
|
||||
try {
|
||||
smanager.showSelectionInfo(player);
|
||||
return;
|
||||
} catch (final Exception ex) {
|
||||
Logger.getLogger(ResidenceMain.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return;
|
||||
}
|
||||
} else if (smanager.worldEdit(player)) {
|
||||
try {
|
||||
smanager.showSelectionInfo(player);
|
||||
return;
|
||||
} catch (final Exception ex) {
|
||||
Logger.getLogger(ResidenceMain.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
case "vert":
|
||||
smanager.vert(player, resadmin);
|
||||
return;
|
||||
case "sky":
|
||||
smanager.sky(player, resadmin);
|
||||
return;
|
||||
case "bedrock":
|
||||
smanager.bedrock(player, resadmin);
|
||||
return;
|
||||
case "coords":
|
||||
final Location playerLoc1 = smanager.getPlayerLoc1(player.getName());
|
||||
if (playerLoc1 != null) {
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("Primary.Selection") + ":" + ChatColor.AQUA + " (" + playerLoc1.getBlockX() + ", " + playerLoc1.getBlockY() + ", "
|
||||
+ playerLoc1.getBlockZ() + ")");
|
||||
}
|
||||
final Location playerLoc2 = smanager.getPlayerLoc2(player.getName());
|
||||
if (playerLoc2 != null) {
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("Secondary.Selection") + ":" + ChatColor.AQUA + " (" + playerLoc2.getBlockX() + ", " + playerLoc2.getBlockY() + ", "
|
||||
+ playerLoc2.getBlockZ() + ")");
|
||||
}
|
||||
return;
|
||||
case "chunk":
|
||||
smanager.selectChunk(player);
|
||||
return;
|
||||
case "worldedit":
|
||||
if (smanager.worldEdit(player)) {
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSuccess"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
case 2:
|
||||
int amount;
|
||||
try {
|
||||
amount = Integer.parseInt(args[1]);
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidAmount"));
|
||||
return;
|
||||
}
|
||||
switch (subcmd) {
|
||||
case "expand":
|
||||
smanager.modify(player, false, amount);
|
||||
return;
|
||||
case "shift":
|
||||
smanager.modify(player, true, amount);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
case 3:
|
||||
try {
|
||||
smanager.selectBySize(player, Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]));
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectionFail"));
|
||||
}
|
||||
return;
|
||||
default:
|
||||
if (args.length > 0) {
|
||||
String resName;
|
||||
String areaName;
|
||||
ClaimedResidence res = null;
|
||||
if (args.length > 1) {
|
||||
res = rmanager.getByName(args[0]);
|
||||
} else {
|
||||
res = rmanager.getByLoc(player.getLocation());
|
||||
}
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
resName = res.getName();
|
||||
CuboidArea area = null;
|
||||
if (args.length > 2) {
|
||||
area = res.getArea(args[1]);
|
||||
areaName = args[1];
|
||||
} else {
|
||||
areaName = res.getAreaIDbyLoc(player.getLocation());
|
||||
area = res.getArea(areaName);
|
||||
}
|
||||
if (area != null) {
|
||||
smanager.placeLoc1(player, area.getHighLoc());
|
||||
smanager.placeLoc2(player, area.getLowLoc());
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("SelectionArea", ChatColor.GOLD + areaName + ChatColor.GREEN + "." + ChatColor.GOLD + resName + ChatColor.GREEN));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("AreaNonExist"));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
final String subcmd = args[0];
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
switch (subcmd) {
|
||||
case "size":
|
||||
case "cost":
|
||||
if (smanager.hasPlacedBoth(player.getName())) {
|
||||
try {
|
||||
smanager.showSelectionInfo(player);
|
||||
return;
|
||||
} catch (final Exception ex) {
|
||||
Logger.getLogger(ResidenceMain.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return;
|
||||
}
|
||||
} else if (smanager.worldEdit(player)) {
|
||||
try {
|
||||
smanager.showSelectionInfo(player);
|
||||
return;
|
||||
} catch (final Exception ex) {
|
||||
Logger.getLogger(ResidenceMain.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
case "vert":
|
||||
smanager.vert(player, resadmin);
|
||||
return;
|
||||
case "sky":
|
||||
smanager.sky(player, resadmin);
|
||||
return;
|
||||
case "bedrock":
|
||||
smanager.bedrock(player, resadmin);
|
||||
return;
|
||||
case "coords":
|
||||
final Location playerLoc1 = smanager.getPlayerLoc1(player.getName());
|
||||
if (playerLoc1 != null) {
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("Primary.Selection") + ":" + ChatColor.AQUA + " (" + playerLoc1.getBlockX() + ", " + playerLoc1.getBlockY() + ", "
|
||||
+ playerLoc1.getBlockZ() + ")");
|
||||
}
|
||||
final Location playerLoc2 = smanager.getPlayerLoc2(player.getName());
|
||||
if (playerLoc2 != null) {
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("Secondary.Selection") + ":" + ChatColor.AQUA + " (" + playerLoc2.getBlockX() + ", " + playerLoc2.getBlockY() + ", "
|
||||
+ playerLoc2.getBlockZ() + ")");
|
||||
}
|
||||
return;
|
||||
case "chunk":
|
||||
smanager.selectChunk(player);
|
||||
return;
|
||||
case "worldedit":
|
||||
if (smanager.worldEdit(player)) {
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSuccess"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
case 2:
|
||||
int amount;
|
||||
try {
|
||||
amount = Integer.parseInt(args[1]);
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidAmount"));
|
||||
return;
|
||||
}
|
||||
switch (subcmd) {
|
||||
case "expand":
|
||||
smanager.modify(player, false, amount);
|
||||
return;
|
||||
case "shift":
|
||||
smanager.modify(player, true, amount);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
case 3:
|
||||
try {
|
||||
smanager.selectBySize(player, Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]));
|
||||
} catch (final Exception ex) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectionFail"));
|
||||
}
|
||||
return;
|
||||
default:
|
||||
if (args.length > 0) {
|
||||
String resName;
|
||||
String areaName;
|
||||
ClaimedResidence res = null;
|
||||
if (args.length > 1) {
|
||||
res = rmanager.getByName(args[0]);
|
||||
} else {
|
||||
res = rmanager.getByLoc(player.getLocation());
|
||||
}
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
resName = res.getName();
|
||||
CuboidArea area = null;
|
||||
if (args.length > 2) {
|
||||
area = res.getArea(args[1]);
|
||||
areaName = args[1];
|
||||
} else {
|
||||
areaName = res.getAreaIDbyLoc(player.getLocation());
|
||||
area = res.getArea(areaName);
|
||||
}
|
||||
if (area != null) {
|
||||
smanager.placeLoc1(player, area.getHighLoc());
|
||||
smanager.placeLoc2(player, area.getLowLoc());
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("SelectionArea", ChatColor.GOLD + areaName + ChatColor.GREEN + "." + ChatColor.GOLD + resName + ChatColor.GREEN));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("AreaNonExist"));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,34 +14,34 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandServer extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandServer(final ResidenceMain plugin) {
|
||||
super("server");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandServer(final ResidenceMain plugin) {
|
||||
super("server");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
if (!resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
res.getPermissions().setOwner("Server Land", false);
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("ResidenceOwnerChange", ChatColor.YELLOW + args[0] + ChatColor.GREEN + "." + ChatColor.YELLOW + "Server Land" + ChatColor.GREEN));
|
||||
if (!resadmin) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
res.getPermissions().setOwner("Server Land", false);
|
||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("ResidenceOwnerChange", ChatColor.YELLOW + args[0] + ChatColor.GREEN + "." + ChatColor.YELLOW + "Server Land" + ChatColor.GREEN));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,38 +14,38 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandSet extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandSet(final ResidenceMain plugin) {
|
||||
super("set");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<residence> [flag] [true/false/remove]");
|
||||
}
|
||||
public CommandSet(final ResidenceMain plugin) {
|
||||
super("set");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<residence> [flag] [true/false/remove]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
if (args.length == 2) {
|
||||
final String res = rmanager.getNameByLoc(player.getLocation());
|
||||
if (res != null) {
|
||||
rmanager.getByName(res).getPermissions().setFlag(player, args[0], args[1], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
} else if (args.length == 3) {
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
if (res != null) {
|
||||
res.getPermissions().setFlag(player, args[1], args[2], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args.length == 2) {
|
||||
final String res = rmanager.getNameByLoc(player.getLocation());
|
||||
if (res != null) {
|
||||
rmanager.getByName(res).getPermissions().setFlag(player, args[0], args[1], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
} else if (args.length == 3) {
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
if (res != null) {
|
||||
res.getPermissions().setFlag(player, args[1], args[2], resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,36 +13,36 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandSetOwner extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandSetOwner(final ResidenceMain plugin) {
|
||||
super("setowner");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setPossibleArguments("[领地名] [玩家]");
|
||||
}
|
||||
public CommandSetOwner(final ResidenceMain plugin) {
|
||||
super("setowner");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(2);
|
||||
setPossibleArguments("[领地名] [玩家]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
if (!resadmin) {
|
||||
sender.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
}
|
||||
final ClaimedResidence area = rmanager.getByName(args[0]);
|
||||
if (area != null) {
|
||||
area.getPermissions().setOwner(args[1], true);
|
||||
if (area.getParent() == null) {
|
||||
sender.sendMessage(
|
||||
ChatColor.GREEN + language.getPhrase("ResidenceOwnerChange", ChatColor.YELLOW + " " + args[0] + " " + ChatColor.GREEN + "." + ChatColor.YELLOW + args[1] + ChatColor.GREEN));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GREEN + language.getPhrase("SubzoneOwnerChange",
|
||||
ChatColor.YELLOW + " " + args[0].split("\\.")[args[1].split("\\.").length - 1] + " " + ChatColor.GREEN + "." + ChatColor.YELLOW + args[1] + ChatColor.GREEN));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
if (!resadmin) {
|
||||
sender.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
}
|
||||
final ClaimedResidence area = rmanager.getByName(args[0]);
|
||||
if (area != null) {
|
||||
area.getPermissions().setOwner(args[1], true);
|
||||
if (area.getParent() == null) {
|
||||
sender.sendMessage(
|
||||
ChatColor.GREEN + language.getPhrase("ResidenceOwnerChange", ChatColor.YELLOW + " " + args[0] + " " + ChatColor.GREEN + "." + ChatColor.YELLOW + args[1] + ChatColor.GREEN));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GREEN + language.getPhrase("SubzoneOwnerChange",
|
||||
ChatColor.YELLOW + " " + args[0].split("\\.")[args[1].split("\\.").length - 1] + " " + ChatColor.GREEN + "." + ChatColor.YELLOW + args[1] + ChatColor.GREEN));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,41 +14,41 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandSubList extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandSubList(final ResidenceMain plugin) {
|
||||
super("sublist");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandSubList(final ResidenceMain plugin) {
|
||||
super("sublist");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
if (args.length == 1 || args.length == 2) {
|
||||
ClaimedResidence res;
|
||||
if (args.length == 0) {
|
||||
res = rmanager.getByLoc(player.getLocation());
|
||||
} else {
|
||||
res = rmanager.getByName(args[0]);
|
||||
}
|
||||
if (res != null) {
|
||||
res.printSubzoneList(player, page);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
int page = 1;
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
if (args.length == 1 || args.length == 2) {
|
||||
ClaimedResidence res;
|
||||
if (args.length == 0) {
|
||||
res = rmanager.getByLoc(player.getLocation());
|
||||
} else {
|
||||
res = rmanager.getByName(args[0]);
|
||||
}
|
||||
if (res != null) {
|
||||
res.printSubzoneList(player, page);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,51 +17,51 @@ import cn.citycraft.Residence.selection.SelectionManager;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandSubZone extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandSubZone(final ResidenceMain plugin) {
|
||||
super("subzone", "sz");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名> [附属领地名]");
|
||||
}
|
||||
public CommandSubZone(final ResidenceMain plugin) {
|
||||
super("subzone", "sz");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
setPossibleArguments("<领地名> [附属领地名]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final SelectionManager smanager = plugin.getSelectionManager();
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
return;
|
||||
}
|
||||
String zname;
|
||||
String parent;
|
||||
if (args.length == 1) {
|
||||
parent = rmanager.getNameByLoc(player.getLocation());
|
||||
zname = args[0];
|
||||
} else {
|
||||
parent = args[0];
|
||||
zname = args[1];
|
||||
}
|
||||
final WorldEditPlugin wep = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
if (wep != null) {
|
||||
if (wep.getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
||||
smanager.worldEdit(player);
|
||||
}
|
||||
}
|
||||
if (smanager.hasPlacedBoth(player.getName())) {
|
||||
final ClaimedResidence res = rmanager.getByName(parent);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
res.addSubzone(player, smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName()), zname, resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final SelectionManager smanager = plugin.getSelectionManager();
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
return;
|
||||
}
|
||||
String zname;
|
||||
String parent;
|
||||
if (args.length == 1) {
|
||||
parent = rmanager.getNameByLoc(player.getLocation());
|
||||
zname = args[0];
|
||||
} else {
|
||||
parent = args[0];
|
||||
zname = args[1];
|
||||
}
|
||||
final WorldEditPlugin wep = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
if (wep != null) {
|
||||
if (wep.getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
||||
smanager.worldEdit(player);
|
||||
}
|
||||
}
|
||||
if (smanager.hasPlacedBoth(player.getName())) {
|
||||
final ClaimedResidence res = rmanager.getByName(parent);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
res.addSubzone(player, smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName()), zname, resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,23 +13,23 @@ import cn.citycraft.Residence.manager.ConfigManager;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandTool extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandTool(final ResidenceMain plugin) {
|
||||
super("tool");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandTool(final ResidenceMain plugin) {
|
||||
super("tool");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final Language language = plugin.getLanguage();
|
||||
final ConfigManager cmanager = plugin.getConfigManager();
|
||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("SelectionTool") + ":" + ChatColor.GREEN + Material.getMaterial(cmanager.getSelectionTooldID()));
|
||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("InfoTool") + ": " + ChatColor.GREEN + Material.getMaterial(cmanager.getInfoToolID()));
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final Language language = plugin.getLanguage();
|
||||
final ConfigManager cmanager = plugin.getConfigManager();
|
||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("SelectionTool") + ":" + ChatColor.GREEN + Material.getMaterial(cmanager.getSelectionTooldID()));
|
||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("InfoTool") + ": " + ChatColor.GREEN + Material.getMaterial(cmanager.getInfoToolID()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,27 +14,27 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandTp extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandTp(final ResidenceMain plugin) {
|
||||
super("tp");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandTp(final ResidenceMain plugin) {
|
||||
super("tp");
|
||||
this.plugin = plugin;
|
||||
setMinimumArguments(1);
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
res.tpToResidence(player, player, resadmin);
|
||||
}
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
res.tpToResidence(player, player, resadmin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,28 +14,28 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandTpSet extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandTpSet(final ResidenceMain plugin) {
|
||||
super("tpset");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandTpSet(final ResidenceMain plugin) {
|
||||
super("tpset");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final boolean resadmin = (command != null);
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
|
||||
final ClaimedResidence res = rmanager.getByLoc(player.getLocation());
|
||||
if (res != null) {
|
||||
res.setTpLoc(player, resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
}
|
||||
final ClaimedResidence res = rmanager.getByLoc(player.getLocation());
|
||||
if (res != null) {
|
||||
res.setTpLoc(player, resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,33 +16,33 @@ import cn.citycraft.Residence.permissions.PermissionManager;
|
||||
import cn.citycraft.Residence.text.Language;
|
||||
|
||||
public class CommandUnStuck extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandUnStuck(final ResidenceMain plugin) {
|
||||
super("unstuck");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
public CommandUnStuck(final ResidenceMain plugin) {
|
||||
super("unstuck");
|
||||
this.plugin = plugin;
|
||||
setOnlyPlayerExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final PermissionManager gmanager = plugin.getPermissionManager();
|
||||
final PermissionGroup group = gmanager.getGroup(player);
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final Player player = (Player) sender;
|
||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||
final Language language = plugin.getLanguage();
|
||||
final PermissionManager gmanager = plugin.getPermissionManager();
|
||||
final PermissionGroup group = gmanager.getGroup(player);
|
||||
|
||||
if (!group.hasUnstuckAccess()) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = rmanager.getByLoc(player.getLocation());
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NotInResidence"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("Moved") + "...");
|
||||
player.teleport(res.getOutsideFreeLoc(player.getLocation()));
|
||||
}
|
||||
}
|
||||
if (!group.hasUnstuckAccess()) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = rmanager.getByLoc(player.getLocation());
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + language.getPhrase("NotInResidence"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("Moved") + "...");
|
||||
player.teleport(res.getOutsideFreeLoc(player.getLocation()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,33 +11,33 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class CommandVersion extends BaseCommand {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public CommandVersion(ResidenceMain plugin) {
|
||||
super("version");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public CommandVersion(ResidenceMain 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 + "------------------------------------");
|
||||
}
|
||||
@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 + "------------------------------------");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,9 +2,14 @@ package cn.citycraft.Residence.economy;
|
||||
|
||||
public interface EconomyInterface {
|
||||
public double getBalance(String playerName);
|
||||
|
||||
public boolean canAfford(String playerName, double amount);
|
||||
|
||||
public boolean add(String playerName, double amount);
|
||||
|
||||
public boolean subtract(String playerName, double amount);
|
||||
|
||||
public boolean transfer(String playerFrom, String playerTo, double amount);
|
||||
|
||||
public String getName();
|
||||
}
|
||||
|
||||
@@ -16,90 +16,90 @@ import com.earth2me.essentials.api.UserDoesNotExistException;
|
||||
*/
|
||||
public class EssentialsEcoAdapter implements EconomyInterface {
|
||||
|
||||
Essentials plugin;
|
||||
Essentials plugin;
|
||||
|
||||
public EssentialsEcoAdapter(final Essentials p) {
|
||||
plugin = p;
|
||||
final String serverland = "Server Land";
|
||||
if (!Economy.playerExists(serverland)) {
|
||||
Economy.createNPC(serverland);
|
||||
}
|
||||
}
|
||||
public EssentialsEcoAdapter(final Essentials p) {
|
||||
plugin = p;
|
||||
final String serverland = "Server Land";
|
||||
if (!Economy.playerExists(serverland)) {
|
||||
Economy.createNPC(serverland);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(final String playerName, final double amount) {
|
||||
if (Economy.playerExists(playerName)) {
|
||||
try {
|
||||
Economy.add(playerName, amount);
|
||||
return true;
|
||||
} catch (final UserDoesNotExistException ex) {
|
||||
return false;
|
||||
} catch (final NoLoanPermittedException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean add(final String playerName, final double amount) {
|
||||
if (Economy.playerExists(playerName)) {
|
||||
try {
|
||||
Economy.add(playerName, amount);
|
||||
return true;
|
||||
} catch (final UserDoesNotExistException ex) {
|
||||
return false;
|
||||
} catch (final NoLoanPermittedException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAfford(final String playerName, final double amount) {
|
||||
try {
|
||||
if (Economy.playerExists(playerName)) {
|
||||
return Economy.hasEnough(playerName, amount);
|
||||
}
|
||||
return false;
|
||||
} catch (final UserDoesNotExistException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean canAfford(final String playerName, final double amount) {
|
||||
try {
|
||||
if (Economy.playerExists(playerName)) {
|
||||
return Economy.hasEnough(playerName, amount);
|
||||
}
|
||||
return false;
|
||||
} catch (final UserDoesNotExistException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(final String playerName) {
|
||||
try {
|
||||
if (Economy.playerExists(playerName)) {
|
||||
return Economy.getMoney(playerName);
|
||||
}
|
||||
} catch (final UserDoesNotExistException ex) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public double getBalance(final String playerName) {
|
||||
try {
|
||||
if (Economy.playerExists(playerName)) {
|
||||
return Economy.getMoney(playerName);
|
||||
}
|
||||
} catch (final UserDoesNotExistException ex) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "EssentialsEconomy";
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return "EssentialsEconomy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean subtract(final String playerName, final double amount) {
|
||||
if (Economy.playerExists(playerName)) {
|
||||
try {
|
||||
Economy.subtract(playerName, amount);
|
||||
return true;
|
||||
} catch (final UserDoesNotExistException ex) {
|
||||
return false;
|
||||
} catch (final NoLoanPermittedException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean subtract(final String playerName, final double amount) {
|
||||
if (Economy.playerExists(playerName)) {
|
||||
try {
|
||||
Economy.subtract(playerName, amount);
|
||||
return true;
|
||||
} catch (final UserDoesNotExistException ex) {
|
||||
return false;
|
||||
} catch (final NoLoanPermittedException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean transfer(final String playerFrom, final String playerTo, final double amount) {
|
||||
try {
|
||||
if (Economy.playerExists(playerFrom) && Economy.playerExists(playerTo) && Economy.hasEnough(playerFrom, amount)) {
|
||||
if (!subtract(playerFrom, amount))
|
||||
return false;
|
||||
if (!add(playerTo, amount)) {
|
||||
add(playerFrom, amount);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (final UserDoesNotExistException ex) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean transfer(final String playerFrom, final String playerTo, final double amount) {
|
||||
try {
|
||||
if (Economy.playerExists(playerFrom) && Economy.playerExists(playerTo) && Economy.hasEnough(playerFrom, amount)) {
|
||||
if (!subtract(playerFrom, amount))
|
||||
return false;
|
||||
if (!add(playerTo, amount)) {
|
||||
add(playerFrom, amount);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (final UserDoesNotExistException ex) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,75 +17,75 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class ResidenceBank {
|
||||
ResidenceMain plugin;
|
||||
ClaimedResidence res;
|
||||
int storedMoney;
|
||||
ResidenceMain plugin;
|
||||
ClaimedResidence res;
|
||||
int storedMoney;
|
||||
|
||||
public ResidenceBank(final ResidenceMain plugin, final ClaimedResidence parent) {
|
||||
this.plugin = plugin;
|
||||
storedMoney = 0;
|
||||
res = parent;
|
||||
}
|
||||
public ResidenceBank(final ResidenceMain plugin, final ClaimedResidence parent) {
|
||||
this.plugin = plugin;
|
||||
storedMoney = 0;
|
||||
res = parent;
|
||||
}
|
||||
|
||||
public void add(final int amount) {
|
||||
storedMoney = storedMoney + amount;
|
||||
}
|
||||
public void add(final int amount) {
|
||||
storedMoney = storedMoney + amount;
|
||||
}
|
||||
|
||||
public void deposit(final Player player, final int amount, final boolean resadmin) {
|
||||
if (!plugin.getConfigManager().enableEconomy()) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
}
|
||||
if (!resadmin && !res.getPermissions().playerHas(player.getName(), "bank", false)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoBankAccess"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getEconomyManager().canAfford(player.getName(), amount)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getEconomyManager().subtract(player.getName(), amount)) {
|
||||
this.add(amount);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("BankDeposit", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN));
|
||||
}
|
||||
}
|
||||
public void deposit(final Player player, final int amount, final boolean resadmin) {
|
||||
if (!plugin.getConfigManager().enableEconomy()) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
}
|
||||
if (!resadmin && !res.getPermissions().playerHas(player.getName(), "bank", false)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoBankAccess"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getEconomyManager().canAfford(player.getName(), amount)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getEconomyManager().subtract(player.getName(), amount)) {
|
||||
this.add(amount);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("BankDeposit", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN));
|
||||
}
|
||||
}
|
||||
|
||||
public int getStoredMoney() {
|
||||
return storedMoney;
|
||||
}
|
||||
public int getStoredMoney() {
|
||||
return storedMoney;
|
||||
}
|
||||
|
||||
public boolean hasEnough(final int amount) {
|
||||
if (storedMoney >= amount) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean hasEnough(final int amount) {
|
||||
if (storedMoney >= amount) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setStoredMoney(final int amount) {
|
||||
storedMoney = amount;
|
||||
}
|
||||
public void setStoredMoney(final int amount) {
|
||||
storedMoney = amount;
|
||||
}
|
||||
|
||||
public void subtract(final int amount) {
|
||||
storedMoney = storedMoney - amount;
|
||||
if (storedMoney < 0) {
|
||||
storedMoney = 0;
|
||||
}
|
||||
}
|
||||
public void subtract(final int amount) {
|
||||
storedMoney = storedMoney - amount;
|
||||
if (storedMoney < 0) {
|
||||
storedMoney = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void withdraw(final Player player, final int amount, final boolean resadmin) {
|
||||
if (!plugin.getConfigManager().enableEconomy()) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
}
|
||||
if (!resadmin && !res.getPermissions().playerHas(player.getName(), "bank", false)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoBankAccess"));
|
||||
return;
|
||||
}
|
||||
if (!hasEnough(amount)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("BankNoMoney"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getEconomyManager().add(player.getName(), amount)) {
|
||||
this.subtract(amount);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("BankWithdraw", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN));
|
||||
}
|
||||
}
|
||||
public void withdraw(final Player player, final int amount, final boolean resadmin) {
|
||||
if (!plugin.getConfigManager().enableEconomy()) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
}
|
||||
if (!resadmin && !res.getPermissions().playerHas(player.getName(), "bank", false)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoBankAccess"));
|
||||
return;
|
||||
}
|
||||
if (!hasEnough(amount)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("BankNoMoney"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getEconomyManager().add(player.getName(), amount)) {
|
||||
this.subtract(amount);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("BankWithdraw", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,245 +28,245 @@ import cn.citycraft.Residence.permissions.PermissionManager;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class TransactionManager {
|
||||
private Map<String, Integer> sellAmount;
|
||||
PermissionManager gmanager;
|
||||
ResidenceManager manager;
|
||||
ResidenceMain plugin;
|
||||
private Map<String, Integer> sellAmount;
|
||||
PermissionManager gmanager;
|
||||
ResidenceManager manager;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public TransactionManager(final ResidenceMain plugin, final ResidenceManager m, final PermissionManager g) {
|
||||
this.plugin = plugin;
|
||||
gmanager = g;
|
||||
manager = m;
|
||||
sellAmount = Collections.synchronizedMap(new HashMap<String, Integer>());
|
||||
}
|
||||
public TransactionManager(final ResidenceMain plugin, final ResidenceManager m, final PermissionManager g) {
|
||||
this.plugin = plugin;
|
||||
gmanager = g;
|
||||
manager = m;
|
||||
sellAmount = Collections.synchronizedMap(new HashMap<String, Integer>());
|
||||
}
|
||||
|
||||
public static boolean chargeEconomyMoney(final ResidenceMain plugin, final Player player, final int amount) {
|
||||
final EconomyInterface econ = plugin.getEconomyManager();
|
||||
if (econ == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
return false;
|
||||
}
|
||||
if (!econ.canAfford(player.getName(), amount)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
||||
return false;
|
||||
}
|
||||
econ.subtract(player.getName(), amount);
|
||||
player.sendMessage(ChatColor.GREEN
|
||||
+ plugin.getLanguage().getPhrase("MoneyCharged", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN + "." + ChatColor.YELLOW + econ.getName() + ChatColor.GREEN));
|
||||
return true;
|
||||
}
|
||||
public static boolean chargeEconomyMoney(final ResidenceMain plugin, final Player player, final int amount) {
|
||||
final EconomyInterface econ = plugin.getEconomyManager();
|
||||
if (econ == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
return false;
|
||||
}
|
||||
if (!econ.canAfford(player.getName(), amount)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
||||
return false;
|
||||
}
|
||||
econ.subtract(player.getName(), amount);
|
||||
player.sendMessage(ChatColor.GREEN
|
||||
+ plugin.getLanguage().getPhrase("MoneyCharged", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN + "." + ChatColor.YELLOW + econ.getName() + ChatColor.GREEN));
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static TransactionManager load(final ResidenceMain plugin, final Map root, final PermissionManager p, final ResidenceManager r) {
|
||||
final TransactionManager tman = new TransactionManager(plugin, r, p);
|
||||
if (root != null) {
|
||||
tman.sellAmount = root;
|
||||
}
|
||||
return tman;
|
||||
}
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static TransactionManager load(final ResidenceMain plugin, final Map root, final PermissionManager p, final ResidenceManager r) {
|
||||
final TransactionManager tman = new TransactionManager(plugin, r, p);
|
||||
if (root != null) {
|
||||
tman.sellAmount = root;
|
||||
}
|
||||
return tman;
|
||||
}
|
||||
|
||||
public void buyPlot(final String areaname, final Player player, final boolean resadmin) {
|
||||
final PermissionGroup group = gmanager.getGroup(player);
|
||||
if (!resadmin) {
|
||||
if (!plugin.getConfigManager().enableEconomy() || plugin.getEconomyManager() == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
return;
|
||||
}
|
||||
final boolean canbuy = group.canBuyLand() || player.hasPermission("plugin.buy");
|
||||
if (!canbuy && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isForSale(areaname)) {
|
||||
final ClaimedResidence res = manager.getByName(areaname);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidArea"));
|
||||
sellAmount.remove(areaname);
|
||||
return;
|
||||
}
|
||||
if (res.getPermissions().getOwner().equals(player.getName())) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("OwnerBuyFail"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getResidenceManager().getOwnedZoneCount(player.getName()) >= group.getMaxZones() && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceTooMany"));
|
||||
return;
|
||||
}
|
||||
final int amount = sellAmount.get(areaname);
|
||||
if (!resadmin) {
|
||||
if (!group.buyLandIgnoreLimits()) {
|
||||
final CuboidArea[] areas = res.getAreaArray();
|
||||
for (final CuboidArea thisarea : areas) {
|
||||
if (!group.inLimits(thisarea)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceBuyTooBig"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final EconomyInterface econ = plugin.getEconomyManager();
|
||||
if (econ == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
return;
|
||||
}
|
||||
final String buyerName = player.getName();
|
||||
String sellerName = res.getPermissions().getOwner();
|
||||
final Player sellerNameFix = plugin.getServer().getPlayer(sellerName);
|
||||
if (sellerNameFix != null) {
|
||||
sellerName = sellerNameFix.getName();
|
||||
}
|
||||
if (econ.canAfford(buyerName, amount)) {
|
||||
if (!econ.transfer(buyerName, sellerName, amount)) {
|
||||
player.sendMessage(ChatColor.RED + "Error, could not transfer " + amount + " from " + buyerName + " to " + sellerName);
|
||||
return;
|
||||
}
|
||||
res.getPermissions().setOwner(player.getName(), true);
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
this.removeFromSale(areaname);
|
||||
player.sendMessage(ChatColor.GREEN
|
||||
+ plugin.getLanguage().getPhrase("MoneyCharged", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN + "." + ChatColor.YELLOW + econ.getName() + ChatColor.GREEN));
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceBought", ChatColor.GREEN + areaname + ChatColor.YELLOW));
|
||||
final Player seller = plugin.getServer().getPlayer(sellerName);
|
||||
if (seller != null && seller.isOnline()) {
|
||||
seller.sendMessage(ChatColor.GREEN
|
||||
+ plugin.getLanguage().getPhrase("ResidenceBuy", ChatColor.YELLOW + player.getName() + ChatColor.GREEN + "." + ChatColor.YELLOW + areaname + ChatColor.GREEN));
|
||||
seller.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("MoneyCredit",
|
||||
ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN + "." + ChatColor.YELLOW + econ.getName() + ChatColor.GREEN));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||
}
|
||||
}
|
||||
public void buyPlot(final String areaname, final Player player, final boolean resadmin) {
|
||||
final PermissionGroup group = gmanager.getGroup(player);
|
||||
if (!resadmin) {
|
||||
if (!plugin.getConfigManager().enableEconomy() || plugin.getEconomyManager() == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
return;
|
||||
}
|
||||
final boolean canbuy = group.canBuyLand() || player.hasPermission("plugin.buy");
|
||||
if (!canbuy && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isForSale(areaname)) {
|
||||
final ClaimedResidence res = manager.getByName(areaname);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidArea"));
|
||||
sellAmount.remove(areaname);
|
||||
return;
|
||||
}
|
||||
if (res.getPermissions().getOwner().equals(player.getName())) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("OwnerBuyFail"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getResidenceManager().getOwnedZoneCount(player.getName()) >= group.getMaxZones() && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceTooMany"));
|
||||
return;
|
||||
}
|
||||
final int amount = sellAmount.get(areaname);
|
||||
if (!resadmin) {
|
||||
if (!group.buyLandIgnoreLimits()) {
|
||||
final CuboidArea[] areas = res.getAreaArray();
|
||||
for (final CuboidArea thisarea : areas) {
|
||||
if (!group.inLimits(thisarea)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceBuyTooBig"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final EconomyInterface econ = plugin.getEconomyManager();
|
||||
if (econ == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
return;
|
||||
}
|
||||
final String buyerName = player.getName();
|
||||
String sellerName = res.getPermissions().getOwner();
|
||||
final Player sellerNameFix = plugin.getServer().getPlayer(sellerName);
|
||||
if (sellerNameFix != null) {
|
||||
sellerName = sellerNameFix.getName();
|
||||
}
|
||||
if (econ.canAfford(buyerName, amount)) {
|
||||
if (!econ.transfer(buyerName, sellerName, amount)) {
|
||||
player.sendMessage(ChatColor.RED + "Error, could not transfer " + amount + " from " + buyerName + " to " + sellerName);
|
||||
return;
|
||||
}
|
||||
res.getPermissions().setOwner(player.getName(), true);
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
this.removeFromSale(areaname);
|
||||
player.sendMessage(ChatColor.GREEN
|
||||
+ plugin.getLanguage().getPhrase("MoneyCharged", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN + "." + ChatColor.YELLOW + econ.getName() + ChatColor.GREEN));
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceBought", ChatColor.GREEN + areaname + ChatColor.YELLOW));
|
||||
final Player seller = plugin.getServer().getPlayer(sellerName);
|
||||
if (seller != null && seller.isOnline()) {
|
||||
seller.sendMessage(ChatColor.GREEN
|
||||
+ plugin.getLanguage().getPhrase("ResidenceBuy", ChatColor.YELLOW + player.getName() + ChatColor.GREEN + "." + ChatColor.YELLOW + areaname + ChatColor.GREEN));
|
||||
seller.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("MoneyCredit",
|
||||
ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN + "." + ChatColor.YELLOW + econ.getName() + ChatColor.GREEN));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||
}
|
||||
}
|
||||
|
||||
public void clearSales() {
|
||||
sellAmount.clear();
|
||||
System.out.println("[Residence] - ReInit land selling.");
|
||||
}
|
||||
public void clearSales() {
|
||||
sellAmount.clear();
|
||||
System.out.println("[Residence] - ReInit land selling.");
|
||||
}
|
||||
|
||||
public int getSaleAmount(final String name) {
|
||||
return sellAmount.get(name);
|
||||
}
|
||||
public int getSaleAmount(final String name) {
|
||||
return sellAmount.get(name);
|
||||
}
|
||||
|
||||
public boolean isForSale(final String areaname) {
|
||||
return sellAmount.containsKey(areaname);
|
||||
}
|
||||
public boolean isForSale(final String areaname) {
|
||||
return sellAmount.containsKey(areaname);
|
||||
}
|
||||
|
||||
public void printForSaleResidences(final Player player) {
|
||||
final Set<Entry<String, Integer>> set = sellAmount.entrySet();
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("LandForSale") + ":");
|
||||
final StringBuilder sbuild = new StringBuilder();
|
||||
sbuild.append(ChatColor.GREEN);
|
||||
boolean firstadd = true;
|
||||
for (final Entry<String, Integer> land : set) {
|
||||
if (!firstadd) {
|
||||
sbuild.append(", ");
|
||||
} else {
|
||||
firstadd = false;
|
||||
}
|
||||
sbuild.append(land.getKey());
|
||||
}
|
||||
player.sendMessage(sbuild.toString());
|
||||
}
|
||||
public void printForSaleResidences(final Player player) {
|
||||
final Set<Entry<String, Integer>> set = sellAmount.entrySet();
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("LandForSale") + ":");
|
||||
final StringBuilder sbuild = new StringBuilder();
|
||||
sbuild.append(ChatColor.GREEN);
|
||||
boolean firstadd = true;
|
||||
for (final Entry<String, Integer> land : set) {
|
||||
if (!firstadd) {
|
||||
sbuild.append(", ");
|
||||
} else {
|
||||
firstadd = false;
|
||||
}
|
||||
sbuild.append(land.getKey());
|
||||
}
|
||||
player.sendMessage(sbuild.toString());
|
||||
}
|
||||
|
||||
public boolean putForSale(final String areaname, final int amount) {
|
||||
if (plugin.getConfigManager().enabledRentSystem()) {
|
||||
if (plugin.getRentManager().isForRent(areaname)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final ClaimedResidence area = manager.getByName(areaname);
|
||||
if (area == null) {
|
||||
return false;
|
||||
}
|
||||
if (sellAmount.containsKey(areaname)) {
|
||||
return false;
|
||||
}
|
||||
sellAmount.put(areaname, amount);
|
||||
return true;
|
||||
}
|
||||
public boolean putForSale(final String areaname, final int amount) {
|
||||
if (plugin.getConfigManager().enabledRentSystem()) {
|
||||
if (plugin.getRentManager().isForRent(areaname)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final ClaimedResidence area = manager.getByName(areaname);
|
||||
if (area == null) {
|
||||
return false;
|
||||
}
|
||||
if (sellAmount.containsKey(areaname)) {
|
||||
return false;
|
||||
}
|
||||
sellAmount.put(areaname, amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void putForSale(final String areaname, final Player player, final int amount, final boolean resadmin) {
|
||||
if (plugin.getConfigManager().enabledRentSystem()) {
|
||||
if (plugin.getRentManager().isForRent(areaname)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentSellFail"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!resadmin) {
|
||||
if (!plugin.getConfigManager().enableEconomy() || plugin.getEconomyManager() == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
return;
|
||||
}
|
||||
final boolean cansell = plugin.getPermissionManager().getGroup(player).canSellLand() || player.hasPermission("plugin.sell");
|
||||
if (!cansell && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
if (amount <= 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidAmount"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final String pname = player.getName();
|
||||
final ClaimedResidence area = manager.getByName(areaname);
|
||||
if (area == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (!area.getPermissions().getOwner().equals(pname) && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
if (sellAmount.containsKey(areaname)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("AlreadySellFail"));
|
||||
return;
|
||||
}
|
||||
sellAmount.put(areaname, amount);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceForSale", ChatColor.YELLOW + areaname + ChatColor.GREEN + "." + ChatColor.YELLOW + amount + ChatColor.GREEN));
|
||||
}
|
||||
public void putForSale(final String areaname, final Player player, final int amount, final boolean resadmin) {
|
||||
if (plugin.getConfigManager().enabledRentSystem()) {
|
||||
if (plugin.getRentManager().isForRent(areaname)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentSellFail"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!resadmin) {
|
||||
if (!plugin.getConfigManager().enableEconomy() || plugin.getEconomyManager() == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
return;
|
||||
}
|
||||
final boolean cansell = plugin.getPermissionManager().getGroup(player).canSellLand() || player.hasPermission("plugin.sell");
|
||||
if (!cansell && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
if (amount <= 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidAmount"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final String pname = player.getName();
|
||||
final ClaimedResidence area = manager.getByName(areaname);
|
||||
if (area == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (!area.getPermissions().getOwner().equals(pname) && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
if (sellAmount.containsKey(areaname)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("AlreadySellFail"));
|
||||
return;
|
||||
}
|
||||
sellAmount.put(areaname, amount);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceForSale", ChatColor.YELLOW + areaname + ChatColor.GREEN + "." + ChatColor.YELLOW + amount + ChatColor.GREEN));
|
||||
}
|
||||
|
||||
public void removeFromSale(final Player player, final String areaname, final boolean resadmin) {
|
||||
final ClaimedResidence area = manager.getByName(areaname);
|
||||
if (area != null) {
|
||||
if (!isForSale(areaname)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForSale"));
|
||||
return;
|
||||
}
|
||||
if (area.getPermissions().getOwner().equals(player.getName()) || resadmin) {
|
||||
removeFromSale(areaname);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceStopSelling"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidArea"));
|
||||
}
|
||||
}
|
||||
public void removeFromSale(final Player player, final String areaname, final boolean resadmin) {
|
||||
final ClaimedResidence area = manager.getByName(areaname);
|
||||
if (area != null) {
|
||||
if (!isForSale(areaname)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForSale"));
|
||||
return;
|
||||
}
|
||||
if (area.getPermissions().getOwner().equals(player.getName()) || resadmin) {
|
||||
removeFromSale(areaname);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceStopSelling"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidArea"));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFromSale(final String areaname) {
|
||||
sellAmount.remove(areaname);
|
||||
}
|
||||
public void removeFromSale(final String areaname) {
|
||||
sellAmount.remove(areaname);
|
||||
}
|
||||
|
||||
public Map<String, Integer> save() {
|
||||
return sellAmount;
|
||||
}
|
||||
public Map<String, Integer> save() {
|
||||
return sellAmount;
|
||||
}
|
||||
|
||||
public void viewSaleInfo(final String areaname, final Player player) {
|
||||
if (sellAmount.containsKey(areaname)) {
|
||||
player.sendMessage("------------------------");
|
||||
player.sendMessage(ChatColor.YELLOW + "Name:" + ChatColor.DARK_GREEN + " " + areaname);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("SellAmount") + ":" + ChatColor.RED + " " + sellAmount.get(areaname));
|
||||
if (plugin.getConfigManager().useLeases()) {
|
||||
final Date etime = plugin.getLeaseManager().getExpireTime(areaname);
|
||||
if (etime != null) {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("LeaseExpire") + ":" + ChatColor.GREEN + " " + etime.toString());
|
||||
}
|
||||
}
|
||||
player.sendMessage("------------------------");
|
||||
}
|
||||
}
|
||||
public void viewSaleInfo(final String areaname, final Player player) {
|
||||
if (sellAmount.containsKey(areaname)) {
|
||||
player.sendMessage("------------------------");
|
||||
player.sendMessage(ChatColor.YELLOW + "Name:" + ChatColor.DARK_GREEN + " " + areaname);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("SellAmount") + ":" + ChatColor.RED + " " + sellAmount.get(areaname));
|
||||
if (plugin.getConfigManager().useLeases()) {
|
||||
final Date etime = plugin.getLeaseManager().getExpireTime(areaname);
|
||||
if (etime != null) {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("LeaseExpire") + ":" + ChatColor.GREEN + " " + etime.toString());
|
||||
}
|
||||
}
|
||||
player.sendMessage("------------------------");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,411 +29,411 @@ import cn.citycraft.Residence.permissions.PermissionGroup;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class RentManager {
|
||||
protected ResidenceMain plugin;
|
||||
protected PluginManager pm;
|
||||
protected Map<String, RentableLand> rentableLand;
|
||||
protected Map<String, RentedLand> rentedLand;
|
||||
protected ResidenceMain plugin;
|
||||
protected PluginManager pm;
|
||||
protected Map<String, RentableLand> rentableLand;
|
||||
protected Map<String, RentedLand> rentedLand;
|
||||
|
||||
public RentManager(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
pm = plugin.getServer().getPluginManager();
|
||||
rentedLand = new HashMap<String, RentedLand>();
|
||||
rentableLand = new HashMap<String, RentableLand>();
|
||||
}
|
||||
public RentManager(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
pm = plugin.getServer().getPluginManager();
|
||||
rentedLand = new HashMap<String, RentedLand>();
|
||||
rentableLand = new HashMap<String, RentableLand>();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static RentManager load(final ResidenceMain plugin, final Map<String, Object> root) {
|
||||
final RentManager rentManager = new RentManager(plugin);
|
||||
if (root != null) {
|
||||
final Map<String, Object> rentables = (Map<String, Object>) root.get("Rentables");
|
||||
for (final Entry<String, Object> rent : rentables.entrySet()) {
|
||||
rentManager.rentableLand.put(rent.getKey(), RentableLand.load((Map<String, Object>) rent.getValue()));
|
||||
}
|
||||
final Map<String, Object> rented = (Map<String, Object>) root.get("Rented");
|
||||
for (final Entry<String, Object> rent : rented.entrySet()) {
|
||||
rentManager.rentedLand.put(rent.getKey(), RentedLand.load((Map<String, Object>) rent.getValue()));
|
||||
}
|
||||
}
|
||||
return rentManager;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public static RentManager load(final ResidenceMain plugin, final Map<String, Object> root) {
|
||||
final RentManager rentManager = new RentManager(plugin);
|
||||
if (root != null) {
|
||||
final Map<String, Object> rentables = (Map<String, Object>) root.get("Rentables");
|
||||
for (final Entry<String, Object> rent : rentables.entrySet()) {
|
||||
rentManager.rentableLand.put(rent.getKey(), RentableLand.load((Map<String, Object>) rent.getValue()));
|
||||
}
|
||||
final Map<String, Object> rented = (Map<String, Object>) root.get("Rented");
|
||||
for (final Entry<String, Object> rent : rented.entrySet()) {
|
||||
rentManager.rentedLand.put(rent.getKey(), RentedLand.load((Map<String, Object>) rent.getValue()));
|
||||
}
|
||||
}
|
||||
return rentManager;
|
||||
}
|
||||
|
||||
public void checkCurrentRents() {
|
||||
final Iterator<Entry<String, RentedLand>> it = rentedLand.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
final Entry<String, RentedLand> next = it.next();
|
||||
final RentedLand land = next.getValue();
|
||||
if (land.endTime <= System.currentTimeMillis()) {
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(next.getKey());
|
||||
if (plugin.getConfigManager().debugEnabled()) {
|
||||
System.out.println("Rent Check: " + next.getKey());
|
||||
}
|
||||
if (res != null) {
|
||||
final ResidenceRentEvent revent = new ResidenceRentEvent(res, null, RentEventType.RENT_EXPIRE);
|
||||
pm.callEvent(revent);
|
||||
if (!revent.isCancelled()) {
|
||||
final RentableLand rentable = rentableLand.get(next.getKey());
|
||||
if (!rentable.repeatable) {
|
||||
rentableLand.remove(next.getKey());
|
||||
it.remove();
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
} else if (land.autoRefresh) {
|
||||
if (!plugin.getEconomyManager().canAfford(land.player, rentable.cost)) {
|
||||
it.remove();
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
} else if (!plugin.getEconomyManager().transfer(land.player, res.getPermissions().getOwner(), rentable.cost)) {
|
||||
it.remove();
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
} else {
|
||||
land.endTime = System.currentTimeMillis() + this.daysToMs(rentable.days);
|
||||
}
|
||||
} else {
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rentableLand.remove(next.getKey());
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void checkCurrentRents() {
|
||||
final Iterator<Entry<String, RentedLand>> it = rentedLand.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
final Entry<String, RentedLand> next = it.next();
|
||||
final RentedLand land = next.getValue();
|
||||
if (land.endTime <= System.currentTimeMillis()) {
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(next.getKey());
|
||||
if (plugin.getConfigManager().debugEnabled()) {
|
||||
System.out.println("Rent Check: " + next.getKey());
|
||||
}
|
||||
if (res != null) {
|
||||
final ResidenceRentEvent revent = new ResidenceRentEvent(res, null, RentEventType.RENT_EXPIRE);
|
||||
pm.callEvent(revent);
|
||||
if (!revent.isCancelled()) {
|
||||
final RentableLand rentable = rentableLand.get(next.getKey());
|
||||
if (!rentable.repeatable) {
|
||||
rentableLand.remove(next.getKey());
|
||||
it.remove();
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
} else if (land.autoRefresh) {
|
||||
if (!plugin.getEconomyManager().canAfford(land.player, rentable.cost)) {
|
||||
it.remove();
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
} else if (!plugin.getEconomyManager().transfer(land.player, res.getPermissions().getOwner(), rentable.cost)) {
|
||||
it.remove();
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
} else {
|
||||
land.endTime = System.currentTimeMillis() + this.daysToMs(rentable.days);
|
||||
}
|
||||
} else {
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rentableLand.remove(next.getKey());
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getCostOfRent(final String landName) {
|
||||
return rentableLand.containsKey(landName) ? rentableLand.get(landName).cost : 0;
|
||||
}
|
||||
public int getCostOfRent(final String landName) {
|
||||
return rentableLand.containsKey(landName) ? rentableLand.get(landName).cost : 0;
|
||||
}
|
||||
|
||||
public int getRentableCount(final String player) {
|
||||
final Set<String> set = rentableLand.keySet();
|
||||
int count = 0;
|
||||
for (final String land : set) {
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(land);
|
||||
if (res != null) {
|
||||
if (res.getPermissions().getOwner().equalsIgnoreCase(player)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
public int getRentableCount(final String player) {
|
||||
final Set<String> set = rentableLand.keySet();
|
||||
int count = 0;
|
||||
for (final String land : set) {
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(land);
|
||||
if (res != null) {
|
||||
if (res.getPermissions().getOwner().equalsIgnoreCase(player)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public boolean getRentableRepeatable(final String landName) {
|
||||
return rentableLand.containsKey(landName) ? rentableLand.get(landName).repeatable : false;
|
||||
}
|
||||
public boolean getRentableRepeatable(final String landName) {
|
||||
return rentableLand.containsKey(landName) ? rentableLand.get(landName).repeatable : false;
|
||||
}
|
||||
|
||||
public int getRentCount(final String player) {
|
||||
final Set<Entry<String, RentedLand>> set = rentedLand.entrySet();
|
||||
int count = 0;
|
||||
for (final Entry<String, RentedLand> land : set) {
|
||||
if (land.getValue().player.equalsIgnoreCase(player)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
public int getRentCount(final String player) {
|
||||
final Set<Entry<String, RentedLand>> set = rentedLand.entrySet();
|
||||
int count = 0;
|
||||
for (final Entry<String, RentedLand> land : set) {
|
||||
if (land.getValue().player.equalsIgnoreCase(player)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public int getRentDays(final String landName) {
|
||||
return rentableLand.containsKey(landName) ? rentableLand.get(landName).days : 0;
|
||||
}
|
||||
public int getRentDays(final String landName) {
|
||||
return rentableLand.containsKey(landName) ? rentableLand.get(landName).days : 0;
|
||||
}
|
||||
|
||||
public boolean getRentedAutoRepeats(final String landName) {
|
||||
return getRentableRepeatable(landName) ? (rentedLand.containsKey(landName) ? rentedLand.get(landName).autoRefresh : false) : false;
|
||||
}
|
||||
public boolean getRentedAutoRepeats(final String landName) {
|
||||
return getRentableRepeatable(landName) ? (rentedLand.containsKey(landName) ? rentedLand.get(landName).autoRefresh : false) : false;
|
||||
}
|
||||
|
||||
public String getRentingPlayer(final String landName) {
|
||||
return rentedLand.containsKey(landName) ? rentedLand.get(landName).player : null;
|
||||
}
|
||||
public String getRentingPlayer(final String landName) {
|
||||
return rentedLand.containsKey(landName) ? rentedLand.get(landName).player : null;
|
||||
}
|
||||
|
||||
public boolean isForRent(final String landName) {
|
||||
return rentableLand.containsKey(landName);
|
||||
}
|
||||
public boolean isForRent(final String landName) {
|
||||
return rentableLand.containsKey(landName);
|
||||
}
|
||||
|
||||
public boolean isRented(final String landName) {
|
||||
return rentedLand.containsKey(landName);
|
||||
}
|
||||
public boolean isRented(final String landName) {
|
||||
return rentedLand.containsKey(landName);
|
||||
}
|
||||
|
||||
public void printRentableResidences(final Player player) {
|
||||
final Set<Entry<String, RentableLand>> set = rentableLand.entrySet();
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("RentableLand") + ":");
|
||||
final StringBuilder sbuild = new StringBuilder();
|
||||
sbuild.append(ChatColor.GREEN);
|
||||
boolean firstadd = true;
|
||||
for (final Entry<String, RentableLand> land : set) {
|
||||
if (!this.isRented(land.getKey())) {
|
||||
if (!firstadd) {
|
||||
sbuild.append(", ");
|
||||
} else {
|
||||
firstadd = false;
|
||||
}
|
||||
sbuild.append(land.getKey());
|
||||
}
|
||||
}
|
||||
player.sendMessage(sbuild.toString());
|
||||
}
|
||||
public void printRentableResidences(final Player player) {
|
||||
final Set<Entry<String, RentableLand>> set = rentableLand.entrySet();
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("RentableLand") + ":");
|
||||
final StringBuilder sbuild = new StringBuilder();
|
||||
sbuild.append(ChatColor.GREEN);
|
||||
boolean firstadd = true;
|
||||
for (final Entry<String, RentableLand> land : set) {
|
||||
if (!this.isRented(land.getKey())) {
|
||||
if (!firstadd) {
|
||||
sbuild.append(", ");
|
||||
} else {
|
||||
firstadd = false;
|
||||
}
|
||||
sbuild.append(land.getKey());
|
||||
}
|
||||
}
|
||||
player.sendMessage(sbuild.toString());
|
||||
}
|
||||
|
||||
public void printRentInfo(final Player player, final String landName) {
|
||||
final RentableLand rentable = rentableLand.get(landName);
|
||||
final RentedLand rented = rentedLand.get(landName);
|
||||
if (rentable != null) {
|
||||
player.sendMessage(ChatColor.GOLD + plugin.getLanguage().getPhrase("Land") + ":" + ChatColor.DARK_GREEN + landName);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Cost") + ": " + ChatColor.DARK_AQUA + rentable.cost + " per " + rentable.days + " days");
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("RentableAutoRenew") + ":" + ChatColor.DARK_AQUA + rentable.repeatable);
|
||||
if (rented != null) {
|
||||
player.sendMessage(ChatColor.GOLD + plugin.getLanguage().getPhrase("Status") + ":" + ChatColor.YELLOW + " "
|
||||
+ plugin.getLanguage().getPhrase("ResidenceRentedBy", ChatColor.RED + rented.player + ChatColor.YELLOW));
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("RentExpire") + ":" + ChatColor.GREEN + new Date(rented.endTime));
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("RentAutoRenew") + ":" + ChatColor.DARK_AQUA + rented.autoRefresh);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.GOLD + plugin.getLanguage().getPhrase("Status") + ":" + ChatColor.GREEN + " " + plugin.getLanguage().getPhrase("Available"));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForRent"));
|
||||
}
|
||||
}
|
||||
public void printRentInfo(final Player player, final String landName) {
|
||||
final RentableLand rentable = rentableLand.get(landName);
|
||||
final RentedLand rented = rentedLand.get(landName);
|
||||
if (rentable != null) {
|
||||
player.sendMessage(ChatColor.GOLD + plugin.getLanguage().getPhrase("Land") + ":" + ChatColor.DARK_GREEN + landName);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Cost") + ": " + ChatColor.DARK_AQUA + rentable.cost + " per " + rentable.days + " days");
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("RentableAutoRenew") + ":" + ChatColor.DARK_AQUA + rentable.repeatable);
|
||||
if (rented != null) {
|
||||
player.sendMessage(ChatColor.GOLD + plugin.getLanguage().getPhrase("Status") + ":" + ChatColor.YELLOW + " "
|
||||
+ plugin.getLanguage().getPhrase("ResidenceRentedBy", ChatColor.RED + rented.player + ChatColor.YELLOW));
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("RentExpire") + ":" + ChatColor.GREEN + new Date(rented.endTime));
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("RentAutoRenew") + ":" + ChatColor.DARK_AQUA + rented.autoRefresh);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.GOLD + plugin.getLanguage().getPhrase("Status") + ":" + ChatColor.GREEN + " " + plugin.getLanguage().getPhrase("Available"));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForRent"));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFromForRent(final Player player, final String landName, final boolean resadmin) {
|
||||
final RentedLand rent = rentedLand.get(landName);
|
||||
if (rent == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotRented"));
|
||||
return;
|
||||
}
|
||||
if (resadmin || rent.player.equalsIgnoreCase(player.getName())) {
|
||||
final ResidenceRentEvent revent = new ResidenceRentEvent(plugin.getResidenceManager().getByName(landName), player, RentEventType.UNRENTABLE);
|
||||
pm.callEvent(revent);
|
||||
if (revent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
rentedLand.remove(landName);
|
||||
if (!rentableLand.get(landName).repeatable) {
|
||||
rentableLand.remove(landName);
|
||||
}
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||
if (res != null) {
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceUnrent", ChatColor.YELLOW + landName + ChatColor.GREEN));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
}
|
||||
public void removeFromForRent(final Player player, final String landName, final boolean resadmin) {
|
||||
final RentedLand rent = rentedLand.get(landName);
|
||||
if (rent == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotRented"));
|
||||
return;
|
||||
}
|
||||
if (resadmin || rent.player.equalsIgnoreCase(player.getName())) {
|
||||
final ResidenceRentEvent revent = new ResidenceRentEvent(plugin.getResidenceManager().getByName(landName), player, RentEventType.UNRENTABLE);
|
||||
pm.callEvent(revent);
|
||||
if (revent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
rentedLand.remove(landName);
|
||||
if (!rentableLand.get(landName).repeatable) {
|
||||
rentableLand.remove(landName);
|
||||
}
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||
if (res != null) {
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceUnrent", ChatColor.YELLOW + landName + ChatColor.GREEN));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFromRent(final String landName) {
|
||||
rentedLand.remove(landName);
|
||||
}
|
||||
public void removeFromRent(final String landName) {
|
||||
rentedLand.remove(landName);
|
||||
}
|
||||
|
||||
public void removeRentable(final String landName) {
|
||||
removeFromRent(landName);
|
||||
rentableLand.remove(landName);
|
||||
}
|
||||
public void removeRentable(final String landName) {
|
||||
removeFromRent(landName);
|
||||
rentableLand.remove(landName);
|
||||
}
|
||||
|
||||
public void rent(final Player player, final String landName, final boolean repeat, final boolean resadmin) {
|
||||
if (!plugin.getConfigManager().enabledRentSystem()) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentDisabled"));
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||
if (res != null) {
|
||||
if (res.getPermissions().getOwner().equalsIgnoreCase(player.getName())) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("OwnerRentFail"));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
if (!resadmin && this.getRentCount(player.getName()) >= group.getMaxRents()) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMaxRent"));
|
||||
return;
|
||||
}
|
||||
if (!this.isForRent(landName)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForRent"));
|
||||
return;
|
||||
}
|
||||
if (this.isRented(landName)) {
|
||||
final String[] split = landName.split("\\.");
|
||||
if (split.length != 0) {
|
||||
player.sendMessage(plugin.getLanguage().getPhrase("ResidenceAlreadyRented",
|
||||
ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED + "." + ChatColor.YELLOW + this.getRentingPlayer(landName)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
final RentableLand land = rentableLand.get(landName);
|
||||
if (plugin.getEconomyManager().canAfford(player.getName(), land.cost)) {
|
||||
final ResidenceRentEvent revent = new ResidenceRentEvent(res, player, RentEventType.RENT);
|
||||
pm.callEvent(revent);
|
||||
if (revent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getEconomyManager().transfer(player.getName(), res.getPermissions().getOwner(), land.cost)) {
|
||||
final RentedLand newrent = new RentedLand();
|
||||
newrent.player = player.getName();
|
||||
newrent.startTime = System.currentTimeMillis();
|
||||
newrent.endTime = System.currentTimeMillis() + daysToMs(land.days);
|
||||
newrent.autoRefresh = repeat;
|
||||
rentedLand.put(landName, newrent);
|
||||
res.getPermissions().copyUserPermissions(res.getPermissions().getOwner(), player.getName());
|
||||
res.getPermissions().clearPlayersFlags(res.getPermissions().getOwner());
|
||||
res.getPermissions().setPlayerFlag(player.getName(), "admin", FlagState.TRUE);
|
||||
final String[] split = landName.split("\\.");
|
||||
if (split.length != 0) {
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceRentSuccess",
|
||||
ChatColor.YELLOW + split[split.length - 1] + ChatColor.GREEN + "." + ChatColor.YELLOW + land.days + ChatColor.GREEN));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Error, unable to transfer money...");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
||||
}
|
||||
}
|
||||
public void rent(final Player player, final String landName, final boolean repeat, final boolean resadmin) {
|
||||
if (!plugin.getConfigManager().enabledRentSystem()) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentDisabled"));
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||
if (res != null) {
|
||||
if (res.getPermissions().getOwner().equalsIgnoreCase(player.getName())) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("OwnerRentFail"));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
if (!resadmin && this.getRentCount(player.getName()) >= group.getMaxRents()) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMaxRent"));
|
||||
return;
|
||||
}
|
||||
if (!this.isForRent(landName)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForRent"));
|
||||
return;
|
||||
}
|
||||
if (this.isRented(landName)) {
|
||||
final String[] split = landName.split("\\.");
|
||||
if (split.length != 0) {
|
||||
player.sendMessage(plugin.getLanguage().getPhrase("ResidenceAlreadyRented",
|
||||
ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED + "." + ChatColor.YELLOW + this.getRentingPlayer(landName)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
final RentableLand land = rentableLand.get(landName);
|
||||
if (plugin.getEconomyManager().canAfford(player.getName(), land.cost)) {
|
||||
final ResidenceRentEvent revent = new ResidenceRentEvent(res, player, RentEventType.RENT);
|
||||
pm.callEvent(revent);
|
||||
if (revent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getEconomyManager().transfer(player.getName(), res.getPermissions().getOwner(), land.cost)) {
|
||||
final RentedLand newrent = new RentedLand();
|
||||
newrent.player = player.getName();
|
||||
newrent.startTime = System.currentTimeMillis();
|
||||
newrent.endTime = System.currentTimeMillis() + daysToMs(land.days);
|
||||
newrent.autoRefresh = repeat;
|
||||
rentedLand.put(landName, newrent);
|
||||
res.getPermissions().copyUserPermissions(res.getPermissions().getOwner(), player.getName());
|
||||
res.getPermissions().clearPlayersFlags(res.getPermissions().getOwner());
|
||||
res.getPermissions().setPlayerFlag(player.getName(), "admin", FlagState.TRUE);
|
||||
final String[] split = landName.split("\\.");
|
||||
if (split.length != 0) {
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceRentSuccess",
|
||||
ChatColor.YELLOW + split[split.length - 1] + ChatColor.GREEN + "." + ChatColor.YELLOW + land.days + ChatColor.GREEN));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Error, unable to transfer money...");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Object> save() {
|
||||
final Map<String, Object> root = new HashMap<String, Object>();
|
||||
final Map<String, Object> rentables = new HashMap<String, Object>();
|
||||
for (final Entry<String, RentableLand> rent : rentableLand.entrySet()) {
|
||||
rentables.put(rent.getKey(), rent.getValue().save());
|
||||
}
|
||||
final Map<String, Object> rented = new HashMap<String, Object>();
|
||||
for (final Entry<String, RentedLand> rent : rentedLand.entrySet()) {
|
||||
rented.put(rent.getKey(), rent.getValue().save());
|
||||
}
|
||||
root.put("Rentables", rentables);
|
||||
root.put("Rented", rented);
|
||||
return root;
|
||||
}
|
||||
public Map<String, Object> save() {
|
||||
final Map<String, Object> root = new HashMap<String, Object>();
|
||||
final Map<String, Object> rentables = new HashMap<String, Object>();
|
||||
for (final Entry<String, RentableLand> rent : rentableLand.entrySet()) {
|
||||
rentables.put(rent.getKey(), rent.getValue().save());
|
||||
}
|
||||
final Map<String, Object> rented = new HashMap<String, Object>();
|
||||
for (final Entry<String, RentedLand> rent : rentedLand.entrySet()) {
|
||||
rented.put(rent.getKey(), rent.getValue().save());
|
||||
}
|
||||
root.put("Rentables", rentables);
|
||||
root.put("Rented", rented);
|
||||
return root;
|
||||
}
|
||||
|
||||
public void setForRent(final Player player, final String landName, final int amount, final int days, final boolean repeatable, final boolean resadmin) {
|
||||
if (!plugin.getConfigManager().enabledRentSystem()) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getTransactionManager().isForSale(landName)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SellRentFail"));
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (!resadmin) {
|
||||
if (!res.getPermissions().hasResidencePermission(player, true)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
if (this.getRentableCount(player.getName()) >= group.getMaxRentables()) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMaxRent"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!rentableLand.containsKey(landName)) {
|
||||
final ResidenceRentEvent revent = new ResidenceRentEvent(res, player, RentEventType.RENTABLE);
|
||||
pm.callEvent(revent);
|
||||
if (revent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
final RentableLand newrent = new RentableLand();
|
||||
newrent.days = days;
|
||||
newrent.cost = amount;
|
||||
newrent.repeatable = repeatable;
|
||||
rentableLand.put(landName, newrent);
|
||||
final String[] split = landName.split("\\.");
|
||||
if (split.length != 0) {
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceForRentSuccess",
|
||||
ChatColor.YELLOW + split[split.length - 1] + ChatColor.GREEN + "." + ChatColor.YELLOW + amount + ChatColor.GREEN + "." + ChatColor.YELLOW + days + ChatColor.GREEN));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceAlreadyRent"));
|
||||
}
|
||||
}
|
||||
public void setForRent(final Player player, final String landName, final int amount, final int days, final boolean repeatable, final boolean resadmin) {
|
||||
if (!plugin.getConfigManager().enabledRentSystem()) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getTransactionManager().isForSale(landName)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SellRentFail"));
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (!resadmin) {
|
||||
if (!res.getPermissions().hasResidencePermission(player, true)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
if (this.getRentableCount(player.getName()) >= group.getMaxRentables()) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMaxRent"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!rentableLand.containsKey(landName)) {
|
||||
final ResidenceRentEvent revent = new ResidenceRentEvent(res, player, RentEventType.RENTABLE);
|
||||
pm.callEvent(revent);
|
||||
if (revent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
final RentableLand newrent = new RentableLand();
|
||||
newrent.days = days;
|
||||
newrent.cost = amount;
|
||||
newrent.repeatable = repeatable;
|
||||
rentableLand.put(landName, newrent);
|
||||
final String[] split = landName.split("\\.");
|
||||
if (split.length != 0) {
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceForRentSuccess",
|
||||
ChatColor.YELLOW + split[split.length - 1] + ChatColor.GREEN + "." + ChatColor.YELLOW + amount + ChatColor.GREEN + "." + ChatColor.YELLOW + days + ChatColor.GREEN));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceAlreadyRent"));
|
||||
}
|
||||
}
|
||||
|
||||
public void setRentedRepeatable(final Player player, final String landName, final boolean value, final boolean resadmin) {
|
||||
final String[] split = landName.split("\\.");
|
||||
final RentedLand land = rentedLand.get(landName);
|
||||
if (land != null && (land.player.equals(player.getName()) || resadmin)) {
|
||||
land.autoRefresh = value;
|
||||
if (value && split.length != 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentEnableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
||||
} else if (split.length != 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentDisableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setRentedRepeatable(final Player player, final String landName, final boolean value, final boolean resadmin) {
|
||||
final String[] split = landName.split("\\.");
|
||||
final RentedLand land = rentedLand.get(landName);
|
||||
if (land != null && (land.player.equals(player.getName()) || resadmin)) {
|
||||
land.autoRefresh = value;
|
||||
if (value && split.length != 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentEnableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
||||
} else if (split.length != 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentDisableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setRentRepeatable(final Player player, final String landName, final boolean value, final boolean resadmin) {
|
||||
final String[] split = landName.split("\\.");
|
||||
final RentableLand land = rentableLand.get(landName);
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||
if (land != null && res != null && (res.getPermissions().getOwner().equalsIgnoreCase(player.getName()) || resadmin)) {
|
||||
land.repeatable = value;
|
||||
if (!value && this.isRented(landName)) {
|
||||
rentedLand.get(landName).autoRefresh = false;
|
||||
}
|
||||
if (value && split.length != 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentableEnableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
||||
} else if (split.length != 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentableDisableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setRentRepeatable(final Player player, final String landName, final boolean value, final boolean resadmin) {
|
||||
final String[] split = landName.split("\\.");
|
||||
final RentableLand land = rentableLand.get(landName);
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||
if (land != null && res != null && (res.getPermissions().getOwner().equalsIgnoreCase(player.getName()) || resadmin)) {
|
||||
land.repeatable = value;
|
||||
if (!value && this.isRented(landName)) {
|
||||
rentedLand.get(landName).autoRefresh = false;
|
||||
}
|
||||
if (value && split.length != 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentableEnableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
||||
} else if (split.length != 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentableDisableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unrent(final Player player, final String landName, final boolean resadmin) {
|
||||
final String[] split = landName.split("\\.");
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (!res.getPermissions().hasResidencePermission(player, true) && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
if (rentedLand.containsKey(landName) && !resadmin) {
|
||||
if (split.length != 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceAlreadyRented",
|
||||
ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED + "." + ChatColor.YELLOW + rentedLand.get(landName).player) + ChatColor.YELLOW);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (rentableLand.containsKey(landName)) {
|
||||
final ResidenceRentEvent revent = new ResidenceRentEvent(res, player, RentEventType.UNRENT);
|
||||
pm.callEvent(revent);
|
||||
if (revent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
rentableLand.remove(landName);
|
||||
if (rentedLand.containsKey(landName)) {
|
||||
rentedLand.remove(landName);
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
}
|
||||
if (split.length != 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceRemoveRentable", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
||||
}
|
||||
public void unrent(final Player player, final String landName, final boolean resadmin) {
|
||||
final String[] split = landName.split("\\.");
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||
if (res == null) {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||
return;
|
||||
}
|
||||
if (!res.getPermissions().hasResidencePermission(player, true) && !resadmin) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
if (rentedLand.containsKey(landName) && !resadmin) {
|
||||
if (split.length != 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceAlreadyRented",
|
||||
ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED + "." + ChatColor.YELLOW + rentedLand.get(landName).player) + ChatColor.YELLOW);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (rentableLand.containsKey(landName)) {
|
||||
final ResidenceRentEvent revent = new ResidenceRentEvent(res, player, RentEventType.UNRENT);
|
||||
pm.callEvent(revent);
|
||||
if (revent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
rentableLand.remove(landName);
|
||||
if (rentedLand.containsKey(landName)) {
|
||||
rentedLand.remove(landName);
|
||||
res.getPermissions().applyDefaultFlags();
|
||||
}
|
||||
if (split.length != 0) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceRemoveRentable", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
||||
}
|
||||
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForRent"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForRent"));
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRentableName(final String oldName, final String newName) {
|
||||
if (rentableLand.containsKey(oldName)) {
|
||||
rentableLand.put(newName, rentableLand.get(oldName));
|
||||
rentableLand.remove(oldName);
|
||||
}
|
||||
if (rentedLand.containsKey(oldName)) {
|
||||
rentedLand.put(newName, rentedLand.get(oldName));
|
||||
rentedLand.remove(oldName);
|
||||
}
|
||||
}
|
||||
public void updateRentableName(final String oldName, final String newName) {
|
||||
if (rentableLand.containsKey(oldName)) {
|
||||
rentableLand.put(newName, rentableLand.get(oldName));
|
||||
rentableLand.remove(oldName);
|
||||
}
|
||||
if (rentedLand.containsKey(oldName)) {
|
||||
rentedLand.put(newName, rentedLand.get(oldName));
|
||||
rentedLand.remove(oldName);
|
||||
}
|
||||
}
|
||||
|
||||
private long daysToMs(final int days) {
|
||||
return ((days) * 24L * 60L * 60L * 1000L);
|
||||
}
|
||||
private long daysToMs(final int days) {
|
||||
return ((days) * 24L * 60L * 60L * 1000L);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int msToDays(final long ms) {
|
||||
return (int) Math.ceil((((ms / 1000D) / 60D) / 60D) / 24D);
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
private int msToDays(final long ms) {
|
||||
return (int) Math.ceil((((ms / 1000D) / 60D) / 60D) / 24D);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ public class RentableLand {
|
||||
|
||||
public static RentableLand load(Map<String, Object> map) {
|
||||
RentableLand newland = new RentableLand();
|
||||
newland.cost = (Integer)map.get("Cost");
|
||||
newland.days = (Integer)map.get("Days");
|
||||
newland.repeatable = (Boolean)map.get("Repeatable");
|
||||
newland.cost = (Integer) map.get("Cost");
|
||||
newland.days = (Integer) map.get("Days");
|
||||
newland.repeatable = (Boolean) map.get("Repeatable");
|
||||
return newland;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ public class RentedLand {
|
||||
rentables.put("AutoRefresh", autoRefresh);
|
||||
return rentables;
|
||||
}
|
||||
public static RentedLand load(Map<String,Object> map)
|
||||
{
|
||||
|
||||
public static RentedLand load(Map<String, Object> map) {
|
||||
RentedLand newland = new RentedLand();
|
||||
newland.player = (String) map.get("Player");
|
||||
newland.startTime = (Long)map.get("StartTime");
|
||||
newland.endTime = (Long)map.get("EndTime");
|
||||
newland.autoRefresh = (Boolean)map.get("AutoRefresh");
|
||||
newland.startTime = (Long) map.get("StartTime");
|
||||
newland.endTime = (Long) map.get("EndTime");
|
||||
newland.autoRefresh = (Boolean) map.get("AutoRefresh");
|
||||
return newland;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,166 +21,166 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class ItemList {
|
||||
|
||||
public static enum ListType {
|
||||
BLACKLIST,
|
||||
WHITELIST,
|
||||
IGNORELIST,
|
||||
OTHER
|
||||
}
|
||||
public static enum ListType {
|
||||
BLACKLIST,
|
||||
WHITELIST,
|
||||
IGNORELIST,
|
||||
OTHER
|
||||
}
|
||||
|
||||
protected List<Material> list;
|
||||
protected List<Material> list;
|
||||
|
||||
protected ListType type;
|
||||
protected ListType type;
|
||||
|
||||
public ItemList(final ListType listType) {
|
||||
this();
|
||||
type = listType;
|
||||
}
|
||||
public ItemList(final ListType listType) {
|
||||
this();
|
||||
type = listType;
|
||||
}
|
||||
|
||||
protected ItemList() {
|
||||
list = new ArrayList<Material>();
|
||||
}
|
||||
protected ItemList() {
|
||||
list = new ArrayList<Material>();
|
||||
}
|
||||
|
||||
public static ItemList load(final Map<String, Object> map) {
|
||||
final ItemList newlist = new ItemList();
|
||||
return load(map, newlist);
|
||||
}
|
||||
public static ItemList load(final Map<String, Object> map) {
|
||||
final ItemList newlist = new ItemList();
|
||||
return load(map, newlist);
|
||||
}
|
||||
|
||||
public static ItemList readList(final ConfigurationSection node) {
|
||||
return ItemList.readList(node, new ItemList());
|
||||
}
|
||||
public static ItemList readList(final ConfigurationSection node) {
|
||||
return ItemList.readList(node, new ItemList());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected static ItemList load(final Map<String, Object> map, final ItemList newlist) {
|
||||
try {
|
||||
newlist.type = ListType.valueOf((String) map.get("Type"));
|
||||
final List<String> list = (List<String>) map.get("ItemList");
|
||||
for (final String item : list) {
|
||||
newlist.add(Material.valueOf(item));
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
return newlist;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
protected static ItemList load(final Map<String, Object> map, final ItemList newlist) {
|
||||
try {
|
||||
newlist.type = ListType.valueOf((String) map.get("Type"));
|
||||
final List<String> list = (List<String>) map.get("ItemList");
|
||||
for (final String item : list) {
|
||||
newlist.add(Material.valueOf(item));
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
return newlist;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected static ItemList readList(final ConfigurationSection node, final ItemList list) {
|
||||
final ListType type = ListType.valueOf(node.getString("Type", "").toUpperCase());
|
||||
list.type = type;
|
||||
final List<String> items = node.getStringList("Items");
|
||||
if (items != null) {
|
||||
for (final String item : items) {
|
||||
int parse = -1;
|
||||
try {
|
||||
parse = Integer.parseInt(item);
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
if (parse == -1) {
|
||||
try {
|
||||
list.add(Material.valueOf(item.toUpperCase()));
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
list.add(Material.getMaterial(parse));
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
protected static ItemList readList(final ConfigurationSection node, final ItemList list) {
|
||||
final ListType type = ListType.valueOf(node.getString("Type", "").toUpperCase());
|
||||
list.type = type;
|
||||
final List<String> items = node.getStringList("Items");
|
||||
if (items != null) {
|
||||
for (final String item : items) {
|
||||
int parse = -1;
|
||||
try {
|
||||
parse = Integer.parseInt(item);
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
if (parse == -1) {
|
||||
try {
|
||||
list.add(Material.valueOf(item.toUpperCase()));
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
list.add(Material.getMaterial(parse));
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void add(final Material mat) {
|
||||
if (!list.contains(mat))
|
||||
list.add(mat);
|
||||
}
|
||||
public void add(final Material mat) {
|
||||
if (!list.contains(mat))
|
||||
list.add(mat);
|
||||
}
|
||||
|
||||
public boolean contains(final Material mat) {
|
||||
return list.contains(mat);
|
||||
}
|
||||
public boolean contains(final Material mat) {
|
||||
return list.contains(mat);
|
||||
}
|
||||
|
||||
public int getListSize() {
|
||||
return list.size();
|
||||
}
|
||||
public int getListSize() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public ListType getType() {
|
||||
return type;
|
||||
}
|
||||
public ListType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isAllowed(final Material mat) {
|
||||
if (type == ListType.BLACKLIST) {
|
||||
if (list.contains(mat)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else if (type == ListType.WHITELIST) {
|
||||
if (list.contains(mat)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean isAllowed(final Material mat) {
|
||||
if (type == ListType.BLACKLIST) {
|
||||
if (list.contains(mat)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else if (type == ListType.WHITELIST) {
|
||||
if (list.contains(mat)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isIgnored(final Material mat) {
|
||||
if (type == ListType.IGNORELIST) {
|
||||
if (list.contains(mat)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean isIgnored(final Material mat) {
|
||||
if (type == ListType.IGNORELIST) {
|
||||
if (list.contains(mat)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isListed(final Material mat) {
|
||||
return this.contains(mat);
|
||||
}
|
||||
public boolean isListed(final Material mat) {
|
||||
return this.contains(mat);
|
||||
}
|
||||
|
||||
public void printList(final Player player) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (final Material mat : list) {
|
||||
if (!first)
|
||||
builder.append(", ");
|
||||
else
|
||||
builder.append(ChatColor.YELLOW);
|
||||
builder.append(mat);
|
||||
first = false;
|
||||
}
|
||||
player.sendMessage(builder.toString());
|
||||
}
|
||||
public void printList(final Player player) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (final Material mat : list) {
|
||||
if (!first)
|
||||
builder.append(", ");
|
||||
else
|
||||
builder.append(ChatColor.YELLOW);
|
||||
builder.append(mat);
|
||||
first = false;
|
||||
}
|
||||
player.sendMessage(builder.toString());
|
||||
}
|
||||
|
||||
public void remove(final Material mat) {
|
||||
list.remove(mat);
|
||||
}
|
||||
public void remove(final Material mat) {
|
||||
list.remove(mat);
|
||||
}
|
||||
|
||||
public Map<String, Object> save() {
|
||||
final Map<String, Object> saveMap = new LinkedHashMap<String, Object>();
|
||||
saveMap.put("Type", type.toString());
|
||||
final List<String> saveList = new ArrayList<String>();
|
||||
for (final Material mat : list) {
|
||||
saveList.add(mat.toString());
|
||||
}
|
||||
saveMap.put("ItemList", saveList);
|
||||
return saveMap;
|
||||
}
|
||||
public Map<String, Object> save() {
|
||||
final Map<String, Object> saveMap = new LinkedHashMap<String, Object>();
|
||||
saveMap.put("Type", type.toString());
|
||||
final List<String> saveList = new ArrayList<String>();
|
||||
for (final Material mat : list) {
|
||||
saveList.add(mat.toString());
|
||||
}
|
||||
saveMap.put("ItemList", saveList);
|
||||
return saveMap;
|
||||
}
|
||||
|
||||
public Material[] toArray() {
|
||||
final Material mats[] = new Material[list.size()];
|
||||
int i = 0;
|
||||
for (final Material mat : list) {
|
||||
mats[i] = mat;
|
||||
i++;
|
||||
}
|
||||
return mats;
|
||||
}
|
||||
public Material[] toArray() {
|
||||
final Material mats[] = new Material[list.size()];
|
||||
int i = 0;
|
||||
for (final Material mat : list) {
|
||||
mats[i] = mat;
|
||||
i++;
|
||||
}
|
||||
return mats;
|
||||
}
|
||||
|
||||
public boolean toggle(final Material mat) {
|
||||
if (list.contains(mat)) {
|
||||
list.remove(mat);
|
||||
return false;
|
||||
}
|
||||
list.add(mat);
|
||||
return true;
|
||||
}
|
||||
public boolean toggle(final Material mat) {
|
||||
if (list.contains(mat)) {
|
||||
list.remove(mat);
|
||||
return false;
|
||||
}
|
||||
list.add(mat);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,37 +21,37 @@ import cn.citycraft.Residence.permissions.PermissionGroup;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class ResidenceItemList extends ItemList {
|
||||
ResidenceMain plugin;
|
||||
ClaimedResidence res;
|
||||
ResidenceMain plugin;
|
||||
ClaimedResidence res;
|
||||
|
||||
public ResidenceItemList(final ResidenceMain plugin, final ClaimedResidence parent, final ListType type) {
|
||||
super(type);
|
||||
this.plugin = plugin;
|
||||
res = parent;
|
||||
}
|
||||
public ResidenceItemList(final ResidenceMain plugin, final ClaimedResidence parent, final ListType type) {
|
||||
super(type);
|
||||
this.plugin = plugin;
|
||||
res = parent;
|
||||
}
|
||||
|
||||
private ResidenceItemList(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
private ResidenceItemList(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static ResidenceItemList load(final ResidenceMain plugin, final ClaimedResidence parent, final Map<String, Object> map) {
|
||||
final ResidenceItemList newlist = new ResidenceItemList(plugin);
|
||||
newlist.res = parent;
|
||||
return (ResidenceItemList) ItemList.load(map, newlist);
|
||||
}
|
||||
public static ResidenceItemList load(final ResidenceMain plugin, final ClaimedResidence parent, final Map<String, Object> map) {
|
||||
final ResidenceItemList newlist = new ResidenceItemList(plugin);
|
||||
newlist.res = parent;
|
||||
return (ResidenceItemList) ItemList.load(map, newlist);
|
||||
}
|
||||
|
||||
public void playerListChange(final Player player, final Material mat, final boolean resadmin) {
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
if (resadmin || (res.getPermissions().hasResidencePermission(player, true) && group.itemListAccess())) {
|
||||
if (super.toggle(mat)) {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ListMaterialAdd",
|
||||
ChatColor.GREEN + mat.toString() + ChatColor.YELLOW + "." + ChatColor.GREEN + type.toString().toLowerCase() + ChatColor.YELLOW));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ListMaterialRemove",
|
||||
ChatColor.GREEN + mat.toString() + ChatColor.YELLOW + "." + ChatColor.GREEN + type.toString().toLowerCase() + ChatColor.YELLOW));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
}
|
||||
public void playerListChange(final Player player, final Material mat, final boolean resadmin) {
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
if (resadmin || (res.getPermissions().hasResidencePermission(player, true) && group.itemListAccess())) {
|
||||
if (super.toggle(mat)) {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ListMaterialAdd",
|
||||
ChatColor.GREEN + mat.toString() + ChatColor.YELLOW + "." + ChatColor.GREEN + type.toString().toLowerCase() + ChatColor.YELLOW));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ListMaterialRemove",
|
||||
ChatColor.GREEN + mat.toString() + ChatColor.YELLOW + "." + ChatColor.GREEN + type.toString().toLowerCase() + ChatColor.YELLOW));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,48 +17,41 @@ public class WorldItemList extends ItemList {
|
||||
protected String world;
|
||||
protected String group;
|
||||
|
||||
public WorldItemList(ListType listType)
|
||||
{
|
||||
public WorldItemList(ListType listType) {
|
||||
super(listType);
|
||||
}
|
||||
|
||||
protected WorldItemList()
|
||||
{
|
||||
protected WorldItemList() {
|
||||
|
||||
}
|
||||
|
||||
public String getWorld()
|
||||
{
|
||||
public String getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public String getGroup()
|
||||
{
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public boolean isAllowed(Material mat, String inworld, String ingroup) {
|
||||
if(!listApplicable(inworld,ingroup))
|
||||
if (!listApplicable(inworld, ingroup))
|
||||
return true;
|
||||
return super.isAllowed(mat);
|
||||
}
|
||||
|
||||
public boolean isIgnored(Material mat, String inworld, String ingroup)
|
||||
{
|
||||
if(!listApplicable(inworld,ingroup))
|
||||
public boolean isIgnored(Material mat, String inworld, String ingroup) {
|
||||
if (!listApplicable(inworld, ingroup))
|
||||
return false;
|
||||
return super.isIgnored(mat);
|
||||
}
|
||||
|
||||
public boolean isListed(Material mat, String inworld, String ingroup)
|
||||
{
|
||||
if(!listApplicable(inworld,ingroup))
|
||||
public boolean isListed(Material mat, String inworld, String ingroup) {
|
||||
if (!listApplicable(inworld, ingroup))
|
||||
return false;
|
||||
return super.isListed(mat);
|
||||
}
|
||||
|
||||
public boolean listApplicable(String inworld, String ingroup)
|
||||
{
|
||||
public boolean listApplicable(String inworld, String ingroup) {
|
||||
if (world != null) {
|
||||
if (!world.equalsIgnoreCase(inworld)) {
|
||||
return false;
|
||||
@@ -72,12 +65,11 @@ public class WorldItemList extends ItemList {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static WorldItemList readList(ConfigurationSection node)
|
||||
{
|
||||
public static WorldItemList readList(ConfigurationSection node) {
|
||||
WorldItemList list = new WorldItemList();
|
||||
ItemList.readList(node, list);
|
||||
list.world = node.getString("World",null);
|
||||
list.group = node.getString("Group",null);
|
||||
list.world = node.getString("World", null);
|
||||
list.group = node.getString("Group", null);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
public class WorldItemManager {
|
||||
protected List<WorldItemList> lists;
|
||||
|
||||
public WorldItemManager(FileConfiguration config)
|
||||
{
|
||||
public WorldItemManager(FileConfiguration config) {
|
||||
lists = new ArrayList<WorldItemList>();
|
||||
this.readLists(config);
|
||||
}
|
||||
@@ -33,8 +32,7 @@ public class WorldItemManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isIgnored(Material mat, String group, String world)
|
||||
{
|
||||
public boolean isIgnored(Material mat, String group, String world) {
|
||||
for (WorldItemList list : lists) {
|
||||
if (list.isIgnored(mat, world, group)) {
|
||||
return true;
|
||||
@@ -50,7 +48,7 @@ public class WorldItemManager {
|
||||
try {
|
||||
WorldItemList list = WorldItemList.readList(config.getConfigurationSection("ItemList." + key));
|
||||
lists.add(list);
|
||||
//System.out.println("Debug: read list " + key + " world: " + list.getWorld() + " group: " + list.getGroup() + " itemcount:" + list.getListSize());
|
||||
// System.out.println("Debug: read list " + key + " world: " + list.getWorld() + " group: " + list.getGroup() + " itemcount:" + list.getListSize());
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Failed to load item list:" + key);
|
||||
}
|
||||
|
||||
@@ -34,186 +34,186 @@ import org.bukkit.event.block.BlockSpreadEvent;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class ResidenceBlockListener implements Listener {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public ResidenceBlockListener(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public ResidenceBlockListener(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockBreak(final BlockBreakEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final Material mat = event.getBlock().getType();
|
||||
final String world = event.getBlock().getWorld().getName();
|
||||
final String group = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||
if (plugin.getItemManager().isIgnored(mat, group, world)) {
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlock().getLocation());
|
||||
if (plugin.getConfigManager().enabledRentSystem()) {
|
||||
if (res != null) {
|
||||
final String resname = res.getName();
|
||||
if (plugin.getConfigManager().preventRentModify() && plugin.getRentManager().isRented(resname)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlock().getLocation(), player);
|
||||
final String pname = player.getName();
|
||||
if (res != null) {
|
||||
if (res.getItemIgnoreList().isListed(mat)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final boolean hasdestroy = perms.playerHas(pname, player.getWorld().getName(), "destroy", perms.playerHas(pname, player.getWorld().getName(), "build", true));
|
||||
final boolean hasContainer = perms.playerHas(pname, player.getWorld().getName(), "container", true);
|
||||
if (!hasdestroy || (!hasContainer && mat == Material.CHEST)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockBreak(final BlockBreakEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final Material mat = event.getBlock().getType();
|
||||
final String world = event.getBlock().getWorld().getName();
|
||||
final String group = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||
if (plugin.getItemManager().isIgnored(mat, group, world)) {
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlock().getLocation());
|
||||
if (plugin.getConfigManager().enabledRentSystem()) {
|
||||
if (res != null) {
|
||||
final String resname = res.getName();
|
||||
if (plugin.getConfigManager().preventRentModify() && plugin.getRentManager().isRented(resname)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlock().getLocation(), player);
|
||||
final String pname = player.getName();
|
||||
if (res != null) {
|
||||
if (res.getItemIgnoreList().isListed(mat)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final boolean hasdestroy = perms.playerHas(pname, player.getWorld().getName(), "destroy", perms.playerHas(pname, player.getWorld().getName(), "build", true));
|
||||
final boolean hasContainer = perms.playerHas(pname, player.getWorld().getName(), "container", true);
|
||||
if (!hasdestroy || (!hasContainer && mat == Material.CHEST)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockBurn(final BlockBurnEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
||||
if (!perms.has("firespread", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockBurn(final BlockBurnEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
||||
if (!perms.has("firespread", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockFromTo(final BlockFromToEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getToBlock().getLocation());
|
||||
final boolean hasflow = perms.has("flow", true);
|
||||
final Material mat = event.getBlock().getType();
|
||||
if (!hasflow) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (mat == Material.LAVA || mat == Material.STATIONARY_LAVA) {
|
||||
if (!perms.has("lavaflow", hasflow)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (mat == Material.WATER || mat == Material.STATIONARY_WATER) {
|
||||
if (!perms.has("waterflow", hasflow)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockFromTo(final BlockFromToEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getToBlock().getLocation());
|
||||
final boolean hasflow = perms.has("flow", true);
|
||||
final Material mat = event.getBlock().getType();
|
||||
if (!hasflow) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (mat == Material.LAVA || mat == Material.STATIONARY_LAVA) {
|
||||
if (!perms.has("lavaflow", hasflow)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (mat == Material.WATER || mat == Material.STATIONARY_WATER) {
|
||||
if (!perms.has("waterflow", hasflow)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockIgnite(final BlockIgniteEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlock().getLocation(), event.getPlayer());
|
||||
final IgniteCause cause = event.getCause();
|
||||
if (cause == IgniteCause.SPREAD) {
|
||||
if (!perms.has("firespread", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (cause == IgniteCause.FLINT_AND_STEEL) {
|
||||
final Player player = event.getPlayer();
|
||||
if (player != null && !perms.playerHas(player.getName(), player.getWorld().getName(), "ignite", true) && !plugin.isResAdminOn(player)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
} else {
|
||||
if (!perms.has("ignite", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockIgnite(final BlockIgniteEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlock().getLocation(), event.getPlayer());
|
||||
final IgniteCause cause = event.getCause();
|
||||
if (cause == IgniteCause.SPREAD) {
|
||||
if (!perms.has("firespread", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (cause == IgniteCause.FLINT_AND_STEEL) {
|
||||
final Player player = event.getPlayer();
|
||||
if (player != null && !perms.playerHas(player.getName(), player.getWorld().getName(), "ignite", true) && !plugin.isResAdminOn(player)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
} else {
|
||||
if (!perms.has("ignite", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockPistonExtend(final BlockPistonExtendEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
||||
if (!perms.has("piston", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
for (final Block block : event.getBlocks()) {
|
||||
final FlagPermissions blockpermsfrom = plugin.getPermsByLoc(block.getLocation());
|
||||
final Location blockto = block.getLocation();
|
||||
blockto.setX(blockto.getX() + event.getDirection().getModX());
|
||||
blockto.setY(blockto.getY() + event.getDirection().getModY());
|
||||
blockto.setZ(blockto.getZ() + event.getDirection().getModZ());
|
||||
final FlagPermissions blockpermsto = plugin.getPermsByLoc(blockto);
|
||||
if (!blockpermsfrom.has("piston", true) || !blockpermsto.has("piston", true)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockPistonExtend(final BlockPistonExtendEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
||||
if (!perms.has("piston", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
for (final Block block : event.getBlocks()) {
|
||||
final FlagPermissions blockpermsfrom = plugin.getPermsByLoc(block.getLocation());
|
||||
final Location blockto = block.getLocation();
|
||||
blockto.setX(blockto.getX() + event.getDirection().getModX());
|
||||
blockto.setY(blockto.getY() + event.getDirection().getModY());
|
||||
blockto.setZ(blockto.getZ() + event.getDirection().getModZ());
|
||||
final FlagPermissions blockpermsto = plugin.getPermsByLoc(blockto);
|
||||
if (!blockpermsfrom.has("piston", true) || !blockpermsto.has("piston", true)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(final BlockPistonRetractEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
||||
if (!perms.has("piston", true)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (event.isSticky()) {
|
||||
final Location location = event.getRetractLocation();
|
||||
final FlagPermissions blockperms = plugin.getPermsByLoc(location);
|
||||
if (!blockperms.has("piston", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(final BlockPistonRetractEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
||||
if (!perms.has("piston", true)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (event.isSticky()) {
|
||||
final Location location = event.getRetractLocation();
|
||||
final FlagPermissions blockperms = plugin.getPermsByLoc(location);
|
||||
if (!blockperms.has("piston", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockPlace(final BlockPlaceEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final Material mat = event.getBlock().getType();
|
||||
final String world = event.getBlock().getWorld().getName();
|
||||
final String group = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||
if (plugin.getItemManager().isIgnored(mat, group, world)) {
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlock().getLocation());
|
||||
if (plugin.getConfigManager().enabledRentSystem()) {
|
||||
if (res != null) {
|
||||
final String resname = res.getName();
|
||||
if (plugin.getConfigManager().preventRentModify() && plugin.getRentManager().isRented(resname)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
final String pname = player.getName();
|
||||
if (res != null) {
|
||||
if (!res.getItemBlacklist().isAllowed(mat)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlock().getLocation(), player);
|
||||
final boolean hasplace = perms.playerHas(pname, player.getWorld().getName(), "place", perms.playerHas(pname, player.getWorld().getName(), "build", true));
|
||||
if (!hasplace) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockPlace(final BlockPlaceEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final Material mat = event.getBlock().getType();
|
||||
final String world = event.getBlock().getWorld().getName();
|
||||
final String group = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||
if (plugin.getItemManager().isIgnored(mat, group, world)) {
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlock().getLocation());
|
||||
if (plugin.getConfigManager().enabledRentSystem()) {
|
||||
if (res != null) {
|
||||
final String resname = res.getName();
|
||||
if (plugin.getConfigManager().preventRentModify() && plugin.getRentManager().isRented(resname)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
final String pname = player.getName();
|
||||
if (res != null) {
|
||||
if (!res.getItemBlacklist().isAllowed(mat)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlock().getLocation(), player);
|
||||
final boolean hasplace = perms.playerHas(pname, player.getWorld().getName(), "place", perms.playerHas(pname, player.getWorld().getName(), "build", true));
|
||||
if (!hasplace) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockSpread(final BlockSpreadEvent event) {
|
||||
final Location loc = event.getBlock().getLocation();
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(loc);
|
||||
if (!perms.has("spread", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockSpread(final BlockSpreadEvent event) {
|
||||
final Location loc = event.getBlock().getLocation();
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(loc);
|
||||
if (!perms.has("spread", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,320 +48,320 @@ import cn.citycraft.Residence.manager.EntityManager;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class ResidenceEntityListener implements Listener {
|
||||
EntityManager entitymanager;
|
||||
ResidenceMain plugin;
|
||||
EntityManager entitymanager;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public ResidenceEntityListener(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.entitymanager = plugin.getEntityManager();
|
||||
}
|
||||
public ResidenceEntityListener(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.entitymanager = plugin.getEntityManager();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onCreatureSpawn(final CreatureSpawnEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getLocation());
|
||||
final Entity ent = event.getEntity();
|
||||
if (entitymanager.isAnimal(ent)) {
|
||||
if (!perms.has("animals", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!perms.has("monsters", true) && entitymanager.isMonster(ent)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onCreatureSpawn(final CreatureSpawnEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getLocation());
|
||||
final Entity ent = event.getEntity();
|
||||
if (entitymanager.isAnimal(ent)) {
|
||||
if (!perms.has("animals", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!perms.has("monsters", true) && entitymanager.isMonster(ent)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEndermanChangeBlock(final EntityChangeBlockEvent event) {
|
||||
if (event.getEntityType() != EntityType.ENDERMAN && event.getEntityType() != EntityType.WITHER) {
|
||||
return;
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
||||
final FlagPermissions world = plugin.getWorldFlags().getPerms(event.getBlock().getWorld().getName());
|
||||
if (event.getEntityType() == EntityType.WITHER) {
|
||||
if (!perms.has("wither", perms.has("explode", world.has("wither", world.has("explode", true))))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!perms.has("build", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEndermanChangeBlock(final EntityChangeBlockEvent event) {
|
||||
if (event.getEntityType() != EntityType.ENDERMAN && event.getEntityType() != EntityType.WITHER) {
|
||||
return;
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
||||
final FlagPermissions world = plugin.getWorldFlags().getPerms(event.getBlock().getWorld().getName());
|
||||
if (event.getEntityType() == EntityType.WITHER) {
|
||||
if (!perms.has("wither", perms.has("explode", world.has("wither", world.has("explode", true))))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!perms.has("build", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityCombust(final EntityCombustEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getEntity().getLocation());
|
||||
if (!perms.has("burn", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityCombust(final EntityCombustEvent event) {
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getEntity().getLocation());
|
||||
if (!perms.has("burn", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityDamage(final EntityDamageEvent event) {
|
||||
Entity ent = event.getEntity();
|
||||
if (ent.hasMetadata("NPC")) {
|
||||
return;
|
||||
}
|
||||
final boolean tamedWolf = ent instanceof Wolf ? ((Wolf) ent).isTamed() : false;
|
||||
final ClaimedResidence area = plugin.getResidenceManager().getByLoc(ent.getLocation());
|
||||
/* Living Entities */
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
final EntityDamageByEntityEvent attackevent = (EntityDamageByEntityEvent) event;
|
||||
final Entity damager = attackevent.getDamager();
|
||||
ClaimedResidence srcarea = null;
|
||||
if (damager != null) {
|
||||
srcarea = plugin.getResidenceManager().getByLoc(damager.getLocation());
|
||||
}
|
||||
boolean srcpvp = true;
|
||||
if (srcarea != null) {
|
||||
srcpvp = srcarea.getPermissions().has("pvp", true);
|
||||
}
|
||||
ent = attackevent.getEntity();
|
||||
if ((ent instanceof Player || tamedWolf) && (damager instanceof Player || (damager instanceof Arrow && (((Arrow) damager).getShooter() instanceof Player)))) {
|
||||
Player attacker = null;
|
||||
if (damager instanceof Player) {
|
||||
attacker = (Player) damager;
|
||||
} else if (damager instanceof Arrow) {
|
||||
attacker = (Player) ((Arrow) damager).getShooter();
|
||||
}
|
||||
if (!srcpvp) {
|
||||
if (attacker != null) {
|
||||
attacker.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPVPZone"));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
/* Check for Player vs Player */
|
||||
if (area == null) {
|
||||
/* World PvP */
|
||||
if (damager != null) {
|
||||
if (!plugin.getWorldFlags().getPerms(damager.getWorld().getName()).has("pvp", true)) {
|
||||
if (attacker != null) {
|
||||
attacker.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("WorldPVPDisabled"));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else /* Normal PvP */
|
||||
if (!area.getPermissions().has("pvp", true)) {
|
||||
if (attacker != null) {
|
||||
attacker.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPVPZone"));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
} else if ((ent instanceof Player || tamedWolf) && (damager instanceof Creeper)) {
|
||||
if (area == null) {
|
||||
if (!plugin.getWorldFlags().getPerms(damager.getWorld().getName()).has("creeper", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!area.getPermissions().has("creeper", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (area == null) {
|
||||
if (!plugin.getWorldFlags().getPerms(ent.getWorld().getName()).has("damage", true) && (ent instanceof Player || tamedWolf)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!area.getPermissions().has("damage", true) && (ent instanceof Player || tamedWolf)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (event.isCancelled()) {
|
||||
/* Put out a fire on a player */
|
||||
if ((ent instanceof Player || tamedWolf) && (event.getCause() == EntityDamageEvent.DamageCause.FIRE || event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK)) {
|
||||
ent.setFireTicks(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityDamage(final EntityDamageEvent event) {
|
||||
Entity ent = event.getEntity();
|
||||
if (ent.hasMetadata("NPC")) {
|
||||
return;
|
||||
}
|
||||
final boolean tamedWolf = ent instanceof Wolf ? ((Wolf) ent).isTamed() : false;
|
||||
final ClaimedResidence area = plugin.getResidenceManager().getByLoc(ent.getLocation());
|
||||
/* Living Entities */
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
final EntityDamageByEntityEvent attackevent = (EntityDamageByEntityEvent) event;
|
||||
final Entity damager = attackevent.getDamager();
|
||||
ClaimedResidence srcarea = null;
|
||||
if (damager != null) {
|
||||
srcarea = plugin.getResidenceManager().getByLoc(damager.getLocation());
|
||||
}
|
||||
boolean srcpvp = true;
|
||||
if (srcarea != null) {
|
||||
srcpvp = srcarea.getPermissions().has("pvp", true);
|
||||
}
|
||||
ent = attackevent.getEntity();
|
||||
if ((ent instanceof Player || tamedWolf) && (damager instanceof Player || (damager instanceof Arrow && (((Arrow) damager).getShooter() instanceof Player)))) {
|
||||
Player attacker = null;
|
||||
if (damager instanceof Player) {
|
||||
attacker = (Player) damager;
|
||||
} else if (damager instanceof Arrow) {
|
||||
attacker = (Player) ((Arrow) damager).getShooter();
|
||||
}
|
||||
if (!srcpvp) {
|
||||
if (attacker != null) {
|
||||
attacker.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPVPZone"));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
/* Check for Player vs Player */
|
||||
if (area == null) {
|
||||
/* World PvP */
|
||||
if (damager != null) {
|
||||
if (!plugin.getWorldFlags().getPerms(damager.getWorld().getName()).has("pvp", true)) {
|
||||
if (attacker != null) {
|
||||
attacker.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("WorldPVPDisabled"));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else /* Normal PvP */
|
||||
if (!area.getPermissions().has("pvp", true)) {
|
||||
if (attacker != null) {
|
||||
attacker.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPVPZone"));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
} else if ((ent instanceof Player || tamedWolf) && (damager instanceof Creeper)) {
|
||||
if (area == null) {
|
||||
if (!plugin.getWorldFlags().getPerms(damager.getWorld().getName()).has("creeper", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!area.getPermissions().has("creeper", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (area == null) {
|
||||
if (!plugin.getWorldFlags().getPerms(ent.getWorld().getName()).has("damage", true) && (ent instanceof Player || tamedWolf)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!area.getPermissions().has("damage", true) && (ent instanceof Player || tamedWolf)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (event.isCancelled()) {
|
||||
/* Put out a fire on a player */
|
||||
if ((ent instanceof Player || tamedWolf) && (event.getCause() == EntityDamageEvent.DamageCause.FIRE || event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK)) {
|
||||
ent.setFireTicks(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent event) {
|
||||
if (event.getEntityType() == EntityType.ITEM_FRAME || (plugin.isGt1_8() && event.getEntityType() == EntityType.ARMOR_STAND)) {
|
||||
final Entity dmgr = event.getDamager();
|
||||
Player player;
|
||||
if (dmgr instanceof Player) {
|
||||
player = (Player) event.getDamager();
|
||||
} else if (dmgr instanceof Projectile && ((Projectile) dmgr).getShooter() instanceof Player) {
|
||||
player = (Player) ((Projectile) dmgr).getShooter();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent event) {
|
||||
if (event.getEntityType() == EntityType.ITEM_FRAME || (plugin.isGt1_8() && event.getEntityType() == EntityType.ARMOR_STAND)) {
|
||||
final Entity dmgr = event.getDamager();
|
||||
Player player;
|
||||
if (dmgr instanceof Player) {
|
||||
player = (Player) event.getDamager();
|
||||
} else if (dmgr instanceof Projectile && ((Projectile) dmgr).getShooter() instanceof Player) {
|
||||
player = (Player) ((Projectile) dmgr).getShooter();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Note: Location of entity, not player; otherwise player could
|
||||
// stand outside of res and still damage
|
||||
final Location loc = event.getEntity().getLocation();
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||
if (res != null) {
|
||||
if (!res.getPermissions().has("container", false)) {
|
||||
if (entitymanager.isMonster(dmgr)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Note: Location of entity, not player; otherwise player could
|
||||
// stand outside of res and still damage
|
||||
final Location loc = event.getEntity().getLocation();
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||
if (res != null) {
|
||||
if (!res.getPermissions().has("container", false)) {
|
||||
if (entitymanager.isMonster(dmgr)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!res.getPermissions().playerHas(player.getName(), "container", false)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!res.getPermissions().playerHas(player.getName(), "container", false)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityExplode(final EntityExplodeEvent event) {
|
||||
if (event.isCancelled() || event.getEntity() == null) {
|
||||
return;
|
||||
}
|
||||
Boolean cancel = false;
|
||||
final EntityType entity = event.getEntityType();
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getEntity().getLocation());
|
||||
final FlagPermissions world = plugin.getWorldFlags().getPerms(event.getEntity().getWorld().getName());
|
||||
if (entity == EntityType.CREEPER) {
|
||||
if (!perms.has("creeper", perms.has("explode", true))) {
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT) {
|
||||
if (!perms.has("tnt", perms.has("explode", true))) {
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.FIREBALL) {
|
||||
if (!perms.has("fireball", perms.has("explode", true))) {
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.SMALL_FIREBALL) {
|
||||
if (!perms.has("fireball", perms.has("explode", true))) {
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.WITHER_SKULL || entity == EntityType.WITHER) {
|
||||
if (!perms.has("wither", perms.has("explode", world.has("wither", world.has("explode", true))))) {
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
if (cancel) {
|
||||
event.setCancelled(true);
|
||||
event.getEntity().remove();
|
||||
} else {
|
||||
final List<Block> preserve = new ArrayList<Block>();
|
||||
for (final Block block : event.blockList()) {
|
||||
final FlagPermissions blockperms = plugin.getPermsByLoc(block.getLocation());
|
||||
if ((!blockperms.has("wither", blockperms.has("explode", world.has("wither", world.has("explode", true)))) && (entity == EntityType.WITHER || entity == EntityType.WITHER_SKULL)
|
||||
|| (!blockperms.has("fireball", blockperms.has("explode", true)) && (entity == EntityType.FIREBALL || entity == EntityType.SMALL_FIREBALL))
|
||||
|| (!blockperms.has("tnt", blockperms.has("explode", true)) && (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT))
|
||||
|| (!blockperms.has("creeper", blockperms.has("explode", true)) && entity == EntityType.CREEPER))) {
|
||||
preserve.add(block);
|
||||
}
|
||||
}
|
||||
for (final Block block : preserve) {
|
||||
event.blockList().remove(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityExplode(final EntityExplodeEvent event) {
|
||||
if (event.isCancelled() || event.getEntity() == null) {
|
||||
return;
|
||||
}
|
||||
Boolean cancel = false;
|
||||
final EntityType entity = event.getEntityType();
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getEntity().getLocation());
|
||||
final FlagPermissions world = plugin.getWorldFlags().getPerms(event.getEntity().getWorld().getName());
|
||||
if (entity == EntityType.CREEPER) {
|
||||
if (!perms.has("creeper", perms.has("explode", true))) {
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT) {
|
||||
if (!perms.has("tnt", perms.has("explode", true))) {
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.FIREBALL) {
|
||||
if (!perms.has("fireball", perms.has("explode", true))) {
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.SMALL_FIREBALL) {
|
||||
if (!perms.has("fireball", perms.has("explode", true))) {
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.WITHER_SKULL || entity == EntityType.WITHER) {
|
||||
if (!perms.has("wither", perms.has("explode", world.has("wither", world.has("explode", true))))) {
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
if (cancel) {
|
||||
event.setCancelled(true);
|
||||
event.getEntity().remove();
|
||||
} else {
|
||||
final List<Block> preserve = new ArrayList<Block>();
|
||||
for (final Block block : event.blockList()) {
|
||||
final FlagPermissions blockperms = plugin.getPermsByLoc(block.getLocation());
|
||||
if ((!blockperms.has("wither", blockperms.has("explode", world.has("wither", world.has("explode", true)))) && (entity == EntityType.WITHER || entity == EntityType.WITHER_SKULL)
|
||||
|| (!blockperms.has("fireball", blockperms.has("explode", true)) && (entity == EntityType.FIREBALL || entity == EntityType.SMALL_FIREBALL))
|
||||
|| (!blockperms.has("tnt", blockperms.has("explode", true)) && (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT))
|
||||
|| (!blockperms.has("creeper", blockperms.has("explode", true)) && entity == EntityType.CREEPER))) {
|
||||
preserve.add(block);
|
||||
}
|
||||
}
|
||||
for (final Block block : preserve) {
|
||||
event.blockList().remove(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityInteract(final EntityInteractEvent event) {
|
||||
final Block block = event.getBlock();
|
||||
final Material mat = block.getType();
|
||||
final Entity entity = event.getEntity();
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(block.getLocation());
|
||||
final boolean hastrample = perms.has("trample", perms.has("hasbuild", true));
|
||||
if (!hastrample && !(entity.getType() == EntityType.FALLING_BLOCK) && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityInteract(final EntityInteractEvent event) {
|
||||
final Block block = event.getBlock();
|
||||
final Material mat = block.getType();
|
||||
final Entity entity = event.getEntity();
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(block.getLocation());
|
||||
final boolean hastrample = perms.has("trample", perms.has("hasbuild", true));
|
||||
if (!hastrample && !(entity.getType() == EntityType.FALLING_BLOCK) && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onExplosionPrime(final ExplosionPrimeEvent event) {
|
||||
final EntityType entity = event.getEntityType();
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getEntity().getLocation());
|
||||
if (entity == EntityType.CREEPER) {
|
||||
if (!perms.has("creeper", perms.has("explode", true))) {
|
||||
event.setCancelled(true);
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT) {
|
||||
if (!perms.has("tnt", perms.has("explode", true))) {
|
||||
event.setCancelled(true);
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.FIREBALL) {
|
||||
if (!perms.has("fireball", perms.has("explode", true))) {
|
||||
event.setCancelled(true);
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.SMALL_FIREBALL) {
|
||||
if (!perms.has("fireball", perms.has("explode", true))) {
|
||||
event.setCancelled(true);
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.WITHER_SKULL) {
|
||||
if (!perms.has("witherdamage", perms.has("damage", true))) {
|
||||
event.setCancelled(true);
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onExplosionPrime(final ExplosionPrimeEvent event) {
|
||||
final EntityType entity = event.getEntityType();
|
||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getEntity().getLocation());
|
||||
if (entity == EntityType.CREEPER) {
|
||||
if (!perms.has("creeper", perms.has("explode", true))) {
|
||||
event.setCancelled(true);
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT) {
|
||||
if (!perms.has("tnt", perms.has("explode", true))) {
|
||||
event.setCancelled(true);
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.FIREBALL) {
|
||||
if (!perms.has("fireball", perms.has("explode", true))) {
|
||||
event.setCancelled(true);
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.SMALL_FIREBALL) {
|
||||
if (!perms.has("fireball", perms.has("explode", true))) {
|
||||
event.setCancelled(true);
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
if (entity == EntityType.WITHER_SKULL) {
|
||||
if (!perms.has("witherdamage", perms.has("damage", true))) {
|
||||
event.setCancelled(true);
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onHangingBreak(final HangingBreakEvent event) {
|
||||
if (event instanceof HangingBreakByEntityEvent) {
|
||||
final HangingBreakByEntityEvent evt = (HangingBreakByEntityEvent) event;
|
||||
if (evt.getRemover() instanceof Player) {
|
||||
final Player player = (Player) evt.getRemover();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final String pname = player.getName();
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getEntity().getLocation(), player);
|
||||
final String world = event.getEntity().getWorld().getName();
|
||||
if (!perms.playerHas(pname, world, "destroy", perms.playerHas(pname, world, "build", true))) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onHangingBreak(final HangingBreakEvent event) {
|
||||
if (event instanceof HangingBreakByEntityEvent) {
|
||||
final HangingBreakByEntityEvent evt = (HangingBreakByEntityEvent) event;
|
||||
if (evt.getRemover() instanceof Player) {
|
||||
final Player player = (Player) evt.getRemover();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final String pname = player.getName();
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getEntity().getLocation(), player);
|
||||
final String world = event.getEntity().getWorld().getName();
|
||||
if (!perms.playerHas(pname, world, "destroy", perms.playerHas(pname, world, "build", true))) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onHangingPlace(final HangingPlaceEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getEntity().getLocation(), player);
|
||||
final String pname = player.getName();
|
||||
final String world = player.getWorld().getName();
|
||||
if (!perms.playerHas(pname, world, "place", perms.playerHas(pname, world, "build", true))) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onHangingPlace(final HangingPlaceEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getEntity().getLocation(), player);
|
||||
final String pname = player.getName();
|
||||
final String world = player.getWorld().getName();
|
||||
if (!perms.playerHas(pname, world, "place", perms.playerHas(pname, world, "build", true))) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onSplashPotion(final PotionSplashEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
final Entity ent = event.getEntity();
|
||||
final boolean srcpvp = plugin.getPermsByLoc(ent.getLocation()).has("pvp", true);
|
||||
final Iterator<LivingEntity> it = event.getAffectedEntities().iterator();
|
||||
while (it.hasNext()) {
|
||||
final LivingEntity target = it.next();
|
||||
if (target.getType() == EntityType.PLAYER) {
|
||||
final Boolean tgtpvp = plugin.getPermsByLoc(target.getLocation()).has("pvp", true);
|
||||
if (!srcpvp || !tgtpvp) {
|
||||
event.setIntensity(target, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onSplashPotion(final PotionSplashEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
final Entity ent = event.getEntity();
|
||||
final boolean srcpvp = plugin.getPermsByLoc(ent.getLocation()).has("pvp", true);
|
||||
final Iterator<LivingEntity> it = event.getAffectedEntities().iterator();
|
||||
while (it.hasNext()) {
|
||||
final LivingEntity target = it.next();
|
||||
if (target.getType() == EntityType.PLAYER) {
|
||||
final Boolean tgtpvp = plugin.getPermsByLoc(target.getLocation()).has("pvp", true);
|
||||
if (!srcpvp || !tgtpvp) {
|
||||
event.setIntensity(target, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.bekvon.bukkit.residence.protection.FlagPermissions;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
|
||||
import cn.citycraft.PluginHelper.utils.ActionBar;
|
||||
import cn.citycraft.PluginHelper.utils.CompatibleUtil;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
import cn.citycraft.Residence.chat.ChatChannel;
|
||||
import cn.citycraft.Residence.permissions.PermissionGroup;
|
||||
@@ -52,494 +53,494 @@ import cn.citycraft.Residence.permissions.PermissionGroup;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ResidencePlayerListener implements Listener {
|
||||
|
||||
protected boolean chatenabled;
|
||||
protected Map<String, String> currentRes;
|
||||
protected Map<String, Location> lastOutsideLoc;
|
||||
protected Map<String, Long> lastUpdate;
|
||||
protected int minUpdateTime;
|
||||
protected List<String> playerToggleChat;
|
||||
ResidenceMain plugin;
|
||||
protected boolean chatenabled;
|
||||
protected Map<String, String> currentRes;
|
||||
protected Map<String, Location> lastOutsideLoc;
|
||||
protected Map<String, Long> lastUpdate;
|
||||
protected int minUpdateTime;
|
||||
protected List<String> playerToggleChat;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public ResidencePlayerListener(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
currentRes = new HashMap<>();
|
||||
lastUpdate = new HashMap<>();
|
||||
lastOutsideLoc = new HashMap<>();
|
||||
playerToggleChat = new ArrayList<>();
|
||||
minUpdateTime = plugin.getConfigManager().getMinMoveUpdateInterval();
|
||||
chatenabled = plugin.getConfigManager().chatEnabled();
|
||||
for (final Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
lastUpdate.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
public ResidencePlayerListener(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
currentRes = new HashMap<>();
|
||||
lastUpdate = new HashMap<>();
|
||||
lastOutsideLoc = new HashMap<>();
|
||||
playerToggleChat = new ArrayList<>();
|
||||
minUpdateTime = plugin.getConfigManager().getMinMoveUpdateInterval();
|
||||
chatenabled = plugin.getConfigManager().chatEnabled();
|
||||
for (final Player player : CompatibleUtil.getOnlinePlayers()) {
|
||||
lastUpdate.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
public String getCurrentResidenceName(final String player) {
|
||||
return currentRes.get(player);
|
||||
}
|
||||
public String getCurrentResidenceName(final String player) {
|
||||
return currentRes.get(player);
|
||||
}
|
||||
|
||||
public void handleNewLocation(final Player player, final Location loc, final boolean move) {
|
||||
final String pname = player.getName();
|
||||
public void handleNewLocation(final Player player, final Location loc, final boolean move) {
|
||||
final String pname = player.getName();
|
||||
|
||||
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||
String areaname = null;
|
||||
boolean chatchange = false;
|
||||
String subzone = null;
|
||||
if (res != null) {
|
||||
areaname = plugin.getResidenceManager().getNameByLoc(loc);
|
||||
while (res.getSubzoneByLoc(player.getLocation()) != null) {
|
||||
subzone = res.getSubzoneNameByLoc(player.getLocation());
|
||||
res = res.getSubzoneByLoc(player.getLocation());
|
||||
areaname = areaname + "." + subzone;
|
||||
}
|
||||
}
|
||||
ClaimedResidence ResOld = null;
|
||||
if (currentRes.containsKey(pname)) {
|
||||
ResOld = plugin.getResidenceManager().getByName(currentRes.get(pname));
|
||||
if (ResOld == null) {
|
||||
currentRes.remove(pname);
|
||||
}
|
||||
}
|
||||
if (res == null) {
|
||||
lastOutsideLoc.put(pname, loc);
|
||||
if (ResOld != null) {
|
||||
final String leave = ResOld.getLeaveMessage();
|
||||
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(ResOld, null, player);
|
||||
plugin.getServer().getPluginManager().callEvent(chgEvent);
|
||||
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||
String areaname = null;
|
||||
boolean chatchange = false;
|
||||
String subzone = null;
|
||||
if (res != null) {
|
||||
areaname = plugin.getResidenceManager().getNameByLoc(loc);
|
||||
while (res.getSubzoneByLoc(player.getLocation()) != null) {
|
||||
subzone = res.getSubzoneNameByLoc(player.getLocation());
|
||||
res = res.getSubzoneByLoc(player.getLocation());
|
||||
areaname = areaname + "." + subzone;
|
||||
}
|
||||
}
|
||||
ClaimedResidence ResOld = null;
|
||||
if (currentRes.containsKey(pname)) {
|
||||
ResOld = plugin.getResidenceManager().getByName(currentRes.get(pname));
|
||||
if (ResOld == null) {
|
||||
currentRes.remove(pname);
|
||||
}
|
||||
}
|
||||
if (res == null) {
|
||||
lastOutsideLoc.put(pname, loc);
|
||||
if (ResOld != null) {
|
||||
final String leave = ResOld.getLeaveMessage();
|
||||
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(ResOld, null, player);
|
||||
plugin.getServer().getPluginManager().callEvent(chgEvent);
|
||||
|
||||
if (leave != null && !leave.equals("")) {
|
||||
if (plugin.getConfigManager().useActionBar()) {
|
||||
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||
}
|
||||
}
|
||||
currentRes.remove(pname);
|
||||
plugin.getChatManager().removeFromChannel(pname);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (move && !res.getPermissions().playerHas(pname, "move", true) && !plugin.isResAdminOn(player) && !player.hasPermission("residence.admin.move")) {
|
||||
final Location lastLoc = lastOutsideLoc.get(pname);
|
||||
if (lastLoc != null) {
|
||||
player.teleport(lastLoc);
|
||||
} else {
|
||||
player.teleport(res.getOutsideFreeLoc(loc));
|
||||
}
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMoveDeny", res.getName().split("\\.")[res.getName().split("\\.").length - 1]));
|
||||
return;
|
||||
}
|
||||
lastOutsideLoc.put(pname, loc);
|
||||
if (!currentRes.containsKey(pname) || ResOld != res) {
|
||||
currentRes.put(pname, areaname);
|
||||
if (subzone == null) {
|
||||
chatchange = true;
|
||||
}
|
||||
ClaimedResidence chgFrom = null;
|
||||
if (ResOld != res && ResOld != null) {
|
||||
final String leave = ResOld.getLeaveMessage();
|
||||
chgFrom = ResOld;
|
||||
if (leave != null && !leave.equals("")) {
|
||||
if (plugin.getConfigManager().useActionBar()) {
|
||||
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||
}
|
||||
}
|
||||
currentRes.remove(pname);
|
||||
plugin.getChatManager().removeFromChannel(pname);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (move && !res.getPermissions().playerHas(pname, "move", true) && !plugin.isResAdminOn(player) && !player.hasPermission("residence.admin.move")) {
|
||||
final Location lastLoc = lastOutsideLoc.get(pname);
|
||||
if (lastLoc != null) {
|
||||
player.teleport(lastLoc);
|
||||
} else {
|
||||
player.teleport(res.getOutsideFreeLoc(loc));
|
||||
}
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMoveDeny", res.getName().split("\\.")[res.getName().split("\\.").length - 1]));
|
||||
return;
|
||||
}
|
||||
lastOutsideLoc.put(pname, loc);
|
||||
if (!currentRes.containsKey(pname) || ResOld != res) {
|
||||
currentRes.put(pname, areaname);
|
||||
if (subzone == null) {
|
||||
chatchange = true;
|
||||
}
|
||||
ClaimedResidence chgFrom = null;
|
||||
if (ResOld != res && ResOld != null) {
|
||||
final String leave = ResOld.getLeaveMessage();
|
||||
chgFrom = ResOld;
|
||||
|
||||
if (leave != null && !leave.equals("") && ResOld != res.getParent()) {
|
||||
if (plugin.getConfigManager().useActionBar()) {
|
||||
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||
}
|
||||
}
|
||||
}
|
||||
final String enterMessage = res.getEnterMessage();
|
||||
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(chgFrom, res, player);
|
||||
plugin.getServer().getPluginManager().callEvent(chgEvent);
|
||||
if (leave != null && !leave.equals("") && ResOld != res.getParent()) {
|
||||
if (plugin.getConfigManager().useActionBar()) {
|
||||
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||
}
|
||||
}
|
||||
}
|
||||
final String enterMessage = res.getEnterMessage();
|
||||
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(chgFrom, res, player);
|
||||
plugin.getServer().getPluginManager().callEvent(chgEvent);
|
||||
|
||||
if (enterMessage != null && !enterMessage.equals("") && !(ResOld != null && res == ResOld.getParent())) {
|
||||
if (plugin.getConfigManager().useActionBar()) {
|
||||
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chatchange && chatenabled) {
|
||||
plugin.getChatManager().setChannel(pname, areaname);
|
||||
}
|
||||
}
|
||||
if (enterMessage != null && !enterMessage.equals("") && !(ResOld != null && res == ResOld.getParent())) {
|
||||
if (plugin.getConfigManager().useActionBar()) {
|
||||
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chatchange && chatenabled) {
|
||||
plugin.getChatManager().setChannel(pname, areaname);
|
||||
}
|
||||
}
|
||||
|
||||
public String insertMessages(final Player player, final String areaname, final ClaimedResidence res, String message) {
|
||||
try {
|
||||
message = message.replaceAll("%player", player.getName());
|
||||
message = message.replaceAll("%owner", res.getPermissions().getOwner());
|
||||
message = message.replaceAll("%residence", areaname);
|
||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||
} catch (final Exception ex) {
|
||||
return "";
|
||||
}
|
||||
return message;
|
||||
}
|
||||
public String insertMessages(final Player player, final String areaname, final ClaimedResidence res, String message) {
|
||||
try {
|
||||
message = message.replaceAll("%player", player.getName());
|
||||
message = message.replaceAll("%owner", res.getPermissions().getOwner());
|
||||
message = message.replaceAll("%residence", areaname);
|
||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||
} catch (final Exception ex) {
|
||||
return "";
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final String pname = player.getName();
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
|
||||
if (res != null) {
|
||||
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
|
||||
if (plugin.getRentManager().isRented(res.getName())) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
|
||||
if (!perms.playerHas(pname, player.getWorld().getName(), "bucket", perms.playerHas(pname, player.getWorld().getName(), "build", true))) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final String pname = player.getName();
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
|
||||
if (res != null) {
|
||||
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
|
||||
if (plugin.getRentManager().isRented(res.getName())) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
|
||||
if (!perms.playerHas(pname, player.getWorld().getName(), "bucket", perms.playerHas(pname, player.getWorld().getName(), "build", true))) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final String pname = player.getName();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
|
||||
if (res != null) {
|
||||
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
|
||||
if (plugin.getRentManager().isRented(res.getName())) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
|
||||
final boolean hasbucket = perms.playerHas(pname, player.getWorld().getName(), "bucket", perms.playerHas(pname, player.getWorld().getName(), "build", true));
|
||||
if (!hasbucket) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final String pname = player.getName();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
|
||||
if (res != null) {
|
||||
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
|
||||
if (plugin.getRentManager().isRented(res.getName())) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
|
||||
final boolean hasbucket = perms.playerHas(pname, player.getWorld().getName(), "bucket", perms.playerHas(pname, player.getWorld().getName(), "build", true));
|
||||
if (!hasbucket) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerChat(final AsyncPlayerChatEvent event) {
|
||||
final String pname = event.getPlayer().getName();
|
||||
if (chatenabled && playerToggleChat.contains(pname)) {
|
||||
final String area = currentRes.get(pname);
|
||||
if (area != null) {
|
||||
final ChatChannel channel = plugin.getChatManager().getChannel(area);
|
||||
if (channel != null) {
|
||||
channel.chat(pname, event.getMessage());
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerChat(final AsyncPlayerChatEvent event) {
|
||||
final String pname = event.getPlayer().getName();
|
||||
if (chatenabled && playerToggleChat.contains(pname)) {
|
||||
final String area = currentRes.get(pname);
|
||||
if (area != null) {
|
||||
final ChatChannel channel = plugin.getChatManager().getChannel(area);
|
||||
if (channel != null) {
|
||||
channel.chat(pname, event.getMessage());
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final Material heldItem = player.getItemInHand().getType();
|
||||
final Block block = event.getClickedBlock();
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
final Material mat = block.getType();
|
||||
if (!((isContainer(mat, block) || isCanUseEntity_RClickOnly(mat, block)) && event.getAction() == Action.RIGHT_CLICK_BLOCK || isCanUseEntity_BothClick(mat, block)
|
||||
|| event.getAction() == Action.PHYSICAL)) {
|
||||
final int typeId = player.getItemInHand().getTypeId();
|
||||
if (typeId != plugin.getConfigManager().getSelectionTooldID() && typeId != plugin.getConfigManager().getInfoToolID() && typeId != 351 && typeId != 416) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
FlagPermissions perms = plugin.getPermsByLocForPlayer(block.getLocation(), player);
|
||||
final String world = player.getWorld().getName();
|
||||
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||
final boolean resadmin = plugin.isResAdminOn(player);
|
||||
if (event.getAction() == Action.PHYSICAL) {
|
||||
if (!resadmin) {
|
||||
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
|
||||
final boolean haspressure = perms.playerHas(player.getName(), world, "pressure", hasuse);
|
||||
if ((!hasuse && !haspressure || !haspressure) && (mat == Material.STONE_PLATE || mat == Material.WOOD_PLATE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!perms.playerHas(player.getName(), world, "trample", perms.playerHas(player.getName(), world, "build", true)) && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!resadmin && !plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getSelectionTooldID()) {
|
||||
final Plugin wep = Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||
if (wep != null) {
|
||||
if (((WorldEditPlugin) wep).getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
if (player.hasPermission("residence.select") || player.hasPermission("residence.create") && !player.isPermissionSet("residence.select")
|
||||
|| group.canCreateResidences() && !player.isPermissionSet("residence.create") && !player.isPermissionSet("residence.select") || resadmin) {
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
final Location loc = block.getLocation();
|
||||
plugin.getSelectionManager().placeLoc1(player, loc);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Primary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
|
||||
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
|
||||
event.setCancelled(true);
|
||||
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
final Location loc = block.getLocation();
|
||||
plugin.getSelectionManager().placeLoc2(player, loc);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Secondary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
|
||||
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getInfoToolID()) {
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
final Location loc = block.getLocation();
|
||||
final String res = plugin.getResidenceManager().getNameByLoc(loc);
|
||||
if (res != null) {
|
||||
plugin.getResidenceManager().printAreaInfo(res, player);
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(plugin.getLanguage().getPhrase("NoResHere"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!resadmin) {
|
||||
if (heldItem != null) {
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (player.getItemInHand().getTypeId() == 351) {
|
||||
if (player.getItemInHand().getData().getData() == 15 && block.getType() == Material.GRASS || player.getItemInHand().getData().getData() == 3 && block.getTypeId() == 17
|
||||
&& (block.getData() == 3 || block.getData() == 7 || block.getData() == 11 || block.getData() == 15)) {
|
||||
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
|
||||
if (!perms.playerHas(player.getName(), world, "build", true)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plugin.isGt1_8()) {
|
||||
if (heldItem == Material.ARMOR_STAND) {
|
||||
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
|
||||
if (!perms.playerHas(player.getName(), world, "build", true)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isContainer(mat, block) || isCanUseEntity(mat, block)) {
|
||||
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
|
||||
for (final Entry<Material, String> checkMat : FlagPermissions.getMaterialUseFlagList().entrySet()) {
|
||||
if (mat == checkMat.getKey()) {
|
||||
if (!perms.playerHas(player.getName(), world, checkMat.getValue(), hasuse)) {
|
||||
if (hasuse || checkMat.getValue().equals("container")) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", checkMat.getValue()));
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plugin.getConfigManager().getCustomContainers().contains(block.getTypeId())) {
|
||||
if (!perms.playerHas(player.getName(), world, "container", hasuse)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())) {
|
||||
if (!hasuse) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId())) {
|
||||
if (!hasuse) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final Material heldItem = player.getItemInHand().getType();
|
||||
final Block block = event.getClickedBlock();
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
final Material mat = block.getType();
|
||||
if (!((isContainer(mat, block) || isCanUseEntity_RClickOnly(mat, block)) && event.getAction() == Action.RIGHT_CLICK_BLOCK || isCanUseEntity_BothClick(mat, block)
|
||||
|| event.getAction() == Action.PHYSICAL)) {
|
||||
final int typeId = player.getItemInHand().getTypeId();
|
||||
if (typeId != plugin.getConfigManager().getSelectionTooldID() && typeId != plugin.getConfigManager().getInfoToolID() && typeId != 351 && typeId != 416) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
FlagPermissions perms = plugin.getPermsByLocForPlayer(block.getLocation(), player);
|
||||
final String world = player.getWorld().getName();
|
||||
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||
final boolean resadmin = plugin.isResAdminOn(player);
|
||||
if (event.getAction() == Action.PHYSICAL) {
|
||||
if (!resadmin) {
|
||||
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
|
||||
final boolean haspressure = perms.playerHas(player.getName(), world, "pressure", hasuse);
|
||||
if ((!hasuse && !haspressure || !haspressure) && (mat == Material.STONE_PLATE || mat == Material.WOOD_PLATE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!perms.playerHas(player.getName(), world, "trample", perms.playerHas(player.getName(), world, "build", true)) && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!resadmin && !plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getSelectionTooldID()) {
|
||||
final Plugin wep = Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||
if (wep != null) {
|
||||
if (((WorldEditPlugin) wep).getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
if (player.hasPermission("residence.select") || player.hasPermission("residence.create") && !player.isPermissionSet("residence.select")
|
||||
|| group.canCreateResidences() && !player.isPermissionSet("residence.create") && !player.isPermissionSet("residence.select") || resadmin) {
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
final Location loc = block.getLocation();
|
||||
plugin.getSelectionManager().placeLoc1(player, loc);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Primary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
|
||||
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
|
||||
event.setCancelled(true);
|
||||
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
final Location loc = block.getLocation();
|
||||
plugin.getSelectionManager().placeLoc2(player, loc);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Secondary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
|
||||
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getInfoToolID()) {
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
final Location loc = block.getLocation();
|
||||
final String res = plugin.getResidenceManager().getNameByLoc(loc);
|
||||
if (res != null) {
|
||||
plugin.getResidenceManager().printAreaInfo(res, player);
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(plugin.getLanguage().getPhrase("NoResHere"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!resadmin) {
|
||||
if (heldItem != null) {
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (player.getItemInHand().getTypeId() == 351) {
|
||||
if (player.getItemInHand().getData().getData() == 15 && block.getType() == Material.GRASS || player.getItemInHand().getData().getData() == 3 && block.getTypeId() == 17
|
||||
&& (block.getData() == 3 || block.getData() == 7 || block.getData() == 11 || block.getData() == 15)) {
|
||||
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
|
||||
if (!perms.playerHas(player.getName(), world, "build", true)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plugin.isGt1_8()) {
|
||||
if (heldItem == Material.ARMOR_STAND) {
|
||||
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
|
||||
if (!perms.playerHas(player.getName(), world, "build", true)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isContainer(mat, block) || isCanUseEntity(mat, block)) {
|
||||
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
|
||||
for (final Entry<Material, String> checkMat : FlagPermissions.getMaterialUseFlagList().entrySet()) {
|
||||
if (mat == checkMat.getKey()) {
|
||||
if (!perms.playerHas(player.getName(), world, checkMat.getValue(), hasuse)) {
|
||||
if (hasuse || checkMat.getValue().equals("container")) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", checkMat.getValue()));
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plugin.getConfigManager().getCustomContainers().contains(block.getTypeId())) {
|
||||
if (!perms.playerHas(player.getName(), world, "container", hasuse)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())) {
|
||||
if (!hasuse) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId())) {
|
||||
if (!hasuse) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerInteractEntity(final PlayerInteractEntityEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final Entity ent = event.getRightClicked();
|
||||
/* Trade */
|
||||
if (ent.getType() == EntityType.VILLAGER) {
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getPlayer().getLocation());
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerInteractEntity(final PlayerInteractEntityEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
final Entity ent = event.getRightClicked();
|
||||
/* Trade */
|
||||
if (ent.getType() == EntityType.VILLAGER) {
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getPlayer().getLocation());
|
||||
|
||||
if (res != null && !res.getPermissions().playerHas(player.getName(), "trade", true)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
/* Container - ItemFrame protection */
|
||||
final Material heldItem = player.getItemInHand().getType();
|
||||
if (!(ent instanceof Hanging)) {
|
||||
return;
|
||||
}
|
||||
final Hanging hanging = (Hanging) ent;
|
||||
if (hanging.getType() != EntityType.ITEM_FRAME) {
|
||||
return;
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(ent.getLocation(), player);
|
||||
final String world = player.getWorld().getName();
|
||||
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||
if (!plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!perms.playerHas(player.getName(), world, "container", perms.playerHas(player.getName(), world, "use", true))) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
||||
}
|
||||
}
|
||||
if (res != null && !res.getPermissions().playerHas(player.getName(), "trade", true)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
/* Container - ItemFrame protection */
|
||||
final Material heldItem = player.getItemInHand().getType();
|
||||
if (!(ent instanceof Hanging)) {
|
||||
return;
|
||||
}
|
||||
final Hanging hanging = (Hanging) ent;
|
||||
if (hanging.getType() != EntityType.ITEM_FRAME) {
|
||||
return;
|
||||
}
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(ent.getLocation(), player);
|
||||
final String world = player.getWorld().getName();
|
||||
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||
if (!plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!perms.playerHas(player.getName(), world, "container", perms.playerHas(player.getName(), world, "use", true))) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
lastUpdate.put(player.getName(), 0L);
|
||||
if (plugin.getPermissionManager().isResidenceAdmin(player)) {
|
||||
plugin.turnResAdminOn(player);
|
||||
}
|
||||
handleNewLocation(player, player.getLocation(), false);
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
lastUpdate.put(player.getName(), 0L);
|
||||
if (plugin.getPermissionManager().isResidenceAdmin(player)) {
|
||||
plugin.turnResAdminOn(player);
|
||||
}
|
||||
handleNewLocation(player, player.getLocation(), false);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerMove(final PlayerMoveEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
final long now = System.currentTimeMillis();
|
||||
if (!lastUpdate.containsKey(player.getName())) {
|
||||
lastUpdate.put(player.getName(), now);
|
||||
return;
|
||||
}
|
||||
final long last = lastUpdate.get(player.getName());
|
||||
if (now - last < plugin.getConfigManager().getMinMoveUpdateInterval()) {
|
||||
return;
|
||||
}
|
||||
lastUpdate.put(player.getName(), now);
|
||||
if (event.getFrom().getWorld() == event.getTo().getWorld()) {
|
||||
if (event.getFrom().distance(event.getTo()) == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
handleNewLocation(player, event.getTo(), true);
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerMove(final PlayerMoveEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
final long now = System.currentTimeMillis();
|
||||
if (!lastUpdate.containsKey(player.getName())) {
|
||||
lastUpdate.put(player.getName(), now);
|
||||
return;
|
||||
}
|
||||
final long last = lastUpdate.get(player.getName());
|
||||
if (now - last < plugin.getConfigManager().getMinMoveUpdateInterval()) {
|
||||
return;
|
||||
}
|
||||
lastUpdate.put(player.getName(), now);
|
||||
if (event.getFrom().getWorld() == event.getTo().getWorld()) {
|
||||
if (event.getFrom().distance(event.getTo()) == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
handleNewLocation(player, event.getTo(), true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(final PlayerQuitEvent event) {
|
||||
final String pname = event.getPlayer().getName();
|
||||
currentRes.remove(pname);
|
||||
lastUpdate.remove(pname);
|
||||
lastOutsideLoc.remove(pname);
|
||||
plugin.getChatManager().removeFromChannel(pname);
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(final PlayerQuitEvent event) {
|
||||
final String pname = event.getPlayer().getName();
|
||||
currentRes.remove(pname);
|
||||
lastUpdate.remove(pname);
|
||||
lastOutsideLoc.remove(pname);
|
||||
plugin.getChatManager().removeFromChannel(pname);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerSpawn(final PlayerRespawnEvent event) {
|
||||
Location loc = event.getRespawnLocation();
|
||||
final Boolean bed = event.isBedSpawn();
|
||||
final Player player = event.getPlayer();
|
||||
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||
if (res == null) {
|
||||
return;
|
||||
}
|
||||
if (res.getPermissions().playerHas(player.getName(), "move", true)) {
|
||||
return;
|
||||
}
|
||||
if (bed) {
|
||||
loc = player.getWorld().getSpawnLocation();
|
||||
}
|
||||
res = plugin.getResidenceManager().getByLoc(loc);
|
||||
if (res != null) {
|
||||
if (!res.getPermissions().playerHas(player.getName(), "move", true)) {
|
||||
loc = res.getOutsideFreeLoc(loc);
|
||||
}
|
||||
}
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoSpawn"));
|
||||
event.setRespawnLocation(loc);
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerSpawn(final PlayerRespawnEvent event) {
|
||||
Location loc = event.getRespawnLocation();
|
||||
final Boolean bed = event.isBedSpawn();
|
||||
final Player player = event.getPlayer();
|
||||
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||
if (res == null) {
|
||||
return;
|
||||
}
|
||||
if (res.getPermissions().playerHas(player.getName(), "move", true)) {
|
||||
return;
|
||||
}
|
||||
if (bed) {
|
||||
loc = player.getWorld().getSpawnLocation();
|
||||
}
|
||||
res = plugin.getResidenceManager().getByLoc(loc);
|
||||
if (res != null) {
|
||||
if (!res.getPermissions().playerHas(player.getName(), "move", true)) {
|
||||
loc = res.getOutsideFreeLoc(loc);
|
||||
}
|
||||
}
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoSpawn"));
|
||||
event.setRespawnLocation(loc);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event) {
|
||||
final Location loc = event.getTo();
|
||||
final Player player = event.getPlayer();
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||
if (res != null) {
|
||||
if (plugin.isResAdminOn(player) || ((res.getPermissions().playerHas(player.getName(), "tp", true) || player.hasPermission("residence.admin.tp"))
|
||||
&& (res.getPermissions().playerHas(player.getName(), "move", true) || player.hasPermission("residence.admin.move")))) {
|
||||
handleNewLocation(player, loc, false);
|
||||
} else {
|
||||
final String areaname = res.getName();
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("TeleportDeny", areaname));
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event) {
|
||||
final Location loc = event.getTo();
|
||||
final Player player = event.getPlayer();
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||
if (res != null) {
|
||||
if (plugin.isResAdminOn(player) || ((res.getPermissions().playerHas(player.getName(), "tp", true) || player.hasPermission("residence.admin.tp"))
|
||||
&& (res.getPermissions().playerHas(player.getName(), "move", true) || player.hasPermission("residence.admin.move")))) {
|
||||
handleNewLocation(player, loc, false);
|
||||
} else {
|
||||
final String areaname = res.getName();
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("TeleportDeny", areaname));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void tooglePlayerResidenceChat(final Player player) {
|
||||
final String pname = player.getName();
|
||||
if (playerToggleChat.contains(pname)) {
|
||||
playerToggleChat.remove(pname);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "OFF" + ChatColor.YELLOW + "!"));
|
||||
} else {
|
||||
playerToggleChat.add(pname);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "ON" + ChatColor.YELLOW + "!"));
|
||||
}
|
||||
}
|
||||
public void tooglePlayerResidenceChat(final Player player) {
|
||||
final String pname = player.getName();
|
||||
if (playerToggleChat.contains(pname)) {
|
||||
playerToggleChat.remove(pname);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "OFF" + ChatColor.YELLOW + "!"));
|
||||
} else {
|
||||
playerToggleChat.add(pname);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "ON" + ChatColor.YELLOW + "!"));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCanUseEntity(final Material mat, final Block block) {
|
||||
return isCanUseEntity_BothClick(mat, block) || isCanUseEntity_RClickOnly(mat, block);
|
||||
}
|
||||
private boolean isCanUseEntity(final Material mat, final Block block) {
|
||||
return isCanUseEntity_BothClick(mat, block) || isCanUseEntity_RClickOnly(mat, block);
|
||||
}
|
||||
|
||||
private boolean isCanUseEntity_BothClick(final Material mat, final Block block) {
|
||||
return mat == Material.LEVER || mat == Material.STONE_BUTTON || mat == Material.WOOD_BUTTON || mat == Material.WOODEN_DOOR || mat == Material.TRAP_DOOR || mat == Material.FENCE_GATE
|
||||
|| mat == Material.PISTON_BASE || mat == Material.PISTON_STICKY_BASE || mat == Material.DRAGON_EGG || plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())
|
||||
|| (plugin.isGt1_8() && (mat == Material.SPRUCE_DOOR || mat == Material.BIRCH_DOOR || mat == Material.JUNGLE_DOOR || mat == Material.ACACIA_DOOR || mat == Material.DARK_OAK_DOOR
|
||||
|| mat == Material.SPRUCE_FENCE_GATE || mat == Material.BIRCH_FENCE_GATE || mat == Material.JUNGLE_FENCE_GATE || mat == Material.ACACIA_FENCE_GATE
|
||||
|| mat == Material.DARK_OAK_FENCE_GATE));
|
||||
}
|
||||
private boolean isCanUseEntity_BothClick(final Material mat, final Block block) {
|
||||
return mat == Material.LEVER || mat == Material.STONE_BUTTON || mat == Material.WOOD_BUTTON || mat == Material.WOODEN_DOOR || mat == Material.TRAP_DOOR || mat == Material.FENCE_GATE
|
||||
|| mat == Material.PISTON_BASE || mat == Material.PISTON_STICKY_BASE || mat == Material.DRAGON_EGG || plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())
|
||||
|| (plugin.isGt1_8() && (mat == Material.SPRUCE_DOOR || mat == Material.BIRCH_DOOR || mat == Material.JUNGLE_DOOR || mat == Material.ACACIA_DOOR || mat == Material.DARK_OAK_DOOR
|
||||
|| mat == Material.SPRUCE_FENCE_GATE || mat == Material.BIRCH_FENCE_GATE || mat == Material.JUNGLE_FENCE_GATE || mat == Material.ACACIA_FENCE_GATE
|
||||
|| mat == Material.DARK_OAK_FENCE_GATE));
|
||||
}
|
||||
|
||||
private boolean isCanUseEntity_RClickOnly(final Material mat, final Block block) {
|
||||
return mat == Material.ITEM_FRAME || mat == Material.BEACON || mat == Material.FLOWER_POT || mat == Material.COMMAND || mat == Material.ANVIL || mat == Material.CAKE_BLOCK
|
||||
|| mat == Material.NOTE_BLOCK || mat == Material.DIODE || mat == Material.DIODE_BLOCK_OFF || mat == Material.DIODE_BLOCK_ON || mat == Material.BED_BLOCK || mat == Material.WORKBENCH
|
||||
|| mat == Material.BREWING_STAND || mat == Material.ENCHANTMENT_TABLE || plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId());
|
||||
}
|
||||
private boolean isCanUseEntity_RClickOnly(final Material mat, final Block block) {
|
||||
return mat == Material.ITEM_FRAME || mat == Material.BEACON || mat == Material.FLOWER_POT || mat == Material.COMMAND || mat == Material.ANVIL || mat == Material.CAKE_BLOCK
|
||||
|| mat == Material.NOTE_BLOCK || mat == Material.DIODE || mat == Material.DIODE_BLOCK_OFF || mat == Material.DIODE_BLOCK_ON || mat == Material.BED_BLOCK || mat == Material.WORKBENCH
|
||||
|| mat == Material.BREWING_STAND || mat == Material.ENCHANTMENT_TABLE || plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId());
|
||||
}
|
||||
|
||||
private boolean isContainer(final Material mat, final Block block) {
|
||||
return FlagPermissions.getMaterialUseFlagList().containsKey(mat) && FlagPermissions.getMaterialUseFlagList().get(mat).equals("container")
|
||||
|| plugin.getConfigManager().getCustomContainers().contains(block.getTypeId());
|
||||
}
|
||||
private boolean isContainer(final Material mat, final Block block) {
|
||||
return FlagPermissions.getMaterialUseFlagList().containsKey(mat) && FlagPermissions.getMaterialUseFlagList().get(mat).equals("container")
|
||||
|| plugin.getConfigManager().getCustomContainers().contains(block.getTypeId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,31 +23,31 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class ResidencePlayerListener_1_8 implements Listener {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public ResidencePlayerListener_1_8(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public ResidencePlayerListener_1_8(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (plugin.isResAdminOn(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Entity ent = event.getRightClicked();
|
||||
if (ent.getType() != EntityType.ARMOR_STAND) {
|
||||
return;
|
||||
}
|
||||
final Entity ent = event.getRightClicked();
|
||||
if (ent.getType() != EntityType.ARMOR_STAND) {
|
||||
return;
|
||||
}
|
||||
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(ent.getLocation(), player);
|
||||
final String world = player.getWorld().getName();
|
||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(ent.getLocation(), player);
|
||||
final String world = player.getWorld().getName();
|
||||
|
||||
if (!perms.playerHas(player.getName(), world, "container", perms.playerHas(player.getName(), world, "use", true))) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
||||
}
|
||||
}
|
||||
if (!perms.playerHas(player.getName(), world, "container", perms.playerHas(player.getName(), world, "use", true))) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,117 +18,117 @@ import com.bekvon.bukkit.residence.protection.FlagPermissions;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class ResidenceBugFix implements Listener {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public ResidenceBugFix(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.getLogger().info("防刷甘蔗补丁已加载...");
|
||||
plugin.getLogger().info("防刷单元补丁已加载...");
|
||||
plugin.getLogger().info("防刷铁轨补丁已加载...");
|
||||
plugin.getLogger().info("防刷生物补丁已加载...");
|
||||
}
|
||||
public ResidenceBugFix(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.getLogger().info("防刷甘蔗补丁已加载...");
|
||||
plugin.getLogger().info("防刷单元补丁已加载...");
|
||||
plugin.getLogger().info("防刷铁轨补丁已加载...");
|
||||
plugin.getLogger().info("防刷生物补丁已加载...");
|
||||
}
|
||||
|
||||
public Block getPlaceBlock(final PlayerInteractEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
final ItemStack it = p.getItemInHand();
|
||||
if (it == null || it.getType() == Material.AIR) {
|
||||
return null;
|
||||
}
|
||||
final Block b = e.getClickedBlock();
|
||||
final BlockFace bf = e.getBlockFace();
|
||||
if (bf == null) {
|
||||
return null;
|
||||
}
|
||||
return b.getRelative(bf, 1);
|
||||
}
|
||||
public Block getPlaceBlock(final PlayerInteractEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
final ItemStack it = p.getItemInHand();
|
||||
if (it == null || it.getType() == Material.AIR) {
|
||||
return null;
|
||||
}
|
||||
final Block b = e.getClickedBlock();
|
||||
final BlockFace bf = e.getBlockFace();
|
||||
if (bf == null) {
|
||||
return null;
|
||||
}
|
||||
return b.getRelative(bf, 1);
|
||||
}
|
||||
|
||||
public Block getPlaceBlockDown(final PlayerInteractEvent e) {
|
||||
final Block b = this.getPlaceBlock(e);
|
||||
return b.getRelative(BlockFace.DOWN);
|
||||
}
|
||||
public Block getPlaceBlockDown(final PlayerInteractEvent e) {
|
||||
final Block b = this.getPlaceBlock(e);
|
||||
return b.getRelative(BlockFace.DOWN);
|
||||
}
|
||||
|
||||
public boolean hasPerm(final ClaimedResidence res, final Player p) {
|
||||
final FlagPermissions perms = res.getPermissions();
|
||||
final String world = p.getWorld().getName();
|
||||
return perms.playerHas(p.getName(), world, "place", perms.playerHas(p.getName(), world, "build", false));
|
||||
}
|
||||
public boolean hasPerm(final ClaimedResidence res, final Player p) {
|
||||
final FlagPermissions perms = res.getPermissions();
|
||||
final String world = p.getWorld().getName();
|
||||
return perms.playerHas(p.getName(), world, "place", perms.playerHas(p.getName(), world, "build", false));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(final PlayerInteractEvent e) {
|
||||
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.PHYSICAL) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Block b = this.getPlaceBlockDown(e);
|
||||
if (b == null) {
|
||||
return;
|
||||
}
|
||||
final Player p = e.getPlayer();
|
||||
final ItemStack it = p.getItemInHand();
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(b.getLocation());
|
||||
if (res == null) {
|
||||
return;
|
||||
}
|
||||
if ((it.getType() == Material.PUMPKIN && (b.getType() == Material.SNOW_BLOCK || b.getType() == Material.IRON_BLOCK))
|
||||
|| (it.getType() == Material.SKULL_ITEM && b.getType() == Material.SOUL_SAND)) {
|
||||
if (!hasPerm(res, p)) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许放置!");
|
||||
}
|
||||
}
|
||||
} catch (final Exception e2) {
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onBlockPlace(final PlayerInteractEvent e) {
|
||||
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.PHYSICAL) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Block b = this.getPlaceBlockDown(e);
|
||||
if (b == null) {
|
||||
return;
|
||||
}
|
||||
final Player p = e.getPlayer();
|
||||
final ItemStack it = p.getItemInHand();
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(b.getLocation());
|
||||
if (res == null) {
|
||||
return;
|
||||
}
|
||||
if ((it.getType() == Material.PUMPKIN && (b.getType() == Material.SNOW_BLOCK || b.getType() == Material.IRON_BLOCK))
|
||||
|| (it.getType() == Material.SKULL_ITEM && b.getType() == Material.SOUL_SAND)) {
|
||||
if (!hasPerm(res, p)) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许放置!");
|
||||
}
|
||||
}
|
||||
} catch (final Exception e2) {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlace(final PlayerInteractEvent e) {
|
||||
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.PHYSICAL) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Player p = e.getPlayer();
|
||||
final ItemStack it = p.getItemInHand();
|
||||
if (it == null || it.getType() == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
final Block b = e.getClickedBlock();
|
||||
final BlockFace bf = e.getBlockFace();
|
||||
if (bf == null || bf != BlockFace.UP) {
|
||||
return;
|
||||
}
|
||||
final Block b1 = b.getRelative(bf, 1);
|
||||
final Block b2 = b.getRelative(bf, 2);
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(b1.getLocation());
|
||||
if (res == null) {
|
||||
return;
|
||||
}
|
||||
if (b1.getType() != Material.AIR && b1.getType() != Material.TORCH && b2.getType() == Material.AIR && checkAround(b2)) {
|
||||
if (!hasPerm(res, p)) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许此操作!");
|
||||
}
|
||||
}
|
||||
} catch (final Exception e2) {
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlace(final PlayerInteractEvent e) {
|
||||
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.PHYSICAL) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Player p = e.getPlayer();
|
||||
final ItemStack it = p.getItemInHand();
|
||||
if (it == null || it.getType() == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
final Block b = e.getClickedBlock();
|
||||
final BlockFace bf = e.getBlockFace();
|
||||
if (bf == null || bf != BlockFace.UP) {
|
||||
return;
|
||||
}
|
||||
final Block b1 = b.getRelative(bf, 1);
|
||||
final Block b2 = b.getRelative(bf, 2);
|
||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(b1.getLocation());
|
||||
if (res == null) {
|
||||
return;
|
||||
}
|
||||
if (b1.getType() != Material.AIR && b1.getType() != Material.TORCH && b2.getType() == Material.AIR && checkAround(b2)) {
|
||||
if (!hasPerm(res, p)) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许此操作!");
|
||||
}
|
||||
}
|
||||
} catch (final Exception e2) {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRailsPhysics(final BlockPhysicsEvent e) {
|
||||
final Material mat = e.getChangedType();
|
||||
if (mat == Material.RAILS || mat == Material.POWERED_RAIL || mat == Material.ACTIVATOR_RAIL || mat == Material.DETECTOR_RAIL) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onRailsPhysics(final BlockPhysicsEvent e) {
|
||||
final Material mat = e.getChangedType();
|
||||
if (mat == Material.RAILS || mat == Material.POWERED_RAIL || mat == Material.ACTIVATOR_RAIL || mat == Material.DETECTOR_RAIL) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSugarCanePhysics(final BlockPhysicsEvent e) {
|
||||
}
|
||||
@EventHandler
|
||||
public void onSugarCanePhysics(final BlockPhysicsEvent e) {
|
||||
}
|
||||
|
||||
private boolean checkAround(final Block b) {
|
||||
final Block be = b.getRelative(BlockFace.EAST);
|
||||
final Block bw = b.getRelative(BlockFace.WEST);
|
||||
final Block bn = b.getRelative(BlockFace.NORTH);
|
||||
final Block bs = b.getRelative(BlockFace.SOUTH);
|
||||
return (be.getType() != Material.AIR || bw.getType() != Material.AIR || bn.getType() != Material.AIR || bs.getType() != Material.AIR);
|
||||
}
|
||||
private boolean checkAround(final Block b) {
|
||||
final Block be = b.getRelative(BlockFace.EAST);
|
||||
final Block bw = b.getRelative(BlockFace.WEST);
|
||||
final Block bn = b.getRelative(BlockFace.NORTH);
|
||||
final Block bs = b.getRelative(BlockFace.SOUTH);
|
||||
return (be.getType() != Material.AIR || bw.getType() != Material.AIR || bn.getType() != Material.AIR || bs.getType() != Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,257 +24,257 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class ConfigManager {
|
||||
private boolean enforceAreaInsideArea;
|
||||
protected boolean actionBar;
|
||||
protected boolean adminOps;
|
||||
protected boolean adminsOnly;
|
||||
protected boolean allowEmptyResidences;
|
||||
protected int autoSaveInt;
|
||||
protected ChatColor chatColor;
|
||||
protected boolean chatEnable;
|
||||
protected List<Integer> customBothClick;
|
||||
protected List<Integer> customContainers;
|
||||
protected List<Integer> customRightClick;
|
||||
protected String defaultGroup;
|
||||
protected String economySystem;
|
||||
protected boolean enableDebug;
|
||||
protected boolean enableEconomy;
|
||||
protected boolean enableLeaseMoneyAccount;
|
||||
protected boolean enableRentSystem;
|
||||
protected boolean flagsInherit;
|
||||
protected FlagPermissions globalCreatorDefaults;
|
||||
protected Map<String, FlagPermissions> globalGroupDefaults;
|
||||
protected FlagPermissions globalResidenceDefaults;
|
||||
protected int infoToolId;
|
||||
protected String language;
|
||||
protected boolean leaseAutoRenew;
|
||||
protected int leaseCheckInterval;
|
||||
protected boolean legacyperms;
|
||||
protected int minMoveUpdate;
|
||||
protected String multiworldPlugin;
|
||||
protected String namefix;
|
||||
protected ResidenceMain plugin;
|
||||
protected boolean preventBuildInRent;
|
||||
protected int rentCheckInterval;
|
||||
protected int selectionToolId;
|
||||
protected boolean showIntervalMessages;
|
||||
protected boolean spoutEnable;
|
||||
protected boolean stopOnSaveError;
|
||||
protected boolean useLeases;
|
||||
private boolean enforceAreaInsideArea;
|
||||
protected boolean actionBar;
|
||||
protected boolean adminOps;
|
||||
protected boolean adminsOnly;
|
||||
protected boolean allowEmptyResidences;
|
||||
protected int autoSaveInt;
|
||||
protected ChatColor chatColor;
|
||||
protected boolean chatEnable;
|
||||
protected List<Integer> customBothClick;
|
||||
protected List<Integer> customContainers;
|
||||
protected List<Integer> customRightClick;
|
||||
protected String defaultGroup;
|
||||
protected String economySystem;
|
||||
protected boolean enableDebug;
|
||||
protected boolean enableEconomy;
|
||||
protected boolean enableLeaseMoneyAccount;
|
||||
protected boolean enableRentSystem;
|
||||
protected boolean flagsInherit;
|
||||
protected FlagPermissions globalCreatorDefaults;
|
||||
protected Map<String, FlagPermissions> globalGroupDefaults;
|
||||
protected FlagPermissions globalResidenceDefaults;
|
||||
protected int infoToolId;
|
||||
protected String language;
|
||||
protected boolean leaseAutoRenew;
|
||||
protected int leaseCheckInterval;
|
||||
protected boolean legacyperms;
|
||||
protected int minMoveUpdate;
|
||||
protected String multiworldPlugin;
|
||||
protected String namefix;
|
||||
protected ResidenceMain plugin;
|
||||
protected boolean preventBuildInRent;
|
||||
protected int rentCheckInterval;
|
||||
protected int selectionToolId;
|
||||
protected boolean showIntervalMessages;
|
||||
protected boolean spoutEnable;
|
||||
protected boolean stopOnSaveError;
|
||||
protected boolean useLeases;
|
||||
|
||||
public ConfigManager(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
globalCreatorDefaults = new FlagPermissions();
|
||||
globalResidenceDefaults = new FlagPermissions();
|
||||
globalGroupDefaults = new HashMap<String, FlagPermissions>();
|
||||
this.load(plugin.getConfig());
|
||||
}
|
||||
public ConfigManager(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
globalCreatorDefaults = new FlagPermissions();
|
||||
globalResidenceDefaults = new FlagPermissions();
|
||||
globalGroupDefaults = new HashMap<String, FlagPermissions>();
|
||||
this.load(plugin.getConfig());
|
||||
}
|
||||
|
||||
public boolean allowAdminsOnly() {
|
||||
return adminsOnly;
|
||||
}
|
||||
public boolean allowAdminsOnly() {
|
||||
return adminsOnly;
|
||||
}
|
||||
|
||||
public boolean allowEmptyResidences() {
|
||||
return allowEmptyResidences;
|
||||
}
|
||||
public boolean allowEmptyResidences() {
|
||||
return allowEmptyResidences;
|
||||
}
|
||||
|
||||
public boolean autoRenewLeases() {
|
||||
return leaseAutoRenew;
|
||||
}
|
||||
public boolean autoRenewLeases() {
|
||||
return leaseAutoRenew;
|
||||
}
|
||||
|
||||
public boolean chatEnabled() {
|
||||
return chatEnable;
|
||||
}
|
||||
public boolean chatEnabled() {
|
||||
return chatEnable;
|
||||
}
|
||||
|
||||
public boolean debugEnabled() {
|
||||
return enableDebug;
|
||||
}
|
||||
public boolean debugEnabled() {
|
||||
return enableDebug;
|
||||
}
|
||||
|
||||
public boolean enabledRentSystem() {
|
||||
return enableRentSystem && enableEconomy();
|
||||
}
|
||||
public boolean enabledRentSystem() {
|
||||
return enableRentSystem && enableEconomy();
|
||||
}
|
||||
|
||||
public boolean enableEconomy() {
|
||||
return enableEconomy && plugin.getEconomyManager() != null;
|
||||
}
|
||||
public boolean enableEconomy() {
|
||||
return enableEconomy && plugin.getEconomyManager() != null;
|
||||
}
|
||||
|
||||
public boolean enableLeaseMoneyAccount() {
|
||||
return enableLeaseMoneyAccount;
|
||||
}
|
||||
public boolean enableLeaseMoneyAccount() {
|
||||
return enableLeaseMoneyAccount;
|
||||
}
|
||||
|
||||
public boolean enableSpout() {
|
||||
return spoutEnable;
|
||||
}
|
||||
public boolean enableSpout() {
|
||||
return spoutEnable;
|
||||
}
|
||||
|
||||
public boolean flagsInherit() {
|
||||
return flagsInherit;
|
||||
}
|
||||
public boolean flagsInherit() {
|
||||
return flagsInherit;
|
||||
}
|
||||
|
||||
public int getAutoSaveInterval() {
|
||||
return autoSaveInt;
|
||||
}
|
||||
public int getAutoSaveInterval() {
|
||||
return autoSaveInt;
|
||||
}
|
||||
|
||||
public ChatColor getChatColor() {
|
||||
return chatColor;
|
||||
}
|
||||
public ChatColor getChatColor() {
|
||||
return chatColor;
|
||||
}
|
||||
|
||||
public List<Integer> getCustomBothClick() {
|
||||
return customBothClick;
|
||||
}
|
||||
public List<Integer> getCustomBothClick() {
|
||||
return customBothClick;
|
||||
}
|
||||
|
||||
public List<Integer> getCustomContainers() {
|
||||
return customContainers;
|
||||
}
|
||||
public List<Integer> getCustomContainers() {
|
||||
return customContainers;
|
||||
}
|
||||
|
||||
public List<Integer> getCustomRightClick() {
|
||||
return customRightClick;
|
||||
}
|
||||
public List<Integer> getCustomRightClick() {
|
||||
return customRightClick;
|
||||
}
|
||||
|
||||
public String getDefaultGroup() {
|
||||
return defaultGroup;
|
||||
}
|
||||
public String getDefaultGroup() {
|
||||
return defaultGroup;
|
||||
}
|
||||
|
||||
public String getEconomySystem() {
|
||||
return economySystem;
|
||||
}
|
||||
public String getEconomySystem() {
|
||||
return economySystem;
|
||||
}
|
||||
|
||||
public boolean getEnforceAreaInsideArea() {
|
||||
return enforceAreaInsideArea;
|
||||
}
|
||||
public boolean getEnforceAreaInsideArea() {
|
||||
return enforceAreaInsideArea;
|
||||
}
|
||||
|
||||
public FlagPermissions getGlobalCreatorDefaultFlags() {
|
||||
return globalCreatorDefaults;
|
||||
}
|
||||
public FlagPermissions getGlobalCreatorDefaultFlags() {
|
||||
return globalCreatorDefaults;
|
||||
}
|
||||
|
||||
public Map<String, FlagPermissions> getGlobalGroupDefaultFlags() {
|
||||
return globalGroupDefaults;
|
||||
}
|
||||
public Map<String, FlagPermissions> getGlobalGroupDefaultFlags() {
|
||||
return globalGroupDefaults;
|
||||
}
|
||||
|
||||
public FlagPermissions getGlobalResidenceDefaultFlags() {
|
||||
return globalResidenceDefaults;
|
||||
}
|
||||
public FlagPermissions getGlobalResidenceDefaultFlags() {
|
||||
return globalResidenceDefaults;
|
||||
}
|
||||
|
||||
public int getInfoToolID() {
|
||||
return infoToolId;
|
||||
}
|
||||
public int getInfoToolID() {
|
||||
return infoToolId;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public int getLeaseCheckInterval() {
|
||||
return leaseCheckInterval;
|
||||
}
|
||||
public int getLeaseCheckInterval() {
|
||||
return leaseCheckInterval;
|
||||
}
|
||||
|
||||
public int getMinMoveUpdateInterval() {
|
||||
return minMoveUpdate;
|
||||
}
|
||||
public int getMinMoveUpdateInterval() {
|
||||
return minMoveUpdate;
|
||||
}
|
||||
|
||||
public String getMultiworldPlugin() {
|
||||
return multiworldPlugin;
|
||||
}
|
||||
public String getMultiworldPlugin() {
|
||||
return multiworldPlugin;
|
||||
}
|
||||
|
||||
public boolean getOpsAreAdmins() {
|
||||
return adminOps;
|
||||
}
|
||||
public boolean getOpsAreAdmins() {
|
||||
return adminOps;
|
||||
}
|
||||
|
||||
public int getRentCheckInterval() {
|
||||
return rentCheckInterval;
|
||||
}
|
||||
public int getRentCheckInterval() {
|
||||
return rentCheckInterval;
|
||||
}
|
||||
|
||||
public String getResidenceNameRegex() {
|
||||
return namefix;
|
||||
}
|
||||
public String getResidenceNameRegex() {
|
||||
return namefix;
|
||||
}
|
||||
|
||||
public int getSelectionTooldID() {
|
||||
return selectionToolId;
|
||||
}
|
||||
public int getSelectionTooldID() {
|
||||
return selectionToolId;
|
||||
}
|
||||
|
||||
public boolean preventRentModify() {
|
||||
return preventBuildInRent;
|
||||
}
|
||||
public boolean preventRentModify() {
|
||||
return preventBuildInRent;
|
||||
}
|
||||
|
||||
public boolean showIntervalMessages() {
|
||||
return showIntervalMessages;
|
||||
}
|
||||
public boolean showIntervalMessages() {
|
||||
return showIntervalMessages;
|
||||
}
|
||||
|
||||
public boolean stopOnSaveError() {
|
||||
return stopOnSaveError;
|
||||
}
|
||||
public boolean stopOnSaveError() {
|
||||
return stopOnSaveError;
|
||||
}
|
||||
|
||||
public boolean useActionBar() {
|
||||
return actionBar;
|
||||
}
|
||||
public boolean useActionBar() {
|
||||
return actionBar;
|
||||
}
|
||||
|
||||
public boolean useLeases() {
|
||||
return useLeases;
|
||||
}
|
||||
public boolean useLeases() {
|
||||
return useLeases;
|
||||
}
|
||||
|
||||
public boolean useLegacyPermissions() {
|
||||
return legacyperms;
|
||||
}
|
||||
public boolean useLegacyPermissions() {
|
||||
return legacyperms;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void load(final FileConfiguration config) {
|
||||
try {
|
||||
if (!config.isConfigurationSection("Global")) {
|
||||
plugin.getLogger().warning("配置文件主键丢失 恢复默认配置文件!");
|
||||
plugin.getConfig().addDefaults(new FileConfig(plugin));
|
||||
}
|
||||
defaultGroup = config.getString("Global.DefaultGroup", "default").toLowerCase();
|
||||
adminsOnly = config.getBoolean("Global.AdminOnlyCommands", false);
|
||||
useLeases = config.getBoolean("Global.UseLeaseSystem", false);
|
||||
leaseAutoRenew = config.getBoolean("Global.LeaseAutoRenew", true);
|
||||
enableEconomy = config.getBoolean("Global.EnableEconomy", false);
|
||||
economySystem = config.getString("Global.EconomySystem", "iConomy");
|
||||
infoToolId = config.getInt("Global.InfoToolId", Material.STRING.getId());
|
||||
selectionToolId = config.getInt("Global.SelectionToolId", Material.WOOD_AXE.getId());
|
||||
adminOps = config.getBoolean("Global.AdminOPs", true);
|
||||
multiworldPlugin = config.getString("Global.MultiWorldPlugin");
|
||||
enableRentSystem = config.getBoolean("Global.EnableRentSystem", false);
|
||||
rentCheckInterval = config.getInt("Global.RentCheckInterval", 10);
|
||||
leaseCheckInterval = config.getInt("Global.LeaseCheckInterval", 10);
|
||||
autoSaveInt = config.getInt("Global.SaveInterval", 10);
|
||||
flagsInherit = config.getBoolean("Global.ResidenceFlagsInherit", false);
|
||||
minMoveUpdate = config.getInt("Global.MoveCheckInterval", 500);
|
||||
chatEnable = config.getBoolean("Global.ResidenceChatEnable", true);
|
||||
actionBar = config.getBoolean("Global.UseActionBar", true);
|
||||
enforceAreaInsideArea = config.getBoolean("Global.EnforceAreaInsideArea", false);
|
||||
language = config.getString("Global.Language", "English");
|
||||
globalCreatorDefaults = FlagPermissions.parseFromConfigNode("CreatorDefault", config.getConfigurationSection("Global"));
|
||||
globalResidenceDefaults = FlagPermissions.parseFromConfigNode("ResidenceDefault", config.getConfigurationSection("Global"));
|
||||
preventBuildInRent = config.getBoolean("Global.PreventRentModify", true);
|
||||
stopOnSaveError = config.getBoolean("Global.StopOnSaveFault", true);
|
||||
legacyperms = config.getBoolean("Global.LegacyPermissions", false);
|
||||
namefix = config.getString("Global.ResidenceNameRegex", "[^A-Za-z0-9\\u4e00-\\u9fa5\\-\\_]");// "[^a-zA-Z0-9\\-\\_]"
|
||||
showIntervalMessages = config.getBoolean("Global.ShowIntervalMessages", false);
|
||||
spoutEnable = config.getBoolean("Global.EnableSpout", false);
|
||||
enableLeaseMoneyAccount = config.getBoolean("Global.EnableLeaseMoneyAccount", true);
|
||||
enableDebug = config.getBoolean("Global.EnableDebug", false);
|
||||
customContainers = config.getIntegerList("Global.CustomContainers");
|
||||
customBothClick = config.getIntegerList("Global.CustomBothClick");
|
||||
customRightClick = config.getIntegerList("Global.CustomRightClick");
|
||||
} catch (final Exception e) {
|
||||
throw new RuntimeException("领地配置文件载入错误...", e);
|
||||
}
|
||||
if (actionBar && plugin.isGt1_8()) {
|
||||
actionBar = ActionBar.init();
|
||||
} else {
|
||||
actionBar = false;
|
||||
}
|
||||
final ConfigurationSection node = config.getConfigurationSection("Global.GroupDefault");
|
||||
if (node != null) {
|
||||
final Set<String> keys = node.getConfigurationSection(defaultGroup).getKeys(false);
|
||||
if (keys != null) {
|
||||
for (final String key : keys) {
|
||||
globalGroupDefaults.put(key, FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.GroupDefault")));
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
chatColor = ChatColor.valueOf(config.getString("Global.ResidenceChatColor", "DARK_PURPLE"));
|
||||
} catch (final Exception ex) {
|
||||
chatColor = ChatColor.DARK_PURPLE;
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
private void load(final FileConfiguration config) {
|
||||
try {
|
||||
if (!config.isConfigurationSection("Global")) {
|
||||
plugin.getLogger().warning("配置文件主键丢失 恢复默认配置文件!");
|
||||
plugin.getConfig().addDefaults(new FileConfig(plugin));
|
||||
}
|
||||
defaultGroup = config.getString("Global.DefaultGroup", "default").toLowerCase();
|
||||
adminsOnly = config.getBoolean("Global.AdminOnlyCommands", false);
|
||||
useLeases = config.getBoolean("Global.UseLeaseSystem", false);
|
||||
leaseAutoRenew = config.getBoolean("Global.LeaseAutoRenew", true);
|
||||
enableEconomy = config.getBoolean("Global.EnableEconomy", false);
|
||||
economySystem = config.getString("Global.EconomySystem", "iConomy");
|
||||
infoToolId = config.getInt("Global.InfoToolId", Material.STRING.getId());
|
||||
selectionToolId = config.getInt("Global.SelectionToolId", Material.WOOD_AXE.getId());
|
||||
adminOps = config.getBoolean("Global.AdminOPs", true);
|
||||
multiworldPlugin = config.getString("Global.MultiWorldPlugin");
|
||||
enableRentSystem = config.getBoolean("Global.EnableRentSystem", false);
|
||||
rentCheckInterval = config.getInt("Global.RentCheckInterval", 10);
|
||||
leaseCheckInterval = config.getInt("Global.LeaseCheckInterval", 10);
|
||||
autoSaveInt = config.getInt("Global.SaveInterval", 10);
|
||||
flagsInherit = config.getBoolean("Global.ResidenceFlagsInherit", false);
|
||||
minMoveUpdate = config.getInt("Global.MoveCheckInterval", 500);
|
||||
chatEnable = config.getBoolean("Global.ResidenceChatEnable", true);
|
||||
actionBar = config.getBoolean("Global.UseActionBar", true);
|
||||
enforceAreaInsideArea = config.getBoolean("Global.EnforceAreaInsideArea", false);
|
||||
language = config.getString("Global.Language", "English");
|
||||
globalCreatorDefaults = FlagPermissions.parseFromConfigNode("CreatorDefault", config.getConfigurationSection("Global"));
|
||||
globalResidenceDefaults = FlagPermissions.parseFromConfigNode("ResidenceDefault", config.getConfigurationSection("Global"));
|
||||
preventBuildInRent = config.getBoolean("Global.PreventRentModify", true);
|
||||
stopOnSaveError = config.getBoolean("Global.StopOnSaveFault", true);
|
||||
legacyperms = config.getBoolean("Global.LegacyPermissions", false);
|
||||
namefix = config.getString("Global.ResidenceNameRegex", "[^A-Za-z0-9\\u4e00-\\u9fa5\\-\\_]");// "[^a-zA-Z0-9\\-\\_]"
|
||||
showIntervalMessages = config.getBoolean("Global.ShowIntervalMessages", false);
|
||||
spoutEnable = config.getBoolean("Global.EnableSpout", false);
|
||||
enableLeaseMoneyAccount = config.getBoolean("Global.EnableLeaseMoneyAccount", true);
|
||||
enableDebug = config.getBoolean("Global.EnableDebug", false);
|
||||
customContainers = config.getIntegerList("Global.CustomContainers");
|
||||
customBothClick = config.getIntegerList("Global.CustomBothClick");
|
||||
customRightClick = config.getIntegerList("Global.CustomRightClick");
|
||||
} catch (final Exception e) {
|
||||
throw new RuntimeException("领地配置文件载入错误...", e);
|
||||
}
|
||||
if (actionBar && plugin.isGt1_8()) {
|
||||
actionBar = ActionBar.init();
|
||||
} else {
|
||||
actionBar = false;
|
||||
}
|
||||
final ConfigurationSection node = config.getConfigurationSection("Global.GroupDefault");
|
||||
if (node != null) {
|
||||
final Set<String> keys = node.getConfigurationSection(defaultGroup).getKeys(false);
|
||||
if (keys != null) {
|
||||
for (final String key : keys) {
|
||||
globalGroupDefaults.put(key, FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.GroupDefault")));
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
chatColor = ChatColor.valueOf(config.getString("Global.ResidenceChatColor", "DARK_PURPLE"));
|
||||
} catch (final Exception ex) {
|
||||
chatColor = ChatColor.DARK_PURPLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,18 +21,18 @@ import org.bukkit.entity.Wolf;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class EntityManager {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public EntityManager(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public EntityManager(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean isAnimal(final Entity ent) {
|
||||
return (ent instanceof Horse || ent instanceof Bat || ent instanceof Snowman || ent instanceof IronGolem || ent instanceof Ocelot || ent instanceof Pig || ent instanceof Sheep
|
||||
|| ent instanceof Chicken || ent instanceof Wolf || ent instanceof Cow || ent instanceof Squid || ent instanceof Villager || (plugin.isGt1_8() && ent instanceof Rabbit));
|
||||
}
|
||||
public boolean isAnimal(final Entity ent) {
|
||||
return (ent instanceof Horse || ent instanceof Bat || ent instanceof Snowman || ent instanceof IronGolem || ent instanceof Ocelot || ent instanceof Pig || ent instanceof Sheep
|
||||
|| ent instanceof Chicken || ent instanceof Wolf || ent instanceof Cow || ent instanceof Squid || ent instanceof Villager || (plugin.isGt1_8() && ent instanceof Rabbit));
|
||||
}
|
||||
|
||||
public boolean isMonster(final Entity ent) {
|
||||
return (ent instanceof Monster || ent instanceof Slime || ent instanceof Ghast);
|
||||
}
|
||||
public boolean isMonster(final Entity ent) {
|
||||
return (ent instanceof Monster || ent instanceof Slime || ent instanceof Ghast);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,298 +28,298 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
* changed by inori 03/17/2012 line 91:limits MaxHeight changed to 255
|
||||
*/
|
||||
public class PermissionGroup {
|
||||
protected boolean buyIgnoreLimits;
|
||||
protected boolean canBuy;
|
||||
protected boolean cancreate;
|
||||
protected boolean canSell;
|
||||
protected double costperarea;
|
||||
protected Map<String, Boolean> creatorDefaultFlags;
|
||||
protected String defaultEnterMessage;
|
||||
protected String defaultLeaveMessage;
|
||||
protected FlagPermissions flagPerms;
|
||||
protected Map<String, Map<String, Boolean>> groupDefaultFlags;
|
||||
protected String groupname;
|
||||
protected boolean itemListAccess;
|
||||
protected boolean kick;
|
||||
protected int leaseGiveTime;
|
||||
protected int maxHeight;
|
||||
protected int maxLeaseTime;
|
||||
protected int maxPhysical;
|
||||
protected int maxRentables;
|
||||
protected int maxRents;
|
||||
protected boolean messageperms;
|
||||
protected int minHeight;
|
||||
protected double renewcostperarea;
|
||||
protected Map<String, Boolean> residenceDefaultFlags;
|
||||
protected int resmax;
|
||||
protected boolean selectCommandAccess;
|
||||
protected int subzonedepth;
|
||||
protected boolean tpaccess;
|
||||
protected boolean unstuck;
|
||||
protected int xmax;
|
||||
protected int ymax;
|
||||
protected int zmax;
|
||||
protected boolean buyIgnoreLimits;
|
||||
protected boolean canBuy;
|
||||
protected boolean cancreate;
|
||||
protected boolean canSell;
|
||||
protected double costperarea;
|
||||
protected Map<String, Boolean> creatorDefaultFlags;
|
||||
protected String defaultEnterMessage;
|
||||
protected String defaultLeaveMessage;
|
||||
protected FlagPermissions flagPerms;
|
||||
protected Map<String, Map<String, Boolean>> groupDefaultFlags;
|
||||
protected String groupname;
|
||||
protected boolean itemListAccess;
|
||||
protected boolean kick;
|
||||
protected int leaseGiveTime;
|
||||
protected int maxHeight;
|
||||
protected int maxLeaseTime;
|
||||
protected int maxPhysical;
|
||||
protected int maxRentables;
|
||||
protected int maxRents;
|
||||
protected boolean messageperms;
|
||||
protected int minHeight;
|
||||
protected double renewcostperarea;
|
||||
protected Map<String, Boolean> residenceDefaultFlags;
|
||||
protected int resmax;
|
||||
protected boolean selectCommandAccess;
|
||||
protected int subzonedepth;
|
||||
protected boolean tpaccess;
|
||||
protected boolean unstuck;
|
||||
protected int xmax;
|
||||
protected int ymax;
|
||||
protected int zmax;
|
||||
|
||||
public PermissionGroup(final String name) {
|
||||
flagPerms = new FlagPermissions();
|
||||
creatorDefaultFlags = new HashMap<String, Boolean>();
|
||||
residenceDefaultFlags = new HashMap<String, Boolean>();
|
||||
groupDefaultFlags = new HashMap<String, Map<String, Boolean>>();
|
||||
groupname = name;
|
||||
}
|
||||
public PermissionGroup(final String name) {
|
||||
flagPerms = new FlagPermissions();
|
||||
creatorDefaultFlags = new HashMap<String, Boolean>();
|
||||
residenceDefaultFlags = new HashMap<String, Boolean>();
|
||||
groupDefaultFlags = new HashMap<String, Map<String, Boolean>>();
|
||||
groupname = name;
|
||||
}
|
||||
|
||||
public PermissionGroup(final String name, final ConfigurationSection node) {
|
||||
this(name);
|
||||
this.parseGroup(node);
|
||||
}
|
||||
public PermissionGroup(final String name, final ConfigurationSection node) {
|
||||
this(name);
|
||||
this.parseGroup(node);
|
||||
}
|
||||
|
||||
public PermissionGroup(final String name, final ConfigurationSection node, final FlagPermissions parentFlagPerms) {
|
||||
this(name, node);
|
||||
flagPerms.setParent(parentFlagPerms);
|
||||
}
|
||||
public PermissionGroup(final String name, final ConfigurationSection node, final FlagPermissions parentFlagPerms) {
|
||||
this(name, node);
|
||||
flagPerms.setParent(parentFlagPerms);
|
||||
}
|
||||
|
||||
public boolean buyLandIgnoreLimits() {
|
||||
return buyIgnoreLimits;
|
||||
}
|
||||
public boolean buyLandIgnoreLimits() {
|
||||
return buyIgnoreLimits;
|
||||
}
|
||||
|
||||
public boolean canBuyLand() {
|
||||
return canBuy;
|
||||
}
|
||||
public boolean canBuyLand() {
|
||||
return canBuy;
|
||||
}
|
||||
|
||||
public boolean canCreateResidences() {
|
||||
return cancreate;
|
||||
}
|
||||
public boolean canCreateResidences() {
|
||||
return cancreate;
|
||||
}
|
||||
|
||||
public boolean canSellLand() {
|
||||
return canSell;
|
||||
}
|
||||
public boolean canSellLand() {
|
||||
return canSell;
|
||||
}
|
||||
|
||||
public boolean canSetEnterLeaveMessages() {
|
||||
return messageperms;
|
||||
}
|
||||
public boolean canSetEnterLeaveMessages() {
|
||||
return messageperms;
|
||||
}
|
||||
|
||||
public double getCostPerBlock() {
|
||||
return costperarea;
|
||||
}
|
||||
public double getCostPerBlock() {
|
||||
return costperarea;
|
||||
}
|
||||
|
||||
public Set<Entry<String, Boolean>> getDefaultCreatorFlags() {
|
||||
return creatorDefaultFlags.entrySet();
|
||||
}
|
||||
public Set<Entry<String, Boolean>> getDefaultCreatorFlags() {
|
||||
return creatorDefaultFlags.entrySet();
|
||||
}
|
||||
|
||||
public String getDefaultEnterMessage() {
|
||||
return defaultEnterMessage;
|
||||
}
|
||||
public String getDefaultEnterMessage() {
|
||||
return defaultEnterMessage;
|
||||
}
|
||||
|
||||
public Set<Entry<String, Map<String, Boolean>>> getDefaultGroupFlags() {
|
||||
return groupDefaultFlags.entrySet();
|
||||
}
|
||||
public Set<Entry<String, Map<String, Boolean>>> getDefaultGroupFlags() {
|
||||
return groupDefaultFlags.entrySet();
|
||||
}
|
||||
|
||||
public String getDefaultLeaveMessage() {
|
||||
return defaultLeaveMessage;
|
||||
}
|
||||
public String getDefaultLeaveMessage() {
|
||||
return defaultLeaveMessage;
|
||||
}
|
||||
|
||||
public Set<Entry<String, Boolean>> getDefaultResidenceFlags() {
|
||||
return residenceDefaultFlags.entrySet();
|
||||
}
|
||||
public Set<Entry<String, Boolean>> getDefaultResidenceFlags() {
|
||||
return residenceDefaultFlags.entrySet();
|
||||
}
|
||||
|
||||
public int getLeaseGiveTime() {
|
||||
return leaseGiveTime;
|
||||
}
|
||||
public int getLeaseGiveTime() {
|
||||
return leaseGiveTime;
|
||||
}
|
||||
|
||||
public double getLeaseRenewCost() {
|
||||
return renewcostperarea;
|
||||
}
|
||||
public double getLeaseRenewCost() {
|
||||
return renewcostperarea;
|
||||
}
|
||||
|
||||
public int getMaxHeight() {
|
||||
return maxHeight;
|
||||
}
|
||||
public int getMaxHeight() {
|
||||
return maxHeight;
|
||||
}
|
||||
|
||||
public int getMaxLeaseTime() {
|
||||
return maxLeaseTime;
|
||||
}
|
||||
public int getMaxLeaseTime() {
|
||||
return maxLeaseTime;
|
||||
}
|
||||
|
||||
public int getMaxPhysicalPerResidence() {
|
||||
return maxPhysical;
|
||||
}
|
||||
public int getMaxPhysicalPerResidence() {
|
||||
return maxPhysical;
|
||||
}
|
||||
|
||||
public int getMaxRentables() {
|
||||
return maxRentables;
|
||||
}
|
||||
public int getMaxRentables() {
|
||||
return maxRentables;
|
||||
}
|
||||
|
||||
public int getMaxRents() {
|
||||
return maxRents;
|
||||
}
|
||||
public int getMaxRents() {
|
||||
return maxRents;
|
||||
}
|
||||
|
||||
public int getMaxSubzoneDepth() {
|
||||
return subzonedepth;
|
||||
}
|
||||
public int getMaxSubzoneDepth() {
|
||||
return subzonedepth;
|
||||
}
|
||||
|
||||
public int getMaxX() {
|
||||
return xmax;
|
||||
}
|
||||
public int getMaxX() {
|
||||
return xmax;
|
||||
}
|
||||
|
||||
public int getMaxY() {
|
||||
return ymax;
|
||||
}
|
||||
public int getMaxY() {
|
||||
return ymax;
|
||||
}
|
||||
|
||||
public int getMaxZ() {
|
||||
return zmax;
|
||||
}
|
||||
public int getMaxZ() {
|
||||
return zmax;
|
||||
}
|
||||
|
||||
public int getMaxZones() {
|
||||
return resmax;
|
||||
}
|
||||
public int getMaxZones() {
|
||||
return resmax;
|
||||
}
|
||||
|
||||
public int getMinHeight() {
|
||||
return minHeight;
|
||||
}
|
||||
public int getMinHeight() {
|
||||
return minHeight;
|
||||
}
|
||||
|
||||
public boolean hasFlagAccess(final String flag) {
|
||||
return flagPerms.has(flag, false);
|
||||
}
|
||||
public boolean hasFlagAccess(final String flag) {
|
||||
return flagPerms.has(flag, false);
|
||||
}
|
||||
|
||||
public boolean hasKickAccess() {
|
||||
return kick;
|
||||
}
|
||||
public boolean hasKickAccess() {
|
||||
return kick;
|
||||
}
|
||||
|
||||
public boolean hasTpAccess() {
|
||||
return tpaccess;
|
||||
}
|
||||
public boolean hasTpAccess() {
|
||||
return tpaccess;
|
||||
}
|
||||
|
||||
public boolean hasUnstuckAccess() {
|
||||
return unstuck;
|
||||
}
|
||||
public boolean hasUnstuckAccess() {
|
||||
return unstuck;
|
||||
}
|
||||
|
||||
public boolean inLimits(final CuboidArea area) {
|
||||
if (area.getXSize() > xmax || area.getYSize() > ymax || area.getZSize() > zmax) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean inLimits(final CuboidArea area) {
|
||||
if (area.getXSize() > xmax || area.getYSize() > ymax || area.getZSize() > zmax) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean itemListAccess() {
|
||||
return itemListAccess;
|
||||
}
|
||||
public boolean itemListAccess() {
|
||||
return itemListAccess;
|
||||
}
|
||||
|
||||
public void printLimits(final Player player) {
|
||||
final ResidenceMain plugin = ResidenceMain.getInstance();
|
||||
player.sendMessage(ChatColor.GRAY + "---------------------------");
|
||||
player.sendMessage(ChatColor.YELLOW + "权限 组:" + ChatColor.DARK_AQUA + " " + plugin.getPermissionManager().getPermissionsGroup(player));
|
||||
player.sendMessage(ChatColor.YELLOW + "领地 组:" + ChatColor.DARK_AQUA + " " + groupname);
|
||||
player.sendMessage(ChatColor.YELLOW + "领地 管理:" + ChatColor.DARK_AQUA + " " + plugin.getPermissionManager().isResidenceAdmin(player));
|
||||
player.sendMessage(ChatColor.YELLOW + "允许创建领地:" + ChatColor.DARK_AQUA + " " + cancreate);
|
||||
player.sendMessage(ChatColor.YELLOW + "最大领地个数:" + ChatColor.DARK_AQUA + " " + resmax);
|
||||
player.sendMessage(ChatColor.YELLOW + "X轴最大长度:" + ChatColor.DARK_AQUA + " " + xmax);
|
||||
player.sendMessage(ChatColor.YELLOW + "Z轴最大长度:" + ChatColor.DARK_AQUA + " " + zmax);
|
||||
player.sendMessage(ChatColor.YELLOW + "Y轴最大高度:" + ChatColor.DARK_AQUA + " " + ymax);
|
||||
player.sendMessage(ChatColor.YELLOW + "高度限制:" + ChatColor.DARK_AQUA + " " + minHeight + " - " + maxHeight);
|
||||
player.sendMessage(ChatColor.YELLOW + "最大子领地深度:" + ChatColor.DARK_AQUA + " " + subzonedepth);
|
||||
player.sendMessage(ChatColor.YELLOW + "是否允许设置进出消息:" + ChatColor.DARK_AQUA + " " + messageperms);
|
||||
player.sendMessage(ChatColor.YELLOW + "你所拥有的领地:" + ChatColor.DARK_AQUA + " " + plugin.getResidenceManager().getOwnedZoneCount(player.getName()));
|
||||
if (plugin.getEconomyManager() != null) {
|
||||
player.sendMessage(ChatColor.YELLOW + "每个方块需要金钱:" + ChatColor.DARK_AQUA + " " + costperarea);
|
||||
}
|
||||
player.sendMessage(ChatColor.YELLOW + "Flag 权限:" + ChatColor.DARK_AQUA + " " + flagPerms.listFlags());
|
||||
if (plugin.getConfigManager().useLeases()) {
|
||||
player.sendMessage(ChatColor.YELLOW + "最大租赁日:" + ChatColor.DARK_AQUA + " " + maxLeaseTime);
|
||||
player.sendMessage(ChatColor.YELLOW + "续租日期:" + ChatColor.DARK_AQUA + " " + leaseGiveTime);
|
||||
player.sendMessage(ChatColor.YELLOW + "续租方块需要金钱:" + ChatColor.DARK_AQUA + " " + renewcostperarea);
|
||||
}
|
||||
player.sendMessage(ChatColor.GRAY + "---------------------------");
|
||||
}
|
||||
public void printLimits(final Player player) {
|
||||
final ResidenceMain plugin = ResidenceMain.getInstance();
|
||||
player.sendMessage(ChatColor.GRAY + "---------------------------");
|
||||
player.sendMessage(ChatColor.YELLOW + "权限 组:" + ChatColor.DARK_AQUA + " " + plugin.getPermissionManager().getPermissionsGroup(player));
|
||||
player.sendMessage(ChatColor.YELLOW + "领地 组:" + ChatColor.DARK_AQUA + " " + groupname);
|
||||
player.sendMessage(ChatColor.YELLOW + "领地 管理:" + ChatColor.DARK_AQUA + " " + plugin.getPermissionManager().isResidenceAdmin(player));
|
||||
player.sendMessage(ChatColor.YELLOW + "允许创建领地:" + ChatColor.DARK_AQUA + " " + cancreate);
|
||||
player.sendMessage(ChatColor.YELLOW + "最大领地个数:" + ChatColor.DARK_AQUA + " " + resmax);
|
||||
player.sendMessage(ChatColor.YELLOW + "X轴最大长度:" + ChatColor.DARK_AQUA + " " + xmax);
|
||||
player.sendMessage(ChatColor.YELLOW + "Z轴最大长度:" + ChatColor.DARK_AQUA + " " + zmax);
|
||||
player.sendMessage(ChatColor.YELLOW + "Y轴最大高度:" + ChatColor.DARK_AQUA + " " + ymax);
|
||||
player.sendMessage(ChatColor.YELLOW + "高度限制:" + ChatColor.DARK_AQUA + " " + minHeight + " - " + maxHeight);
|
||||
player.sendMessage(ChatColor.YELLOW + "最大子领地深度:" + ChatColor.DARK_AQUA + " " + subzonedepth);
|
||||
player.sendMessage(ChatColor.YELLOW + "是否允许设置进出消息:" + ChatColor.DARK_AQUA + " " + messageperms);
|
||||
player.sendMessage(ChatColor.YELLOW + "你所拥有的领地:" + ChatColor.DARK_AQUA + " " + plugin.getResidenceManager().getOwnedZoneCount(player.getName()));
|
||||
if (plugin.getEconomyManager() != null) {
|
||||
player.sendMessage(ChatColor.YELLOW + "每个方块需要金钱:" + ChatColor.DARK_AQUA + " " + costperarea);
|
||||
}
|
||||
player.sendMessage(ChatColor.YELLOW + "Flag 权限:" + ChatColor.DARK_AQUA + " " + flagPerms.listFlags());
|
||||
if (plugin.getConfigManager().useLeases()) {
|
||||
player.sendMessage(ChatColor.YELLOW + "最大租赁日:" + ChatColor.DARK_AQUA + " " + maxLeaseTime);
|
||||
player.sendMessage(ChatColor.YELLOW + "续租日期:" + ChatColor.DARK_AQUA + " " + leaseGiveTime);
|
||||
player.sendMessage(ChatColor.YELLOW + "续租方块需要金钱:" + ChatColor.DARK_AQUA + " " + renewcostperarea);
|
||||
}
|
||||
player.sendMessage(ChatColor.GRAY + "---------------------------");
|
||||
}
|
||||
|
||||
public boolean selectCommandAccess() {
|
||||
return selectCommandAccess;
|
||||
}
|
||||
public boolean selectCommandAccess() {
|
||||
return selectCommandAccess;
|
||||
}
|
||||
|
||||
private void parseGroup(final ConfigurationSection limits) {
|
||||
if (limits == null) {
|
||||
return;
|
||||
}
|
||||
cancreate = limits.getBoolean("Residence.CanCreate", false);
|
||||
resmax = limits.getInt("Residence.MaxResidences", 0);
|
||||
maxPhysical = limits.getInt("Residence.MaxAreasPerResidence", 2);
|
||||
xmax = limits.getInt("Residence.MaxEastWest", 0);
|
||||
ymax = limits.getInt("Residence.MaxUpDown", 0);
|
||||
zmax = limits.getInt("Residence.MaxNorthSouth", 0);
|
||||
minHeight = limits.getInt("Residence.MinHeight", 0);
|
||||
maxHeight = limits.getInt("Residence.MaxHeight", 255);
|
||||
tpaccess = limits.getBoolean("Residence.CanTeleport", false);
|
||||
subzonedepth = limits.getInt("Residence.SubzoneDepth", 0);
|
||||
messageperms = limits.getBoolean("Messaging.CanChange", false);
|
||||
defaultEnterMessage = limits.getString("Messaging.DefaultEnter", null);
|
||||
defaultLeaveMessage = limits.getString("Messaging.DefaultLeave", null);
|
||||
maxLeaseTime = limits.getInt("Lease.MaxDays", 16);
|
||||
leaseGiveTime = limits.getInt("Lease.RenewIncrement", 14);
|
||||
maxRents = limits.getInt("Rent.MaxRents", 0);
|
||||
maxRentables = limits.getInt("Rent.MaxRentables", 0);
|
||||
renewcostperarea = limits.getDouble("Economy.RenewCost", 0.02D);
|
||||
canBuy = limits.getBoolean("Economy.CanBuy", false);
|
||||
canSell = limits.getBoolean("Economy.CanSell", false);
|
||||
buyIgnoreLimits = limits.getBoolean("Economy.IgnoreLimits", false);
|
||||
costperarea = limits.getDouble("Economy.BuyCost", 0);
|
||||
unstuck = limits.getBoolean("Residence.Unstuck", false);
|
||||
kick = limits.getBoolean("Residence.Kick", false);
|
||||
selectCommandAccess = limits.getBoolean("Residence.SelectCommandAccess", true);
|
||||
itemListAccess = limits.getBoolean("Residence.ItemListAccess", true);
|
||||
ConfigurationSection node = limits.getConfigurationSection("Flags.Permission");
|
||||
Set<String> flags = null;
|
||||
if (node != null) {
|
||||
flags = node.getKeys(false);
|
||||
}
|
||||
if (flags != null) {
|
||||
final Iterator<String> flagit = flags.iterator();
|
||||
while (flagit.hasNext()) {
|
||||
final String flagname = flagit.next();
|
||||
final boolean access = limits.getBoolean("Flags.Permission." + flagname, false);
|
||||
flagPerms.setFlag(flagname, access ? FlagState.TRUE : FlagState.FALSE);
|
||||
}
|
||||
}
|
||||
node = limits.getConfigurationSection("Flags.CreatorDefault");
|
||||
if (node != null) {
|
||||
flags = node.getKeys(false);
|
||||
}
|
||||
if (flags != null) {
|
||||
final Iterator<String> flagit = flags.iterator();
|
||||
while (flagit.hasNext()) {
|
||||
final String flagname = flagit.next();
|
||||
final boolean access = limits.getBoolean("Flags.CreatorDefault." + flagname, false);
|
||||
creatorDefaultFlags.put(flagname, access);
|
||||
}
|
||||
private void parseGroup(final ConfigurationSection limits) {
|
||||
if (limits == null) {
|
||||
return;
|
||||
}
|
||||
cancreate = limits.getBoolean("Residence.CanCreate", false);
|
||||
resmax = limits.getInt("Residence.MaxResidences", 0);
|
||||
maxPhysical = limits.getInt("Residence.MaxAreasPerResidence", 2);
|
||||
xmax = limits.getInt("Residence.MaxEastWest", 0);
|
||||
ymax = limits.getInt("Residence.MaxUpDown", 0);
|
||||
zmax = limits.getInt("Residence.MaxNorthSouth", 0);
|
||||
minHeight = limits.getInt("Residence.MinHeight", 0);
|
||||
maxHeight = limits.getInt("Residence.MaxHeight", 255);
|
||||
tpaccess = limits.getBoolean("Residence.CanTeleport", false);
|
||||
subzonedepth = limits.getInt("Residence.SubzoneDepth", 0);
|
||||
messageperms = limits.getBoolean("Messaging.CanChange", false);
|
||||
defaultEnterMessage = limits.getString("Messaging.DefaultEnter", null);
|
||||
defaultLeaveMessage = limits.getString("Messaging.DefaultLeave", null);
|
||||
maxLeaseTime = limits.getInt("Lease.MaxDays", 16);
|
||||
leaseGiveTime = limits.getInt("Lease.RenewIncrement", 14);
|
||||
maxRents = limits.getInt("Rent.MaxRents", 0);
|
||||
maxRentables = limits.getInt("Rent.MaxRentables", 0);
|
||||
renewcostperarea = limits.getDouble("Economy.RenewCost", 0.02D);
|
||||
canBuy = limits.getBoolean("Economy.CanBuy", false);
|
||||
canSell = limits.getBoolean("Economy.CanSell", false);
|
||||
buyIgnoreLimits = limits.getBoolean("Economy.IgnoreLimits", false);
|
||||
costperarea = limits.getDouble("Economy.BuyCost", 0);
|
||||
unstuck = limits.getBoolean("Residence.Unstuck", false);
|
||||
kick = limits.getBoolean("Residence.Kick", false);
|
||||
selectCommandAccess = limits.getBoolean("Residence.SelectCommandAccess", true);
|
||||
itemListAccess = limits.getBoolean("Residence.ItemListAccess", true);
|
||||
ConfigurationSection node = limits.getConfigurationSection("Flags.Permission");
|
||||
Set<String> flags = null;
|
||||
if (node != null) {
|
||||
flags = node.getKeys(false);
|
||||
}
|
||||
if (flags != null) {
|
||||
final Iterator<String> flagit = flags.iterator();
|
||||
while (flagit.hasNext()) {
|
||||
final String flagname = flagit.next();
|
||||
final boolean access = limits.getBoolean("Flags.Permission." + flagname, false);
|
||||
flagPerms.setFlag(flagname, access ? FlagState.TRUE : FlagState.FALSE);
|
||||
}
|
||||
}
|
||||
node = limits.getConfigurationSection("Flags.CreatorDefault");
|
||||
if (node != null) {
|
||||
flags = node.getKeys(false);
|
||||
}
|
||||
if (flags != null) {
|
||||
final Iterator<String> flagit = flags.iterator();
|
||||
while (flagit.hasNext()) {
|
||||
final String flagname = flagit.next();
|
||||
final boolean access = limits.getBoolean("Flags.CreatorDefault." + flagname, false);
|
||||
creatorDefaultFlags.put(flagname, access);
|
||||
}
|
||||
|
||||
}
|
||||
node = limits.getConfigurationSection("Flags.Default");
|
||||
if (node != null) {
|
||||
flags = node.getKeys(false);
|
||||
}
|
||||
if (flags != null) {
|
||||
final Iterator<String> flagit = flags.iterator();
|
||||
while (flagit.hasNext()) {
|
||||
final String flagname = flagit.next();
|
||||
final boolean access = limits.getBoolean("Flags.Default." + flagname, false);
|
||||
residenceDefaultFlags.put(flagname, access);
|
||||
}
|
||||
}
|
||||
node = limits.getConfigurationSection("Flags.GroupDefault");
|
||||
Set<String> groupDef = null;
|
||||
if (node != null) {
|
||||
groupDef = node.getKeys(false);
|
||||
}
|
||||
if (groupDef != null) {
|
||||
final Iterator<String> groupit = groupDef.iterator();
|
||||
while (groupit.hasNext()) {
|
||||
final String name = groupit.next();
|
||||
final Map<String, Boolean> gflags = new HashMap<String, Boolean>();
|
||||
flags = limits.getConfigurationSection("Flags.GroupDefault." + name).getKeys(false);
|
||||
final Iterator<String> flagit = flags.iterator();
|
||||
while (flagit.hasNext()) {
|
||||
final String flagname = flagit.next();
|
||||
final boolean access = limits.getBoolean("Flags.GroupDefault." + name + "." + flagname, false);
|
||||
gflags.put(flagname, access);
|
||||
}
|
||||
groupDefaultFlags.put(name, gflags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
node = limits.getConfigurationSection("Flags.Default");
|
||||
if (node != null) {
|
||||
flags = node.getKeys(false);
|
||||
}
|
||||
if (flags != null) {
|
||||
final Iterator<String> flagit = flags.iterator();
|
||||
while (flagit.hasNext()) {
|
||||
final String flagname = flagit.next();
|
||||
final boolean access = limits.getBoolean("Flags.Default." + flagname, false);
|
||||
residenceDefaultFlags.put(flagname, access);
|
||||
}
|
||||
}
|
||||
node = limits.getConfigurationSection("Flags.GroupDefault");
|
||||
Set<String> groupDef = null;
|
||||
if (node != null) {
|
||||
groupDef = node.getKeys(false);
|
||||
}
|
||||
if (groupDef != null) {
|
||||
final Iterator<String> groupit = groupDef.iterator();
|
||||
while (groupit.hasNext()) {
|
||||
final String name = groupit.next();
|
||||
final Map<String, Boolean> gflags = new HashMap<String, Boolean>();
|
||||
flags = limits.getConfigurationSection("Flags.GroupDefault." + name).getKeys(false);
|
||||
final Iterator<String> flagit = flags.iterator();
|
||||
while (flagit.hasNext()) {
|
||||
final String flagname = flagit.next();
|
||||
final boolean access = limits.getBoolean("Flags.GroupDefault." + name + "." + flagname, false);
|
||||
gflags.put(flagname, access);
|
||||
}
|
||||
groupDefaultFlags.put(name, gflags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,131 +26,131 @@ import cn.citycraft.Residence.vaultinterface.ResidenceVaultAdapter;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class PermissionManager {
|
||||
protected static PermissionsInterface perms;
|
||||
protected FlagPermissions globalFlagPerms;
|
||||
protected Map<String, PermissionGroup> groups;
|
||||
protected Map<String, String> playersGroup;
|
||||
ResidenceMain plugin;
|
||||
protected static PermissionsInterface perms;
|
||||
protected FlagPermissions globalFlagPerms;
|
||||
protected Map<String, PermissionGroup> groups;
|
||||
protected Map<String, String> playersGroup;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public PermissionManager(final ResidenceMain plugin) {
|
||||
try {
|
||||
this.plugin = plugin;
|
||||
groups = Collections.synchronizedMap(new HashMap<String, PermissionGroup>());
|
||||
playersGroup = Collections.synchronizedMap(new HashMap<String, String>());
|
||||
globalFlagPerms = new FlagPermissions();
|
||||
this.readConfig(plugin.getConfig());
|
||||
final boolean enable = plugin.getConfig().getBoolean("Global.EnablePermissions", true);
|
||||
if (enable) {
|
||||
this.checkPermissions();
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
plugin.getLogger().warning("权限管理载入失败,请报告以下错误给作者,谢谢!");
|
||||
plugin.getLogger().warning("错误: " + ex);
|
||||
}
|
||||
}
|
||||
public PermissionManager(final ResidenceMain plugin) {
|
||||
try {
|
||||
this.plugin = plugin;
|
||||
groups = Collections.synchronizedMap(new HashMap<String, PermissionGroup>());
|
||||
playersGroup = Collections.synchronizedMap(new HashMap<String, String>());
|
||||
globalFlagPerms = new FlagPermissions();
|
||||
this.readConfig(plugin.getConfig());
|
||||
final boolean enable = plugin.getConfig().getBoolean("Global.EnablePermissions", true);
|
||||
if (enable) {
|
||||
this.checkPermissions();
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
plugin.getLogger().warning("权限管理载入失败,请报告以下错误给作者,谢谢!");
|
||||
plugin.getLogger().warning("错误: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
public PermissionGroup getGroup(final Player player) {
|
||||
return groups.get(this.getGroupNameByPlayer(player));
|
||||
}
|
||||
public PermissionGroup getGroup(final Player player) {
|
||||
return groups.get(this.getGroupNameByPlayer(player));
|
||||
}
|
||||
|
||||
public PermissionGroup getGroup(final String player, final String world) {
|
||||
return groups.get(this.getGroupNameByPlayer(player, world));
|
||||
}
|
||||
public PermissionGroup getGroup(final String player, final String world) {
|
||||
return groups.get(this.getGroupNameByPlayer(player, world));
|
||||
}
|
||||
|
||||
public PermissionGroup getGroupByName(String group) {
|
||||
group = group.toLowerCase();
|
||||
if (!groups.containsKey(group)) {
|
||||
return groups.get(plugin.getConfigManager().getDefaultGroup());
|
||||
}
|
||||
return groups.get(group);
|
||||
}
|
||||
public PermissionGroup getGroupByName(String group) {
|
||||
group = group.toLowerCase();
|
||||
if (!groups.containsKey(group)) {
|
||||
return groups.get(plugin.getConfigManager().getDefaultGroup());
|
||||
}
|
||||
return groups.get(group);
|
||||
}
|
||||
|
||||
public String getGroupNameByPlayer(final Player player) {
|
||||
return this.getGroupNameByPlayer(player.getName(), player.getWorld().getName());
|
||||
}
|
||||
public String getGroupNameByPlayer(final Player player) {
|
||||
return this.getGroupNameByPlayer(player.getName(), player.getWorld().getName());
|
||||
}
|
||||
|
||||
public String getGroupNameByPlayer(String player, final String world) {
|
||||
player = player.toLowerCase();
|
||||
if (playersGroup.containsKey(player)) {
|
||||
String group = playersGroup.get(player);
|
||||
if (group != null) {
|
||||
group = group.toLowerCase();
|
||||
if (group != null && groups.containsKey(group)) {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
}
|
||||
final String group = this.getPermissionsGroup(player, world);
|
||||
if (group == null || !groups.containsKey(group)) {
|
||||
return plugin.getConfigManager().getDefaultGroup().toLowerCase();
|
||||
}
|
||||
return group;
|
||||
}
|
||||
public String getGroupNameByPlayer(String player, final String world) {
|
||||
player = player.toLowerCase();
|
||||
if (playersGroup.containsKey(player)) {
|
||||
String group = playersGroup.get(player);
|
||||
if (group != null) {
|
||||
group = group.toLowerCase();
|
||||
if (group != null && groups.containsKey(group)) {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
}
|
||||
final String group = this.getPermissionsGroup(player, world);
|
||||
if (group == null || !groups.containsKey(group)) {
|
||||
return plugin.getConfigManager().getDefaultGroup().toLowerCase();
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
public String getPermissionsGroup(final Player player) {
|
||||
return this.getPermissionsGroup(player.getName(), player.getWorld().getName());
|
||||
}
|
||||
public String getPermissionsGroup(final Player player) {
|
||||
return this.getPermissionsGroup(player.getName(), player.getWorld().getName());
|
||||
}
|
||||
|
||||
public String getPermissionsGroup(final String player, final String world) {
|
||||
if (perms == null) {
|
||||
return plugin.getConfigManager().getDefaultGroup();
|
||||
}
|
||||
return perms.getPlayerGroup(player, world);
|
||||
}
|
||||
public String getPermissionsGroup(final String player, final String world) {
|
||||
if (perms == null) {
|
||||
return plugin.getConfigManager().getDefaultGroup();
|
||||
}
|
||||
return perms.getPlayerGroup(player, world);
|
||||
}
|
||||
|
||||
public PermissionsInterface getPermissionsPlugin() {
|
||||
return perms;
|
||||
}
|
||||
public PermissionsInterface getPermissionsPlugin() {
|
||||
return perms;
|
||||
}
|
||||
|
||||
public boolean hasGroup(String group) {
|
||||
group = group.toLowerCase();
|
||||
return groups.containsKey(group);
|
||||
}
|
||||
public boolean hasGroup(String group) {
|
||||
group = group.toLowerCase();
|
||||
return groups.containsKey(group);
|
||||
}
|
||||
|
||||
public boolean isResidenceAdmin(final Player player) {
|
||||
return (player.hasPermission("residence.admin") || (player.isOp() && plugin.getConfigManager().getOpsAreAdmins()));
|
||||
}
|
||||
public boolean isResidenceAdmin(final Player player) {
|
||||
return (player.hasPermission("residence.admin") || (player.isOp() && plugin.getConfigManager().getOpsAreAdmins()));
|
||||
}
|
||||
|
||||
private void checkPermissions() {
|
||||
final Server server = plugin.getServer();
|
||||
final Plugin p = server.getPluginManager().getPlugin("Vault");
|
||||
if (p != null) {
|
||||
final ResidenceVaultAdapter vault = new ResidenceVaultAdapter(server);
|
||||
if (vault.permissionsOK()) {
|
||||
perms = vault;
|
||||
plugin.getLogger().info("发现 Vault 使用权限系统: " + vault.getPermissionsName());
|
||||
return;
|
||||
}
|
||||
plugin.getLogger().info("发现 Vault, 但是 Vault 未找到权限系统...");
|
||||
}
|
||||
}
|
||||
private void checkPermissions() {
|
||||
final Server server = plugin.getServer();
|
||||
final Plugin p = server.getPluginManager().getPlugin("Vault");
|
||||
if (p != null) {
|
||||
final ResidenceVaultAdapter vault = new ResidenceVaultAdapter(server);
|
||||
if (vault.permissionsOK()) {
|
||||
perms = vault;
|
||||
plugin.getLogger().info("发现 Vault 使用权限系统: " + vault.getPermissionsName());
|
||||
return;
|
||||
}
|
||||
plugin.getLogger().info("发现 Vault, 但是 Vault 未找到权限系统...");
|
||||
}
|
||||
}
|
||||
|
||||
private void readConfig(final FileConfiguration config) {
|
||||
final String defaultGroup = plugin.getConfigManager().getDefaultGroup();
|
||||
globalFlagPerms = FlagPermissions.parseFromConfigNode("FlagPermission", config.getConfigurationSection("Global"));
|
||||
final ConfigurationSection nodes = config.getConfigurationSection("Groups");
|
||||
if (nodes != null) {
|
||||
final Set<String> entrys = nodes.getKeys(false);
|
||||
for (final String key : entrys) {
|
||||
try {
|
||||
groups.put(key.toLowerCase(), new PermissionGroup(key.toLowerCase(), nodes.getConfigurationSection(key), globalFlagPerms));
|
||||
final List<String> mirrors = nodes.getConfigurationSection(key).getStringList("Mirror");
|
||||
for (final String group : mirrors) {
|
||||
groups.put(group.toLowerCase(), new PermissionGroup(key.toLowerCase(), nodes.getConfigurationSection(key), globalFlagPerms));
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
plugin.getLogger().info("错误 从配置文件读取:" + key + " 抛出异常:" + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!groups.containsKey(defaultGroup)) {
|
||||
groups.put(defaultGroup, new PermissionGroup(defaultGroup));
|
||||
}
|
||||
final Set<String> keys = config.getConfigurationSection("GroupAssignments").getKeys(false);
|
||||
if (keys != null) {
|
||||
for (final String key : keys) {
|
||||
playersGroup.put(key.toLowerCase(), config.getString("GroupAssignments." + key, defaultGroup).toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
private void readConfig(final FileConfiguration config) {
|
||||
final String defaultGroup = plugin.getConfigManager().getDefaultGroup();
|
||||
globalFlagPerms = FlagPermissions.parseFromConfigNode("FlagPermission", config.getConfigurationSection("Global"));
|
||||
final ConfigurationSection nodes = config.getConfigurationSection("Groups");
|
||||
if (nodes != null) {
|
||||
final Set<String> entrys = nodes.getKeys(false);
|
||||
for (final String key : entrys) {
|
||||
try {
|
||||
groups.put(key.toLowerCase(), new PermissionGroup(key.toLowerCase(), nodes.getConfigurationSection(key), globalFlagPerms));
|
||||
final List<String> mirrors = nodes.getConfigurationSection(key).getStringList("Mirror");
|
||||
for (final String group : mirrors) {
|
||||
groups.put(group.toLowerCase(), new PermissionGroup(key.toLowerCase(), nodes.getConfigurationSection(key), globalFlagPerms));
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
plugin.getLogger().info("错误 从配置文件读取:" + key + " 抛出异常:" + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!groups.containsKey(defaultGroup)) {
|
||||
groups.put(defaultGroup, new PermissionGroup(defaultGroup));
|
||||
}
|
||||
final Set<String> keys = config.getConfigurationSection("GroupAssignments").getKeys(false);
|
||||
if (keys != null) {
|
||||
for (final String key : keys) {
|
||||
playersGroup.put(key.toLowerCase(), config.getString("GroupAssignments." + key, defaultGroup).toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,5 +13,6 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public interface PermissionsInterface {
|
||||
public String getPlayerGroup(Player player);
|
||||
|
||||
public String getPlayerGroup(String player, String world);
|
||||
}
|
||||
|
||||
@@ -26,23 +26,21 @@ public class YMLSaveHelper {
|
||||
|
||||
File f;
|
||||
Yaml yml;
|
||||
Map<String,Object> root;
|
||||
Map<String, Object> root;
|
||||
|
||||
public YMLSaveHelper(File ymlfile) throws IOException
|
||||
{
|
||||
public YMLSaveHelper(File ymlfile) throws IOException {
|
||||
DumperOptions options = new DumperOptions();
|
||||
options.setDefaultFlowStyle(FlowStyle.BLOCK);
|
||||
yml = new Yaml(options);
|
||||
|
||||
root = new LinkedHashMap<String,Object>();
|
||||
if(ymlfile == null)
|
||||
root = new LinkedHashMap<String, Object>();
|
||||
if (ymlfile == null)
|
||||
throw new IOException("YMLSaveHelper: null file...");
|
||||
f = ymlfile;
|
||||
}
|
||||
|
||||
public void save() throws IOException
|
||||
{
|
||||
if(f.isFile())
|
||||
public void save() throws IOException {
|
||||
if (f.isFile())
|
||||
f.delete();
|
||||
FileOutputStream fout = new FileOutputStream(f);
|
||||
OutputStreamWriter osw = new OutputStreamWriter(fout, "UTF8");
|
||||
@@ -51,16 +49,14 @@ public class YMLSaveHelper {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void load() throws IOException
|
||||
{
|
||||
public void load() throws IOException {
|
||||
FileInputStream fis = new FileInputStream(f);
|
||||
InputStreamReader isr = new InputStreamReader(fis, "UTF8");
|
||||
root = (Map<String, Object>) yml.load(isr);
|
||||
root = (Map<String, Object>) yml.load(isr);
|
||||
isr.close();
|
||||
}
|
||||
|
||||
public Map<String,Object> getRoot()
|
||||
{
|
||||
public Map<String, Object> getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,21 +5,21 @@ import org.bukkit.Bukkit;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class AutoSaveTask implements Runnable {
|
||||
ResidenceMain res;
|
||||
ResidenceMain res;
|
||||
|
||||
public AutoSaveTask(final ResidenceMain res) {
|
||||
this.res = res;
|
||||
}
|
||||
public AutoSaveTask(final ResidenceMain res) {
|
||||
this.res = res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (res.isInit()) {
|
||||
res.saveYml();
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
Bukkit.getLogger().warning("领地数据保存错误,可能造成部分领地丢失,请尝试恢复备份文件!");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (res.isInit()) {
|
||||
res.saveYml();
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
Bukkit.getLogger().warning("领地数据保存错误,可能造成部分领地丢失,请尝试恢复备份文件!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
package cn.citycraft.Residence.runnable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Damageable;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
|
||||
import cn.citycraft.PluginHelper.utils.CompatibleUtil;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class HealTask implements Runnable {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public HealTask(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public HealTask(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (final Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
final String resname = plugin.getPlayerListener().getCurrentResidenceName(player.getName());
|
||||
ClaimedResidence res = null;
|
||||
if (resname != null) {
|
||||
res = plugin.getResidenceManager().getByName(resname);
|
||||
}
|
||||
if (res != null && res.getPermissions().has("healing", false)) {
|
||||
final Damageable damage = player;
|
||||
final double health = damage.getHealth();
|
||||
if (health < 20 && !player.isDead()) {
|
||||
player.setHealth(health + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (final Player player : CompatibleUtil.getOnlinePlayers()) {
|
||||
final String resname = plugin.getPlayerListener().getCurrentResidenceName(player.getName());
|
||||
ClaimedResidence res = null;
|
||||
if (resname != null) {
|
||||
res = plugin.getResidenceManager().getByName(resname);
|
||||
}
|
||||
if (res != null && res.getPermissions().has("healing", false)) {
|
||||
final Damageable damage = player;
|
||||
final double health = damage.getHealth();
|
||||
if (health < 20 && !player.isDead()) {
|
||||
player.setHealth(health + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@ package cn.citycraft.Residence.runnable;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class LeaseTask implements Runnable {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public LeaseTask(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public LeaseTask(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLeaseManager().doExpirations();
|
||||
if (plugin.getConfigManager().showIntervalMessages()) {
|
||||
plugin.getLogger().info(" - Lease Expirations checked!");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLeaseManager().doExpirations();
|
||||
if (plugin.getConfigManager().showIntervalMessages()) {
|
||||
plugin.getLogger().info(" - Lease Expirations checked!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@ package cn.citycraft.Residence.runnable;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class RentTask implements Runnable {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public RentTask(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public RentTask(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getRentManager().checkCurrentRents();
|
||||
if (plugin.getConfigManager().showIntervalMessages()) {
|
||||
plugin.getLogger().info(" - Rent Expirations checked!");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getRentManager().checkCurrentRents();
|
||||
if (plugin.getConfigManager().showIntervalMessages()) {
|
||||
plugin.getLogger().info(" - Rent Expirations checked!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,21 +7,21 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class TaskManager {
|
||||
Plugin plugin;
|
||||
Plugin plugin;
|
||||
|
||||
List<BukkitTask> tasklist;
|
||||
List<BukkitTask> tasklist;
|
||||
|
||||
public TaskManager(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.tasklist = new ArrayList<BukkitTask>();
|
||||
}
|
||||
public TaskManager(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.tasklist = new ArrayList<BukkitTask>();
|
||||
}
|
||||
|
||||
public void add(BukkitTask task) {
|
||||
tasklist.add(task);
|
||||
}
|
||||
public void add(BukkitTask task) {
|
||||
tasklist.add(task);
|
||||
}
|
||||
|
||||
public void cancelall() {
|
||||
for (BukkitTask bukkitTask : tasklist)
|
||||
bukkitTask.cancel();
|
||||
}
|
||||
public void cancelall() {
|
||||
for (BukkitTask bukkitTask : tasklist)
|
||||
bukkitTask.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,302 +26,302 @@ import cn.citycraft.Residence.permissions.PermissionGroup;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class SelectionManager {
|
||||
public static final int MAX_HEIGHT = 255, MIN_HEIGHT = 0;
|
||||
protected Map<String, Location> playerLoc1;
|
||||
protected Map<String, Location> playerLoc2;
|
||||
protected Server server;
|
||||
ResidenceMain plugin;
|
||||
public static final int MAX_HEIGHT = 255, MIN_HEIGHT = 0;
|
||||
protected Map<String, Location> playerLoc1;
|
||||
protected Map<String, Location> playerLoc2;
|
||||
protected Server server;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public SelectionManager(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.server = Bukkit.getServer();
|
||||
playerLoc1 = Collections.synchronizedMap(new HashMap<String, Location>());
|
||||
playerLoc2 = Collections.synchronizedMap(new HashMap<String, Location>());
|
||||
}
|
||||
public SelectionManager(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.server = Bukkit.getServer();
|
||||
playerLoc1 = Collections.synchronizedMap(new HashMap<String, Location>());
|
||||
playerLoc2 = Collections.synchronizedMap(new HashMap<String, Location>());
|
||||
}
|
||||
|
||||
public void bedrock(final Player player, final boolean resadmin) {
|
||||
if (hasPlacedBoth(player.getName())) {
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
final int y1 = playerLoc1.get(player.getName()).getBlockY();
|
||||
final int y2 = playerLoc2.get(player.getName()).getBlockY();
|
||||
if (y1 < y2) {
|
||||
int newy = MIN_HEIGHT;
|
||||
if (!resadmin) {
|
||||
if (newy < group.getMinHeight()) {
|
||||
newy = group.getMinHeight();
|
||||
}
|
||||
if (y2 - newy > (group.getMaxY() - 1)) {
|
||||
newy = y2 - (group.getMaxY() - 1);
|
||||
}
|
||||
}
|
||||
playerLoc1.get(player.getName()).setY(newy);
|
||||
} else {
|
||||
int newy = MIN_HEIGHT;
|
||||
if (!resadmin) {
|
||||
if (newy < group.getMinHeight()) {
|
||||
newy = group.getMinHeight();
|
||||
}
|
||||
if (y1 - newy > (group.getMaxY() - 1)) {
|
||||
newy = y1 - (group.getMaxY() - 1);
|
||||
}
|
||||
}
|
||||
playerLoc2.get(player.getName()).setY(newy);
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionBedrock"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||
}
|
||||
}
|
||||
public void bedrock(final Player player, final boolean resadmin) {
|
||||
if (hasPlacedBoth(player.getName())) {
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
final int y1 = playerLoc1.get(player.getName()).getBlockY();
|
||||
final int y2 = playerLoc2.get(player.getName()).getBlockY();
|
||||
if (y1 < y2) {
|
||||
int newy = MIN_HEIGHT;
|
||||
if (!resadmin) {
|
||||
if (newy < group.getMinHeight()) {
|
||||
newy = group.getMinHeight();
|
||||
}
|
||||
if (y2 - newy > (group.getMaxY() - 1)) {
|
||||
newy = y2 - (group.getMaxY() - 1);
|
||||
}
|
||||
}
|
||||
playerLoc1.get(player.getName()).setY(newy);
|
||||
} else {
|
||||
int newy = MIN_HEIGHT;
|
||||
if (!resadmin) {
|
||||
if (newy < group.getMinHeight()) {
|
||||
newy = group.getMinHeight();
|
||||
}
|
||||
if (y1 - newy > (group.getMaxY() - 1)) {
|
||||
newy = y1 - (group.getMaxY() - 1);
|
||||
}
|
||||
}
|
||||
playerLoc2.get(player.getName()).setY(newy);
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionBedrock"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||
}
|
||||
}
|
||||
|
||||
public void clearSelection(final Player player) {
|
||||
playerLoc1.remove(player.getName());
|
||||
playerLoc2.remove(player.getName());
|
||||
}
|
||||
public void clearSelection(final Player player) {
|
||||
playerLoc1.remove(player.getName());
|
||||
playerLoc2.remove(player.getName());
|
||||
}
|
||||
|
||||
public Location getPlayerLoc1(final String player) {
|
||||
return playerLoc1.get(player);
|
||||
}
|
||||
public Location getPlayerLoc1(final String player) {
|
||||
return playerLoc1.get(player);
|
||||
}
|
||||
|
||||
public Location getPlayerLoc2(final String player) {
|
||||
return playerLoc2.get(player);
|
||||
}
|
||||
public Location getPlayerLoc2(final String player) {
|
||||
return playerLoc2.get(player);
|
||||
}
|
||||
|
||||
public boolean hasPlacedBoth(final String player) {
|
||||
return (playerLoc1.containsKey(player) && playerLoc2.containsKey(player));
|
||||
}
|
||||
public boolean hasPlacedBoth(final String player) {
|
||||
return (playerLoc1.containsKey(player) && playerLoc2.containsKey(player));
|
||||
}
|
||||
|
||||
public void modify(final Player player, final boolean shift, final int amount) {
|
||||
if (!this.hasPlacedBoth(player.getName())) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||
return;
|
||||
}
|
||||
final Direction d = this.getDirection(player);
|
||||
if (d == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidDirection"));
|
||||
}
|
||||
final CuboidArea area = new CuboidArea(playerLoc1.get(player.getName()), playerLoc2.get(player.getName()));
|
||||
if (d == Direction.UP) {
|
||||
int oldy = area.getHighLoc().getBlockY();
|
||||
oldy = oldy + amount;
|
||||
if (oldy > MAX_HEIGHT) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectTooHigh"));
|
||||
oldy = MAX_HEIGHT;
|
||||
}
|
||||
area.getHighLoc().setY(oldy);
|
||||
if (shift) {
|
||||
int oldy2 = area.getLowLoc().getBlockY();
|
||||
oldy2 = oldy2 + amount;
|
||||
area.getLowLoc().setY(oldy2);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting.Up") + "...");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding.Up") + "...");
|
||||
}
|
||||
}
|
||||
if (d == Direction.DOWN) {
|
||||
int oldy = area.getLowLoc().getBlockY();
|
||||
oldy = oldy - amount;
|
||||
if (oldy < MIN_HEIGHT) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectTooLow"));
|
||||
oldy = MIN_HEIGHT;
|
||||
}
|
||||
area.getLowLoc().setY(oldy);
|
||||
if (shift) {
|
||||
int oldy2 = area.getHighLoc().getBlockY();
|
||||
oldy2 = oldy2 - amount;
|
||||
area.getHighLoc().setY(oldy2);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting.Down") + "...");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding.Down") + "...");
|
||||
}
|
||||
}
|
||||
if (d == Direction.MINUSX) {
|
||||
int oldx = area.getLowLoc().getBlockX();
|
||||
oldx = oldx - amount;
|
||||
area.getLowLoc().setX(oldx);
|
||||
if (shift) {
|
||||
int oldx2 = area.getHighLoc().getBlockX();
|
||||
oldx2 = oldx2 - amount;
|
||||
area.getHighLoc().setX(oldx2);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " -X...");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " -X...");
|
||||
}
|
||||
}
|
||||
if (d == Direction.PLUSX) {
|
||||
int oldx = area.getHighLoc().getBlockX();
|
||||
oldx = oldx + amount;
|
||||
area.getHighLoc().setX(oldx);
|
||||
if (shift) {
|
||||
int oldx2 = area.getLowLoc().getBlockX();
|
||||
oldx2 = oldx2 + amount;
|
||||
area.getLowLoc().setX(oldx2);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " +X...");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " +X...");
|
||||
}
|
||||
}
|
||||
if (d == Direction.MINUSZ) {
|
||||
int oldz = area.getLowLoc().getBlockZ();
|
||||
oldz = oldz - amount;
|
||||
area.getLowLoc().setZ(oldz);
|
||||
if (shift) {
|
||||
int oldz2 = area.getHighLoc().getBlockZ();
|
||||
oldz2 = oldz2 - amount;
|
||||
area.getHighLoc().setZ(oldz2);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " -Z...");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " -Z...");
|
||||
}
|
||||
}
|
||||
if (d == Direction.PLUSZ) {
|
||||
int oldz = area.getHighLoc().getBlockZ();
|
||||
oldz = oldz + amount;
|
||||
area.getHighLoc().setZ(oldz);
|
||||
if (shift) {
|
||||
int oldz2 = area.getLowLoc().getBlockZ();
|
||||
oldz2 = oldz2 + amount;
|
||||
area.getLowLoc().setZ(oldz2);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " +Z...");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " +Z...");
|
||||
}
|
||||
}
|
||||
playerLoc1.put(player.getName(), area.getHighLoc());
|
||||
playerLoc2.put(player.getName(), area.getLowLoc());
|
||||
}
|
||||
public void modify(final Player player, final boolean shift, final int amount) {
|
||||
if (!this.hasPlacedBoth(player.getName())) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||
return;
|
||||
}
|
||||
final Direction d = this.getDirection(player);
|
||||
if (d == null) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidDirection"));
|
||||
}
|
||||
final CuboidArea area = new CuboidArea(playerLoc1.get(player.getName()), playerLoc2.get(player.getName()));
|
||||
if (d == Direction.UP) {
|
||||
int oldy = area.getHighLoc().getBlockY();
|
||||
oldy = oldy + amount;
|
||||
if (oldy > MAX_HEIGHT) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectTooHigh"));
|
||||
oldy = MAX_HEIGHT;
|
||||
}
|
||||
area.getHighLoc().setY(oldy);
|
||||
if (shift) {
|
||||
int oldy2 = area.getLowLoc().getBlockY();
|
||||
oldy2 = oldy2 + amount;
|
||||
area.getLowLoc().setY(oldy2);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting.Up") + "...");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding.Up") + "...");
|
||||
}
|
||||
}
|
||||
if (d == Direction.DOWN) {
|
||||
int oldy = area.getLowLoc().getBlockY();
|
||||
oldy = oldy - amount;
|
||||
if (oldy < MIN_HEIGHT) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectTooLow"));
|
||||
oldy = MIN_HEIGHT;
|
||||
}
|
||||
area.getLowLoc().setY(oldy);
|
||||
if (shift) {
|
||||
int oldy2 = area.getHighLoc().getBlockY();
|
||||
oldy2 = oldy2 - amount;
|
||||
area.getHighLoc().setY(oldy2);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting.Down") + "...");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding.Down") + "...");
|
||||
}
|
||||
}
|
||||
if (d == Direction.MINUSX) {
|
||||
int oldx = area.getLowLoc().getBlockX();
|
||||
oldx = oldx - amount;
|
||||
area.getLowLoc().setX(oldx);
|
||||
if (shift) {
|
||||
int oldx2 = area.getHighLoc().getBlockX();
|
||||
oldx2 = oldx2 - amount;
|
||||
area.getHighLoc().setX(oldx2);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " -X...");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " -X...");
|
||||
}
|
||||
}
|
||||
if (d == Direction.PLUSX) {
|
||||
int oldx = area.getHighLoc().getBlockX();
|
||||
oldx = oldx + amount;
|
||||
area.getHighLoc().setX(oldx);
|
||||
if (shift) {
|
||||
int oldx2 = area.getLowLoc().getBlockX();
|
||||
oldx2 = oldx2 + amount;
|
||||
area.getLowLoc().setX(oldx2);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " +X...");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " +X...");
|
||||
}
|
||||
}
|
||||
if (d == Direction.MINUSZ) {
|
||||
int oldz = area.getLowLoc().getBlockZ();
|
||||
oldz = oldz - amount;
|
||||
area.getLowLoc().setZ(oldz);
|
||||
if (shift) {
|
||||
int oldz2 = area.getHighLoc().getBlockZ();
|
||||
oldz2 = oldz2 - amount;
|
||||
area.getHighLoc().setZ(oldz2);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " -Z...");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " -Z...");
|
||||
}
|
||||
}
|
||||
if (d == Direction.PLUSZ) {
|
||||
int oldz = area.getHighLoc().getBlockZ();
|
||||
oldz = oldz + amount;
|
||||
area.getHighLoc().setZ(oldz);
|
||||
if (shift) {
|
||||
int oldz2 = area.getLowLoc().getBlockZ();
|
||||
oldz2 = oldz2 + amount;
|
||||
area.getLowLoc().setZ(oldz2);
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " +Z...");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " +Z...");
|
||||
}
|
||||
}
|
||||
playerLoc1.put(player.getName(), area.getHighLoc());
|
||||
playerLoc2.put(player.getName(), area.getLowLoc());
|
||||
}
|
||||
|
||||
public void placeLoc1(final Player player, final Location loc) {
|
||||
if (loc != null) {
|
||||
playerLoc1.put(player.getName(), loc);
|
||||
}
|
||||
}
|
||||
public void placeLoc1(final Player player, final Location loc) {
|
||||
if (loc != null) {
|
||||
playerLoc1.put(player.getName(), loc);
|
||||
}
|
||||
}
|
||||
|
||||
public void placeLoc2(final Player player, final Location loc) {
|
||||
if (loc != null) {
|
||||
playerLoc2.put(player.getName(), loc);
|
||||
}
|
||||
}
|
||||
public void placeLoc2(final Player player, final Location loc) {
|
||||
if (loc != null) {
|
||||
playerLoc2.put(player.getName(), loc);
|
||||
}
|
||||
}
|
||||
|
||||
public void selectBySize(final Player player, final int xsize, final int ysize, final int zsize) {
|
||||
final Location myloc = player.getLocation();
|
||||
final Location loc1 = new Location(myloc.getWorld(), myloc.getBlockX() + xsize, myloc.getBlockY() + ysize, myloc.getBlockZ() + zsize);
|
||||
final Location loc2 = new Location(myloc.getWorld(), myloc.getBlockX() - xsize, myloc.getBlockY() - ysize, myloc.getBlockZ() - zsize);
|
||||
placeLoc1(player, loc1);
|
||||
placeLoc2(player, loc2);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSuccess"));
|
||||
showSelectionInfo(player);
|
||||
}
|
||||
public void selectBySize(final Player player, final int xsize, final int ysize, final int zsize) {
|
||||
final Location myloc = player.getLocation();
|
||||
final Location loc1 = new Location(myloc.getWorld(), myloc.getBlockX() + xsize, myloc.getBlockY() + ysize, myloc.getBlockZ() + zsize);
|
||||
final Location loc2 = new Location(myloc.getWorld(), myloc.getBlockX() - xsize, myloc.getBlockY() - ysize, myloc.getBlockZ() - zsize);
|
||||
placeLoc1(player, loc1);
|
||||
placeLoc2(player, loc2);
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSuccess"));
|
||||
showSelectionInfo(player);
|
||||
}
|
||||
|
||||
public void selectChunk(final Player player) {
|
||||
final Chunk chunk = player.getWorld().getChunkAt(player.getLocation());
|
||||
final int xcoord = chunk.getX() * 16;
|
||||
final int zcoord = chunk.getZ() * 16;
|
||||
final int ycoord = MIN_HEIGHT;
|
||||
final int xmax = xcoord + 15;
|
||||
final int zmax = zcoord + 15;
|
||||
final int ymax = MAX_HEIGHT;
|
||||
this.playerLoc1.put(player.getName(), new Location(player.getWorld(), xcoord, ycoord, zcoord));
|
||||
this.playerLoc2.put(player.getName(), new Location(player.getWorld(), xmax, ymax, zmax));
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSuccess"));
|
||||
}
|
||||
public void selectChunk(final Player player) {
|
||||
final Chunk chunk = player.getWorld().getChunkAt(player.getLocation());
|
||||
final int xcoord = chunk.getX() * 16;
|
||||
final int zcoord = chunk.getZ() * 16;
|
||||
final int ycoord = MIN_HEIGHT;
|
||||
final int xmax = xcoord + 15;
|
||||
final int zmax = zcoord + 15;
|
||||
final int ymax = MAX_HEIGHT;
|
||||
this.playerLoc1.put(player.getName(), new Location(player.getWorld(), xcoord, ycoord, zcoord));
|
||||
this.playerLoc2.put(player.getName(), new Location(player.getWorld(), xmax, ymax, zmax));
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSuccess"));
|
||||
}
|
||||
|
||||
public void showSelectionInfo(final Player player) {
|
||||
final String pname = player.getName();
|
||||
if (this.hasPlacedBoth(pname)) {
|
||||
final CuboidArea cuboidArea = new CuboidArea(getPlayerLoc1(pname), getPlayerLoc2(pname));
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Selection.Total.Size") + ":" + ChatColor.DARK_AQUA + " " + cuboidArea.getSize());
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
if (plugin.getConfigManager().enableEconomy()) {
|
||||
player.sendMessage(
|
||||
ChatColor.YELLOW + plugin.getLanguage().getPhrase("Land.Cost") + ":" + ChatColor.DARK_AQUA + " " + ((int) Math.ceil(cuboidArea.getSize() * group.getCostPerBlock())));
|
||||
}
|
||||
player.sendMessage(ChatColor.YELLOW + "X" + plugin.getLanguage().getPhrase("Size") + ":" + ChatColor.DARK_AQUA + " " + cuboidArea.getXSize());
|
||||
player.sendMessage(ChatColor.YELLOW + "Y" + plugin.getLanguage().getPhrase("Size") + ":" + ChatColor.DARK_AQUA + " " + cuboidArea.getYSize());
|
||||
player.sendMessage(ChatColor.YELLOW + "Z" + plugin.getLanguage().getPhrase("Size") + ":" + ChatColor.DARK_AQUA + " " + cuboidArea.getZSize());
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||
}
|
||||
}
|
||||
public void showSelectionInfo(final Player player) {
|
||||
final String pname = player.getName();
|
||||
if (this.hasPlacedBoth(pname)) {
|
||||
final CuboidArea cuboidArea = new CuboidArea(getPlayerLoc1(pname), getPlayerLoc2(pname));
|
||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Selection.Total.Size") + ":" + ChatColor.DARK_AQUA + " " + cuboidArea.getSize());
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
if (plugin.getConfigManager().enableEconomy()) {
|
||||
player.sendMessage(
|
||||
ChatColor.YELLOW + plugin.getLanguage().getPhrase("Land.Cost") + ":" + ChatColor.DARK_AQUA + " " + ((int) Math.ceil(cuboidArea.getSize() * group.getCostPerBlock())));
|
||||
}
|
||||
player.sendMessage(ChatColor.YELLOW + "X" + plugin.getLanguage().getPhrase("Size") + ":" + ChatColor.DARK_AQUA + " " + cuboidArea.getXSize());
|
||||
player.sendMessage(ChatColor.YELLOW + "Y" + plugin.getLanguage().getPhrase("Size") + ":" + ChatColor.DARK_AQUA + " " + cuboidArea.getYSize());
|
||||
player.sendMessage(ChatColor.YELLOW + "Z" + plugin.getLanguage().getPhrase("Size") + ":" + ChatColor.DARK_AQUA + " " + cuboidArea.getZSize());
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||
}
|
||||
}
|
||||
|
||||
public void sky(final Player player, final boolean resadmin) {
|
||||
if (hasPlacedBoth(player.getName())) {
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
final int y1 = playerLoc1.get(player.getName()).getBlockY();
|
||||
final int y2 = playerLoc2.get(player.getName()).getBlockY();
|
||||
if (y1 > y2) {
|
||||
int newy = MAX_HEIGHT;
|
||||
if (!resadmin) {
|
||||
if (group.getMaxHeight() < newy) {
|
||||
newy = group.getMaxHeight();
|
||||
}
|
||||
if (newy - y2 > (group.getMaxY() - 1)) {
|
||||
newy = y2 + (group.getMaxY() - 1);
|
||||
}
|
||||
}
|
||||
playerLoc1.get(player.getName()).setY(newy);
|
||||
} else {
|
||||
int newy = MAX_HEIGHT;
|
||||
if (!resadmin) {
|
||||
if (group.getMaxHeight() < newy) {
|
||||
newy = group.getMaxHeight();
|
||||
}
|
||||
if (newy - y1 > (group.getMaxY() - 1)) {
|
||||
newy = y1 + (group.getMaxY() - 1);
|
||||
}
|
||||
}
|
||||
playerLoc2.get(player.getName()).setY(newy);
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSky"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||
}
|
||||
}
|
||||
public void sky(final Player player, final boolean resadmin) {
|
||||
if (hasPlacedBoth(player.getName())) {
|
||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||
final int y1 = playerLoc1.get(player.getName()).getBlockY();
|
||||
final int y2 = playerLoc2.get(player.getName()).getBlockY();
|
||||
if (y1 > y2) {
|
||||
int newy = MAX_HEIGHT;
|
||||
if (!resadmin) {
|
||||
if (group.getMaxHeight() < newy) {
|
||||
newy = group.getMaxHeight();
|
||||
}
|
||||
if (newy - y2 > (group.getMaxY() - 1)) {
|
||||
newy = y2 + (group.getMaxY() - 1);
|
||||
}
|
||||
}
|
||||
playerLoc1.get(player.getName()).setY(newy);
|
||||
} else {
|
||||
int newy = MAX_HEIGHT;
|
||||
if (!resadmin) {
|
||||
if (group.getMaxHeight() < newy) {
|
||||
newy = group.getMaxHeight();
|
||||
}
|
||||
if (newy - y1 > (group.getMaxY() - 1)) {
|
||||
newy = y1 + (group.getMaxY() - 1);
|
||||
}
|
||||
}
|
||||
playerLoc2.get(player.getName()).setY(newy);
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSky"));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||
}
|
||||
}
|
||||
|
||||
public void vert(final Player player, final boolean resadmin) {
|
||||
if (hasPlacedBoth(player.getName())) {
|
||||
this.sky(player, resadmin);
|
||||
this.bedrock(player, resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||
}
|
||||
}
|
||||
public void vert(final Player player, final boolean resadmin) {
|
||||
if (hasPlacedBoth(player.getName())) {
|
||||
this.sky(player, resadmin);
|
||||
this.bedrock(player, resadmin);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean worldEdit(final Player player) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("WorldEditNotFound"));
|
||||
return false;
|
||||
}
|
||||
public boolean worldEdit(final Player player) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("WorldEditNotFound"));
|
||||
return false;
|
||||
}
|
||||
|
||||
private Direction getDirection(final Player player) {
|
||||
final float pitch = player.getLocation().getPitch();
|
||||
final float yaw = player.getLocation().getYaw();
|
||||
if (pitch < -50) {
|
||||
return Direction.UP;
|
||||
}
|
||||
if (pitch > 50) {
|
||||
return Direction.DOWN;
|
||||
}
|
||||
if ((yaw > 45 && yaw < 135) || (yaw < -45 && yaw > -135)) {
|
||||
return Direction.MINUSX;
|
||||
}
|
||||
if ((yaw > 225 && yaw < 315) || (yaw < -225 && yaw > -315)) {
|
||||
return Direction.PLUSX;
|
||||
}
|
||||
if ((yaw > 135 && yaw < 225) || (yaw < -135 && yaw > -225)) {
|
||||
return Direction.MINUSZ;
|
||||
}
|
||||
if ((yaw < 45 || yaw > 315) || (yaw > -45 || yaw < -315)) {
|
||||
return Direction.PLUSZ;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private Direction getDirection(final Player player) {
|
||||
final float pitch = player.getLocation().getPitch();
|
||||
final float yaw = player.getLocation().getYaw();
|
||||
if (pitch < -50) {
|
||||
return Direction.UP;
|
||||
}
|
||||
if (pitch > 50) {
|
||||
return Direction.DOWN;
|
||||
}
|
||||
if ((yaw > 45 && yaw < 135) || (yaw < -45 && yaw > -135)) {
|
||||
return Direction.MINUSX;
|
||||
}
|
||||
if ((yaw > 225 && yaw < 315) || (yaw < -225 && yaw > -315)) {
|
||||
return Direction.PLUSX;
|
||||
}
|
||||
if ((yaw > 135 && yaw < 225) || (yaw < -135 && yaw > -225)) {
|
||||
return Direction.MINUSZ;
|
||||
}
|
||||
if ((yaw < 45 || yaw > 315) || (yaw > -45 || yaw < -315)) {
|
||||
return Direction.PLUSZ;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public enum Direction {
|
||||
DOWN,
|
||||
MINUSX,
|
||||
MINUSZ,
|
||||
PLUSX,
|
||||
PLUSZ,
|
||||
UP
|
||||
}
|
||||
public enum Direction {
|
||||
DOWN,
|
||||
MINUSX,
|
||||
MINUSZ,
|
||||
PLUSX,
|
||||
PLUSZ,
|
||||
UP
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
*
|
||||
*/
|
||||
public class WECUI {
|
||||
public static void UPDATESELECT(final ClaimedResidence res, final Player player) {
|
||||
final WorldEditPlugin wep = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
final Selection selection = new CuboidSelection(Bukkit.getWorld(res.getWorld()), res.getAreaByLoc(player.getLocation()).getLowLoc(), res.getAreaByLoc(player.getLocation()).getHighLoc());
|
||||
wep.setSelection(player, selection);
|
||||
}
|
||||
public static void UPDATESELECT(final ClaimedResidence res, final Player player) {
|
||||
final WorldEditPlugin wep = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
final Selection selection = new CuboidSelection(Bukkit.getWorld(res.getWorld()), res.getAreaByLoc(player.getLocation()).getLowLoc(), res.getAreaByLoc(player.getLocation()).getHighLoc());
|
||||
wep.setSelection(player, selection);
|
||||
}
|
||||
}
|
||||
@@ -20,87 +20,87 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class WorldEditSelectionManager extends SelectionManager {
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public WorldEditSelectionManager(final ResidenceMain plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public WorldEditSelectionManager(final ResidenceMain plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bedrock(final Player player, final boolean resadmin) {
|
||||
this.worldEdit(player);
|
||||
super.bedrock(player, resadmin);
|
||||
afterSelectionUpdate(player);
|
||||
}
|
||||
@Override
|
||||
public void bedrock(final Player player, final boolean resadmin) {
|
||||
this.worldEdit(player);
|
||||
super.bedrock(player, resadmin);
|
||||
afterSelectionUpdate(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify(final Player player, final boolean shift, final int amount) {
|
||||
this.worldEdit(player);
|
||||
super.modify(player, shift, amount);
|
||||
afterSelectionUpdate(player);
|
||||
}
|
||||
@Override
|
||||
public void modify(final Player player, final boolean shift, final int amount) {
|
||||
this.worldEdit(player);
|
||||
super.modify(player, shift, amount);
|
||||
afterSelectionUpdate(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLoc1(final Player player, final Location loc) {
|
||||
this.worldEdit(player);
|
||||
super.placeLoc1(player, loc);
|
||||
this.afterSelectionUpdate(player);
|
||||
}
|
||||
@Override
|
||||
public void placeLoc1(final Player player, final Location loc) {
|
||||
this.worldEdit(player);
|
||||
super.placeLoc1(player, loc);
|
||||
this.afterSelectionUpdate(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLoc2(final Player player, final Location loc) {
|
||||
this.worldEdit(player);
|
||||
super.placeLoc2(player, loc);
|
||||
this.afterSelectionUpdate(player);
|
||||
}
|
||||
@Override
|
||||
public void placeLoc2(final Player player, final Location loc) {
|
||||
this.worldEdit(player);
|
||||
super.placeLoc2(player, loc);
|
||||
this.afterSelectionUpdate(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectChunk(final Player player) {
|
||||
this.worldEdit(player);
|
||||
super.selectChunk(player);
|
||||
afterSelectionUpdate(player);
|
||||
}
|
||||
@Override
|
||||
public void selectChunk(final Player player) {
|
||||
this.worldEdit(player);
|
||||
super.selectChunk(player);
|
||||
afterSelectionUpdate(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showSelectionInfo(final Player player) {
|
||||
this.worldEdit(player);
|
||||
super.showSelectionInfo(player);
|
||||
}
|
||||
@Override
|
||||
public void showSelectionInfo(final Player player) {
|
||||
this.worldEdit(player);
|
||||
super.showSelectionInfo(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sky(final Player player, final boolean resadmin) {
|
||||
this.worldEdit(player);
|
||||
super.sky(player, resadmin);
|
||||
afterSelectionUpdate(player);
|
||||
}
|
||||
@Override
|
||||
public void sky(final Player player, final boolean resadmin) {
|
||||
this.worldEdit(player);
|
||||
super.sky(player, resadmin);
|
||||
afterSelectionUpdate(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean worldEdit(final Player player) {
|
||||
final WorldEditPlugin wep = (WorldEditPlugin) server.getPluginManager().getPlugin("WorldEdit");
|
||||
final Selection sel = wep.getSelection(player);
|
||||
if (sel != null) {
|
||||
Location pos1 = sel.getMinimumPoint();
|
||||
Location pos2 = sel.getMaximumPoint();
|
||||
try {
|
||||
final CuboidRegion region = (CuboidRegion) sel.getRegionSelector().getRegion();
|
||||
pos1 = new Location(player.getWorld(), region.getPos1().getX(), region.getPos1().getY(), region.getPos1().getZ());
|
||||
pos2 = new Location(player.getWorld(), region.getPos2().getX(), region.getPos2().getY(), region.getPos2().getZ());
|
||||
} catch (final Exception e) {
|
||||
}
|
||||
this.playerLoc1.put(player.getName(), pos1);
|
||||
this.playerLoc2.put(player.getName(), pos2);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean worldEdit(final Player player) {
|
||||
final WorldEditPlugin wep = (WorldEditPlugin) server.getPluginManager().getPlugin("WorldEdit");
|
||||
final Selection sel = wep.getSelection(player);
|
||||
if (sel != null) {
|
||||
Location pos1 = sel.getMinimumPoint();
|
||||
Location pos2 = sel.getMaximumPoint();
|
||||
try {
|
||||
final CuboidRegion region = (CuboidRegion) sel.getRegionSelector().getRegion();
|
||||
pos1 = new Location(player.getWorld(), region.getPos1().getX(), region.getPos1().getY(), region.getPos1().getZ());
|
||||
pos2 = new Location(player.getWorld(), region.getPos2().getX(), region.getPos2().getY(), region.getPos2().getZ());
|
||||
} catch (final Exception e) {
|
||||
}
|
||||
this.playerLoc1.put(player.getName(), pos1);
|
||||
this.playerLoc2.put(player.getName(), pos2);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void afterSelectionUpdate(final Player player) {
|
||||
if (hasPlacedBoth(player.getName())) {
|
||||
final WorldEditPlugin wep = (WorldEditPlugin) server.getPluginManager().getPlugin("WorldEdit");
|
||||
final World world = playerLoc1.get(player.getName()).getWorld();
|
||||
final Selection selection = new CuboidSelection(world, playerLoc1.get(player.getName()), playerLoc2.get(player.getName()));
|
||||
wep.setSelection(player, selection);
|
||||
}
|
||||
}
|
||||
private void afterSelectionUpdate(final Player player) {
|
||||
if (hasPlacedBoth(player.getName())) {
|
||||
final WorldEditPlugin wep = (WorldEditPlugin) server.getPluginManager().getPlugin("WorldEdit");
|
||||
final World world = playerLoc1.get(player.getName()).getWorld();
|
||||
final Selection selection = new CuboidSelection(world, playerLoc1.get(player.getName()), playerLoc2.get(player.getName()));
|
||||
wep.setSelection(player, selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,67 +16,67 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class Language {
|
||||
public Map<String, String> text;
|
||||
public Map<String, String> text;
|
||||
|
||||
public Language() {
|
||||
text = new HashMap<String, String>();
|
||||
}
|
||||
public Language() {
|
||||
text = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
public static Language parseText(final FileConfiguration node, final String topkey) {
|
||||
final Language newholder = new Language();
|
||||
final Set<String> keys = node.getConfigurationSection(topkey).getKeys(false);
|
||||
for (final String key : keys) {
|
||||
newholder.text.put(key, node.getString(topkey + "." + key));
|
||||
}
|
||||
return newholder;
|
||||
}
|
||||
public static Language parseText(final FileConfiguration node, final String topkey) {
|
||||
final Language newholder = new Language();
|
||||
final Set<String> keys = node.getConfigurationSection(topkey).getKeys(false);
|
||||
for (final String key : keys) {
|
||||
newholder.text.put(key, node.getString(topkey + "." + key));
|
||||
}
|
||||
return newholder;
|
||||
}
|
||||
|
||||
public String getPhrase(final String key) {
|
||||
final String[] split = key.split("\\.");
|
||||
return getPhrase(split);
|
||||
}
|
||||
public String getPhrase(final String key) {
|
||||
final String[] split = key.split("\\.");
|
||||
return getPhrase(split);
|
||||
}
|
||||
|
||||
public String getPhrase(final String key, final String words) {
|
||||
return this.getPhrase(key.split("\\."), words);
|
||||
}
|
||||
public String getPhrase(final String key, final String words) {
|
||||
return this.getPhrase(key.split("\\."), words);
|
||||
}
|
||||
|
||||
public String getPhrase(final String[] keys) {
|
||||
return this.getPhrase(keys, (String[]) null);
|
||||
}
|
||||
public String getPhrase(final String[] keys) {
|
||||
return this.getPhrase(keys, (String[]) null);
|
||||
}
|
||||
|
||||
public String getPhrase(final String[] keys, final String words) {
|
||||
if (words == null) {
|
||||
return this.getPhrase(keys, (String[]) null);
|
||||
}
|
||||
return this.getPhrase(keys, words.split("\\."));
|
||||
}
|
||||
public String getPhrase(final String[] keys, final String words) {
|
||||
if (words == null) {
|
||||
return this.getPhrase(keys, (String[]) null);
|
||||
}
|
||||
return this.getPhrase(keys, words.split("\\."));
|
||||
}
|
||||
|
||||
public String getPhrase(final String[] keys, final String[] words) {
|
||||
String sentence = "";
|
||||
for (final String key : keys) {
|
||||
if (sentence.length() == 0) {
|
||||
sentence = this.getText(key);
|
||||
} else {
|
||||
sentence = sentence + " " + this.getText(key).toLowerCase();
|
||||
}
|
||||
}
|
||||
if (words != null) {
|
||||
for (int i = 0; i < words.length; i++) {
|
||||
sentence = sentence.replaceAll("%" + (i + 1), words[i]);
|
||||
}
|
||||
}
|
||||
return sentence;
|
||||
}
|
||||
public String getPhrase(final String[] keys, final String[] words) {
|
||||
String sentence = "";
|
||||
for (final String key : keys) {
|
||||
if (sentence.length() == 0) {
|
||||
sentence = this.getText(key);
|
||||
} else {
|
||||
sentence = sentence + " " + this.getText(key).toLowerCase();
|
||||
}
|
||||
}
|
||||
if (words != null) {
|
||||
for (int i = 0; i < words.length; i++) {
|
||||
sentence = sentence.replaceAll("%" + (i + 1), words[i]);
|
||||
}
|
||||
}
|
||||
return sentence;
|
||||
}
|
||||
|
||||
public void setText(final String key, final String intext) {
|
||||
text.put(key, intext);
|
||||
}
|
||||
public void setText(final String key, final String intext) {
|
||||
text.put(key, intext);
|
||||
}
|
||||
|
||||
private String getText(final String key) {
|
||||
String t = text.get(key);
|
||||
if (t == null) {
|
||||
t = "<missing language key: " + key + ">";
|
||||
}
|
||||
return t;
|
||||
}
|
||||
private String getText(final String key) {
|
||||
String t = text.get(key);
|
||||
if (t == null) {
|
||||
t = "<missing language key: " + key + ">";
|
||||
}
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,173 +22,173 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class HelpEntry {
|
||||
protected static int linesPerPage = 7;
|
||||
protected String desc;
|
||||
protected String[] lines;
|
||||
protected String name;
|
||||
protected List<HelpEntry> subentrys;
|
||||
ResidenceMain plugin;
|
||||
protected static int linesPerPage = 7;
|
||||
protected String desc;
|
||||
protected String[] lines;
|
||||
protected String name;
|
||||
protected List<HelpEntry> subentrys;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public HelpEntry(final ResidenceMain plugin, final String entryname) {
|
||||
this.plugin = plugin;
|
||||
name = entryname;
|
||||
subentrys = new ArrayList<HelpEntry>();
|
||||
lines = new String[0];
|
||||
}
|
||||
public HelpEntry(final ResidenceMain plugin, final String entryname) {
|
||||
this.plugin = plugin;
|
||||
name = entryname;
|
||||
subentrys = new ArrayList<HelpEntry>();
|
||||
lines = new String[0];
|
||||
}
|
||||
|
||||
public static int getLinesPerPage() {
|
||||
return linesPerPage;
|
||||
}
|
||||
public static int getLinesPerPage() {
|
||||
return linesPerPage;
|
||||
}
|
||||
|
||||
public static HelpEntry parseHelp(final ResidenceMain plugin, final FileConfiguration node, final String key) {
|
||||
final String split[] = key.split("\\.");
|
||||
final String thisname = split[split.length - 1];
|
||||
final HelpEntry entry = new HelpEntry(plugin, thisname);
|
||||
final ConfigurationSection keysnode = node.getConfigurationSection(key);
|
||||
Set<String> keys = null;
|
||||
if (keysnode != null) {
|
||||
keys = keysnode.getKeys(false);
|
||||
}
|
||||
if (keys != null) {
|
||||
if (keys.contains("Info")) {
|
||||
final List<String> stringList = node.getStringList(key + ".Info");
|
||||
if (stringList != null) {
|
||||
entry.lines = new String[stringList.size()];
|
||||
for (int i = 0; i < stringList.size(); i++) {
|
||||
entry.lines[i] = "- " + stringList.get(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (keys.contains("Description")) {
|
||||
entry.desc = node.getString(key + ".Description");
|
||||
}
|
||||
if (keys.contains("SubCommands")) {
|
||||
final Set<String> subcommandkeys = node.getConfigurationSection(key + ".SubCommands").getKeys(false);
|
||||
for (final String subkey : subcommandkeys) {
|
||||
entry.subentrys.add(HelpEntry.parseHelp(plugin, node, key + ".SubCommands." + subkey));
|
||||
}
|
||||
}
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
public static HelpEntry parseHelp(final ResidenceMain plugin, final FileConfiguration node, final String key) {
|
||||
final String split[] = key.split("\\.");
|
||||
final String thisname = split[split.length - 1];
|
||||
final HelpEntry entry = new HelpEntry(plugin, thisname);
|
||||
final ConfigurationSection keysnode = node.getConfigurationSection(key);
|
||||
Set<String> keys = null;
|
||||
if (keysnode != null) {
|
||||
keys = keysnode.getKeys(false);
|
||||
}
|
||||
if (keys != null) {
|
||||
if (keys.contains("Info")) {
|
||||
final List<String> stringList = node.getStringList(key + ".Info");
|
||||
if (stringList != null) {
|
||||
entry.lines = new String[stringList.size()];
|
||||
for (int i = 0; i < stringList.size(); i++) {
|
||||
entry.lines[i] = "- " + stringList.get(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (keys.contains("Description")) {
|
||||
entry.desc = node.getString(key + ".Description");
|
||||
}
|
||||
if (keys.contains("SubCommands")) {
|
||||
final Set<String> subcommandkeys = node.getConfigurationSection(key + ".SubCommands").getKeys(false);
|
||||
for (final String subkey : subcommandkeys) {
|
||||
entry.subentrys.add(HelpEntry.parseHelp(plugin, node, key + ".SubCommands." + subkey));
|
||||
}
|
||||
}
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
public static void setLinesPerPage(final int lines) {
|
||||
linesPerPage = lines;
|
||||
}
|
||||
public static void setLinesPerPage(final int lines) {
|
||||
linesPerPage = lines;
|
||||
}
|
||||
|
||||
public void addSubEntry(final HelpEntry entry) {
|
||||
if (!subentrys.contains(entry)) {
|
||||
subentrys.add(entry);
|
||||
}
|
||||
}
|
||||
public void addSubEntry(final HelpEntry entry) {
|
||||
if (!subentrys.contains(entry)) {
|
||||
subentrys.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containesEntry(final String name) {
|
||||
return this.getSubEntry(name) != null;
|
||||
}
|
||||
public boolean containesEntry(final String name) {
|
||||
return this.getSubEntry(name) != null;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
if (desc == null) {
|
||||
return "";
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
public String getDescription() {
|
||||
if (desc == null) {
|
||||
return "";
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (name == null) {
|
||||
return "";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
if (name == null) {
|
||||
return "";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public HelpEntry getSubEntry(final String name) {
|
||||
final String[] split = name.split("\\.");
|
||||
HelpEntry entry = this;
|
||||
for (final String entryname : split) {
|
||||
entry = entry.findSubEntry(entryname);
|
||||
if (entry == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
public HelpEntry getSubEntry(final String name) {
|
||||
final String[] split = name.split("\\.");
|
||||
HelpEntry entry = this;
|
||||
for (final String entryname : split) {
|
||||
entry = entry.findSubEntry(entryname);
|
||||
if (entry == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
public int getSubEntryCount() {
|
||||
return subentrys.size();
|
||||
}
|
||||
public int getSubEntryCount() {
|
||||
return subentrys.size();
|
||||
}
|
||||
|
||||
public void printHelp(final CommandSender sender, final int page) {
|
||||
final List<String> helplines = this.getHelpData();
|
||||
final int pagecount = (int) Math.ceil((double) helplines.size() / (double) linesPerPage);
|
||||
if (page > pagecount || page < 1) {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("HelpPageHeader",
|
||||
ChatColor.YELLOW + name + ChatColor.RED + "." + ChatColor.YELLOW + page + ChatColor.RED + "." + ChatColor.YELLOW + pagecount + ChatColor.RED));
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + plugin.getLanguage().getPhrase("Description") + ": " + ChatColor.GREEN + desc);
|
||||
final int start = linesPerPage * (page - 1);
|
||||
final int end = start + linesPerPage;
|
||||
boolean alternatecolor = false;
|
||||
for (int i = start; i < end; i++) {
|
||||
if (helplines.size() > i) {
|
||||
if (alternatecolor) {
|
||||
sender.sendMessage(ChatColor.YELLOW + helplines.get(i));
|
||||
alternatecolor = false;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + helplines.get(i));
|
||||
alternatecolor = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (page < pagecount) {
|
||||
sender.sendMessage(ChatColor.GRAY + "---<" + plugin.getLanguage().getPhrase("NextPage") + ">---");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GRAY + "-----------------------");
|
||||
}
|
||||
}
|
||||
public void printHelp(final CommandSender sender, final int page) {
|
||||
final List<String> helplines = this.getHelpData();
|
||||
final int pagecount = (int) Math.ceil((double) helplines.size() / (double) linesPerPage);
|
||||
if (page > pagecount || page < 1) {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("HelpPageHeader",
|
||||
ChatColor.YELLOW + name + ChatColor.RED + "." + ChatColor.YELLOW + page + ChatColor.RED + "." + ChatColor.YELLOW + pagecount + ChatColor.RED));
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + plugin.getLanguage().getPhrase("Description") + ": " + ChatColor.GREEN + desc);
|
||||
final int start = linesPerPage * (page - 1);
|
||||
final int end = start + linesPerPage;
|
||||
boolean alternatecolor = false;
|
||||
for (int i = start; i < end; i++) {
|
||||
if (helplines.size() > i) {
|
||||
if (alternatecolor) {
|
||||
sender.sendMessage(ChatColor.YELLOW + helplines.get(i));
|
||||
alternatecolor = false;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + helplines.get(i));
|
||||
alternatecolor = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (page < pagecount) {
|
||||
sender.sendMessage(ChatColor.GRAY + "---<" + plugin.getLanguage().getPhrase("NextPage") + ">---");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GRAY + "-----------------------");
|
||||
}
|
||||
}
|
||||
|
||||
public void printHelp(final CommandSender sender, final int page, final String path) {
|
||||
final HelpEntry subEntry = this.getSubEntry(path);
|
||||
if (subEntry != null) {
|
||||
subEntry.printHelp(sender, page);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
|
||||
}
|
||||
}
|
||||
public void printHelp(final CommandSender sender, final int page, final String path) {
|
||||
final HelpEntry subEntry = this.getSubEntry(path);
|
||||
if (subEntry != null) {
|
||||
subEntry.printHelp(sender, page);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeSubEntry(final HelpEntry entry) {
|
||||
if (subentrys.contains(entry)) {
|
||||
subentrys.remove(entry);
|
||||
}
|
||||
}
|
||||
public void removeSubEntry(final HelpEntry entry) {
|
||||
if (subentrys.contains(entry)) {
|
||||
subentrys.remove(entry);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDescription(final String description) {
|
||||
desc = description;
|
||||
}
|
||||
public void setDescription(final String description) {
|
||||
desc = description;
|
||||
}
|
||||
|
||||
public void setName(final String inname) {
|
||||
name = inname;
|
||||
}
|
||||
public void setName(final String inname) {
|
||||
name = inname;
|
||||
}
|
||||
|
||||
private HelpEntry findSubEntry(final String name) {
|
||||
for (final HelpEntry entry : subentrys) {
|
||||
if (entry.getName().equalsIgnoreCase(name)) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private HelpEntry findSubEntry(final String name) {
|
||||
for (final HelpEntry entry : subentrys) {
|
||||
if (entry.getName().equalsIgnoreCase(name)) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<String> getHelpData() {
|
||||
final List<String> helplines = new ArrayList<String>();
|
||||
helplines.addAll(Arrays.asList(lines));
|
||||
if (subentrys.size() > 0) {
|
||||
helplines.add(ChatColor.LIGHT_PURPLE + "---" + plugin.getLanguage().getPhrase("SubCommands") + "---");
|
||||
}
|
||||
for (final HelpEntry entry : subentrys) {
|
||||
helplines.add(ChatColor.GREEN + entry.getName() + ChatColor.YELLOW + " - " + entry.getDescription());
|
||||
}
|
||||
return helplines;
|
||||
}
|
||||
private List<String> getHelpData() {
|
||||
final List<String> helplines = new ArrayList<String>();
|
||||
helplines.addAll(Arrays.asList(lines));
|
||||
if (subentrys.size() > 0) {
|
||||
helplines.add(ChatColor.LIGHT_PURPLE + "---" + plugin.getLanguage().getPhrase("SubCommands") + "---");
|
||||
}
|
||||
for (final HelpEntry entry : subentrys) {
|
||||
helplines.add(ChatColor.GREEN + entry.getName() + ChatColor.YELLOW + " - " + entry.getDescription());
|
||||
}
|
||||
return helplines;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,44 +19,44 @@ import cn.citycraft.Residence.ResidenceMain;
|
||||
*/
|
||||
public class InformationPager {
|
||||
|
||||
public static int linesPerPage = 7;
|
||||
public static int linesPerPage = 7;
|
||||
|
||||
public static int getLinesPerPage() {
|
||||
return linesPerPage;
|
||||
}
|
||||
public static int getLinesPerPage() {
|
||||
return linesPerPage;
|
||||
}
|
||||
|
||||
public static void printInfo(final ResidenceMain plugin, final CommandSender sender, final String title, final List<String> lines, final int page) {
|
||||
final int perPage = 6;
|
||||
final int start = (page - 1) * perPage;
|
||||
final int end = start + perPage;
|
||||
int pagecount = (int) Math.ceil((double) lines.size() / (double) perPage);
|
||||
if (pagecount == 0) {
|
||||
pagecount = 1;
|
||||
}
|
||||
if (page > pagecount) {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidPage"));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(ChatColor.YELLOW + "---<" + ChatColor.GREEN + title + ChatColor.YELLOW + ">---");
|
||||
sender.sendMessage(ChatColor.YELLOW + "---<"
|
||||
+ plugin.getLanguage().getPhrase("GenericPage", ChatColor.GREEN + String.format("%d", page) + ChatColor.YELLOW + "." + ChatColor.GREEN + pagecount + ChatColor.YELLOW) + ">---");
|
||||
for (int i = start; i < end; i++) {
|
||||
if (lines.size() > i) {
|
||||
sender.sendMessage(ChatColor.GREEN + lines.get(i));
|
||||
}
|
||||
}
|
||||
if (pagecount > page) {
|
||||
sender.sendMessage(ChatColor.GRAY + "---<" + plugin.getLanguage().getPhrase("NextPage") + ">---");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GRAY + "-----------------------");
|
||||
}
|
||||
}
|
||||
public static void printInfo(final ResidenceMain plugin, final CommandSender sender, final String title, final List<String> lines, final int page) {
|
||||
final int perPage = 6;
|
||||
final int start = (page - 1) * perPage;
|
||||
final int end = start + perPage;
|
||||
int pagecount = (int) Math.ceil((double) lines.size() / (double) perPage);
|
||||
if (pagecount == 0) {
|
||||
pagecount = 1;
|
||||
}
|
||||
if (page > pagecount) {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidPage"));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(ChatColor.YELLOW + "---<" + ChatColor.GREEN + title + ChatColor.YELLOW + ">---");
|
||||
sender.sendMessage(ChatColor.YELLOW + "---<"
|
||||
+ plugin.getLanguage().getPhrase("GenericPage", ChatColor.GREEN + String.format("%d", page) + ChatColor.YELLOW + "." + ChatColor.GREEN + pagecount + ChatColor.YELLOW) + ">---");
|
||||
for (int i = start; i < end; i++) {
|
||||
if (lines.size() > i) {
|
||||
sender.sendMessage(ChatColor.GREEN + lines.get(i));
|
||||
}
|
||||
}
|
||||
if (pagecount > page) {
|
||||
sender.sendMessage(ChatColor.GRAY + "---<" + plugin.getLanguage().getPhrase("NextPage") + ">---");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GRAY + "-----------------------");
|
||||
}
|
||||
}
|
||||
|
||||
public static void printInfo(final ResidenceMain plugin, final CommandSender sender, final String title, final String[] lines, final int page) {
|
||||
InformationPager.printInfo(plugin, sender, title, Arrays.asList(lines), page);
|
||||
}
|
||||
public static void printInfo(final ResidenceMain plugin, final CommandSender sender, final String title, final String[] lines, final int page) {
|
||||
InformationPager.printInfo(plugin, sender, title, Arrays.asList(lines), page);
|
||||
}
|
||||
|
||||
public static void setLinesPerPage(final int lines) {
|
||||
linesPerPage = lines;
|
||||
}
|
||||
public static void setLinesPerPage(final int lines) {
|
||||
linesPerPage = lines;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,101 +18,101 @@ import org.bukkit.World;
|
||||
import cn.citycraft.Residence.ResidenceMain;
|
||||
|
||||
public class DataBackup {
|
||||
private final File BackupDir;
|
||||
private final File BackupDir;
|
||||
|
||||
ResidenceMain plugin;
|
||||
ResidenceMain plugin;
|
||||
|
||||
public DataBackup(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
BackupDir = new File(plugin.getDataLocation(), "Backup");
|
||||
}
|
||||
public DataBackup(final ResidenceMain plugin) {
|
||||
this.plugin = plugin;
|
||||
BackupDir = new File(plugin.getDataLocation(), "Backup");
|
||||
}
|
||||
|
||||
public void backup() throws IOException {
|
||||
try {
|
||||
BackupDir.mkdir();
|
||||
final Date date = new Date();
|
||||
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
|
||||
final File fileZip = new File(BackupDir, dateFormat.format(date) + ".zip");
|
||||
public void backup() throws IOException {
|
||||
try {
|
||||
BackupDir.mkdir();
|
||||
final Date date = new Date();
|
||||
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
|
||||
final File fileZip = new File(BackupDir, dateFormat.format(date) + ".zip");
|
||||
|
||||
// Create the Source List, and add directories/etc to the file.
|
||||
final List<File> sources = new ArrayList<File>();
|
||||
// Create the Source List, and add directories/etc to the file.
|
||||
final List<File> sources = new ArrayList<File>();
|
||||
|
||||
final File saveFolder = new File(plugin.getDataLocation(), "Save");
|
||||
final File worldFolder = new File(saveFolder, "Worlds");
|
||||
if (!saveFolder.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
File saveFile;
|
||||
for (final World world : Bukkit.getServer().getWorlds()) {
|
||||
saveFile = new File(worldFolder, "res_" + world.getName() + ".yml");
|
||||
if (saveFile.isFile()) {
|
||||
sources.add(saveFile);
|
||||
}
|
||||
}
|
||||
packZip(fileZip, sources);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
final File saveFolder = new File(plugin.getDataLocation(), "Save");
|
||||
final File worldFolder = new File(saveFolder, "Worlds");
|
||||
if (!saveFolder.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
File saveFile;
|
||||
for (final World world : Bukkit.getServer().getWorlds()) {
|
||||
saveFile = new File(worldFolder, "res_" + world.getName() + ".yml");
|
||||
if (saveFile.isFile()) {
|
||||
sources.add(saveFile);
|
||||
}
|
||||
}
|
||||
packZip(fileZip, sources);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private String buildPath(final String path, final String file) {
|
||||
if (path == null || path.isEmpty()) {
|
||||
return file;
|
||||
}
|
||||
private String buildPath(final String path, final String file) {
|
||||
if (path == null || path.isEmpty()) {
|
||||
return file;
|
||||
}
|
||||
|
||||
return path + File.separator + file;
|
||||
}
|
||||
return path + File.separator + file;
|
||||
}
|
||||
|
||||
private void packZip(final File output, final List<File> sources) throws IOException {
|
||||
final ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(output));
|
||||
zipOut.setLevel(Deflater.DEFAULT_COMPRESSION);
|
||||
private void packZip(final File output, final List<File> sources) throws IOException {
|
||||
final ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(output));
|
||||
zipOut.setLevel(Deflater.DEFAULT_COMPRESSION);
|
||||
|
||||
for (final File source : sources) {
|
||||
if (source.isDirectory()) {
|
||||
zipDir(zipOut, "", source);
|
||||
} else {
|
||||
zipFile(zipOut, "", source);
|
||||
}
|
||||
}
|
||||
for (final File source : sources) {
|
||||
if (source.isDirectory()) {
|
||||
zipDir(zipOut, "", source);
|
||||
} else {
|
||||
zipFile(zipOut, "", source);
|
||||
}
|
||||
}
|
||||
|
||||
zipOut.flush();
|
||||
zipOut.close();
|
||||
}
|
||||
zipOut.flush();
|
||||
zipOut.close();
|
||||
}
|
||||
|
||||
private void zipDir(final ZipOutputStream zos, String path, final File dir) throws IOException {
|
||||
if (!dir.canRead()) {
|
||||
return;
|
||||
}
|
||||
private void zipDir(final ZipOutputStream zos, String path, final File dir) throws IOException {
|
||||
if (!dir.canRead()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final File[] files = dir.listFiles();
|
||||
path = buildPath(path, dir.getName());
|
||||
final File[] files = dir.listFiles();
|
||||
path = buildPath(path, dir.getName());
|
||||
|
||||
for (final File source : files) {
|
||||
if (source.isDirectory()) {
|
||||
zipDir(zos, path, source);
|
||||
} else {
|
||||
zipFile(zos, path, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final File source : files) {
|
||||
if (source.isDirectory()) {
|
||||
zipDir(zos, path, source);
|
||||
} else {
|
||||
zipFile(zos, path, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void zipFile(final ZipOutputStream zos, final String path, final File file) throws IOException {
|
||||
if (!file.canRead()) {
|
||||
return;
|
||||
}
|
||||
private void zipFile(final ZipOutputStream zos, final String path, final File file) throws IOException {
|
||||
if (!file.canRead()) {
|
||||
return;
|
||||
}
|
||||
|
||||
zos.putNextEntry(new ZipEntry(buildPath(path, file.getName())));
|
||||
zos.putNextEntry(new ZipEntry(buildPath(path, file.getName())));
|
||||
|
||||
final FileInputStream fis = new FileInputStream(file);
|
||||
final byte[] buffer = new byte[4092];
|
||||
int byteCount = 0;
|
||||
final FileInputStream fis = new FileInputStream(file);
|
||||
final byte[] buffer = new byte[4092];
|
||||
int byteCount = 0;
|
||||
|
||||
while ((byteCount = fis.read(buffer)) != -1) {
|
||||
zos.write(buffer, 0, byteCount);
|
||||
}
|
||||
while ((byteCount = fis.read(buffer)) != -1) {
|
||||
zos.write(buffer, 0, byteCount);
|
||||
}
|
||||
|
||||
fis.close();
|
||||
zos.closeEntry();
|
||||
}
|
||||
fis.close();
|
||||
zos.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,127 +21,127 @@ import net.milkbowl.vault.permission.Permission;
|
||||
*/
|
||||
public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInterface {
|
||||
|
||||
public static Permission permissions = null;
|
||||
public static Economy economy = null;
|
||||
public static Chat chat = null;
|
||||
public static Permission permissions = null;
|
||||
public static Economy economy = null;
|
||||
public static Chat chat = null;
|
||||
|
||||
public ResidenceVaultAdapter(final Server s) {
|
||||
this.setupPermissions(s);
|
||||
this.setupEconomy(s);
|
||||
this.setupChat(s);
|
||||
}
|
||||
public ResidenceVaultAdapter(final Server s) {
|
||||
this.setupPermissions(s);
|
||||
this.setupEconomy(s);
|
||||
this.setupChat(s);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean add(final String playerName, final double amount) {
|
||||
return economy.depositPlayer(playerName, amount).transactionSuccess();
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean add(final String playerName, final double amount) {
|
||||
return economy.depositPlayer(playerName, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean canAfford(final String playerName, final double amount) {
|
||||
return economy.has(playerName, amount);
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean canAfford(final String playerName, final double amount) {
|
||||
return economy.has(playerName, amount);
|
||||
}
|
||||
|
||||
public boolean chatOK() {
|
||||
return chat != null;
|
||||
}
|
||||
public boolean chatOK() {
|
||||
return chat != null;
|
||||
}
|
||||
|
||||
public boolean economyOK() {
|
||||
return economy != null;
|
||||
}
|
||||
public boolean economyOK() {
|
||||
return economy != null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public double getBalance(final String playerName) {
|
||||
return economy.getBalance(playerName);
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public double getBalance(final String playerName) {
|
||||
return economy.getBalance(playerName);
|
||||
}
|
||||
|
||||
public String getChatName() {
|
||||
if (chat != null)
|
||||
return chat.getName();
|
||||
return "";
|
||||
}
|
||||
public String getChatName() {
|
||||
if (chat != null)
|
||||
return chat.getName();
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getEconomyName() {
|
||||
if (economy != null)
|
||||
return economy.getName();
|
||||
return "";
|
||||
}
|
||||
public String getEconomyName() {
|
||||
if (economy != null)
|
||||
return economy.getName();
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Vault";
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Vault";
|
||||
}
|
||||
|
||||
public String getPermissionsName() {
|
||||
if (permissions != null)
|
||||
return permissions.getName();
|
||||
return "";
|
||||
}
|
||||
public String getPermissionsName() {
|
||||
if (permissions != null)
|
||||
return permissions.getName();
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerGroup(final Player player) {
|
||||
final String group = permissions.getPrimaryGroup(player).toLowerCase();
|
||||
if (group == null)
|
||||
return group;
|
||||
return group.toLowerCase();
|
||||
}
|
||||
@Override
|
||||
public String getPlayerGroup(final Player player) {
|
||||
final String group = permissions.getPrimaryGroup(player).toLowerCase();
|
||||
if (group == null)
|
||||
return group;
|
||||
return group.toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public String getPlayerGroup(final String player, final String world) {
|
||||
final String group = permissions.getPrimaryGroup(world, player);
|
||||
if (group == null)
|
||||
return group;
|
||||
return group.toLowerCase();
|
||||
}
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public String getPlayerGroup(final String player, final String world) {
|
||||
final String group = permissions.getPrimaryGroup(world, player);
|
||||
if (group == null)
|
||||
return group;
|
||||
return group.toLowerCase();
|
||||
}
|
||||
|
||||
public boolean permissionsOK() {
|
||||
if (permissions != null && !permissions.getName().equalsIgnoreCase("SuperPerms"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public boolean permissionsOK() {
|
||||
if (permissions != null && !permissions.getName().equalsIgnoreCase("SuperPerms"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean subtract(final String playerName, final double amount) {
|
||||
return economy.withdrawPlayer(playerName, amount).transactionSuccess();
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean subtract(final String playerName, final double amount) {
|
||||
return economy.withdrawPlayer(playerName, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean transfer(final String playerFrom, final String playerTo, final double amount) {
|
||||
if (economy.withdrawPlayer(playerFrom, amount).transactionSuccess()) {
|
||||
if (economy.depositPlayer(playerTo, amount).transactionSuccess())
|
||||
return true;
|
||||
economy.depositPlayer(playerFrom, amount);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean transfer(final String playerFrom, final String playerTo, final double amount) {
|
||||
if (economy.withdrawPlayer(playerFrom, amount).transactionSuccess()) {
|
||||
if (economy.depositPlayer(playerTo, amount).transactionSuccess())
|
||||
return true;
|
||||
economy.depositPlayer(playerFrom, amount);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean setupChat(final Server s) {
|
||||
final RegisteredServiceProvider<Chat> chatProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
|
||||
if (chatProvider != null) {
|
||||
chat = chatProvider.getProvider();
|
||||
}
|
||||
return (chat != null);
|
||||
}
|
||||
private boolean setupChat(final Server s) {
|
||||
final RegisteredServiceProvider<Chat> chatProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
|
||||
if (chatProvider != null) {
|
||||
chat = chatProvider.getProvider();
|
||||
}
|
||||
return (chat != null);
|
||||
}
|
||||
|
||||
private boolean setupEconomy(final Server s) {
|
||||
final RegisteredServiceProvider<Economy> economyProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
economy = economyProvider.getProvider();
|
||||
}
|
||||
return (economy != null);
|
||||
}
|
||||
private boolean setupEconomy(final Server s) {
|
||||
final RegisteredServiceProvider<Economy> economyProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
economy = economyProvider.getProvider();
|
||||
}
|
||||
return (economy != null);
|
||||
}
|
||||
|
||||
private boolean setupPermissions(final Server s) {
|
||||
final RegisteredServiceProvider<Permission> permissionProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
||||
if (permissionProvider != null) {
|
||||
permissions = permissionProvider.getProvider();
|
||||
}
|
||||
return (permissions != null);
|
||||
}
|
||||
private boolean setupPermissions(final Server s) {
|
||||
final RegisteredServiceProvider<Permission> permissionProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
||||
if (permissionProvider != null) {
|
||||
permissions = permissionProvider.getProvider();
|
||||
}
|
||||
return (permissions != null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,117 +27,117 @@ import cn.citycraft.Residence.text.Language;
|
||||
import cn.citycraft.Residence.text.help.HelpEntry;
|
||||
|
||||
public class Residence {
|
||||
static ResidenceMain instance;
|
||||
static ResidenceMain instance;
|
||||
|
||||
public Residence(final ResidenceMain instance) {
|
||||
Residence.instance = instance;
|
||||
}
|
||||
public Residence(final ResidenceMain instance) {
|
||||
Residence.instance = instance;
|
||||
}
|
||||
|
||||
public static ChatManager getChatManager() {
|
||||
return instance.getChatManager();
|
||||
}
|
||||
public static ChatManager getChatManager() {
|
||||
return instance.getChatManager();
|
||||
}
|
||||
|
||||
public static ConfigManager getConfigManager() {
|
||||
return instance.getConfigManager();
|
||||
}
|
||||
public static ConfigManager getConfigManager() {
|
||||
return instance.getConfigManager();
|
||||
}
|
||||
|
||||
public static File getDataLocation() {
|
||||
return instance.getDataFolder();
|
||||
}
|
||||
public static File getDataLocation() {
|
||||
return instance.getDataFolder();
|
||||
}
|
||||
|
||||
public static Map<String, String> getDeleteConfirm() {
|
||||
return instance.getDeleteConfirm();
|
||||
}
|
||||
public static Map<String, String> getDeleteConfirm() {
|
||||
return instance.getDeleteConfirm();
|
||||
}
|
||||
|
||||
public static EconomyInterface getEconomyManager() {
|
||||
return instance.getEconomyManager();
|
||||
}
|
||||
public static EconomyInterface getEconomyManager() {
|
||||
return instance.getEconomyManager();
|
||||
}
|
||||
|
||||
public static EntityManager getEntityManager() {
|
||||
return instance.getEntityManager();
|
||||
}
|
||||
public static EntityManager getEntityManager() {
|
||||
return instance.getEntityManager();
|
||||
}
|
||||
|
||||
public static HelpEntry getHelppages() {
|
||||
return instance.getHelppages();
|
||||
}
|
||||
public static HelpEntry getHelppages() {
|
||||
return instance.getHelppages();
|
||||
}
|
||||
|
||||
public static WorldItemManager getItemManager() {
|
||||
return instance.getItemManager();
|
||||
}
|
||||
public static WorldItemManager getItemManager() {
|
||||
return instance.getItemManager();
|
||||
}
|
||||
|
||||
public static Language getLanguage() {
|
||||
if (instance.getLanguage() == null) {
|
||||
instance.setLanguage(new Language());
|
||||
}
|
||||
return instance.getLanguage();
|
||||
}
|
||||
public static Language getLanguage() {
|
||||
if (instance.getLanguage() == null) {
|
||||
instance.setLanguage(new Language());
|
||||
}
|
||||
return instance.getLanguage();
|
||||
}
|
||||
|
||||
public static LeaseManager getLeaseManager() {
|
||||
return instance.getLeaseManager();
|
||||
}
|
||||
public static LeaseManager getLeaseManager() {
|
||||
return instance.getLeaseManager();
|
||||
}
|
||||
|
||||
public static PermissionListManager getPermissionListManager() {
|
||||
return instance.getPermissionListManager();
|
||||
}
|
||||
public static PermissionListManager getPermissionListManager() {
|
||||
return instance.getPermissionListManager();
|
||||
}
|
||||
|
||||
public static PermissionManager getPermissionManager() {
|
||||
return instance.getPermissionManager();
|
||||
}
|
||||
public static PermissionManager getPermissionManager() {
|
||||
return instance.getPermissionManager();
|
||||
}
|
||||
|
||||
public static FlagPermissions getPermsByLoc(final Location loc) {
|
||||
final ClaimedResidence res = getResidenceManager().getByLoc(loc);
|
||||
if (res != null) {
|
||||
return res.getPermissions();
|
||||
}
|
||||
return getWorldFlags().getPerms(loc.getWorld().getName());
|
||||
}
|
||||
public static FlagPermissions getPermsByLoc(final Location loc) {
|
||||
final ClaimedResidence res = getResidenceManager().getByLoc(loc);
|
||||
if (res != null) {
|
||||
return res.getPermissions();
|
||||
}
|
||||
return getWorldFlags().getPerms(loc.getWorld().getName());
|
||||
}
|
||||
|
||||
public static FlagPermissions getPermsByLocForPlayer(final Location loc, final Player player) {
|
||||
final ClaimedResidence res = getResidenceManager().getByLoc(loc);
|
||||
if (res != null) {
|
||||
return res.getPermissions();
|
||||
} else if (player != null) {
|
||||
return getWorldFlags().getPerms(player);
|
||||
} else {
|
||||
return getWorldFlags().getPerms(loc.getWorld().getName());
|
||||
}
|
||||
}
|
||||
public static FlagPermissions getPermsByLocForPlayer(final Location loc, final Player player) {
|
||||
final ClaimedResidence res = getResidenceManager().getByLoc(loc);
|
||||
if (res != null) {
|
||||
return res.getPermissions();
|
||||
} else if (player != null) {
|
||||
return getWorldFlags().getPerms(player);
|
||||
} else {
|
||||
return getWorldFlags().getPerms(loc.getWorld().getName());
|
||||
}
|
||||
}
|
||||
|
||||
public static RentManager getRentManager() {
|
||||
return instance.getRentManager();
|
||||
}
|
||||
public static RentManager getRentManager() {
|
||||
return instance.getRentManager();
|
||||
}
|
||||
|
||||
public static ResidenceManager getResidenceManager() {
|
||||
return instance.getResidenceManager();
|
||||
}
|
||||
public static ResidenceManager getResidenceManager() {
|
||||
return instance.getResidenceManager();
|
||||
}
|
||||
|
||||
public static SelectionManager getSelectionManager() {
|
||||
return instance.getSelectionManager();
|
||||
}
|
||||
public static SelectionManager getSelectionManager() {
|
||||
return instance.getSelectionManager();
|
||||
}
|
||||
|
||||
public static TransactionManager getTransactionManager() {
|
||||
return instance.getTransactionManager();
|
||||
}
|
||||
public static TransactionManager getTransactionManager() {
|
||||
return instance.getTransactionManager();
|
||||
}
|
||||
|
||||
public static WorldFlagManager getWorldFlags() {
|
||||
return instance.getWorldFlags();
|
||||
}
|
||||
public static WorldFlagManager getWorldFlags() {
|
||||
return instance.getWorldFlags();
|
||||
}
|
||||
|
||||
public static boolean isResAdminOn(final Player player) {
|
||||
if (instance.getResadminToggle().contains(player.getName())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean isResAdminOn(final Player player) {
|
||||
if (instance.getResadminToggle().contains(player.getName())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isResAdminOn(final String player) {
|
||||
if (instance.getResadminToggle().contains(player.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean isResAdminOn(final String player) {
|
||||
if (instance.getResadminToggle().contains(player.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isUseWorldEdit() {
|
||||
return instance.isUseWorldEdit();
|
||||
}
|
||||
public static boolean isUseWorldEdit() {
|
||||
return instance.isUseWorldEdit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,21 +15,20 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
*/
|
||||
public class CancellableResidenceEvent extends ResidenceEvent implements Cancellable {
|
||||
|
||||
protected boolean cancelled;
|
||||
protected boolean cancelled;
|
||||
|
||||
public CancellableResidenceEvent(String eventName, ClaimedResidence resref)
|
||||
{
|
||||
super(eventName,resref);
|
||||
}
|
||||
public CancellableResidenceEvent(String eventName, ClaimedResidence resref) {
|
||||
super(eventName, resref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
@Override
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,22 +16,21 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
*/
|
||||
public class CancellableResidencePlayerEvent extends ResidencePlayerEvent implements Cancellable {
|
||||
|
||||
protected boolean cancelled;
|
||||
protected boolean cancelled;
|
||||
|
||||
public CancellableResidencePlayerEvent(String eventName, ClaimedResidence resref, Player player)
|
||||
{
|
||||
super(eventName, resref, player);
|
||||
cancelled = false;
|
||||
}
|
||||
public CancellableResidencePlayerEvent(String eventName, ClaimedResidence resref, Player player) {
|
||||
super(eventName, resref, player);
|
||||
cancelled = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
@Override
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,21 +16,20 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
*/
|
||||
public class CancellableResidencePlayerFlagEvent extends ResidencePlayerFlagEvent implements Cancellable {
|
||||
|
||||
protected boolean cancelled;
|
||||
protected boolean cancelled;
|
||||
|
||||
public CancellableResidencePlayerFlagEvent(String eventName, ClaimedResidence resref, Player player, String flag, FlagType type, String target)
|
||||
{
|
||||
super(eventName, resref, player, flag, type, target);
|
||||
}
|
||||
public CancellableResidencePlayerFlagEvent(String eventName, ClaimedResidence resref, Player player, String flag, FlagType type, String target) {
|
||||
super(eventName, resref, player, flag, type, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
@Override
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,11 +37,14 @@ public class ResidenceChangedEvent extends ResidencePlayerEvent {
|
||||
* Constructs a {@link ResidenceChangedEvent} to identify a residence transition for the
|
||||
* given player
|
||||
*
|
||||
* @param from the residence that the player left or {@code null} if coming from an
|
||||
* unprotected area.
|
||||
* @param to the residence that the player entered or {@code null} if entering an
|
||||
* unprotected area.
|
||||
* @param player player involved in the transition
|
||||
* @param from
|
||||
* the residence that the player left or {@code null} if coming from an
|
||||
* unprotected area.
|
||||
* @param to
|
||||
* the residence that the player entered or {@code null} if entering an
|
||||
* unprotected area.
|
||||
* @param player
|
||||
* player involved in the transition
|
||||
*/
|
||||
public ResidenceChangedEvent(ClaimedResidence from, ClaimedResidence to, Player player) {
|
||||
super("RESIDENCE_CHANGE", null, player);
|
||||
@@ -53,20 +56,20 @@ public class ResidenceChangedEvent extends ResidencePlayerEvent {
|
||||
* Returns the residence from which player came.
|
||||
*
|
||||
* @return the residence from which player came or {@code null} if player came from an
|
||||
* unprotected area
|
||||
* unprotected area
|
||||
*/
|
||||
public ClaimedResidence getFrom() {
|
||||
return from;
|
||||
return from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the residence that player has entered.
|
||||
*
|
||||
* @return the residence that player has entered or {@code null} if player enters an
|
||||
* unprotected area
|
||||
* unprotected area
|
||||
*/
|
||||
public ClaimedResidence getTo() {
|
||||
return to;
|
||||
return to;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
public class ResidenceChatEvent extends CancellableResidencePlayerEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
@@ -35,23 +36,19 @@ public class ResidenceChatEvent extends CancellableResidencePlayerEvent {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getChatMessage()
|
||||
{
|
||||
public String getChatMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setChatMessage(String newmessage)
|
||||
{
|
||||
public void setChatMessage(String newmessage) {
|
||||
message = newmessage;
|
||||
}
|
||||
|
||||
public ChatColor getColor()
|
||||
{
|
||||
public ChatColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(ChatColor c)
|
||||
{
|
||||
public void setColor(ChatColor c) {
|
||||
color = c;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,53 +16,51 @@ import org.bukkit.event.HandlerList;
|
||||
*/
|
||||
public class ResidenceCommandEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
protected boolean cancelled;
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
protected String cmd;
|
||||
protected String arglist[];
|
||||
CommandSender commandsender;
|
||||
public ResidenceCommandEvent(String command, String args[], CommandSender sender)
|
||||
{
|
||||
super();
|
||||
cancelled = false;
|
||||
arglist = args;
|
||||
cmd = command;
|
||||
commandsender = sender;
|
||||
}
|
||||
protected boolean cancelled;
|
||||
|
||||
public String[] getArgs()
|
||||
{
|
||||
return arglist;
|
||||
}
|
||||
protected String cmd;
|
||||
protected String arglist[];
|
||||
CommandSender commandsender;
|
||||
|
||||
public String getCommand()
|
||||
{
|
||||
return cmd;
|
||||
}
|
||||
public ResidenceCommandEvent(String command, String args[], CommandSender sender) {
|
||||
super();
|
||||
cancelled = false;
|
||||
arglist = args;
|
||||
cmd = command;
|
||||
commandsender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
public String[] getArgs() {
|
||||
return arglist;
|
||||
}
|
||||
|
||||
public CommandSender getSender()
|
||||
{
|
||||
return commandsender;
|
||||
}
|
||||
public String getCommand() {
|
||||
return cmd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
public CommandSender getSender() {
|
||||
return commandsender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.bekvon.bukkit.residence.protection.CuboidArea;
|
||||
public class ResidenceCreationEvent extends CancellableResidencePlayerEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
@@ -30,30 +31,25 @@ public class ResidenceCreationEvent extends CancellableResidencePlayerEvent {
|
||||
protected String resname;
|
||||
CuboidArea area;
|
||||
|
||||
public ResidenceCreationEvent(Player player, String newname, ClaimedResidence resref, CuboidArea resarea)
|
||||
{
|
||||
super("RESIDENCE_CREATE",resref,player);
|
||||
public ResidenceCreationEvent(Player player, String newname, ClaimedResidence resref, CuboidArea resarea) {
|
||||
super("RESIDENCE_CREATE", resref, player);
|
||||
resname = newname;
|
||||
area = resarea;
|
||||
}
|
||||
|
||||
public String getResidenceName()
|
||||
{
|
||||
public String getResidenceName() {
|
||||
return resname;
|
||||
}
|
||||
|
||||
public void setResidenceName(String name)
|
||||
{
|
||||
public void setResidenceName(String name) {
|
||||
resname = name;
|
||||
}
|
||||
|
||||
public CuboidArea getPhysicalArea()
|
||||
{
|
||||
public CuboidArea getPhysicalArea() {
|
||||
return area;
|
||||
}
|
||||
|
||||
public void setPhysicalArea(CuboidArea newarea)
|
||||
{
|
||||
public void setPhysicalArea(CuboidArea newarea) {
|
||||
area = newarea;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,19 +28,19 @@ public class ResidenceDeleteEvent extends CancellableResidencePlayerEvent {
|
||||
}
|
||||
|
||||
public enum DeleteCause {
|
||||
LEASE_EXPIRE,PLAYER_DELETE,OTHER
|
||||
LEASE_EXPIRE,
|
||||
PLAYER_DELETE,
|
||||
OTHER
|
||||
}
|
||||
|
||||
DeleteCause cause;
|
||||
|
||||
public ResidenceDeleteEvent(Player player, ClaimedResidence resref, DeleteCause delcause)
|
||||
{
|
||||
public ResidenceDeleteEvent(Player player, ClaimedResidence resref, DeleteCause delcause) {
|
||||
super("RESIDENCE_DELETE", resref, player);
|
||||
cause = delcause;
|
||||
}
|
||||
|
||||
public DeleteCause getCause()
|
||||
{
|
||||
public DeleteCause getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,32 +16,31 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
*/
|
||||
public class ResidenceEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private String message;
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
ClaimedResidence res;
|
||||
private String message;
|
||||
|
||||
public ResidenceEvent(String eventName, ClaimedResidence resref)
|
||||
{
|
||||
message = eventName;
|
||||
res = resref;
|
||||
}
|
||||
ClaimedResidence res;
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
public ResidenceEvent(String eventName, ClaimedResidence resref) {
|
||||
message = eventName;
|
||||
res = resref;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public ClaimedResidence getResidence()
|
||||
{
|
||||
return res;
|
||||
}
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public ClaimedResidence getResidence() {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.bekvon.bukkit.residence.protection.FlagPermissions.FlagState;
|
||||
public class ResidenceFlagChangeEvent extends CancellableResidencePlayerFlagEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
@@ -29,14 +30,12 @@ public class ResidenceFlagChangeEvent extends CancellableResidencePlayerFlagEven
|
||||
|
||||
FlagState newstate;
|
||||
|
||||
public ResidenceFlagChangeEvent(ClaimedResidence resref, Player player, String flag, FlagType type,FlagState newState, String target)
|
||||
{
|
||||
public ResidenceFlagChangeEvent(ClaimedResidence resref, Player player, String flag, FlagType type, FlagState newState, String target) {
|
||||
super("RESIDENCE_FLAG_CHANGE", resref, player, flag, type, target);
|
||||
newstate = newState;
|
||||
}
|
||||
|
||||
public FlagState getNewState()
|
||||
{
|
||||
public FlagState getNewState() {
|
||||
return newstate;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,46 +14,42 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
* @author Administrator
|
||||
*/
|
||||
public class ResidenceFlagCheckEvent extends ResidenceFlagEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
private boolean override;
|
||||
private boolean override;
|
||||
|
||||
private boolean overridevalue;
|
||||
boolean defaultvalue;
|
||||
public ResidenceFlagCheckEvent(ClaimedResidence resref, String flag, FlagType type, String target, boolean defaultValue)
|
||||
{
|
||||
super("RESIDENCE_FLAG_CHECK", resref, flag, type, target);
|
||||
defaultvalue = defaultValue;
|
||||
override = false;
|
||||
}
|
||||
private boolean overridevalue;
|
||||
boolean defaultvalue;
|
||||
|
||||
public boolean getDefaultValue()
|
||||
{
|
||||
return defaultvalue;
|
||||
}
|
||||
public ResidenceFlagCheckEvent(ClaimedResidence resref, String flag, FlagType type, String target, boolean defaultValue) {
|
||||
super("RESIDENCE_FLAG_CHECK", resref, flag, type, target);
|
||||
defaultvalue = defaultValue;
|
||||
override = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
public boolean getDefaultValue() {
|
||||
return defaultvalue;
|
||||
}
|
||||
|
||||
public boolean getOverrideValue()
|
||||
{
|
||||
return overridevalue;
|
||||
}
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public boolean isOverriden()
|
||||
{
|
||||
return override;
|
||||
}
|
||||
public boolean getOverrideValue() {
|
||||
return overridevalue;
|
||||
}
|
||||
|
||||
public void overrideCheck(boolean flagval)
|
||||
{
|
||||
overridevalue = flagval;
|
||||
override=true;
|
||||
}
|
||||
public boolean isOverriden() {
|
||||
return override;
|
||||
}
|
||||
|
||||
public void overrideCheck(boolean flagval) {
|
||||
overridevalue = flagval;
|
||||
override = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.bekvon.bukkit.residence.protection.FlagPermissions.FlagState;
|
||||
public class ResidenceFlagEvent extends ResidenceEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
@@ -26,9 +27,10 @@ public class ResidenceFlagEvent extends ResidenceEvent {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public enum FlagType
|
||||
{
|
||||
RESIDENCE,GROUP,PLAYER
|
||||
public enum FlagType {
|
||||
RESIDENCE,
|
||||
GROUP,
|
||||
PLAYER
|
||||
}
|
||||
|
||||
String flagname;
|
||||
@@ -36,26 +38,22 @@ public class ResidenceFlagEvent extends ResidenceEvent {
|
||||
FlagState flagstate;
|
||||
String flagtarget;
|
||||
|
||||
public ResidenceFlagEvent(String eventName, ClaimedResidence resref, String flag, FlagType type, String target)
|
||||
{
|
||||
public ResidenceFlagEvent(String eventName, ClaimedResidence resref, String flag, FlagType type, String target) {
|
||||
super(eventName, resref);
|
||||
flagname = flag;
|
||||
flagtype = type;
|
||||
flagtarget = target;
|
||||
}
|
||||
|
||||
public String getFlag()
|
||||
{
|
||||
public String getFlag() {
|
||||
return flagname;
|
||||
}
|
||||
|
||||
public FlagType getFlagType()
|
||||
{
|
||||
public FlagType getFlagType() {
|
||||
return flagtype;
|
||||
}
|
||||
|
||||
public String getFlagTargetPlayerOrGroup()
|
||||
{
|
||||
public String getFlagTargetPlayerOrGroup() {
|
||||
return flagtarget;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
package com.bekvon.bukkit.residence.event;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
@@ -15,6 +16,7 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
public class ResidenceOwnerChangeEvent extends ResidenceEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
@@ -26,14 +28,12 @@ public class ResidenceOwnerChangeEvent extends ResidenceEvent {
|
||||
|
||||
protected String newowner;
|
||||
|
||||
public ResidenceOwnerChangeEvent(ClaimedResidence resref, String newOwner)
|
||||
{
|
||||
super("RESIDENCE_OWNER_CHANGE",resref);
|
||||
public ResidenceOwnerChangeEvent(ClaimedResidence resref, String newOwner) {
|
||||
super("RESIDENCE_OWNER_CHANGE", resref);
|
||||
newowner = newOwner;
|
||||
}
|
||||
|
||||
public String getNewOwner()
|
||||
{
|
||||
public String getNewOwner() {
|
||||
return newowner;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,29 +15,29 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
*/
|
||||
public class ResidencePlayerEvent extends ResidenceEvent implements ResidencePlayerEventInterface {
|
||||
|
||||
Player p;
|
||||
Player p;
|
||||
|
||||
public ResidencePlayerEvent(final String eventName, final ClaimedResidence resref, final Player player) {
|
||||
super(eventName, resref);
|
||||
res = resref;
|
||||
p = player;
|
||||
}
|
||||
public ResidencePlayerEvent(final String eventName, final ClaimedResidence resref, final Player player) {
|
||||
super(eventName, resref);
|
||||
res = resref;
|
||||
p = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return p;
|
||||
}
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAdmin() {
|
||||
if (isPlayer()) {
|
||||
return p.hasPermission("residence.admin") || p.isOp();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isAdmin() {
|
||||
if (isPlayer()) {
|
||||
return p.hasPermission("residence.admin") || p.isOp();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return p != null;
|
||||
}
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return p != null;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user