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