mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Add plot leave
This commit is contained in:
parent
3633576e03
commit
a913983d99
@ -5,10 +5,11 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import java.util.*;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "leave",
|
||||
description = "Leave a plot",
|
||||
@ -16,7 +17,7 @@ import java.util.Set;
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Leave extends Command {
|
||||
public Leave(Command parent, boolean isStatic) {
|
||||
public Leave() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
||||
@ -27,9 +28,21 @@ public class Leave extends Command {
|
||||
checkTrue(plot.isAdded(player.getUUID()), C.NO_PLOT_PERMS);
|
||||
checkTrue(args.length == 0, C.COMMAND_SYNTAX, getUsage());
|
||||
if (plot.isOwner(player.getUUID())) {
|
||||
Set<UUID> owners = plot.getOwners();
|
||||
checkTrue(plot.hasOwner(), C.ALREADY_OWNER);
|
||||
// TODO setowner, other
|
||||
} else {
|
||||
|
||||
UUID uuid = player.getUUID();
|
||||
if (plot.isAdded(uuid)) {
|
||||
if (plot.removeTrusted(uuid)) {
|
||||
EventUtil.manager.callTrusted(player, plot, uuid, false);
|
||||
}
|
||||
if (plot.removeMember(uuid)) {
|
||||
EventUtil.manager.callMember(player, plot, uuid, false);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.REMOVED_PLAYERS, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -61,6 +61,7 @@ public class MainCommand extends Command {
|
||||
new Delete();
|
||||
new Trust();
|
||||
new Add();
|
||||
new Leave();
|
||||
new Deny();
|
||||
new Remove();
|
||||
new Info();
|
||||
|
@ -123,8 +123,6 @@ public abstract class SchematicHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Paste a schematic.
|
||||
*
|
||||
@ -352,12 +350,10 @@ public abstract class SchematicHandler {
|
||||
|
||||
public Schematic getSchematic(CompoundTag tag) {
|
||||
Map<String, Tag> tagMap = tag.getValue();
|
||||
// Slow
|
||||
// byte[] addId = new byte[0];
|
||||
// if (tagMap.containsKey("AddBlocks")) {
|
||||
// addId = ByteArrayTag.class.cast(tagMap.get("AddBlocks")).getValue();
|
||||
// }
|
||||
// end slow
|
||||
byte[] addBlocks = null;
|
||||
if (tagMap.containsKey("AddBlocks")) {
|
||||
addBlocks = ByteArrayTag.class.cast(tagMap.get("AddBlocks")).getValue();
|
||||
}
|
||||
|
||||
short width = ShortTag.class.cast(tagMap.get("Width")).getValue();
|
||||
short length = ShortTag.class.cast(tagMap.get("Length")).getValue();
|
||||
@ -380,18 +376,25 @@ public abstract class SchematicHandler {
|
||||
block[i] = id;
|
||||
}
|
||||
|
||||
// Slow + has code for exceptions (addId) inside the loop rather than outside
|
||||
// for (int index = 0; index < b.length; index++) {
|
||||
// if ((index >> 1) >= addId.length) {
|
||||
// blocks[index] = (short) (b[index] & 0xFF);
|
||||
// } else {
|
||||
// if ((index & 1) == 0) {
|
||||
// blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (b[index] & 0xFF));
|
||||
// } else {
|
||||
// blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (b[index] & 0xFF));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (addBlocks != null) {
|
||||
if (addBlocks.length == block.length) {
|
||||
for (int i = 0; i < addBlocks.length; i++) {
|
||||
byte val = addBlocks[i];
|
||||
if (val != 0) {
|
||||
block[i] |= (val << 8);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int index = 0; index < block.length; index++) {
|
||||
if ((index & 1) == 0) {
|
||||
block[index] = (short) (((addBlocks[index >> 1] & 0x0F) << 8) + (block[index]));
|
||||
} else {
|
||||
block[index] = (short) (((addBlocks[index >> 1] & 0xF0) << 4) + (block[index]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Slow as wrapper for each block
|
||||
// final DataCollection[] collection = new DataCollection[b.length];
|
||||
// for (int x = 0; x < b.length; x++) {
|
||||
|
Loading…
Reference in New Issue
Block a user