mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-28 11:44:42 +02:00
Several changes:
- Several API improvements - persistent WorldEdit bypass toggle - persistent plot chat toggle - Plot BO3 exporting (useful f - Fix fastmode clearing unclaim border - Add player-interact flag for NPC interaction etc. Fixes #543 - Several fixes for sponge - some code cleanup - Closes #529
This commit is contained in:
46
src/main/java/com/intellectualcrafters/plot/object/BO3.java
Normal file
46
src/main/java/com/intellectualcrafters/plot/object/BO3.java
Normal file
@ -0,0 +1,46 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
public class BO3 {
|
||||
private final ChunkLoc chunk;
|
||||
private final StringBuilder blocks;
|
||||
private final StringBuilder children;
|
||||
private final String name;
|
||||
|
||||
public BO3(String name, ChunkLoc loc) {
|
||||
this.name = name;
|
||||
this.chunk = loc;
|
||||
this.blocks = new StringBuilder();
|
||||
this.children = new StringBuilder();
|
||||
}
|
||||
|
||||
public void addChild(BO3 child) {
|
||||
ChunkLoc childloc = child.getLoc();
|
||||
children.append("Branch(" + (childloc.x - chunk.x) + ",0," + (childloc.z - chunk.z) + "," + name + "_" + childloc.x + "_" + childloc.z + ")\n");
|
||||
}
|
||||
|
||||
public ChunkLoc getLoc() {
|
||||
return this.chunk;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void addBlock(int x, int y, int z, PlotBlock block) {
|
||||
if (block.data == 0) {
|
||||
// Block(-3,1,-2,AIR)
|
||||
blocks.append("Block(" + x + "," + y + "," + z + "," + block.id + ")\n");
|
||||
}
|
||||
else {
|
||||
blocks.append("Block(" + x + "," + y + "," + z + "," + block.id + ":" + block.data + ")\n");
|
||||
}
|
||||
}
|
||||
|
||||
public String getBlocks() {
|
||||
return blocks.toString();
|
||||
}
|
||||
|
||||
public String getChildren() {
|
||||
return children.toString();
|
||||
}
|
||||
}
|
@ -20,6 +20,8 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -28,13 +30,18 @@ import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.util.BO3Handler;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
/**
|
||||
@ -717,6 +724,71 @@ public class Plot {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the plot as a schematic to the configured output directory
|
||||
* @return
|
||||
*/
|
||||
public void export(final RunnableVal<Boolean> whenDone) {
|
||||
SchematicHandler.manager.getCompoundTag(world, id, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (value == null) {
|
||||
if (whenDone != null) {
|
||||
whenDone.value = false;
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
}
|
||||
else {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String name = id+ "," + world + "," + MainUtil.getName(owner);
|
||||
final boolean result = SchematicHandler.manager.save(value, Settings.SCHEMATIC_SAVE_PATH + File.separator + name + ".schematic");
|
||||
if (whenDone != null) {
|
||||
whenDone.value = result;
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the plot as a BO3 object
|
||||
* @param whenDone value will be false if exporting fails
|
||||
*/
|
||||
public void exportBO3(final RunnableVal<Boolean> whenDone) {
|
||||
boolean result = BO3Handler.saveBO3(this);
|
||||
if (whenDone != null) {
|
||||
whenDone.value = result;
|
||||
}
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload the plot to the configured web interface
|
||||
* @param whenDone value will be null if uploading fails
|
||||
*/
|
||||
public void upload(final RunnableVal<URL> whenDone) {
|
||||
SchematicHandler.manager.getCompoundTag(world, id, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
URL url = SchematicHandler.manager.upload(value, null, null);
|
||||
if (whenDone != null) {
|
||||
whenDone.value = url;
|
||||
}
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
|
@ -45,9 +45,11 @@ public abstract class PlotManager {
|
||||
/*
|
||||
* Plot clearing (return false if you do not support some method)
|
||||
*/
|
||||
public abstract boolean clearPlot(final PlotWorld plotworld, final Plot plot, boolean isDelete, Runnable whenDone);
|
||||
public abstract boolean clearPlot(final PlotWorld plotworld, final Plot plot, Runnable whenDone);
|
||||
|
||||
public abstract boolean claimPlot(final PlotWorld plotworld, final Plot plot);
|
||||
|
||||
public abstract boolean unclaimPlot(final PlotWorld plotworld, final Plot plot, Runnable whenDone);
|
||||
|
||||
public abstract Location getSignLoc(final PlotWorld plotworld, final Plot plot);
|
||||
|
||||
|
@ -176,8 +176,12 @@ public abstract class PlotPlayer implements CommandCaller {
|
||||
public abstract Location getLocationFull();
|
||||
|
||||
/**
|
||||
* Get the player's UUID
|
||||
* @return
|
||||
* Get the player's UUID<br>
|
||||
* === !IMPORTANT ===<br>
|
||||
* The UUID is dependent on the mode chosen in the settings.yml and may not be the same as Bukkit has
|
||||
* (especially if using an old version of Bukkit that does not support UUIDs)
|
||||
*
|
||||
* @return UUID
|
||||
*/
|
||||
public abstract UUID getUUID();
|
||||
|
||||
|
@ -1,70 +0,0 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings({"unused"})
|
||||
public class StaticStrings {
|
||||
|
||||
public static final String
|
||||
PERMISSION_ADMIN = "plots.admin",
|
||||
PERMISSION_PROJECTILE_UNOWNED = "plots.projectile.unowned",
|
||||
PERMISSION_PROJECTILE_OTHER = "plots.projectile.other",
|
||||
PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS = "plots.admin.interact.blockedcommands",
|
||||
PERMISSION_WORLDEDIT_BYPASS = "plots.worldedit.bypass",
|
||||
PERMISSION_ADMIN_EXIT_DENIED = "plots.admin.exit.denied",
|
||||
PERMISSION_ADMIN_ENTRY_DENIED = "plots.admin.entry.denied",
|
||||
PERMISSION_COMMANDS_CHAT = "plots.admin.command.chat",
|
||||
PERMISSION_ADMIN_DESTROY_UNOWNED = "plots.admin.destroy.unowned",
|
||||
PERMISSION_ADMIN_DESTROY_OTHER = "plots.admin.destroy.other",
|
||||
PERMISSION_ADMIN_DESTROY_ROAD = "plots.admin.destroy.road",
|
||||
PERMISSION_ADMIN_BUILD_ROAD = "plots.admin.build.road",
|
||||
PERMISSION_ADMIN_BUILD_UNOWNED = "plots.admin.build.unowned",
|
||||
PERMISSION_ADMIN_BUILD_OTHER = "plots.admin.build.other",
|
||||
PERMISSION_ADMIN_INTERACT_ROAD = "plots.admin.interact.road",
|
||||
PERMISSION_ADMIN_INTERACT_UNOWNED = "plots.admin.interact.unowned",
|
||||
PERMISSION_ADMIN_INTERACT_OTHER = "plots.admin.interact.other",
|
||||
PERMISSION_ADMIN_BUILD_HEIGHTLIMIT = "plots.admin.build.heightlimit";
|
||||
|
||||
public static final String
|
||||
FLAG_USE = "use",
|
||||
FLAG_PLACE = "place",
|
||||
FLAG_PVP = "pvp",
|
||||
FLAG_HANGING_PLACE = "hanging-place",
|
||||
FLAG_HANGING_BREAK = "hanging-break",
|
||||
FLAG_HOSTILE_INTERACT = "hostile-interact",
|
||||
FLAG_ANIMAL_INTERACT = "animal-interact",
|
||||
FLAG_VEHICLE_USE = "vehicle-use",
|
||||
FLAG_TAMED_INTERACT = "tamed-interact",
|
||||
FLAG_DISABLE_PHYSICS = "disable-physics";
|
||||
|
||||
public static final String
|
||||
META_INVENTORY = "inventory";
|
||||
|
||||
|
||||
public static final String
|
||||
PREFIX_META = "META_",
|
||||
PREFIX_FLAG = "FLAG_",
|
||||
PREFIX_PERMISSION = "PERMISSION_";
|
||||
|
||||
public static Map<String, String> getStrings(final String prefix) {
|
||||
final Field[] fields = StaticStrings.class.getDeclaredFields();
|
||||
Map<String, String> strings = new HashMap<>();
|
||||
for (final Field field : fields) {
|
||||
if (field.getGenericType() != String.class) {
|
||||
continue;
|
||||
}
|
||||
if (field.getName().startsWith(prefix)) {
|
||||
field.setAccessible(true);
|
||||
try {
|
||||
String value = field.get(StaticStrings.class).toString();
|
||||
strings.put(field.getName(), value);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user