summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDico Karssiens <dico.karssiens@gmail.com>2018-10-04 10:24:13 +0100
committerDico Karssiens <dico.karssiens@gmail.com>2018-10-04 10:24:13 +0100
commite55c595e54116961798cec03f6404d0c8d986e6d (patch)
tree0ef21b8f58d694c5a6a5b5455e501126a92dbb02
parentc4801757a2fda147e1cee65f70f80fb215047525 (diff)
Tiny fixes
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/registration/reflect/ReflectiveCommand.java21
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/registration/reflect/ReflectiveRegistration.java2
-rw-r--r--src/main/kotlin/io/dico/parcels2/command/ParcelParameterTypes.kt10
-rw-r--r--src/main/kotlin/io/dico/parcels2/listener/ParcelListeners.kt10
-rw-r--r--todo.md17
5 files changed, 52 insertions, 8 deletions
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/registration/reflect/ReflectiveCommand.java b/dicore3/command/src/main/java/io/dico/dicore/command/registration/reflect/ReflectiveCommand.java
index ee90efe..2d7c333 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/registration/reflect/ReflectiveCommand.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/registration/reflect/ReflectiveCommand.java
@@ -11,6 +11,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
public final class ReflectiveCommand extends Command {
+ private static final int continuationMask = 1 << 3;
private final Cmd cmdAnnotation;
private final Method method;
private final Object instance;
@@ -86,13 +87,16 @@ public final class ReflectiveCommand extends Command {
@Override
public String execute(CommandSender sender, ExecutionContext context) throws CommandException {
String[] parameterOrder = this.parameterOrder;
- int start = Integer.bitCount(flags);
- Object[] args = new Object[parameterOrder.length + start];
+ int extraArgumentCount = Integer.bitCount(flags);
+ int parameterStartIndex = Integer.bitCount(flags & ~continuationMask);
+
+ Object[] args = new Object[parameterOrder.length + extraArgumentCount];
int i = 0;
int mask = 1;
if ((flags & mask) != 0) {
+ // Has receiver
try {
args[i++] = ((ICommandInterceptor) instance).getReceiver(context, method, getCmdName());
} catch (Exception ex) {
@@ -103,20 +107,29 @@ public final class ReflectiveCommand extends Command {
mask <<= 1;
if ((flags & mask) != 0) {
+ // Has sender
args[i++] = sender;
}
mask <<= 1;
if ((flags & mask) != 0) {
+ // Has context
args[i++] = context;
}
+ mask <<= 1;
+ if ((flags & mask) != 0) {
+ // Has continuation
+
+ extraArgumentCount--;
+ }
+
for (int n = args.length; i < n; i++) {
- args[i] = context.get(parameterOrder[i - start]);
+ args[i] = context.get(parameterOrder[i - extraArgumentCount]);
}
- mask <<= 1;
if ((flags & mask) != 0) {
+ // Since it has continuation, call as coroutine
return callAsCoroutine(context, args);
}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/registration/reflect/ReflectiveRegistration.java b/dicore3/command/src/main/java/io/dico/dicore/command/registration/reflect/ReflectiveRegistration.java
index 1405414..6b1965d 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/registration/reflect/ReflectiveRegistration.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/registration/reflect/ReflectiveRegistration.java
@@ -236,7 +236,7 @@ public class ReflectiveRegistration {
Parameter<?, ?> parameter = parseParameter(selector, method, parameters[i], parameterNames[i - start]);
list.addParameter(parameter);
}
- command.setParameterOrder(parameterNames);
+ command.setParameterOrder(hasContinuationParameter ? Arrays.copyOfRange(parameterNames, 0, parameterNames.length - 1) : parameterNames);
RequirePermissions cmdPermissions = method.getAnnotation(RequirePermissions.class);
if (cmdPermissions != null) {
diff --git a/src/main/kotlin/io/dico/parcels2/command/ParcelParameterTypes.kt b/src/main/kotlin/io/dico/parcels2/command/ParcelParameterTypes.kt
index a9f5498..c7083a1 100644
--- a/src/main/kotlin/io/dico/parcels2/command/ParcelParameterTypes.kt
+++ b/src/main/kotlin/io/dico/parcels2/command/ParcelParameterTypes.kt
@@ -9,6 +9,7 @@ import io.dico.parcels2.*
import io.dico.parcels2.command.ProfileKind.Companion.ANY
import io.dico.parcels2.command.ProfileKind.Companion.FAKE
import io.dico.parcels2.command.ProfileKind.Companion.REAL
+import org.bukkit.Location
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
@@ -70,4 +71,13 @@ class ProfileParameterType : ParameterType<PlayerProfile, Int>(PlayerProfile::cl
return PlayerProfile.byName(input, allowReal, allowFake)
}
+ override fun complete(
+ parameter: Parameter<PlayerProfile, Int>,
+ sender: CommandSender,
+ location: Location?,
+ buffer: ArgumentBuffer
+ ): MutableList<String> {
+ logger.info("Completing PlayerProfile: ${buffer.next()}")
+ return super.complete(parameter, sender, location, buffer)
+ }
}
diff --git a/src/main/kotlin/io/dico/parcels2/listener/ParcelListeners.kt b/src/main/kotlin/io/dico/parcels2/listener/ParcelListeners.kt
index 59d10e7..9c9bdc2 100644
--- a/src/main/kotlin/io/dico/parcels2/listener/ParcelListeners.kt
+++ b/src/main/kotlin/io/dico/parcels2/listener/ParcelListeners.kt
@@ -266,6 +266,8 @@ class ParcelListeners(
}
}
+ // private val blockPlaceInteractItems = EnumSet.of(LAVA_BUCKET, WATER_BUCKET, BUCKET, FLINT_AND_STEEL)
+
@Suppress("NON_EXHAUSTIVE_WHEN")
private fun onPlayerRightClick(event: PlayerInteractEvent, world: ParcelWorld, parcel: Parcel?) {
if (event.hasItem()) {
@@ -275,9 +277,11 @@ class ParcelListeners(
event.isCancelled = true; return
}
- if (!canBuildOnArea(event.player, parcel)) {
- when (item) {
- LAVA_BUCKET, WATER_BUCKET, BUCKET, FLINT_AND_STEEL -> {
+ when (item) {
+ LAVA_BUCKET, WATER_BUCKET, BUCKET, FLINT_AND_STEEL -> {
+ val block = event.clickedBlock.getRelative(event.blockFace)
+ val otherParcel = world.getParcelAt(block)
+ if (!canBuildOnArea(event.player, otherParcel)) {
event.isCancelled = true
}
}
diff --git a/todo.md b/todo.md
index 03d491b..6f3b12a 100644
--- a/todo.md
+++ b/todo.md
@@ -84,3 +84,20 @@ Implement a container that doesn't require loading all parcel data on startup (C
~~Store player status on parcel (allowed, default banned) as a number to allow for future additions to this set of possibilities~~
+After testing on Redstoner
+-
+
+Clear (and swap) entities on /p clear etc
+Fix command lag
+Chorus fruit can grow outside plots
+Vines can grow outside plots
+Ghasts, bats, phantoms and magma cubes can be spawned with eggs
+ParcelTarget doesn't report a world that wasn't found correctly
+Jumping on turtle eggs is considered as interacting with pressure plates
+Setbiome internal error when progress reporting is attached
+Unclaim doesn't clear the plot. It probably should.
+Players can shoot boats and minecarts.
+You can use disabled items by rightclicking air.
+Tab complete isn't working correctly.
+~~Bed use in nether and end might not have to be blocked.~~
+