Archived
0

Tiny fixes

This commit is contained in:
Dico Karssiens
2018-10-04 10:24:13 +01:00
parent c4801757a2
commit e55c595e54
5 changed files with 54 additions and 10 deletions

View File

@@ -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;
}
for (int n = args.length; i < n; i++) {
args[i] = context.get(parameterOrder[i - start]);
}
mask <<= 1;
if ((flags & mask) != 0) {
// Has continuation
extraArgumentCount--;
}
for (int n = args.length; i < n; i++) {
args[i] = context.get(parameterOrder[i - extraArgumentCount]);
}
if ((flags & mask) != 0) {
// Since it has continuation, call as coroutine
return callAsCoroutine(context, args);
}

View File

@@ -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) {

View File

@@ -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)
}
}

View File

@@ -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
}
}

17
todo.md
View File

@@ -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.~~