diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 60915d509..0f7b4fb93 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -19,6 +19,7 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; +import com.intellectualcrafters.plot.commands.Add; import com.intellectualcrafters.plot.commands.Auto; import com.intellectualcrafters.plot.commands.BukkitCommand; import com.intellectualcrafters.plot.commands.Buy; @@ -42,10 +43,9 @@ import com.intellectualcrafters.plot.commands.DebugRoadRegen; import com.intellectualcrafters.plot.commands.DebugSaveTest; import com.intellectualcrafters.plot.commands.DebugUUID; import com.intellectualcrafters.plot.commands.Delete; -import com.intellectualcrafters.plot.commands.Denied; +import com.intellectualcrafters.plot.commands.Deny; import com.intellectualcrafters.plot.commands.FlagCmd; import com.intellectualcrafters.plot.commands.Help; -import com.intellectualcrafters.plot.commands.Helpers; import com.intellectualcrafters.plot.commands.Home; import com.intellectualcrafters.plot.commands.Inbox; import com.intellectualcrafters.plot.commands.Info; @@ -59,6 +59,7 @@ import com.intellectualcrafters.plot.commands.Purge; import com.intellectualcrafters.plot.commands.Rate; import com.intellectualcrafters.plot.commands.RegenAllRoads; import com.intellectualcrafters.plot.commands.Reload; +import com.intellectualcrafters.plot.commands.Remove; import com.intellectualcrafters.plot.commands.SchematicCmd; import com.intellectualcrafters.plot.commands.Set; import com.intellectualcrafters.plot.commands.SetOwner; @@ -68,9 +69,11 @@ import com.intellectualcrafters.plot.commands.TP; import com.intellectualcrafters.plot.commands.Target; import com.intellectualcrafters.plot.commands.Template; import com.intellectualcrafters.plot.commands.Trim; -import com.intellectualcrafters.plot.commands.Trusted; +import com.intellectualcrafters.plot.commands.Trust; import com.intellectualcrafters.plot.commands.Unclaim; +import com.intellectualcrafters.plot.commands.Undeny; import com.intellectualcrafters.plot.commands.Unlink; +import com.intellectualcrafters.plot.commands.Untrust; import com.intellectualcrafters.plot.commands.Visit; import com.intellectualcrafters.plot.commands.WE_Anywhere; import com.intellectualcrafters.plot.commands.list; @@ -230,9 +233,14 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { MainCommand.subCommands.add(new Clear()); MainCommand.subCommands.add(new Delete()); MainCommand.subCommands.add(new SetOwner()); - MainCommand.subCommands.add(new Denied()); - MainCommand.subCommands.add(new Helpers()); - MainCommand.subCommands.add(new Trusted()); + + MainCommand.subCommands.add(new Trust()); + MainCommand.subCommands.add(new Add()); + MainCommand.subCommands.add(new Deny()); + MainCommand.subCommands.add(new Untrust()); + MainCommand.subCommands.add(new Remove()); + MainCommand.subCommands.add(new Undeny()); + MainCommand.subCommands.add(new Info()); MainCommand.subCommands.add(new list()); MainCommand.subCommands.add(new Help()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index 80fe3fe78..735efd2cc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -658,7 +658,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; /** * Get the numbers of plots, which the player is able to build in * - * @param player Player, for whom we're getting the plots (trusted, helper and owner) + * @param player Player, for whom we're getting the plots (trusted, member and owner) * * @return the number of allowed plots * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Add.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Add.java new file mode 100644 index 000000000..0936667f1 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Add.java @@ -0,0 +1,92 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PlotSquared - A plot manager and world generator for the Bukkit API / +// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / +// / +// This program is free software; you can redistribute it and/or modify / +// it under the terms of the GNU General Public License as published by / +// the Free Software Foundation; either version 3 of the License, or / +// (at your option) any later version. / +// / +// This program is distributed in the hope that it will be useful, / +// but WITHOUT ANY WARRANTY; without even the implied warranty of / +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / +// GNU General Public License for more details. / +// / +// You should have received a copy of the GNU General Public License / +// along with this program; if not, write to the Free Software Foundation, / +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / +// / +// You can contact us via: support@intellectualsites.com / +//////////////////////////////////////////////////////////////////////////////////////////////////// +package com.intellectualcrafters.plot.commands; + +import java.util.UUID; + +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.EventUtil; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; + +public class Add extends SubCommand { + public Add() { + super(Command.ADD, "Allow a user to build while you are online", "add ", CommandCategory.ACTIONS, true); + } + + @Override + public boolean execute(final PlotPlayer plr, final String... args) { + if (args.length != 1) { + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot add "); + return true; + } + final Location loc = plr.getLocation(); + final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } + if ((plot == null) || !plot.hasOwner()) { + MainUtil.sendMessage(plr, C.PLOT_UNOWNED); + return false; + } + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.add")) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); + return true; + } + UUID uuid; + if (args[0].equalsIgnoreCase("*")) { + uuid = DBFunc.everyone; + } else { + uuid = UUIDHandler.getUUID(args[0]); + } + if (uuid == null) { + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); + return false; + } + if (!plot.members.contains(uuid)) { + if (plot.isOwner(uuid)) { + MainUtil.sendMessage(plr, C.ALREADY_OWNER); + return false; + } + if (plot.trusted.contains(uuid)) { + plot.trusted.remove(uuid); + DBFunc.removeTrusted(loc.getWorld(), plot, uuid); + } + if (plot.denied.contains(uuid)) { + plot.denied.remove(uuid); + DBFunc.removeDenied(loc.getWorld(), plot, uuid); + } + plot.addMember(uuid); + DBFunc.setMember(loc.getWorld(), plot, uuid); + EventUtil.manager.callMember(plr, plot, uuid, true); + } else { + MainUtil.sendMessage(plr, C.ALREADY_ADDED); + return false; + } + MainUtil.sendMessage(plr, C.MEMBER_ADDED); + return true; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index 0a335f242..55211105c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -451,10 +451,12 @@ public class Cluster extends SubCommand { } if (args[1].toLowerCase().equals("add")) { cluster.helpers.add(uuid); + DBFunc.setHelper(cluster, uuid); return MainUtil.sendMessage(plr, C.CLUSTER_ADDED_HELPER); } if (args[1].toLowerCase().equals("remove")) { cluster.helpers.remove(uuid); + DBFunc.removeHelper(cluster, uuid); return MainUtil.sendMessage(plr, C.CLUSTER_REMOVED_HELPER); } MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster helpers "); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java index 18746cef7..40e609f91 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java @@ -34,12 +34,21 @@ public enum Command { // (Rating system) (ratings can be stored as the average, and number of // ratings) // - /plot rate - MOVE("move", ""), + + ADD("add","a"), + TRUST("trust", "t"), + DENY("deny", "d"), + + REMOVE("remove", "r"), + UNTRUST("untrust", "ut"), + UNDENY("undeny", "ud"), + + MOVE("move"), FLAG("flag", "f"), TARGET("target"), CLUSTER("cluster", "clusters"), BUY("buy", "b"), - CREATEROADSCHEMATIC("createroadschematic"), + CREATEROADSCHEMATIC("createroadschematic", "crs"), DEBUGROADREGEN("debugroadregen"), DEBUGFIXFLAGS("debugfixflags"), REGENALLROADS("regenallroads"), @@ -51,29 +60,22 @@ public enum Command { INBOX("inbox"), DEBUGCLAIMTEST("debugclaimtest"), COMMENT("comment", "msg"), - TRUSTED("trusted", "trust"), PASTE("paste"), CLIPBOARD("clipboard", "cboard"), COPY("copy"), KICK("kick", "k"), - HELPERS("helpers", "hp"), - DENIED("denied", "dn"), CLAIM("claim", "c"), MERGE("merge", "m"), UNLINK("unlink", "u"), - CLEAR("clear", "clear", new CommandPermission("plots.clear")), - DELETE("delete", "d", new CommandPermission("plots.delete")), - DEBUG("debug", "debug", new CommandPermission("plots.admin")), + CLEAR("clear", "", new CommandPermission("plots.clear")), + DELETE("delete", "", new CommandPermission("plots.delete")), + DEBUG("debug", "", new CommandPermission("plots.admin")), INTERFACE("interface", "int", new CommandPermission("plots.interface")), HOME("home", "h"), INFO("info", "i"), LIST("list", "l"), SET("set", "s"), PURGE("purge"), - OP("op", "add"), - DEOP("deop", "deadmin"), - BAN("ban", "block"), - UNBAN("unban", "unblock"), DATABASE("database", "convert"), CONFIRM("confirm"), TP("tp", "tp"), diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java index 374419b7b..a90c1fe94 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -222,8 +222,8 @@ public class DebugUUID extends SubCommand { if (value != null) { plot.owner = value; } - plot.helpers = new ArrayList<>(); plot.trusted = new ArrayList<>(); + plot.members = new ArrayList<>(); plot.denied = new ArrayList<>(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Deny.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Deny.java new file mode 100644 index 000000000..8bdea4d5d --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Deny.java @@ -0,0 +1,92 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PlotSquared - A plot manager and world generator for the Bukkit API / +// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / +// / +// This program is free software; you can redistribute it and/or modify / +// it under the terms of the GNU General Public License as published by / +// the Free Software Foundation; either version 3 of the License, or / +// (at your option) any later version. / +// / +// This program is distributed in the hope that it will be useful, / +// but WITHOUT ANY WARRANTY; without even the implied warranty of / +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / +// GNU General Public License for more details. / +// / +// You should have received a copy of the GNU General Public License / +// along with this program; if not, write to the Free Software Foundation, / +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / +// / +// You can contact us via: support@intellectualsites.com / +//////////////////////////////////////////////////////////////////////////////////////////////////// +package com.intellectualcrafters.plot.commands; + +import java.util.UUID; + +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.EventUtil; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; + +public class Deny extends SubCommand { + public Deny() { + super(Command.DENY, "Deny a user from a plot", "deny ", CommandCategory.ACTIONS, true); + } + + @Override + public boolean execute(final PlotPlayer plr, final String... args) { + if (args.length != 1) { + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot deny "); + return true; + } + final Location loc = plr.getLocation(); + final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } + if ((plot == null) || !plot.hasOwner()) { + MainUtil.sendMessage(plr, C.PLOT_UNOWNED); + return false; + } + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.deny")) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); + return true; + } + UUID uuid; + if (args[0].equalsIgnoreCase("*")) { + uuid = DBFunc.everyone; + } else { + uuid = UUIDHandler.getUUID(args[0]); + } + if (uuid == null) { + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); + return false; + } + if (!plot.denied.contains(uuid)) { + if (plot.isOwner(uuid)) { + MainUtil.sendMessage(plr, C.ALREADY_OWNER); + return false; + } + if (plot.trusted.contains(uuid)) { + plot.trusted.remove(uuid); + DBFunc.removeTrusted(loc.getWorld(), plot, uuid); + } + if (plot.members.contains(uuid)) { + plot.members.remove(uuid); + DBFunc.removeMember(loc.getWorld(), plot, uuid); + } + plot.addDenied(uuid); + DBFunc.setDenied(loc.getWorld(), plot, uuid); + EventUtil.manager.callDenied(plr, plot, uuid, true); + } else { + MainUtil.sendMessage(plr, C.ALREADY_ADDED); + return false; + } + MainUtil.sendMessage(plr, C.DENIED_ADDED); + return true; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 732a1a682..ce77c2f05 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -39,6 +39,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -103,8 +104,8 @@ public class Info extends SubCommand { boolean trustedEveryone; // Wildcard player {added} { - containsEveryone = (plot.helpers != null) && plot.helpers.contains(DBFunc.everyone); - trustedEveryone = (plot.trusted != null) && plot.trusted.contains(DBFunc.everyone); + containsEveryone = (plot.trusted != null) && plot.trusted.contains(DBFunc.everyone); + trustedEveryone = (plot.members != null) && plot.members.contains(DBFunc.everyone); } // Unclaimed? if (!hasOwner && !containsEveryone && !trustedEveryone) { @@ -122,20 +123,18 @@ public class Info extends SubCommand { if (args.length == 1) { info = getCaption(args[0].toLowerCase()); if (info == null) { - MainUtil.sendMessage(player, "&6Categories&7: &ahelpers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); + MainUtil.sendMessage(player, "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); return false; } } - info = format(info, world, plot, player); - MainUtil.sendMessage(player, C.PLOT_INFO_HEADER); - MainUtil.sendMessage(player, info, false); + formatAndSend(info, world, plot, player); return true; } private String getCaption(final String string) { switch (string) { - case "helpers": - return C.PLOT_INFO_HELPERS.s(); + case "trusted": + return C.PLOT_INFO_TRUSTED.s(); case "alias": return C.PLOT_INFO_ALIAS.s(); case "biome": @@ -148,8 +147,8 @@ public class Info extends SubCommand { return C.PLOT_INFO_ID.s(); case "size": return C.PLOT_INFO_SIZE.s(); - case "trusted": - return C.PLOT_INFO_TRUSTED.s(); + case "members": + return C.PLOT_INFO_MEMBERS.s(); case "owner": return C.PLOT_INFO_OWNER.s(); case "rating": @@ -159,7 +158,7 @@ public class Info extends SubCommand { } } - private String format(String info, final String world, final Plot plot, final PlotPlayer player) { + private String formatAndSend(String info, final String world, final Plot plot, final PlotPlayer player) { final PlotId id = plot.id; final PlotId id2 = MainUtil.getTopPlot(plot).id; final int num = MainUtil.getPlotSelectionIds(id, id2).size(); @@ -167,10 +166,13 @@ public class Info extends SubCommand { Location top = MainUtil.getPlotTopLoc(world, plot.id); Location bot = MainUtil.getPlotBottomLoc(world, plot.id).add(1,0,1); final String biome = BlockManager.manager.getBiome(bot.add((top.getX() - bot.getX()) / 2, 0, (top.getX() - bot.getX()) / 2)); - final String helpers = getPlayerList(plot.helpers); final String trusted = getPlayerList(plot.trusted); + final String members = getPlayerList(plot.members); final String denied = getPlayerList(plot.denied); + + // TODO async final String rating = String.format("%.1f", DBFunc.getRatings(plot)); + final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none"); final boolean build = (player == null) || plot.isAdded(player.getUUID()); String owner = "none"; @@ -186,14 +188,26 @@ public class Info extends SubCommand { info = info.replaceAll("%num%", num + ""); info = info.replaceAll("%biome%", biome); info = info.replaceAll("%owner%", owner); - info = info.replaceAll("%helpers%", helpers); + info = info.replaceAll("%members%", members); info = info.replaceAll("%trusted%", trusted); + info = info.replaceAll("%helpers%", trusted); info = info.replaceAll("%denied%", denied); info = info.replaceAll("%rating%", rating); info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags)); info = info.replaceAll("%build%", build + ""); info = info.replaceAll("%desc%", "No description set."); - return info; + + if (info.contains("%rating%")) { + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + // TODO Auto-generated method stub + } + }); + } + + MainUtil.sendMessage(player, C.PLOT_INFO_HEADER); + MainUtil.sendMessage(player, info, false); } private String getPlayerList(final Collection uuids) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index dba751312..e0d7ab257 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -87,6 +87,7 @@ public class Rate extends SubCommand { } else { sendMessage(plr, C.COMMAND_WENT_WRONG); } + DBFunc.setRating(plot, plr.getUUID(), rating); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java index af49dfc59..07b9cb6ad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.util.MainUtil; public class Reload extends SubCommand { public Reload() { - super("reload", "plots.admin.command.reload", "Reload configurations", "", "reload", CommandCategory.INFO, false); + super("reload", "plots.admin.command.reload", "Reload configurations", "reload", CommandCategory.INFO, false); } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Remove.java similarity index 53% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Remove.java index 5262419ce..40c3fbf0b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Remove.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; +import java.util.Iterator; import java.util.UUID; import com.intellectualcrafters.plot.config.C; @@ -28,21 +28,20 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -public class Denied extends SubCommand { - public Denied() { - super(Command.DENIED, "Manage plot helpers", "denied {add|remove} {player}", CommandCategory.ACTIONS, true); +public class Remove extends SubCommand { + public Remove() { + super(Command.REMOVE, "Remove a player from a plot", "remove ", CommandCategory.ACTIONS, true); } @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (args.length < 2) { - MainUtil.sendMessage(plr, C.DENIED_NEED_ARGUMENT); + if (args.length != 1) { + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot remove "); return true; } final Location loc = plr.getLocation(); @@ -54,76 +53,89 @@ public class Denied extends SubCommand { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.denied")) { + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.remove")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return true; } - if (args[0].equalsIgnoreCase("add")) { - UUID uuid; - if (args[1].equalsIgnoreCase("*")) { - uuid = DBFunc.everyone; - } else { - uuid = UUIDHandler.getUUID(args[1]); - } - if (uuid == null) { - MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]); - return false; - } - if (!plot.denied.contains(uuid)) { - if (plot.isOwner(uuid)) { - MainUtil.sendMessage(plr, C.ALREADY_OWNER); - return false; + int count = 0; + if (args[0].equals("unknown")) { + Iterator i = plot.members.iterator(); + while (i.hasNext()) { + UUID uuid = i.next(); + if (UUIDHandler.getName(uuid) == null) { + DBFunc.removeMember(plot.world, plot, uuid); + i.remove(); + count++; } + } + i = plot.trusted.iterator(); + while (i.hasNext()) { + UUID uuid = i.next(); + if (UUIDHandler.getName(uuid) == null) { + DBFunc.removeTrusted(plot.world, plot, uuid); + i.remove(); + count++; + } + } + i = plot.denied.iterator(); + while (i.hasNext()) { + UUID uuid = i.next(); + if (UUIDHandler.getName(uuid) == null) { + DBFunc.removeDenied(plot.world, plot, uuid); + i.remove(); + count++; + } + } + } + else if (args[0].equals("*")){ + Iterator i = plot.members.iterator(); + while (i.hasNext()) { + UUID uuid = i.next(); + DBFunc.removeMember(plot.world, plot, uuid); + i.remove(); + count++; + } + i = plot.trusted.iterator(); + while (i.hasNext()) { + UUID uuid = i.next(); + DBFunc.removeTrusted(plot.world, plot, uuid); + i.remove(); + count++; + } + i = plot.denied.iterator(); + while (i.hasNext()) { + UUID uuid = i.next(); + DBFunc.removeDenied(plot.world, plot, uuid); + i.remove(); + count++; + } + } + else { + UUID uuid = UUIDHandler.getUUID(args[0]); + if (uuid != null) { if (plot.trusted.contains(uuid)) { + DBFunc.removeTrusted(plot.world, plot, uuid); plot.trusted.remove(uuid); - DBFunc.removeTrusted(loc.getWorld(), plot, uuid); + count++; } - if (plot.helpers.contains(uuid)) { - plot.helpers.remove(uuid); - DBFunc.removeHelper(loc.getWorld(), plot, uuid); + else if (plot.members.contains(uuid)) { + DBFunc.removeMember(plot.world, plot, uuid); + plot.members.remove(uuid); + count++; } - plot.addDenied(uuid); - DBFunc.setDenied(loc.getWorld(), plot, uuid); - EventUtil.manager.callDenied(plr, plot, uuid, true); - } else { - MainUtil.sendMessage(plr, C.ALREADY_ADDED); - return false; - } - final PlotPlayer player = UUIDHandler.getPlayer(uuid); - if (!uuid.equals(DBFunc.everyone) && (player != null) && player.isOnline()) { - final Plot pl = MainUtil.getPlot(player.getLocation()); - if ((pl != null) && pl.id.equals(plot.id)) { - MainUtil.sendMessage(player, C.YOU_BE_DENIED); - player.teleport(BlockManager.manager.getSpawn(loc.getWorld())); + else if (plot.denied.contains(uuid)) { + DBFunc.removeDenied(plot.world, plot, uuid); + plot.denied.remove(uuid); + count++; } } - MainUtil.sendMessage(plr, C.DENIED_ADDED); - return true; - } else if (args[0].equalsIgnoreCase("remove")) { - if (args[1].equalsIgnoreCase("*")) { - if (plot.denied.size() == 0) { - MainUtil.sendMessage(plr, C.WAS_NOT_ADDED); - return true; - } - for (UUID uuid : plot.denied) { - DBFunc.removeDenied(loc.getWorld(), plot, uuid); - } - plot.denied = new ArrayList<>(); - MainUtil.sendMessage(plr, C.DENIED_REMOVED); - return true; - } - final UUID uuid = UUIDHandler.getUUID(args[1]); - if (!plot.denied.contains(uuid)) { - MainUtil.sendMessage(plr, C.WAS_NOT_ADDED); - return true; - } - plot.removeDenied(uuid); - DBFunc.removeDenied(loc.getWorld(), plot, uuid); - EventUtil.manager.callDenied(plr, plot, uuid, false); - MainUtil.sendMessage(plr, C.DENIED_REMOVED); - } else { - MainUtil.sendMessage(plr, C.DENIED_NEED_ARGUMENT); - return true; + } + if (count == 0) { + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); + return false; + } + else { + MainUtil.sendMessage(plr, C.REMOVED_PLAYERS, count + ""); } return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index e5f289226..34615be81 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -37,7 +37,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class SetOwner extends SubCommand { public SetOwner() { - super("setowner", "plots.set.owner", "Set the plot owner", "setowner {player}", "so", CommandCategory.ACTIONS, true); + super("setowner", "plots.set.owner", "Set the plot owner", "setowner ", "so", CommandCategory.ACTIONS, true); } /* diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trust.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trust.java new file mode 100644 index 000000000..99b77da34 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trust.java @@ -0,0 +1,92 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PlotSquared - A plot manager and world generator for the Bukkit API / +// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / +// / +// This program is free software; you can redistribute it and/or modify / +// it under the terms of the GNU General Public License as published by / +// the Free Software Foundation; either version 3 of the License, or / +// (at your option) any later version. / +// / +// This program is distributed in the hope that it will be useful, / +// but WITHOUT ANY WARRANTY; without even the implied warranty of / +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / +// GNU General Public License for more details. / +// / +// You should have received a copy of the GNU General Public License / +// along with this program; if not, write to the Free Software Foundation, / +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / +// / +// You can contact us via: support@intellectualsites.com / +//////////////////////////////////////////////////////////////////////////////////////////////////// +package com.intellectualcrafters.plot.commands; + +import java.util.UUID; + +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.EventUtil; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; + +public class Trust extends SubCommand { + public Trust() { + super(Command.TRUST, "Allow a player to build in a plot", "trust ", CommandCategory.ACTIONS, true); + } + + @Override + public boolean execute(final PlotPlayer plr, final String... args) { + if (args.length != 1) { + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot trust "); + return true; + } + final Location loc = plr.getLocation(); + final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } + if ((plot == null) || !plot.hasOwner()) { + MainUtil.sendMessage(plr, C.PLOT_UNOWNED); + return false; + } + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.trust")) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); + return true; + } + UUID uuid; + if (args[0].equalsIgnoreCase("*")) { + uuid = DBFunc.everyone; + } else { + uuid = UUIDHandler.getUUID(args[0]); + } + if (uuid == null) { + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); + return false; + } + if (!plot.trusted.contains(uuid)) { + if (plot.isOwner(uuid)) { + MainUtil.sendMessage(plr, C.ALREADY_OWNER); + return false; + } + if (plot.members.contains(uuid)) { + plot.members.remove(uuid); + DBFunc.removeMember(loc.getWorld(), plot, uuid); + } + if (plot.denied.contains(uuid)) { + plot.denied.remove(uuid); + DBFunc.removeDenied(loc.getWorld(), plot, uuid); + } + plot.addTrusted(uuid); + DBFunc.setTrusted(loc.getWorld(), plot, uuid); + EventUtil.manager.callTrusted(plr, plot, uuid, true); + } else { + MainUtil.sendMessage(plr, C.ALREADY_ADDED); + return false; + } + MainUtil.sendMessage(plr, C.TRUSTED_ADDED); + return true; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Undeny.java similarity index 55% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Undeny.java index ea74aba5c..35a715fa0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Undeny.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; +import java.util.Iterator; import java.util.UUID; import com.intellectualcrafters.plot.config.C; @@ -33,16 +33,15 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -@SuppressWarnings("deprecation") -public class Trusted extends SubCommand { - public Trusted() { - super(Command.TRUSTED, "Manage trusted users for a plot", "trusted {add|remove} {player}", CommandCategory.ACTIONS, true); +public class Undeny extends SubCommand { + public Undeny() { + super(Command.UNDENY, "Remove a denied user from a plot", "undeny ", CommandCategory.ACTIONS, true); } @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (args.length < 2) { - MainUtil.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); + if (args.length != 1) { + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot undeny "); return true; } final Location loc = plr.getLocation(); @@ -54,68 +53,48 @@ public class Trusted extends SubCommand { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.trusted")) { + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.undeny")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return true; } - if (args[0].equalsIgnoreCase("add")) { - UUID uuid; - if (args[1].equalsIgnoreCase("*")) { - uuid = DBFunc.everyone; - } else { - uuid = UUIDHandler.getUUID(args[1]); - } - if (uuid == null) { - MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]); - return false; - } - if (!plot.trusted.contains(uuid)) { - if (plot.isOwner(uuid)) { - MainUtil.sendMessage(plr, C.ALREADY_OWNER); - return false; - } - if (plot.helpers.contains(uuid)) { - plot.helpers.remove(uuid); - DBFunc.removeHelper(loc.getWorld(), plot, uuid); + int count = 0; + if (args[0].equals("unknown")) { + Iterator i = plot.denied.iterator(); + i = plot.denied.iterator(); + while (i.hasNext()) { + UUID uuid = i.next(); + if (UUIDHandler.getName(uuid) == null) { + DBFunc.removeDenied(plot.world, plot, uuid); + i.remove(); + count++; } + } + } + else if (args[0].equals("*")){ + Iterator i = plot.denied.iterator(); + while (i.hasNext()) { + UUID uuid = i.next(); + DBFunc.removeDenied(plot.world, plot, uuid); + i.remove(); + count++; + } + } + else { + UUID uuid = UUIDHandler.getUUID(args[0]); + if (uuid != null) { if (plot.denied.contains(uuid)) { + DBFunc.removeDenied(plot.world, plot, uuid); plot.denied.remove(uuid); - DBFunc.removeDenied(loc.getWorld(), plot, uuid); + count++; } - plot.addTrusted(uuid); - DBFunc.setTrusted(loc.getWorld(), plot, uuid); - EventUtil.manager.callTrusted(plr, plot, uuid, true); - } else { - MainUtil.sendMessage(plr, C.ALREADY_ADDED); - return false; } - MainUtil.sendMessage(plr, C.TRUSTED_ADDED); - return true; - } else if (args[0].equalsIgnoreCase("remove")) { - if (args[1].equalsIgnoreCase("*")) { - if (plot.trusted.size() == 0) { - MainUtil.sendMessage(plr, C.WAS_NOT_ADDED); - return true; - } - for (UUID uuid : plot.trusted) { - DBFunc.removeTrusted(loc.getWorld(), plot, uuid); - } - plot.trusted = new ArrayList<>(); - MainUtil.sendMessage(plr, C.TRUSTED_REMOVED); - return true; - } - final UUID uuid = UUIDHandler.getUUID(args[1]); - if (!plot.trusted.contains(uuid)) { - MainUtil.sendMessage(plr, C.T_WAS_NOT_ADDED); - return true; - } - plot.removeTrusted(uuid); - DBFunc.removeTrusted(loc.getWorld(), plot, uuid); - EventUtil.manager.callTrusted(plr, plot, uuid, false); - MainUtil.sendMessage(plr, C.TRUSTED_REMOVED); - } else { - MainUtil.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); - return true; + } + if (count == 0) { + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); + return false; + } + else { + MainUtil.sendMessage(plr, C.REMOVED_PLAYERS, count + ""); } return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Untrust.java similarity index 56% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Untrust.java index 585c4582c..e7c7d3f8d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Untrust.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; +import java.util.Iterator; import java.util.UUID; import com.intellectualcrafters.plot.config.C; @@ -33,15 +33,15 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -public class Helpers extends SubCommand { - public Helpers() { - super(Command.HELPERS, "Manage plot helpers", "helpers {add|remove} {player}", CommandCategory.ACTIONS, true); +public class Untrust extends SubCommand { + public Untrust() { + super(Command.UNTRUST, "Remove a trusted user from a plot", "untrust ", CommandCategory.ACTIONS, true); } @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (args.length < 2) { - MainUtil.sendMessage(plr, C.HELPER_NEED_ARGUMENT); + if (args.length != 1) { + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot untrust "); return true; } final Location loc = plr.getLocation(); @@ -53,68 +53,48 @@ public class Helpers extends SubCommand { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.helpers")) { + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.untrust")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return true; } - if (args[0].equalsIgnoreCase("add")) { - UUID uuid; - if (args[1].equalsIgnoreCase("*")) { - uuid = DBFunc.everyone; - } else { - uuid = UUIDHandler.getUUID(args[1]); - } - if (uuid == null) { - MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]); - return false; - } - if (!plot.helpers.contains(uuid)) { - if (plot.isOwner(uuid)) { - MainUtil.sendMessage(plr, C.ALREADY_OWNER); - return false; + int count = 0; + if (args[0].equals("unknown")) { + Iterator i = plot.trusted.iterator(); + i = plot.trusted.iterator(); + while (i.hasNext()) { + UUID uuid = i.next(); + if (UUIDHandler.getName(uuid) == null) { + DBFunc.removeTrusted(plot.world, plot, uuid); + i.remove(); + count++; } + } + } + else if (args[0].equals("*")){ + Iterator i = plot.trusted.iterator(); + while (i.hasNext()) { + UUID uuid = i.next(); + DBFunc.removeTrusted(plot.world, plot, uuid); + i.remove(); + count++; + } + } + else { + UUID uuid = UUIDHandler.getUUID(args[0]); + if (uuid != null) { if (plot.trusted.contains(uuid)) { + DBFunc.removeTrusted(plot.world, plot, uuid); plot.trusted.remove(uuid); - DBFunc.removeTrusted(loc.getWorld(), plot, uuid); + count++; } - if (plot.denied.contains(uuid)) { - plot.denied.remove(uuid); - DBFunc.removeDenied(loc.getWorld(), plot, uuid); - } - plot.addHelper(uuid); - DBFunc.setHelper(loc.getWorld(), plot, uuid); - EventUtil.manager.callHelper(plr, plot, uuid, true); - } else { - MainUtil.sendMessage(plr, C.ALREADY_ADDED); - return false; } - MainUtil.sendMessage(plr, C.HELPER_ADDED); - return true; - } else if (args[0].equalsIgnoreCase("remove")) { - if (args[1].equalsIgnoreCase("*")) { - if (plot.helpers.size() == 0) { - MainUtil.sendMessage(plr, C.WAS_NOT_ADDED); - return true; - } - for (UUID uuid : plot.helpers) { - DBFunc.removeHelper(loc.getWorld(), plot, uuid); - } - plot.helpers = new ArrayList<>(); - MainUtil.sendMessage(plr, C.HELPER_REMOVED); - return true; - } - final UUID uuid = UUIDHandler.getUUID(args[1]); - if (!plot.helpers.contains(uuid)) { - MainUtil.sendMessage(plr, C.WAS_NOT_ADDED); - return false; - } - plot.removeHelper(uuid); - DBFunc.removeHelper(loc.getWorld(), plot, uuid); - EventUtil.manager.callHelper(plr, plot, uuid, false); - MainUtil.sendMessage(plr, C.HELPER_REMOVED); - } else { - MainUtil.sendMessage(plr, C.HELPER_NEED_ARGUMENT); - return true; + } + if (count == 0) { + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); + return false; + } + else { + MainUtil.sendMessage(plr, C.REMOVED_PLAYERS, count + ""); } return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java index 55f099a5b..9e85e0004 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -130,7 +130,7 @@ public class list extends SubCommand { } plots = new ArrayList(); for (Plot plot : PlotSquared.getPlots()) { - if (plot.helpers.contains(plr.getUUID()) || plot.trusted.contains(plr.getUUID())) { + if (plot.trusted.contains(plr.getUUID()) || plot.members.contains(plr.getUUID())) { plots.add(plot); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 1286018a1..64c71bd0d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -53,7 +53,7 @@ public enum C { /* * Cluster */ - CLUSTER_AVAILABLE_ARGS("$1The following sub commands are available: $4list$2, $4create$2, $4delete$2, $4resize$2, $4invite$2, $4kick$2, $4leave$2, $4helpers$2, $4info$2, $4tp$2, $4sethome", "Cluster"), + CLUSTER_AVAILABLE_ARGS("$1The following sub commands are available: $4list$2, $4create$2, $4delete$2, $4resize$2, $4invite$2, $4kick$2, $4leave$2, $4members$2, $4info$2, $4tp$2, $4sethome", "Cluster"), CLUSTER_LIST_HEADING("$2There are $1%s$2 clusters in this world", "Cluster"), CLUSTER_LIST_ELEMENT("$2 - $1%s\n", "Cluster"), CLUSTER_INTERSECTION("$2The proposed area overlaps with $1%s$2 existing cluster/s", "Cluster"), @@ -69,7 +69,7 @@ public enum C { CLUSTER_NOT_ADDED("$2That player was not added to the plot cluster", "Cluster"), CLUSTER_CANNOT_LEAVE("$1You must delete or transfer ownership before leaving", "Cluster"), CLUSTER_ADDED_HELPER("$4Successfully added a helper to the cluster", "Cluster"), - CLUSTER_REMOVED_HELPER("$4Successfully removed a helper to the cluster", "Cluster"), + CLUSTER_REMOVED_HELPER("$4Successfully removed a helper from the cluster", "Cluster"), CLUSTER_REGENERATED("$4Successfully started cluster regeneration", "Cluster"), CLUSTER_TELEPORTING("$4Teleporting...", "Cluster"), CLUSTER_INFO("$1Current cluster: $2%id%\n$1Name: $2%name%\n$1Owner: $2%owner%\n$1Size: $2%size%\n$1Rights: $2%rights%", "Cluster"), @@ -337,24 +337,10 @@ public enum C { */ PLOT_UNOWNED("$2The current plot must have an owner to perform this action", "Info"), PLOT_INFO_UNCLAIMED("$2Plot $1%s$2 is not yet claimed", "Info"), - /* - * PLOT_INFO("" + - * "$1ID$2: $4%id%$2\n" + - * "$1Alias$2: $4%alias%\n" + - * "$1Owner$2: $4%owner%\n" + - * "$1Helpers$2: $4%helpers%\n" + - * "$1Trusted$2: $4%trusted%\n" + - * "$1Denied$2: $4%denied%\n" + - * "$1Flags$2: $4%flags%\n" + - * "$1Biome$2: $4%biome%\n" + - * "$1Rating$2: $4%rating%$2/$410\n" + - * "$1Can build$2: $4%build%" - * ), - */ PLOT_INFO_HEADER("$3====== $1INFO $3======", false, "Info"), - PLOT_INFO("$1ID: $2%id%$1\n" + "$1Alias: $2%alias%$1\n" + "$1Owner: $2%owner%$1\n" + "$1Biome: $2%biome%$1\n" + "$1Can Build: $2%build%$1\n" + "$1Rating: $2%rating%$1/$210$1\n" + "$1Helpers: $2%helpers%$1\n" + "$1Trusted: $2%trusted%$1\n" + "$1Denied: $2%denied%$1\n" + "$1Flags: $2%flags%", "Info"), - PLOT_INFO_HELPERS("$1Helpers:$2 %helpers%", "Info"), + PLOT_INFO("$1ID: $2%id%$1\n" + "$1Alias: $2%alias%$1\n" + "$1Owner: $2%owner%$1\n" + "$1Biome: $2%biome%$1\n" + "$1Can Build: $2%build%$1\n" + "$1Rating: $2%rating%$1/$210$1\n" + "$1Trusted: $2%trusted%$1\n" + "$1Members: $2%members%$1\n" + "$1Denied: $2%denied%$1\n" + "$1Flags: $2%flags%", "Info"), PLOT_INFO_TRUSTED("$1Trusted:$2 %trusted%", "Info"), + PLOT_INFO_MEMBERS("$1Members:$2 %members%", "Info"), PLOT_INFO_DENIED("$1Denied:$2 %denied%", "Info"), PLOT_INFO_FLAGS("$1Flags:$2 %flags%", "Info"), PLOT_INFO_BIOME("$1Biome:$2 %biome%", "Info"), @@ -433,23 +419,22 @@ public enum C { FLAG_NOT_ADDED("$2The flag could not be added", "Flag"), FLAG_REMOVED("$4Successfully removed flag", "Flag"), FLAG_ADDED("$4Successfully added flag", "Flag"), - /* - * Helper - */ - HELPER_ADDED("$4You successfully added a helper to the plot", "Helper"), - HELPER_REMOVED("$4You successfully removed a helper from the plot", "Helper"), - HELPER_NEED_ARGUMENT("$2Arguments are missing. $1/plot helpers add $2or $1/plot helpers remove ", "Helper"), - WAS_NOT_ADDED("$2That player was not added as a helper on this plot", "Helper"), - PLOT_REMOVED_HELPER("$1Plot %s of which you were added to has been deleted due to owner inactivity", "Helper"), /* * Trusted */ - ALREADY_OWNER("$2That user is already the plot owner.", "Trusted"), - ALREADY_ADDED("$2That user is already added to that category.", "Trusted"), - TRUSTED_ADDED("$4You successfully added a trusted user to the plot", "Trusted"), - TRUSTED_REMOVED("$1You successfully removed a trusted user from the plot", "Trusted"), - TRUSTED_NEED_ARGUMENT("$2Arguments are missing. $1/plot trusted add $2or $1/plot trusted remove ", "Trusted"), - T_WAS_NOT_ADDED("$2That player was not added as a trusted user on this plot", "Trusted"), + TRUSTED_ADDED("$4You successfully trusted a user to the plot", "Trusted"), + TRUSTED_REMOVED("$4You successfully removed a trusted user from the plot", "Trusted"), + WAS_NOT_ADDED("$2That player was not trusted on this plot", "Trusted"), + PLOT_REMOVED_USER("$1Plot %s of which you were added to has been deleted due to owner inactivity", "Trusted"), + /* + * Member + */ + REMOVED_PLAYERS("$2Removed %s players from this plot.", "Member"), + ALREADY_OWNER("$2That user is already the plot owner.", "Member"), + ALREADY_ADDED("$2That user is already added to that category.", "Member"), + MEMBER_ADDED("$4That user can now build while the plot owner is online", "Member"), + MEMBER_REMOVED("$1You successfully removed a user from the plot", "Member"), + MEMBER_WAS_NOT_ADDED("$2That player was not added as a user on this plot", "Member"), /* * Set Owner */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index a90f2396c..a03a8f75a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -219,7 +219,7 @@ public interface AbstractDB { * @param plot Plot Object * @param uuid Player that should be removed */ - public void removeHelper(final String world, final Plot plot, final UUID uuid); + public void removeTrusted(final String world, final Plot plot, final UUID uuid); /** * @param cluster PlotCluster Object @@ -231,7 +231,7 @@ public interface AbstractDB { * @param plot Plot Object * @param uuid Player that should be removed */ - public void removeTrusted(final String world, final Plot plot, final UUID uuid); + public void removeMember(final String world, final Plot plot, final UUID uuid); /** * @@ -244,7 +244,7 @@ public interface AbstractDB { * @param plot Plot Object * @param uuid Player that should be removed */ - public void setHelper(final String world, final Plot plot, final UUID uuid); + public void setTrusted(final String world, final Plot plot, final UUID uuid); /** * @param cluster PlotCluster Object @@ -256,7 +256,7 @@ public interface AbstractDB { * @param plot Plot Object * @param uuid Player that should be added */ - public void setTrusted(final String world, final Plot plot, final UUID uuid); + public void setMember(final String world, final Plot plot, final UUID uuid); /** * @@ -286,6 +286,14 @@ public interface AbstractDB { * @return Plot Ratings (pre-calculated) */ public double getRatings(final Plot plot); + + /** + * Set a rating for a plot + * @param plot + * @param rater + * @param value + */ + public void setRating(final Plot plot, UUID rater, int value); /** * Remove a plot comment diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index a0c67f3f3..b8bb3c0b8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -90,7 +90,7 @@ public class DBFunc { } /** - * Create all settings + (helpers, denied, trusted) + * Create all settings + (trusted, denied, members) * * @param plots List containing all plot objects */ @@ -253,8 +253,8 @@ public class DBFunc { * @param plot * @param uuid */ - public static void removeHelper(final String world, final Plot plot, final UUID uuid) { - dbManager.removeHelper(world, plot, uuid); + public static void removeTrusted(final String world, final Plot plot, final UUID uuid) { + dbManager.removeTrusted(world, plot, uuid); } /** @@ -285,8 +285,8 @@ public class DBFunc { * @param plot * @param uuid */ - public static void removeTrusted(final String world, final Plot plot, final UUID uuid) { - dbManager.removeTrusted(world, plot, uuid); + public static void removeMember(final String world, final Plot plot, final UUID uuid) { + dbManager.removeMember(world, plot, uuid); } /** @@ -303,8 +303,8 @@ public class DBFunc { * @param plot * @param uuid */ - public static void setHelper(final String world, final Plot plot, final UUID uuid) { - dbManager.setHelper(world, plot, uuid); + public static void setTrusted(final String world, final Plot plot, final UUID uuid) { + dbManager.setTrusted(world, plot, uuid); } public static void setHelper(final PlotCluster cluster, final UUID uuid) { @@ -316,8 +316,8 @@ public class DBFunc { * @param plot * @param uuid */ - public static void setTrusted(final String world, final Plot plot, final UUID uuid) { - dbManager.setTrusted(world, plot, uuid); + public static void setMember(final String world, final Plot plot, final UUID uuid) { + dbManager.setMember(world, plot, uuid); } public static void setInvited(final String world, final PlotCluster cluster, final UUID uuid) { @@ -345,6 +345,10 @@ public class DBFunc { public static double getRatings(final Plot plot) { return dbManager.getRatings(plot); } + + public static void setRating(Plot plot, UUID rater, int value) { + dbManager.setRating(plot, rater, value); + } public static HashMap> getClusters() { return dbManager.getClusters(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 634e8ab6e..c629aa365 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -193,13 +193,13 @@ public class SQLManager implements AbstractDB { denied.add(new UUIDPair(id, uuid)); } } - if (plot.trusted != null) { - for (UUID uuid : plot.trusted) { + if (plot.members != null) { + for (UUID uuid : plot.members) { trusted.add(new UUIDPair(id, uuid)); } } - if (plot.helpers != null) { - for (UUID uuid : plot.helpers) { + if (plot.trusted != null) { + for (UUID uuid : plot.trusted) { helpers.add(new UUIDPair(id, uuid)); } } @@ -835,7 +835,7 @@ public class SQLManager implements AbstractDB { } final Plot plot = plots.get(id); if (plot != null) { - plot.addHelper(user); + plot.addTrusted(user); } else { PlotSquared.log("&cPLOT " + id + " in plot_helpers does not exist. Please create the plot or remove this entry."); } @@ -854,7 +854,7 @@ public class SQLManager implements AbstractDB { } final Plot plot = plots.get(id); if (plot != null) { - plot.addTrusted(user); + plot.addMember(user); } else { PlotSquared.log("&cPLOT " + id + " in plot_trusted does not exist. Please create the plot or remove this entry."); } @@ -1409,7 +1409,7 @@ public class SQLManager implements AbstractDB { } @Override - public void removeHelper(final String world, final Plot plot, final UUID uuid) { + public void removeTrusted(final String world, final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -1428,7 +1428,7 @@ public class SQLManager implements AbstractDB { } @Override - public void removeTrusted(final String world, final Plot plot, final UUID uuid) { + public void removeMember(final String world, final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -1447,7 +1447,7 @@ public class SQLManager implements AbstractDB { } @Override - public void setHelper(final String world, final Plot plot, final UUID uuid) { + public void setTrusted(final String world, final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -1484,7 +1484,7 @@ public class SQLManager implements AbstractDB { } @Override - public void setTrusted(final String world, final Plot plot, final UUID uuid) { + public void setMember(final String world, final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -1559,6 +1559,27 @@ public class SQLManager implements AbstractDB { } return 0.0d; } + + + @Override + public void setRating(final Plot plot, final UUID rater, final int value) { + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + try { + final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT IGNORE INTO `" + SQLManager.this.prefix + "plot_ratings` (`plot_plot_id`, `rating`, `player`) VALUES(?,?,?)"); + statement.setInt(1, getId(plot.world, plot.id)); + statement.setInt(2, value); + statement.setString(3, rater.toString()); + statement.executeUpdate(); + statement.close(); + } catch (final SQLException e) { + PlotSquared.log("&7[WARN] " + "Failed to set denied for plot " + plot.id); + e.printStackTrace(); + } + } + }); + } @Override public void delete(final PlotCluster cluster) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java index 3278c560b..3693eb4ea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java @@ -230,7 +230,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector { } } if (plots.get(world).containsKey(id)) { - plots.get(world).get(id).helpers.add(helper); + plots.get(world).get(id).trusted.add(helper); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEManager.java index 3ce548c36..77aebf2b8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEManager.java @@ -27,7 +27,7 @@ public class WEManager { UUID uuid = player.getUUID(); for (Plot plot : PlotSquared.getPlots(player.getLocation().getWorld()).values()) { if (!plot.settings.getMerged(0) && !plot.settings.getMerged(3)) { - if (plot.isOwner(uuid) || plot.helpers.contains(uuid)) { + if (plot.isOwner(uuid) || plot.trusted.contains(uuid)) { Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id); regions.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ())); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java index 9cdca9426..e664f12aa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java @@ -53,13 +53,13 @@ public class InfoInventory implements InventoryHolder { public InfoInventory build() { final UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(this.player)); final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.owner), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.isAdded(uuid), "&cIs Denied: &6" + this.plot.isDenied(uuid)); - final ItemStack helpers = getItem(Material.EMERALD, "&cHelpers", "&cAmount: &6" + this.plot.helpers.size(), "&8Click to view a list of the plot helpers"); - final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.trusted.size(), "&8Click to view a list of trusted players"); + final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.trusted.size(), "&8Click to view a list of the trusted users"); + final ItemStack members = getItem(Material.EMERALD, "&cMembers", "&cAmount: &6" + this.plot.members.size(), "&8Click to view a list of plot members"); final ItemStack denied = getItem(Material.EMERALD, "&cDenied", "&cAmount: &6" + this.plot.denied.size(), "&8Click to view a list of denied players"); final ItemStack flags = getItem(Material.EMERALD, "&cFlags", "&cAmount: &6" + this.plot.settings.flags.size(), "&8Click to view a list of plot flags"); this.inventory.setItem(2, generalInfo); - this.inventory.setItem(3, helpers); - this.inventory.setItem(4, trusted); + this.inventory.setItem(3, trusted); + this.inventory.setItem(4, members); this.inventory.setItem(5, denied); this.inventory.setItem(6, flags); return this; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index ec372d6f1..a09a06c87 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -53,13 +53,13 @@ public class Plot implements Cloneable { */ public boolean deny_entry; /** - * List of helpers (with plot permissions) - */ - public ArrayList helpers; - /** - * List of trusted users (with plot permissions) + * List of trusted (with plot permissions) */ public ArrayList trusted; + /** + * List of members users (with plot permissions) + */ + public ArrayList members; /** * List of denied players */ @@ -83,17 +83,17 @@ public class Plot implements Cloneable { * * @param id * @param owner - * @param helpers + * @param trusted * @param denied */ - public Plot(final PlotId id, final UUID owner, final ArrayList helpers, final ArrayList denied, final String world) { + public Plot(final PlotId id, final UUID owner, final ArrayList trusted, final ArrayList denied, final String world) { this.id = id; this.settings = new PlotSettings(this); this.owner = owner; this.deny_entry = this.owner == null; - this.helpers = helpers; + this.trusted = trusted; this.denied = denied; - this.trusted = new ArrayList<>(); + this.members = new ArrayList<>(); this.settings.setAlias(""); this.delete = false; this.settings.flags = new HashSet(); @@ -105,17 +105,17 @@ public class Plot implements Cloneable { * * @param id * @param owner - * @param helpers + * @param trusted * @param denied * @param merged */ - public Plot(final PlotId id, final UUID owner, final ArrayList helpers, final ArrayList trusted, final ArrayList denied, final String alias, final BlockLoc position, final Set flags, final String world, final boolean[] merged) { + public Plot(final PlotId id, final UUID owner, final ArrayList trusted, final ArrayList members, final ArrayList denied, final String alias, final BlockLoc position, final Set flags, final String world, final boolean[] merged) { this.id = id; this.settings = new PlotSettings(this); this.owner = owner; this.deny_entry = this.owner != null; + this.members = members; this.trusted = trusted; - this.helpers = helpers; this.denied = denied; this.settings.setAlias(alias); this.settings.setPosition(position); @@ -151,7 +151,7 @@ public class Plot implements Cloneable { } /** - * Check if the player is either the owner or on the helpers list + * Check if the player is either the owner or on the trusted list * * @param uuid * @@ -188,7 +188,7 @@ public class Plot implements Cloneable { public Object clone() throws CloneNotSupportedException { final Plot p = (Plot) super.clone(); if (!p.equals(this) || (p != this)) { - return new Plot(this.id, this.owner, this.helpers, this.trusted, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.flags, this.world, this.settings.getMerged()); + return new Plot(this.id, this.owner, this.trusted, this.members, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.flags, this.world, this.settings.getMerged()); } return p; } @@ -207,8 +207,8 @@ public class Plot implements Cloneable { * * @param uuid */ - public void addHelper(final UUID uuid) { - this.helpers.add(uuid); + public void addTrusted(final UUID uuid) { + this.trusted.add(uuid); } /** @@ -216,8 +216,8 @@ public class Plot implements Cloneable { * * @param uuid */ - public void addTrusted(final UUID uuid) { - this.trusted.add(uuid); + public void addMember(final UUID uuid) { + this.members.add(uuid); } /** @@ -248,7 +248,7 @@ public class Plot implements Cloneable { * @param uuid */ public void removeHelper(final UUID uuid) { - this.helpers.remove(uuid); + this.trusted.remove(uuid); } /** @@ -257,7 +257,7 @@ public class Plot implements Cloneable { * @param uuid */ public void removeTrusted(final UUID uuid) { - this.trusted.remove(uuid); + this.members.remove(uuid); } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java index ecf722302..c14f3b407 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java @@ -85,10 +85,10 @@ public class PlotHandler { if (plot.denied.contains(uuid)) { return false; } - if (plot.helpers.contains(uuid) || plot.helpers.contains(DBFunc.everyone)) { + if (plot.trusted.contains(uuid) || plot.trusted.contains(DBFunc.everyone)) { return true; } - if (plot.trusted.contains(uuid) || plot.trusted.contains(DBFunc.everyone)) { + if (plot.members.contains(uuid) || plot.members.contains(DBFunc.everyone)) { if (PlotHandler.isOnline(plot)) { return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java index 9d0a07469..7e3a502c8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java @@ -45,7 +45,7 @@ public abstract class EventUtil { public abstract void callDenied(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added); - public abstract void callHelper(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added); - public abstract void callTrusted(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added); + + public abstract void callMember(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index 806ada38c..1858e1789 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -94,10 +94,16 @@ public class ExpireManager { } final PlotDeleteEvent event = new PlotDeleteEvent(world, plot.id); Bukkit.getServer().getPluginManager().callEvent(event); - for (final UUID helper : plot.helpers) { + for (final UUID helper : plot.trusted) { final PlotPlayer player = UUIDHandler.getPlayer(helper); if (player != null) { - MainUtil.sendMessage(player, C.PLOT_REMOVED_HELPER, plot.id.toString()); + MainUtil.sendMessage(player, C.PLOT_REMOVED_USER, plot.id.toString()); + } + } + for (final UUID helper : plot.members) { + final PlotPlayer player = UUIDHandler.getPlayer(helper); + if (player != null) { + MainUtil.sendMessage(player, C.PLOT_REMOVED_USER, plot.id.toString()); } } final PlotManager manager = PlotSquared.getPlotManager(world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index fc7343f15..af82a0d42 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -84,8 +84,8 @@ public class MainUtil { if (plot == null) { continue; } - if (plot.helpers != null) { - myplot.helpers = plot.helpers; + if (plot.trusted != null) { + myplot.trusted = plot.trusted; } if (plot.denied != null) { myplot.denied = plot.denied; @@ -1162,20 +1162,20 @@ public class MainUtil { plot.settings.setMerged(currentPlot.settings.getMerged()); DBFunc.setMerged(world, plot, currentPlot.settings.getMerged()); } + if (currentPlot.members != null && currentPlot.members.size() > 0) { + plot.members = currentPlot.members; + for (UUID member : plot.members) { + DBFunc.setMember(world, plot, member); + } + } if (currentPlot.trusted != null && currentPlot.trusted.size() > 0) { - plot.trusted = currentPlot.trusted; + plot.members = currentPlot.trusted; for (UUID trusted : plot.trusted) { DBFunc.setTrusted(world, plot, trusted); } } - if (currentPlot.helpers != null && currentPlot.helpers.size() > 0) { - plot.trusted = currentPlot.helpers; - for (UUID helpers : plot.helpers) { - DBFunc.setHelper(world, plot, helpers); - } - } if (currentPlot.denied != null && currentPlot.denied.size() > 0) { - plot.trusted = currentPlot.denied; + plot.members = currentPlot.denied; for (UUID denied : plot.denied) { DBFunc.setDenied(world, plot, denied); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitEventUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitEventUtil.java index 24fd886a6..66f7036ab 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitEventUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitEventUtil.java @@ -99,12 +99,12 @@ public class BukkitEventUtil extends EventUtil { } @Override - public void callHelper(PlotPlayer initiator, Plot plot, UUID player, boolean added) { + public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) { callEvent(new PlayerPlotHelperEvent(getPlayer(initiator), plot, player, added)); } @Override - public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) { + public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) { callEvent(new PlayerPlotTrustedEvent(getPlayer(initiator), plot, player, added)); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java index d56b5fbe7..b6b185520 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java @@ -90,10 +90,10 @@ public class UUIDHandler { public static HashSet getAllUUIDS() { HashSet uuids = new HashSet(); for (Plot plot : PlotSquared.getPlotsRaw()) { - for (UUID uuid : plot.helpers) { + for (UUID uuid : plot.trusted) { uuids.add(uuid); } - for (UUID uuid : plot.trusted) { + for (UUID uuid : plot.members) { uuids.add(uuid); } for (UUID uuid : plot.denied) {