mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2026-06-17 15:06:15 +00:00
File diff suppressed because it is too large
Load Diff
@@ -23,50 +23,50 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
*/
|
*/
|
||||||
public class ChatChannel {
|
public class ChatChannel {
|
||||||
|
|
||||||
protected List<String> members;
|
protected List<String> members;
|
||||||
protected final String name;
|
protected final String name;
|
||||||
protected final ResidenceMain plugin;
|
protected final ResidenceMain plugin;
|
||||||
protected final PluginManager pm;
|
protected final PluginManager pm;
|
||||||
|
|
||||||
public ChatChannel(final ResidenceMain plugin, final String channelName) {
|
public ChatChannel(final ResidenceMain plugin, final String channelName) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
pm = plugin.getServer().getPluginManager();
|
pm = plugin.getServer().getPluginManager();
|
||||||
name = channelName;
|
name = channelName;
|
||||||
members = new ArrayList<String>();
|
members = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chat(final String sourcePlayer, final String message) {
|
public void chat(final String sourcePlayer, final String message) {
|
||||||
final Server serv = plugin.getServer();
|
final Server serv = plugin.getServer();
|
||||||
final ChatColor color = plugin.getConfigManager().getChatColor();
|
final ChatColor color = plugin.getConfigManager().getChatColor();
|
||||||
final ResidenceChatEvent cevent = new ResidenceChatEvent(plugin.getResidenceManager().getByName(name), serv.getPlayer(sourcePlayer), message, color);
|
final ResidenceChatEvent cevent = new ResidenceChatEvent(plugin.getResidenceManager().getByName(name), serv.getPlayer(sourcePlayer), message, color);
|
||||||
pm.callEvent(cevent);
|
pm.callEvent(cevent);
|
||||||
if (cevent.isCancelled()) {
|
if (cevent.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (final String member : members) {
|
for (final String member : members) {
|
||||||
final Player player = serv.getPlayer(member);
|
final Player player = serv.getPlayer(member);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.sendMessage(cevent.getColor() + sourcePlayer + ": " + cevent.getChatMessage());
|
player.sendMessage(cevent.getColor() + sourcePlayer + ": " + cevent.getChatMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugin.getLogger().info("ResidentialChat[" + name + "] - " + sourcePlayer + ": " + cevent.getChatMessage());
|
plugin.getLogger().info("ResidentialChat[" + name + "] - " + sourcePlayer + ": " + cevent.getChatMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasMember(final String player) {
|
public boolean hasMember(final String player) {
|
||||||
return members.contains(player);
|
return members.contains(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void join(final String player) {
|
public void join(final String player) {
|
||||||
if (!members.contains(player)) {
|
if (!members.contains(player)) {
|
||||||
members.add(player);
|
members.add(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leave(final String player) {
|
public void leave(final String player) {
|
||||||
members.remove(player);
|
members.remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int memberCount() {
|
public int memberCount() {
|
||||||
return members.size();
|
return members.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,36 +16,36 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
*/
|
*/
|
||||||
public class ChatManager {
|
public class ChatManager {
|
||||||
|
|
||||||
protected Map<String, ChatChannel> channelmap;
|
protected Map<String, ChatChannel> channelmap;
|
||||||
protected final ResidenceMain plugin;
|
protected final ResidenceMain plugin;
|
||||||
|
|
||||||
public ChatManager(final ResidenceMain plugin) {
|
public ChatManager(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
channelmap = new HashMap<String, ChatChannel>();
|
channelmap = new HashMap<String, ChatChannel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatChannel getChannel(final String channel) {
|
public ChatChannel getChannel(final String channel) {
|
||||||
return channelmap.get(channel);
|
return channelmap.get(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatChannel getPlayerChannel(final String player) {
|
public ChatChannel getPlayerChannel(final String player) {
|
||||||
for (final ChatChannel chan : channelmap.values())
|
for (final ChatChannel chan : channelmap.values())
|
||||||
if (chan.hasMember(player))
|
if (chan.hasMember(player))
|
||||||
return chan;
|
return chan;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeFromChannel(final String player) {
|
public void removeFromChannel(final String player) {
|
||||||
for (final ChatChannel chan : channelmap.values())
|
for (final ChatChannel chan : channelmap.values())
|
||||||
if (chan.hasMember(player))
|
if (chan.hasMember(player))
|
||||||
chan.leave(player);
|
chan.leave(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChannel(final String player, final String channel) {
|
public void setChannel(final String player, final String channel) {
|
||||||
this.removeFromChannel(player);
|
this.removeFromChannel(player);
|
||||||
if (!channelmap.containsKey(channel))
|
if (!channelmap.containsKey(channel))
|
||||||
channelmap.put(channel, new ChatChannel(plugin, channel));
|
channelmap.put(channel, new ChatChannel(plugin, channel));
|
||||||
channelmap.get(channel).join(player);
|
channelmap.get(channel).join(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,40 +11,40 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.chat.ChatChannel;
|
import cn.citycraft.Residence.chat.ChatChannel;
|
||||||
|
|
||||||
public class CommandRc extends BaseCommand {
|
public class CommandRc extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandRc(final ResidenceMain plugin) {
|
public CommandRc(final ResidenceMain plugin) {
|
||||||
super("rc");
|
super("rc");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final String pname = sender.getName();
|
final String pname = sender.getName();
|
||||||
if (plugin.getConfigManager().chatEnabled()) {
|
if (plugin.getConfigManager().chatEnabled()) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
plugin.getPlayerListener().tooglePlayerResidenceChat((Player) sender);
|
plugin.getPlayerListener().tooglePlayerResidenceChat((Player) sender);
|
||||||
} else {
|
} else {
|
||||||
final String area = plugin.getPlayerListener().getCurrentResidenceName(pname);
|
final String area = plugin.getPlayerListener().getCurrentResidenceName(pname);
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
final ChatChannel channel = plugin.getChatManager().getChannel(area);
|
final ChatChannel channel = plugin.getChatManager().getChannel(area);
|
||||||
if (channel != null) {
|
if (channel != null) {
|
||||||
String message = "";
|
String message = "";
|
||||||
for (final String arg : args) {
|
for (final String arg : args) {
|
||||||
message = message + " " + arg;
|
message = message + " " + arg;
|
||||||
}
|
}
|
||||||
channel.chat(pname, message);
|
channel.chat(pname, message);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidChannel"));
|
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidChannel"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotInResidence"));
|
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotInResidence"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ChatDisabled"));
|
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ChatDisabled"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,115 +54,115 @@ import cn.citycraft.Residence.commandsub.CommandUnStuck;
|
|||||||
import cn.citycraft.Residence.commandsub.CommandVersion;
|
import cn.citycraft.Residence.commandsub.CommandVersion;
|
||||||
|
|
||||||
public class CommandRes extends BaseCommand implements DefaultCommand {
|
public class CommandRes extends BaseCommand implements DefaultCommand {
|
||||||
HandlerSubCommand hdsubcmd;
|
HandlerSubCommand hdsubcmd;
|
||||||
|
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandRes(final ResidenceMain plugin) {
|
public CommandRes(final ResidenceMain plugin) {
|
||||||
super("res", "residence", "resadmin");
|
super("res", "residence", "resadmin");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
hdsubcmd = new HandlerSubCommand(plugin);
|
hdsubcmd = new HandlerSubCommand(plugin);
|
||||||
|
|
||||||
hdsubcmd.registerCommand(new CommandArea(plugin));
|
hdsubcmd.registerCommand(new CommandArea(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandBank(plugin));
|
hdsubcmd.registerCommand(new CommandBank(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandCheck(plugin));
|
hdsubcmd.registerCommand(new CommandCheck(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandCheckSelf(plugin));
|
hdsubcmd.registerCommand(new CommandCheckSelf(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandClearFlags(plugin));
|
hdsubcmd.registerCommand(new CommandClearFlags(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandCompass(plugin));
|
hdsubcmd.registerCommand(new CommandCompass(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandConfirm(plugin));
|
hdsubcmd.registerCommand(new CommandConfirm(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandCreate(plugin));
|
hdsubcmd.registerCommand(new CommandCreate(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandCurrent(plugin));
|
hdsubcmd.registerCommand(new CommandCurrent(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandDefault(plugin));
|
hdsubcmd.registerCommand(new CommandDefault(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandGive(plugin));
|
hdsubcmd.registerCommand(new CommandGive(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandGset(plugin));
|
hdsubcmd.registerCommand(new CommandGset(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandInfo(plugin));
|
hdsubcmd.registerCommand(new CommandInfo(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandKick(plugin));
|
hdsubcmd.registerCommand(new CommandKick(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandLease(plugin));
|
hdsubcmd.registerCommand(new CommandLease(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandLimits(plugin));
|
hdsubcmd.registerCommand(new CommandLimits(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandList(plugin));
|
hdsubcmd.registerCommand(new CommandList(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandListAll(plugin));
|
hdsubcmd.registerCommand(new CommandListAll(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandListAllHidden(plugin));
|
hdsubcmd.registerCommand(new CommandListAllHidden(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandListHidden(plugin));
|
hdsubcmd.registerCommand(new CommandListHidden(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandLists(plugin));
|
hdsubcmd.registerCommand(new CommandLists(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandLset(plugin));
|
hdsubcmd.registerCommand(new CommandLset(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandMarket(plugin));
|
hdsubcmd.registerCommand(new CommandMarket(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandMaterial(plugin));
|
hdsubcmd.registerCommand(new CommandMaterial(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandMessage(plugin));
|
hdsubcmd.registerCommand(new CommandMessage(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandMirror(plugin));
|
hdsubcmd.registerCommand(new CommandMirror(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandPset(plugin));
|
hdsubcmd.registerCommand(new CommandPset(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandRemove(plugin));
|
hdsubcmd.registerCommand(new CommandRemove(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandRemoveAll(plugin));
|
hdsubcmd.registerCommand(new CommandRemoveAll(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandRename(plugin));
|
hdsubcmd.registerCommand(new CommandRename(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandRenameArea(plugin));
|
hdsubcmd.registerCommand(new CommandRenameArea(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandSelect(plugin));
|
hdsubcmd.registerCommand(new CommandSelect(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandServer(plugin));
|
hdsubcmd.registerCommand(new CommandServer(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandSet(plugin));
|
hdsubcmd.registerCommand(new CommandSet(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandSetOwner(plugin));
|
hdsubcmd.registerCommand(new CommandSetOwner(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandSubList(plugin));
|
hdsubcmd.registerCommand(new CommandSubList(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandSubZone(plugin));
|
hdsubcmd.registerCommand(new CommandSubZone(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandTool(plugin));
|
hdsubcmd.registerCommand(new CommandTool(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandTp(plugin));
|
hdsubcmd.registerCommand(new CommandTp(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandTpSet(plugin));
|
hdsubcmd.registerCommand(new CommandTpSet(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandUnStuck(plugin));
|
hdsubcmd.registerCommand(new CommandUnStuck(plugin));
|
||||||
hdsubcmd.registerCommand(new CommandVersion(plugin));
|
hdsubcmd.registerCommand(new CommandVersion(plugin));
|
||||||
|
|
||||||
hdsubcmd.setDefaultCommand(this);
|
hdsubcmd.setDefaultCommand(this);
|
||||||
|
|
||||||
plugin.getCommand("residence").setTabCompleter(hdsubcmd);
|
plugin.getCommand("residence").setTabCompleter(hdsubcmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void defaultExecute(final CommandSender sender, final Command command, final String label) throws CommandException {
|
public void defaultExecute(final CommandSender sender, final Command command, final String label) throws CommandException {
|
||||||
commandHelp(new String[] { "?" }, true, sender);
|
commandHelp(new String[] { "?" }, true, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
boolean resadmin = false;
|
boolean resadmin = false;
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (label.equalsIgnoreCase("resadmin")) {
|
if (label.equalsIgnoreCase("resadmin")) {
|
||||||
if (plugin.getPermissionManager().isResidenceAdmin((Player) sender)) {
|
if (plugin.getPermissionManager().isResidenceAdmin((Player) sender)) {
|
||||||
resadmin = true;
|
resadmin = true;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NonAdmin"));
|
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NonAdmin"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resadmin = true;
|
resadmin = true;
|
||||||
}
|
}
|
||||||
if (args.length > 0 && args[args.length - 1].equalsIgnoreCase("?") || args.length > 1 && args[args.length - 2].equals("?")) {
|
if (args.length > 0 && args[args.length - 1].equalsIgnoreCase("?") || args.length > 1 && args[args.length - 2].equals("?")) {
|
||||||
commandHelp(args, resadmin, sender);
|
commandHelp(args, resadmin, sender);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plugin.getConfigManager().allowAdminsOnly()) {
|
if (plugin.getConfigManager().allowAdminsOnly()) {
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("AdminOnly"));
|
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("AdminOnly"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hdsubcmd.onCommand(sender, resadmin ? command : null, label, args);
|
hdsubcmd.onCommand(sender, resadmin ? command : null, label, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void commandHelp(final String[] args, final boolean resadmin, final CommandSender sender) {
|
private void commandHelp(final String[] args, final boolean resadmin, final CommandSender sender) {
|
||||||
if (plugin.getHelppages() != null) {
|
if (plugin.getHelppages() != null) {
|
||||||
String helppath = "res";
|
String helppath = "res";
|
||||||
for (final String arg : args) {
|
for (final String arg : args) {
|
||||||
if (arg.equalsIgnoreCase("?")) {
|
if (arg.equalsIgnoreCase("?")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
helppath = helppath + "." + arg;
|
helppath = helppath + "." + arg;
|
||||||
}
|
}
|
||||||
int page = 1;
|
int page = 1;
|
||||||
if (!args[args.length - 1].equalsIgnoreCase("?")) {
|
if (!args[args.length - 1].equalsIgnoreCase("?")) {
|
||||||
try {
|
try {
|
||||||
page = Integer.parseInt(args[args.length - 1]);
|
page = Integer.parseInt(args[args.length - 1]);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
|
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plugin.getHelppages().containesEntry(helppath)) {
|
if (plugin.getHelppages().containesEntry(helppath)) {
|
||||||
plugin.getHelppages().printHelp(sender, page, helppath);
|
plugin.getHelppages().printHelp(sender, page, helppath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,26 +13,26 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
|||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class CommandResLoad extends BaseCommand {
|
public class CommandResLoad extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandResLoad(final ResidenceMain plugin) {
|
public CommandResLoad(final ResidenceMain plugin) {
|
||||||
super("resload");
|
super("resload");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
if (!(sender instanceof Player) || plugin.getPermissionManager().isResidenceAdmin((Player) sender)) {
|
if (!(sender instanceof Player) || plugin.getPermissionManager().isResidenceAdmin((Player) sender)) {
|
||||||
try {
|
try {
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
plugin.loadYml();
|
plugin.loadYml();
|
||||||
sender.sendMessage(ChatColor.GREEN + "[Residence] 从配置保存文件重新载入数据...");
|
sender.sendMessage(ChatColor.GREEN + "[Residence] 从配置保存文件重新载入数据...");
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
sender.sendMessage(ChatColor.RED + "[Residence] 无法从配置保存文件重新载入数据, 请查看控制台异常信息!");
|
sender.sendMessage(ChatColor.RED + "[Residence] 无法从配置保存文件重新载入数据, 请查看控制台异常信息!");
|
||||||
sender.sendMessage(ChatColor.RED + "[Residence] 异常: " + ex.getMessage());
|
sender.sendMessage(ChatColor.RED + "[Residence] 异常: " + ex.getMessage());
|
||||||
Logger.getLogger(ResidenceMain.class.getName()).log(Level.SEVERE, null, ex);
|
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;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class CommandResReload extends BaseCommand {
|
public class CommandResReload extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandResReload(final ResidenceMain plugin) {
|
public CommandResReload(final ResidenceMain plugin) {
|
||||||
super("resreload");
|
super("resreload");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
if (plugin.getPermissionManager().isResidenceAdmin(player)) {
|
if (plugin.getPermissionManager().isResidenceAdmin(player)) {
|
||||||
plugin.reloadPlugin();
|
plugin.reloadPlugin();
|
||||||
sender.sendMessage(ChatColor.GREEN + "[Residence] 重载配置文件.");
|
sender.sendMessage(ChatColor.GREEN + "[Residence] 重载配置文件.");
|
||||||
plugin.getLogger().info("重载 by " + player.getName() + ".");
|
plugin.getLogger().info("重载 by " + player.getName() + ".");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
plugin.reloadPlugin();
|
plugin.reloadPlugin();
|
||||||
plugin.getLogger().info("重载 by 控制台.");
|
plugin.getLogger().info("重载 by 控制台.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,24 +10,24 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
|||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class CommandResWorld extends BaseCommand {
|
public class CommandResWorld extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandResWorld(final ResidenceMain plugin) {
|
public CommandResWorld(final ResidenceMain plugin) {
|
||||||
super("resworld");
|
super("resworld");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(2);
|
setMinimumArguments(2);
|
||||||
setPossibleArguments("remove <世界名称>");
|
setPossibleArguments("remove <世界名称>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
if (args[0].equalsIgnoreCase("remove")) {
|
if (args[0].equalsIgnoreCase("remove")) {
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
plugin.getResidenceManager().removeAllFromWorld(sender, args[1]);
|
plugin.getResidenceManager().removeAllFromWorld(sender, args[1]);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + "当前命令必须从控制台执行.");
|
sender.sendMessage(ChatColor.RED + "当前命令必须从控制台执行.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,76 +18,76 @@ import cn.citycraft.Residence.selection.SelectionManager;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandArea extends BaseCommand {
|
public class CommandArea extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandArea(final ResidenceMain plugin) {
|
public CommandArea(final ResidenceMain plugin) {
|
||||||
super("area");
|
super("area");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(3);
|
setMinimumArguments(3);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("<list|listall|add|remove|replace> <领地名称> [区域名称]");
|
setPossibleArguments("<list|listall|add|remove|replace> <领地名称> [区域名称]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
final SelectionManager smanager = plugin.getSelectionManager();
|
final SelectionManager smanager = plugin.getSelectionManager();
|
||||||
final WorldEditPlugin wep = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
final WorldEditPlugin wep = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
int page = 1;
|
int page = 1;
|
||||||
try {
|
try {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
page = Integer.parseInt(args[args.length - 1]);
|
page = Integer.parseInt(args[args.length - 1]);
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} 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) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (wep != null) {
|
if (wep != null) {
|
||||||
if (wep.getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
if (wep.getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
||||||
smanager.worldEdit(player);
|
smanager.worldEdit(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
switch (subcmd) {
|
switch (subcmd) {
|
||||||
case "list":
|
case "list":
|
||||||
res.printAreaList(player, page);
|
res.printAreaList(player, page);
|
||||||
return;
|
return;
|
||||||
case "listall":
|
case "listall":
|
||||||
res.printAdvancedAreaList(player, page);
|
res.printAdvancedAreaList(player, page);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
switch (subcmd) {
|
switch (subcmd) {
|
||||||
case "add":
|
case "add":
|
||||||
if (smanager.hasPlacedBoth(player.getName())) {
|
if (smanager.hasPlacedBoth(player.getName())) {
|
||||||
res.addArea(player, new CuboidArea(smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName())), args[2], resadmin);
|
res.addArea(player, new CuboidArea(smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName())), args[2], resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case "remove":
|
case "remove":
|
||||||
res.removeArea(player, args[2], resadmin);
|
res.removeArea(player, args[2], resadmin);
|
||||||
return;
|
return;
|
||||||
case "replace":
|
case "replace":
|
||||||
if (smanager.hasPlacedBoth(player.getName())) {
|
if (smanager.hasPlacedBoth(player.getName())) {
|
||||||
res.replaceArea(player, new CuboidArea(smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName())), args[2], resadmin);
|
res.replaceArea(player, new CuboidArea(smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName())), args[2], resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,41 +14,41 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandBank extends BaseCommand {
|
public class CommandBank extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandBank(final ResidenceMain plugin) {
|
public CommandBank(final ResidenceMain plugin) {
|
||||||
super("bank");
|
super("bank");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(2);
|
setMinimumArguments(2);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("[deposit(存入)|withdraw(取出)] 金额");
|
setPossibleArguments("[deposit(存入)|withdraw(取出)] 金额");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
final ClaimedResidence res = rmanager.getByName(plugin.getPlayerListener().getCurrentResidenceName(player.getName()));
|
final ClaimedResidence res = rmanager.getByName(plugin.getPlayerListener().getCurrentResidenceName(player.getName()));
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("NotInResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("NotInResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
try {
|
try {
|
||||||
amount = Integer.parseInt(args[1]);
|
amount = Integer.parseInt(args[1]);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidAmount"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidAmount"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String subcmd = args[0];
|
final String subcmd = args[0];
|
||||||
switch (subcmd) {
|
switch (subcmd) {
|
||||||
case "deposit":
|
case "deposit":
|
||||||
res.getBank().deposit(player, amount, resadmin);
|
res.getBank().deposit(player, amount, resadmin);
|
||||||
case "withdraw":
|
case "withdraw":
|
||||||
res.getBank().withdraw(player, amount, resadmin);
|
res.getBank().withdraw(player, amount, resadmin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,41 +14,41 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandCheck extends BaseCommand {
|
public class CommandCheck extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandCheck(final ResidenceMain plugin) {
|
public CommandCheck(final ResidenceMain plugin) {
|
||||||
super("check");
|
super("check");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(2);
|
setMinimumArguments(2);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("<领地名称> <权限> [玩家]");
|
setPossibleArguments("<领地名称> <权限> [玩家]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
String pname = player.getName();
|
String pname = player.getName();
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
if (args.length == 2 || args.length == 3) {
|
if (args.length == 2 || args.length == 3) {
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
pname = args[2];
|
pname = args[2];
|
||||||
}
|
}
|
||||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!res.getPermissions().hasApplicableFlag(pname, args[1])) {
|
if (!res.getPermissions().hasApplicableFlag(pname, args[1])) {
|
||||||
player.sendMessage(language.getPhrase("FlagCheckFalse",
|
player.sendMessage(language.getPhrase("FlagCheckFalse",
|
||||||
ChatColor.YELLOW + args[0] + ChatColor.RED + "." + ChatColor.YELLOW + pname + ChatColor.RED + "." + ChatColor.YELLOW + args[0] + ChatColor.RED));
|
ChatColor.YELLOW + args[0] + ChatColor.RED + "." + ChatColor.YELLOW + pname + ChatColor.RED + "." + ChatColor.YELLOW + args[0] + ChatColor.RED));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(language.getPhrase("FlagCheckTrue",
|
player.sendMessage(language.getPhrase("FlagCheckTrue",
|
||||||
ChatColor.GREEN + args[0] + ChatColor.YELLOW + "." + ChatColor.GREEN + pname + ChatColor.YELLOW + "." + ChatColor.YELLOW + args[0] + ChatColor.RED + "."
|
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")));
|
+ (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;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class CommandCheckSelf extends BaseCommand {
|
public class CommandCheckSelf extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandCheckSelf(final ResidenceMain plugin) {
|
public CommandCheckSelf(final ResidenceMain plugin) {
|
||||||
super("checkself");
|
super("checkself");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("[权限]");
|
setPossibleArguments("[权限]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final FlagPermissions perm = plugin.getPermsByLocForPlayer(player.getLocation(), player);
|
final FlagPermissions perm = plugin.getPermsByLocForPlayer(player.getLocation(), player);
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
player.sendMessage("§e权限列表: ");
|
player.sendMessage("§e权限列表: ");
|
||||||
perm.printFlags(player);
|
perm.printFlags(player);
|
||||||
return;
|
return;
|
||||||
case 1:
|
case 1:
|
||||||
final String flag = args[0];
|
final String flag = args[0];
|
||||||
player.sendMessage("§e权限检查: §a" + flag + " " + (perm.checkValidFlag(flag, false) ? "§atrue" : "§cfalse"));
|
player.sendMessage("§e权限检查: §a" + flag + " " + (perm.checkValidFlag(flag, false) ? "§atrue" : "§cfalse"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,34 +14,34 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandClearFlags extends BaseCommand {
|
public class CommandClearFlags extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandClearFlags(final ResidenceMain plugin) {
|
public CommandClearFlags(final ResidenceMain plugin) {
|
||||||
super("clearflags");
|
super("clearflags");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("<领地名称>");
|
setPossibleArguments("<领地名称>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ClaimedResidence area = rmanager.getByName(args[1]);
|
final ClaimedResidence area = rmanager.getByName(args[1]);
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
area.getPermissions().clearFlags();
|
area.getPermissions().clearFlags();
|
||||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagsCleared"));
|
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagsCleared"));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,40 +14,40 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandCompass extends BaseCommand {
|
public class CommandCompass extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandCompass(final ResidenceMain plugin) {
|
public CommandCompass(final ResidenceMain plugin) {
|
||||||
super("compass", "cp");
|
super("compass", "cp");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setDescription("切换指南针方向");
|
setDescription("切换指南针方向");
|
||||||
setPossibleArguments("[领地名称]");
|
setPossibleArguments("[领地名称]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
player.setCompassTarget(player.getWorld().getSpawnLocation());
|
player.setCompassTarget(player.getWorld().getSpawnLocation());
|
||||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("CompassTargetReset"));
|
player.sendMessage(ChatColor.GREEN + language.getPhrase("CompassTargetReset"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String resname = args[0];
|
final String resname = args[0];
|
||||||
|
|
||||||
if (rmanager.getByName(resname) != null) {
|
if (rmanager.getByName(resname) != null) {
|
||||||
if (rmanager.getByName(resname).getWorld().equalsIgnoreCase(player.getWorld().getName())) {
|
if (rmanager.getByName(resname).getWorld().equalsIgnoreCase(player.getWorld().getName())) {
|
||||||
final Location low = rmanager.getByName(resname).getArea("main").getLowLoc();
|
final Location low = rmanager.getByName(resname).getArea("main").getLowLoc();
|
||||||
final Location high = rmanager.getByName(resname).getArea("main").getHighLoc();
|
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);
|
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.setCompassTarget(mid);
|
||||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("CompassTargetSet", ChatColor.YELLOW + resname + ChatColor.GREEN));
|
player.sendMessage(ChatColor.GREEN + language.getPhrase("CompassTargetSet", ChatColor.YELLOW + resname + ChatColor.GREEN));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,35 +15,35 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandConfirm extends BaseCommand {
|
public class CommandConfirm extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandConfirm(final ResidenceMain plugin) {
|
public CommandConfirm(final ResidenceMain plugin) {
|
||||||
super("confirm");
|
super("confirm");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
Player player = null;
|
Player player = null;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Map<String, String> deleteConfirm = plugin.getDeleteConfirm();
|
final Map<String, String> deleteConfirm = plugin.getDeleteConfirm();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
String name = "Console";
|
String name = "Console";
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
player = (Player) sender;
|
player = (Player) sender;
|
||||||
name = player.getName();
|
name = player.getName();
|
||||||
}
|
}
|
||||||
final String area = deleteConfirm.get(name);
|
final String area = deleteConfirm.get(name);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
sender.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
sender.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
} else {
|
} else {
|
||||||
rmanager.removeResidence(player, area, resadmin);
|
rmanager.removeResidence(player, area, resadmin);
|
||||||
deleteConfirm.remove(name);
|
deleteConfirm.remove(name);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
sender.sendMessage(ChatColor.GREEN + language.getPhrase("ResidenceRemove", ChatColor.YELLOW + name + ChatColor.GREEN));
|
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;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandCreate extends BaseCommand {
|
public class CommandCreate extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandCreate(final ResidenceMain plugin) {
|
public CommandCreate(final ResidenceMain plugin) {
|
||||||
super("create", "new");
|
super("create", "new");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("<领地名称>");
|
setPossibleArguments("<领地名称>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
final SelectionManager smanager = plugin.getSelectionManager();
|
final SelectionManager smanager = plugin.getSelectionManager();
|
||||||
final WorldEditPlugin wep = (WorldEditPlugin) plugin.getServer().getPluginManager().getPlugin("WorldEdit");
|
final WorldEditPlugin wep = (WorldEditPlugin) plugin.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
if (wep != null) {
|
if (wep != null) {
|
||||||
if (wep.getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
if (wep.getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
||||||
smanager.worldEdit(player);
|
smanager.worldEdit(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (smanager.hasPlacedBoth(player.getName())) {
|
if (smanager.hasPlacedBoth(player.getName())) {
|
||||||
rmanager.addResidence(player, args[0], smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName()), resadmin);
|
rmanager.addResidence(player, args[0], smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName()), resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,25 +13,25 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandCurrent extends BaseCommand {
|
public class CommandCurrent extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandCurrent(final ResidenceMain plugin) {
|
public CommandCurrent(final ResidenceMain plugin) {
|
||||||
super("current");
|
super("current");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
final String res = rmanager.getNameByLoc(player.getLocation());
|
final String res = rmanager.getNameByLoc(player.getLocation());
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("NotInResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("NotInResidence"));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("InResidence", ChatColor.YELLOW + res + ChatColor.GREEN));
|
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;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class CommandDefault extends BaseCommand {
|
public class CommandDefault extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandDefault(final ResidenceMain plugin) {
|
public CommandDefault(final ResidenceMain plugin) {
|
||||||
super("default");
|
super("default");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("<领地名称>");
|
setPossibleArguments("<领地名称>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||||
res.getPermissions().applyDefaultFlags(player, resadmin);
|
res.getPermissions().applyDefaultFlags(player, resadmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,23 +11,23 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
|||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class CommandGive extends BaseCommand {
|
public class CommandGive extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandGive(final ResidenceMain plugin) {
|
public CommandGive(final ResidenceMain plugin) {
|
||||||
super("give");
|
super("give");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(2);
|
setMinimumArguments(2);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("<目标玩家> <赠送的领地>");
|
setPossibleArguments("<目标玩家> <赠送的领地>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
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;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandGset extends BaseCommand {
|
public class CommandGset extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandGset(final ResidenceMain plugin) {
|
public CommandGset(final ResidenceMain plugin) {
|
||||||
super("gset");
|
super("gset");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(3);
|
setMinimumArguments(3);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("<领地名称(不写则为所在领地)> <组名称> <权限> <权限状态>");
|
setPossibleArguments("<领地名称(不写则为所在领地)> <组名称> <权限> <权限状态>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
final ClaimedResidence area = rmanager.getByLoc(player.getLocation());
|
final ClaimedResidence area = rmanager.getByLoc(player.getLocation());
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
area.getPermissions().setGroupFlag(player, args[0], args[1], args[2], resadmin);
|
area.getPermissions().setGroupFlag(player, args[0], args[1], args[2], resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidArea"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidArea"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (args.length == 4) {
|
} else if (args.length == 4) {
|
||||||
final ClaimedResidence area = rmanager.getByName(args[0]);
|
final ClaimedResidence area = rmanager.getByName(args[0]);
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
area.getPermissions().setGroupFlag(player, args[1], args[2], args[3], resadmin);
|
area.getPermissions().setGroupFlag(player, args[1], args[2], args[3], resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,33 +13,33 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandInfo extends BaseCommand {
|
public class CommandInfo extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandInfo(final ResidenceMain plugin) {
|
public CommandInfo(final ResidenceMain plugin) {
|
||||||
super("info");
|
super("info");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
|
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
final String area = rmanager.getNameByLoc(player.getLocation());
|
final String area = rmanager.getNameByLoc(player.getLocation());
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
rmanager.printAreaInfo(area, player);
|
rmanager.printAreaInfo(area, player);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
rmanager.printAreaInfo(args[0], player);
|
rmanager.printAreaInfo(args[0], player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,43 +16,43 @@ import cn.citycraft.Residence.permissions.PermissionGroup;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandKick extends BaseCommand {
|
public class CommandKick extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandKick(final ResidenceMain plugin) {
|
public CommandKick(final ResidenceMain plugin) {
|
||||||
super("kick");
|
super("kick");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("<目标玩家>");
|
setPossibleArguments("<目标玩家>");
|
||||||
setDescription("把玩家T出当前领地!");
|
setDescription("把玩家T出当前领地!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||||
|
|
||||||
final Player targetplayer = Bukkit.getPlayer(args[0]);
|
final Player targetplayer = Bukkit.getPlayer(args[0]);
|
||||||
if (targetplayer == null) {
|
if (targetplayer == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!group.hasKickAccess()) {
|
if (!group.hasKickAccess()) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ClaimedResidence res = rmanager.getByLoc(targetplayer.getLocation());
|
final ClaimedResidence res = rmanager.getByLoc(targetplayer.getLocation());
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (res.getOwner().equals(player.getName())) {
|
if (res.getOwner().equals(player.getName())) {
|
||||||
if (res.getPlayersInResidence().contains(targetplayer)) {
|
if (res.getPlayersInResidence().contains(targetplayer)) {
|
||||||
targetplayer.teleport(res.getOutsideFreeLoc(player.getLocation()));
|
targetplayer.teleport(res.getOutsideFreeLoc(player.getLocation()));
|
||||||
targetplayer.sendMessage(ChatColor.RED + language.getPhrase("Kicked") + "!");
|
targetplayer.sendMessage(ChatColor.RED + language.getPhrase("Kicked") + "!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,81 +15,81 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandLease extends BaseCommand {
|
public class CommandLease extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandLease(final ResidenceMain plugin) {
|
public CommandLease(final ResidenceMain plugin) {
|
||||||
super("lease");
|
super("lease");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(2);
|
setMinimumArguments(2);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("[renew/cost] [领地名]");
|
setPossibleArguments("[renew/cost] [领地名]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
final LeaseManager leasemanager = plugin.getLeaseManager();
|
final LeaseManager leasemanager = plugin.getLeaseManager();
|
||||||
|
|
||||||
if (args.length == 1 || args.length == 2) {
|
if (args.length == 1 || args.length == 2) {
|
||||||
if (args[0].equals("renew")) {
|
if (args[0].equals("renew")) {
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
leasemanager.renewArea(args[1], player);
|
leasemanager.renewArea(args[1], player);
|
||||||
} else {
|
} else {
|
||||||
leasemanager.renewArea(rmanager.getNameByLoc(player.getLocation()), player);
|
leasemanager.renewArea(rmanager.getNameByLoc(player.getLocation()), player);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (args[0].equals("cost")) {
|
} else if (args[0].equals("cost")) {
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(args[1]);
|
final ClaimedResidence res = plugin.getResidenceManager().getByName(args[1]);
|
||||||
if (res == null || leasemanager.leaseExpires(args[1])) {
|
if (res == null || leasemanager.leaseExpires(args[1])) {
|
||||||
final int cost = leasemanager.getRenewCost(res);
|
final int cost = leasemanager.getRenewCost(res);
|
||||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("LeaseRenewalCost", ChatColor.RED + args[1] + ChatColor.YELLOW + "." + ChatColor.RED + cost + ChatColor.YELLOW));
|
player.sendMessage(ChatColor.YELLOW + language.getPhrase("LeaseRenewalCost", ChatColor.RED + args[1] + ChatColor.YELLOW + "." + ChatColor.RED + cost + ChatColor.YELLOW));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final String area = rmanager.getNameByLoc(player.getLocation());
|
final String area = rmanager.getNameByLoc(player.getLocation());
|
||||||
final ClaimedResidence res = rmanager.getByName(area);
|
final ClaimedResidence res = rmanager.getByName(area);
|
||||||
if (area == null || res == null) {
|
if (area == null || res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidArea"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidArea"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (leasemanager.leaseExpires(area)) {
|
if (leasemanager.leaseExpires(area)) {
|
||||||
final int cost = leasemanager.getRenewCost(res);
|
final int cost = leasemanager.getRenewCost(res);
|
||||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("LeaseRenewalCost", ChatColor.RED + area + ChatColor.YELLOW + "." + ChatColor.RED + cost + ChatColor.YELLOW));
|
player.sendMessage(ChatColor.YELLOW + language.getPhrase("LeaseRenewalCost", ChatColor.RED + area + ChatColor.YELLOW + "." + ChatColor.RED + cost + ChatColor.YELLOW));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (args.length == 3) {
|
} else if (args.length == 3) {
|
||||||
if (args[0].equals("set")) {
|
if (args[0].equals("set")) {
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args[2].equals("infinite")) {
|
if (args[2].equals("infinite")) {
|
||||||
if (leasemanager.leaseExpires(args[1])) {
|
if (leasemanager.leaseExpires(args[1])) {
|
||||||
leasemanager.removeExpireTime(args[1]);
|
leasemanager.removeExpireTime(args[1]);
|
||||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("LeaseInfinite"));
|
player.sendMessage(ChatColor.GREEN + language.getPhrase("LeaseInfinite"));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("LeaseNotExpire"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int days;
|
int days;
|
||||||
try {
|
try {
|
||||||
days = Integer.parseInt(args[2]);
|
days = Integer.parseInt(args[2]);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidDays"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidDays"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
leasemanager.setExpireTime(player, args[1], days);
|
leasemanager.setExpireTime(player, args[1], days);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,19 +10,19 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.permissions.PermissionManager;
|
import cn.citycraft.Residence.permissions.PermissionManager;
|
||||||
|
|
||||||
public class CommandLimits extends BaseCommand {
|
public class CommandLimits extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandLimits(final ResidenceMain plugin) {
|
public CommandLimits(final ResidenceMain plugin) {
|
||||||
super("limits");
|
super("limits");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final PermissionManager gmanager = plugin.getPermissionManager();
|
final PermissionManager gmanager = plugin.getPermissionManager();
|
||||||
gmanager.getGroup(player).printLimits(player);
|
gmanager.getGroup(player).printLimits(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,41 +11,41 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
|||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class CommandList extends BaseCommand {
|
public class CommandList extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandList(final ResidenceMain plugin) {
|
public CommandList(final ResidenceMain plugin) {
|
||||||
super("list");
|
super("list");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
int page = 1;
|
int page = 1;
|
||||||
try {
|
try {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
page = Integer.parseInt(args[args.length - 1]);
|
page = Integer.parseInt(args[args.length - 1]);
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
}
|
}
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
rmanager.listResidences(player);
|
rmanager.listResidences(player);
|
||||||
return;
|
return;
|
||||||
case 1:
|
case 1:
|
||||||
try {
|
try {
|
||||||
Integer.parseInt(args[0]);
|
Integer.parseInt(args[0]);
|
||||||
rmanager.listResidences(player, page);
|
rmanager.listResidences(player, page);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
rmanager.listResidences(player, args[0]);
|
rmanager.listResidences(player, args[0]);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case 2:
|
case 2:
|
||||||
rmanager.listResidences(player, args[0], page);
|
rmanager.listResidences(player, args[0], page);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,26 +11,26 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
|||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class CommandListAll extends BaseCommand {
|
public class CommandListAll extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandListAll(final ResidenceMain plugin) {
|
public CommandListAll(final ResidenceMain plugin) {
|
||||||
super("listall");
|
super("listall");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
int page = 1;
|
int page = 1;
|
||||||
try {
|
try {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
page = Integer.parseInt(args[args.length - 1]);
|
page = Integer.parseInt(args[args.length - 1]);
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
}
|
}
|
||||||
rmanager.listAllResidences(player, page);
|
rmanager.listAllResidences(player, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,34 +13,34 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandListAllHidden extends BaseCommand {
|
public class CommandListAllHidden extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandListAllHidden(final ResidenceMain plugin) {
|
public CommandListAllHidden(final ResidenceMain plugin) {
|
||||||
super("listallhidden");
|
super("listallhidden");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
int page = 1;
|
int page = 1;
|
||||||
try {
|
try {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
page = Integer.parseInt(args[args.length - 1]);
|
page = Integer.parseInt(args[args.length - 1]);
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rmanager.listAllResidences(player, page, true);
|
rmanager.listAllResidences(player, page, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,42 +13,42 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandListHidden extends BaseCommand {
|
public class CommandListHidden extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandListHidden(final ResidenceMain plugin) {
|
public CommandListHidden(final ResidenceMain plugin) {
|
||||||
super("listhidden");
|
super("listhidden");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
int page = 1;
|
int page = 1;
|
||||||
try {
|
try {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
page = Integer.parseInt(args[args.length - 1]);
|
page = Integer.parseInt(args[args.length - 1]);
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
rmanager.listResidences(player, 1, true);
|
rmanager.listResidences(player, 1, true);
|
||||||
return;
|
return;
|
||||||
case 2:
|
case 2:
|
||||||
rmanager.listResidences(player, args[1], page, true);
|
rmanager.listResidences(player, args[1], page, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,67 +14,67 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandLists extends BaseCommand {
|
public class CommandLists extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandLists(final ResidenceMain plugin) {
|
public CommandLists(final ResidenceMain plugin) {
|
||||||
super("lists");
|
super("lists");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("用法: /res lists ? 查看帮助");
|
setPossibleArguments("用法: /res lists ? 查看帮助");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
final PermissionListManager pmanager = plugin.getPermissionListManager();
|
final PermissionListManager pmanager = plugin.getPermissionListManager();
|
||||||
final String listname = args[1];
|
final String listname = args[1];
|
||||||
|
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case "list":
|
case "list":
|
||||||
pmanager.printLists(player);
|
pmanager.printLists(player);
|
||||||
return;
|
return;
|
||||||
case "add":
|
case "add":
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
pmanager.makeList(player, listname);
|
pmanager.makeList(player, listname);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case "remove":
|
case "remove":
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
pmanager.removeList(player, listname);
|
pmanager.removeList(player, listname);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case "apply":
|
case "apply":
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
pmanager.applyListToResidence(player, listname, args[2], resadmin);
|
pmanager.applyListToResidence(player, listname, args[2], resadmin);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case "set":
|
case "set":
|
||||||
if (args.length == 4) {
|
if (args.length == 4) {
|
||||||
pmanager.getList(player.getName(), listname).setFlag(args[2], FlagPermissions.stringToFlagState(args[3]));
|
pmanager.getList(player.getName(), listname).setFlag(args[2], FlagPermissions.stringToFlagState(args[3]));
|
||||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagSet"));
|
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagSet"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case "pset":
|
case "pset":
|
||||||
if (args.length == 5) {
|
if (args.length == 5) {
|
||||||
pmanager.getList(player.getName(), listname).setGroupFlag(args[2], args[3], FlagPermissions.stringToFlagState(args[4]));
|
pmanager.getList(player.getName(), listname).setGroupFlag(args[2], args[3], FlagPermissions.stringToFlagState(args[4]));
|
||||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagSet"));
|
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagSet"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case "gset":
|
case "gset":
|
||||||
if (args.length == 5) {
|
if (args.length == 5) {
|
||||||
pmanager.getList(player.getName(), listname).setPlayerFlag(args[2], args[3], FlagPermissions.stringToFlagState(args[4]));
|
pmanager.getList(player.getName(), listname).setPlayerFlag(args[2], args[3], FlagPermissions.stringToFlagState(args[4]));
|
||||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagSet"));
|
player.sendMessage(ChatColor.GREEN + language.getPhrase("FlagSet"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case "view":
|
case "view":
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
pmanager.printList(player, listname);
|
pmanager.printList(player, listname);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,60 +15,60 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandLset extends BaseCommand {
|
public class CommandLset extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandLset(final ResidenceMain plugin) {
|
public CommandLset(final ResidenceMain plugin) {
|
||||||
super("lset");
|
super("lset");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(2);
|
setMinimumArguments(2);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("<领地名称> [blacklist(bl)/ignorelist(il)||info] [material]");
|
setPossibleArguments("<领地名称> [blacklist(bl)/ignorelist(il)||info] [material]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||||
|
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Material mat = null;
|
Material mat = null;
|
||||||
|
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
try {
|
try {
|
||||||
mat = Material.valueOf(args[3].toUpperCase());
|
mat = Material.valueOf(args[3].toUpperCase());
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidMaterial"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidMaterial"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final String subcmd = args[1];
|
final String subcmd = args[1];
|
||||||
|
|
||||||
switch (subcmd) {
|
switch (subcmd) {
|
||||||
|
|
||||||
case "info":
|
case "info":
|
||||||
player.sendMessage(ChatColor.RED + "Blacklist:");
|
player.sendMessage(ChatColor.RED + "Blacklist:");
|
||||||
res.getItemBlacklist().printList(player);
|
res.getItemBlacklist().printList(player);
|
||||||
player.sendMessage(ChatColor.GREEN + "Ignorelist:");
|
player.sendMessage(ChatColor.GREEN + "Ignorelist:");
|
||||||
res.getItemIgnoreList().printList(player);
|
res.getItemIgnoreList().printList(player);
|
||||||
return;
|
return;
|
||||||
case "bl":
|
case "bl":
|
||||||
case "blacklist":
|
case "blacklist":
|
||||||
res.getItemBlacklist().playerListChange(player, mat, resadmin);
|
res.getItemBlacklist().playerListChange(player, mat, resadmin);
|
||||||
return;
|
return;
|
||||||
case "il":
|
case "il":
|
||||||
case "ignorelist":
|
case "ignorelist":
|
||||||
res.getItemIgnoreList().playerListChange(player, mat, resadmin);
|
res.getItemIgnoreList().playerListChange(player, mat, resadmin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,207 +18,207 @@ import cn.citycraft.Residence.selection.SelectionManager;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandMarket extends BaseCommand {
|
public class CommandMarket extends BaseCommand {
|
||||||
ConfigManager cmanager;
|
ConfigManager cmanager;
|
||||||
PermissionManager gmanager;
|
PermissionManager gmanager;
|
||||||
Language language;
|
Language language;
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
RentManager rentmanager;
|
RentManager rentmanager;
|
||||||
ResidenceManager rmanager;
|
ResidenceManager rmanager;
|
||||||
SelectionManager smanager;
|
SelectionManager smanager;
|
||||||
TransactionManager tmanager;
|
TransactionManager tmanager;
|
||||||
|
|
||||||
public CommandMarket(final ResidenceMain plugin) {
|
public CommandMarket(final ResidenceMain plugin) {
|
||||||
super("market");
|
super("market");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
rmanager = plugin.getResidenceManager();
|
rmanager = plugin.getResidenceManager();
|
||||||
language = plugin.getLanguage();
|
language = plugin.getLanguage();
|
||||||
smanager = plugin.getSelectionManager();
|
smanager = plugin.getSelectionManager();
|
||||||
gmanager = plugin.getPermissionManager();
|
gmanager = plugin.getPermissionManager();
|
||||||
rentmanager = plugin.getRentManager();
|
rentmanager = plugin.getRentManager();
|
||||||
cmanager = plugin.getConfigManager();
|
cmanager = plugin.getConfigManager();
|
||||||
tmanager = plugin.getTransactionManager();
|
tmanager = plugin.getTransactionManager();
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
int page = 1;
|
int page = 1;
|
||||||
try {
|
try {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
page = Integer.parseInt(args[args.length - 1]);
|
page = Integer.parseInt(args[args.length - 1]);
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
final String cmd = args[0].toLowerCase();
|
final String cmd = args[0].toLowerCase();
|
||||||
if (cmd.equals("list")) {
|
if (cmd.equals("list")) {
|
||||||
commandResMarketList(args, resadmin, player, page);
|
commandResMarketList(args, resadmin, player, page);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cmd.equals("autorenew")) {
|
if (cmd.equals("autorenew")) {
|
||||||
commandResMarketAutorenew(args, resadmin, player, page);
|
commandResMarketAutorenew(args, resadmin, player, page);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cmd.equals("rentable")) {
|
if (cmd.equals("rentable")) {
|
||||||
commandResMarketRentable(args, resadmin, player, page);
|
commandResMarketRentable(args, resadmin, player, page);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cmd.equals("rent")) {
|
if (cmd.equals("rent")) {
|
||||||
commandResMarketRent(args, resadmin, player, page);
|
commandResMarketRent(args, resadmin, player, page);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd.equals("release")) {
|
if (cmd.equals("release")) {
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (rentmanager.isRented(args[1])) {
|
if (rentmanager.isRented(args[1])) {
|
||||||
rentmanager.removeFromForRent(player, args[1], resadmin);
|
rentmanager.removeFromForRent(player, args[1], resadmin);
|
||||||
} else {
|
} else {
|
||||||
rentmanager.unrent(player, args[1], resadmin);
|
rentmanager.unrent(player, args[1], resadmin);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cmd.equals("info")) {
|
if (cmd.equals("info")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
final String areaname = rmanager.getNameByLoc(player.getLocation());
|
final String areaname = rmanager.getNameByLoc(player.getLocation());
|
||||||
tmanager.viewSaleInfo(areaname, player);
|
tmanager.viewSaleInfo(areaname, player);
|
||||||
if (cmanager.enabledRentSystem() && rentmanager.isForRent(areaname)) {
|
if (cmanager.enabledRentSystem() && rentmanager.isForRent(areaname)) {
|
||||||
rentmanager.printRentInfo(player, areaname);
|
rentmanager.printRentInfo(player, areaname);
|
||||||
}
|
}
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
tmanager.viewSaleInfo(args[1], player);
|
tmanager.viewSaleInfo(args[1], player);
|
||||||
if (cmanager.enabledRentSystem() && rentmanager.isForRent(args[1])) {
|
if (cmanager.enabledRentSystem() && rentmanager.isForRent(args[1])) {
|
||||||
rentmanager.printRentInfo(player, args[1]);
|
rentmanager.printRentInfo(player, args[1]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cmd.equals("buy")) {
|
if (cmd.equals("buy")) {
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tmanager.buyPlot(args[1], player, resadmin);
|
tmanager.buyPlot(args[1], player, resadmin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cmd.equals("unsell")) {
|
if (cmd.equals("unsell")) {
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tmanager.removeFromSale(player, args[1], resadmin);
|
tmanager.removeFromSale(player, args[1], resadmin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cmd.equals("sell")) {
|
if (cmd.equals("sell")) {
|
||||||
if (args.length != 3) {
|
if (args.length != 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int amount;
|
int amount;
|
||||||
try {
|
try {
|
||||||
amount = Integer.parseInt(args[2]);
|
amount = Integer.parseInt(args[2]);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidAmount"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidAmount"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tmanager.putForSale(args[1], player, amount, resadmin);
|
tmanager.putForSale(args[1], player, amount, resadmin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean commandResMarketAutorenew(final String[] args, final boolean resadmin, final Player player, final int page) {
|
private boolean commandResMarketAutorenew(final String[] args, final boolean resadmin, final Player player, final int page) {
|
||||||
if (!cmanager.enableEconomy()) {
|
if (!cmanager.enableEconomy()) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("MarketDisabled"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("MarketDisabled"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length != 3) {
|
if (args.length != 3) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean value;
|
boolean value;
|
||||||
if (args[2].equalsIgnoreCase("true") || args[2].equalsIgnoreCase("t")) {
|
if (args[2].equalsIgnoreCase("true") || args[2].equalsIgnoreCase("t")) {
|
||||||
value = true;
|
value = true;
|
||||||
} else if (args[2].equalsIgnoreCase("false") || args[2].equalsIgnoreCase("f")) {
|
} else if (args[2].equalsIgnoreCase("false") || args[2].equalsIgnoreCase("f")) {
|
||||||
value = false;
|
value = false;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidBoolean"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidBoolean"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (rentmanager.isRented(args[1]) && rentmanager.getRentingPlayer(args[1]).equalsIgnoreCase(player.getName())) {
|
if (rentmanager.isRented(args[1]) && rentmanager.getRentingPlayer(args[1]).equalsIgnoreCase(player.getName())) {
|
||||||
rentmanager.setRentedRepeatable(player, args[1], value, resadmin);
|
rentmanager.setRentedRepeatable(player, args[1], value, resadmin);
|
||||||
} else if (rentmanager.isForRent(args[1])) {
|
} else if (rentmanager.isForRent(args[1])) {
|
||||||
rentmanager.setRentRepeatable(player, args[1], value, resadmin);
|
rentmanager.setRentRepeatable(player, args[1], value, resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("RentReleaseInvalid", ChatColor.YELLOW + args[1] + ChatColor.RED));
|
player.sendMessage(ChatColor.RED + language.getPhrase("RentReleaseInvalid", ChatColor.YELLOW + args[1] + ChatColor.RED));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean commandResMarketList(final String[] args, final boolean resadmin, final Player player, final int page) {
|
private boolean commandResMarketList(final String[] args, final boolean resadmin, final Player player, final int page) {
|
||||||
if (!cmanager.enableEconomy()) {
|
if (!cmanager.enableEconomy()) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("MarketDisabled"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("MarketDisabled"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.BLUE + "---" + language.getPhrase("MarketList") + "---");
|
player.sendMessage(ChatColor.BLUE + "---" + language.getPhrase("MarketList") + "---");
|
||||||
tmanager.printForSaleResidences(player);
|
tmanager.printForSaleResidences(player);
|
||||||
if (cmanager.enabledRentSystem()) {
|
if (cmanager.enabledRentSystem()) {
|
||||||
rentmanager.printRentableResidences(player);
|
rentmanager.printRentableResidences(player);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean commandResMarketRent(final String[] args, final boolean resadmin, final Player player, final int page) {
|
private boolean commandResMarketRent(final String[] args, final boolean resadmin, final Player player, final int page) {
|
||||||
if (args.length < 2 || args.length > 3) {
|
if (args.length < 2 || args.length > 3) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean repeat = false;
|
boolean repeat = false;
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
if (args[2].equalsIgnoreCase("t") || args[2].equalsIgnoreCase("true")) {
|
if (args[2].equalsIgnoreCase("t") || args[2].equalsIgnoreCase("true")) {
|
||||||
repeat = true;
|
repeat = true;
|
||||||
} else if (!args[2].equalsIgnoreCase("f") && !args[2].equalsIgnoreCase("false")) {
|
} else if (!args[2].equalsIgnoreCase("f") && !args[2].equalsIgnoreCase("false")) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidBoolean"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidBoolean"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rentmanager.rent(player, args[1], repeat, resadmin);
|
rentmanager.rent(player, args[1], repeat, resadmin);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean commandResMarketRentable(final String[] args, final boolean resadmin, final Player player, final int page) {
|
private boolean commandResMarketRentable(final String[] args, final boolean resadmin, final Player player, final int page) {
|
||||||
if (args.length < 4 || args.length > 5) {
|
if (args.length < 4 || args.length > 5) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!cmanager.enabledRentSystem()) {
|
if (!cmanager.enabledRentSystem()) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("RentDisabled"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("RentDisabled"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int days;
|
int days;
|
||||||
int cost;
|
int cost;
|
||||||
try {
|
try {
|
||||||
cost = Integer.parseInt(args[2]);
|
cost = Integer.parseInt(args[2]);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidCost"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidCost"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
days = Integer.parseInt(args[3]);
|
days = Integer.parseInt(args[3]);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidDays"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidDays"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean repeat = false;
|
boolean repeat = false;
|
||||||
if (args.length == 5) {
|
if (args.length == 5) {
|
||||||
final String state = args[4];
|
final String state = args[4];
|
||||||
if (state.equalsIgnoreCase("t") || state.equalsIgnoreCase("true")) {
|
if (state.equalsIgnoreCase("t") || state.equalsIgnoreCase("true")) {
|
||||||
repeat = true;
|
repeat = true;
|
||||||
} else if (!state.equalsIgnoreCase("f") && !state.equalsIgnoreCase("false")) {
|
} else if (!state.equalsIgnoreCase("f") && !state.equalsIgnoreCase("false")) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidBoolean"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidBoolean"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rentmanager.setForRent(player, args[1], cost, days, repeat, resadmin);
|
rentmanager.setForRent(player, args[1], cost, days, repeat, resadmin);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,28 +12,28 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandMaterial extends BaseCommand {
|
public class CommandMaterial extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandMaterial(final ResidenceMain plugin) {
|
public CommandMaterial(final ResidenceMain plugin) {
|
||||||
super("material");
|
super("material");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
|
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
player.sendMessage(ChatColor.GREEN
|
player.sendMessage(ChatColor.GREEN
|
||||||
+ language.getPhrase("MaterialGet", ChatColor.GOLD + args[0] + ChatColor.GREEN + "." + ChatColor.RED + Material.getMaterial(Integer.parseInt(args[0])).name() + 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) {
|
} catch (final Exception ex) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidMaterial"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidMaterial"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,36 +15,36 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandMessage extends BaseCommand {
|
public class CommandMessage extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandMessage(final ResidenceMain plugin) {
|
public CommandMessage(final ResidenceMain plugin) {
|
||||||
super("message");
|
super("message");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("[enter|leave] [消息(移除则留空)]");
|
setPossibleArguments("[enter|leave] [消息(移除则留空)]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
final ClaimedResidence res = rmanager.getByLoc(player.getLocation());
|
final ClaimedResidence res = rmanager.getByLoc(player.getLocation());
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String message = null;
|
String message = null;
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
message = StringUtil.consolidateStrings(args, 1);
|
message = StringUtil.consolidateStrings(args, 1);
|
||||||
}
|
}
|
||||||
boolean enter = false;
|
boolean enter = false;
|
||||||
if (args[0].equalsIgnoreCase("enter")) {
|
if (args[0].equalsIgnoreCase("enter")) {
|
||||||
enter = true;
|
enter = true;
|
||||||
}
|
}
|
||||||
res.setEnterLeaveMessage(player, message, enter, resadmin);
|
res.setEnterLeaveMessage(player, message, enter, resadmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,21 +11,21 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
|||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class CommandMirror extends BaseCommand {
|
public class CommandMirror extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandMirror(final ResidenceMain plugin) {
|
public CommandMirror(final ResidenceMain plugin) {
|
||||||
super("mirror");
|
super("mirror");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(2);
|
setMinimumArguments(2);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
rmanager.mirrorPerms(player, args[1], args[0], resadmin);
|
rmanager.mirrorPerms(player, args[1], args[0], resadmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,56 +14,56 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandPset extends BaseCommand {
|
public class CommandPset extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandPset(final ResidenceMain plugin) {
|
public CommandPset(final ResidenceMain plugin) {
|
||||||
super("pset");
|
super("pset");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(2);
|
setMinimumArguments(2);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("<residence> [player] [flag|removeall] [true/false/remove]");
|
setPossibleArguments("<residence> [player] [flag|removeall] [true/false/remove]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
if (args.length == 2 && args[1].equalsIgnoreCase("removeall")) {
|
if (args.length == 2 && args[1].equalsIgnoreCase("removeall")) {
|
||||||
final ClaimedResidence area = rmanager.getByLoc(player.getLocation());
|
final ClaimedResidence area = rmanager.getByLoc(player.getLocation());
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
area.getPermissions().removeAllPlayerFlags(player, args[1], resadmin);
|
area.getPermissions().removeAllPlayerFlags(player, args[1], resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (args.length == 3 && args[2].equalsIgnoreCase("removeall")) {
|
} else if (args.length == 3 && args[2].equalsIgnoreCase("removeall")) {
|
||||||
final ClaimedResidence area = rmanager.getByName(args[0]);
|
final ClaimedResidence area = rmanager.getByName(args[0]);
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
area.getPermissions().removeAllPlayerFlags(player, args[2], resadmin);
|
area.getPermissions().removeAllPlayerFlags(player, args[2], resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (args.length == 3) {
|
} else if (args.length == 3) {
|
||||||
final ClaimedResidence area = rmanager.getByLoc(player.getLocation());
|
final ClaimedResidence area = rmanager.getByLoc(player.getLocation());
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
area.getPermissions().setPlayerFlag(player, args[0], args[1], args[2], resadmin);
|
area.getPermissions().setPlayerFlag(player, args[0], args[1], args[2], resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (args.length == 4) {
|
} else if (args.length == 4) {
|
||||||
final ClaimedResidence area = rmanager.getByName(args[0]);
|
final ClaimedResidence area = rmanager.getByName(args[0]);
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
area.getPermissions().setPlayerFlag(player, args[1], args[2], args[3], resadmin);
|
area.getPermissions().setPlayerFlag(player, args[1], args[2], args[3], resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,85 +17,85 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandRemove extends BaseCommand {
|
public class CommandRemove extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandRemove(final ResidenceMain plugin) {
|
public CommandRemove(final ResidenceMain plugin) {
|
||||||
super("remove", "delete");
|
super("remove", "delete");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
Player player = null;
|
Player player = null;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Map<String, String> deleteConfirm = plugin.getDeleteConfirm();
|
final Map<String, String> deleteConfirm = plugin.getDeleteConfirm();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
player = (Player) sender;
|
player = (Player) sender;
|
||||||
final String area = rmanager.getNameByLoc(player.getLocation());
|
final String area = rmanager.getNameByLoc(player.getLocation());
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
final ClaimedResidence res = rmanager.getByName(area);
|
final ClaimedResidence res = rmanager.getByName(area);
|
||||||
if (res.getParent() != null) {
|
if (res.getParent() != null) {
|
||||||
final String[] split = area.split("\\.");
|
final String[] split = area.split("\\.");
|
||||||
final String words = split[split.length - 1];
|
final String words = split[split.length - 1];
|
||||||
if (!deleteConfirm.containsKey(player.getName()) || !area.equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
|
if (!deleteConfirm.containsKey(player.getName()) || !area.equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteSubzoneConfirm", ChatColor.YELLOW + words + ChatColor.RED));
|
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteSubzoneConfirm", ChatColor.YELLOW + words + ChatColor.RED));
|
||||||
deleteConfirm.put(player.getName(), area);
|
deleteConfirm.put(player.getName(), area);
|
||||||
} else {
|
} else {
|
||||||
rmanager.removeResidence(player, area, resadmin);
|
rmanager.removeResidence(player, area, resadmin);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!deleteConfirm.containsKey(player.getName()) || !area.equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
|
if (!deleteConfirm.containsKey(player.getName()) || !area.equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + area + ChatColor.RED));
|
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + area + ChatColor.RED));
|
||||||
deleteConfirm.put(player.getName(), area);
|
deleteConfirm.put(player.getName(), area);
|
||||||
} else {
|
} else {
|
||||||
rmanager.removeResidence(player, area, resadmin);
|
rmanager.removeResidence(player, area, resadmin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
if (!deleteConfirm.containsKey(player.getName()) || !args[0].equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
|
if (!deleteConfirm.containsKey(player.getName()) || !args[0].equalsIgnoreCase(deleteConfirm.get(player.getName()))) {
|
||||||
String words = null;
|
String words = null;
|
||||||
if (rmanager.getByName(args[0]) != null) {
|
if (rmanager.getByName(args[0]) != null) {
|
||||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||||
if (res.getParent() != null) {
|
if (res.getParent() != null) {
|
||||||
final String[] split = args[0].split("\\.");
|
final String[] split = args[0].split("\\.");
|
||||||
words = split[split.length - 1];
|
words = split[split.length - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (words == null) {
|
if (words == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + args[0] + ChatColor.RED));
|
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + args[0] + ChatColor.RED));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteSubzoneConfirm", ChatColor.YELLOW + words + ChatColor.RED));
|
player.sendMessage(ChatColor.RED + language.getPhrase("DeleteSubzoneConfirm", ChatColor.YELLOW + words + ChatColor.RED));
|
||||||
}
|
}
|
||||||
deleteConfirm.put(player.getName(), args[0]);
|
deleteConfirm.put(player.getName(), args[0]);
|
||||||
} else {
|
} else {
|
||||||
rmanager.removeResidence(player, args[0], resadmin);
|
rmanager.removeResidence(player, args[0], resadmin);
|
||||||
}
|
}
|
||||||
} else if (!deleteConfirm.containsKey("Console") || !args[0].equalsIgnoreCase(deleteConfirm.get("Console"))) {
|
} else if (!deleteConfirm.containsKey("Console") || !args[0].equalsIgnoreCase(deleteConfirm.get("Console"))) {
|
||||||
String words = null;
|
String words = null;
|
||||||
if (rmanager.getByName(args[0]) != null) {
|
if (rmanager.getByName(args[0]) != null) {
|
||||||
final ClaimedResidence res = rmanager.getByName(args[1]);
|
final ClaimedResidence res = rmanager.getByName(args[1]);
|
||||||
if (res.getParent() != null) {
|
if (res.getParent() != null) {
|
||||||
final String[] split = args[0].split("\\.");
|
final String[] split = args[0].split("\\.");
|
||||||
words = split[split.length - 1];
|
words = split[split.length - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (words == null) {
|
if (words == null) {
|
||||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + args[0] + ChatColor.RED));
|
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + language.getPhrase("DeleteConfirm", ChatColor.YELLOW + args[0] + ChatColor.RED));
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + language.getPhrase("DeleteSubzoneConfirm", ChatColor.YELLOW + words + ChatColor.RED));
|
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + language.getPhrase("DeleteSubzoneConfirm", ChatColor.YELLOW + words + ChatColor.RED));
|
||||||
}
|
}
|
||||||
deleteConfirm.put("Console", args[0]);
|
deleteConfirm.put("Console", args[0]);
|
||||||
} else {
|
} else {
|
||||||
rmanager.removeResidence(args[0]);
|
rmanager.removeResidence(args[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,29 +13,29 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandRemoveAll extends BaseCommand {
|
public class CommandRemoveAll extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandRemoveAll(final ResidenceMain plugin) {
|
public CommandRemoveAll(final ResidenceMain plugin) {
|
||||||
super("removeall");
|
super("removeall");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
if (resadmin || args[0].endsWith(pname)) {
|
if (resadmin || args[0].endsWith(pname)) {
|
||||||
rmanager.removeAllByOwner(player, args[0]);
|
rmanager.removeAllByOwner(player, args[0]);
|
||||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("RemovePlayersResidences", ChatColor.YELLOW + args[1] + ChatColor.GREEN));
|
player.sendMessage(ChatColor.GREEN + language.getPhrase("RemovePlayersResidences", ChatColor.YELLOW + args[1] + ChatColor.GREEN));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,22 +11,22 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
|||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class CommandRename extends BaseCommand {
|
public class CommandRename extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandRename(final ResidenceMain plugin) {
|
public CommandRename(final ResidenceMain plugin) {
|
||||||
super("rename");
|
super("rename");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(2);
|
setMinimumArguments(2);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
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;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandRenameArea extends BaseCommand {
|
public class CommandRenameArea extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandRenameArea(final ResidenceMain plugin) {
|
public CommandRenameArea(final ResidenceMain plugin) {
|
||||||
super("renamearea");
|
super("renamearea");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(3);
|
setMinimumArguments(3);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res.renameArea(player, args[1], args[2], resadmin);
|
res.renameArea(player, args[1], args[2], resadmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,147 +21,147 @@ import cn.citycraft.Residence.selection.SelectionManager;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandSelect extends BaseCommand {
|
public class CommandSelect extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandSelect(final ResidenceMain plugin) {
|
public CommandSelect(final ResidenceMain plugin) {
|
||||||
super("select");
|
super("select");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPermission("residence.select");
|
setPermission("residence.select");
|
||||||
setPossibleArguments("请使用/res select ? 查看帮助");
|
setPossibleArguments("请使用/res select ? 查看帮助");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||||
final SelectionManager smanager = plugin.getSelectionManager();
|
final SelectionManager smanager = plugin.getSelectionManager();
|
||||||
|
|
||||||
if (!group.selectCommandAccess() && !resadmin) {
|
if (!group.selectCommandAccess() && !resadmin) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectDiabled"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("SelectDiabled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!group.canCreateResidences() && group.getMaxSubzoneDepth() <= 0 && !resadmin) {
|
if (!group.canCreateResidences() && group.getMaxSubzoneDepth() <= 0 && !resadmin) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectDiabled"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("SelectDiabled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String subcmd = args[0];
|
final String subcmd = args[0];
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
switch (subcmd) {
|
switch (subcmd) {
|
||||||
case "size":
|
case "size":
|
||||||
case "cost":
|
case "cost":
|
||||||
if (smanager.hasPlacedBoth(player.getName())) {
|
if (smanager.hasPlacedBoth(player.getName())) {
|
||||||
try {
|
try {
|
||||||
smanager.showSelectionInfo(player);
|
smanager.showSelectionInfo(player);
|
||||||
return;
|
return;
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
Logger.getLogger(ResidenceMain.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(ResidenceMain.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (smanager.worldEdit(player)) {
|
} else if (smanager.worldEdit(player)) {
|
||||||
try {
|
try {
|
||||||
smanager.showSelectionInfo(player);
|
smanager.showSelectionInfo(player);
|
||||||
return;
|
return;
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
Logger.getLogger(ResidenceMain.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(ResidenceMain.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case "vert":
|
case "vert":
|
||||||
smanager.vert(player, resadmin);
|
smanager.vert(player, resadmin);
|
||||||
return;
|
return;
|
||||||
case "sky":
|
case "sky":
|
||||||
smanager.sky(player, resadmin);
|
smanager.sky(player, resadmin);
|
||||||
return;
|
return;
|
||||||
case "bedrock":
|
case "bedrock":
|
||||||
smanager.bedrock(player, resadmin);
|
smanager.bedrock(player, resadmin);
|
||||||
return;
|
return;
|
||||||
case "coords":
|
case "coords":
|
||||||
final Location playerLoc1 = smanager.getPlayerLoc1(player.getName());
|
final Location playerLoc1 = smanager.getPlayerLoc1(player.getName());
|
||||||
if (playerLoc1 != null) {
|
if (playerLoc1 != null) {
|
||||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("Primary.Selection") + ":" + ChatColor.AQUA + " (" + playerLoc1.getBlockX() + ", " + playerLoc1.getBlockY() + ", "
|
player.sendMessage(ChatColor.GREEN + language.getPhrase("Primary.Selection") + ":" + ChatColor.AQUA + " (" + playerLoc1.getBlockX() + ", " + playerLoc1.getBlockY() + ", "
|
||||||
+ playerLoc1.getBlockZ() + ")");
|
+ playerLoc1.getBlockZ() + ")");
|
||||||
}
|
}
|
||||||
final Location playerLoc2 = smanager.getPlayerLoc2(player.getName());
|
final Location playerLoc2 = smanager.getPlayerLoc2(player.getName());
|
||||||
if (playerLoc2 != null) {
|
if (playerLoc2 != null) {
|
||||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("Secondary.Selection") + ":" + ChatColor.AQUA + " (" + playerLoc2.getBlockX() + ", " + playerLoc2.getBlockY() + ", "
|
player.sendMessage(ChatColor.GREEN + language.getPhrase("Secondary.Selection") + ":" + ChatColor.AQUA + " (" + playerLoc2.getBlockX() + ", " + playerLoc2.getBlockY() + ", "
|
||||||
+ playerLoc2.getBlockZ() + ")");
|
+ playerLoc2.getBlockZ() + ")");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case "chunk":
|
case "chunk":
|
||||||
smanager.selectChunk(player);
|
smanager.selectChunk(player);
|
||||||
return;
|
return;
|
||||||
case "worldedit":
|
case "worldedit":
|
||||||
if (smanager.worldEdit(player)) {
|
if (smanager.worldEdit(player)) {
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSuccess"));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSuccess"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case 2:
|
case 2:
|
||||||
int amount;
|
int amount;
|
||||||
try {
|
try {
|
||||||
amount = Integer.parseInt(args[1]);
|
amount = Integer.parseInt(args[1]);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidAmount"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidAmount"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (subcmd) {
|
switch (subcmd) {
|
||||||
case "expand":
|
case "expand":
|
||||||
smanager.modify(player, false, amount);
|
smanager.modify(player, false, amount);
|
||||||
return;
|
return;
|
||||||
case "shift":
|
case "shift":
|
||||||
smanager.modify(player, true, amount);
|
smanager.modify(player, true, amount);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case 3:
|
case 3:
|
||||||
try {
|
try {
|
||||||
smanager.selectBySize(player, Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]));
|
smanager.selectBySize(player, Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]));
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectionFail"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("SelectionFail"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
String resName;
|
String resName;
|
||||||
String areaName;
|
String areaName;
|
||||||
ClaimedResidence res = null;
|
ClaimedResidence res = null;
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
res = rmanager.getByName(args[0]);
|
res = rmanager.getByName(args[0]);
|
||||||
} else {
|
} else {
|
||||||
res = rmanager.getByLoc(player.getLocation());
|
res = rmanager.getByLoc(player.getLocation());
|
||||||
}
|
}
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resName = res.getName();
|
resName = res.getName();
|
||||||
CuboidArea area = null;
|
CuboidArea area = null;
|
||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
area = res.getArea(args[1]);
|
area = res.getArea(args[1]);
|
||||||
areaName = args[1];
|
areaName = args[1];
|
||||||
} else {
|
} else {
|
||||||
areaName = res.getAreaIDbyLoc(player.getLocation());
|
areaName = res.getAreaIDbyLoc(player.getLocation());
|
||||||
area = res.getArea(areaName);
|
area = res.getArea(areaName);
|
||||||
}
|
}
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
smanager.placeLoc1(player, area.getHighLoc());
|
smanager.placeLoc1(player, area.getHighLoc());
|
||||||
smanager.placeLoc2(player, area.getLowLoc());
|
smanager.placeLoc2(player, area.getLowLoc());
|
||||||
player.sendMessage(ChatColor.GREEN + language.getPhrase("SelectionArea", ChatColor.GOLD + areaName + ChatColor.GREEN + "." + ChatColor.GOLD + resName + ChatColor.GREEN));
|
player.sendMessage(ChatColor.GREEN + language.getPhrase("SelectionArea", ChatColor.GOLD + areaName + ChatColor.GREEN + "." + ChatColor.GOLD + resName + ChatColor.GREEN));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("AreaNonExist"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("AreaNonExist"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,34 +14,34 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandServer extends BaseCommand {
|
public class CommandServer extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandServer(final ResidenceMain plugin) {
|
public CommandServer(final ResidenceMain plugin) {
|
||||||
super("server");
|
super("server");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res.getPermissions().setOwner("Server Land", false);
|
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));
|
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;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandSet extends BaseCommand {
|
public class CommandSet extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandSet(final ResidenceMain plugin) {
|
public CommandSet(final ResidenceMain plugin) {
|
||||||
super("set");
|
super("set");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(2);
|
setMinimumArguments(2);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("<residence> [flag] [true/false/remove]");
|
setPossibleArguments("<residence> [flag] [true/false/remove]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
final String res = rmanager.getNameByLoc(player.getLocation());
|
final String res = rmanager.getNameByLoc(player.getLocation());
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
rmanager.getByName(res).getPermissions().setFlag(player, args[0], args[1], resadmin);
|
rmanager.getByName(res).getPermissions().setFlag(player, args[0], args[1], resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
} else if (args.length == 3) {
|
} else if (args.length == 3) {
|
||||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
res.getPermissions().setFlag(player, args[1], args[2], resadmin);
|
res.getPermissions().setFlag(player, args[1], args[2], resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,36 +13,36 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandSetOwner extends BaseCommand {
|
public class CommandSetOwner extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandSetOwner(final ResidenceMain plugin) {
|
public CommandSetOwner(final ResidenceMain plugin) {
|
||||||
super("setowner");
|
super("setowner");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(2);
|
setMinimumArguments(2);
|
||||||
setPossibleArguments("[领地名] [玩家]");
|
setPossibleArguments("[领地名] [玩家]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
sender.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
sender.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||||
}
|
}
|
||||||
final ClaimedResidence area = rmanager.getByName(args[0]);
|
final ClaimedResidence area = rmanager.getByName(args[0]);
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
area.getPermissions().setOwner(args[1], true);
|
area.getPermissions().setOwner(args[1], true);
|
||||||
if (area.getParent() == null) {
|
if (area.getParent() == null) {
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
ChatColor.GREEN + language.getPhrase("ResidenceOwnerChange", ChatColor.YELLOW + " " + args[0] + " " + ChatColor.GREEN + "." + ChatColor.YELLOW + args[1] + ChatColor.GREEN));
|
ChatColor.GREEN + language.getPhrase("ResidenceOwnerChange", ChatColor.YELLOW + " " + args[0] + " " + ChatColor.GREEN + "." + ChatColor.YELLOW + args[1] + ChatColor.GREEN));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.GREEN + language.getPhrase("SubzoneOwnerChange",
|
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));
|
ChatColor.YELLOW + " " + args[0].split("\\.")[args[1].split("\\.").length - 1] + " " + ChatColor.GREEN + "." + ChatColor.YELLOW + args[1] + ChatColor.GREEN));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
sender.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,41 +14,41 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandSubList extends BaseCommand {
|
public class CommandSubList extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandSubList(final ResidenceMain plugin) {
|
public CommandSubList(final ResidenceMain plugin) {
|
||||||
super("sublist");
|
super("sublist");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
int page = 1;
|
int page = 1;
|
||||||
try {
|
try {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
page = Integer.parseInt(args[args.length - 1]);
|
page = Integer.parseInt(args[args.length - 1]);
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
}
|
}
|
||||||
if (args.length == 1 || args.length == 2) {
|
if (args.length == 1 || args.length == 2) {
|
||||||
ClaimedResidence res;
|
ClaimedResidence res;
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
res = rmanager.getByLoc(player.getLocation());
|
res = rmanager.getByLoc(player.getLocation());
|
||||||
} else {
|
} else {
|
||||||
res = rmanager.getByName(args[0]);
|
res = rmanager.getByName(args[0]);
|
||||||
}
|
}
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
res.printSubzoneList(player, page);
|
res.printSubzoneList(player, page);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,51 +17,51 @@ import cn.citycraft.Residence.selection.SelectionManager;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandSubZone extends BaseCommand {
|
public class CommandSubZone extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandSubZone(final ResidenceMain plugin) {
|
public CommandSubZone(final ResidenceMain plugin) {
|
||||||
super("subzone", "sz");
|
super("subzone", "sz");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
setPossibleArguments("<领地名> [附属领地名]");
|
setPossibleArguments("<领地名> [附属领地名]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
final SelectionManager smanager = plugin.getSelectionManager();
|
final SelectionManager smanager = plugin.getSelectionManager();
|
||||||
if (args.length != 2 && args.length != 3) {
|
if (args.length != 2 && args.length != 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String zname;
|
String zname;
|
||||||
String parent;
|
String parent;
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
parent = rmanager.getNameByLoc(player.getLocation());
|
parent = rmanager.getNameByLoc(player.getLocation());
|
||||||
zname = args[0];
|
zname = args[0];
|
||||||
} else {
|
} else {
|
||||||
parent = args[0];
|
parent = args[0];
|
||||||
zname = args[1];
|
zname = args[1];
|
||||||
}
|
}
|
||||||
final WorldEditPlugin wep = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
final WorldEditPlugin wep = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
if (wep != null) {
|
if (wep != null) {
|
||||||
if (wep.getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
if (wep.getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
||||||
smanager.worldEdit(player);
|
smanager.worldEdit(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (smanager.hasPlacedBoth(player.getName())) {
|
if (smanager.hasPlacedBoth(player.getName())) {
|
||||||
final ClaimedResidence res = rmanager.getByName(parent);
|
final ClaimedResidence res = rmanager.getByName(parent);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res.addSubzone(player, smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName()), zname, resadmin);
|
res.addSubzone(player, smanager.getPlayerLoc1(player.getName()), smanager.getPlayerLoc2(player.getName()), zname, resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("SelectPoints"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,23 +13,23 @@ import cn.citycraft.Residence.manager.ConfigManager;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandTool extends BaseCommand {
|
public class CommandTool extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandTool(final ResidenceMain plugin) {
|
public CommandTool(final ResidenceMain plugin) {
|
||||||
super("tool");
|
super("tool");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
final ConfigManager cmanager = plugin.getConfigManager();
|
final ConfigManager cmanager = plugin.getConfigManager();
|
||||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("SelectionTool") + ":" + ChatColor.GREEN + Material.getMaterial(cmanager.getSelectionTooldID()));
|
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()));
|
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;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandTp extends BaseCommand {
|
public class CommandTp extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandTp(final ResidenceMain plugin) {
|
public CommandTp(final ResidenceMain plugin) {
|
||||||
super("tp");
|
super("tp");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setMinimumArguments(1);
|
setMinimumArguments(1);
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
final ClaimedResidence res = rmanager.getByName(args[0]);
|
final ClaimedResidence res = rmanager.getByName(args[0]);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res.tpToResidence(player, player, resadmin);
|
res.tpToResidence(player, player, resadmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,28 +14,28 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandTpSet extends BaseCommand {
|
public class CommandTpSet extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandTpSet(final ResidenceMain plugin) {
|
public CommandTpSet(final ResidenceMain plugin) {
|
||||||
super("tpset");
|
super("tpset");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
|
|
||||||
final boolean resadmin = (command != null);
|
final boolean resadmin = (command != null);
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
|
|
||||||
final ClaimedResidence res = rmanager.getByLoc(player.getLocation());
|
final ClaimedResidence res = rmanager.getByLoc(player.getLocation());
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
res.setTpLoc(player, resadmin);
|
res.setTpLoc(player, resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,33 +16,33 @@ import cn.citycraft.Residence.permissions.PermissionManager;
|
|||||||
import cn.citycraft.Residence.text.Language;
|
import cn.citycraft.Residence.text.Language;
|
||||||
|
|
||||||
public class CommandUnStuck extends BaseCommand {
|
public class CommandUnStuck extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandUnStuck(final ResidenceMain plugin) {
|
public CommandUnStuck(final ResidenceMain plugin) {
|
||||||
super("unstuck");
|
super("unstuck");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setOnlyPlayerExecutable();
|
setOnlyPlayerExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final ResidenceManager rmanager = plugin.getResidenceManager();
|
final ResidenceManager rmanager = plugin.getResidenceManager();
|
||||||
final Language language = plugin.getLanguage();
|
final Language language = plugin.getLanguage();
|
||||||
final PermissionManager gmanager = plugin.getPermissionManager();
|
final PermissionManager gmanager = plugin.getPermissionManager();
|
||||||
final PermissionGroup group = gmanager.getGroup(player);
|
final PermissionGroup group = gmanager.getGroup(player);
|
||||||
|
|
||||||
if (!group.hasUnstuckAccess()) {
|
if (!group.hasUnstuckAccess()) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ClaimedResidence res = rmanager.getByLoc(player.getLocation());
|
final ClaimedResidence res = rmanager.getByLoc(player.getLocation());
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + language.getPhrase("NotInResidence"));
|
player.sendMessage(ChatColor.RED + language.getPhrase("NotInResidence"));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + language.getPhrase("Moved") + "...");
|
player.sendMessage(ChatColor.YELLOW + language.getPhrase("Moved") + "...");
|
||||||
player.teleport(res.getOutsideFreeLoc(player.getLocation()));
|
player.teleport(res.getOutsideFreeLoc(player.getLocation()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,33 +11,33 @@ import cn.citycraft.PluginHelper.commands.BaseCommand;
|
|||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class CommandVersion extends BaseCommand {
|
public class CommandVersion extends BaseCommand {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public CommandVersion(ResidenceMain plugin) {
|
public CommandVersion(ResidenceMain plugin) {
|
||||||
super("version");
|
super("version");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
|
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
|
||||||
sender.sendMessage(ChatColor.GRAY + "------------------------------------");
|
sender.sendMessage(ChatColor.GRAY + "------------------------------------");
|
||||||
sender.sendMessage(ChatColor.RED + "当前服务器运行的 " + ChatColor.GOLD + "Residence" + ChatColor.RED + " 版本: " + ChatColor.BLUE + plugin.getDescription().getVersion());
|
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 + "创建者: " + ChatColor.YELLOW + "bekvon");
|
||||||
sender.sendMessage(ChatColor.GREEN + "升级到 1.8 by: " + ChatColor.YELLOW + "DartCZ");
|
sender.sendMessage(ChatColor.GREEN + "升级到 1.8 by: " + ChatColor.YELLOW + "DartCZ");
|
||||||
sender.sendMessage(ChatColor.RED + "升级到最新无UUID版本 by: " + ChatColor.YELLOW + "喵♂呜");
|
sender.sendMessage(ChatColor.RED + "升级到最新无UUID版本 by: " + ChatColor.YELLOW + "喵♂呜");
|
||||||
String names = null;
|
String names = null;
|
||||||
List<String> authlist = plugin.getDescription().getAuthors();
|
List<String> authlist = plugin.getDescription().getAuthors();
|
||||||
for (String auth : authlist)
|
for (String auth : authlist)
|
||||||
if (names == null)
|
if (names == null)
|
||||||
names = auth;
|
names = auth;
|
||||||
else
|
else
|
||||||
names = names + ", " + auth;
|
names = names + ", " + auth;
|
||||||
sender.sendMessage(ChatColor.GREEN + "作者: " + ChatColor.YELLOW + names);
|
sender.sendMessage(ChatColor.GREEN + "作者: " + ChatColor.YELLOW + names);
|
||||||
sender.sendMessage(ChatColor.DARK_AQUA + "插件命令列表,帮助, 请查看wiki:");
|
sender.sendMessage(ChatColor.DARK_AQUA + "插件命令列表,帮助, 请查看wiki:");
|
||||||
sender.sendMessage(ChatColor.GREEN + "http://residencebukkitmod.wikispaces.com/");
|
sender.sendMessage(ChatColor.GREEN + "http://residencebukkitmod.wikispaces.com/");
|
||||||
sender.sendMessage(ChatColor.AQUA + "重制版本请查看Jenkins:");
|
sender.sendMessage(ChatColor.AQUA + "重制版本请查看Jenkins:");
|
||||||
sender.sendMessage(ChatColor.BLUE + plugin.getDescription().getWebsite());
|
sender.sendMessage(ChatColor.BLUE + plugin.getDescription().getWebsite());
|
||||||
sender.sendMessage(ChatColor.GRAY + "------------------------------------");
|
sender.sendMessage(ChatColor.GRAY + "------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,14 @@ package cn.citycraft.Residence.economy;
|
|||||||
|
|
||||||
public interface EconomyInterface {
|
public interface EconomyInterface {
|
||||||
public double getBalance(String playerName);
|
public double getBalance(String playerName);
|
||||||
|
|
||||||
public boolean canAfford(String playerName, double amount);
|
public boolean canAfford(String playerName, double amount);
|
||||||
|
|
||||||
public boolean add(String playerName, double amount);
|
public boolean add(String playerName, double amount);
|
||||||
|
|
||||||
public boolean subtract(String playerName, double amount);
|
public boolean subtract(String playerName, double amount);
|
||||||
|
|
||||||
public boolean transfer(String playerFrom, String playerTo, double amount);
|
public boolean transfer(String playerFrom, String playerTo, double amount);
|
||||||
|
|
||||||
public String getName();
|
public String getName();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,90 +16,90 @@ import com.earth2me.essentials.api.UserDoesNotExistException;
|
|||||||
*/
|
*/
|
||||||
public class EssentialsEcoAdapter implements EconomyInterface {
|
public class EssentialsEcoAdapter implements EconomyInterface {
|
||||||
|
|
||||||
Essentials plugin;
|
Essentials plugin;
|
||||||
|
|
||||||
public EssentialsEcoAdapter(final Essentials p) {
|
public EssentialsEcoAdapter(final Essentials p) {
|
||||||
plugin = p;
|
plugin = p;
|
||||||
final String serverland = "Server Land";
|
final String serverland = "Server Land";
|
||||||
if (!Economy.playerExists(serverland)) {
|
if (!Economy.playerExists(serverland)) {
|
||||||
Economy.createNPC(serverland);
|
Economy.createNPC(serverland);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean add(final String playerName, final double amount) {
|
public boolean add(final String playerName, final double amount) {
|
||||||
if (Economy.playerExists(playerName)) {
|
if (Economy.playerExists(playerName)) {
|
||||||
try {
|
try {
|
||||||
Economy.add(playerName, amount);
|
Economy.add(playerName, amount);
|
||||||
return true;
|
return true;
|
||||||
} catch (final UserDoesNotExistException ex) {
|
} catch (final UserDoesNotExistException ex) {
|
||||||
return false;
|
return false;
|
||||||
} catch (final NoLoanPermittedException ex) {
|
} catch (final NoLoanPermittedException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAfford(final String playerName, final double amount) {
|
public boolean canAfford(final String playerName, final double amount) {
|
||||||
try {
|
try {
|
||||||
if (Economy.playerExists(playerName)) {
|
if (Economy.playerExists(playerName)) {
|
||||||
return Economy.hasEnough(playerName, amount);
|
return Economy.hasEnough(playerName, amount);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} catch (final UserDoesNotExistException ex) {
|
} catch (final UserDoesNotExistException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBalance(final String playerName) {
|
public double getBalance(final String playerName) {
|
||||||
try {
|
try {
|
||||||
if (Economy.playerExists(playerName)) {
|
if (Economy.playerExists(playerName)) {
|
||||||
return Economy.getMoney(playerName);
|
return Economy.getMoney(playerName);
|
||||||
}
|
}
|
||||||
} catch (final UserDoesNotExistException ex) {
|
} catch (final UserDoesNotExistException ex) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "EssentialsEconomy";
|
return "EssentialsEconomy";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean subtract(final String playerName, final double amount) {
|
public boolean subtract(final String playerName, final double amount) {
|
||||||
if (Economy.playerExists(playerName)) {
|
if (Economy.playerExists(playerName)) {
|
||||||
try {
|
try {
|
||||||
Economy.subtract(playerName, amount);
|
Economy.subtract(playerName, amount);
|
||||||
return true;
|
return true;
|
||||||
} catch (final UserDoesNotExistException ex) {
|
} catch (final UserDoesNotExistException ex) {
|
||||||
return false;
|
return false;
|
||||||
} catch (final NoLoanPermittedException ex) {
|
} catch (final NoLoanPermittedException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean transfer(final String playerFrom, final String playerTo, final double amount) {
|
public boolean transfer(final String playerFrom, final String playerTo, final double amount) {
|
||||||
try {
|
try {
|
||||||
if (Economy.playerExists(playerFrom) && Economy.playerExists(playerTo) && Economy.hasEnough(playerFrom, amount)) {
|
if (Economy.playerExists(playerFrom) && Economy.playerExists(playerTo) && Economy.hasEnough(playerFrom, amount)) {
|
||||||
if (!subtract(playerFrom, amount))
|
if (!subtract(playerFrom, amount))
|
||||||
return false;
|
return false;
|
||||||
if (!add(playerTo, amount)) {
|
if (!add(playerTo, amount)) {
|
||||||
add(playerFrom, amount);
|
add(playerFrom, amount);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (final UserDoesNotExistException ex) {
|
} catch (final UserDoesNotExistException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,75 +17,75 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class ResidenceBank {
|
public class ResidenceBank {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
ClaimedResidence res;
|
ClaimedResidence res;
|
||||||
int storedMoney;
|
int storedMoney;
|
||||||
|
|
||||||
public ResidenceBank(final ResidenceMain plugin, final ClaimedResidence parent) {
|
public ResidenceBank(final ResidenceMain plugin, final ClaimedResidence parent) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
storedMoney = 0;
|
storedMoney = 0;
|
||||||
res = parent;
|
res = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(final int amount) {
|
public void add(final int amount) {
|
||||||
storedMoney = storedMoney + amount;
|
storedMoney = storedMoney + amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deposit(final Player player, final int amount, final boolean resadmin) {
|
public void deposit(final Player player, final int amount, final boolean resadmin) {
|
||||||
if (!plugin.getConfigManager().enableEconomy()) {
|
if (!plugin.getConfigManager().enableEconomy()) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||||
}
|
}
|
||||||
if (!resadmin && !res.getPermissions().playerHas(player.getName(), "bank", false)) {
|
if (!resadmin && !res.getPermissions().playerHas(player.getName(), "bank", false)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoBankAccess"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoBankAccess"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!plugin.getEconomyManager().canAfford(player.getName(), amount)) {
|
if (!plugin.getEconomyManager().canAfford(player.getName(), amount)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plugin.getEconomyManager().subtract(player.getName(), amount)) {
|
if (plugin.getEconomyManager().subtract(player.getName(), amount)) {
|
||||||
this.add(amount);
|
this.add(amount);
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("BankDeposit", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("BankDeposit", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStoredMoney() {
|
public int getStoredMoney() {
|
||||||
return storedMoney;
|
return storedMoney;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasEnough(final int amount) {
|
public boolean hasEnough(final int amount) {
|
||||||
if (storedMoney >= amount) {
|
if (storedMoney >= amount) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStoredMoney(final int amount) {
|
public void setStoredMoney(final int amount) {
|
||||||
storedMoney = amount;
|
storedMoney = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void subtract(final int amount) {
|
public void subtract(final int amount) {
|
||||||
storedMoney = storedMoney - amount;
|
storedMoney = storedMoney - amount;
|
||||||
if (storedMoney < 0) {
|
if (storedMoney < 0) {
|
||||||
storedMoney = 0;
|
storedMoney = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void withdraw(final Player player, final int amount, final boolean resadmin) {
|
public void withdraw(final Player player, final int amount, final boolean resadmin) {
|
||||||
if (!plugin.getConfigManager().enableEconomy()) {
|
if (!plugin.getConfigManager().enableEconomy()) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||||
}
|
}
|
||||||
if (!resadmin && !res.getPermissions().playerHas(player.getName(), "bank", false)) {
|
if (!resadmin && !res.getPermissions().playerHas(player.getName(), "bank", false)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoBankAccess"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoBankAccess"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!hasEnough(amount)) {
|
if (!hasEnough(amount)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("BankNoMoney"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("BankNoMoney"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plugin.getEconomyManager().add(player.getName(), amount)) {
|
if (plugin.getEconomyManager().add(player.getName(), amount)) {
|
||||||
this.subtract(amount);
|
this.subtract(amount);
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("BankWithdraw", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN));
|
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
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class TransactionManager {
|
public class TransactionManager {
|
||||||
private Map<String, Integer> sellAmount;
|
private Map<String, Integer> sellAmount;
|
||||||
PermissionManager gmanager;
|
PermissionManager gmanager;
|
||||||
ResidenceManager manager;
|
ResidenceManager manager;
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public TransactionManager(final ResidenceMain plugin, final ResidenceManager m, final PermissionManager g) {
|
public TransactionManager(final ResidenceMain plugin, final ResidenceManager m, final PermissionManager g) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
gmanager = g;
|
gmanager = g;
|
||||||
manager = m;
|
manager = m;
|
||||||
sellAmount = Collections.synchronizedMap(new HashMap<String, Integer>());
|
sellAmount = Collections.synchronizedMap(new HashMap<String, Integer>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean chargeEconomyMoney(final ResidenceMain plugin, final Player player, final int amount) {
|
public static boolean chargeEconomyMoney(final ResidenceMain plugin, final Player player, final int amount) {
|
||||||
final EconomyInterface econ = plugin.getEconomyManager();
|
final EconomyInterface econ = plugin.getEconomyManager();
|
||||||
if (econ == null) {
|
if (econ == null) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!econ.canAfford(player.getName(), amount)) {
|
if (!econ.canAfford(player.getName(), amount)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
econ.subtract(player.getName(), amount);
|
econ.subtract(player.getName(), amount);
|
||||||
player.sendMessage(ChatColor.GREEN
|
player.sendMessage(ChatColor.GREEN
|
||||||
+ plugin.getLanguage().getPhrase("MoneyCharged", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN + "." + ChatColor.YELLOW + econ.getName() + ChatColor.GREEN));
|
+ plugin.getLanguage().getPhrase("MoneyCharged", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN + "." + ChatColor.YELLOW + econ.getName() + ChatColor.GREEN));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public static TransactionManager load(final ResidenceMain plugin, final Map root, final PermissionManager p, final ResidenceManager r) {
|
public static TransactionManager load(final ResidenceMain plugin, final Map root, final PermissionManager p, final ResidenceManager r) {
|
||||||
final TransactionManager tman = new TransactionManager(plugin, r, p);
|
final TransactionManager tman = new TransactionManager(plugin, r, p);
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
tman.sellAmount = root;
|
tman.sellAmount = root;
|
||||||
}
|
}
|
||||||
return tman;
|
return tman;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buyPlot(final String areaname, final Player player, final boolean resadmin) {
|
public void buyPlot(final String areaname, final Player player, final boolean resadmin) {
|
||||||
final PermissionGroup group = gmanager.getGroup(player);
|
final PermissionGroup group = gmanager.getGroup(player);
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
if (!plugin.getConfigManager().enableEconomy() || plugin.getEconomyManager() == null) {
|
if (!plugin.getConfigManager().enableEconomy() || plugin.getEconomyManager() == null) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final boolean canbuy = group.canBuyLand() || player.hasPermission("plugin.buy");
|
final boolean canbuy = group.canBuyLand() || player.hasPermission("plugin.buy");
|
||||||
if (!canbuy && !resadmin) {
|
if (!canbuy && !resadmin) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isForSale(areaname)) {
|
if (isForSale(areaname)) {
|
||||||
final ClaimedResidence res = manager.getByName(areaname);
|
final ClaimedResidence res = manager.getByName(areaname);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidArea"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidArea"));
|
||||||
sellAmount.remove(areaname);
|
sellAmount.remove(areaname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (res.getPermissions().getOwner().equals(player.getName())) {
|
if (res.getPermissions().getOwner().equals(player.getName())) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("OwnerBuyFail"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("OwnerBuyFail"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plugin.getResidenceManager().getOwnedZoneCount(player.getName()) >= group.getMaxZones() && !resadmin) {
|
if (plugin.getResidenceManager().getOwnedZoneCount(player.getName()) >= group.getMaxZones() && !resadmin) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceTooMany"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceTooMany"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int amount = sellAmount.get(areaname);
|
final int amount = sellAmount.get(areaname);
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
if (!group.buyLandIgnoreLimits()) {
|
if (!group.buyLandIgnoreLimits()) {
|
||||||
final CuboidArea[] areas = res.getAreaArray();
|
final CuboidArea[] areas = res.getAreaArray();
|
||||||
for (final CuboidArea thisarea : areas) {
|
for (final CuboidArea thisarea : areas) {
|
||||||
if (!group.inLimits(thisarea)) {
|
if (!group.inLimits(thisarea)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceBuyTooBig"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceBuyTooBig"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final EconomyInterface econ = plugin.getEconomyManager();
|
final EconomyInterface econ = plugin.getEconomyManager();
|
||||||
if (econ == null) {
|
if (econ == null) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String buyerName = player.getName();
|
final String buyerName = player.getName();
|
||||||
String sellerName = res.getPermissions().getOwner();
|
String sellerName = res.getPermissions().getOwner();
|
||||||
final Player sellerNameFix = plugin.getServer().getPlayer(sellerName);
|
final Player sellerNameFix = plugin.getServer().getPlayer(sellerName);
|
||||||
if (sellerNameFix != null) {
|
if (sellerNameFix != null) {
|
||||||
sellerName = sellerNameFix.getName();
|
sellerName = sellerNameFix.getName();
|
||||||
}
|
}
|
||||||
if (econ.canAfford(buyerName, amount)) {
|
if (econ.canAfford(buyerName, amount)) {
|
||||||
if (!econ.transfer(buyerName, sellerName, amount)) {
|
if (!econ.transfer(buyerName, sellerName, amount)) {
|
||||||
player.sendMessage(ChatColor.RED + "Error, could not transfer " + amount + " from " + buyerName + " to " + sellerName);
|
player.sendMessage(ChatColor.RED + "Error, could not transfer " + amount + " from " + buyerName + " to " + sellerName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res.getPermissions().setOwner(player.getName(), true);
|
res.getPermissions().setOwner(player.getName(), true);
|
||||||
res.getPermissions().applyDefaultFlags();
|
res.getPermissions().applyDefaultFlags();
|
||||||
this.removeFromSale(areaname);
|
this.removeFromSale(areaname);
|
||||||
player.sendMessage(ChatColor.GREEN
|
player.sendMessage(ChatColor.GREEN
|
||||||
+ plugin.getLanguage().getPhrase("MoneyCharged", ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN + "." + ChatColor.YELLOW + econ.getName() + 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));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceBought", ChatColor.GREEN + areaname + ChatColor.YELLOW));
|
||||||
final Player seller = plugin.getServer().getPlayer(sellerName);
|
final Player seller = plugin.getServer().getPlayer(sellerName);
|
||||||
if (seller != null && seller.isOnline()) {
|
if (seller != null && seller.isOnline()) {
|
||||||
seller.sendMessage(ChatColor.GREEN
|
seller.sendMessage(ChatColor.GREEN
|
||||||
+ plugin.getLanguage().getPhrase("ResidenceBuy", ChatColor.YELLOW + player.getName() + ChatColor.GREEN + "." + ChatColor.YELLOW + areaname + 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",
|
seller.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("MoneyCredit",
|
||||||
ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN + "." + ChatColor.YELLOW + econ.getName() + ChatColor.GREEN));
|
ChatColor.YELLOW + String.format("%d", amount) + ChatColor.GREEN + "." + ChatColor.YELLOW + econ.getName() + ChatColor.GREEN));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearSales() {
|
public void clearSales() {
|
||||||
sellAmount.clear();
|
sellAmount.clear();
|
||||||
System.out.println("[Residence] - ReInit land selling.");
|
System.out.println("[Residence] - ReInit land selling.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSaleAmount(final String name) {
|
public int getSaleAmount(final String name) {
|
||||||
return sellAmount.get(name);
|
return sellAmount.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isForSale(final String areaname) {
|
public boolean isForSale(final String areaname) {
|
||||||
return sellAmount.containsKey(areaname);
|
return sellAmount.containsKey(areaname);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printForSaleResidences(final Player player) {
|
public void printForSaleResidences(final Player player) {
|
||||||
final Set<Entry<String, Integer>> set = sellAmount.entrySet();
|
final Set<Entry<String, Integer>> set = sellAmount.entrySet();
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("LandForSale") + ":");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("LandForSale") + ":");
|
||||||
final StringBuilder sbuild = new StringBuilder();
|
final StringBuilder sbuild = new StringBuilder();
|
||||||
sbuild.append(ChatColor.GREEN);
|
sbuild.append(ChatColor.GREEN);
|
||||||
boolean firstadd = true;
|
boolean firstadd = true;
|
||||||
for (final Entry<String, Integer> land : set) {
|
for (final Entry<String, Integer> land : set) {
|
||||||
if (!firstadd) {
|
if (!firstadd) {
|
||||||
sbuild.append(", ");
|
sbuild.append(", ");
|
||||||
} else {
|
} else {
|
||||||
firstadd = false;
|
firstadd = false;
|
||||||
}
|
}
|
||||||
sbuild.append(land.getKey());
|
sbuild.append(land.getKey());
|
||||||
}
|
}
|
||||||
player.sendMessage(sbuild.toString());
|
player.sendMessage(sbuild.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean putForSale(final String areaname, final int amount) {
|
public boolean putForSale(final String areaname, final int amount) {
|
||||||
if (plugin.getConfigManager().enabledRentSystem()) {
|
if (plugin.getConfigManager().enabledRentSystem()) {
|
||||||
if (plugin.getRentManager().isForRent(areaname)) {
|
if (plugin.getRentManager().isForRent(areaname)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final ClaimedResidence area = manager.getByName(areaname);
|
final ClaimedResidence area = manager.getByName(areaname);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (sellAmount.containsKey(areaname)) {
|
if (sellAmount.containsKey(areaname)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sellAmount.put(areaname, amount);
|
sellAmount.put(areaname, amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void putForSale(final String areaname, final Player player, final int amount, final boolean resadmin) {
|
public void putForSale(final String areaname, final Player player, final int amount, final boolean resadmin) {
|
||||||
if (plugin.getConfigManager().enabledRentSystem()) {
|
if (plugin.getConfigManager().enabledRentSystem()) {
|
||||||
if (plugin.getRentManager().isForRent(areaname)) {
|
if (plugin.getRentManager().isForRent(areaname)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentSellFail"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentSellFail"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
if (!plugin.getConfigManager().enableEconomy() || plugin.getEconomyManager() == null) {
|
if (!plugin.getConfigManager().enableEconomy() || plugin.getEconomyManager() == null) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final boolean cansell = plugin.getPermissionManager().getGroup(player).canSellLand() || player.hasPermission("plugin.sell");
|
final boolean cansell = plugin.getPermissionManager().getGroup(player).canSellLand() || player.hasPermission("plugin.sell");
|
||||||
if (!cansell && !resadmin) {
|
if (!cansell && !resadmin) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (amount <= 0) {
|
if (amount <= 0) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidAmount"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidAmount"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
final ClaimedResidence area = manager.getByName(areaname);
|
final ClaimedResidence area = manager.getByName(areaname);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!area.getPermissions().getOwner().equals(pname) && !resadmin) {
|
if (!area.getPermissions().getOwner().equals(pname) && !resadmin) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sellAmount.containsKey(areaname)) {
|
if (sellAmount.containsKey(areaname)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("AlreadySellFail"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("AlreadySellFail"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sellAmount.put(areaname, amount);
|
sellAmount.put(areaname, amount);
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceForSale", ChatColor.YELLOW + areaname + ChatColor.GREEN + "." + ChatColor.YELLOW + amount + ChatColor.GREEN));
|
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) {
|
public void removeFromSale(final Player player, final String areaname, final boolean resadmin) {
|
||||||
final ClaimedResidence area = manager.getByName(areaname);
|
final ClaimedResidence area = manager.getByName(areaname);
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
if (!isForSale(areaname)) {
|
if (!isForSale(areaname)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForSale"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForSale"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (area.getPermissions().getOwner().equals(player.getName()) || resadmin) {
|
if (area.getPermissions().getOwner().equals(player.getName()) || resadmin) {
|
||||||
removeFromSale(areaname);
|
removeFromSale(areaname);
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceStopSelling"));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceStopSelling"));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidArea"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidArea"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeFromSale(final String areaname) {
|
public void removeFromSale(final String areaname) {
|
||||||
sellAmount.remove(areaname);
|
sellAmount.remove(areaname);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Integer> save() {
|
public Map<String, Integer> save() {
|
||||||
return sellAmount;
|
return sellAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void viewSaleInfo(final String areaname, final Player player) {
|
public void viewSaleInfo(final String areaname, final Player player) {
|
||||||
if (sellAmount.containsKey(areaname)) {
|
if (sellAmount.containsKey(areaname)) {
|
||||||
player.sendMessage("------------------------");
|
player.sendMessage("------------------------");
|
||||||
player.sendMessage(ChatColor.YELLOW + "Name:" + ChatColor.DARK_GREEN + " " + areaname);
|
player.sendMessage(ChatColor.YELLOW + "Name:" + ChatColor.DARK_GREEN + " " + areaname);
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("SellAmount") + ":" + ChatColor.RED + " " + sellAmount.get(areaname));
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("SellAmount") + ":" + ChatColor.RED + " " + sellAmount.get(areaname));
|
||||||
if (plugin.getConfigManager().useLeases()) {
|
if (plugin.getConfigManager().useLeases()) {
|
||||||
final Date etime = plugin.getLeaseManager().getExpireTime(areaname);
|
final Date etime = plugin.getLeaseManager().getExpireTime(areaname);
|
||||||
if (etime != null) {
|
if (etime != null) {
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("LeaseExpire") + ":" + ChatColor.GREEN + " " + etime.toString());
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("LeaseExpire") + ":" + ChatColor.GREEN + " " + etime.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.sendMessage("------------------------");
|
player.sendMessage("------------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,411 +29,411 @@ import cn.citycraft.Residence.permissions.PermissionGroup;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class RentManager {
|
public class RentManager {
|
||||||
protected ResidenceMain plugin;
|
protected ResidenceMain plugin;
|
||||||
protected PluginManager pm;
|
protected PluginManager pm;
|
||||||
protected Map<String, RentableLand> rentableLand;
|
protected Map<String, RentableLand> rentableLand;
|
||||||
protected Map<String, RentedLand> rentedLand;
|
protected Map<String, RentedLand> rentedLand;
|
||||||
|
|
||||||
public RentManager(final ResidenceMain plugin) {
|
public RentManager(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
pm = plugin.getServer().getPluginManager();
|
pm = plugin.getServer().getPluginManager();
|
||||||
rentedLand = new HashMap<String, RentedLand>();
|
rentedLand = new HashMap<String, RentedLand>();
|
||||||
rentableLand = new HashMap<String, RentableLand>();
|
rentableLand = new HashMap<String, RentableLand>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static RentManager load(final ResidenceMain plugin, final Map<String, Object> root) {
|
public static RentManager load(final ResidenceMain plugin, final Map<String, Object> root) {
|
||||||
final RentManager rentManager = new RentManager(plugin);
|
final RentManager rentManager = new RentManager(plugin);
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
final Map<String, Object> rentables = (Map<String, Object>) root.get("Rentables");
|
final Map<String, Object> rentables = (Map<String, Object>) root.get("Rentables");
|
||||||
for (final Entry<String, Object> rent : rentables.entrySet()) {
|
for (final Entry<String, Object> rent : rentables.entrySet()) {
|
||||||
rentManager.rentableLand.put(rent.getKey(), RentableLand.load((Map<String, Object>) rent.getValue()));
|
rentManager.rentableLand.put(rent.getKey(), RentableLand.load((Map<String, Object>) rent.getValue()));
|
||||||
}
|
}
|
||||||
final Map<String, Object> rented = (Map<String, Object>) root.get("Rented");
|
final Map<String, Object> rented = (Map<String, Object>) root.get("Rented");
|
||||||
for (final Entry<String, Object> rent : rented.entrySet()) {
|
for (final Entry<String, Object> rent : rented.entrySet()) {
|
||||||
rentManager.rentedLand.put(rent.getKey(), RentedLand.load((Map<String, Object>) rent.getValue()));
|
rentManager.rentedLand.put(rent.getKey(), RentedLand.load((Map<String, Object>) rent.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rentManager;
|
return rentManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkCurrentRents() {
|
public void checkCurrentRents() {
|
||||||
final Iterator<Entry<String, RentedLand>> it = rentedLand.entrySet().iterator();
|
final Iterator<Entry<String, RentedLand>> it = rentedLand.entrySet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
final Entry<String, RentedLand> next = it.next();
|
final Entry<String, RentedLand> next = it.next();
|
||||||
final RentedLand land = next.getValue();
|
final RentedLand land = next.getValue();
|
||||||
if (land.endTime <= System.currentTimeMillis()) {
|
if (land.endTime <= System.currentTimeMillis()) {
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(next.getKey());
|
final ClaimedResidence res = plugin.getResidenceManager().getByName(next.getKey());
|
||||||
if (plugin.getConfigManager().debugEnabled()) {
|
if (plugin.getConfigManager().debugEnabled()) {
|
||||||
System.out.println("Rent Check: " + next.getKey());
|
System.out.println("Rent Check: " + next.getKey());
|
||||||
}
|
}
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
final ResidenceRentEvent revent = new ResidenceRentEvent(res, null, RentEventType.RENT_EXPIRE);
|
final ResidenceRentEvent revent = new ResidenceRentEvent(res, null, RentEventType.RENT_EXPIRE);
|
||||||
pm.callEvent(revent);
|
pm.callEvent(revent);
|
||||||
if (!revent.isCancelled()) {
|
if (!revent.isCancelled()) {
|
||||||
final RentableLand rentable = rentableLand.get(next.getKey());
|
final RentableLand rentable = rentableLand.get(next.getKey());
|
||||||
if (!rentable.repeatable) {
|
if (!rentable.repeatable) {
|
||||||
rentableLand.remove(next.getKey());
|
rentableLand.remove(next.getKey());
|
||||||
it.remove();
|
it.remove();
|
||||||
res.getPermissions().applyDefaultFlags();
|
res.getPermissions().applyDefaultFlags();
|
||||||
} else if (land.autoRefresh) {
|
} else if (land.autoRefresh) {
|
||||||
if (!plugin.getEconomyManager().canAfford(land.player, rentable.cost)) {
|
if (!plugin.getEconomyManager().canAfford(land.player, rentable.cost)) {
|
||||||
it.remove();
|
it.remove();
|
||||||
res.getPermissions().applyDefaultFlags();
|
res.getPermissions().applyDefaultFlags();
|
||||||
} else if (!plugin.getEconomyManager().transfer(land.player, res.getPermissions().getOwner(), rentable.cost)) {
|
} else if (!plugin.getEconomyManager().transfer(land.player, res.getPermissions().getOwner(), rentable.cost)) {
|
||||||
it.remove();
|
it.remove();
|
||||||
res.getPermissions().applyDefaultFlags();
|
res.getPermissions().applyDefaultFlags();
|
||||||
} else {
|
} else {
|
||||||
land.endTime = System.currentTimeMillis() + this.daysToMs(rentable.days);
|
land.endTime = System.currentTimeMillis() + this.daysToMs(rentable.days);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res.getPermissions().applyDefaultFlags();
|
res.getPermissions().applyDefaultFlags();
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rentableLand.remove(next.getKey());
|
rentableLand.remove(next.getKey());
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCostOfRent(final String landName) {
|
public int getCostOfRent(final String landName) {
|
||||||
return rentableLand.containsKey(landName) ? rentableLand.get(landName).cost : 0;
|
return rentableLand.containsKey(landName) ? rentableLand.get(landName).cost : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRentableCount(final String player) {
|
public int getRentableCount(final String player) {
|
||||||
final Set<String> set = rentableLand.keySet();
|
final Set<String> set = rentableLand.keySet();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (final String land : set) {
|
for (final String land : set) {
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(land);
|
final ClaimedResidence res = plugin.getResidenceManager().getByName(land);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (res.getPermissions().getOwner().equalsIgnoreCase(player)) {
|
if (res.getPermissions().getOwner().equalsIgnoreCase(player)) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getRentableRepeatable(final String landName) {
|
public boolean getRentableRepeatable(final String landName) {
|
||||||
return rentableLand.containsKey(landName) ? rentableLand.get(landName).repeatable : false;
|
return rentableLand.containsKey(landName) ? rentableLand.get(landName).repeatable : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRentCount(final String player) {
|
public int getRentCount(final String player) {
|
||||||
final Set<Entry<String, RentedLand>> set = rentedLand.entrySet();
|
final Set<Entry<String, RentedLand>> set = rentedLand.entrySet();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (final Entry<String, RentedLand> land : set) {
|
for (final Entry<String, RentedLand> land : set) {
|
||||||
if (land.getValue().player.equalsIgnoreCase(player)) {
|
if (land.getValue().player.equalsIgnoreCase(player)) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRentDays(final String landName) {
|
public int getRentDays(final String landName) {
|
||||||
return rentableLand.containsKey(landName) ? rentableLand.get(landName).days : 0;
|
return rentableLand.containsKey(landName) ? rentableLand.get(landName).days : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getRentedAutoRepeats(final String landName) {
|
public boolean getRentedAutoRepeats(final String landName) {
|
||||||
return getRentableRepeatable(landName) ? (rentedLand.containsKey(landName) ? rentedLand.get(landName).autoRefresh : false) : false;
|
return getRentableRepeatable(landName) ? (rentedLand.containsKey(landName) ? rentedLand.get(landName).autoRefresh : false) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRentingPlayer(final String landName) {
|
public String getRentingPlayer(final String landName) {
|
||||||
return rentedLand.containsKey(landName) ? rentedLand.get(landName).player : null;
|
return rentedLand.containsKey(landName) ? rentedLand.get(landName).player : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isForRent(final String landName) {
|
public boolean isForRent(final String landName) {
|
||||||
return rentableLand.containsKey(landName);
|
return rentableLand.containsKey(landName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRented(final String landName) {
|
public boolean isRented(final String landName) {
|
||||||
return rentedLand.containsKey(landName);
|
return rentedLand.containsKey(landName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printRentableResidences(final Player player) {
|
public void printRentableResidences(final Player player) {
|
||||||
final Set<Entry<String, RentableLand>> set = rentableLand.entrySet();
|
final Set<Entry<String, RentableLand>> set = rentableLand.entrySet();
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("RentableLand") + ":");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("RentableLand") + ":");
|
||||||
final StringBuilder sbuild = new StringBuilder();
|
final StringBuilder sbuild = new StringBuilder();
|
||||||
sbuild.append(ChatColor.GREEN);
|
sbuild.append(ChatColor.GREEN);
|
||||||
boolean firstadd = true;
|
boolean firstadd = true;
|
||||||
for (final Entry<String, RentableLand> land : set) {
|
for (final Entry<String, RentableLand> land : set) {
|
||||||
if (!this.isRented(land.getKey())) {
|
if (!this.isRented(land.getKey())) {
|
||||||
if (!firstadd) {
|
if (!firstadd) {
|
||||||
sbuild.append(", ");
|
sbuild.append(", ");
|
||||||
} else {
|
} else {
|
||||||
firstadd = false;
|
firstadd = false;
|
||||||
}
|
}
|
||||||
sbuild.append(land.getKey());
|
sbuild.append(land.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.sendMessage(sbuild.toString());
|
player.sendMessage(sbuild.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printRentInfo(final Player player, final String landName) {
|
public void printRentInfo(final Player player, final String landName) {
|
||||||
final RentableLand rentable = rentableLand.get(landName);
|
final RentableLand rentable = rentableLand.get(landName);
|
||||||
final RentedLand rented = rentedLand.get(landName);
|
final RentedLand rented = rentedLand.get(landName);
|
||||||
if (rentable != null) {
|
if (rentable != null) {
|
||||||
player.sendMessage(ChatColor.GOLD + plugin.getLanguage().getPhrase("Land") + ":" + ChatColor.DARK_GREEN + landName);
|
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.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);
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("RentableAutoRenew") + ":" + ChatColor.DARK_AQUA + rentable.repeatable);
|
||||||
if (rented != null) {
|
if (rented != null) {
|
||||||
player.sendMessage(ChatColor.GOLD + plugin.getLanguage().getPhrase("Status") + ":" + ChatColor.YELLOW + " "
|
player.sendMessage(ChatColor.GOLD + plugin.getLanguage().getPhrase("Status") + ":" + ChatColor.YELLOW + " "
|
||||||
+ plugin.getLanguage().getPhrase("ResidenceRentedBy", ChatColor.RED + rented.player + 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.YELLOW + plugin.getLanguage().getPhrase("RentExpire") + ":" + ChatColor.GREEN + new Date(rented.endTime));
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("RentAutoRenew") + ":" + ChatColor.DARK_AQUA + rented.autoRefresh);
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("RentAutoRenew") + ":" + ChatColor.DARK_AQUA + rented.autoRefresh);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.GOLD + plugin.getLanguage().getPhrase("Status") + ":" + ChatColor.GREEN + " " + plugin.getLanguage().getPhrase("Available"));
|
player.sendMessage(ChatColor.GOLD + plugin.getLanguage().getPhrase("Status") + ":" + ChatColor.GREEN + " " + plugin.getLanguage().getPhrase("Available"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForRent"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForRent"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeFromForRent(final Player player, final String landName, final boolean resadmin) {
|
public void removeFromForRent(final Player player, final String landName, final boolean resadmin) {
|
||||||
final RentedLand rent = rentedLand.get(landName);
|
final RentedLand rent = rentedLand.get(landName);
|
||||||
if (rent == null) {
|
if (rent == null) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotRented"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotRented"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (resadmin || rent.player.equalsIgnoreCase(player.getName())) {
|
if (resadmin || rent.player.equalsIgnoreCase(player.getName())) {
|
||||||
final ResidenceRentEvent revent = new ResidenceRentEvent(plugin.getResidenceManager().getByName(landName), player, RentEventType.UNRENTABLE);
|
final ResidenceRentEvent revent = new ResidenceRentEvent(plugin.getResidenceManager().getByName(landName), player, RentEventType.UNRENTABLE);
|
||||||
pm.callEvent(revent);
|
pm.callEvent(revent);
|
||||||
if (revent.isCancelled()) {
|
if (revent.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rentedLand.remove(landName);
|
rentedLand.remove(landName);
|
||||||
if (!rentableLand.get(landName).repeatable) {
|
if (!rentableLand.get(landName).repeatable) {
|
||||||
rentableLand.remove(landName);
|
rentableLand.remove(landName);
|
||||||
}
|
}
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
res.getPermissions().applyDefaultFlags();
|
res.getPermissions().applyDefaultFlags();
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceUnrent", ChatColor.YELLOW + landName + ChatColor.GREEN));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceUnrent", ChatColor.YELLOW + landName + ChatColor.GREEN));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeFromRent(final String landName) {
|
public void removeFromRent(final String landName) {
|
||||||
rentedLand.remove(landName);
|
rentedLand.remove(landName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeRentable(final String landName) {
|
public void removeRentable(final String landName) {
|
||||||
removeFromRent(landName);
|
removeFromRent(landName);
|
||||||
rentableLand.remove(landName);
|
rentableLand.remove(landName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rent(final Player player, final String landName, final boolean repeat, final boolean resadmin) {
|
public void rent(final Player player, final String landName, final boolean repeat, final boolean resadmin) {
|
||||||
if (!plugin.getConfigManager().enabledRentSystem()) {
|
if (!plugin.getConfigManager().enabledRentSystem()) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentDisabled"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentDisabled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (res.getPermissions().getOwner().equalsIgnoreCase(player.getName())) {
|
if (res.getPermissions().getOwner().equalsIgnoreCase(player.getName())) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("OwnerRentFail"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("OwnerRentFail"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||||
if (!resadmin && this.getRentCount(player.getName()) >= group.getMaxRents()) {
|
if (!resadmin && this.getRentCount(player.getName()) >= group.getMaxRents()) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMaxRent"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMaxRent"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.isForRent(landName)) {
|
if (!this.isForRent(landName)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForRent"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForRent"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.isRented(landName)) {
|
if (this.isRented(landName)) {
|
||||||
final String[] split = landName.split("\\.");
|
final String[] split = landName.split("\\.");
|
||||||
if (split.length != 0) {
|
if (split.length != 0) {
|
||||||
player.sendMessage(plugin.getLanguage().getPhrase("ResidenceAlreadyRented",
|
player.sendMessage(plugin.getLanguage().getPhrase("ResidenceAlreadyRented",
|
||||||
ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED + "." + ChatColor.YELLOW + this.getRentingPlayer(landName)));
|
ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED + "." + ChatColor.YELLOW + this.getRentingPlayer(landName)));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final RentableLand land = rentableLand.get(landName);
|
final RentableLand land = rentableLand.get(landName);
|
||||||
if (plugin.getEconomyManager().canAfford(player.getName(), land.cost)) {
|
if (plugin.getEconomyManager().canAfford(player.getName(), land.cost)) {
|
||||||
final ResidenceRentEvent revent = new ResidenceRentEvent(res, player, RentEventType.RENT);
|
final ResidenceRentEvent revent = new ResidenceRentEvent(res, player, RentEventType.RENT);
|
||||||
pm.callEvent(revent);
|
pm.callEvent(revent);
|
||||||
if (revent.isCancelled()) {
|
if (revent.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plugin.getEconomyManager().transfer(player.getName(), res.getPermissions().getOwner(), land.cost)) {
|
if (plugin.getEconomyManager().transfer(player.getName(), res.getPermissions().getOwner(), land.cost)) {
|
||||||
final RentedLand newrent = new RentedLand();
|
final RentedLand newrent = new RentedLand();
|
||||||
newrent.player = player.getName();
|
newrent.player = player.getName();
|
||||||
newrent.startTime = System.currentTimeMillis();
|
newrent.startTime = System.currentTimeMillis();
|
||||||
newrent.endTime = System.currentTimeMillis() + daysToMs(land.days);
|
newrent.endTime = System.currentTimeMillis() + daysToMs(land.days);
|
||||||
newrent.autoRefresh = repeat;
|
newrent.autoRefresh = repeat;
|
||||||
rentedLand.put(landName, newrent);
|
rentedLand.put(landName, newrent);
|
||||||
res.getPermissions().copyUserPermissions(res.getPermissions().getOwner(), player.getName());
|
res.getPermissions().copyUserPermissions(res.getPermissions().getOwner(), player.getName());
|
||||||
res.getPermissions().clearPlayersFlags(res.getPermissions().getOwner());
|
res.getPermissions().clearPlayersFlags(res.getPermissions().getOwner());
|
||||||
res.getPermissions().setPlayerFlag(player.getName(), "admin", FlagState.TRUE);
|
res.getPermissions().setPlayerFlag(player.getName(), "admin", FlagState.TRUE);
|
||||||
final String[] split = landName.split("\\.");
|
final String[] split = landName.split("\\.");
|
||||||
if (split.length != 0) {
|
if (split.length != 0) {
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceRentSuccess",
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceRentSuccess",
|
||||||
ChatColor.YELLOW + split[split.length - 1] + ChatColor.GREEN + "." + ChatColor.YELLOW + land.days + ChatColor.GREEN));
|
ChatColor.YELLOW + split[split.length - 1] + ChatColor.GREEN + "." + ChatColor.YELLOW + land.days + ChatColor.GREEN));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + "Error, unable to transfer money...");
|
player.sendMessage(ChatColor.RED + "Error, unable to transfer money...");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NotEnoughMoney"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> save() {
|
public Map<String, Object> save() {
|
||||||
final Map<String, Object> root = new HashMap<String, Object>();
|
final Map<String, Object> root = new HashMap<String, Object>();
|
||||||
final Map<String, Object> rentables = new HashMap<String, Object>();
|
final Map<String, Object> rentables = new HashMap<String, Object>();
|
||||||
for (final Entry<String, RentableLand> rent : rentableLand.entrySet()) {
|
for (final Entry<String, RentableLand> rent : rentableLand.entrySet()) {
|
||||||
rentables.put(rent.getKey(), rent.getValue().save());
|
rentables.put(rent.getKey(), rent.getValue().save());
|
||||||
}
|
}
|
||||||
final Map<String, Object> rented = new HashMap<String, Object>();
|
final Map<String, Object> rented = new HashMap<String, Object>();
|
||||||
for (final Entry<String, RentedLand> rent : rentedLand.entrySet()) {
|
for (final Entry<String, RentedLand> rent : rentedLand.entrySet()) {
|
||||||
rented.put(rent.getKey(), rent.getValue().save());
|
rented.put(rent.getKey(), rent.getValue().save());
|
||||||
}
|
}
|
||||||
root.put("Rentables", rentables);
|
root.put("Rentables", rentables);
|
||||||
root.put("Rented", rented);
|
root.put("Rented", rented);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setForRent(final Player player, final String landName, final int amount, final int days, final boolean repeatable, final boolean resadmin) {
|
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()) {
|
if (!plugin.getConfigManager().enabledRentSystem()) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("MarketDisabled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plugin.getTransactionManager().isForSale(landName)) {
|
if (plugin.getTransactionManager().isForSale(landName)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SellRentFail"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SellRentFail"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
if (!res.getPermissions().hasResidencePermission(player, true)) {
|
if (!res.getPermissions().hasResidencePermission(player, true)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||||
if (this.getRentableCount(player.getName()) >= group.getMaxRentables()) {
|
if (this.getRentableCount(player.getName()) >= group.getMaxRentables()) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMaxRent"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMaxRent"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!rentableLand.containsKey(landName)) {
|
if (!rentableLand.containsKey(landName)) {
|
||||||
final ResidenceRentEvent revent = new ResidenceRentEvent(res, player, RentEventType.RENTABLE);
|
final ResidenceRentEvent revent = new ResidenceRentEvent(res, player, RentEventType.RENTABLE);
|
||||||
pm.callEvent(revent);
|
pm.callEvent(revent);
|
||||||
if (revent.isCancelled()) {
|
if (revent.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final RentableLand newrent = new RentableLand();
|
final RentableLand newrent = new RentableLand();
|
||||||
newrent.days = days;
|
newrent.days = days;
|
||||||
newrent.cost = amount;
|
newrent.cost = amount;
|
||||||
newrent.repeatable = repeatable;
|
newrent.repeatable = repeatable;
|
||||||
rentableLand.put(landName, newrent);
|
rentableLand.put(landName, newrent);
|
||||||
final String[] split = landName.split("\\.");
|
final String[] split = landName.split("\\.");
|
||||||
if (split.length != 0) {
|
if (split.length != 0) {
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("ResidenceForRentSuccess",
|
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));
|
ChatColor.YELLOW + split[split.length - 1] + ChatColor.GREEN + "." + ChatColor.YELLOW + amount + ChatColor.GREEN + "." + ChatColor.YELLOW + days + ChatColor.GREEN));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceAlreadyRent"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceAlreadyRent"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRentedRepeatable(final Player player, final String landName, final boolean value, final boolean resadmin) {
|
public void setRentedRepeatable(final Player player, final String landName, final boolean value, final boolean resadmin) {
|
||||||
final String[] split = landName.split("\\.");
|
final String[] split = landName.split("\\.");
|
||||||
final RentedLand land = rentedLand.get(landName);
|
final RentedLand land = rentedLand.get(landName);
|
||||||
if (land != null && (land.player.equals(player.getName()) || resadmin)) {
|
if (land != null && (land.player.equals(player.getName()) || resadmin)) {
|
||||||
land.autoRefresh = value;
|
land.autoRefresh = value;
|
||||||
if (value && split.length != 0) {
|
if (value && split.length != 0) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentEnableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentEnableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
||||||
} else if (split.length != 0) {
|
} else if (split.length != 0) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentDisableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
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) {
|
public void setRentRepeatable(final Player player, final String landName, final boolean value, final boolean resadmin) {
|
||||||
final String[] split = landName.split("\\.");
|
final String[] split = landName.split("\\.");
|
||||||
final RentableLand land = rentableLand.get(landName);
|
final RentableLand land = rentableLand.get(landName);
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||||
if (land != null && res != null && (res.getPermissions().getOwner().equalsIgnoreCase(player.getName()) || resadmin)) {
|
if (land != null && res != null && (res.getPermissions().getOwner().equalsIgnoreCase(player.getName()) || resadmin)) {
|
||||||
land.repeatable = value;
|
land.repeatable = value;
|
||||||
if (!value && this.isRented(landName)) {
|
if (!value && this.isRented(landName)) {
|
||||||
rentedLand.get(landName).autoRefresh = false;
|
rentedLand.get(landName).autoRefresh = false;
|
||||||
}
|
}
|
||||||
if (value && split.length != 0) {
|
if (value && split.length != 0) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentableEnableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentableEnableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
||||||
} else if (split.length != 0) {
|
} else if (split.length != 0) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentableDisableRenew", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
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) {
|
public void unrent(final Player player, final String landName, final boolean resadmin) {
|
||||||
final String[] split = landName.split("\\.");
|
final String[] split = landName.split("\\.");
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
final ClaimedResidence res = plugin.getResidenceManager().getByName(landName);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("InvalidResidence"));
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("InvalidResidence"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!res.getPermissions().hasResidencePermission(player, true) && !resadmin) {
|
if (!res.getPermissions().hasResidencePermission(player, true) && !resadmin) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (rentedLand.containsKey(landName) && !resadmin) {
|
if (rentedLand.containsKey(landName) && !resadmin) {
|
||||||
if (split.length != 0) {
|
if (split.length != 0) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceAlreadyRented",
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceAlreadyRented",
|
||||||
ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED + "." + ChatColor.YELLOW + rentedLand.get(landName).player) + ChatColor.YELLOW);
|
ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED + "." + ChatColor.YELLOW + rentedLand.get(landName).player) + ChatColor.YELLOW);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (rentableLand.containsKey(landName)) {
|
if (rentableLand.containsKey(landName)) {
|
||||||
final ResidenceRentEvent revent = new ResidenceRentEvent(res, player, RentEventType.UNRENT);
|
final ResidenceRentEvent revent = new ResidenceRentEvent(res, player, RentEventType.UNRENT);
|
||||||
pm.callEvent(revent);
|
pm.callEvent(revent);
|
||||||
if (revent.isCancelled()) {
|
if (revent.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rentableLand.remove(landName);
|
rentableLand.remove(landName);
|
||||||
if (rentedLand.containsKey(landName)) {
|
if (rentedLand.containsKey(landName)) {
|
||||||
rentedLand.remove(landName);
|
rentedLand.remove(landName);
|
||||||
res.getPermissions().applyDefaultFlags();
|
res.getPermissions().applyDefaultFlags();
|
||||||
}
|
}
|
||||||
if (split.length != 0) {
|
if (split.length != 0) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceRemoveRentable", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceRemoveRentable", ChatColor.YELLOW + split[split.length - 1] + ChatColor.RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForRent"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceNotForRent"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateRentableName(final String oldName, final String newName) {
|
public void updateRentableName(final String oldName, final String newName) {
|
||||||
if (rentableLand.containsKey(oldName)) {
|
if (rentableLand.containsKey(oldName)) {
|
||||||
rentableLand.put(newName, rentableLand.get(oldName));
|
rentableLand.put(newName, rentableLand.get(oldName));
|
||||||
rentableLand.remove(oldName);
|
rentableLand.remove(oldName);
|
||||||
}
|
}
|
||||||
if (rentedLand.containsKey(oldName)) {
|
if (rentedLand.containsKey(oldName)) {
|
||||||
rentedLand.put(newName, rentedLand.get(oldName));
|
rentedLand.put(newName, rentedLand.get(oldName));
|
||||||
rentedLand.remove(oldName);
|
rentedLand.remove(oldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long daysToMs(final int days) {
|
private long daysToMs(final int days) {
|
||||||
return ((days) * 24L * 60L * 60L * 1000L);
|
return ((days) * 24L * 60L * 60L * 1000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private int msToDays(final long ms) {
|
private int msToDays(final long ms) {
|
||||||
return (int) Math.ceil((((ms / 1000D) / 60D) / 60D) / 24D);
|
return (int) Math.ceil((((ms / 1000D) / 60D) / 60D) / 24D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ public class RentableLand {
|
|||||||
|
|
||||||
public static RentableLand load(Map<String, Object> map) {
|
public static RentableLand load(Map<String, Object> map) {
|
||||||
RentableLand newland = new RentableLand();
|
RentableLand newland = new RentableLand();
|
||||||
newland.cost = (Integer)map.get("Cost");
|
newland.cost = (Integer) map.get("Cost");
|
||||||
newland.days = (Integer)map.get("Days");
|
newland.days = (Integer) map.get("Days");
|
||||||
newland.repeatable = (Boolean)map.get("Repeatable");
|
newland.repeatable = (Boolean) map.get("Repeatable");
|
||||||
return newland;
|
return newland;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ public class RentedLand {
|
|||||||
rentables.put("AutoRefresh", autoRefresh);
|
rentables.put("AutoRefresh", autoRefresh);
|
||||||
return rentables;
|
return rentables;
|
||||||
}
|
}
|
||||||
public static RentedLand load(Map<String,Object> map)
|
|
||||||
{
|
public static RentedLand load(Map<String, Object> map) {
|
||||||
RentedLand newland = new RentedLand();
|
RentedLand newland = new RentedLand();
|
||||||
newland.player = (String) map.get("Player");
|
newland.player = (String) map.get("Player");
|
||||||
newland.startTime = (Long)map.get("StartTime");
|
newland.startTime = (Long) map.get("StartTime");
|
||||||
newland.endTime = (Long)map.get("EndTime");
|
newland.endTime = (Long) map.get("EndTime");
|
||||||
newland.autoRefresh = (Boolean)map.get("AutoRefresh");
|
newland.autoRefresh = (Boolean) map.get("AutoRefresh");
|
||||||
return newland;
|
return newland;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,166 +21,166 @@ import org.bukkit.entity.Player;
|
|||||||
*/
|
*/
|
||||||
public class ItemList {
|
public class ItemList {
|
||||||
|
|
||||||
public static enum ListType {
|
public static enum ListType {
|
||||||
BLACKLIST,
|
BLACKLIST,
|
||||||
WHITELIST,
|
WHITELIST,
|
||||||
IGNORELIST,
|
IGNORELIST,
|
||||||
OTHER
|
OTHER
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Material> list;
|
protected List<Material> list;
|
||||||
|
|
||||||
protected ListType type;
|
protected ListType type;
|
||||||
|
|
||||||
public ItemList(final ListType listType) {
|
public ItemList(final ListType listType) {
|
||||||
this();
|
this();
|
||||||
type = listType;
|
type = listType;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ItemList() {
|
protected ItemList() {
|
||||||
list = new ArrayList<Material>();
|
list = new ArrayList<Material>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemList load(final Map<String, Object> map) {
|
public static ItemList load(final Map<String, Object> map) {
|
||||||
final ItemList newlist = new ItemList();
|
final ItemList newlist = new ItemList();
|
||||||
return load(map, newlist);
|
return load(map, newlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemList readList(final ConfigurationSection node) {
|
public static ItemList readList(final ConfigurationSection node) {
|
||||||
return ItemList.readList(node, new ItemList());
|
return ItemList.readList(node, new ItemList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected static ItemList load(final Map<String, Object> map, final ItemList newlist) {
|
protected static ItemList load(final Map<String, Object> map, final ItemList newlist) {
|
||||||
try {
|
try {
|
||||||
newlist.type = ListType.valueOf((String) map.get("Type"));
|
newlist.type = ListType.valueOf((String) map.get("Type"));
|
||||||
final List<String> list = (List<String>) map.get("ItemList");
|
final List<String> list = (List<String>) map.get("ItemList");
|
||||||
for (final String item : list) {
|
for (final String item : list) {
|
||||||
newlist.add(Material.valueOf(item));
|
newlist.add(Material.valueOf(item));
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
}
|
}
|
||||||
return newlist;
|
return newlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
protected static ItemList readList(final ConfigurationSection node, final ItemList list) {
|
protected static ItemList readList(final ConfigurationSection node, final ItemList list) {
|
||||||
final ListType type = ListType.valueOf(node.getString("Type", "").toUpperCase());
|
final ListType type = ListType.valueOf(node.getString("Type", "").toUpperCase());
|
||||||
list.type = type;
|
list.type = type;
|
||||||
final List<String> items = node.getStringList("Items");
|
final List<String> items = node.getStringList("Items");
|
||||||
if (items != null) {
|
if (items != null) {
|
||||||
for (final String item : items) {
|
for (final String item : items) {
|
||||||
int parse = -1;
|
int parse = -1;
|
||||||
try {
|
try {
|
||||||
parse = Integer.parseInt(item);
|
parse = Integer.parseInt(item);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
}
|
}
|
||||||
if (parse == -1) {
|
if (parse == -1) {
|
||||||
try {
|
try {
|
||||||
list.add(Material.valueOf(item.toUpperCase()));
|
list.add(Material.valueOf(item.toUpperCase()));
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
list.add(Material.getMaterial(parse));
|
list.add(Material.getMaterial(parse));
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(final Material mat) {
|
public void add(final Material mat) {
|
||||||
if (!list.contains(mat))
|
if (!list.contains(mat))
|
||||||
list.add(mat);
|
list.add(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(final Material mat) {
|
public boolean contains(final Material mat) {
|
||||||
return list.contains(mat);
|
return list.contains(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getListSize() {
|
public int getListSize() {
|
||||||
return list.size();
|
return list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListType getType() {
|
public ListType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllowed(final Material mat) {
|
public boolean isAllowed(final Material mat) {
|
||||||
if (type == ListType.BLACKLIST) {
|
if (type == ListType.BLACKLIST) {
|
||||||
if (list.contains(mat)) {
|
if (list.contains(mat)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (type == ListType.WHITELIST) {
|
} else if (type == ListType.WHITELIST) {
|
||||||
if (list.contains(mat)) {
|
if (list.contains(mat)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIgnored(final Material mat) {
|
public boolean isIgnored(final Material mat) {
|
||||||
if (type == ListType.IGNORELIST) {
|
if (type == ListType.IGNORELIST) {
|
||||||
if (list.contains(mat)) {
|
if (list.contains(mat)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isListed(final Material mat) {
|
public boolean isListed(final Material mat) {
|
||||||
return this.contains(mat);
|
return this.contains(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printList(final Player player) {
|
public void printList(final Player player) {
|
||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (final Material mat : list) {
|
for (final Material mat : list) {
|
||||||
if (!first)
|
if (!first)
|
||||||
builder.append(", ");
|
builder.append(", ");
|
||||||
else
|
else
|
||||||
builder.append(ChatColor.YELLOW);
|
builder.append(ChatColor.YELLOW);
|
||||||
builder.append(mat);
|
builder.append(mat);
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
player.sendMessage(builder.toString());
|
player.sendMessage(builder.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(final Material mat) {
|
public void remove(final Material mat) {
|
||||||
list.remove(mat);
|
list.remove(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> save() {
|
public Map<String, Object> save() {
|
||||||
final Map<String, Object> saveMap = new LinkedHashMap<String, Object>();
|
final Map<String, Object> saveMap = new LinkedHashMap<String, Object>();
|
||||||
saveMap.put("Type", type.toString());
|
saveMap.put("Type", type.toString());
|
||||||
final List<String> saveList = new ArrayList<String>();
|
final List<String> saveList = new ArrayList<String>();
|
||||||
for (final Material mat : list) {
|
for (final Material mat : list) {
|
||||||
saveList.add(mat.toString());
|
saveList.add(mat.toString());
|
||||||
}
|
}
|
||||||
saveMap.put("ItemList", saveList);
|
saveMap.put("ItemList", saveList);
|
||||||
return saveMap;
|
return saveMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Material[] toArray() {
|
public Material[] toArray() {
|
||||||
final Material mats[] = new Material[list.size()];
|
final Material mats[] = new Material[list.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final Material mat : list) {
|
for (final Material mat : list) {
|
||||||
mats[i] = mat;
|
mats[i] = mat;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return mats;
|
return mats;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean toggle(final Material mat) {
|
public boolean toggle(final Material mat) {
|
||||||
if (list.contains(mat)) {
|
if (list.contains(mat)) {
|
||||||
list.remove(mat);
|
list.remove(mat);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
list.add(mat);
|
list.add(mat);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,37 +21,37 @@ import cn.citycraft.Residence.permissions.PermissionGroup;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class ResidenceItemList extends ItemList {
|
public class ResidenceItemList extends ItemList {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
ClaimedResidence res;
|
ClaimedResidence res;
|
||||||
|
|
||||||
public ResidenceItemList(final ResidenceMain plugin, final ClaimedResidence parent, final ListType type) {
|
public ResidenceItemList(final ResidenceMain plugin, final ClaimedResidence parent, final ListType type) {
|
||||||
super(type);
|
super(type);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
res = parent;
|
res = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResidenceItemList(final ResidenceMain plugin) {
|
private ResidenceItemList(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResidenceItemList load(final ResidenceMain plugin, final ClaimedResidence parent, final Map<String, Object> map) {
|
public static ResidenceItemList load(final ResidenceMain plugin, final ClaimedResidence parent, final Map<String, Object> map) {
|
||||||
final ResidenceItemList newlist = new ResidenceItemList(plugin);
|
final ResidenceItemList newlist = new ResidenceItemList(plugin);
|
||||||
newlist.res = parent;
|
newlist.res = parent;
|
||||||
return (ResidenceItemList) ItemList.load(map, newlist);
|
return (ResidenceItemList) ItemList.load(map, newlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playerListChange(final Player player, final Material mat, final boolean resadmin) {
|
public void playerListChange(final Player player, final Material mat, final boolean resadmin) {
|
||||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||||
if (resadmin || (res.getPermissions().hasResidencePermission(player, true) && group.itemListAccess())) {
|
if (resadmin || (res.getPermissions().hasResidencePermission(player, true) && group.itemListAccess())) {
|
||||||
if (super.toggle(mat)) {
|
if (super.toggle(mat)) {
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ListMaterialAdd",
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ListMaterialAdd",
|
||||||
ChatColor.GREEN + mat.toString() + ChatColor.YELLOW + "." + ChatColor.GREEN + type.toString().toLowerCase() + ChatColor.YELLOW));
|
ChatColor.GREEN + mat.toString() + ChatColor.YELLOW + "." + ChatColor.GREEN + type.toString().toLowerCase() + ChatColor.YELLOW));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ListMaterialRemove",
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ListMaterialRemove",
|
||||||
ChatColor.GREEN + mat.toString() + ChatColor.YELLOW + "." + ChatColor.GREEN + type.toString().toLowerCase() + ChatColor.YELLOW));
|
ChatColor.GREEN + mat.toString() + ChatColor.YELLOW + "." + ChatColor.GREEN + type.toString().toLowerCase() + ChatColor.YELLOW));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,50 +15,43 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
public class WorldItemList extends ItemList {
|
public class WorldItemList extends ItemList {
|
||||||
|
|
||||||
protected String world;
|
protected String world;
|
||||||
protected String group;
|
protected String group;
|
||||||
|
|
||||||
public WorldItemList(ListType listType)
|
public WorldItemList(ListType listType) {
|
||||||
{
|
|
||||||
super(listType);
|
super(listType);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WorldItemList()
|
protected WorldItemList() {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWorld()
|
public String getWorld() {
|
||||||
{
|
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGroup()
|
public String getGroup() {
|
||||||
{
|
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllowed(Material mat, String inworld, String ingroup) {
|
public boolean isAllowed(Material mat, String inworld, String ingroup) {
|
||||||
if(!listApplicable(inworld,ingroup))
|
if (!listApplicable(inworld, ingroup))
|
||||||
return true;
|
return true;
|
||||||
return super.isAllowed(mat);
|
return super.isAllowed(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIgnored(Material mat, String inworld, String ingroup)
|
public boolean isIgnored(Material mat, String inworld, String ingroup) {
|
||||||
{
|
if (!listApplicable(inworld, ingroup))
|
||||||
if(!listApplicable(inworld,ingroup))
|
|
||||||
return false;
|
return false;
|
||||||
return super.isIgnored(mat);
|
return super.isIgnored(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isListed(Material mat, String inworld, String ingroup)
|
public boolean isListed(Material mat, String inworld, String ingroup) {
|
||||||
{
|
if (!listApplicable(inworld, ingroup))
|
||||||
if(!listApplicable(inworld,ingroup))
|
|
||||||
return false;
|
return false;
|
||||||
return super.isListed(mat);
|
return super.isListed(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean listApplicable(String inworld, String ingroup)
|
public boolean listApplicable(String inworld, String ingroup) {
|
||||||
{
|
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
if (!world.equalsIgnoreCase(inworld)) {
|
if (!world.equalsIgnoreCase(inworld)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -72,12 +65,11 @@ public class WorldItemList extends ItemList {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WorldItemList readList(ConfigurationSection node)
|
public static WorldItemList readList(ConfigurationSection node) {
|
||||||
{
|
|
||||||
WorldItemList list = new WorldItemList();
|
WorldItemList list = new WorldItemList();
|
||||||
ItemList.readList(node, list);
|
ItemList.readList(node, list);
|
||||||
list.world = node.getString("World",null);
|
list.world = node.getString("World", null);
|
||||||
list.group = node.getString("Group",null);
|
list.group = node.getString("Group", null);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
public class WorldItemManager {
|
public class WorldItemManager {
|
||||||
protected List<WorldItemList> lists;
|
protected List<WorldItemList> lists;
|
||||||
|
|
||||||
public WorldItemManager(FileConfiguration config)
|
public WorldItemManager(FileConfiguration config) {
|
||||||
{
|
|
||||||
lists = new ArrayList<WorldItemList>();
|
lists = new ArrayList<WorldItemList>();
|
||||||
this.readLists(config);
|
this.readLists(config);
|
||||||
}
|
}
|
||||||
@@ -33,8 +32,7 @@ public class WorldItemManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIgnored(Material mat, String group, String world)
|
public boolean isIgnored(Material mat, String group, String world) {
|
||||||
{
|
|
||||||
for (WorldItemList list : lists) {
|
for (WorldItemList list : lists) {
|
||||||
if (list.isIgnored(mat, world, group)) {
|
if (list.isIgnored(mat, world, group)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -50,7 +48,7 @@ public class WorldItemManager {
|
|||||||
try {
|
try {
|
||||||
WorldItemList list = WorldItemList.readList(config.getConfigurationSection("ItemList." + key));
|
WorldItemList list = WorldItemList.readList(config.getConfigurationSection("ItemList." + key));
|
||||||
lists.add(list);
|
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) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Failed to load item list:" + key);
|
System.out.println("Failed to load item list:" + key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,186 +34,186 @@ import org.bukkit.event.block.BlockSpreadEvent;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class ResidenceBlockListener implements Listener {
|
public class ResidenceBlockListener implements Listener {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public ResidenceBlockListener(final ResidenceMain plugin) {
|
public ResidenceBlockListener(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onBlockBreak(final BlockBreakEvent event) {
|
public void onBlockBreak(final BlockBreakEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (plugin.isResAdminOn(player)) {
|
if (plugin.isResAdminOn(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Material mat = event.getBlock().getType();
|
final Material mat = event.getBlock().getType();
|
||||||
final String world = event.getBlock().getWorld().getName();
|
final String world = event.getBlock().getWorld().getName();
|
||||||
final String group = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
final String group = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||||
if (plugin.getItemManager().isIgnored(mat, group, world)) {
|
if (plugin.getItemManager().isIgnored(mat, group, world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlock().getLocation());
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlock().getLocation());
|
||||||
if (plugin.getConfigManager().enabledRentSystem()) {
|
if (plugin.getConfigManager().enabledRentSystem()) {
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
final String resname = res.getName();
|
final String resname = res.getName();
|
||||||
if (plugin.getConfigManager().preventRentModify() && plugin.getRentManager().isRented(resname)) {
|
if (plugin.getConfigManager().preventRentModify() && plugin.getRentManager().isRented(resname)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlock().getLocation(), player);
|
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlock().getLocation(), player);
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (res.getItemIgnoreList().isListed(mat)) {
|
if (res.getItemIgnoreList().isListed(mat)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final boolean hasdestroy = perms.playerHas(pname, player.getWorld().getName(), "destroy", perms.playerHas(pname, player.getWorld().getName(), "build", true));
|
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);
|
final boolean hasContainer = perms.playerHas(pname, player.getWorld().getName(), "container", true);
|
||||||
if (!hasdestroy || (!hasContainer && mat == Material.CHEST)) {
|
if (!hasdestroy || (!hasContainer && mat == Material.CHEST)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onBlockBurn(final BlockBurnEvent event) {
|
public void onBlockBurn(final BlockBurnEvent event) {
|
||||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
||||||
if (!perms.has("firespread", true)) {
|
if (!perms.has("firespread", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onBlockFromTo(final BlockFromToEvent event) {
|
public void onBlockFromTo(final BlockFromToEvent event) {
|
||||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getToBlock().getLocation());
|
final FlagPermissions perms = plugin.getPermsByLoc(event.getToBlock().getLocation());
|
||||||
final boolean hasflow = perms.has("flow", true);
|
final boolean hasflow = perms.has("flow", true);
|
||||||
final Material mat = event.getBlock().getType();
|
final Material mat = event.getBlock().getType();
|
||||||
if (!hasflow) {
|
if (!hasflow) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mat == Material.LAVA || mat == Material.STATIONARY_LAVA) {
|
if (mat == Material.LAVA || mat == Material.STATIONARY_LAVA) {
|
||||||
if (!perms.has("lavaflow", hasflow)) {
|
if (!perms.has("lavaflow", hasflow)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mat == Material.WATER || mat == Material.STATIONARY_WATER) {
|
if (mat == Material.WATER || mat == Material.STATIONARY_WATER) {
|
||||||
if (!perms.has("waterflow", hasflow)) {
|
if (!perms.has("waterflow", hasflow)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onBlockIgnite(final BlockIgniteEvent event) {
|
public void onBlockIgnite(final BlockIgniteEvent event) {
|
||||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlock().getLocation(), event.getPlayer());
|
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlock().getLocation(), event.getPlayer());
|
||||||
final IgniteCause cause = event.getCause();
|
final IgniteCause cause = event.getCause();
|
||||||
if (cause == IgniteCause.SPREAD) {
|
if (cause == IgniteCause.SPREAD) {
|
||||||
if (!perms.has("firespread", true)) {
|
if (!perms.has("firespread", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (cause == IgniteCause.FLINT_AND_STEEL) {
|
} else if (cause == IgniteCause.FLINT_AND_STEEL) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (player != null && !perms.playerHas(player.getName(), player.getWorld().getName(), "ignite", true) && !plugin.isResAdminOn(player)) {
|
if (player != null && !perms.playerHas(player.getName(), player.getWorld().getName(), "ignite", true) && !plugin.isResAdminOn(player)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!perms.has("ignite", true)) {
|
if (!perms.has("ignite", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onBlockPistonExtend(final BlockPistonExtendEvent event) {
|
public void onBlockPistonExtend(final BlockPistonExtendEvent event) {
|
||||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
||||||
if (!perms.has("piston", true)) {
|
if (!perms.has("piston", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
for (final Block block : event.getBlocks()) {
|
for (final Block block : event.getBlocks()) {
|
||||||
final FlagPermissions blockpermsfrom = plugin.getPermsByLoc(block.getLocation());
|
final FlagPermissions blockpermsfrom = plugin.getPermsByLoc(block.getLocation());
|
||||||
final Location blockto = block.getLocation();
|
final Location blockto = block.getLocation();
|
||||||
blockto.setX(blockto.getX() + event.getDirection().getModX());
|
blockto.setX(blockto.getX() + event.getDirection().getModX());
|
||||||
blockto.setY(blockto.getY() + event.getDirection().getModY());
|
blockto.setY(blockto.getY() + event.getDirection().getModY());
|
||||||
blockto.setZ(blockto.getZ() + event.getDirection().getModZ());
|
blockto.setZ(blockto.getZ() + event.getDirection().getModZ());
|
||||||
final FlagPermissions blockpermsto = plugin.getPermsByLoc(blockto);
|
final FlagPermissions blockpermsto = plugin.getPermsByLoc(blockto);
|
||||||
if (!blockpermsfrom.has("piston", true) || !blockpermsto.has("piston", true)) {
|
if (!blockpermsfrom.has("piston", true) || !blockpermsto.has("piston", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onBlockPistonRetract(final BlockPistonRetractEvent event) {
|
public void onBlockPistonRetract(final BlockPistonRetractEvent event) {
|
||||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
||||||
if (!perms.has("piston", true)) {
|
if (!perms.has("piston", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.isSticky()) {
|
if (event.isSticky()) {
|
||||||
final Location location = event.getRetractLocation();
|
final Location location = event.getRetractLocation();
|
||||||
final FlagPermissions blockperms = plugin.getPermsByLoc(location);
|
final FlagPermissions blockperms = plugin.getPermsByLoc(location);
|
||||||
if (!blockperms.has("piston", true)) {
|
if (!blockperms.has("piston", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onBlockPlace(final BlockPlaceEvent event) {
|
public void onBlockPlace(final BlockPlaceEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (plugin.isResAdminOn(player)) {
|
if (plugin.isResAdminOn(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Material mat = event.getBlock().getType();
|
final Material mat = event.getBlock().getType();
|
||||||
final String world = event.getBlock().getWorld().getName();
|
final String world = event.getBlock().getWorld().getName();
|
||||||
final String group = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
final String group = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||||
if (plugin.getItemManager().isIgnored(mat, group, world)) {
|
if (plugin.getItemManager().isIgnored(mat, group, world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlock().getLocation());
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlock().getLocation());
|
||||||
if (plugin.getConfigManager().enabledRentSystem()) {
|
if (plugin.getConfigManager().enabledRentSystem()) {
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
final String resname = res.getName();
|
final String resname = res.getName();
|
||||||
if (plugin.getConfigManager().preventRentModify() && plugin.getRentManager().isRented(resname)) {
|
if (plugin.getConfigManager().preventRentModify() && plugin.getRentManager().isRented(resname)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (!res.getItemBlacklist().isAllowed(mat)) {
|
if (!res.getItemBlacklist().isAllowed(mat)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlock().getLocation(), player);
|
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));
|
final boolean hasplace = perms.playerHas(pname, player.getWorld().getName(), "place", perms.playerHas(pname, player.getWorld().getName(), "build", true));
|
||||||
if (!hasplace) {
|
if (!hasplace) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onBlockSpread(final BlockSpreadEvent event) {
|
public void onBlockSpread(final BlockSpreadEvent event) {
|
||||||
final Location loc = event.getBlock().getLocation();
|
final Location loc = event.getBlock().getLocation();
|
||||||
final FlagPermissions perms = plugin.getPermsByLoc(loc);
|
final FlagPermissions perms = plugin.getPermsByLoc(loc);
|
||||||
if (!perms.has("spread", true)) {
|
if (!perms.has("spread", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,320 +48,320 @@ import cn.citycraft.Residence.manager.EntityManager;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class ResidenceEntityListener implements Listener {
|
public class ResidenceEntityListener implements Listener {
|
||||||
EntityManager entitymanager;
|
EntityManager entitymanager;
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public ResidenceEntityListener(final ResidenceMain plugin) {
|
public ResidenceEntityListener(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.entitymanager = plugin.getEntityManager();
|
this.entitymanager = plugin.getEntityManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onCreatureSpawn(final CreatureSpawnEvent event) {
|
public void onCreatureSpawn(final CreatureSpawnEvent event) {
|
||||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getLocation());
|
final FlagPermissions perms = plugin.getPermsByLoc(event.getLocation());
|
||||||
final Entity ent = event.getEntity();
|
final Entity ent = event.getEntity();
|
||||||
if (entitymanager.isAnimal(ent)) {
|
if (entitymanager.isAnimal(ent)) {
|
||||||
if (!perms.has("animals", true)) {
|
if (!perms.has("animals", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!perms.has("monsters", true) && entitymanager.isMonster(ent)) {
|
} else if (!perms.has("monsters", true) && entitymanager.isMonster(ent)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onEndermanChangeBlock(final EntityChangeBlockEvent event) {
|
public void onEndermanChangeBlock(final EntityChangeBlockEvent event) {
|
||||||
if (event.getEntityType() != EntityType.ENDERMAN && event.getEntityType() != EntityType.WITHER) {
|
if (event.getEntityType() != EntityType.ENDERMAN && event.getEntityType() != EntityType.WITHER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
final FlagPermissions perms = plugin.getPermsByLoc(event.getBlock().getLocation());
|
||||||
final FlagPermissions world = plugin.getWorldFlags().getPerms(event.getBlock().getWorld().getName());
|
final FlagPermissions world = plugin.getWorldFlags().getPerms(event.getBlock().getWorld().getName());
|
||||||
if (event.getEntityType() == EntityType.WITHER) {
|
if (event.getEntityType() == EntityType.WITHER) {
|
||||||
if (!perms.has("wither", perms.has("explode", world.has("wither", world.has("explode", true))))) {
|
if (!perms.has("wither", perms.has("explode", world.has("wither", world.has("explode", true))))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!perms.has("build", true)) {
|
} else if (!perms.has("build", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onEntityCombust(final EntityCombustEvent event) {
|
public void onEntityCombust(final EntityCombustEvent event) {
|
||||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getEntity().getLocation());
|
final FlagPermissions perms = plugin.getPermsByLoc(event.getEntity().getLocation());
|
||||||
if (!perms.has("burn", true)) {
|
if (!perms.has("burn", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onEntityDamage(final EntityDamageEvent event) {
|
public void onEntityDamage(final EntityDamageEvent event) {
|
||||||
Entity ent = event.getEntity();
|
Entity ent = event.getEntity();
|
||||||
if (ent.hasMetadata("NPC")) {
|
if (ent.hasMetadata("NPC")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final boolean tamedWolf = ent instanceof Wolf ? ((Wolf) ent).isTamed() : false;
|
final boolean tamedWolf = ent instanceof Wolf ? ((Wolf) ent).isTamed() : false;
|
||||||
final ClaimedResidence area = plugin.getResidenceManager().getByLoc(ent.getLocation());
|
final ClaimedResidence area = plugin.getResidenceManager().getByLoc(ent.getLocation());
|
||||||
/* Living Entities */
|
/* Living Entities */
|
||||||
if (event instanceof EntityDamageByEntityEvent) {
|
if (event instanceof EntityDamageByEntityEvent) {
|
||||||
final EntityDamageByEntityEvent attackevent = (EntityDamageByEntityEvent) event;
|
final EntityDamageByEntityEvent attackevent = (EntityDamageByEntityEvent) event;
|
||||||
final Entity damager = attackevent.getDamager();
|
final Entity damager = attackevent.getDamager();
|
||||||
ClaimedResidence srcarea = null;
|
ClaimedResidence srcarea = null;
|
||||||
if (damager != null) {
|
if (damager != null) {
|
||||||
srcarea = plugin.getResidenceManager().getByLoc(damager.getLocation());
|
srcarea = plugin.getResidenceManager().getByLoc(damager.getLocation());
|
||||||
}
|
}
|
||||||
boolean srcpvp = true;
|
boolean srcpvp = true;
|
||||||
if (srcarea != null) {
|
if (srcarea != null) {
|
||||||
srcpvp = srcarea.getPermissions().has("pvp", true);
|
srcpvp = srcarea.getPermissions().has("pvp", true);
|
||||||
}
|
}
|
||||||
ent = attackevent.getEntity();
|
ent = attackevent.getEntity();
|
||||||
if ((ent instanceof Player || tamedWolf) && (damager instanceof Player || (damager instanceof Arrow && (((Arrow) damager).getShooter() instanceof Player)))) {
|
if ((ent instanceof Player || tamedWolf) && (damager instanceof Player || (damager instanceof Arrow && (((Arrow) damager).getShooter() instanceof Player)))) {
|
||||||
Player attacker = null;
|
Player attacker = null;
|
||||||
if (damager instanceof Player) {
|
if (damager instanceof Player) {
|
||||||
attacker = (Player) damager;
|
attacker = (Player) damager;
|
||||||
} else if (damager instanceof Arrow) {
|
} else if (damager instanceof Arrow) {
|
||||||
attacker = (Player) ((Arrow) damager).getShooter();
|
attacker = (Player) ((Arrow) damager).getShooter();
|
||||||
}
|
}
|
||||||
if (!srcpvp) {
|
if (!srcpvp) {
|
||||||
if (attacker != null) {
|
if (attacker != null) {
|
||||||
attacker.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPVPZone"));
|
attacker.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPVPZone"));
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Check for Player vs Player */
|
/* Check for Player vs Player */
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
/* World PvP */
|
/* World PvP */
|
||||||
if (damager != null) {
|
if (damager != null) {
|
||||||
if (!plugin.getWorldFlags().getPerms(damager.getWorld().getName()).has("pvp", true)) {
|
if (!plugin.getWorldFlags().getPerms(damager.getWorld().getName()).has("pvp", true)) {
|
||||||
if (attacker != null) {
|
if (attacker != null) {
|
||||||
attacker.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("WorldPVPDisabled"));
|
attacker.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("WorldPVPDisabled"));
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else /* Normal PvP */
|
} else /* Normal PvP */
|
||||||
if (!area.getPermissions().has("pvp", true)) {
|
if (!area.getPermissions().has("pvp", true)) {
|
||||||
if (attacker != null) {
|
if (attacker != null) {
|
||||||
attacker.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPVPZone"));
|
attacker.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPVPZone"));
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if ((ent instanceof Player || tamedWolf) && (damager instanceof Creeper)) {
|
} else if ((ent instanceof Player || tamedWolf) && (damager instanceof Creeper)) {
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
if (!plugin.getWorldFlags().getPerms(damager.getWorld().getName()).has("creeper", true)) {
|
if (!plugin.getWorldFlags().getPerms(damager.getWorld().getName()).has("creeper", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!area.getPermissions().has("creeper", true)) {
|
} else if (!area.getPermissions().has("creeper", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
if (!plugin.getWorldFlags().getPerms(ent.getWorld().getName()).has("damage", true) && (ent instanceof Player || tamedWolf)) {
|
if (!plugin.getWorldFlags().getPerms(ent.getWorld().getName()).has("damage", true) && (ent instanceof Player || tamedWolf)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!area.getPermissions().has("damage", true) && (ent instanceof Player || tamedWolf)) {
|
} else if (!area.getPermissions().has("damage", true) && (ent instanceof Player || tamedWolf)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
/* Put out a fire on a player */
|
/* Put out a fire on a player */
|
||||||
if ((ent instanceof Player || tamedWolf) && (event.getCause() == EntityDamageEvent.DamageCause.FIRE || event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK)) {
|
if ((ent instanceof Player || tamedWolf) && (event.getCause() == EntityDamageEvent.DamageCause.FIRE || event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK)) {
|
||||||
ent.setFireTicks(0);
|
ent.setFireTicks(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent event) {
|
public void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent event) {
|
||||||
if (event.getEntityType() == EntityType.ITEM_FRAME || (plugin.isGt1_8() && event.getEntityType() == EntityType.ARMOR_STAND)) {
|
if (event.getEntityType() == EntityType.ITEM_FRAME || (plugin.isGt1_8() && event.getEntityType() == EntityType.ARMOR_STAND)) {
|
||||||
final Entity dmgr = event.getDamager();
|
final Entity dmgr = event.getDamager();
|
||||||
Player player;
|
Player player;
|
||||||
if (dmgr instanceof Player) {
|
if (dmgr instanceof Player) {
|
||||||
player = (Player) event.getDamager();
|
player = (Player) event.getDamager();
|
||||||
} else if (dmgr instanceof Projectile && ((Projectile) dmgr).getShooter() instanceof Player) {
|
} else if (dmgr instanceof Projectile && ((Projectile) dmgr).getShooter() instanceof Player) {
|
||||||
player = (Player) ((Projectile) dmgr).getShooter();
|
player = (Player) ((Projectile) dmgr).getShooter();
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.isResAdminOn(player)) {
|
if (plugin.isResAdminOn(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: Location of entity, not player; otherwise player could
|
// Note: Location of entity, not player; otherwise player could
|
||||||
// stand outside of res and still damage
|
// stand outside of res and still damage
|
||||||
final Location loc = event.getEntity().getLocation();
|
final Location loc = event.getEntity().getLocation();
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (!res.getPermissions().has("container", false)) {
|
if (!res.getPermissions().has("container", false)) {
|
||||||
if (entitymanager.isMonster(dmgr)) {
|
if (entitymanager.isMonster(dmgr)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res.getPermissions().playerHas(player.getName(), "container", false)) {
|
if (!res.getPermissions().playerHas(player.getName(), "container", false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onEntityExplode(final EntityExplodeEvent event) {
|
public void onEntityExplode(final EntityExplodeEvent event) {
|
||||||
if (event.isCancelled() || event.getEntity() == null) {
|
if (event.isCancelled() || event.getEntity() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Boolean cancel = false;
|
Boolean cancel = false;
|
||||||
final EntityType entity = event.getEntityType();
|
final EntityType entity = event.getEntityType();
|
||||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getEntity().getLocation());
|
final FlagPermissions perms = plugin.getPermsByLoc(event.getEntity().getLocation());
|
||||||
final FlagPermissions world = plugin.getWorldFlags().getPerms(event.getEntity().getWorld().getName());
|
final FlagPermissions world = plugin.getWorldFlags().getPerms(event.getEntity().getWorld().getName());
|
||||||
if (entity == EntityType.CREEPER) {
|
if (entity == EntityType.CREEPER) {
|
||||||
if (!perms.has("creeper", perms.has("explode", true))) {
|
if (!perms.has("creeper", perms.has("explode", true))) {
|
||||||
cancel = true;
|
cancel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT) {
|
if (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT) {
|
||||||
if (!perms.has("tnt", perms.has("explode", true))) {
|
if (!perms.has("tnt", perms.has("explode", true))) {
|
||||||
cancel = true;
|
cancel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity == EntityType.FIREBALL) {
|
if (entity == EntityType.FIREBALL) {
|
||||||
if (!perms.has("fireball", perms.has("explode", true))) {
|
if (!perms.has("fireball", perms.has("explode", true))) {
|
||||||
cancel = true;
|
cancel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity == EntityType.SMALL_FIREBALL) {
|
if (entity == EntityType.SMALL_FIREBALL) {
|
||||||
if (!perms.has("fireball", perms.has("explode", true))) {
|
if (!perms.has("fireball", perms.has("explode", true))) {
|
||||||
cancel = true;
|
cancel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity == EntityType.WITHER_SKULL || entity == EntityType.WITHER) {
|
if (entity == EntityType.WITHER_SKULL || entity == EntityType.WITHER) {
|
||||||
if (!perms.has("wither", perms.has("explode", world.has("wither", world.has("explode", true))))) {
|
if (!perms.has("wither", perms.has("explode", world.has("wither", world.has("explode", true))))) {
|
||||||
cancel = true;
|
cancel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cancel) {
|
if (cancel) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getEntity().remove();
|
event.getEntity().remove();
|
||||||
} else {
|
} else {
|
||||||
final List<Block> preserve = new ArrayList<Block>();
|
final List<Block> preserve = new ArrayList<Block>();
|
||||||
for (final Block block : event.blockList()) {
|
for (final Block block : event.blockList()) {
|
||||||
final FlagPermissions blockperms = plugin.getPermsByLoc(block.getLocation());
|
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)
|
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("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("tnt", blockperms.has("explode", true)) && (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT))
|
||||||
|| (!blockperms.has("creeper", blockperms.has("explode", true)) && entity == EntityType.CREEPER))) {
|
|| (!blockperms.has("creeper", blockperms.has("explode", true)) && entity == EntityType.CREEPER))) {
|
||||||
preserve.add(block);
|
preserve.add(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (final Block block : preserve) {
|
for (final Block block : preserve) {
|
||||||
event.blockList().remove(block);
|
event.blockList().remove(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onEntityInteract(final EntityInteractEvent event) {
|
public void onEntityInteract(final EntityInteractEvent event) {
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
final Material mat = block.getType();
|
final Material mat = block.getType();
|
||||||
final Entity entity = event.getEntity();
|
final Entity entity = event.getEntity();
|
||||||
final FlagPermissions perms = plugin.getPermsByLoc(block.getLocation());
|
final FlagPermissions perms = plugin.getPermsByLoc(block.getLocation());
|
||||||
final boolean hastrample = perms.has("trample", perms.has("hasbuild", true));
|
final boolean hastrample = perms.has("trample", perms.has("hasbuild", true));
|
||||||
if (!hastrample && !(entity.getType() == EntityType.FALLING_BLOCK) && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
|
if (!hastrample && !(entity.getType() == EntityType.FALLING_BLOCK) && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onExplosionPrime(final ExplosionPrimeEvent event) {
|
public void onExplosionPrime(final ExplosionPrimeEvent event) {
|
||||||
final EntityType entity = event.getEntityType();
|
final EntityType entity = event.getEntityType();
|
||||||
final FlagPermissions perms = plugin.getPermsByLoc(event.getEntity().getLocation());
|
final FlagPermissions perms = plugin.getPermsByLoc(event.getEntity().getLocation());
|
||||||
if (entity == EntityType.CREEPER) {
|
if (entity == EntityType.CREEPER) {
|
||||||
if (!perms.has("creeper", perms.has("explode", true))) {
|
if (!perms.has("creeper", perms.has("explode", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getEntity().remove();
|
event.getEntity().remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT) {
|
if (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT) {
|
||||||
if (!perms.has("tnt", perms.has("explode", true))) {
|
if (!perms.has("tnt", perms.has("explode", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getEntity().remove();
|
event.getEntity().remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity == EntityType.FIREBALL) {
|
if (entity == EntityType.FIREBALL) {
|
||||||
if (!perms.has("fireball", perms.has("explode", true))) {
|
if (!perms.has("fireball", perms.has("explode", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getEntity().remove();
|
event.getEntity().remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity == EntityType.SMALL_FIREBALL) {
|
if (entity == EntityType.SMALL_FIREBALL) {
|
||||||
if (!perms.has("fireball", perms.has("explode", true))) {
|
if (!perms.has("fireball", perms.has("explode", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getEntity().remove();
|
event.getEntity().remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity == EntityType.WITHER_SKULL) {
|
if (entity == EntityType.WITHER_SKULL) {
|
||||||
if (!perms.has("witherdamage", perms.has("damage", true))) {
|
if (!perms.has("witherdamage", perms.has("damage", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getEntity().remove();
|
event.getEntity().remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onHangingBreak(final HangingBreakEvent event) {
|
public void onHangingBreak(final HangingBreakEvent event) {
|
||||||
if (event instanceof HangingBreakByEntityEvent) {
|
if (event instanceof HangingBreakByEntityEvent) {
|
||||||
final HangingBreakByEntityEvent evt = (HangingBreakByEntityEvent) event;
|
final HangingBreakByEntityEvent evt = (HangingBreakByEntityEvent) event;
|
||||||
if (evt.getRemover() instanceof Player) {
|
if (evt.getRemover() instanceof Player) {
|
||||||
final Player player = (Player) evt.getRemover();
|
final Player player = (Player) evt.getRemover();
|
||||||
if (plugin.isResAdminOn(player)) {
|
if (plugin.isResAdminOn(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getEntity().getLocation(), player);
|
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getEntity().getLocation(), player);
|
||||||
final String world = event.getEntity().getWorld().getName();
|
final String world = event.getEntity().getWorld().getName();
|
||||||
if (!perms.playerHas(pname, world, "destroy", perms.playerHas(pname, world, "build", true))) {
|
if (!perms.playerHas(pname, world, "destroy", perms.playerHas(pname, world, "build", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onHangingPlace(final HangingPlaceEvent event) {
|
public void onHangingPlace(final HangingPlaceEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (plugin.isResAdminOn(player)) {
|
if (plugin.isResAdminOn(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getEntity().getLocation(), player);
|
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getEntity().getLocation(), player);
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
final String world = player.getWorld().getName();
|
final String world = player.getWorld().getName();
|
||||||
if (!perms.playerHas(pname, world, "place", perms.playerHas(pname, world, "build", true))) {
|
if (!perms.playerHas(pname, world, "place", perms.playerHas(pname, world, "build", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onSplashPotion(final PotionSplashEvent event) {
|
public void onSplashPotion(final PotionSplashEvent event) {
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Entity ent = event.getEntity();
|
final Entity ent = event.getEntity();
|
||||||
final boolean srcpvp = plugin.getPermsByLoc(ent.getLocation()).has("pvp", true);
|
final boolean srcpvp = plugin.getPermsByLoc(ent.getLocation()).has("pvp", true);
|
||||||
final Iterator<LivingEntity> it = event.getAffectedEntities().iterator();
|
final Iterator<LivingEntity> it = event.getAffectedEntities().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
final LivingEntity target = it.next();
|
final LivingEntity target = it.next();
|
||||||
if (target.getType() == EntityType.PLAYER) {
|
if (target.getType() == EntityType.PLAYER) {
|
||||||
final Boolean tgtpvp = plugin.getPermsByLoc(target.getLocation()).has("pvp", true);
|
final Boolean tgtpvp = plugin.getPermsByLoc(target.getLocation()).has("pvp", true);
|
||||||
if (!srcpvp || !tgtpvp) {
|
if (!srcpvp || !tgtpvp) {
|
||||||
event.setIntensity(target, 0);
|
event.setIntensity(target, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import com.bekvon.bukkit.residence.protection.FlagPermissions;
|
|||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
|
||||||
import cn.citycraft.PluginHelper.utils.ActionBar;
|
import cn.citycraft.PluginHelper.utils.ActionBar;
|
||||||
|
import cn.citycraft.PluginHelper.utils.CompatibleUtil;
|
||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
import cn.citycraft.Residence.chat.ChatChannel;
|
import cn.citycraft.Residence.chat.ChatChannel;
|
||||||
import cn.citycraft.Residence.permissions.PermissionGroup;
|
import cn.citycraft.Residence.permissions.PermissionGroup;
|
||||||
@@ -52,494 +53,494 @@ import cn.citycraft.Residence.permissions.PermissionGroup;
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class ResidencePlayerListener implements Listener {
|
public class ResidencePlayerListener implements Listener {
|
||||||
|
|
||||||
protected boolean chatenabled;
|
protected boolean chatenabled;
|
||||||
protected Map<String, String> currentRes;
|
protected Map<String, String> currentRes;
|
||||||
protected Map<String, Location> lastOutsideLoc;
|
protected Map<String, Location> lastOutsideLoc;
|
||||||
protected Map<String, Long> lastUpdate;
|
protected Map<String, Long> lastUpdate;
|
||||||
protected int minUpdateTime;
|
protected int minUpdateTime;
|
||||||
protected List<String> playerToggleChat;
|
protected List<String> playerToggleChat;
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public ResidencePlayerListener(final ResidenceMain plugin) {
|
public ResidencePlayerListener(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
currentRes = new HashMap<>();
|
currentRes = new HashMap<>();
|
||||||
lastUpdate = new HashMap<>();
|
lastUpdate = new HashMap<>();
|
||||||
lastOutsideLoc = new HashMap<>();
|
lastOutsideLoc = new HashMap<>();
|
||||||
playerToggleChat = new ArrayList<>();
|
playerToggleChat = new ArrayList<>();
|
||||||
minUpdateTime = plugin.getConfigManager().getMinMoveUpdateInterval();
|
minUpdateTime = plugin.getConfigManager().getMinMoveUpdateInterval();
|
||||||
chatenabled = plugin.getConfigManager().chatEnabled();
|
chatenabled = plugin.getConfigManager().chatEnabled();
|
||||||
for (final Player player : Bukkit.getServer().getOnlinePlayers()) {
|
for (final Player player : CompatibleUtil.getOnlinePlayers()) {
|
||||||
lastUpdate.put(player.getName(), System.currentTimeMillis());
|
lastUpdate.put(player.getName(), System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCurrentResidenceName(final String player) {
|
public String getCurrentResidenceName(final String player) {
|
||||||
return currentRes.get(player);
|
return currentRes.get(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleNewLocation(final Player player, final Location loc, final boolean move) {
|
public void handleNewLocation(final Player player, final Location loc, final boolean move) {
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
|
|
||||||
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||||
String areaname = null;
|
String areaname = null;
|
||||||
boolean chatchange = false;
|
boolean chatchange = false;
|
||||||
String subzone = null;
|
String subzone = null;
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
areaname = plugin.getResidenceManager().getNameByLoc(loc);
|
areaname = plugin.getResidenceManager().getNameByLoc(loc);
|
||||||
while (res.getSubzoneByLoc(player.getLocation()) != null) {
|
while (res.getSubzoneByLoc(player.getLocation()) != null) {
|
||||||
subzone = res.getSubzoneNameByLoc(player.getLocation());
|
subzone = res.getSubzoneNameByLoc(player.getLocation());
|
||||||
res = res.getSubzoneByLoc(player.getLocation());
|
res = res.getSubzoneByLoc(player.getLocation());
|
||||||
areaname = areaname + "." + subzone;
|
areaname = areaname + "." + subzone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClaimedResidence ResOld = null;
|
ClaimedResidence ResOld = null;
|
||||||
if (currentRes.containsKey(pname)) {
|
if (currentRes.containsKey(pname)) {
|
||||||
ResOld = plugin.getResidenceManager().getByName(currentRes.get(pname));
|
ResOld = plugin.getResidenceManager().getByName(currentRes.get(pname));
|
||||||
if (ResOld == null) {
|
if (ResOld == null) {
|
||||||
currentRes.remove(pname);
|
currentRes.remove(pname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
lastOutsideLoc.put(pname, loc);
|
lastOutsideLoc.put(pname, loc);
|
||||||
if (ResOld != null) {
|
if (ResOld != null) {
|
||||||
final String leave = ResOld.getLeaveMessage();
|
final String leave = ResOld.getLeaveMessage();
|
||||||
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(ResOld, null, player);
|
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(ResOld, null, player);
|
||||||
plugin.getServer().getPluginManager().callEvent(chgEvent);
|
plugin.getServer().getPluginManager().callEvent(chgEvent);
|
||||||
|
|
||||||
if (leave != null && !leave.equals("")) {
|
if (leave != null && !leave.equals("")) {
|
||||||
if (plugin.getConfigManager().useActionBar()) {
|
if (plugin.getConfigManager().useActionBar()) {
|
||||||
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentRes.remove(pname);
|
currentRes.remove(pname);
|
||||||
plugin.getChatManager().removeFromChannel(pname);
|
plugin.getChatManager().removeFromChannel(pname);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (move && !res.getPermissions().playerHas(pname, "move", true) && !plugin.isResAdminOn(player) && !player.hasPermission("residence.admin.move")) {
|
if (move && !res.getPermissions().playerHas(pname, "move", true) && !plugin.isResAdminOn(player) && !player.hasPermission("residence.admin.move")) {
|
||||||
final Location lastLoc = lastOutsideLoc.get(pname);
|
final Location lastLoc = lastOutsideLoc.get(pname);
|
||||||
if (lastLoc != null) {
|
if (lastLoc != null) {
|
||||||
player.teleport(lastLoc);
|
player.teleport(lastLoc);
|
||||||
} else {
|
} else {
|
||||||
player.teleport(res.getOutsideFreeLoc(loc));
|
player.teleport(res.getOutsideFreeLoc(loc));
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMoveDeny", res.getName().split("\\.")[res.getName().split("\\.").length - 1]));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ResidenceMoveDeny", res.getName().split("\\.")[res.getName().split("\\.").length - 1]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastOutsideLoc.put(pname, loc);
|
lastOutsideLoc.put(pname, loc);
|
||||||
if (!currentRes.containsKey(pname) || ResOld != res) {
|
if (!currentRes.containsKey(pname) || ResOld != res) {
|
||||||
currentRes.put(pname, areaname);
|
currentRes.put(pname, areaname);
|
||||||
if (subzone == null) {
|
if (subzone == null) {
|
||||||
chatchange = true;
|
chatchange = true;
|
||||||
}
|
}
|
||||||
ClaimedResidence chgFrom = null;
|
ClaimedResidence chgFrom = null;
|
||||||
if (ResOld != res && ResOld != null) {
|
if (ResOld != res && ResOld != null) {
|
||||||
final String leave = ResOld.getLeaveMessage();
|
final String leave = ResOld.getLeaveMessage();
|
||||||
chgFrom = ResOld;
|
chgFrom = ResOld;
|
||||||
|
|
||||||
if (leave != null && !leave.equals("") && ResOld != res.getParent()) {
|
if (leave != null && !leave.equals("") && ResOld != res.getParent()) {
|
||||||
if (plugin.getConfigManager().useActionBar()) {
|
if (plugin.getConfigManager().useActionBar()) {
|
||||||
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
player.sendMessage(ChatColor.YELLOW + insertMessages(player, ResOld.getName(), ResOld, leave));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final String enterMessage = res.getEnterMessage();
|
final String enterMessage = res.getEnterMessage();
|
||||||
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(chgFrom, res, player);
|
final ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(chgFrom, res, player);
|
||||||
plugin.getServer().getPluginManager().callEvent(chgEvent);
|
plugin.getServer().getPluginManager().callEvent(chgEvent);
|
||||||
|
|
||||||
if (enterMessage != null && !enterMessage.equals("") && !(ResOld != null && res == ResOld.getParent())) {
|
if (enterMessage != null && !enterMessage.equals("") && !(ResOld != null && res == ResOld.getParent())) {
|
||||||
if (plugin.getConfigManager().useActionBar()) {
|
if (plugin.getConfigManager().useActionBar()) {
|
||||||
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
|
ActionBar.send(player, ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
|
player.sendMessage(ChatColor.YELLOW + insertMessages(player, areaname, res, enterMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (chatchange && chatenabled) {
|
if (chatchange && chatenabled) {
|
||||||
plugin.getChatManager().setChannel(pname, areaname);
|
plugin.getChatManager().setChannel(pname, areaname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String insertMessages(final Player player, final String areaname, final ClaimedResidence res, String message) {
|
public String insertMessages(final Player player, final String areaname, final ClaimedResidence res, String message) {
|
||||||
try {
|
try {
|
||||||
message = message.replaceAll("%player", player.getName());
|
message = message.replaceAll("%player", player.getName());
|
||||||
message = message.replaceAll("%owner", res.getPermissions().getOwner());
|
message = message.replaceAll("%owner", res.getPermissions().getOwner());
|
||||||
message = message.replaceAll("%residence", areaname);
|
message = message.replaceAll("%residence", areaname);
|
||||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event) {
|
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (plugin.isResAdminOn(player)) {
|
if (plugin.isResAdminOn(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
|
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
|
||||||
if (plugin.getRentManager().isRented(res.getName())) {
|
if (plugin.getRentManager().isRented(res.getName())) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
|
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))) {
|
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"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
|
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
if (plugin.isResAdminOn(player)) {
|
if (plugin.isResAdminOn(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getBlockClicked().getLocation());
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
|
if (plugin.getConfigManager().preventRentModify() && plugin.getConfigManager().enabledRentSystem()) {
|
||||||
if (plugin.getRentManager().isRented(res.getName())) {
|
if (plugin.getRentManager().isRented(res.getName())) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("RentedModifyDeny"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(event.getBlockClicked().getLocation(), player);
|
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));
|
final boolean hasbucket = perms.playerHas(pname, player.getWorld().getName(), "bucket", perms.playerHas(pname, player.getWorld().getName(), "build", true));
|
||||||
if (!hasbucket) {
|
if (!hasbucket) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "bucket"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerChat(final AsyncPlayerChatEvent event) {
|
public void onPlayerChat(final AsyncPlayerChatEvent event) {
|
||||||
final String pname = event.getPlayer().getName();
|
final String pname = event.getPlayer().getName();
|
||||||
if (chatenabled && playerToggleChat.contains(pname)) {
|
if (chatenabled && playerToggleChat.contains(pname)) {
|
||||||
final String area = currentRes.get(pname);
|
final String area = currentRes.get(pname);
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
final ChatChannel channel = plugin.getChatManager().getChannel(area);
|
final ChatChannel channel = plugin.getChatManager().getChannel(area);
|
||||||
if (channel != null) {
|
if (channel != null) {
|
||||||
channel.chat(pname, event.getMessage());
|
channel.chat(pname, event.getMessage());
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerInteract(final PlayerInteractEvent event) {
|
public void onPlayerInteract(final PlayerInteractEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final Material heldItem = player.getItemInHand().getType();
|
final Material heldItem = player.getItemInHand().getType();
|
||||||
final Block block = event.getClickedBlock();
|
final Block block = event.getClickedBlock();
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Material mat = block.getType();
|
final Material mat = block.getType();
|
||||||
if (!((isContainer(mat, block) || isCanUseEntity_RClickOnly(mat, block)) && event.getAction() == Action.RIGHT_CLICK_BLOCK || isCanUseEntity_BothClick(mat, block)
|
if (!((isContainer(mat, block) || isCanUseEntity_RClickOnly(mat, block)) && event.getAction() == Action.RIGHT_CLICK_BLOCK || isCanUseEntity_BothClick(mat, block)
|
||||||
|| event.getAction() == Action.PHYSICAL)) {
|
|| event.getAction() == Action.PHYSICAL)) {
|
||||||
final int typeId = player.getItemInHand().getTypeId();
|
final int typeId = player.getItemInHand().getTypeId();
|
||||||
if (typeId != plugin.getConfigManager().getSelectionTooldID() && typeId != plugin.getConfigManager().getInfoToolID() && typeId != 351 && typeId != 416) {
|
if (typeId != plugin.getConfigManager().getSelectionTooldID() && typeId != plugin.getConfigManager().getInfoToolID() && typeId != 351 && typeId != 416) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FlagPermissions perms = plugin.getPermsByLocForPlayer(block.getLocation(), player);
|
FlagPermissions perms = plugin.getPermsByLocForPlayer(block.getLocation(), player);
|
||||||
final String world = player.getWorld().getName();
|
final String world = player.getWorld().getName();
|
||||||
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||||
final boolean resadmin = plugin.isResAdminOn(player);
|
final boolean resadmin = plugin.isResAdminOn(player);
|
||||||
if (event.getAction() == Action.PHYSICAL) {
|
if (event.getAction() == Action.PHYSICAL) {
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
|
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
|
||||||
final boolean haspressure = perms.playerHas(player.getName(), world, "pressure", hasuse);
|
final boolean haspressure = perms.playerHas(player.getName(), world, "pressure", hasuse);
|
||||||
if ((!hasuse && !haspressure || !haspressure) && (mat == Material.STONE_PLATE || mat == Material.WOOD_PLATE)) {
|
if ((!hasuse && !haspressure || !haspressure) && (mat == Material.STONE_PLATE || mat == Material.WOOD_PLATE)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!perms.playerHas(player.getName(), world, "trample", perms.playerHas(player.getName(), world, "build", true)) && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
|
if (!perms.playerHas(player.getName(), world, "trample", perms.playerHas(player.getName(), world, "build", true)) && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!resadmin && !plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
|
if (!resadmin && !plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getSelectionTooldID()) {
|
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getSelectionTooldID()) {
|
||||||
final Plugin wep = Bukkit.getPluginManager().getPlugin("WorldEdit");
|
final Plugin wep = Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||||
if (wep != null) {
|
if (wep != null) {
|
||||||
if (((WorldEditPlugin) wep).getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
if (((WorldEditPlugin) wep).getConfig().getInt("wand-item") == plugin.getConfigManager().getSelectionTooldID()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||||
if (player.hasPermission("residence.select") || player.hasPermission("residence.create") && !player.isPermissionSet("residence.select")
|
if (player.hasPermission("residence.select") || player.hasPermission("residence.create") && !player.isPermissionSet("residence.select")
|
||||||
|| group.canCreateResidences() && !player.isPermissionSet("residence.create") && !player.isPermissionSet("residence.select") || resadmin) {
|
|| group.canCreateResidences() && !player.isPermissionSet("residence.create") && !player.isPermissionSet("residence.select") || resadmin) {
|
||||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
final Location loc = block.getLocation();
|
final Location loc = block.getLocation();
|
||||||
plugin.getSelectionManager().placeLoc1(player, loc);
|
plugin.getSelectionManager().placeLoc1(player, loc);
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Primary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Primary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
|
||||||
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
|
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
final Location loc = block.getLocation();
|
final Location loc = block.getLocation();
|
||||||
plugin.getSelectionManager().placeLoc2(player, loc);
|
plugin.getSelectionManager().placeLoc2(player, loc);
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Secondary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectPoint", plugin.getLanguage().getPhrase("Secondary")) + ChatColor.RED + "(" + loc.getBlockX() + ","
|
||||||
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
|
+ loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getInfoToolID()) {
|
if (player.getItemInHand().getTypeId() == plugin.getConfigManager().getInfoToolID()) {
|
||||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
final Location loc = block.getLocation();
|
final Location loc = block.getLocation();
|
||||||
final String res = plugin.getResidenceManager().getNameByLoc(loc);
|
final String res = plugin.getResidenceManager().getNameByLoc(loc);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
plugin.getResidenceManager().printAreaInfo(res, player);
|
plugin.getResidenceManager().printAreaInfo(res, player);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else {
|
} else {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(plugin.getLanguage().getPhrase("NoResHere"));
|
player.sendMessage(plugin.getLanguage().getPhrase("NoResHere"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
if (heldItem != null) {
|
if (heldItem != null) {
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
if (player.getItemInHand().getTypeId() == 351) {
|
if (player.getItemInHand().getTypeId() == 351) {
|
||||||
if (player.getItemInHand().getData().getData() == 15 && block.getType() == Material.GRASS || player.getItemInHand().getData().getData() == 3 && block.getTypeId() == 17
|
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)) {
|
&& (block.getData() == 3 || block.getData() == 7 || block.getData() == 11 || block.getData() == 15)) {
|
||||||
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
|
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
|
||||||
if (!perms.playerHas(player.getName(), world, "build", true)) {
|
if (!perms.playerHas(player.getName(), world, "build", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plugin.isGt1_8()) {
|
if (plugin.isGt1_8()) {
|
||||||
if (heldItem == Material.ARMOR_STAND) {
|
if (heldItem == Material.ARMOR_STAND) {
|
||||||
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
|
perms = plugin.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
|
||||||
if (!perms.playerHas(player.getName(), world, "build", true)) {
|
if (!perms.playerHas(player.getName(), world, "build", true)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isContainer(mat, block) || isCanUseEntity(mat, block)) {
|
if (isContainer(mat, block) || isCanUseEntity(mat, block)) {
|
||||||
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
|
final boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
|
||||||
for (final Entry<Material, String> checkMat : FlagPermissions.getMaterialUseFlagList().entrySet()) {
|
for (final Entry<Material, String> checkMat : FlagPermissions.getMaterialUseFlagList().entrySet()) {
|
||||||
if (mat == checkMat.getKey()) {
|
if (mat == checkMat.getKey()) {
|
||||||
if (!perms.playerHas(player.getName(), world, checkMat.getValue(), hasuse)) {
|
if (!perms.playerHas(player.getName(), world, checkMat.getValue(), hasuse)) {
|
||||||
if (hasuse || checkMat.getValue().equals("container")) {
|
if (hasuse || checkMat.getValue().equals("container")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", checkMat.getValue()));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", checkMat.getValue()));
|
||||||
} else {
|
} else {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plugin.getConfigManager().getCustomContainers().contains(block.getTypeId())) {
|
if (plugin.getConfigManager().getCustomContainers().contains(block.getTypeId())) {
|
||||||
if (!perms.playerHas(player.getName(), world, "container", hasuse)) {
|
if (!perms.playerHas(player.getName(), world, "container", hasuse)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())) {
|
if (plugin.getConfigManager().getCustomBothClick().contains(block.getTypeId())) {
|
||||||
if (!hasuse) {
|
if (!hasuse) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
if (plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId())) {
|
if (plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId())) {
|
||||||
if (!hasuse) {
|
if (!hasuse) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "use"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerInteractEntity(final PlayerInteractEntityEvent event) {
|
public void onPlayerInteractEntity(final PlayerInteractEntityEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (plugin.isResAdminOn(player)) {
|
if (plugin.isResAdminOn(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Entity ent = event.getRightClicked();
|
final Entity ent = event.getRightClicked();
|
||||||
/* Trade */
|
/* Trade */
|
||||||
if (ent.getType() == EntityType.VILLAGER) {
|
if (ent.getType() == EntityType.VILLAGER) {
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getPlayer().getLocation());
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(event.getPlayer().getLocation());
|
||||||
|
|
||||||
if (res != null && !res.getPermissions().playerHas(player.getName(), "trade", true)) {
|
if (res != null && !res.getPermissions().playerHas(player.getName(), "trade", true)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Container - ItemFrame protection */
|
/* Container - ItemFrame protection */
|
||||||
final Material heldItem = player.getItemInHand().getType();
|
final Material heldItem = player.getItemInHand().getType();
|
||||||
if (!(ent instanceof Hanging)) {
|
if (!(ent instanceof Hanging)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Hanging hanging = (Hanging) ent;
|
final Hanging hanging = (Hanging) ent;
|
||||||
if (hanging.getType() != EntityType.ITEM_FRAME) {
|
if (hanging.getType() != EntityType.ITEM_FRAME) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(ent.getLocation(), player);
|
final FlagPermissions perms = plugin.getPermsByLocForPlayer(ent.getLocation(), player);
|
||||||
final String world = player.getWorld().getName();
|
final String world = player.getWorld().getName();
|
||||||
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
final String permgroup = plugin.getPermissionManager().getGroupNameByPlayer(player);
|
||||||
if (!plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
|
if (!plugin.getItemManager().isAllowed(heldItem, permgroup, world)) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("ItemBlacklisted"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!perms.playerHas(player.getName(), world, "container", perms.playerHas(player.getName(), world, "use", true))) {
|
if (!perms.playerHas(player.getName(), world, "container", perms.playerHas(player.getName(), world, "use", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
lastUpdate.put(player.getName(), 0L);
|
lastUpdate.put(player.getName(), 0L);
|
||||||
if (plugin.getPermissionManager().isResidenceAdmin(player)) {
|
if (plugin.getPermissionManager().isResidenceAdmin(player)) {
|
||||||
plugin.turnResAdminOn(player);
|
plugin.turnResAdminOn(player);
|
||||||
}
|
}
|
||||||
handleNewLocation(player, player.getLocation(), false);
|
handleNewLocation(player, player.getLocation(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerMove(final PlayerMoveEvent event) {
|
public void onPlayerMove(final PlayerMoveEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
if (!lastUpdate.containsKey(player.getName())) {
|
if (!lastUpdate.containsKey(player.getName())) {
|
||||||
lastUpdate.put(player.getName(), now);
|
lastUpdate.put(player.getName(), now);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final long last = lastUpdate.get(player.getName());
|
final long last = lastUpdate.get(player.getName());
|
||||||
if (now - last < plugin.getConfigManager().getMinMoveUpdateInterval()) {
|
if (now - last < plugin.getConfigManager().getMinMoveUpdateInterval()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastUpdate.put(player.getName(), now);
|
lastUpdate.put(player.getName(), now);
|
||||||
if (event.getFrom().getWorld() == event.getTo().getWorld()) {
|
if (event.getFrom().getWorld() == event.getTo().getWorld()) {
|
||||||
if (event.getFrom().distance(event.getTo()) == 0) {
|
if (event.getFrom().distance(event.getTo()) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleNewLocation(player, event.getTo(), true);
|
handleNewLocation(player, event.getTo(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerQuit(final PlayerQuitEvent event) {
|
public void onPlayerQuit(final PlayerQuitEvent event) {
|
||||||
final String pname = event.getPlayer().getName();
|
final String pname = event.getPlayer().getName();
|
||||||
currentRes.remove(pname);
|
currentRes.remove(pname);
|
||||||
lastUpdate.remove(pname);
|
lastUpdate.remove(pname);
|
||||||
lastOutsideLoc.remove(pname);
|
lastOutsideLoc.remove(pname);
|
||||||
plugin.getChatManager().removeFromChannel(pname);
|
plugin.getChatManager().removeFromChannel(pname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerSpawn(final PlayerRespawnEvent event) {
|
public void onPlayerSpawn(final PlayerRespawnEvent event) {
|
||||||
Location loc = event.getRespawnLocation();
|
Location loc = event.getRespawnLocation();
|
||||||
final Boolean bed = event.isBedSpawn();
|
final Boolean bed = event.isBedSpawn();
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (res.getPermissions().playerHas(player.getName(), "move", true)) {
|
if (res.getPermissions().playerHas(player.getName(), "move", true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (bed) {
|
if (bed) {
|
||||||
loc = player.getWorld().getSpawnLocation();
|
loc = player.getWorld().getSpawnLocation();
|
||||||
}
|
}
|
||||||
res = plugin.getResidenceManager().getByLoc(loc);
|
res = plugin.getResidenceManager().getByLoc(loc);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (!res.getPermissions().playerHas(player.getName(), "move", true)) {
|
if (!res.getPermissions().playerHas(player.getName(), "move", true)) {
|
||||||
loc = res.getOutsideFreeLoc(loc);
|
loc = res.getOutsideFreeLoc(loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoSpawn"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoSpawn"));
|
||||||
event.setRespawnLocation(loc);
|
event.setRespawnLocation(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerTeleport(final PlayerTeleportEvent event) {
|
public void onPlayerTeleport(final PlayerTeleportEvent event) {
|
||||||
final Location loc = event.getTo();
|
final Location loc = event.getTo();
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(loc);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (plugin.isResAdminOn(player) || ((res.getPermissions().playerHas(player.getName(), "tp", true) || player.hasPermission("residence.admin.tp"))
|
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")))) {
|
&& (res.getPermissions().playerHas(player.getName(), "move", true) || player.hasPermission("residence.admin.move")))) {
|
||||||
handleNewLocation(player, loc, false);
|
handleNewLocation(player, loc, false);
|
||||||
} else {
|
} else {
|
||||||
final String areaname = res.getName();
|
final String areaname = res.getName();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("TeleportDeny", areaname));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("TeleportDeny", areaname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tooglePlayerResidenceChat(final Player player) {
|
public void tooglePlayerResidenceChat(final Player player) {
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
if (playerToggleChat.contains(pname)) {
|
if (playerToggleChat.contains(pname)) {
|
||||||
playerToggleChat.remove(pname);
|
playerToggleChat.remove(pname);
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "OFF" + ChatColor.YELLOW + "!"));
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "OFF" + ChatColor.YELLOW + "!"));
|
||||||
} else {
|
} else {
|
||||||
playerToggleChat.add(pname);
|
playerToggleChat.add(pname);
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "ON" + ChatColor.YELLOW + "!"));
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("ResidenceChat", ChatColor.RED + "ON" + ChatColor.YELLOW + "!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCanUseEntity(final Material mat, final Block block) {
|
private boolean isCanUseEntity(final Material mat, final Block block) {
|
||||||
return isCanUseEntity_BothClick(mat, block) || isCanUseEntity_RClickOnly(mat, block);
|
return isCanUseEntity_BothClick(mat, block) || isCanUseEntity_RClickOnly(mat, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCanUseEntity_BothClick(final Material mat, final Block 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
|
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())
|
|| 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
|
|| (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.SPRUCE_FENCE_GATE || mat == Material.BIRCH_FENCE_GATE || mat == Material.JUNGLE_FENCE_GATE || mat == Material.ACACIA_FENCE_GATE
|
||||||
|| mat == Material.DARK_OAK_FENCE_GATE));
|
|| mat == Material.DARK_OAK_FENCE_GATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCanUseEntity_RClickOnly(final Material mat, final Block block) {
|
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
|
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.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());
|
|| mat == Material.BREWING_STAND || mat == Material.ENCHANTMENT_TABLE || plugin.getConfigManager().getCustomRightClick().contains(block.getTypeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isContainer(final Material mat, final Block block) {
|
private boolean isContainer(final Material mat, final Block block) {
|
||||||
return FlagPermissions.getMaterialUseFlagList().containsKey(mat) && FlagPermissions.getMaterialUseFlagList().get(mat).equals("container")
|
return FlagPermissions.getMaterialUseFlagList().containsKey(mat) && FlagPermissions.getMaterialUseFlagList().get(mat).equals("container")
|
||||||
|| plugin.getConfigManager().getCustomContainers().contains(block.getTypeId());
|
|| plugin.getConfigManager().getCustomContainers().contains(block.getTypeId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,31 +23,31 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class ResidencePlayerListener_1_8 implements Listener {
|
public class ResidencePlayerListener_1_8 implements Listener {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public ResidencePlayerListener_1_8(final ResidenceMain plugin) {
|
public ResidencePlayerListener_1_8(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent event) {
|
public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (plugin.isResAdminOn(player)) {
|
if (plugin.isResAdminOn(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Entity ent = event.getRightClicked();
|
final Entity ent = event.getRightClicked();
|
||||||
if (ent.getType() != EntityType.ARMOR_STAND) {
|
if (ent.getType() != EntityType.ARMOR_STAND) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final FlagPermissions perms = plugin.getPermsByLocForPlayer(ent.getLocation(), player);
|
final FlagPermissions perms = plugin.getPermsByLocForPlayer(ent.getLocation(), player);
|
||||||
final String world = player.getWorld().getName();
|
final String world = player.getWorld().getName();
|
||||||
|
|
||||||
if (!perms.playerHas(player.getName(), world, "container", perms.playerHas(player.getName(), world, "use", true))) {
|
if (!perms.playerHas(player.getName(), world, "container", perms.playerHas(player.getName(), world, "use", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("FlagDeny", "container"));
|
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;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class ResidenceBugFix implements Listener {
|
public class ResidenceBugFix implements Listener {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public ResidenceBugFix(final ResidenceMain plugin) {
|
public ResidenceBugFix(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
plugin.getLogger().info("防刷甘蔗补丁已加载...");
|
plugin.getLogger().info("防刷甘蔗补丁已加载...");
|
||||||
plugin.getLogger().info("防刷单元补丁已加载...");
|
plugin.getLogger().info("防刷单元补丁已加载...");
|
||||||
plugin.getLogger().info("防刷铁轨补丁已加载...");
|
plugin.getLogger().info("防刷铁轨补丁已加载...");
|
||||||
plugin.getLogger().info("防刷生物补丁已加载...");
|
plugin.getLogger().info("防刷生物补丁已加载...");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getPlaceBlock(final PlayerInteractEvent e) {
|
public Block getPlaceBlock(final PlayerInteractEvent e) {
|
||||||
final Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
final ItemStack it = p.getItemInHand();
|
final ItemStack it = p.getItemInHand();
|
||||||
if (it == null || it.getType() == Material.AIR) {
|
if (it == null || it.getType() == Material.AIR) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final Block b = e.getClickedBlock();
|
final Block b = e.getClickedBlock();
|
||||||
final BlockFace bf = e.getBlockFace();
|
final BlockFace bf = e.getBlockFace();
|
||||||
if (bf == null) {
|
if (bf == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return b.getRelative(bf, 1);
|
return b.getRelative(bf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getPlaceBlockDown(final PlayerInteractEvent e) {
|
public Block getPlaceBlockDown(final PlayerInteractEvent e) {
|
||||||
final Block b = this.getPlaceBlock(e);
|
final Block b = this.getPlaceBlock(e);
|
||||||
return b.getRelative(BlockFace.DOWN);
|
return b.getRelative(BlockFace.DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPerm(final ClaimedResidence res, final Player p) {
|
public boolean hasPerm(final ClaimedResidence res, final Player p) {
|
||||||
final FlagPermissions perms = res.getPermissions();
|
final FlagPermissions perms = res.getPermissions();
|
||||||
final String world = p.getWorld().getName();
|
final String world = p.getWorld().getName();
|
||||||
return perms.playerHas(p.getName(), world, "place", perms.playerHas(p.getName(), world, "build", false));
|
return perms.playerHas(p.getName(), world, "place", perms.playerHas(p.getName(), world, "build", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockPlace(final PlayerInteractEvent e) {
|
public void onBlockPlace(final PlayerInteractEvent e) {
|
||||||
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.PHYSICAL) {
|
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.PHYSICAL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final Block b = this.getPlaceBlockDown(e);
|
final Block b = this.getPlaceBlockDown(e);
|
||||||
if (b == null) {
|
if (b == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
final ItemStack it = p.getItemInHand();
|
final ItemStack it = p.getItemInHand();
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(b.getLocation());
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(b.getLocation());
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((it.getType() == Material.PUMPKIN && (b.getType() == Material.SNOW_BLOCK || b.getType() == Material.IRON_BLOCK))
|
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)) {
|
|| (it.getType() == Material.SKULL_ITEM && b.getType() == Material.SOUL_SAND)) {
|
||||||
if (!hasPerm(res, p)) {
|
if (!hasPerm(res, p)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许放置!");
|
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许放置!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception e2) {
|
} catch (final Exception e2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlace(final PlayerInteractEvent e) {
|
public void onPlace(final PlayerInteractEvent e) {
|
||||||
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.PHYSICAL) {
|
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.PHYSICAL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
final ItemStack it = p.getItemInHand();
|
final ItemStack it = p.getItemInHand();
|
||||||
if (it == null || it.getType() == Material.AIR) {
|
if (it == null || it.getType() == Material.AIR) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Block b = e.getClickedBlock();
|
final Block b = e.getClickedBlock();
|
||||||
final BlockFace bf = e.getBlockFace();
|
final BlockFace bf = e.getBlockFace();
|
||||||
if (bf == null || bf != BlockFace.UP) {
|
if (bf == null || bf != BlockFace.UP) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Block b1 = b.getRelative(bf, 1);
|
final Block b1 = b.getRelative(bf, 1);
|
||||||
final Block b2 = b.getRelative(bf, 2);
|
final Block b2 = b.getRelative(bf, 2);
|
||||||
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(b1.getLocation());
|
final ClaimedResidence res = plugin.getResidenceManager().getByLoc(b1.getLocation());
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (b1.getType() != Material.AIR && b1.getType() != Material.TORCH && b2.getType() == Material.AIR && checkAround(b2)) {
|
if (b1.getType() != Material.AIR && b1.getType() != Material.TORCH && b2.getType() == Material.AIR && checkAround(b2)) {
|
||||||
if (!hasPerm(res, p)) {
|
if (!hasPerm(res, p)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许此操作!");
|
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许此操作!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception e2) {
|
} catch (final Exception e2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onRailsPhysics(final BlockPhysicsEvent e) {
|
public void onRailsPhysics(final BlockPhysicsEvent e) {
|
||||||
final Material mat = e.getChangedType();
|
final Material mat = e.getChangedType();
|
||||||
if (mat == Material.RAILS || mat == Material.POWERED_RAIL || mat == Material.ACTIVATOR_RAIL || mat == Material.DETECTOR_RAIL) {
|
if (mat == Material.RAILS || mat == Material.POWERED_RAIL || mat == Material.ACTIVATOR_RAIL || mat == Material.DETECTOR_RAIL) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onSugarCanePhysics(final BlockPhysicsEvent e) {
|
public void onSugarCanePhysics(final BlockPhysicsEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAround(final Block b) {
|
private boolean checkAround(final Block b) {
|
||||||
final Block be = b.getRelative(BlockFace.EAST);
|
final Block be = b.getRelative(BlockFace.EAST);
|
||||||
final Block bw = b.getRelative(BlockFace.WEST);
|
final Block bw = b.getRelative(BlockFace.WEST);
|
||||||
final Block bn = b.getRelative(BlockFace.NORTH);
|
final Block bn = b.getRelative(BlockFace.NORTH);
|
||||||
final Block bs = b.getRelative(BlockFace.SOUTH);
|
final Block bs = b.getRelative(BlockFace.SOUTH);
|
||||||
return (be.getType() != Material.AIR || bw.getType() != Material.AIR || bn.getType() != Material.AIR || bs.getType() != Material.AIR);
|
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
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
private boolean enforceAreaInsideArea;
|
private boolean enforceAreaInsideArea;
|
||||||
protected boolean actionBar;
|
protected boolean actionBar;
|
||||||
protected boolean adminOps;
|
protected boolean adminOps;
|
||||||
protected boolean adminsOnly;
|
protected boolean adminsOnly;
|
||||||
protected boolean allowEmptyResidences;
|
protected boolean allowEmptyResidences;
|
||||||
protected int autoSaveInt;
|
protected int autoSaveInt;
|
||||||
protected ChatColor chatColor;
|
protected ChatColor chatColor;
|
||||||
protected boolean chatEnable;
|
protected boolean chatEnable;
|
||||||
protected List<Integer> customBothClick;
|
protected List<Integer> customBothClick;
|
||||||
protected List<Integer> customContainers;
|
protected List<Integer> customContainers;
|
||||||
protected List<Integer> customRightClick;
|
protected List<Integer> customRightClick;
|
||||||
protected String defaultGroup;
|
protected String defaultGroup;
|
||||||
protected String economySystem;
|
protected String economySystem;
|
||||||
protected boolean enableDebug;
|
protected boolean enableDebug;
|
||||||
protected boolean enableEconomy;
|
protected boolean enableEconomy;
|
||||||
protected boolean enableLeaseMoneyAccount;
|
protected boolean enableLeaseMoneyAccount;
|
||||||
protected boolean enableRentSystem;
|
protected boolean enableRentSystem;
|
||||||
protected boolean flagsInherit;
|
protected boolean flagsInherit;
|
||||||
protected FlagPermissions globalCreatorDefaults;
|
protected FlagPermissions globalCreatorDefaults;
|
||||||
protected Map<String, FlagPermissions> globalGroupDefaults;
|
protected Map<String, FlagPermissions> globalGroupDefaults;
|
||||||
protected FlagPermissions globalResidenceDefaults;
|
protected FlagPermissions globalResidenceDefaults;
|
||||||
protected int infoToolId;
|
protected int infoToolId;
|
||||||
protected String language;
|
protected String language;
|
||||||
protected boolean leaseAutoRenew;
|
protected boolean leaseAutoRenew;
|
||||||
protected int leaseCheckInterval;
|
protected int leaseCheckInterval;
|
||||||
protected boolean legacyperms;
|
protected boolean legacyperms;
|
||||||
protected int minMoveUpdate;
|
protected int minMoveUpdate;
|
||||||
protected String multiworldPlugin;
|
protected String multiworldPlugin;
|
||||||
protected String namefix;
|
protected String namefix;
|
||||||
protected ResidenceMain plugin;
|
protected ResidenceMain plugin;
|
||||||
protected boolean preventBuildInRent;
|
protected boolean preventBuildInRent;
|
||||||
protected int rentCheckInterval;
|
protected int rentCheckInterval;
|
||||||
protected int selectionToolId;
|
protected int selectionToolId;
|
||||||
protected boolean showIntervalMessages;
|
protected boolean showIntervalMessages;
|
||||||
protected boolean spoutEnable;
|
protected boolean spoutEnable;
|
||||||
protected boolean stopOnSaveError;
|
protected boolean stopOnSaveError;
|
||||||
protected boolean useLeases;
|
protected boolean useLeases;
|
||||||
|
|
||||||
public ConfigManager(final ResidenceMain plugin) {
|
public ConfigManager(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
globalCreatorDefaults = new FlagPermissions();
|
globalCreatorDefaults = new FlagPermissions();
|
||||||
globalResidenceDefaults = new FlagPermissions();
|
globalResidenceDefaults = new FlagPermissions();
|
||||||
globalGroupDefaults = new HashMap<String, FlagPermissions>();
|
globalGroupDefaults = new HashMap<String, FlagPermissions>();
|
||||||
this.load(plugin.getConfig());
|
this.load(plugin.getConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean allowAdminsOnly() {
|
public boolean allowAdminsOnly() {
|
||||||
return adminsOnly;
|
return adminsOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean allowEmptyResidences() {
|
public boolean allowEmptyResidences() {
|
||||||
return allowEmptyResidences;
|
return allowEmptyResidences;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean autoRenewLeases() {
|
public boolean autoRenewLeases() {
|
||||||
return leaseAutoRenew;
|
return leaseAutoRenew;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean chatEnabled() {
|
public boolean chatEnabled() {
|
||||||
return chatEnable;
|
return chatEnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean debugEnabled() {
|
public boolean debugEnabled() {
|
||||||
return enableDebug;
|
return enableDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enabledRentSystem() {
|
public boolean enabledRentSystem() {
|
||||||
return enableRentSystem && enableEconomy();
|
return enableRentSystem && enableEconomy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enableEconomy() {
|
public boolean enableEconomy() {
|
||||||
return enableEconomy && plugin.getEconomyManager() != null;
|
return enableEconomy && plugin.getEconomyManager() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enableLeaseMoneyAccount() {
|
public boolean enableLeaseMoneyAccount() {
|
||||||
return enableLeaseMoneyAccount;
|
return enableLeaseMoneyAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enableSpout() {
|
public boolean enableSpout() {
|
||||||
return spoutEnable;
|
return spoutEnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean flagsInherit() {
|
public boolean flagsInherit() {
|
||||||
return flagsInherit;
|
return flagsInherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAutoSaveInterval() {
|
public int getAutoSaveInterval() {
|
||||||
return autoSaveInt;
|
return autoSaveInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatColor getChatColor() {
|
public ChatColor getChatColor() {
|
||||||
return chatColor;
|
return chatColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getCustomBothClick() {
|
public List<Integer> getCustomBothClick() {
|
||||||
return customBothClick;
|
return customBothClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getCustomContainers() {
|
public List<Integer> getCustomContainers() {
|
||||||
return customContainers;
|
return customContainers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getCustomRightClick() {
|
public List<Integer> getCustomRightClick() {
|
||||||
return customRightClick;
|
return customRightClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDefaultGroup() {
|
public String getDefaultGroup() {
|
||||||
return defaultGroup;
|
return defaultGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEconomySystem() {
|
public String getEconomySystem() {
|
||||||
return economySystem;
|
return economySystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getEnforceAreaInsideArea() {
|
public boolean getEnforceAreaInsideArea() {
|
||||||
return enforceAreaInsideArea;
|
return enforceAreaInsideArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlagPermissions getGlobalCreatorDefaultFlags() {
|
public FlagPermissions getGlobalCreatorDefaultFlags() {
|
||||||
return globalCreatorDefaults;
|
return globalCreatorDefaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, FlagPermissions> getGlobalGroupDefaultFlags() {
|
public Map<String, FlagPermissions> getGlobalGroupDefaultFlags() {
|
||||||
return globalGroupDefaults;
|
return globalGroupDefaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlagPermissions getGlobalResidenceDefaultFlags() {
|
public FlagPermissions getGlobalResidenceDefaultFlags() {
|
||||||
return globalResidenceDefaults;
|
return globalResidenceDefaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInfoToolID() {
|
public int getInfoToolID() {
|
||||||
return infoToolId;
|
return infoToolId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLanguage() {
|
public String getLanguage() {
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLeaseCheckInterval() {
|
public int getLeaseCheckInterval() {
|
||||||
return leaseCheckInterval;
|
return leaseCheckInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMinMoveUpdateInterval() {
|
public int getMinMoveUpdateInterval() {
|
||||||
return minMoveUpdate;
|
return minMoveUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMultiworldPlugin() {
|
public String getMultiworldPlugin() {
|
||||||
return multiworldPlugin;
|
return multiworldPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getOpsAreAdmins() {
|
public boolean getOpsAreAdmins() {
|
||||||
return adminOps;
|
return adminOps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRentCheckInterval() {
|
public int getRentCheckInterval() {
|
||||||
return rentCheckInterval;
|
return rentCheckInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResidenceNameRegex() {
|
public String getResidenceNameRegex() {
|
||||||
return namefix;
|
return namefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSelectionTooldID() {
|
public int getSelectionTooldID() {
|
||||||
return selectionToolId;
|
return selectionToolId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean preventRentModify() {
|
public boolean preventRentModify() {
|
||||||
return preventBuildInRent;
|
return preventBuildInRent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean showIntervalMessages() {
|
public boolean showIntervalMessages() {
|
||||||
return showIntervalMessages;
|
return showIntervalMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean stopOnSaveError() {
|
public boolean stopOnSaveError() {
|
||||||
return stopOnSaveError;
|
return stopOnSaveError;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean useActionBar() {
|
public boolean useActionBar() {
|
||||||
return actionBar;
|
return actionBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean useLeases() {
|
public boolean useLeases() {
|
||||||
return useLeases;
|
return useLeases;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean useLegacyPermissions() {
|
public boolean useLegacyPermissions() {
|
||||||
return legacyperms;
|
return legacyperms;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private void load(final FileConfiguration config) {
|
private void load(final FileConfiguration config) {
|
||||||
try {
|
try {
|
||||||
if (!config.isConfigurationSection("Global")) {
|
if (!config.isConfigurationSection("Global")) {
|
||||||
plugin.getLogger().warning("配置文件主键丢失 恢复默认配置文件!");
|
plugin.getLogger().warning("配置文件主键丢失 恢复默认配置文件!");
|
||||||
plugin.getConfig().addDefaults(new FileConfig(plugin));
|
plugin.getConfig().addDefaults(new FileConfig(plugin));
|
||||||
}
|
}
|
||||||
defaultGroup = config.getString("Global.DefaultGroup", "default").toLowerCase();
|
defaultGroup = config.getString("Global.DefaultGroup", "default").toLowerCase();
|
||||||
adminsOnly = config.getBoolean("Global.AdminOnlyCommands", false);
|
adminsOnly = config.getBoolean("Global.AdminOnlyCommands", false);
|
||||||
useLeases = config.getBoolean("Global.UseLeaseSystem", false);
|
useLeases = config.getBoolean("Global.UseLeaseSystem", false);
|
||||||
leaseAutoRenew = config.getBoolean("Global.LeaseAutoRenew", true);
|
leaseAutoRenew = config.getBoolean("Global.LeaseAutoRenew", true);
|
||||||
enableEconomy = config.getBoolean("Global.EnableEconomy", false);
|
enableEconomy = config.getBoolean("Global.EnableEconomy", false);
|
||||||
economySystem = config.getString("Global.EconomySystem", "iConomy");
|
economySystem = config.getString("Global.EconomySystem", "iConomy");
|
||||||
infoToolId = config.getInt("Global.InfoToolId", Material.STRING.getId());
|
infoToolId = config.getInt("Global.InfoToolId", Material.STRING.getId());
|
||||||
selectionToolId = config.getInt("Global.SelectionToolId", Material.WOOD_AXE.getId());
|
selectionToolId = config.getInt("Global.SelectionToolId", Material.WOOD_AXE.getId());
|
||||||
adminOps = config.getBoolean("Global.AdminOPs", true);
|
adminOps = config.getBoolean("Global.AdminOPs", true);
|
||||||
multiworldPlugin = config.getString("Global.MultiWorldPlugin");
|
multiworldPlugin = config.getString("Global.MultiWorldPlugin");
|
||||||
enableRentSystem = config.getBoolean("Global.EnableRentSystem", false);
|
enableRentSystem = config.getBoolean("Global.EnableRentSystem", false);
|
||||||
rentCheckInterval = config.getInt("Global.RentCheckInterval", 10);
|
rentCheckInterval = config.getInt("Global.RentCheckInterval", 10);
|
||||||
leaseCheckInterval = config.getInt("Global.LeaseCheckInterval", 10);
|
leaseCheckInterval = config.getInt("Global.LeaseCheckInterval", 10);
|
||||||
autoSaveInt = config.getInt("Global.SaveInterval", 10);
|
autoSaveInt = config.getInt("Global.SaveInterval", 10);
|
||||||
flagsInherit = config.getBoolean("Global.ResidenceFlagsInherit", false);
|
flagsInherit = config.getBoolean("Global.ResidenceFlagsInherit", false);
|
||||||
minMoveUpdate = config.getInt("Global.MoveCheckInterval", 500);
|
minMoveUpdate = config.getInt("Global.MoveCheckInterval", 500);
|
||||||
chatEnable = config.getBoolean("Global.ResidenceChatEnable", true);
|
chatEnable = config.getBoolean("Global.ResidenceChatEnable", true);
|
||||||
actionBar = config.getBoolean("Global.UseActionBar", true);
|
actionBar = config.getBoolean("Global.UseActionBar", true);
|
||||||
enforceAreaInsideArea = config.getBoolean("Global.EnforceAreaInsideArea", false);
|
enforceAreaInsideArea = config.getBoolean("Global.EnforceAreaInsideArea", false);
|
||||||
language = config.getString("Global.Language", "English");
|
language = config.getString("Global.Language", "English");
|
||||||
globalCreatorDefaults = FlagPermissions.parseFromConfigNode("CreatorDefault", config.getConfigurationSection("Global"));
|
globalCreatorDefaults = FlagPermissions.parseFromConfigNode("CreatorDefault", config.getConfigurationSection("Global"));
|
||||||
globalResidenceDefaults = FlagPermissions.parseFromConfigNode("ResidenceDefault", config.getConfigurationSection("Global"));
|
globalResidenceDefaults = FlagPermissions.parseFromConfigNode("ResidenceDefault", config.getConfigurationSection("Global"));
|
||||||
preventBuildInRent = config.getBoolean("Global.PreventRentModify", true);
|
preventBuildInRent = config.getBoolean("Global.PreventRentModify", true);
|
||||||
stopOnSaveError = config.getBoolean("Global.StopOnSaveFault", true);
|
stopOnSaveError = config.getBoolean("Global.StopOnSaveFault", true);
|
||||||
legacyperms = config.getBoolean("Global.LegacyPermissions", false);
|
legacyperms = config.getBoolean("Global.LegacyPermissions", false);
|
||||||
namefix = config.getString("Global.ResidenceNameRegex", "[^A-Za-z0-9\\u4e00-\\u9fa5\\-\\_]");// "[^a-zA-Z0-9\\-\\_]"
|
namefix = config.getString("Global.ResidenceNameRegex", "[^A-Za-z0-9\\u4e00-\\u9fa5\\-\\_]");// "[^a-zA-Z0-9\\-\\_]"
|
||||||
showIntervalMessages = config.getBoolean("Global.ShowIntervalMessages", false);
|
showIntervalMessages = config.getBoolean("Global.ShowIntervalMessages", false);
|
||||||
spoutEnable = config.getBoolean("Global.EnableSpout", false);
|
spoutEnable = config.getBoolean("Global.EnableSpout", false);
|
||||||
enableLeaseMoneyAccount = config.getBoolean("Global.EnableLeaseMoneyAccount", true);
|
enableLeaseMoneyAccount = config.getBoolean("Global.EnableLeaseMoneyAccount", true);
|
||||||
enableDebug = config.getBoolean("Global.EnableDebug", false);
|
enableDebug = config.getBoolean("Global.EnableDebug", false);
|
||||||
customContainers = config.getIntegerList("Global.CustomContainers");
|
customContainers = config.getIntegerList("Global.CustomContainers");
|
||||||
customBothClick = config.getIntegerList("Global.CustomBothClick");
|
customBothClick = config.getIntegerList("Global.CustomBothClick");
|
||||||
customRightClick = config.getIntegerList("Global.CustomRightClick");
|
customRightClick = config.getIntegerList("Global.CustomRightClick");
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new RuntimeException("领地配置文件载入错误...", e);
|
throw new RuntimeException("领地配置文件载入错误...", e);
|
||||||
}
|
}
|
||||||
if (actionBar && plugin.isGt1_8()) {
|
if (actionBar && plugin.isGt1_8()) {
|
||||||
actionBar = ActionBar.init();
|
actionBar = ActionBar.init();
|
||||||
} else {
|
} else {
|
||||||
actionBar = false;
|
actionBar = false;
|
||||||
}
|
}
|
||||||
final ConfigurationSection node = config.getConfigurationSection("Global.GroupDefault");
|
final ConfigurationSection node = config.getConfigurationSection("Global.GroupDefault");
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
final Set<String> keys = node.getConfigurationSection(defaultGroup).getKeys(false);
|
final Set<String> keys = node.getConfigurationSection(defaultGroup).getKeys(false);
|
||||||
if (keys != null) {
|
if (keys != null) {
|
||||||
for (final String key : keys) {
|
for (final String key : keys) {
|
||||||
globalGroupDefaults.put(key, FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.GroupDefault")));
|
globalGroupDefaults.put(key, FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.GroupDefault")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
chatColor = ChatColor.valueOf(config.getString("Global.ResidenceChatColor", "DARK_PURPLE"));
|
chatColor = ChatColor.valueOf(config.getString("Global.ResidenceChatColor", "DARK_PURPLE"));
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
chatColor = ChatColor.DARK_PURPLE;
|
chatColor = ChatColor.DARK_PURPLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,18 +21,18 @@ import org.bukkit.entity.Wolf;
|
|||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class EntityManager {
|
public class EntityManager {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public EntityManager(final ResidenceMain plugin) {
|
public EntityManager(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAnimal(final Entity ent) {
|
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
|
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));
|
|| 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) {
|
public boolean isMonster(final Entity ent) {
|
||||||
return (ent instanceof Monster || ent instanceof Slime || ent instanceof Ghast);
|
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
|
* changed by inori 03/17/2012 line 91:limits MaxHeight changed to 255
|
||||||
*/
|
*/
|
||||||
public class PermissionGroup {
|
public class PermissionGroup {
|
||||||
protected boolean buyIgnoreLimits;
|
protected boolean buyIgnoreLimits;
|
||||||
protected boolean canBuy;
|
protected boolean canBuy;
|
||||||
protected boolean cancreate;
|
protected boolean cancreate;
|
||||||
protected boolean canSell;
|
protected boolean canSell;
|
||||||
protected double costperarea;
|
protected double costperarea;
|
||||||
protected Map<String, Boolean> creatorDefaultFlags;
|
protected Map<String, Boolean> creatorDefaultFlags;
|
||||||
protected String defaultEnterMessage;
|
protected String defaultEnterMessage;
|
||||||
protected String defaultLeaveMessage;
|
protected String defaultLeaveMessage;
|
||||||
protected FlagPermissions flagPerms;
|
protected FlagPermissions flagPerms;
|
||||||
protected Map<String, Map<String, Boolean>> groupDefaultFlags;
|
protected Map<String, Map<String, Boolean>> groupDefaultFlags;
|
||||||
protected String groupname;
|
protected String groupname;
|
||||||
protected boolean itemListAccess;
|
protected boolean itemListAccess;
|
||||||
protected boolean kick;
|
protected boolean kick;
|
||||||
protected int leaseGiveTime;
|
protected int leaseGiveTime;
|
||||||
protected int maxHeight;
|
protected int maxHeight;
|
||||||
protected int maxLeaseTime;
|
protected int maxLeaseTime;
|
||||||
protected int maxPhysical;
|
protected int maxPhysical;
|
||||||
protected int maxRentables;
|
protected int maxRentables;
|
||||||
protected int maxRents;
|
protected int maxRents;
|
||||||
protected boolean messageperms;
|
protected boolean messageperms;
|
||||||
protected int minHeight;
|
protected int minHeight;
|
||||||
protected double renewcostperarea;
|
protected double renewcostperarea;
|
||||||
protected Map<String, Boolean> residenceDefaultFlags;
|
protected Map<String, Boolean> residenceDefaultFlags;
|
||||||
protected int resmax;
|
protected int resmax;
|
||||||
protected boolean selectCommandAccess;
|
protected boolean selectCommandAccess;
|
||||||
protected int subzonedepth;
|
protected int subzonedepth;
|
||||||
protected boolean tpaccess;
|
protected boolean tpaccess;
|
||||||
protected boolean unstuck;
|
protected boolean unstuck;
|
||||||
protected int xmax;
|
protected int xmax;
|
||||||
protected int ymax;
|
protected int ymax;
|
||||||
protected int zmax;
|
protected int zmax;
|
||||||
|
|
||||||
public PermissionGroup(final String name) {
|
public PermissionGroup(final String name) {
|
||||||
flagPerms = new FlagPermissions();
|
flagPerms = new FlagPermissions();
|
||||||
creatorDefaultFlags = new HashMap<String, Boolean>();
|
creatorDefaultFlags = new HashMap<String, Boolean>();
|
||||||
residenceDefaultFlags = new HashMap<String, Boolean>();
|
residenceDefaultFlags = new HashMap<String, Boolean>();
|
||||||
groupDefaultFlags = new HashMap<String, Map<String, Boolean>>();
|
groupDefaultFlags = new HashMap<String, Map<String, Boolean>>();
|
||||||
groupname = name;
|
groupname = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PermissionGroup(final String name, final ConfigurationSection node) {
|
public PermissionGroup(final String name, final ConfigurationSection node) {
|
||||||
this(name);
|
this(name);
|
||||||
this.parseGroup(node);
|
this.parseGroup(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PermissionGroup(final String name, final ConfigurationSection node, final FlagPermissions parentFlagPerms) {
|
public PermissionGroup(final String name, final ConfigurationSection node, final FlagPermissions parentFlagPerms) {
|
||||||
this(name, node);
|
this(name, node);
|
||||||
flagPerms.setParent(parentFlagPerms);
|
flagPerms.setParent(parentFlagPerms);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean buyLandIgnoreLimits() {
|
public boolean buyLandIgnoreLimits() {
|
||||||
return buyIgnoreLimits;
|
return buyIgnoreLimits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBuyLand() {
|
public boolean canBuyLand() {
|
||||||
return canBuy;
|
return canBuy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canCreateResidences() {
|
public boolean canCreateResidences() {
|
||||||
return cancreate;
|
return cancreate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSellLand() {
|
public boolean canSellLand() {
|
||||||
return canSell;
|
return canSell;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSetEnterLeaveMessages() {
|
public boolean canSetEnterLeaveMessages() {
|
||||||
return messageperms;
|
return messageperms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getCostPerBlock() {
|
public double getCostPerBlock() {
|
||||||
return costperarea;
|
return costperarea;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Entry<String, Boolean>> getDefaultCreatorFlags() {
|
public Set<Entry<String, Boolean>> getDefaultCreatorFlags() {
|
||||||
return creatorDefaultFlags.entrySet();
|
return creatorDefaultFlags.entrySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDefaultEnterMessage() {
|
public String getDefaultEnterMessage() {
|
||||||
return defaultEnterMessage;
|
return defaultEnterMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Entry<String, Map<String, Boolean>>> getDefaultGroupFlags() {
|
public Set<Entry<String, Map<String, Boolean>>> getDefaultGroupFlags() {
|
||||||
return groupDefaultFlags.entrySet();
|
return groupDefaultFlags.entrySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDefaultLeaveMessage() {
|
public String getDefaultLeaveMessage() {
|
||||||
return defaultLeaveMessage;
|
return defaultLeaveMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Entry<String, Boolean>> getDefaultResidenceFlags() {
|
public Set<Entry<String, Boolean>> getDefaultResidenceFlags() {
|
||||||
return residenceDefaultFlags.entrySet();
|
return residenceDefaultFlags.entrySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLeaseGiveTime() {
|
public int getLeaseGiveTime() {
|
||||||
return leaseGiveTime;
|
return leaseGiveTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getLeaseRenewCost() {
|
public double getLeaseRenewCost() {
|
||||||
return renewcostperarea;
|
return renewcostperarea;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxHeight() {
|
public int getMaxHeight() {
|
||||||
return maxHeight;
|
return maxHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxLeaseTime() {
|
public int getMaxLeaseTime() {
|
||||||
return maxLeaseTime;
|
return maxLeaseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxPhysicalPerResidence() {
|
public int getMaxPhysicalPerResidence() {
|
||||||
return maxPhysical;
|
return maxPhysical;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxRentables() {
|
public int getMaxRentables() {
|
||||||
return maxRentables;
|
return maxRentables;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxRents() {
|
public int getMaxRents() {
|
||||||
return maxRents;
|
return maxRents;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxSubzoneDepth() {
|
public int getMaxSubzoneDepth() {
|
||||||
return subzonedepth;
|
return subzonedepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxX() {
|
public int getMaxX() {
|
||||||
return xmax;
|
return xmax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxY() {
|
public int getMaxY() {
|
||||||
return ymax;
|
return ymax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxZ() {
|
public int getMaxZ() {
|
||||||
return zmax;
|
return zmax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxZones() {
|
public int getMaxZones() {
|
||||||
return resmax;
|
return resmax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMinHeight() {
|
public int getMinHeight() {
|
||||||
return minHeight;
|
return minHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFlagAccess(final String flag) {
|
public boolean hasFlagAccess(final String flag) {
|
||||||
return flagPerms.has(flag, false);
|
return flagPerms.has(flag, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasKickAccess() {
|
public boolean hasKickAccess() {
|
||||||
return kick;
|
return kick;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTpAccess() {
|
public boolean hasTpAccess() {
|
||||||
return tpaccess;
|
return tpaccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasUnstuckAccess() {
|
public boolean hasUnstuckAccess() {
|
||||||
return unstuck;
|
return unstuck;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inLimits(final CuboidArea area) {
|
public boolean inLimits(final CuboidArea area) {
|
||||||
if (area.getXSize() > xmax || area.getYSize() > ymax || area.getZSize() > zmax) {
|
if (area.getXSize() > xmax || area.getYSize() > ymax || area.getZSize() > zmax) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean itemListAccess() {
|
public boolean itemListAccess() {
|
||||||
return itemListAccess;
|
return itemListAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printLimits(final Player player) {
|
public void printLimits(final Player player) {
|
||||||
final ResidenceMain plugin = ResidenceMain.getInstance();
|
final ResidenceMain plugin = ResidenceMain.getInstance();
|
||||||
player.sendMessage(ChatColor.GRAY + "---------------------------");
|
player.sendMessage(ChatColor.GRAY + "---------------------------");
|
||||||
player.sendMessage(ChatColor.YELLOW + "权限 组:" + ChatColor.DARK_AQUA + " " + plugin.getPermissionManager().getPermissionsGroup(player));
|
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 + " " + groupname);
|
||||||
player.sendMessage(ChatColor.YELLOW + "领地 管理:" + ChatColor.DARK_AQUA + " " + plugin.getPermissionManager().isResidenceAdmin(player));
|
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 + " " + cancreate);
|
||||||
player.sendMessage(ChatColor.YELLOW + "最大领地个数:" + ChatColor.DARK_AQUA + " " + resmax);
|
player.sendMessage(ChatColor.YELLOW + "最大领地个数:" + ChatColor.DARK_AQUA + " " + resmax);
|
||||||
player.sendMessage(ChatColor.YELLOW + "X轴最大长度:" + ChatColor.DARK_AQUA + " " + xmax);
|
player.sendMessage(ChatColor.YELLOW + "X轴最大长度:" + ChatColor.DARK_AQUA + " " + xmax);
|
||||||
player.sendMessage(ChatColor.YELLOW + "Z轴最大长度:" + ChatColor.DARK_AQUA + " " + zmax);
|
player.sendMessage(ChatColor.YELLOW + "Z轴最大长度:" + ChatColor.DARK_AQUA + " " + zmax);
|
||||||
player.sendMessage(ChatColor.YELLOW + "Y轴最大高度:" + ChatColor.DARK_AQUA + " " + ymax);
|
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 + " " + minHeight + " - " + maxHeight);
|
||||||
player.sendMessage(ChatColor.YELLOW + "最大子领地深度:" + ChatColor.DARK_AQUA + " " + subzonedepth);
|
player.sendMessage(ChatColor.YELLOW + "最大子领地深度:" + ChatColor.DARK_AQUA + " " + subzonedepth);
|
||||||
player.sendMessage(ChatColor.YELLOW + "是否允许设置进出消息:" + ChatColor.DARK_AQUA + " " + messageperms);
|
player.sendMessage(ChatColor.YELLOW + "是否允许设置进出消息:" + ChatColor.DARK_AQUA + " " + messageperms);
|
||||||
player.sendMessage(ChatColor.YELLOW + "你所拥有的领地:" + ChatColor.DARK_AQUA + " " + plugin.getResidenceManager().getOwnedZoneCount(player.getName()));
|
player.sendMessage(ChatColor.YELLOW + "你所拥有的领地:" + ChatColor.DARK_AQUA + " " + plugin.getResidenceManager().getOwnedZoneCount(player.getName()));
|
||||||
if (plugin.getEconomyManager() != null) {
|
if (plugin.getEconomyManager() != null) {
|
||||||
player.sendMessage(ChatColor.YELLOW + "每个方块需要金钱:" + ChatColor.DARK_AQUA + " " + costperarea);
|
player.sendMessage(ChatColor.YELLOW + "每个方块需要金钱:" + ChatColor.DARK_AQUA + " " + costperarea);
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.YELLOW + "Flag 权限:" + ChatColor.DARK_AQUA + " " + flagPerms.listFlags());
|
player.sendMessage(ChatColor.YELLOW + "Flag 权限:" + ChatColor.DARK_AQUA + " " + flagPerms.listFlags());
|
||||||
if (plugin.getConfigManager().useLeases()) {
|
if (plugin.getConfigManager().useLeases()) {
|
||||||
player.sendMessage(ChatColor.YELLOW + "最大租赁日:" + ChatColor.DARK_AQUA + " " + maxLeaseTime);
|
player.sendMessage(ChatColor.YELLOW + "最大租赁日:" + ChatColor.DARK_AQUA + " " + maxLeaseTime);
|
||||||
player.sendMessage(ChatColor.YELLOW + "续租日期:" + ChatColor.DARK_AQUA + " " + leaseGiveTime);
|
player.sendMessage(ChatColor.YELLOW + "续租日期:" + ChatColor.DARK_AQUA + " " + leaseGiveTime);
|
||||||
player.sendMessage(ChatColor.YELLOW + "续租方块需要金钱:" + ChatColor.DARK_AQUA + " " + renewcostperarea);
|
player.sendMessage(ChatColor.YELLOW + "续租方块需要金钱:" + ChatColor.DARK_AQUA + " " + renewcostperarea);
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.GRAY + "---------------------------");
|
player.sendMessage(ChatColor.GRAY + "---------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean selectCommandAccess() {
|
public boolean selectCommandAccess() {
|
||||||
return selectCommandAccess;
|
return selectCommandAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseGroup(final ConfigurationSection limits) {
|
private void parseGroup(final ConfigurationSection limits) {
|
||||||
if (limits == null) {
|
if (limits == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cancreate = limits.getBoolean("Residence.CanCreate", false);
|
cancreate = limits.getBoolean("Residence.CanCreate", false);
|
||||||
resmax = limits.getInt("Residence.MaxResidences", 0);
|
resmax = limits.getInt("Residence.MaxResidences", 0);
|
||||||
maxPhysical = limits.getInt("Residence.MaxAreasPerResidence", 2);
|
maxPhysical = limits.getInt("Residence.MaxAreasPerResidence", 2);
|
||||||
xmax = limits.getInt("Residence.MaxEastWest", 0);
|
xmax = limits.getInt("Residence.MaxEastWest", 0);
|
||||||
ymax = limits.getInt("Residence.MaxUpDown", 0);
|
ymax = limits.getInt("Residence.MaxUpDown", 0);
|
||||||
zmax = limits.getInt("Residence.MaxNorthSouth", 0);
|
zmax = limits.getInt("Residence.MaxNorthSouth", 0);
|
||||||
minHeight = limits.getInt("Residence.MinHeight", 0);
|
minHeight = limits.getInt("Residence.MinHeight", 0);
|
||||||
maxHeight = limits.getInt("Residence.MaxHeight", 255);
|
maxHeight = limits.getInt("Residence.MaxHeight", 255);
|
||||||
tpaccess = limits.getBoolean("Residence.CanTeleport", false);
|
tpaccess = limits.getBoolean("Residence.CanTeleport", false);
|
||||||
subzonedepth = limits.getInt("Residence.SubzoneDepth", 0);
|
subzonedepth = limits.getInt("Residence.SubzoneDepth", 0);
|
||||||
messageperms = limits.getBoolean("Messaging.CanChange", false);
|
messageperms = limits.getBoolean("Messaging.CanChange", false);
|
||||||
defaultEnterMessage = limits.getString("Messaging.DefaultEnter", null);
|
defaultEnterMessage = limits.getString("Messaging.DefaultEnter", null);
|
||||||
defaultLeaveMessage = limits.getString("Messaging.DefaultLeave", null);
|
defaultLeaveMessage = limits.getString("Messaging.DefaultLeave", null);
|
||||||
maxLeaseTime = limits.getInt("Lease.MaxDays", 16);
|
maxLeaseTime = limits.getInt("Lease.MaxDays", 16);
|
||||||
leaseGiveTime = limits.getInt("Lease.RenewIncrement", 14);
|
leaseGiveTime = limits.getInt("Lease.RenewIncrement", 14);
|
||||||
maxRents = limits.getInt("Rent.MaxRents", 0);
|
maxRents = limits.getInt("Rent.MaxRents", 0);
|
||||||
maxRentables = limits.getInt("Rent.MaxRentables", 0);
|
maxRentables = limits.getInt("Rent.MaxRentables", 0);
|
||||||
renewcostperarea = limits.getDouble("Economy.RenewCost", 0.02D);
|
renewcostperarea = limits.getDouble("Economy.RenewCost", 0.02D);
|
||||||
canBuy = limits.getBoolean("Economy.CanBuy", false);
|
canBuy = limits.getBoolean("Economy.CanBuy", false);
|
||||||
canSell = limits.getBoolean("Economy.CanSell", false);
|
canSell = limits.getBoolean("Economy.CanSell", false);
|
||||||
buyIgnoreLimits = limits.getBoolean("Economy.IgnoreLimits", false);
|
buyIgnoreLimits = limits.getBoolean("Economy.IgnoreLimits", false);
|
||||||
costperarea = limits.getDouble("Economy.BuyCost", 0);
|
costperarea = limits.getDouble("Economy.BuyCost", 0);
|
||||||
unstuck = limits.getBoolean("Residence.Unstuck", false);
|
unstuck = limits.getBoolean("Residence.Unstuck", false);
|
||||||
kick = limits.getBoolean("Residence.Kick", false);
|
kick = limits.getBoolean("Residence.Kick", false);
|
||||||
selectCommandAccess = limits.getBoolean("Residence.SelectCommandAccess", true);
|
selectCommandAccess = limits.getBoolean("Residence.SelectCommandAccess", true);
|
||||||
itemListAccess = limits.getBoolean("Residence.ItemListAccess", true);
|
itemListAccess = limits.getBoolean("Residence.ItemListAccess", true);
|
||||||
ConfigurationSection node = limits.getConfigurationSection("Flags.Permission");
|
ConfigurationSection node = limits.getConfigurationSection("Flags.Permission");
|
||||||
Set<String> flags = null;
|
Set<String> flags = null;
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
flags = node.getKeys(false);
|
flags = node.getKeys(false);
|
||||||
}
|
}
|
||||||
if (flags != null) {
|
if (flags != null) {
|
||||||
final Iterator<String> flagit = flags.iterator();
|
final Iterator<String> flagit = flags.iterator();
|
||||||
while (flagit.hasNext()) {
|
while (flagit.hasNext()) {
|
||||||
final String flagname = flagit.next();
|
final String flagname = flagit.next();
|
||||||
final boolean access = limits.getBoolean("Flags.Permission." + flagname, false);
|
final boolean access = limits.getBoolean("Flags.Permission." + flagname, false);
|
||||||
flagPerms.setFlag(flagname, access ? FlagState.TRUE : FlagState.FALSE);
|
flagPerms.setFlag(flagname, access ? FlagState.TRUE : FlagState.FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node = limits.getConfigurationSection("Flags.CreatorDefault");
|
node = limits.getConfigurationSection("Flags.CreatorDefault");
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
flags = node.getKeys(false);
|
flags = node.getKeys(false);
|
||||||
}
|
}
|
||||||
if (flags != null) {
|
if (flags != null) {
|
||||||
final Iterator<String> flagit = flags.iterator();
|
final Iterator<String> flagit = flags.iterator();
|
||||||
while (flagit.hasNext()) {
|
while (flagit.hasNext()) {
|
||||||
final String flagname = flagit.next();
|
final String flagname = flagit.next();
|
||||||
final boolean access = limits.getBoolean("Flags.CreatorDefault." + flagname, false);
|
final boolean access = limits.getBoolean("Flags.CreatorDefault." + flagname, false);
|
||||||
creatorDefaultFlags.put(flagname, access);
|
creatorDefaultFlags.put(flagname, access);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
node = limits.getConfigurationSection("Flags.Default");
|
node = limits.getConfigurationSection("Flags.Default");
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
flags = node.getKeys(false);
|
flags = node.getKeys(false);
|
||||||
}
|
}
|
||||||
if (flags != null) {
|
if (flags != null) {
|
||||||
final Iterator<String> flagit = flags.iterator();
|
final Iterator<String> flagit = flags.iterator();
|
||||||
while (flagit.hasNext()) {
|
while (flagit.hasNext()) {
|
||||||
final String flagname = flagit.next();
|
final String flagname = flagit.next();
|
||||||
final boolean access = limits.getBoolean("Flags.Default." + flagname, false);
|
final boolean access = limits.getBoolean("Flags.Default." + flagname, false);
|
||||||
residenceDefaultFlags.put(flagname, access);
|
residenceDefaultFlags.put(flagname, access);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node = limits.getConfigurationSection("Flags.GroupDefault");
|
node = limits.getConfigurationSection("Flags.GroupDefault");
|
||||||
Set<String> groupDef = null;
|
Set<String> groupDef = null;
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
groupDef = node.getKeys(false);
|
groupDef = node.getKeys(false);
|
||||||
}
|
}
|
||||||
if (groupDef != null) {
|
if (groupDef != null) {
|
||||||
final Iterator<String> groupit = groupDef.iterator();
|
final Iterator<String> groupit = groupDef.iterator();
|
||||||
while (groupit.hasNext()) {
|
while (groupit.hasNext()) {
|
||||||
final String name = groupit.next();
|
final String name = groupit.next();
|
||||||
final Map<String, Boolean> gflags = new HashMap<String, Boolean>();
|
final Map<String, Boolean> gflags = new HashMap<String, Boolean>();
|
||||||
flags = limits.getConfigurationSection("Flags.GroupDefault." + name).getKeys(false);
|
flags = limits.getConfigurationSection("Flags.GroupDefault." + name).getKeys(false);
|
||||||
final Iterator<String> flagit = flags.iterator();
|
final Iterator<String> flagit = flags.iterator();
|
||||||
while (flagit.hasNext()) {
|
while (flagit.hasNext()) {
|
||||||
final String flagname = flagit.next();
|
final String flagname = flagit.next();
|
||||||
final boolean access = limits.getBoolean("Flags.GroupDefault." + name + "." + flagname, false);
|
final boolean access = limits.getBoolean("Flags.GroupDefault." + name + "." + flagname, false);
|
||||||
gflags.put(flagname, access);
|
gflags.put(flagname, access);
|
||||||
}
|
}
|
||||||
groupDefaultFlags.put(name, gflags);
|
groupDefaultFlags.put(name, gflags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,131 +26,131 @@ import cn.citycraft.Residence.vaultinterface.ResidenceVaultAdapter;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class PermissionManager {
|
public class PermissionManager {
|
||||||
protected static PermissionsInterface perms;
|
protected static PermissionsInterface perms;
|
||||||
protected FlagPermissions globalFlagPerms;
|
protected FlagPermissions globalFlagPerms;
|
||||||
protected Map<String, PermissionGroup> groups;
|
protected Map<String, PermissionGroup> groups;
|
||||||
protected Map<String, String> playersGroup;
|
protected Map<String, String> playersGroup;
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public PermissionManager(final ResidenceMain plugin) {
|
public PermissionManager(final ResidenceMain plugin) {
|
||||||
try {
|
try {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
groups = Collections.synchronizedMap(new HashMap<String, PermissionGroup>());
|
groups = Collections.synchronizedMap(new HashMap<String, PermissionGroup>());
|
||||||
playersGroup = Collections.synchronizedMap(new HashMap<String, String>());
|
playersGroup = Collections.synchronizedMap(new HashMap<String, String>());
|
||||||
globalFlagPerms = new FlagPermissions();
|
globalFlagPerms = new FlagPermissions();
|
||||||
this.readConfig(plugin.getConfig());
|
this.readConfig(plugin.getConfig());
|
||||||
final boolean enable = plugin.getConfig().getBoolean("Global.EnablePermissions", true);
|
final boolean enable = plugin.getConfig().getBoolean("Global.EnablePermissions", true);
|
||||||
if (enable) {
|
if (enable) {
|
||||||
this.checkPermissions();
|
this.checkPermissions();
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
plugin.getLogger().warning("权限管理载入失败,请报告以下错误给作者,谢谢!");
|
plugin.getLogger().warning("权限管理载入失败,请报告以下错误给作者,谢谢!");
|
||||||
plugin.getLogger().warning("错误: " + ex);
|
plugin.getLogger().warning("错误: " + ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PermissionGroup getGroup(final Player player) {
|
public PermissionGroup getGroup(final Player player) {
|
||||||
return groups.get(this.getGroupNameByPlayer(player));
|
return groups.get(this.getGroupNameByPlayer(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PermissionGroup getGroup(final String player, final String world) {
|
public PermissionGroup getGroup(final String player, final String world) {
|
||||||
return groups.get(this.getGroupNameByPlayer(player, world));
|
return groups.get(this.getGroupNameByPlayer(player, world));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PermissionGroup getGroupByName(String group) {
|
public PermissionGroup getGroupByName(String group) {
|
||||||
group = group.toLowerCase();
|
group = group.toLowerCase();
|
||||||
if (!groups.containsKey(group)) {
|
if (!groups.containsKey(group)) {
|
||||||
return groups.get(plugin.getConfigManager().getDefaultGroup());
|
return groups.get(plugin.getConfigManager().getDefaultGroup());
|
||||||
}
|
}
|
||||||
return groups.get(group);
|
return groups.get(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGroupNameByPlayer(final Player player) {
|
public String getGroupNameByPlayer(final Player player) {
|
||||||
return this.getGroupNameByPlayer(player.getName(), player.getWorld().getName());
|
return this.getGroupNameByPlayer(player.getName(), player.getWorld().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGroupNameByPlayer(String player, final String world) {
|
public String getGroupNameByPlayer(String player, final String world) {
|
||||||
player = player.toLowerCase();
|
player = player.toLowerCase();
|
||||||
if (playersGroup.containsKey(player)) {
|
if (playersGroup.containsKey(player)) {
|
||||||
String group = playersGroup.get(player);
|
String group = playersGroup.get(player);
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
group = group.toLowerCase();
|
group = group.toLowerCase();
|
||||||
if (group != null && groups.containsKey(group)) {
|
if (group != null && groups.containsKey(group)) {
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final String group = this.getPermissionsGroup(player, world);
|
final String group = this.getPermissionsGroup(player, world);
|
||||||
if (group == null || !groups.containsKey(group)) {
|
if (group == null || !groups.containsKey(group)) {
|
||||||
return plugin.getConfigManager().getDefaultGroup().toLowerCase();
|
return plugin.getConfigManager().getDefaultGroup().toLowerCase();
|
||||||
}
|
}
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermissionsGroup(final Player player) {
|
public String getPermissionsGroup(final Player player) {
|
||||||
return this.getPermissionsGroup(player.getName(), player.getWorld().getName());
|
return this.getPermissionsGroup(player.getName(), player.getWorld().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermissionsGroup(final String player, final String world) {
|
public String getPermissionsGroup(final String player, final String world) {
|
||||||
if (perms == null) {
|
if (perms == null) {
|
||||||
return plugin.getConfigManager().getDefaultGroup();
|
return plugin.getConfigManager().getDefaultGroup();
|
||||||
}
|
}
|
||||||
return perms.getPlayerGroup(player, world);
|
return perms.getPlayerGroup(player, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PermissionsInterface getPermissionsPlugin() {
|
public PermissionsInterface getPermissionsPlugin() {
|
||||||
return perms;
|
return perms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasGroup(String group) {
|
public boolean hasGroup(String group) {
|
||||||
group = group.toLowerCase();
|
group = group.toLowerCase();
|
||||||
return groups.containsKey(group);
|
return groups.containsKey(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isResidenceAdmin(final Player player) {
|
public boolean isResidenceAdmin(final Player player) {
|
||||||
return (player.hasPermission("residence.admin") || (player.isOp() && plugin.getConfigManager().getOpsAreAdmins()));
|
return (player.hasPermission("residence.admin") || (player.isOp() && plugin.getConfigManager().getOpsAreAdmins()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkPermissions() {
|
private void checkPermissions() {
|
||||||
final Server server = plugin.getServer();
|
final Server server = plugin.getServer();
|
||||||
final Plugin p = server.getPluginManager().getPlugin("Vault");
|
final Plugin p = server.getPluginManager().getPlugin("Vault");
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
final ResidenceVaultAdapter vault = new ResidenceVaultAdapter(server);
|
final ResidenceVaultAdapter vault = new ResidenceVaultAdapter(server);
|
||||||
if (vault.permissionsOK()) {
|
if (vault.permissionsOK()) {
|
||||||
perms = vault;
|
perms = vault;
|
||||||
plugin.getLogger().info("发现 Vault 使用权限系统: " + vault.getPermissionsName());
|
plugin.getLogger().info("发现 Vault 使用权限系统: " + vault.getPermissionsName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.getLogger().info("发现 Vault, 但是 Vault 未找到权限系统...");
|
plugin.getLogger().info("发现 Vault, 但是 Vault 未找到权限系统...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readConfig(final FileConfiguration config) {
|
private void readConfig(final FileConfiguration config) {
|
||||||
final String defaultGroup = plugin.getConfigManager().getDefaultGroup();
|
final String defaultGroup = plugin.getConfigManager().getDefaultGroup();
|
||||||
globalFlagPerms = FlagPermissions.parseFromConfigNode("FlagPermission", config.getConfigurationSection("Global"));
|
globalFlagPerms = FlagPermissions.parseFromConfigNode("FlagPermission", config.getConfigurationSection("Global"));
|
||||||
final ConfigurationSection nodes = config.getConfigurationSection("Groups");
|
final ConfigurationSection nodes = config.getConfigurationSection("Groups");
|
||||||
if (nodes != null) {
|
if (nodes != null) {
|
||||||
final Set<String> entrys = nodes.getKeys(false);
|
final Set<String> entrys = nodes.getKeys(false);
|
||||||
for (final String key : entrys) {
|
for (final String key : entrys) {
|
||||||
try {
|
try {
|
||||||
groups.put(key.toLowerCase(), new PermissionGroup(key.toLowerCase(), nodes.getConfigurationSection(key), globalFlagPerms));
|
groups.put(key.toLowerCase(), new PermissionGroup(key.toLowerCase(), nodes.getConfigurationSection(key), globalFlagPerms));
|
||||||
final List<String> mirrors = nodes.getConfigurationSection(key).getStringList("Mirror");
|
final List<String> mirrors = nodes.getConfigurationSection(key).getStringList("Mirror");
|
||||||
for (final String group : mirrors) {
|
for (final String group : mirrors) {
|
||||||
groups.put(group.toLowerCase(), new PermissionGroup(key.toLowerCase(), nodes.getConfigurationSection(key), globalFlagPerms));
|
groups.put(group.toLowerCase(), new PermissionGroup(key.toLowerCase(), nodes.getConfigurationSection(key), globalFlagPerms));
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
plugin.getLogger().info("错误 从配置文件读取:" + key + " 抛出异常:" + ex);
|
plugin.getLogger().info("错误 从配置文件读取:" + key + " 抛出异常:" + ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!groups.containsKey(defaultGroup)) {
|
if (!groups.containsKey(defaultGroup)) {
|
||||||
groups.put(defaultGroup, new PermissionGroup(defaultGroup));
|
groups.put(defaultGroup, new PermissionGroup(defaultGroup));
|
||||||
}
|
}
|
||||||
final Set<String> keys = config.getConfigurationSection("GroupAssignments").getKeys(false);
|
final Set<String> keys = config.getConfigurationSection("GroupAssignments").getKeys(false);
|
||||||
if (keys != null) {
|
if (keys != null) {
|
||||||
for (final String key : keys) {
|
for (final String key : keys) {
|
||||||
playersGroup.put(key.toLowerCase(), config.getString("GroupAssignments." + key, defaultGroup).toLowerCase());
|
playersGroup.put(key.toLowerCase(), config.getString("GroupAssignments." + key, defaultGroup).toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,5 +13,6 @@ import org.bukkit.entity.Player;
|
|||||||
*/
|
*/
|
||||||
public interface PermissionsInterface {
|
public interface PermissionsInterface {
|
||||||
public String getPlayerGroup(Player player);
|
public String getPlayerGroup(Player player);
|
||||||
|
|
||||||
public String getPlayerGroup(String player, String world);
|
public String getPlayerGroup(String player, String world);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,23 +26,21 @@ public class YMLSaveHelper {
|
|||||||
|
|
||||||
File f;
|
File f;
|
||||||
Yaml yml;
|
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();
|
DumperOptions options = new DumperOptions();
|
||||||
options.setDefaultFlowStyle(FlowStyle.BLOCK);
|
options.setDefaultFlowStyle(FlowStyle.BLOCK);
|
||||||
yml = new Yaml(options);
|
yml = new Yaml(options);
|
||||||
|
|
||||||
root = new LinkedHashMap<String,Object>();
|
root = new LinkedHashMap<String, Object>();
|
||||||
if(ymlfile == null)
|
if (ymlfile == null)
|
||||||
throw new IOException("YMLSaveHelper: null file...");
|
throw new IOException("YMLSaveHelper: null file...");
|
||||||
f = ymlfile;
|
f = ymlfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() throws IOException
|
public void save() throws IOException {
|
||||||
{
|
if (f.isFile())
|
||||||
if(f.isFile())
|
|
||||||
f.delete();
|
f.delete();
|
||||||
FileOutputStream fout = new FileOutputStream(f);
|
FileOutputStream fout = new FileOutputStream(f);
|
||||||
OutputStreamWriter osw = new OutputStreamWriter(fout, "UTF8");
|
OutputStreamWriter osw = new OutputStreamWriter(fout, "UTF8");
|
||||||
@@ -51,16 +49,14 @@ public class YMLSaveHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void load() throws IOException
|
public void load() throws IOException {
|
||||||
{
|
|
||||||
FileInputStream fis = new FileInputStream(f);
|
FileInputStream fis = new FileInputStream(f);
|
||||||
InputStreamReader isr = new InputStreamReader(fis, "UTF8");
|
InputStreamReader isr = new InputStreamReader(fis, "UTF8");
|
||||||
root = (Map<String, Object>) yml.load(isr);
|
root = (Map<String, Object>) yml.load(isr);
|
||||||
isr.close();
|
isr.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String,Object> getRoot()
|
public Map<String, Object> getRoot() {
|
||||||
{
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,21 +5,21 @@ import org.bukkit.Bukkit;
|
|||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class AutoSaveTask implements Runnable {
|
public class AutoSaveTask implements Runnable {
|
||||||
ResidenceMain res;
|
ResidenceMain res;
|
||||||
|
|
||||||
public AutoSaveTask(final ResidenceMain res) {
|
public AutoSaveTask(final ResidenceMain res) {
|
||||||
this.res = res;
|
this.res = res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
if (res.isInit()) {
|
if (res.isInit()) {
|
||||||
res.saveYml();
|
res.saveYml();
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
Bukkit.getLogger().warning("领地数据保存错误,可能造成部分领地丢失,请尝试恢复备份文件!");
|
Bukkit.getLogger().warning("领地数据保存错误,可能造成部分领地丢失,请尝试恢复备份文件!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,39 @@
|
|||||||
package cn.citycraft.Residence.runnable;
|
package cn.citycraft.Residence.runnable;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Damageable;
|
import org.bukkit.entity.Damageable;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||||
|
|
||||||
|
import cn.citycraft.PluginHelper.utils.CompatibleUtil;
|
||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class HealTask implements Runnable {
|
public class HealTask implements Runnable {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public HealTask(final ResidenceMain plugin) {
|
public HealTask(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
for (final Player player : Bukkit.getServer().getOnlinePlayers()) {
|
for (final Player player : CompatibleUtil.getOnlinePlayers()) {
|
||||||
final String resname = plugin.getPlayerListener().getCurrentResidenceName(player.getName());
|
final String resname = plugin.getPlayerListener().getCurrentResidenceName(player.getName());
|
||||||
ClaimedResidence res = null;
|
ClaimedResidence res = null;
|
||||||
if (resname != null) {
|
if (resname != null) {
|
||||||
res = plugin.getResidenceManager().getByName(resname);
|
res = plugin.getResidenceManager().getByName(resname);
|
||||||
}
|
}
|
||||||
if (res != null && res.getPermissions().has("healing", false)) {
|
if (res != null && res.getPermissions().has("healing", false)) {
|
||||||
final Damageable damage = player;
|
final Damageable damage = player;
|
||||||
final double health = damage.getHealth();
|
final double health = damage.getHealth();
|
||||||
if (health < 20 && !player.isDead()) {
|
if (health < 20 && !player.isDead()) {
|
||||||
player.setHealth(health + 1);
|
player.setHealth(health + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,17 @@ package cn.citycraft.Residence.runnable;
|
|||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class LeaseTask implements Runnable {
|
public class LeaseTask implements Runnable {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public LeaseTask(final ResidenceMain plugin) {
|
public LeaseTask(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
plugin.getLeaseManager().doExpirations();
|
plugin.getLeaseManager().doExpirations();
|
||||||
if (plugin.getConfigManager().showIntervalMessages()) {
|
if (plugin.getConfigManager().showIntervalMessages()) {
|
||||||
plugin.getLogger().info(" - Lease Expirations checked!");
|
plugin.getLogger().info(" - Lease Expirations checked!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,17 @@ package cn.citycraft.Residence.runnable;
|
|||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class RentTask implements Runnable {
|
public class RentTask implements Runnable {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public RentTask(final ResidenceMain plugin) {
|
public RentTask(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
plugin.getRentManager().checkCurrentRents();
|
plugin.getRentManager().checkCurrentRents();
|
||||||
if (plugin.getConfigManager().showIntervalMessages()) {
|
if (plugin.getConfigManager().showIntervalMessages()) {
|
||||||
plugin.getLogger().info(" - Rent Expirations checked!");
|
plugin.getLogger().info(" - Rent Expirations checked!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,21 +7,21 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
public class TaskManager {
|
public class TaskManager {
|
||||||
Plugin plugin;
|
Plugin plugin;
|
||||||
|
|
||||||
List<BukkitTask> tasklist;
|
List<BukkitTask> tasklist;
|
||||||
|
|
||||||
public TaskManager(Plugin plugin) {
|
public TaskManager(Plugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.tasklist = new ArrayList<BukkitTask>();
|
this.tasklist = new ArrayList<BukkitTask>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(BukkitTask task) {
|
public void add(BukkitTask task) {
|
||||||
tasklist.add(task);
|
tasklist.add(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelall() {
|
public void cancelall() {
|
||||||
for (BukkitTask bukkitTask : tasklist)
|
for (BukkitTask bukkitTask : tasklist)
|
||||||
bukkitTask.cancel();
|
bukkitTask.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,302 +26,302 @@ import cn.citycraft.Residence.permissions.PermissionGroup;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class SelectionManager {
|
public class SelectionManager {
|
||||||
public static final int MAX_HEIGHT = 255, MIN_HEIGHT = 0;
|
public static final int MAX_HEIGHT = 255, MIN_HEIGHT = 0;
|
||||||
protected Map<String, Location> playerLoc1;
|
protected Map<String, Location> playerLoc1;
|
||||||
protected Map<String, Location> playerLoc2;
|
protected Map<String, Location> playerLoc2;
|
||||||
protected Server server;
|
protected Server server;
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public SelectionManager(final ResidenceMain plugin) {
|
public SelectionManager(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.server = Bukkit.getServer();
|
this.server = Bukkit.getServer();
|
||||||
playerLoc1 = Collections.synchronizedMap(new HashMap<String, Location>());
|
playerLoc1 = Collections.synchronizedMap(new HashMap<String, Location>());
|
||||||
playerLoc2 = Collections.synchronizedMap(new HashMap<String, Location>());
|
playerLoc2 = Collections.synchronizedMap(new HashMap<String, Location>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bedrock(final Player player, final boolean resadmin) {
|
public void bedrock(final Player player, final boolean resadmin) {
|
||||||
if (hasPlacedBoth(player.getName())) {
|
if (hasPlacedBoth(player.getName())) {
|
||||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||||
final int y1 = playerLoc1.get(player.getName()).getBlockY();
|
final int y1 = playerLoc1.get(player.getName()).getBlockY();
|
||||||
final int y2 = playerLoc2.get(player.getName()).getBlockY();
|
final int y2 = playerLoc2.get(player.getName()).getBlockY();
|
||||||
if (y1 < y2) {
|
if (y1 < y2) {
|
||||||
int newy = MIN_HEIGHT;
|
int newy = MIN_HEIGHT;
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
if (newy < group.getMinHeight()) {
|
if (newy < group.getMinHeight()) {
|
||||||
newy = group.getMinHeight();
|
newy = group.getMinHeight();
|
||||||
}
|
}
|
||||||
if (y2 - newy > (group.getMaxY() - 1)) {
|
if (y2 - newy > (group.getMaxY() - 1)) {
|
||||||
newy = y2 - (group.getMaxY() - 1);
|
newy = y2 - (group.getMaxY() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playerLoc1.get(player.getName()).setY(newy);
|
playerLoc1.get(player.getName()).setY(newy);
|
||||||
} else {
|
} else {
|
||||||
int newy = MIN_HEIGHT;
|
int newy = MIN_HEIGHT;
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
if (newy < group.getMinHeight()) {
|
if (newy < group.getMinHeight()) {
|
||||||
newy = group.getMinHeight();
|
newy = group.getMinHeight();
|
||||||
}
|
}
|
||||||
if (y1 - newy > (group.getMaxY() - 1)) {
|
if (y1 - newy > (group.getMaxY() - 1)) {
|
||||||
newy = y1 - (group.getMaxY() - 1);
|
newy = y1 - (group.getMaxY() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playerLoc2.get(player.getName()).setY(newy);
|
playerLoc2.get(player.getName()).setY(newy);
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionBedrock"));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionBedrock"));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearSelection(final Player player) {
|
public void clearSelection(final Player player) {
|
||||||
playerLoc1.remove(player.getName());
|
playerLoc1.remove(player.getName());
|
||||||
playerLoc2.remove(player.getName());
|
playerLoc2.remove(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getPlayerLoc1(final String player) {
|
public Location getPlayerLoc1(final String player) {
|
||||||
return playerLoc1.get(player);
|
return playerLoc1.get(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getPlayerLoc2(final String player) {
|
public Location getPlayerLoc2(final String player) {
|
||||||
return playerLoc2.get(player);
|
return playerLoc2.get(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPlacedBoth(final String player) {
|
public boolean hasPlacedBoth(final String player) {
|
||||||
return (playerLoc1.containsKey(player) && playerLoc2.containsKey(player));
|
return (playerLoc1.containsKey(player) && playerLoc2.containsKey(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void modify(final Player player, final boolean shift, final int amount) {
|
public void modify(final Player player, final boolean shift, final int amount) {
|
||||||
if (!this.hasPlacedBoth(player.getName())) {
|
if (!this.hasPlacedBoth(player.getName())) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Direction d = this.getDirection(player);
|
final Direction d = this.getDirection(player);
|
||||||
if (d == null) {
|
if (d == null) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidDirection"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidDirection"));
|
||||||
}
|
}
|
||||||
final CuboidArea area = new CuboidArea(playerLoc1.get(player.getName()), playerLoc2.get(player.getName()));
|
final CuboidArea area = new CuboidArea(playerLoc1.get(player.getName()), playerLoc2.get(player.getName()));
|
||||||
if (d == Direction.UP) {
|
if (d == Direction.UP) {
|
||||||
int oldy = area.getHighLoc().getBlockY();
|
int oldy = area.getHighLoc().getBlockY();
|
||||||
oldy = oldy + amount;
|
oldy = oldy + amount;
|
||||||
if (oldy > MAX_HEIGHT) {
|
if (oldy > MAX_HEIGHT) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectTooHigh"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectTooHigh"));
|
||||||
oldy = MAX_HEIGHT;
|
oldy = MAX_HEIGHT;
|
||||||
}
|
}
|
||||||
area.getHighLoc().setY(oldy);
|
area.getHighLoc().setY(oldy);
|
||||||
if (shift) {
|
if (shift) {
|
||||||
int oldy2 = area.getLowLoc().getBlockY();
|
int oldy2 = area.getLowLoc().getBlockY();
|
||||||
oldy2 = oldy2 + amount;
|
oldy2 = oldy2 + amount;
|
||||||
area.getLowLoc().setY(oldy2);
|
area.getLowLoc().setY(oldy2);
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting.Up") + "...");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting.Up") + "...");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding.Up") + "...");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding.Up") + "...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (d == Direction.DOWN) {
|
if (d == Direction.DOWN) {
|
||||||
int oldy = area.getLowLoc().getBlockY();
|
int oldy = area.getLowLoc().getBlockY();
|
||||||
oldy = oldy - amount;
|
oldy = oldy - amount;
|
||||||
if (oldy < MIN_HEIGHT) {
|
if (oldy < MIN_HEIGHT) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectTooLow"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectTooLow"));
|
||||||
oldy = MIN_HEIGHT;
|
oldy = MIN_HEIGHT;
|
||||||
}
|
}
|
||||||
area.getLowLoc().setY(oldy);
|
area.getLowLoc().setY(oldy);
|
||||||
if (shift) {
|
if (shift) {
|
||||||
int oldy2 = area.getHighLoc().getBlockY();
|
int oldy2 = area.getHighLoc().getBlockY();
|
||||||
oldy2 = oldy2 - amount;
|
oldy2 = oldy2 - amount;
|
||||||
area.getHighLoc().setY(oldy2);
|
area.getHighLoc().setY(oldy2);
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting.Down") + "...");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting.Down") + "...");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding.Down") + "...");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding.Down") + "...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (d == Direction.MINUSX) {
|
if (d == Direction.MINUSX) {
|
||||||
int oldx = area.getLowLoc().getBlockX();
|
int oldx = area.getLowLoc().getBlockX();
|
||||||
oldx = oldx - amount;
|
oldx = oldx - amount;
|
||||||
area.getLowLoc().setX(oldx);
|
area.getLowLoc().setX(oldx);
|
||||||
if (shift) {
|
if (shift) {
|
||||||
int oldx2 = area.getHighLoc().getBlockX();
|
int oldx2 = area.getHighLoc().getBlockX();
|
||||||
oldx2 = oldx2 - amount;
|
oldx2 = oldx2 - amount;
|
||||||
area.getHighLoc().setX(oldx2);
|
area.getHighLoc().setX(oldx2);
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " -X...");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " -X...");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " -X...");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " -X...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (d == Direction.PLUSX) {
|
if (d == Direction.PLUSX) {
|
||||||
int oldx = area.getHighLoc().getBlockX();
|
int oldx = area.getHighLoc().getBlockX();
|
||||||
oldx = oldx + amount;
|
oldx = oldx + amount;
|
||||||
area.getHighLoc().setX(oldx);
|
area.getHighLoc().setX(oldx);
|
||||||
if (shift) {
|
if (shift) {
|
||||||
int oldx2 = area.getLowLoc().getBlockX();
|
int oldx2 = area.getLowLoc().getBlockX();
|
||||||
oldx2 = oldx2 + amount;
|
oldx2 = oldx2 + amount;
|
||||||
area.getLowLoc().setX(oldx2);
|
area.getLowLoc().setX(oldx2);
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " +X...");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " +X...");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " +X...");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " +X...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (d == Direction.MINUSZ) {
|
if (d == Direction.MINUSZ) {
|
||||||
int oldz = area.getLowLoc().getBlockZ();
|
int oldz = area.getLowLoc().getBlockZ();
|
||||||
oldz = oldz - amount;
|
oldz = oldz - amount;
|
||||||
area.getLowLoc().setZ(oldz);
|
area.getLowLoc().setZ(oldz);
|
||||||
if (shift) {
|
if (shift) {
|
||||||
int oldz2 = area.getHighLoc().getBlockZ();
|
int oldz2 = area.getHighLoc().getBlockZ();
|
||||||
oldz2 = oldz2 - amount;
|
oldz2 = oldz2 - amount;
|
||||||
area.getHighLoc().setZ(oldz2);
|
area.getHighLoc().setZ(oldz2);
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " -Z...");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " -Z...");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " -Z...");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " -Z...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (d == Direction.PLUSZ) {
|
if (d == Direction.PLUSZ) {
|
||||||
int oldz = area.getHighLoc().getBlockZ();
|
int oldz = area.getHighLoc().getBlockZ();
|
||||||
oldz = oldz + amount;
|
oldz = oldz + amount;
|
||||||
area.getHighLoc().setZ(oldz);
|
area.getHighLoc().setZ(oldz);
|
||||||
if (shift) {
|
if (shift) {
|
||||||
int oldz2 = area.getLowLoc().getBlockZ();
|
int oldz2 = area.getLowLoc().getBlockZ();
|
||||||
oldz2 = oldz2 + amount;
|
oldz2 = oldz2 + amount;
|
||||||
area.getLowLoc().setZ(oldz2);
|
area.getLowLoc().setZ(oldz2);
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " +Z...");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Shifting") + " +Z...");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " +Z...");
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Expanding") + " +Z...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playerLoc1.put(player.getName(), area.getHighLoc());
|
playerLoc1.put(player.getName(), area.getHighLoc());
|
||||||
playerLoc2.put(player.getName(), area.getLowLoc());
|
playerLoc2.put(player.getName(), area.getLowLoc());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void placeLoc1(final Player player, final Location loc) {
|
public void placeLoc1(final Player player, final Location loc) {
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
playerLoc1.put(player.getName(), loc);
|
playerLoc1.put(player.getName(), loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void placeLoc2(final Player player, final Location loc) {
|
public void placeLoc2(final Player player, final Location loc) {
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
playerLoc2.put(player.getName(), loc);
|
playerLoc2.put(player.getName(), loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectBySize(final Player player, final int xsize, final int ysize, final int zsize) {
|
public void selectBySize(final Player player, final int xsize, final int ysize, final int zsize) {
|
||||||
final Location myloc = player.getLocation();
|
final Location myloc = player.getLocation();
|
||||||
final Location loc1 = new Location(myloc.getWorld(), myloc.getBlockX() + xsize, myloc.getBlockY() + ysize, myloc.getBlockZ() + zsize);
|
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);
|
final Location loc2 = new Location(myloc.getWorld(), myloc.getBlockX() - xsize, myloc.getBlockY() - ysize, myloc.getBlockZ() - zsize);
|
||||||
placeLoc1(player, loc1);
|
placeLoc1(player, loc1);
|
||||||
placeLoc2(player, loc2);
|
placeLoc2(player, loc2);
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSuccess"));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSuccess"));
|
||||||
showSelectionInfo(player);
|
showSelectionInfo(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectChunk(final Player player) {
|
public void selectChunk(final Player player) {
|
||||||
final Chunk chunk = player.getWorld().getChunkAt(player.getLocation());
|
final Chunk chunk = player.getWorld().getChunkAt(player.getLocation());
|
||||||
final int xcoord = chunk.getX() * 16;
|
final int xcoord = chunk.getX() * 16;
|
||||||
final int zcoord = chunk.getZ() * 16;
|
final int zcoord = chunk.getZ() * 16;
|
||||||
final int ycoord = MIN_HEIGHT;
|
final int ycoord = MIN_HEIGHT;
|
||||||
final int xmax = xcoord + 15;
|
final int xmax = xcoord + 15;
|
||||||
final int zmax = zcoord + 15;
|
final int zmax = zcoord + 15;
|
||||||
final int ymax = MAX_HEIGHT;
|
final int ymax = MAX_HEIGHT;
|
||||||
this.playerLoc1.put(player.getName(), new Location(player.getWorld(), xcoord, ycoord, zcoord));
|
this.playerLoc1.put(player.getName(), new Location(player.getWorld(), xcoord, ycoord, zcoord));
|
||||||
this.playerLoc2.put(player.getName(), new Location(player.getWorld(), xmax, ymax, zmax));
|
this.playerLoc2.put(player.getName(), new Location(player.getWorld(), xmax, ymax, zmax));
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSuccess"));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSuccess"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showSelectionInfo(final Player player) {
|
public void showSelectionInfo(final Player player) {
|
||||||
final String pname = player.getName();
|
final String pname = player.getName();
|
||||||
if (this.hasPlacedBoth(pname)) {
|
if (this.hasPlacedBoth(pname)) {
|
||||||
final CuboidArea cuboidArea = new CuboidArea(getPlayerLoc1(pname), getPlayerLoc2(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());
|
player.sendMessage(ChatColor.YELLOW + plugin.getLanguage().getPhrase("Selection.Total.Size") + ":" + ChatColor.DARK_AQUA + " " + cuboidArea.getSize());
|
||||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||||
if (plugin.getConfigManager().enableEconomy()) {
|
if (plugin.getConfigManager().enableEconomy()) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
ChatColor.YELLOW + plugin.getLanguage().getPhrase("Land.Cost") + ":" + ChatColor.DARK_AQUA + " " + ((int) Math.ceil(cuboidArea.getSize() * group.getCostPerBlock())));
|
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 + "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 + "Y" + plugin.getLanguage().getPhrase("Size") + ":" + ChatColor.DARK_AQUA + " " + cuboidArea.getYSize());
|
||||||
player.sendMessage(ChatColor.YELLOW + "Z" + plugin.getLanguage().getPhrase("Size") + ":" + ChatColor.DARK_AQUA + " " + cuboidArea.getZSize());
|
player.sendMessage(ChatColor.YELLOW + "Z" + plugin.getLanguage().getPhrase("Size") + ":" + ChatColor.DARK_AQUA + " " + cuboidArea.getZSize());
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sky(final Player player, final boolean resadmin) {
|
public void sky(final Player player, final boolean resadmin) {
|
||||||
if (hasPlacedBoth(player.getName())) {
|
if (hasPlacedBoth(player.getName())) {
|
||||||
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
final PermissionGroup group = plugin.getPermissionManager().getGroup(player);
|
||||||
final int y1 = playerLoc1.get(player.getName()).getBlockY();
|
final int y1 = playerLoc1.get(player.getName()).getBlockY();
|
||||||
final int y2 = playerLoc2.get(player.getName()).getBlockY();
|
final int y2 = playerLoc2.get(player.getName()).getBlockY();
|
||||||
if (y1 > y2) {
|
if (y1 > y2) {
|
||||||
int newy = MAX_HEIGHT;
|
int newy = MAX_HEIGHT;
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
if (group.getMaxHeight() < newy) {
|
if (group.getMaxHeight() < newy) {
|
||||||
newy = group.getMaxHeight();
|
newy = group.getMaxHeight();
|
||||||
}
|
}
|
||||||
if (newy - y2 > (group.getMaxY() - 1)) {
|
if (newy - y2 > (group.getMaxY() - 1)) {
|
||||||
newy = y2 + (group.getMaxY() - 1);
|
newy = y2 + (group.getMaxY() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playerLoc1.get(player.getName()).setY(newy);
|
playerLoc1.get(player.getName()).setY(newy);
|
||||||
} else {
|
} else {
|
||||||
int newy = MAX_HEIGHT;
|
int newy = MAX_HEIGHT;
|
||||||
if (!resadmin) {
|
if (!resadmin) {
|
||||||
if (group.getMaxHeight() < newy) {
|
if (group.getMaxHeight() < newy) {
|
||||||
newy = group.getMaxHeight();
|
newy = group.getMaxHeight();
|
||||||
}
|
}
|
||||||
if (newy - y1 > (group.getMaxY() - 1)) {
|
if (newy - y1 > (group.getMaxY() - 1)) {
|
||||||
newy = y1 + (group.getMaxY() - 1);
|
newy = y1 + (group.getMaxY() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playerLoc2.get(player.getName()).setY(newy);
|
playerLoc2.get(player.getName()).setY(newy);
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSky"));
|
player.sendMessage(ChatColor.GREEN + plugin.getLanguage().getPhrase("SelectionSky"));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void vert(final Player player, final boolean resadmin) {
|
public void vert(final Player player, final boolean resadmin) {
|
||||||
if (hasPlacedBoth(player.getName())) {
|
if (hasPlacedBoth(player.getName())) {
|
||||||
this.sky(player, resadmin);
|
this.sky(player, resadmin);
|
||||||
this.bedrock(player, resadmin);
|
this.bedrock(player, resadmin);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("SelectPoints"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean worldEdit(final Player player) {
|
public boolean worldEdit(final Player player) {
|
||||||
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("WorldEditNotFound"));
|
player.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("WorldEditNotFound"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Direction getDirection(final Player player) {
|
private Direction getDirection(final Player player) {
|
||||||
final float pitch = player.getLocation().getPitch();
|
final float pitch = player.getLocation().getPitch();
|
||||||
final float yaw = player.getLocation().getYaw();
|
final float yaw = player.getLocation().getYaw();
|
||||||
if (pitch < -50) {
|
if (pitch < -50) {
|
||||||
return Direction.UP;
|
return Direction.UP;
|
||||||
}
|
}
|
||||||
if (pitch > 50) {
|
if (pitch > 50) {
|
||||||
return Direction.DOWN;
|
return Direction.DOWN;
|
||||||
}
|
}
|
||||||
if ((yaw > 45 && yaw < 135) || (yaw < -45 && yaw > -135)) {
|
if ((yaw > 45 && yaw < 135) || (yaw < -45 && yaw > -135)) {
|
||||||
return Direction.MINUSX;
|
return Direction.MINUSX;
|
||||||
}
|
}
|
||||||
if ((yaw > 225 && yaw < 315) || (yaw < -225 && yaw > -315)) {
|
if ((yaw > 225 && yaw < 315) || (yaw < -225 && yaw > -315)) {
|
||||||
return Direction.PLUSX;
|
return Direction.PLUSX;
|
||||||
}
|
}
|
||||||
if ((yaw > 135 && yaw < 225) || (yaw < -135 && yaw > -225)) {
|
if ((yaw > 135 && yaw < 225) || (yaw < -135 && yaw > -225)) {
|
||||||
return Direction.MINUSZ;
|
return Direction.MINUSZ;
|
||||||
}
|
}
|
||||||
if ((yaw < 45 || yaw > 315) || (yaw > -45 || yaw < -315)) {
|
if ((yaw < 45 || yaw > 315) || (yaw > -45 || yaw < -315)) {
|
||||||
return Direction.PLUSZ;
|
return Direction.PLUSZ;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Direction {
|
public enum Direction {
|
||||||
DOWN,
|
DOWN,
|
||||||
MINUSX,
|
MINUSX,
|
||||||
MINUSZ,
|
MINUSZ,
|
||||||
PLUSX,
|
PLUSX,
|
||||||
PLUSZ,
|
PLUSZ,
|
||||||
UP
|
UP
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ import com.sk89q.worldedit.bukkit.selections.Selection;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class WECUI {
|
public class WECUI {
|
||||||
public static void UPDATESELECT(final ClaimedResidence res, final Player player) {
|
public static void UPDATESELECT(final ClaimedResidence res, final Player player) {
|
||||||
final WorldEditPlugin wep = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
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());
|
final Selection selection = new CuboidSelection(Bukkit.getWorld(res.getWorld()), res.getAreaByLoc(player.getLocation()).getLowLoc(), res.getAreaByLoc(player.getLocation()).getHighLoc());
|
||||||
wep.setSelection(player, selection);
|
wep.setSelection(player, selection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,87 +20,87 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class WorldEditSelectionManager extends SelectionManager {
|
public class WorldEditSelectionManager extends SelectionManager {
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public WorldEditSelectionManager(final ResidenceMain plugin) {
|
public WorldEditSelectionManager(final ResidenceMain plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bedrock(final Player player, final boolean resadmin) {
|
public void bedrock(final Player player, final boolean resadmin) {
|
||||||
this.worldEdit(player);
|
this.worldEdit(player);
|
||||||
super.bedrock(player, resadmin);
|
super.bedrock(player, resadmin);
|
||||||
afterSelectionUpdate(player);
|
afterSelectionUpdate(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modify(final Player player, final boolean shift, final int amount) {
|
public void modify(final Player player, final boolean shift, final int amount) {
|
||||||
this.worldEdit(player);
|
this.worldEdit(player);
|
||||||
super.modify(player, shift, amount);
|
super.modify(player, shift, amount);
|
||||||
afterSelectionUpdate(player);
|
afterSelectionUpdate(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void placeLoc1(final Player player, final Location loc) {
|
public void placeLoc1(final Player player, final Location loc) {
|
||||||
this.worldEdit(player);
|
this.worldEdit(player);
|
||||||
super.placeLoc1(player, loc);
|
super.placeLoc1(player, loc);
|
||||||
this.afterSelectionUpdate(player);
|
this.afterSelectionUpdate(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void placeLoc2(final Player player, final Location loc) {
|
public void placeLoc2(final Player player, final Location loc) {
|
||||||
this.worldEdit(player);
|
this.worldEdit(player);
|
||||||
super.placeLoc2(player, loc);
|
super.placeLoc2(player, loc);
|
||||||
this.afterSelectionUpdate(player);
|
this.afterSelectionUpdate(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectChunk(final Player player) {
|
public void selectChunk(final Player player) {
|
||||||
this.worldEdit(player);
|
this.worldEdit(player);
|
||||||
super.selectChunk(player);
|
super.selectChunk(player);
|
||||||
afterSelectionUpdate(player);
|
afterSelectionUpdate(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showSelectionInfo(final Player player) {
|
public void showSelectionInfo(final Player player) {
|
||||||
this.worldEdit(player);
|
this.worldEdit(player);
|
||||||
super.showSelectionInfo(player);
|
super.showSelectionInfo(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sky(final Player player, final boolean resadmin) {
|
public void sky(final Player player, final boolean resadmin) {
|
||||||
this.worldEdit(player);
|
this.worldEdit(player);
|
||||||
super.sky(player, resadmin);
|
super.sky(player, resadmin);
|
||||||
afterSelectionUpdate(player);
|
afterSelectionUpdate(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean worldEdit(final Player player) {
|
public boolean worldEdit(final Player player) {
|
||||||
final WorldEditPlugin wep = (WorldEditPlugin) server.getPluginManager().getPlugin("WorldEdit");
|
final WorldEditPlugin wep = (WorldEditPlugin) server.getPluginManager().getPlugin("WorldEdit");
|
||||||
final Selection sel = wep.getSelection(player);
|
final Selection sel = wep.getSelection(player);
|
||||||
if (sel != null) {
|
if (sel != null) {
|
||||||
Location pos1 = sel.getMinimumPoint();
|
Location pos1 = sel.getMinimumPoint();
|
||||||
Location pos2 = sel.getMaximumPoint();
|
Location pos2 = sel.getMaximumPoint();
|
||||||
try {
|
try {
|
||||||
final CuboidRegion region = (CuboidRegion) sel.getRegionSelector().getRegion();
|
final CuboidRegion region = (CuboidRegion) sel.getRegionSelector().getRegion();
|
||||||
pos1 = new Location(player.getWorld(), region.getPos1().getX(), region.getPos1().getY(), region.getPos1().getZ());
|
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());
|
pos2 = new Location(player.getWorld(), region.getPos2().getX(), region.getPos2().getY(), region.getPos2().getZ());
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
}
|
}
|
||||||
this.playerLoc1.put(player.getName(), pos1);
|
this.playerLoc1.put(player.getName(), pos1);
|
||||||
this.playerLoc2.put(player.getName(), pos2);
|
this.playerLoc2.put(player.getName(), pos2);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void afterSelectionUpdate(final Player player) {
|
private void afterSelectionUpdate(final Player player) {
|
||||||
if (hasPlacedBoth(player.getName())) {
|
if (hasPlacedBoth(player.getName())) {
|
||||||
final WorldEditPlugin wep = (WorldEditPlugin) server.getPluginManager().getPlugin("WorldEdit");
|
final WorldEditPlugin wep = (WorldEditPlugin) server.getPluginManager().getPlugin("WorldEdit");
|
||||||
final World world = playerLoc1.get(player.getName()).getWorld();
|
final World world = playerLoc1.get(player.getName()).getWorld();
|
||||||
final Selection selection = new CuboidSelection(world, playerLoc1.get(player.getName()), playerLoc2.get(player.getName()));
|
final Selection selection = new CuboidSelection(world, playerLoc1.get(player.getName()), playerLoc2.get(player.getName()));
|
||||||
wep.setSelection(player, selection);
|
wep.setSelection(player, selection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,67 +16,67 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class Language {
|
public class Language {
|
||||||
public Map<String, String> text;
|
public Map<String, String> text;
|
||||||
|
|
||||||
public Language() {
|
public Language() {
|
||||||
text = new HashMap<String, String>();
|
text = new HashMap<String, String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Language parseText(final FileConfiguration node, final String topkey) {
|
public static Language parseText(final FileConfiguration node, final String topkey) {
|
||||||
final Language newholder = new Language();
|
final Language newholder = new Language();
|
||||||
final Set<String> keys = node.getConfigurationSection(topkey).getKeys(false);
|
final Set<String> keys = node.getConfigurationSection(topkey).getKeys(false);
|
||||||
for (final String key : keys) {
|
for (final String key : keys) {
|
||||||
newholder.text.put(key, node.getString(topkey + "." + key));
|
newholder.text.put(key, node.getString(topkey + "." + key));
|
||||||
}
|
}
|
||||||
return newholder;
|
return newholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPhrase(final String key) {
|
public String getPhrase(final String key) {
|
||||||
final String[] split = key.split("\\.");
|
final String[] split = key.split("\\.");
|
||||||
return getPhrase(split);
|
return getPhrase(split);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPhrase(final String key, final String words) {
|
public String getPhrase(final String key, final String words) {
|
||||||
return this.getPhrase(key.split("\\."), words);
|
return this.getPhrase(key.split("\\."), words);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPhrase(final String[] keys) {
|
public String getPhrase(final String[] keys) {
|
||||||
return this.getPhrase(keys, (String[]) null);
|
return this.getPhrase(keys, (String[]) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPhrase(final String[] keys, final String words) {
|
public String getPhrase(final String[] keys, final String words) {
|
||||||
if (words == null) {
|
if (words == null) {
|
||||||
return this.getPhrase(keys, (String[]) null);
|
return this.getPhrase(keys, (String[]) null);
|
||||||
}
|
}
|
||||||
return this.getPhrase(keys, words.split("\\."));
|
return this.getPhrase(keys, words.split("\\."));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPhrase(final String[] keys, final String[] words) {
|
public String getPhrase(final String[] keys, final String[] words) {
|
||||||
String sentence = "";
|
String sentence = "";
|
||||||
for (final String key : keys) {
|
for (final String key : keys) {
|
||||||
if (sentence.length() == 0) {
|
if (sentence.length() == 0) {
|
||||||
sentence = this.getText(key);
|
sentence = this.getText(key);
|
||||||
} else {
|
} else {
|
||||||
sentence = sentence + " " + this.getText(key).toLowerCase();
|
sentence = sentence + " " + this.getText(key).toLowerCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (words != null) {
|
if (words != null) {
|
||||||
for (int i = 0; i < words.length; i++) {
|
for (int i = 0; i < words.length; i++) {
|
||||||
sentence = sentence.replaceAll("%" + (i + 1), words[i]);
|
sentence = sentence.replaceAll("%" + (i + 1), words[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sentence;
|
return sentence;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(final String key, final String intext) {
|
public void setText(final String key, final String intext) {
|
||||||
text.put(key, intext);
|
text.put(key, intext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getText(final String key) {
|
private String getText(final String key) {
|
||||||
String t = text.get(key);
|
String t = text.get(key);
|
||||||
if (t == null) {
|
if (t == null) {
|
||||||
t = "<missing language key: " + key + ">";
|
t = "<missing language key: " + key + ">";
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,173 +22,173 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class HelpEntry {
|
public class HelpEntry {
|
||||||
protected static int linesPerPage = 7;
|
protected static int linesPerPage = 7;
|
||||||
protected String desc;
|
protected String desc;
|
||||||
protected String[] lines;
|
protected String[] lines;
|
||||||
protected String name;
|
protected String name;
|
||||||
protected List<HelpEntry> subentrys;
|
protected List<HelpEntry> subentrys;
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public HelpEntry(final ResidenceMain plugin, final String entryname) {
|
public HelpEntry(final ResidenceMain plugin, final String entryname) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
name = entryname;
|
name = entryname;
|
||||||
subentrys = new ArrayList<HelpEntry>();
|
subentrys = new ArrayList<HelpEntry>();
|
||||||
lines = new String[0];
|
lines = new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getLinesPerPage() {
|
public static int getLinesPerPage() {
|
||||||
return linesPerPage;
|
return linesPerPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HelpEntry parseHelp(final ResidenceMain plugin, final FileConfiguration node, final String key) {
|
public static HelpEntry parseHelp(final ResidenceMain plugin, final FileConfiguration node, final String key) {
|
||||||
final String split[] = key.split("\\.");
|
final String split[] = key.split("\\.");
|
||||||
final String thisname = split[split.length - 1];
|
final String thisname = split[split.length - 1];
|
||||||
final HelpEntry entry = new HelpEntry(plugin, thisname);
|
final HelpEntry entry = new HelpEntry(plugin, thisname);
|
||||||
final ConfigurationSection keysnode = node.getConfigurationSection(key);
|
final ConfigurationSection keysnode = node.getConfigurationSection(key);
|
||||||
Set<String> keys = null;
|
Set<String> keys = null;
|
||||||
if (keysnode != null) {
|
if (keysnode != null) {
|
||||||
keys = keysnode.getKeys(false);
|
keys = keysnode.getKeys(false);
|
||||||
}
|
}
|
||||||
if (keys != null) {
|
if (keys != null) {
|
||||||
if (keys.contains("Info")) {
|
if (keys.contains("Info")) {
|
||||||
final List<String> stringList = node.getStringList(key + ".Info");
|
final List<String> stringList = node.getStringList(key + ".Info");
|
||||||
if (stringList != null) {
|
if (stringList != null) {
|
||||||
entry.lines = new String[stringList.size()];
|
entry.lines = new String[stringList.size()];
|
||||||
for (int i = 0; i < stringList.size(); i++) {
|
for (int i = 0; i < stringList.size(); i++) {
|
||||||
entry.lines[i] = "- " + stringList.get(i);
|
entry.lines[i] = "- " + stringList.get(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (keys.contains("Description")) {
|
if (keys.contains("Description")) {
|
||||||
entry.desc = node.getString(key + ".Description");
|
entry.desc = node.getString(key + ".Description");
|
||||||
}
|
}
|
||||||
if (keys.contains("SubCommands")) {
|
if (keys.contains("SubCommands")) {
|
||||||
final Set<String> subcommandkeys = node.getConfigurationSection(key + ".SubCommands").getKeys(false);
|
final Set<String> subcommandkeys = node.getConfigurationSection(key + ".SubCommands").getKeys(false);
|
||||||
for (final String subkey : subcommandkeys) {
|
for (final String subkey : subcommandkeys) {
|
||||||
entry.subentrys.add(HelpEntry.parseHelp(plugin, node, key + ".SubCommands." + subkey));
|
entry.subentrys.add(HelpEntry.parseHelp(plugin, node, key + ".SubCommands." + subkey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLinesPerPage(final int lines) {
|
public static void setLinesPerPage(final int lines) {
|
||||||
linesPerPage = lines;
|
linesPerPage = lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSubEntry(final HelpEntry entry) {
|
public void addSubEntry(final HelpEntry entry) {
|
||||||
if (!subentrys.contains(entry)) {
|
if (!subentrys.contains(entry)) {
|
||||||
subentrys.add(entry);
|
subentrys.add(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containesEntry(final String name) {
|
public boolean containesEntry(final String name) {
|
||||||
return this.getSubEntry(name) != null;
|
return this.getSubEntry(name) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
if (desc == null) {
|
if (desc == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HelpEntry getSubEntry(final String name) {
|
public HelpEntry getSubEntry(final String name) {
|
||||||
final String[] split = name.split("\\.");
|
final String[] split = name.split("\\.");
|
||||||
HelpEntry entry = this;
|
HelpEntry entry = this;
|
||||||
for (final String entryname : split) {
|
for (final String entryname : split) {
|
||||||
entry = entry.findSubEntry(entryname);
|
entry = entry.findSubEntry(entryname);
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSubEntryCount() {
|
public int getSubEntryCount() {
|
||||||
return subentrys.size();
|
return subentrys.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHelp(final CommandSender sender, final int page) {
|
public void printHelp(final CommandSender sender, final int page) {
|
||||||
final List<String> helplines = this.getHelpData();
|
final List<String> helplines = this.getHelpData();
|
||||||
final int pagecount = (int) Math.ceil((double) helplines.size() / (double) linesPerPage);
|
final int pagecount = (int) Math.ceil((double) helplines.size() / (double) linesPerPage);
|
||||||
if (page > pagecount || page < 1) {
|
if (page > pagecount || page < 1) {
|
||||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
|
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("HelpPageHeader",
|
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("HelpPageHeader",
|
||||||
ChatColor.YELLOW + name + ChatColor.RED + "." + ChatColor.YELLOW + page + ChatColor.RED + "." + ChatColor.YELLOW + pagecount + ChatColor.RED));
|
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);
|
sender.sendMessage(ChatColor.DARK_AQUA + plugin.getLanguage().getPhrase("Description") + ": " + ChatColor.GREEN + desc);
|
||||||
final int start = linesPerPage * (page - 1);
|
final int start = linesPerPage * (page - 1);
|
||||||
final int end = start + linesPerPage;
|
final int end = start + linesPerPage;
|
||||||
boolean alternatecolor = false;
|
boolean alternatecolor = false;
|
||||||
for (int i = start; i < end; i++) {
|
for (int i = start; i < end; i++) {
|
||||||
if (helplines.size() > i) {
|
if (helplines.size() > i) {
|
||||||
if (alternatecolor) {
|
if (alternatecolor) {
|
||||||
sender.sendMessage(ChatColor.YELLOW + helplines.get(i));
|
sender.sendMessage(ChatColor.YELLOW + helplines.get(i));
|
||||||
alternatecolor = false;
|
alternatecolor = false;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.GOLD + helplines.get(i));
|
sender.sendMessage(ChatColor.GOLD + helplines.get(i));
|
||||||
alternatecolor = true;
|
alternatecolor = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (page < pagecount) {
|
if (page < pagecount) {
|
||||||
sender.sendMessage(ChatColor.GRAY + "---<" + plugin.getLanguage().getPhrase("NextPage") + ">---");
|
sender.sendMessage(ChatColor.GRAY + "---<" + plugin.getLanguage().getPhrase("NextPage") + ">---");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.GRAY + "-----------------------");
|
sender.sendMessage(ChatColor.GRAY + "-----------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHelp(final CommandSender sender, final int page, final String path) {
|
public void printHelp(final CommandSender sender, final int page, final String path) {
|
||||||
final HelpEntry subEntry = this.getSubEntry(path);
|
final HelpEntry subEntry = this.getSubEntry(path);
|
||||||
if (subEntry != null) {
|
if (subEntry != null) {
|
||||||
subEntry.printHelp(sender, page);
|
subEntry.printHelp(sender, page);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
|
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeSubEntry(final HelpEntry entry) {
|
public void removeSubEntry(final HelpEntry entry) {
|
||||||
if (subentrys.contains(entry)) {
|
if (subentrys.contains(entry)) {
|
||||||
subentrys.remove(entry);
|
subentrys.remove(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(final String description) {
|
public void setDescription(final String description) {
|
||||||
desc = description;
|
desc = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(final String inname) {
|
public void setName(final String inname) {
|
||||||
name = inname;
|
name = inname;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HelpEntry findSubEntry(final String name) {
|
private HelpEntry findSubEntry(final String name) {
|
||||||
for (final HelpEntry entry : subentrys) {
|
for (final HelpEntry entry : subentrys) {
|
||||||
if (entry.getName().equalsIgnoreCase(name)) {
|
if (entry.getName().equalsIgnoreCase(name)) {
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getHelpData() {
|
private List<String> getHelpData() {
|
||||||
final List<String> helplines = new ArrayList<String>();
|
final List<String> helplines = new ArrayList<String>();
|
||||||
helplines.addAll(Arrays.asList(lines));
|
helplines.addAll(Arrays.asList(lines));
|
||||||
if (subentrys.size() > 0) {
|
if (subentrys.size() > 0) {
|
||||||
helplines.add(ChatColor.LIGHT_PURPLE + "---" + plugin.getLanguage().getPhrase("SubCommands") + "---");
|
helplines.add(ChatColor.LIGHT_PURPLE + "---" + plugin.getLanguage().getPhrase("SubCommands") + "---");
|
||||||
}
|
}
|
||||||
for (final HelpEntry entry : subentrys) {
|
for (final HelpEntry entry : subentrys) {
|
||||||
helplines.add(ChatColor.GREEN + entry.getName() + ChatColor.YELLOW + " - " + entry.getDescription());
|
helplines.add(ChatColor.GREEN + entry.getName() + ChatColor.YELLOW + " - " + entry.getDescription());
|
||||||
}
|
}
|
||||||
return helplines;
|
return helplines;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,44 +19,44 @@ import cn.citycraft.Residence.ResidenceMain;
|
|||||||
*/
|
*/
|
||||||
public class InformationPager {
|
public class InformationPager {
|
||||||
|
|
||||||
public static int linesPerPage = 7;
|
public static int linesPerPage = 7;
|
||||||
|
|
||||||
public static int getLinesPerPage() {
|
public static int getLinesPerPage() {
|
||||||
return linesPerPage;
|
return linesPerPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printInfo(final ResidenceMain plugin, final CommandSender sender, final String title, final List<String> lines, final int page) {
|
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 perPage = 6;
|
||||||
final int start = (page - 1) * perPage;
|
final int start = (page - 1) * perPage;
|
||||||
final int end = start + perPage;
|
final int end = start + perPage;
|
||||||
int pagecount = (int) Math.ceil((double) lines.size() / (double) perPage);
|
int pagecount = (int) Math.ceil((double) lines.size() / (double) perPage);
|
||||||
if (pagecount == 0) {
|
if (pagecount == 0) {
|
||||||
pagecount = 1;
|
pagecount = 1;
|
||||||
}
|
}
|
||||||
if (page > pagecount) {
|
if (page > pagecount) {
|
||||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidPage"));
|
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidPage"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(ChatColor.YELLOW + "---<" + ChatColor.GREEN + title + ChatColor.YELLOW + ">---");
|
sender.sendMessage(ChatColor.YELLOW + "---<" + ChatColor.GREEN + title + ChatColor.YELLOW + ">---");
|
||||||
sender.sendMessage(ChatColor.YELLOW + "---<"
|
sender.sendMessage(ChatColor.YELLOW + "---<"
|
||||||
+ plugin.getLanguage().getPhrase("GenericPage", ChatColor.GREEN + String.format("%d", page) + ChatColor.YELLOW + "." + ChatColor.GREEN + pagecount + 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++) {
|
for (int i = start; i < end; i++) {
|
||||||
if (lines.size() > i) {
|
if (lines.size() > i) {
|
||||||
sender.sendMessage(ChatColor.GREEN + lines.get(i));
|
sender.sendMessage(ChatColor.GREEN + lines.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pagecount > page) {
|
if (pagecount > page) {
|
||||||
sender.sendMessage(ChatColor.GRAY + "---<" + plugin.getLanguage().getPhrase("NextPage") + ">---");
|
sender.sendMessage(ChatColor.GRAY + "---<" + plugin.getLanguage().getPhrase("NextPage") + ">---");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.GRAY + "-----------------------");
|
sender.sendMessage(ChatColor.GRAY + "-----------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printInfo(final ResidenceMain plugin, final CommandSender sender, final String title, final String[] lines, final int 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);
|
InformationPager.printInfo(plugin, sender, title, Arrays.asList(lines), page);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLinesPerPage(final int lines) {
|
public static void setLinesPerPage(final int lines) {
|
||||||
linesPerPage = lines;
|
linesPerPage = lines;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,101 +18,101 @@ import org.bukkit.World;
|
|||||||
import cn.citycraft.Residence.ResidenceMain;
|
import cn.citycraft.Residence.ResidenceMain;
|
||||||
|
|
||||||
public class DataBackup {
|
public class DataBackup {
|
||||||
private final File BackupDir;
|
private final File BackupDir;
|
||||||
|
|
||||||
ResidenceMain plugin;
|
ResidenceMain plugin;
|
||||||
|
|
||||||
public DataBackup(final ResidenceMain plugin) {
|
public DataBackup(final ResidenceMain plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
BackupDir = new File(plugin.getDataLocation(), "Backup");
|
BackupDir = new File(plugin.getDataLocation(), "Backup");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void backup() throws IOException {
|
public void backup() throws IOException {
|
||||||
try {
|
try {
|
||||||
BackupDir.mkdir();
|
BackupDir.mkdir();
|
||||||
final Date date = new Date();
|
final Date date = new Date();
|
||||||
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
|
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
|
||||||
final File fileZip = new File(BackupDir, dateFormat.format(date) + ".zip");
|
final File fileZip = new File(BackupDir, dateFormat.format(date) + ".zip");
|
||||||
|
|
||||||
// Create the Source List, and add directories/etc to the file.
|
// Create the Source List, and add directories/etc to the file.
|
||||||
final List<File> sources = new ArrayList<File>();
|
final List<File> sources = new ArrayList<File>();
|
||||||
|
|
||||||
final File saveFolder = new File(plugin.getDataLocation(), "Save");
|
final File saveFolder = new File(plugin.getDataLocation(), "Save");
|
||||||
final File worldFolder = new File(saveFolder, "Worlds");
|
final File worldFolder = new File(saveFolder, "Worlds");
|
||||||
if (!saveFolder.isDirectory()) {
|
if (!saveFolder.isDirectory()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File saveFile;
|
File saveFile;
|
||||||
for (final World world : Bukkit.getServer().getWorlds()) {
|
for (final World world : Bukkit.getServer().getWorlds()) {
|
||||||
saveFile = new File(worldFolder, "res_" + world.getName() + ".yml");
|
saveFile = new File(worldFolder, "res_" + world.getName() + ".yml");
|
||||||
if (saveFile.isFile()) {
|
if (saveFile.isFile()) {
|
||||||
sources.add(saveFile);
|
sources.add(saveFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
packZip(fileZip, sources);
|
packZip(fileZip, sources);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String buildPath(final String path, final String file) {
|
private String buildPath(final String path, final String file) {
|
||||||
if (path == null || path.isEmpty()) {
|
if (path == null || path.isEmpty()) {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
return path + File.separator + file;
|
return path + File.separator + file;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void packZip(final File output, final List<File> sources) throws IOException {
|
private void packZip(final File output, final List<File> sources) throws IOException {
|
||||||
final ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(output));
|
final ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(output));
|
||||||
zipOut.setLevel(Deflater.DEFAULT_COMPRESSION);
|
zipOut.setLevel(Deflater.DEFAULT_COMPRESSION);
|
||||||
|
|
||||||
for (final File source : sources) {
|
for (final File source : sources) {
|
||||||
if (source.isDirectory()) {
|
if (source.isDirectory()) {
|
||||||
zipDir(zipOut, "", source);
|
zipDir(zipOut, "", source);
|
||||||
} else {
|
} else {
|
||||||
zipFile(zipOut, "", source);
|
zipFile(zipOut, "", source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zipOut.flush();
|
zipOut.flush();
|
||||||
zipOut.close();
|
zipOut.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void zipDir(final ZipOutputStream zos, String path, final File dir) throws IOException {
|
private void zipDir(final ZipOutputStream zos, String path, final File dir) throws IOException {
|
||||||
if (!dir.canRead()) {
|
if (!dir.canRead()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final File[] files = dir.listFiles();
|
final File[] files = dir.listFiles();
|
||||||
path = buildPath(path, dir.getName());
|
path = buildPath(path, dir.getName());
|
||||||
|
|
||||||
for (final File source : files) {
|
for (final File source : files) {
|
||||||
if (source.isDirectory()) {
|
if (source.isDirectory()) {
|
||||||
zipDir(zos, path, source);
|
zipDir(zos, path, source);
|
||||||
} else {
|
} else {
|
||||||
zipFile(zos, path, source);
|
zipFile(zos, path, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void zipFile(final ZipOutputStream zos, final String path, final File file) throws IOException {
|
private void zipFile(final ZipOutputStream zos, final String path, final File file) throws IOException {
|
||||||
if (!file.canRead()) {
|
if (!file.canRead()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
zos.putNextEntry(new ZipEntry(buildPath(path, file.getName())));
|
zos.putNextEntry(new ZipEntry(buildPath(path, file.getName())));
|
||||||
|
|
||||||
final FileInputStream fis = new FileInputStream(file);
|
final FileInputStream fis = new FileInputStream(file);
|
||||||
final byte[] buffer = new byte[4092];
|
final byte[] buffer = new byte[4092];
|
||||||
int byteCount = 0;
|
int byteCount = 0;
|
||||||
|
|
||||||
while ((byteCount = fis.read(buffer)) != -1) {
|
while ((byteCount = fis.read(buffer)) != -1) {
|
||||||
zos.write(buffer, 0, byteCount);
|
zos.write(buffer, 0, byteCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
fis.close();
|
fis.close();
|
||||||
zos.closeEntry();
|
zos.closeEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,127 +21,127 @@ import net.milkbowl.vault.permission.Permission;
|
|||||||
*/
|
*/
|
||||||
public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInterface {
|
public class ResidenceVaultAdapter implements EconomyInterface, PermissionsInterface {
|
||||||
|
|
||||||
public static Permission permissions = null;
|
public static Permission permissions = null;
|
||||||
public static Economy economy = null;
|
public static Economy economy = null;
|
||||||
public static Chat chat = null;
|
public static Chat chat = null;
|
||||||
|
|
||||||
public ResidenceVaultAdapter(final Server s) {
|
public ResidenceVaultAdapter(final Server s) {
|
||||||
this.setupPermissions(s);
|
this.setupPermissions(s);
|
||||||
this.setupEconomy(s);
|
this.setupEconomy(s);
|
||||||
this.setupChat(s);
|
this.setupChat(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean add(final String playerName, final double amount) {
|
public boolean add(final String playerName, final double amount) {
|
||||||
return economy.depositPlayer(playerName, amount).transactionSuccess();
|
return economy.depositPlayer(playerName, amount).transactionSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean canAfford(final String playerName, final double amount) {
|
public boolean canAfford(final String playerName, final double amount) {
|
||||||
return economy.has(playerName, amount);
|
return economy.has(playerName, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean chatOK() {
|
public boolean chatOK() {
|
||||||
return chat != null;
|
return chat != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean economyOK() {
|
public boolean economyOK() {
|
||||||
return economy != null;
|
return economy != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public double getBalance(final String playerName) {
|
public double getBalance(final String playerName) {
|
||||||
return economy.getBalance(playerName);
|
return economy.getBalance(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getChatName() {
|
public String getChatName() {
|
||||||
if (chat != null)
|
if (chat != null)
|
||||||
return chat.getName();
|
return chat.getName();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEconomyName() {
|
public String getEconomyName() {
|
||||||
if (economy != null)
|
if (economy != null)
|
||||||
return economy.getName();
|
return economy.getName();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Vault";
|
return "Vault";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermissionsName() {
|
public String getPermissionsName() {
|
||||||
if (permissions != null)
|
if (permissions != null)
|
||||||
return permissions.getName();
|
return permissions.getName();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerGroup(final Player player) {
|
public String getPlayerGroup(final Player player) {
|
||||||
final String group = permissions.getPrimaryGroup(player).toLowerCase();
|
final String group = permissions.getPrimaryGroup(player).toLowerCase();
|
||||||
if (group == null)
|
if (group == null)
|
||||||
return group;
|
return group;
|
||||||
return group.toLowerCase();
|
return group.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public String getPlayerGroup(final String player, final String world) {
|
public String getPlayerGroup(final String player, final String world) {
|
||||||
final String group = permissions.getPrimaryGroup(world, player);
|
final String group = permissions.getPrimaryGroup(world, player);
|
||||||
if (group == null)
|
if (group == null)
|
||||||
return group;
|
return group;
|
||||||
return group.toLowerCase();
|
return group.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean permissionsOK() {
|
public boolean permissionsOK() {
|
||||||
if (permissions != null && !permissions.getName().equalsIgnoreCase("SuperPerms"))
|
if (permissions != null && !permissions.getName().equalsIgnoreCase("SuperPerms"))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean subtract(final String playerName, final double amount) {
|
public boolean subtract(final String playerName, final double amount) {
|
||||||
return economy.withdrawPlayer(playerName, amount).transactionSuccess();
|
return economy.withdrawPlayer(playerName, amount).transactionSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean transfer(final String playerFrom, final String playerTo, final double amount) {
|
public boolean transfer(final String playerFrom, final String playerTo, final double amount) {
|
||||||
if (economy.withdrawPlayer(playerFrom, amount).transactionSuccess()) {
|
if (economy.withdrawPlayer(playerFrom, amount).transactionSuccess()) {
|
||||||
if (economy.depositPlayer(playerTo, amount).transactionSuccess())
|
if (economy.depositPlayer(playerTo, amount).transactionSuccess())
|
||||||
return true;
|
return true;
|
||||||
economy.depositPlayer(playerFrom, amount);
|
economy.depositPlayer(playerFrom, amount);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setupChat(final Server s) {
|
private boolean setupChat(final Server s) {
|
||||||
final RegisteredServiceProvider<Chat> chatProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
|
final RegisteredServiceProvider<Chat> chatProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
|
||||||
if (chatProvider != null) {
|
if (chatProvider != null) {
|
||||||
chat = chatProvider.getProvider();
|
chat = chatProvider.getProvider();
|
||||||
}
|
}
|
||||||
return (chat != null);
|
return (chat != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setupEconomy(final Server s) {
|
private boolean setupEconomy(final Server s) {
|
||||||
final RegisteredServiceProvider<Economy> economyProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
final RegisteredServiceProvider<Economy> economyProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||||
if (economyProvider != null) {
|
if (economyProvider != null) {
|
||||||
economy = economyProvider.getProvider();
|
economy = economyProvider.getProvider();
|
||||||
}
|
}
|
||||||
return (economy != null);
|
return (economy != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setupPermissions(final Server s) {
|
private boolean setupPermissions(final Server s) {
|
||||||
final RegisteredServiceProvider<Permission> permissionProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
final RegisteredServiceProvider<Permission> permissionProvider = s.getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
||||||
if (permissionProvider != null) {
|
if (permissionProvider != null) {
|
||||||
permissions = permissionProvider.getProvider();
|
permissions = permissionProvider.getProvider();
|
||||||
}
|
}
|
||||||
return (permissions != null);
|
return (permissions != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,117 +27,117 @@ import cn.citycraft.Residence.text.Language;
|
|||||||
import cn.citycraft.Residence.text.help.HelpEntry;
|
import cn.citycraft.Residence.text.help.HelpEntry;
|
||||||
|
|
||||||
public class Residence {
|
public class Residence {
|
||||||
static ResidenceMain instance;
|
static ResidenceMain instance;
|
||||||
|
|
||||||
public Residence(final ResidenceMain instance) {
|
public Residence(final ResidenceMain instance) {
|
||||||
Residence.instance = instance;
|
Residence.instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChatManager getChatManager() {
|
public static ChatManager getChatManager() {
|
||||||
return instance.getChatManager();
|
return instance.getChatManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConfigManager getConfigManager() {
|
public static ConfigManager getConfigManager() {
|
||||||
return instance.getConfigManager();
|
return instance.getConfigManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getDataLocation() {
|
public static File getDataLocation() {
|
||||||
return instance.getDataFolder();
|
return instance.getDataFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, String> getDeleteConfirm() {
|
public static Map<String, String> getDeleteConfirm() {
|
||||||
return instance.getDeleteConfirm();
|
return instance.getDeleteConfirm();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EconomyInterface getEconomyManager() {
|
public static EconomyInterface getEconomyManager() {
|
||||||
return instance.getEconomyManager();
|
return instance.getEconomyManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityManager getEntityManager() {
|
public static EntityManager getEntityManager() {
|
||||||
return instance.getEntityManager();
|
return instance.getEntityManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HelpEntry getHelppages() {
|
public static HelpEntry getHelppages() {
|
||||||
return instance.getHelppages();
|
return instance.getHelppages();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WorldItemManager getItemManager() {
|
public static WorldItemManager getItemManager() {
|
||||||
return instance.getItemManager();
|
return instance.getItemManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Language getLanguage() {
|
public static Language getLanguage() {
|
||||||
if (instance.getLanguage() == null) {
|
if (instance.getLanguage() == null) {
|
||||||
instance.setLanguage(new Language());
|
instance.setLanguage(new Language());
|
||||||
}
|
}
|
||||||
return instance.getLanguage();
|
return instance.getLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LeaseManager getLeaseManager() {
|
public static LeaseManager getLeaseManager() {
|
||||||
return instance.getLeaseManager();
|
return instance.getLeaseManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PermissionListManager getPermissionListManager() {
|
public static PermissionListManager getPermissionListManager() {
|
||||||
return instance.getPermissionListManager();
|
return instance.getPermissionListManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PermissionManager getPermissionManager() {
|
public static PermissionManager getPermissionManager() {
|
||||||
return instance.getPermissionManager();
|
return instance.getPermissionManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FlagPermissions getPermsByLoc(final Location loc) {
|
public static FlagPermissions getPermsByLoc(final Location loc) {
|
||||||
final ClaimedResidence res = getResidenceManager().getByLoc(loc);
|
final ClaimedResidence res = getResidenceManager().getByLoc(loc);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
return res.getPermissions();
|
return res.getPermissions();
|
||||||
}
|
}
|
||||||
return getWorldFlags().getPerms(loc.getWorld().getName());
|
return getWorldFlags().getPerms(loc.getWorld().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FlagPermissions getPermsByLocForPlayer(final Location loc, final Player player) {
|
public static FlagPermissions getPermsByLocForPlayer(final Location loc, final Player player) {
|
||||||
final ClaimedResidence res = getResidenceManager().getByLoc(loc);
|
final ClaimedResidence res = getResidenceManager().getByLoc(loc);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
return res.getPermissions();
|
return res.getPermissions();
|
||||||
} else if (player != null) {
|
} else if (player != null) {
|
||||||
return getWorldFlags().getPerms(player);
|
return getWorldFlags().getPerms(player);
|
||||||
} else {
|
} else {
|
||||||
return getWorldFlags().getPerms(loc.getWorld().getName());
|
return getWorldFlags().getPerms(loc.getWorld().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RentManager getRentManager() {
|
public static RentManager getRentManager() {
|
||||||
return instance.getRentManager();
|
return instance.getRentManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResidenceManager getResidenceManager() {
|
public static ResidenceManager getResidenceManager() {
|
||||||
return instance.getResidenceManager();
|
return instance.getResidenceManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SelectionManager getSelectionManager() {
|
public static SelectionManager getSelectionManager() {
|
||||||
return instance.getSelectionManager();
|
return instance.getSelectionManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TransactionManager getTransactionManager() {
|
public static TransactionManager getTransactionManager() {
|
||||||
return instance.getTransactionManager();
|
return instance.getTransactionManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WorldFlagManager getWorldFlags() {
|
public static WorldFlagManager getWorldFlags() {
|
||||||
return instance.getWorldFlags();
|
return instance.getWorldFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isResAdminOn(final Player player) {
|
public static boolean isResAdminOn(final Player player) {
|
||||||
if (instance.getResadminToggle().contains(player.getName())) {
|
if (instance.getResadminToggle().contains(player.getName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isResAdminOn(final String player) {
|
public static boolean isResAdminOn(final String player) {
|
||||||
if (instance.getResadminToggle().contains(player.toLowerCase())) {
|
if (instance.getResadminToggle().contains(player.toLowerCase())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUseWorldEdit() {
|
public static boolean isUseWorldEdit() {
|
||||||
return instance.isUseWorldEdit();
|
return instance.isUseWorldEdit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,21 +15,20 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
|||||||
*/
|
*/
|
||||||
public class CancellableResidenceEvent extends ResidenceEvent implements Cancellable {
|
public class CancellableResidenceEvent extends ResidenceEvent implements Cancellable {
|
||||||
|
|
||||||
protected boolean cancelled;
|
protected boolean cancelled;
|
||||||
|
|
||||||
public CancellableResidenceEvent(String eventName, ClaimedResidence resref)
|
public CancellableResidenceEvent(String eventName, ClaimedResidence resref) {
|
||||||
{
|
super(eventName, resref);
|
||||||
super(eventName,resref);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean bln) {
|
public void setCancelled(boolean bln) {
|
||||||
cancelled = bln;
|
cancelled = bln;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,22 +16,21 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
|||||||
*/
|
*/
|
||||||
public class CancellableResidencePlayerEvent extends ResidencePlayerEvent implements Cancellable {
|
public class CancellableResidencePlayerEvent extends ResidencePlayerEvent implements Cancellable {
|
||||||
|
|
||||||
protected boolean cancelled;
|
protected boolean cancelled;
|
||||||
|
|
||||||
public CancellableResidencePlayerEvent(String eventName, ClaimedResidence resref, Player player)
|
public CancellableResidencePlayerEvent(String eventName, ClaimedResidence resref, Player player) {
|
||||||
{
|
super(eventName, resref, player);
|
||||||
super(eventName, resref, player);
|
cancelled = false;
|
||||||
cancelled = false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean bln) {
|
public void setCancelled(boolean bln) {
|
||||||
cancelled = bln;
|
cancelled = bln;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,21 +16,20 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
|||||||
*/
|
*/
|
||||||
public class CancellableResidencePlayerFlagEvent extends ResidencePlayerFlagEvent implements Cancellable {
|
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)
|
public CancellableResidencePlayerFlagEvent(String eventName, ClaimedResidence resref, Player player, String flag, FlagType type, String target) {
|
||||||
{
|
super(eventName, resref, player, flag, type, target);
|
||||||
super(eventName, resref, player, flag, type, target);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean bln) {
|
public void setCancelled(boolean bln) {
|
||||||
cancelled = bln;
|
cancelled = bln;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
|||||||
*/
|
*/
|
||||||
public class ResidenceChangedEvent extends ResidencePlayerEvent {
|
public class ResidenceChangedEvent extends ResidencePlayerEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private ClaimedResidence from = null;
|
private ClaimedResidence from = null;
|
||||||
private ClaimedResidence to = null;
|
private ClaimedResidence to = null;
|
||||||
|
|
||||||
@@ -37,38 +37,41 @@ public class ResidenceChangedEvent extends ResidencePlayerEvent {
|
|||||||
* Constructs a {@link ResidenceChangedEvent} to identify a residence transition for the
|
* Constructs a {@link ResidenceChangedEvent} to identify a residence transition for the
|
||||||
* given player
|
* given player
|
||||||
*
|
*
|
||||||
* @param from the residence that the player left or {@code null} if coming from an
|
* @param from
|
||||||
* unprotected area.
|
* the residence that the player left or {@code null} if coming from an
|
||||||
* @param to the residence that the player entered or {@code null} if entering an
|
* unprotected area.
|
||||||
* unprotected area.
|
* @param to
|
||||||
* @param player player involved in the transition
|
* 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) {
|
public ResidenceChangedEvent(ClaimedResidence from, ClaimedResidence to, Player player) {
|
||||||
super("RESIDENCE_CHANGE", null, player);
|
super("RESIDENCE_CHANGE", null, player);
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.to = to;
|
this.to = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the residence from which player came.
|
* Returns the residence from which player came.
|
||||||
*
|
*
|
||||||
* @return the residence from which player came or {@code null} if player came from an
|
* @return the residence from which player came or {@code null} if player came from an
|
||||||
* unprotected area
|
* unprotected area
|
||||||
*/
|
*/
|
||||||
public ClaimedResidence getFrom() {
|
public ClaimedResidence getFrom() {
|
||||||
return from;
|
return from;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the residence that player has entered.
|
* Returns the residence that player has entered.
|
||||||
*
|
*
|
||||||
* @return the residence that player has entered or {@code null} if player enters an
|
* @return the residence that player has entered or {@code null} if player enters an
|
||||||
* unprotected area
|
* unprotected area
|
||||||
*/
|
*/
|
||||||
public ClaimedResidence getTo() {
|
public ClaimedResidence getTo() {
|
||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
|||||||
public class ResidenceChatEvent extends CancellableResidencePlayerEvent {
|
public class ResidenceChatEvent extends CancellableResidencePlayerEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
@@ -28,30 +29,26 @@ public class ResidenceChatEvent extends CancellableResidencePlayerEvent {
|
|||||||
|
|
||||||
protected String message;
|
protected String message;
|
||||||
ChatColor color;
|
ChatColor color;
|
||||||
|
|
||||||
public ResidenceChatEvent(ClaimedResidence resref, Player player, String message, ChatColor color) {
|
public ResidenceChatEvent(ClaimedResidence resref, Player player, String message, ChatColor color) {
|
||||||
super("RESIDENCE_CHAT_EVENT", resref, player);
|
super("RESIDENCE_CHAT_EVENT", resref, player);
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getChatMessage()
|
public String getChatMessage() {
|
||||||
{
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChatMessage(String newmessage)
|
public void setChatMessage(String newmessage) {
|
||||||
{
|
|
||||||
message = newmessage;
|
message = newmessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatColor getColor()
|
public ChatColor getColor() {
|
||||||
{
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(ChatColor c)
|
public void setColor(ChatColor c) {
|
||||||
{
|
|
||||||
color = c;
|
color = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,53 +16,51 @@ import org.bukkit.event.HandlerList;
|
|||||||
*/
|
*/
|
||||||
public class ResidenceCommandEvent extends Event implements Cancellable {
|
public class ResidenceCommandEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean cancelled;
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
protected String cmd;
|
protected boolean cancelled;
|
||||||
protected String arglist[];
|
|
||||||
CommandSender commandsender;
|
|
||||||
public ResidenceCommandEvent(String command, String args[], CommandSender sender)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
cancelled = false;
|
|
||||||
arglist = args;
|
|
||||||
cmd = command;
|
|
||||||
commandsender = sender;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getArgs()
|
protected String cmd;
|
||||||
{
|
protected String arglist[];
|
||||||
return arglist;
|
CommandSender commandsender;
|
||||||
}
|
|
||||||
|
|
||||||
public String getCommand()
|
public ResidenceCommandEvent(String command, String args[], CommandSender sender) {
|
||||||
{
|
super();
|
||||||
return cmd;
|
cancelled = false;
|
||||||
}
|
arglist = args;
|
||||||
|
cmd = command;
|
||||||
|
commandsender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public String[] getArgs() {
|
||||||
public HandlerList getHandlers() {
|
return arglist;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public CommandSender getSender()
|
public String getCommand() {
|
||||||
{
|
return cmd;
|
||||||
return commandsender;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public HandlerList getHandlers() {
|
||||||
return cancelled;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public CommandSender getSender() {
|
||||||
public void setCancelled(boolean bln) {
|
return commandsender;
|
||||||
cancelled = bln;
|
}
|
||||||
}
|
|
||||||
|
@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 {
|
public class ResidenceCreationEvent extends CancellableResidencePlayerEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
@@ -30,30 +31,25 @@ public class ResidenceCreationEvent extends CancellableResidencePlayerEvent {
|
|||||||
protected String resname;
|
protected String resname;
|
||||||
CuboidArea area;
|
CuboidArea area;
|
||||||
|
|
||||||
public ResidenceCreationEvent(Player player, String newname, ClaimedResidence resref, CuboidArea resarea)
|
public ResidenceCreationEvent(Player player, String newname, ClaimedResidence resref, CuboidArea resarea) {
|
||||||
{
|
super("RESIDENCE_CREATE", resref, player);
|
||||||
super("RESIDENCE_CREATE",resref,player);
|
|
||||||
resname = newname;
|
resname = newname;
|
||||||
area = resarea;
|
area = resarea;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResidenceName()
|
public String getResidenceName() {
|
||||||
{
|
|
||||||
return resname;
|
return resname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResidenceName(String name)
|
public void setResidenceName(String name) {
|
||||||
{
|
|
||||||
resname = name;
|
resname = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CuboidArea getPhysicalArea()
|
public CuboidArea getPhysicalArea() {
|
||||||
{
|
|
||||||
return area;
|
return area;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPhysicalArea(CuboidArea newarea)
|
public void setPhysicalArea(CuboidArea newarea) {
|
||||||
{
|
|
||||||
area = newarea;
|
area = newarea;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,19 +28,19 @@ public class ResidenceDeleteEvent extends CancellableResidencePlayerEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum DeleteCause {
|
public enum DeleteCause {
|
||||||
LEASE_EXPIRE,PLAYER_DELETE,OTHER
|
LEASE_EXPIRE,
|
||||||
|
PLAYER_DELETE,
|
||||||
|
OTHER
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteCause cause;
|
DeleteCause cause;
|
||||||
|
|
||||||
public ResidenceDeleteEvent(Player player, ClaimedResidence resref, DeleteCause delcause)
|
public ResidenceDeleteEvent(Player player, ClaimedResidence resref, DeleteCause delcause) {
|
||||||
{
|
|
||||||
super("RESIDENCE_DELETE", resref, player);
|
super("RESIDENCE_DELETE", resref, player);
|
||||||
cause = delcause;
|
cause = delcause;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteCause getCause()
|
public DeleteCause getCause() {
|
||||||
{
|
|
||||||
return cause;
|
return cause;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,32 +16,31 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
|||||||
*/
|
*/
|
||||||
public class ResidenceEvent extends Event {
|
public class ResidenceEvent extends Event {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String message;
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
ClaimedResidence res;
|
private String message;
|
||||||
|
|
||||||
public ResidenceEvent(String eventName, ClaimedResidence resref)
|
ClaimedResidence res;
|
||||||
{
|
|
||||||
message = eventName;
|
|
||||||
res = resref;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public ResidenceEvent(String eventName, ClaimedResidence resref) {
|
||||||
public HandlerList getHandlers() {
|
message = eventName;
|
||||||
return handlers;
|
res = resref;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
@Override
|
||||||
return message;
|
public HandlerList getHandlers() {
|
||||||
}
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
public ClaimedResidence getResidence()
|
public String getMessage() {
|
||||||
{
|
return message;
|
||||||
return res;
|
}
|
||||||
}
|
|
||||||
|
public ClaimedResidence getResidence() {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import com.bekvon.bukkit.residence.protection.FlagPermissions.FlagState;
|
|||||||
public class ResidenceFlagChangeEvent extends CancellableResidencePlayerFlagEvent {
|
public class ResidenceFlagChangeEvent extends CancellableResidencePlayerFlagEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
@@ -29,14 +30,12 @@ public class ResidenceFlagChangeEvent extends CancellableResidencePlayerFlagEven
|
|||||||
|
|
||||||
FlagState newstate;
|
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);
|
super("RESIDENCE_FLAG_CHANGE", resref, player, flag, type, target);
|
||||||
newstate = newState;
|
newstate = newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlagState getNewState()
|
public FlagState getNewState() {
|
||||||
{
|
|
||||||
return newstate;
|
return newstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,46 +14,42 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class ResidenceFlagCheckEvent extends ResidenceFlagEvent {
|
public class ResidenceFlagCheckEvent extends ResidenceFlagEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean override;
|
private boolean override;
|
||||||
|
|
||||||
private boolean overridevalue;
|
private boolean overridevalue;
|
||||||
boolean defaultvalue;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getDefaultValue()
|
public ResidenceFlagCheckEvent(ClaimedResidence resref, String flag, FlagType type, String target, boolean defaultValue) {
|
||||||
{
|
super("RESIDENCE_FLAG_CHECK", resref, flag, type, target);
|
||||||
return defaultvalue;
|
defaultvalue = defaultValue;
|
||||||
}
|
override = false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public boolean getDefaultValue() {
|
||||||
public HandlerList getHandlers() {
|
return defaultvalue;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getOverrideValue()
|
@Override
|
||||||
{
|
public HandlerList getHandlers() {
|
||||||
return overridevalue;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOverriden()
|
public boolean getOverrideValue() {
|
||||||
{
|
return overridevalue;
|
||||||
return override;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void overrideCheck(boolean flagval)
|
public boolean isOverriden() {
|
||||||
{
|
return override;
|
||||||
overridevalue = flagval;
|
}
|
||||||
override=true;
|
|
||||||
}
|
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 {
|
public class ResidenceFlagEvent extends ResidenceEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
@@ -25,10 +26,11 @@ public class ResidenceFlagEvent extends ResidenceEvent {
|
|||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum FlagType
|
public enum FlagType {
|
||||||
{
|
RESIDENCE,
|
||||||
RESIDENCE,GROUP,PLAYER
|
GROUP,
|
||||||
|
PLAYER
|
||||||
}
|
}
|
||||||
|
|
||||||
String flagname;
|
String flagname;
|
||||||
@@ -36,26 +38,22 @@ public class ResidenceFlagEvent extends ResidenceEvent {
|
|||||||
FlagState flagstate;
|
FlagState flagstate;
|
||||||
String flagtarget;
|
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);
|
super(eventName, resref);
|
||||||
flagname = flag;
|
flagname = flag;
|
||||||
flagtype = type;
|
flagtype = type;
|
||||||
flagtarget = target;
|
flagtarget = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFlag()
|
public String getFlag() {
|
||||||
{
|
|
||||||
return flagname;
|
return flagname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlagType getFlagType()
|
public FlagType getFlagType() {
|
||||||
{
|
|
||||||
return flagtype;
|
return flagtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFlagTargetPlayerOrGroup()
|
public String getFlagTargetPlayerOrGroup() {
|
||||||
{
|
|
||||||
return flagtarget;
|
return flagtarget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
package com.bekvon.bukkit.residence.event;
|
package com.bekvon.bukkit.residence.event;
|
||||||
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||||
@@ -15,6 +16,7 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
|||||||
public class ResidenceOwnerChangeEvent extends ResidenceEvent {
|
public class ResidenceOwnerChangeEvent extends ResidenceEvent {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
@@ -26,14 +28,12 @@ public class ResidenceOwnerChangeEvent extends ResidenceEvent {
|
|||||||
|
|
||||||
protected String newowner;
|
protected String newowner;
|
||||||
|
|
||||||
public ResidenceOwnerChangeEvent(ClaimedResidence resref, String newOwner)
|
public ResidenceOwnerChangeEvent(ClaimedResidence resref, String newOwner) {
|
||||||
{
|
super("RESIDENCE_OWNER_CHANGE", resref);
|
||||||
super("RESIDENCE_OWNER_CHANGE",resref);
|
|
||||||
newowner = newOwner;
|
newowner = newOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNewOwner()
|
public String getNewOwner() {
|
||||||
{
|
|
||||||
return newowner;
|
return newowner;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,29 +15,29 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
|||||||
*/
|
*/
|
||||||
public class ResidencePlayerEvent extends ResidenceEvent implements ResidencePlayerEventInterface {
|
public class ResidencePlayerEvent extends ResidenceEvent implements ResidencePlayerEventInterface {
|
||||||
|
|
||||||
Player p;
|
Player p;
|
||||||
|
|
||||||
public ResidencePlayerEvent(final String eventName, final ClaimedResidence resref, final Player player) {
|
public ResidencePlayerEvent(final String eventName, final ClaimedResidence resref, final Player player) {
|
||||||
super(eventName, resref);
|
super(eventName, resref);
|
||||||
res = resref;
|
res = resref;
|
||||||
p = player;
|
p = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAdmin() {
|
public boolean isAdmin() {
|
||||||
if (isPlayer()) {
|
if (isPlayer()) {
|
||||||
return p.hasPermission("residence.admin") || p.isOp();
|
return p.hasPermission("residence.admin") || p.isOp();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPlayer() {
|
public boolean isPlayer() {
|
||||||
return p != null;
|
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