mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Fix minor issues
This commit is contained in:
parent
32e095ce15
commit
287cb0f5ad
@ -38,6 +38,7 @@ import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
@ -223,7 +224,7 @@ public abstract class Command {
|
||||
return "plots." + getFullId();
|
||||
}
|
||||
|
||||
public <T> void paginate(PlotPlayer player, List<T> c, int size, int page,
|
||||
public <T> void paginate(PlotPlayer<?> player, List<T> c, int size, int page,
|
||||
RunnableVal3<Integer, T, Caption> add, String baseCommand, String header) {
|
||||
// Calculate pages & index
|
||||
if (page < 0) {
|
||||
@ -576,34 +577,36 @@ public abstract class Command {
|
||||
return this.getFullId().hashCode();
|
||||
}
|
||||
|
||||
public void checkTrue(boolean mustBeTrue, Captions message, Template... args) {
|
||||
public void checkTrue(boolean mustBeTrue, Caption message, Template... args) {
|
||||
if (!mustBeTrue) {
|
||||
throw new CommandException(message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends Object> T check(T object, Captions message, Template... args) {
|
||||
public <T> T check(T object, Caption message, Template... args) {
|
||||
if (object == null) {
|
||||
throw new CommandException(message, args);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
public enum CommandResult {
|
||||
FAILURE, SUCCESS
|
||||
}
|
||||
|
||||
|
||||
public static class CommandException extends RuntimeException {
|
||||
|
||||
private final Template[] args;
|
||||
private final Caption message;
|
||||
|
||||
public CommandException(Caption message, Template... args) {
|
||||
public CommandException(@Nullable final Caption message, final Template... args) {
|
||||
this.message = message;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public void perform(PlotPlayer player) {
|
||||
public void perform(@Nullable final PlotPlayer<?> player) {
|
||||
if (player != null && message != null) {
|
||||
player.sendMessage(message, args);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.caption.Templates;
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.database.DBFunc;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
@ -74,7 +75,9 @@ public class Trust extends Command {
|
||||
checkTrue(currentPlot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST),
|
||||
Captions.NO_PLOT_PERMS);
|
||||
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
|
||||
|
||||
checkTrue(args.length == 1, TranslatableCaption.of("commandconfig.command_syntax"),
|
||||
Templates.of("value", getUsage()));
|
||||
|
||||
final CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> {
|
||||
@ -90,7 +93,9 @@ public class Trust extends Command {
|
||||
future.completeExceptionally(throwable);
|
||||
return;
|
||||
} else {
|
||||
checkTrue(!uuids.isEmpty(), Captions.INVALID_PLAYER, args[0]);
|
||||
checkTrue(!uuids.isEmpty(), TranslatableCaption.of("errors.invalid_player"),
|
||||
Templates.of("value", args[0]));
|
||||
|
||||
Iterator<UUID> iterator = uuids.iterator();
|
||||
int size = currentPlot.getTrusted().size() + currentPlot.getMembers().size();
|
||||
while (iterator.hasNext()) {
|
||||
|
@ -1,15 +1,10 @@
|
||||
package com.plotsquared.core.util;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
/**
|
||||
* This cache is used for world generation and just saves a bit of calculation time when checking if something is in the plot area.
|
||||
*/
|
||||
@UtilityClass
|
||||
public class ChunkUtil {
|
||||
|
||||
|
||||
/**
|
||||
* Cache of mapping x,y,z coordinates to the chunk array<br>
|
||||
* - Used for efficient world generation<br>
|
||||
@ -46,6 +41,9 @@ public class ChunkUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private ChunkUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the J value for Chunk block storage from the chunk xyz coordinates.
|
||||
* J is in the range 0 to 4095 where it represents a position in an array of 16x16x16 xyz (ChunkSection Array[4096]).
|
||||
@ -55,8 +53,8 @@ public class ChunkUtil {
|
||||
* @param z Relative z coordinate
|
||||
* @return J value for xyz position in Array[4096].
|
||||
*/
|
||||
public static int getJ(@Range(from = 0, to = 15) int x, @Range(from = 0, to = 255) int y,
|
||||
@Range(from = 0, to = 15) int z) {
|
||||
public static int getJ(int x, int y,
|
||||
int z) {
|
||||
return CACHE_J[y][x][z];
|
||||
}
|
||||
|
||||
@ -66,7 +64,7 @@ public class ChunkUtil {
|
||||
* @param j Position in the xyz Array[4096].
|
||||
* @return x coordinate within the chunk
|
||||
*/
|
||||
public static int getX(@Range(from = 0, to = 4095) int j) {
|
||||
public static int getX(int j) {
|
||||
return x_loc[j];
|
||||
}
|
||||
|
||||
@ -77,7 +75,7 @@ public class ChunkUtil {
|
||||
* @param j Position in the xyz Array[4096].
|
||||
* @return x coordinate within the chunk
|
||||
*/
|
||||
public static int getY(@Range(from = 0, to = 15) int i, @Range(from = 0, to = 4095) int j) {
|
||||
public static int getY(int i, int j) {
|
||||
return y_loc[i][j];
|
||||
}
|
||||
|
||||
@ -87,7 +85,7 @@ public class ChunkUtil {
|
||||
* @param j Position in the xyz Array[4096].
|
||||
* @return z coordinate within the chunk
|
||||
*/
|
||||
public static int getZ(@Range(from = 0, to = 4095) int j) {
|
||||
public static int getZ(int j) {
|
||||
return z_loc[j];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user