mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Fixes #1037
This commit is contained in:
parent
7873bcf592
commit
6bad640cec
@ -8,9 +8,10 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.intellectualcrafters.plot.util.EventUtil;
|
import com.intellectualcrafters.plot.util.EventUtil;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
|
||||||
import com.plotsquared.general.commands.Argument;
|
import com.plotsquared.general.commands.Argument;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
@ -42,40 +43,46 @@ public class Add extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
UUID uuid;
|
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||||
if (args[0].equalsIgnoreCase("*") && (Permissions.hasPermission(plr, "plots.add.everyone") || Permissions.hasPermission(plr, "plots.admin.command.add"))) {
|
if (uuids == null || uuids.isEmpty()) {
|
||||||
uuid = DBFunc.everyone;
|
|
||||||
} else {
|
|
||||||
// TODO have a runnable for fetch
|
|
||||||
uuid = UUIDHandler.getUUID(args[0], null);
|
|
||||||
}
|
|
||||||
if (uuid == null) {
|
|
||||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (plot.isOwner(uuid)) {
|
Iterator<UUID> iter = uuids.iterator();
|
||||||
MainUtil.sendMessage(plr, C.ALREADY_OWNER);
|
while (iter.hasNext()) {
|
||||||
return false;
|
UUID uuid = iter.next();
|
||||||
}
|
if (uuid == DBFunc.everyone && !(Permissions.hasPermission(plr, "plots.add.everyone") || Permissions.hasPermission(plr, "plots.admin.command.add"))) {
|
||||||
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||||
if (plot.getMembers().contains(uuid)) {
|
continue;
|
||||||
MainUtil.sendMessage(plr, C.ALREADY_ADDED);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (plot.removeTrusted(uuid)) {
|
|
||||||
plot.addMember(uuid);
|
|
||||||
} else {
|
|
||||||
if ((plot.getMembers().size() + plot.getTrusted().size()) >= plot.getArea().MAX_PLOT_MEMBERS) {
|
|
||||||
MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (plot.getDenied().contains(uuid)) {
|
if (plot.isOwner(uuid)) {
|
||||||
plot.removeDenied(uuid);
|
MainUtil.sendMessage(plr, C.ALREADY_OWNER, MainUtil.getName(uuid));
|
||||||
|
iter.remove();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
plot.addMember(uuid);
|
if (plot.getMembers().contains(uuid)) {
|
||||||
|
MainUtil.sendMessage(plr, C.ALREADY_ADDED, MainUtil.getName(uuid));
|
||||||
|
iter.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (plot.removeTrusted(uuid)) {
|
||||||
|
plot.addMember(uuid);
|
||||||
|
} else {
|
||||||
|
if ((plot.getMembers().size() + plot.getTrusted().size()) >= plot.getArea().MAX_PLOT_MEMBERS) {
|
||||||
|
MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
|
||||||
|
iter.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (plot.getDenied().contains(uuid)) {
|
||||||
|
plot.removeDenied(uuid);
|
||||||
|
}
|
||||||
|
plot.addMember(uuid);
|
||||||
|
}
|
||||||
|
EventUtil.manager.callMember(plr, plot, uuid, true);
|
||||||
|
}
|
||||||
|
if (!uuids.isEmpty()) {
|
||||||
|
MainUtil.sendMessage(plr, C.MEMBER_ADDED);
|
||||||
}
|
}
|
||||||
EventUtil.manager.callMember(plr, plot, uuid, true);
|
|
||||||
MainUtil.sendMessage(plr, C.MEMBER_ADDED);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,8 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
|||||||
import com.plotsquared.general.commands.Argument;
|
import com.plotsquared.general.commands.Argument;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.*;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@CommandDeclaration(command = "deny",
|
@CommandDeclaration(command = "deny",
|
||||||
aliases = {"d", "ban"},
|
aliases = {"d", "ban"},
|
||||||
@ -44,36 +45,41 @@ public class Deny extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
UUID uuid;
|
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||||
if (args[0].equalsIgnoreCase("*")) {
|
if (uuids == null || uuids.isEmpty()) {
|
||||||
uuid = DBFunc.everyone;
|
|
||||||
} else {
|
|
||||||
uuid = UUIDHandler.getUUID(args[0], null);
|
|
||||||
}
|
|
||||||
if (uuid == null) {
|
|
||||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (plot.isOwner(uuid)) {
|
Iterator<UUID> iter = uuids.iterator();
|
||||||
MainUtil.sendMessage(plr, C.ALREADY_OWNER);
|
while (iter.hasNext()) {
|
||||||
return false;
|
UUID uuid = iter.next();
|
||||||
}
|
if (uuid == DBFunc.everyone && !(Permissions.hasPermission(plr, "plots.deny.everyone") || Permissions.hasPermission(plr, "plots.admin.command.deny"))) {
|
||||||
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||||
if (plot.getDenied().contains(uuid)) {
|
continue;
|
||||||
MainUtil.sendMessage(plr, C.ALREADY_ADDED);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
plot.removeMember(uuid);
|
|
||||||
plot.removeTrusted(uuid);
|
|
||||||
plot.addDenied(uuid);
|
|
||||||
EventUtil.manager.callDenied(plr, plot, uuid, true);
|
|
||||||
MainUtil.sendMessage(plr, C.DENIED_ADDED);
|
|
||||||
if (!uuid.equals(DBFunc.everyone)) {
|
|
||||||
handleKick(UUIDHandler.getPlayer(uuid), plot);
|
|
||||||
} else {
|
|
||||||
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
|
||||||
handleKick(pp, plot);
|
|
||||||
}
|
}
|
||||||
|
if (plot.isOwner(uuid)) {
|
||||||
|
MainUtil.sendMessage(plr, C.ALREADY_OWNER, MainUtil.getName(uuid));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plot.getDenied().contains(uuid)) {
|
||||||
|
MainUtil.sendMessage(plr, C.ALREADY_ADDED, MainUtil.getName(uuid));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
plot.removeMember(uuid);
|
||||||
|
plot.removeTrusted(uuid);
|
||||||
|
plot.addDenied(uuid);
|
||||||
|
EventUtil.manager.callDenied(plr, plot, uuid, true);
|
||||||
|
if (!uuid.equals(DBFunc.everyone)) {
|
||||||
|
handleKick(UUIDHandler.getPlayer(uuid), plot);
|
||||||
|
} else {
|
||||||
|
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
||||||
|
handleKick(pp, plot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!uuids.isEmpty()) {
|
||||||
|
MainUtil.sendMessage(plr, C.DENIED_ADDED);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
@ -10,6 +11,9 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||||
import com.plotsquared.general.commands.Argument;
|
import com.plotsquared.general.commands.Argument;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandDeclaration(command = "kick",
|
@CommandDeclaration(command = "kick",
|
||||||
aliases = {"k"},
|
aliases = {"k"},
|
||||||
@ -35,32 +39,50 @@ public class Kick extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotPlayer player = UUIDHandler.getPlayer(args[0]);
|
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||||
if (player == null) {
|
if (uuids == null) {
|
||||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location location2 = player.getLocation();
|
Set<PlotPlayer> players = new HashSet<>();
|
||||||
if (!plr.getLocation().getWorld().equals(location2.getWorld()) || !plot.equals(location2.getPlot())) {
|
for (UUID uuid : uuids) {
|
||||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
if (uuid == DBFunc.everyone) {
|
||||||
return false;
|
players.addAll(plot.getPlayersInPlot());
|
||||||
}
|
break;
|
||||||
if (player.hasPermission("plots.admin.entry.denied")) {
|
}
|
||||||
C.CANNOT_KICK_PLAYER.send(plr, player.getName());
|
PlotPlayer pp = UUIDHandler.getPlayer(uuid);
|
||||||
return false;
|
if (pp != null) {
|
||||||
}
|
players.add(pp);
|
||||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
}
|
||||||
C.YOU_GOT_KICKED.send(player);
|
}
|
||||||
if (plot.equals(spawn.getPlot())) {
|
players.remove(plr); // Don't ever kick the calling player
|
||||||
Location newSpawn = WorldUtil.IMP.getSpawn(player);
|
if (players.isEmpty()) {
|
||||||
if (plot.equals(newSpawn.getPlot())) {
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||||
// Kick from server if you can't be teleported to spawn
|
return false;
|
||||||
player.kick(C.YOU_GOT_KICKED.s());
|
}
|
||||||
} else {
|
for (PlotPlayer player : players) {
|
||||||
player.teleport(newSpawn);
|
Location location2 = player.getLocation();
|
||||||
|
if (!plr.getLocation().getWorld().equals(location2.getWorld()) || !plot.equals(location2.getPlot())) {
|
||||||
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (player.hasPermission("plots.admin.entry.denied")) {
|
||||||
|
C.CANNOT_KICK_PLAYER.send(plr, player.getName());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
||||||
|
C.YOU_GOT_KICKED.send(player);
|
||||||
|
if (plot.equals(spawn.getPlot())) {
|
||||||
|
Location newSpawn = WorldUtil.IMP.getSpawn(player);
|
||||||
|
if (plot.equals(newSpawn.getPlot())) {
|
||||||
|
// Kick from server if you can't be teleported to spawn
|
||||||
|
player.kick(C.YOU_GOT_KICKED.s());
|
||||||
|
} else {
|
||||||
|
player.teleport(newSpawn);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
player.teleport(spawn);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
player.teleport(spawn);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,7 @@ public class MainCommand extends Command {
|
|||||||
new Trust();
|
new Trust();
|
||||||
new Add();
|
new Add();
|
||||||
new Deny();
|
new Deny();
|
||||||
new Untrust();
|
|
||||||
new Remove();
|
new Remove();
|
||||||
new Undeny();
|
|
||||||
new Info();
|
new Info();
|
||||||
new ListCmd();
|
new ListCmd();
|
||||||
new Debug();
|
new Debug();
|
||||||
|
@ -10,13 +10,12 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
import com.plotsquared.general.commands.Argument;
|
import com.plotsquared.general.commands.Argument;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
command = "remove",
|
command = "remove",
|
||||||
aliases = {"r"},
|
aliases = {"r","untrust", "ut", "undeny", "ud"},
|
||||||
description = "Remove a player from a plot",
|
description = "Remove a player from a plot",
|
||||||
usage = "/plot remove <player>",
|
usage = "/plot remove <player>",
|
||||||
category = CommandCategory.SETTINGS,
|
category = CommandCategory.SETTINGS,
|
||||||
@ -64,36 +63,22 @@ public class Remove extends SubCommand {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "*":
|
|
||||||
ArrayList<UUID> toRemove = new ArrayList<>();
|
|
||||||
HashSet<UUID> all = new HashSet<>();
|
|
||||||
all.addAll(plot.getMembers());
|
|
||||||
all.addAll(plot.getTrusted());
|
|
||||||
all.addAll(plot.getDenied());
|
|
||||||
for (UUID uuid : all) {
|
|
||||||
toRemove.add(uuid);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
for (UUID uuid : toRemove) {
|
|
||||||
plot.removeDenied(uuid);
|
|
||||||
plot.removeTrusted(uuid);
|
|
||||||
plot.removeMember(uuid);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
UUID uuid = UUIDHandler.getUUID(args[0], null);
|
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||||
if (uuid != null) {
|
if (uuids != null) {
|
||||||
if (plot.getTrusted().contains(uuid)) {
|
for (UUID uuid : uuids) {
|
||||||
if (plot.removeTrusted(uuid)) {
|
if (plot.getTrusted().contains(uuid)) {
|
||||||
count++;
|
if (plot.removeTrusted(uuid)) {
|
||||||
}
|
count++;
|
||||||
} else if (plot.getMembers().contains(uuid)) {
|
}
|
||||||
if (plot.removeMember(uuid)) {
|
} else if (plot.getMembers().contains(uuid)) {
|
||||||
count++;
|
if (plot.removeMember(uuid)) {
|
||||||
}
|
count++;
|
||||||
} else if (plot.getDenied().contains(uuid)) {
|
}
|
||||||
if (plot.removeDenied(uuid)) {
|
} else if (plot.getDenied().contains(uuid)) {
|
||||||
count++;
|
if (plot.removeDenied(uuid)) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,10 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.intellectualcrafters.plot.util.EventUtil;
|
import com.intellectualcrafters.plot.util.EventUtil;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
|
||||||
import com.plotsquared.general.commands.Argument;
|
import com.plotsquared.general.commands.Argument;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
import java.util.UUID;
|
import java.util.*;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
command = "trust",
|
command = "trust",
|
||||||
@ -41,38 +41,43 @@ public class Trust extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
UUID uuid;
|
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||||
if (args[0].equalsIgnoreCase("*") && (Permissions.hasPermission(plr, "plots.trust.everyone") || Permissions.hasPermission(plr, "plots.admin.command.trust"))) {
|
if (uuids == null || uuids.isEmpty()) {
|
||||||
uuid = DBFunc.everyone;
|
|
||||||
} else {
|
|
||||||
uuid = UUIDHandler.getUUID(args[0], null);
|
|
||||||
}
|
|
||||||
if (uuid == null) {
|
|
||||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (plot.isOwner(uuid)) {
|
Iterator<UUID> iter = uuids.iterator();
|
||||||
MainUtil.sendMessage(plr, C.ALREADY_OWNER);
|
while (iter.hasNext()) {
|
||||||
return false;
|
UUID uuid = iter.next();
|
||||||
}
|
if (uuid == DBFunc.everyone && !(Permissions.hasPermission(plr, "plots.trust.everyone") || Permissions.hasPermission(plr, "plots.admin.command.trust"))) {
|
||||||
if (plot.getTrusted().contains(uuid)) {
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||||
MainUtil.sendMessage(plr, C.ALREADY_ADDED);
|
continue;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (plot.removeMember(uuid)) {
|
|
||||||
plot.addTrusted(uuid);
|
|
||||||
} else {
|
|
||||||
if ((plot.getMembers().size() + plot.getTrusted().size()) >= plot.getArea().MAX_PLOT_MEMBERS) {
|
|
||||||
MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (plot.getDenied().contains(uuid)) {
|
if (plot.isOwner(uuid)) {
|
||||||
plot.removeDenied(uuid);
|
MainUtil.sendMessage(plr, C.ALREADY_OWNER, MainUtil.getName(uuid));
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
plot.addTrusted(uuid);
|
if (plot.getTrusted().contains(uuid)) {
|
||||||
|
MainUtil.sendMessage(plr, C.ALREADY_ADDED, MainUtil.getName(uuid));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (plot.removeMember(uuid)) {
|
||||||
|
plot.addTrusted(uuid);
|
||||||
|
} else {
|
||||||
|
if ((plot.getMembers().size() + plot.getTrusted().size()) >= plot.getArea().MAX_PLOT_MEMBERS) {
|
||||||
|
MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (plot.getDenied().contains(uuid)) {
|
||||||
|
plot.removeDenied(uuid);
|
||||||
|
}
|
||||||
|
plot.addTrusted(uuid);
|
||||||
|
}
|
||||||
|
EventUtil.manager.callTrusted(plr, plot, uuid, true);
|
||||||
|
}
|
||||||
|
if (!uuids.isEmpty()) {
|
||||||
|
MainUtil.sendMessage(plr, C.TRUSTED_ADDED);
|
||||||
}
|
}
|
||||||
EventUtil.manager.callTrusted(plr, plot, uuid, true);
|
|
||||||
MainUtil.sendMessage(plr, C.TRUSTED_ADDED);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
|
||||||
import com.plotsquared.general.commands.Argument;
|
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@CommandDeclaration(
|
|
||||||
command = "undeny",
|
|
||||||
aliases = {"ud"},
|
|
||||||
description = "Remove a denied user from a plot",
|
|
||||||
usage = "/plot undeny <player>",
|
|
||||||
requiredType = RequiredType.PLAYER,
|
|
||||||
category = CommandCategory.SETTINGS)
|
|
||||||
public class Undeny extends SubCommand {
|
|
||||||
|
|
||||||
public Undeny() {
|
|
||||||
super(Argument.PlayerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
|
||||||
|
|
||||||
Location loc = plr.getLocation();
|
|
||||||
Plot plot = loc.getPlotAbs();
|
|
||||||
if (plot == null) {
|
|
||||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
|
||||||
}
|
|
||||||
if (!plot.hasOwner()) {
|
|
||||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.undeny")) {
|
|
||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
int count = 0;
|
|
||||||
switch (args[0]) {
|
|
||||||
case "unknown":
|
|
||||||
ArrayList<UUID> toRemove = new ArrayList<>();
|
|
||||||
for (UUID uuid : plot.getDenied()) {
|
|
||||||
if (UUIDHandler.getName(uuid) == null) {
|
|
||||||
toRemove.add(uuid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (UUID uuid : toRemove) {
|
|
||||||
plot.removeDenied(uuid);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "*":
|
|
||||||
for (UUID uuid : new ArrayList<>(plot.getDenied())) {
|
|
||||||
plot.removeDenied(uuid);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
UUID uuid = UUIDHandler.getUUID(args[0], null);
|
|
||||||
if (uuid != null) {
|
|
||||||
if (plot.removeDenied(uuid)) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (count == 0) {
|
|
||||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
MainUtil.sendMessage(plr, C.REMOVED_PLAYERS, count + "");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
|
||||||
import com.plotsquared.general.commands.Argument;
|
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
// UNTRUST("untrust", "ut"),
|
|
||||||
|
|
||||||
@CommandDeclaration(
|
|
||||||
command = "untrust",
|
|
||||||
aliases = {"ut"},
|
|
||||||
permission = "plots.untrust",
|
|
||||||
description = "Remove a trusted user from a plot",
|
|
||||||
usage = "/plot untrust <player>",
|
|
||||||
requiredType = RequiredType.PLAYER,
|
|
||||||
category = CommandCategory.SETTINGS)
|
|
||||||
public class Untrust extends SubCommand {
|
|
||||||
|
|
||||||
public Untrust() {
|
|
||||||
super(Argument.PlayerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
|
||||||
Location loc = plr.getLocation();
|
|
||||||
Plot plot = loc.getPlotAbs();
|
|
||||||
if (plot == null) {
|
|
||||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
|
||||||
}
|
|
||||||
if (!plot.hasOwner()) {
|
|
||||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.untrust")) {
|
|
||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
int count = 0;
|
|
||||||
switch (args[0]) {
|
|
||||||
case "unknown":
|
|
||||||
ArrayList<UUID> toRemove = new ArrayList<>();
|
|
||||||
for (UUID uuid : plot.getTrusted()) {
|
|
||||||
if (UUIDHandler.getName(uuid) == null) {
|
|
||||||
toRemove.add(uuid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (UUID uuid : toRemove) {
|
|
||||||
plot.removeTrusted(uuid);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "*":
|
|
||||||
for (UUID uuid : new ArrayList<>(plot.getTrusted())) {
|
|
||||||
plot.removeTrusted(uuid);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
UUID uuid = UUIDHandler.getUUID(args[0], null);
|
|
||||||
if (uuid != null) {
|
|
||||||
if (plot.removeTrusted(uuid)) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (count == 0) {
|
|
||||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
MainUtil.sendMessage(plr, C.REMOVED_PLAYERS, count + "");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -574,8 +574,8 @@ public enum C {
|
|||||||
* Member
|
* Member
|
||||||
*/
|
*/
|
||||||
REMOVED_PLAYERS("$2Removed %s players from this plot.", "Member"),
|
REMOVED_PLAYERS("$2Removed %s players from this plot.", "Member"),
|
||||||
ALREADY_OWNER("$2That user is already the plot owner.", "Member"),
|
ALREADY_OWNER("$2That user is already the plot owner: %s0", "Member"),
|
||||||
ALREADY_ADDED("$2That user is already added to that category.", "Member"),
|
ALREADY_ADDED("$2That user is already added to that category: %s0", "Member"),
|
||||||
MEMBER_ADDED("$4That user can now build while the plot owner is online", "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_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"),
|
MEMBER_WAS_NOT_ADDED("$2That player was not added as a user on this plot", "Member"),
|
||||||
|
@ -19,7 +19,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@ -35,9 +34,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -692,6 +693,35 @@ public class MainUtil {
|
|||||||
return ratings;
|
return ratings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Set<UUID> getUUIDsFromString(String list) {
|
||||||
|
String[] split = list.split(",");
|
||||||
|
HashSet<UUID> result = new HashSet<UUID>();
|
||||||
|
for (String name : split) {
|
||||||
|
if (name.length() == 0) {
|
||||||
|
// Invalid
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (name.equals("*")) {
|
||||||
|
result.add(DBFunc.everyone);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (name.length() > 16) {
|
||||||
|
try {
|
||||||
|
result.add(UUID.fromString(name));
|
||||||
|
continue;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UUID uuid = UUIDHandler.getUUID(name, null);
|
||||||
|
if (uuid == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
result.add(uuid);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a string with plot information.
|
* Format a string with plot information.
|
||||||
* @param info
|
* @param info
|
||||||
|
Loading…
Reference in New Issue
Block a user