Minor command changes

Changed RequiredType in some classes and formatting changed in others.
This commit is contained in:
MattBDev 2019-04-22 11:55:05 -04:00
parent f5fa15080c
commit ef8d33db41
12 changed files with 69 additions and 52 deletions

View file

@ -19,7 +19,7 @@ import java.util.UUID;
@CommandDeclaration(command = "add",
description = "Allow a user to build in a plot while you are online",
usage = "/plot add <player>", category = CommandCategory.SETTINGS, permission = "plots.add",
requiredType = RequiredType.NONE) public class Add extends Command {
requiredType = RequiredType.PLAYER) public class Add extends Command {
public Add() {
super(MainCommand.getInstance(), true);
@ -63,21 +63,19 @@ import java.util.UUID;
checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST),
Captions.PLOT_MAX_MEMBERS);
confirm.run(this, new Runnable() {
@Override // Success
public void run() {
for (UUID uuid : uuids) {
if (uuid != DBFunc.EVERYONE) {
if (!plot.removeTrusted(uuid)) {
if (plot.getDenied().contains(uuid)) {
plot.removeDenied(uuid);
}
// Success
confirm.run(this, () -> {
for (UUID uuid : uuids) {
if (uuid != DBFunc.EVERYONE) {
if (!plot.removeTrusted(uuid)) {
if (plot.getDenied().contains(uuid)) {
plot.removeDenied(uuid);
}
}
plot.addMember(uuid);
EventUtil.manager.callMember(player, plot, uuid, true);
MainUtil.sendMessage(player, Captions.MEMBER_ADDED);
}
plot.addMember(uuid);
EventUtil.manager.callMember(player, plot, uuid, true);
MainUtil.sendMessage(player, Captions.MEMBER_ADDED);
}
}, null);
}

View file

@ -25,8 +25,12 @@ public class Auto extends SubCommand {
if (allowedPlots == null) {
allowedPlots = player.getAllowedPlots();
}
int currentPlots =
Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(plotarea.worldname);
int currentPlots;
if (Settings.Limit.GLOBAL) {
currentPlots = player.getPlotCount();
} else {
currentPlots = player.getPlotCount(plotarea.worldname);
}
int diff = currentPlots - allowedPlots;
if (diff + sizeX * sizeZ > 0) {
if (diff < 0) {

View file

@ -27,11 +27,9 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
return false;
}
plot.addRunning();
plot.setBiome(value.toUpperCase(), new Runnable() {
@Override public void run() {
plot.removeRunning();
MainUtil.sendMessage(player, Captions.BIOME_SET_TO.s() + value.toLowerCase());
}
plot.setBiome(value.toUpperCase(), () -> {
plot.removeRunning();
MainUtil.sendMessage(player, Captions.BIOME_SET_TO.s() + value.toLowerCase());
});
return true;
}

View file

@ -126,13 +126,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
}
i++;
final AtomicBoolean result = new AtomicBoolean(false);
result.set(origin.move(possible, new Runnable() {
@Override public void run() {
if (result.get()) {
MainUtil.sendMessage(player,
"Moving: " + origin + " -> " + possible);
TaskManager.runTaskLater(task, 1);
}
result.set(origin.move(possible, () -> {
if (result.get()) {
MainUtil.sendMessage(player,
"Moving: " + origin + " -> " + possible);
TaskManager.runTaskLater(task, 1);
}
}, false));
if (result.get()) {

View file

@ -16,7 +16,7 @@ import java.util.UUID;
@CommandDeclaration(command = "deny", aliases = {"d", "ban"},
description = "Deny a user from a plot", usage = "/plot deny <player>",
category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE) public class Deny
category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER) public class Deny
extends SubCommand {
public Deny() {

View file

@ -38,8 +38,12 @@ import java.util.UUID;
if (args.length > 2) {
break;
}
final UUID uuid =
args.length == 2 ? UUIDHandler.getUUIDFromString(args[1]) : player.getUUID();
final UUID uuid;
if (args.length == 2) {
uuid = UUIDHandler.getUUIDFromString(args[1]);
} else {
uuid = player.getUUID();
}
if (uuid == null) {
Captions.INVALID_PLAYER.send(player, args[1]);
return;
@ -47,12 +51,20 @@ import java.util.UUID;
MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal<byte[]>() {
@Override public void run(byte[] array) {
if (arg0.equals("check")) { // check
int granted =
array == null ? 0 : ByteArrayUtilities.bytesToInteger(array);
int granted;
if (array == null) {
granted = 0;
} else {
granted = ByteArrayUtilities.bytesToInteger(array);
}
Captions.GRANTED_PLOTS.send(player, granted);
} else { // add
int amount =
1 + (array == null ? 0 : ByteArrayUtilities.bytesToInteger(array));
int amount;
if (array == null) {
amount = 1;
} else {
amount = 1 + ByteArrayUtilities.bytesToInteger(array);
}
boolean replace = array != null;
String key = "grantedPlots";
byte[] rawData = ByteArrayUtilities.integerToBytes(amount);

View file

@ -15,7 +15,7 @@ import java.util.List;
@CommandDeclaration(command = "inbox", description = "Review the comments for a plot",
usage = "/plot inbox [inbox] [delete <index>|clear|page]", permission = "plots.inbox",
category = CommandCategory.CHAT, requiredType = RequiredType.NONE) public class Inbox
category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER) public class Inbox
extends SubCommand {
public void displayComments(PlotPlayer player, List<PlotComment> oldComments, int page) {
@ -23,7 +23,7 @@ import java.util.List;
MainUtil.sendMessage(player, Captions.INBOX_EMPTY);
return;
}
PlotComment[] comments = oldComments.toArray(new PlotComment[oldComments.size()]);
PlotComment[] comments = oldComments.toArray(new PlotComment[0]);
if (page < 0) {
page = 0;
}

View file

@ -130,9 +130,15 @@ import java.util.UUID;
if (arg != null) {
info = getCaption(arg);
if (info == null) {
MainUtil.sendMessage(player,
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
+ "&aowner&7, " + (Settings.Ratings.USE_LIKES ? " &alikes" : " &arating"));
if (Settings.Ratings.USE_LIKES) {
MainUtil.sendMessage(player,
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
+ "&aowner&7, " + " &alikes");
} else {
MainUtil.sendMessage(player,
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
+ "&aowner&7, " + " &arating");
}
return false;
}
full = true;

View file

@ -19,7 +19,7 @@ import java.util.UUID;
@CommandDeclaration(command = "kick", aliases = {"k"}, description = "Kick a player from your plot",
permission = "plots.kick", usage = "/plot kick <player>", category = CommandCategory.TELEPORT,
requiredType = RequiredType.NONE) public class Kick extends SubCommand {
requiredType = RequiredType.PLAYER) public class Kick extends SubCommand {
public Kick() {
super(Argument.PlayerName);

View file

@ -96,8 +96,11 @@ public class Like extends SubCommand {
final Rating result = EventUtil.manager.callRating(player, plot, new Rating(rating));
if (result != null) {
plot.addRating(uuid, result);
sendMessage(player, like ? Captions.RATING_LIKED : Captions.RATING_DISLIKED,
plot.getId().toString());
if (like) {
sendMessage(player, Captions.RATING_LIKED, plot.getId().toString());
} else {
sendMessage(player, Captions.RATING_DISLIKED, plot.getId().toString());
}
}
};
if (plot.getSettings().ratings == null) {

View file

@ -9,7 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
@CommandDeclaration(usage = "/plot swap <X;Z>", command = "swap", description = "Swap two plots",
aliases = {"switch"}, category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE)
aliases = {"switch"}, category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER)
public class Swap extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) {

View file

@ -7,8 +7,8 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.*;
@CommandDeclaration(command = "unlink", aliases = {"u", "unmerge"},
description = "Unlink a mega-plot", usage = "/plot unlink [createroads]", requiredType = RequiredType.PLAYER, category = CommandCategory.SETTINGS, confirmation = true)
@CommandDeclaration(command = "unlink", aliases = {"u",
"unmerge"}, description = "Unlink a mega-plot", usage = "/plot unlink [createroads]", requiredType = RequiredType.PLAYER, category = CommandCategory.SETTINGS, confirmation = true)
public class Unlink extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
@ -38,14 +38,12 @@ public class Unlink extends SubCommand {
} else {
createRoad = true;
}
Runnable runnable = new Runnable() {
@Override public void run() {
if (!plot.unlinkPlot(createRoad, createRoad)) {
MainUtil.sendMessage(player, "&cUnlink has been cancelled");
return;
}
MainUtil.sendMessage(player, Captions.UNLINK_SUCCESS);
Runnable runnable = () -> {
if (!plot.unlinkPlot(createRoad, createRoad)) {
MainUtil.sendMessage(player, "&cUnlink has been cancelled");
return;
}
MainUtil.sendMessage(player, Captions.UNLINK_SUCCESS);
};
if (hasConfirmation(player)) {
CmdConfirm.addPending(player, "/plot unlink " + plot.getId(), runnable);