本文整理汇总了Java中com.intellectualcrafters.plot.object.RunnableVal类的典型用法代码示例。如果您正苦于以下问题:Java RunnableVal类的具体用法?Java RunnableVal怎么用?Java RunnableVal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RunnableVal类属于com.intellectualcrafters.plot.object包,在下文中一共展示了RunnableVal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCompoundTag
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
@Override
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
Location[] corners = MainUtil.getCorners(world, regions);
Location pos1 = corners[0];
Location pos2 = corners[1];
final CuboidRegion region = new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ()));
final EditSession editSession = new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
final int mx = pos1.getX();
final int my = pos1.getY();
final int mz = pos1.getZ();
ReadOnlyClipboard clipboard = ReadOnlyClipboard.of(editSession, region);
Clipboard holder = new BlockArrayClipboard(region, clipboard);
com.sk89q.jnbt.CompoundTag weTag = SchematicWriter.writeTag(holder);
CompoundTag tag = new CompoundTag((Map<String, Tag>) (Map<?, ?>) weTag.getValue());
whenDone.run(tag);
}
});
}
示例2: upload
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
@Override
public void upload(final CompoundTag tag, final UUID uuid, final String file, final RunnableVal<URL> whenDone) {
if (tag == null) {
PS.debug("&cCannot save empty tag");
com.intellectualcrafters.plot.util.TaskManager.runTask(whenDone);
return;
}
MainUtil.upload(uuid, file, "schematic", new RunnableVal<OutputStream>() {
@Override
public void run(OutputStream output) {
try {
try (PGZIPOutputStream gzip = new PGZIPOutputStream(output)) {
com.sk89q.jnbt.CompoundTag weTag = (com.sk89q.jnbt.CompoundTag) FaweCache.asTag(tag);
try (NBTOutputStream nos = new NBTOutputStream(gzip)) {
Map<String, com.sk89q.jnbt.Tag> map = weTag.getValue();
nos.writeNamedTag("Schematic", map.containsKey("Schematic") ? map.get("Schematic") : weTag);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}, whenDone);
}
示例3: getComments
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
@Override
public boolean getComments(final Plot plot, final RunnableVal whenDone) {
if (plot == null || plot.owner == null) {
return false;
}
ArrayList<PlotComment> comments = plot.settings.getComments(toString());
if (comments != null) {
whenDone.value = comments;
TaskManager.runTask(whenDone);
return true;
}
DBFunc.getComments(plot.world, plot, toString(), new RunnableVal() {
@Override
public void run() {
whenDone.value = value;
if (value != null) {
for (PlotComment comment : (ArrayList<PlotComment>) value) {
plot.settings.addComment(comment);
}
}
TaskManager.runTask(whenDone);
}
});
return true;
}
示例4: execute
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
@Override
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
C.NOT_IN_PLOT.send(player);
return;
}
HashSet<RegionWrapper> regions = plot.getRegions();
final LocalBlockQueue queue = plot.getArea().getQueue(false);
ChunkManager.chunkTask(plot, new RunnableVal<int[]>() {
@Override
public void run(int[] value) {
queue.fixChunkLighting(value[0], value[1]);
}
}, new Runnable() {
@Override
public void run() {
plot.refreshChunks();
C.SET_BLOCK_ACTION_FINISHED.send(player);
}
}, 5);
}
示例5: autoClaimSafe
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
/**
* Claim a new plot for a player
* @param player
* @param area
* @param start
* @param schem
*/
public static void autoClaimSafe(final PlotPlayer player, final PlotArea area, PlotId start, final String schem) {
autoClaimFromDatabase(player, area, start, new RunnableVal<Plot>() {
@Override
public void run(final Plot plot) {
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object ignore) {
if (plot == null) {
MainUtil.sendMessage(player, C.NO_FREE_PLOTS);
} else {
plot.claim(player, true, schem, false);
if (area.AUTO_MERGE) {
plot.autoMerge(-1, Integer.MAX_VALUE, player.getUUID(), true);
}
}
}
});
}
});
}
示例6: startUuidCatching
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
private void startUuidCatching() {
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
debug("Starting UUID caching");
UUIDHandler.startCaching(new Runnable() {
@Override
public void run() {
UUIDHandler.add(new StringWrapper("*"), DBFunc.everyone);
foreachPlotRaw(new RunnableVal<Plot>() {
@Override
public void run(Plot plot) {
if (plot.hasOwner() && plot.temp != -1) {
if (UUIDHandler.getName(plot.owner) == null) {
UUIDHandler.implementation.unknown.add(plot.owner);
}
}
}
});
startExpiryTasks();
startPlotMeConversion();
}
});
}
}, 20);
}
示例7: getBasePlots
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
/**
* Get all the base plots in a single set (for merged plots it just returns
* the bottom plot).
* @return Set of base Plots
*/
public Set<Plot> getBasePlots() {
int size = getPlotCount();
final Set<Plot> result = new HashSet<>(size);
foreachPlotArea(new RunnableVal<PlotArea>() {
@Override
public void run(PlotArea value) {
for (Plot plot : value.getPlots()) {
if (!plot.isBasePlot()) {
continue;
}
result.add(plot);
}
}
});
return result;
}
示例8: disable
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
/**
* Close the database connection.
*/
public void disable() {
try {
// Validate that all data in the db is correct
final HashSet<Plot> plots = new HashSet<>();
foreachPlotRaw(new RunnableVal<Plot>() {
@Override
public void run(Plot value) {
plots.add(value);
}
});
DBFunc.validatePlots(plots);
// Close the connection
DBFunc.close();
UUIDHandler.handleShutdown();
} catch (NullPointerException ignored) {
ignored.printStackTrace();
PS.log("&cCould not close database connection!");
}
}
示例9: objectTask
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
/**
* Break up a series of tasks so that they can run without lagging the server.
* @param objects
* @param task
* @param whenDone
*/
public static <T> void objectTask(Collection<T> objects, final RunnableVal<T> task, final Runnable whenDone) {
final Iterator<T> iterator = objects.iterator();
TaskManager.runTask(new Runnable() {
@Override
public void run() {
long start = System.currentTimeMillis();
boolean hasNext;
while ((hasNext = iterator.hasNext()) && System.currentTimeMillis() - start < 5) {
task.value = iterator.next();
task.run();
}
if (!hasNext) {
TaskManager.runTaskLater(whenDone, 1);
} else {
TaskManager.runTaskLater(this, 1);
}
}
});
}
示例10: setChunkInPlotArea
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
public static void setChunkInPlotArea(RunnableVal<ScopedLocalBlockQueue> force, RunnableVal<ScopedLocalBlockQueue> add, String world, ChunkLoc loc) {
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
if (PS.get().isAugmented(world)) {
int bx = loc.x << 4;
int bz = loc.z << 4;
ScopedLocalBlockQueue scoped = new ScopedLocalBlockQueue(queue, new Location(world, bx, 0, bz), new Location(world, bx + 15, 255, bz + 15));
if (force != null) {
force.run(scoped);
} else {
scoped.regenChunk(loc.x, loc.z);
if (add != null) {
add.run(scoped);
}
}
queue.flush();
} else {
CURRENT_FORCE_CHUNK = force;
CURRENT_ADD_CHUNK = add;
queue.regenChunk(loc.x, loc.z);
CURRENT_FORCE_CHUNK = null;
CURRENT_ADD_CHUNK = null;
}
}
示例11: chunkTask
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
public static void chunkTask(final Plot plot, final RunnableVal<int[]> task, final Runnable whenDone, final int allocate) {
final ArrayList<RegionWrapper> regions = new ArrayList<>(plot.getRegions());
Runnable smallTask = new Runnable() {
@Override
public void run() {
if (regions.isEmpty()) {
TaskManager.runTask(whenDone);
return;
}
RegionWrapper value = regions.remove(0);
Location pos1 = new Location(plot.getWorldName(), value.minX, 0, value.minZ);
Location pos2 = new Location(plot.getWorldName(), value.maxX, 0, value.maxZ);
chunkTask(pos1, pos2, task, this, allocate);
}
};
smallTask.run();
}
示例12: upload
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
public void upload(final CompoundTag tag, UUID uuid, String file, RunnableVal<URL> whenDone) {
if (tag == null) {
PS.debug("&cCannot save empty tag");
TaskManager.runTask(whenDone);
return;
}
MainUtil.upload(uuid, file, "schematic", new RunnableVal<OutputStream>() {
@Override
public void run(OutputStream output) {
try {
try (GZIPOutputStream gzip = new GZIPOutputStream(output, true)) {
try (NBTOutputStream nos = new NBTOutputStream(gzip)) {
nos.writeTag(tag);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}, whenDone);
}
示例13: getCompoundTag
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
public void getCompoundTag(final Plot plot, final RunnableVal<CompoundTag> whenDone) {
getCompoundTag(plot.getWorldName(), plot.getRegions(), new RunnableVal<CompoundTag>() {
@Override
public void run(CompoundTag value) {
if (!plot.getFlags().isEmpty()) {
HashMap<String, Tag> flagMap = new HashMap<>();
for (Map.Entry<Flag<?>, Object> entry : plot.getFlags().entrySet()) {
String key = entry.getKey().getName();
flagMap.put(key, new StringTag(key, entry.getKey().valueToString(entry.getValue())));
}
CompoundTag tag = new CompoundTag("Flags", flagMap);
HashMap<String, Tag> map = new HashMap<>(value.getValue());
map.put("Flags", tag);
value.setValue(map);
}
whenDone.run(value);
}
});
}
示例14: sendTitle
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
public static void sendTitle(final PlotPlayer player, final Plot plot) {
if (!Settings.COMMENT_NOTIFICATIONS) {
return;
}
if (!plot.isOwner(player.getUUID())) {
return;
}
TaskManager.runTaskLaterAsync(new Runnable() {
@Override
public void run() {
Collection<CommentInbox> boxes = CommentManager.inboxes.values();
final AtomicInteger count = new AtomicInteger(0);
final AtomicInteger size = new AtomicInteger(boxes.size());
for (final CommentInbox inbox : inboxes.values()) {
inbox.getComments(plot, new RunnableVal() {
@Override
public void run() {
int total;
if (value != null) {
int num = 0;
for (PlotComment comment : (ArrayList<PlotComment>) value) {
if (comment.timestamp > getTimestamp(player, inbox.toString())) {
num++;
}
}
total = count.addAndGet(num);
}
else {
total = count.get();
}
if (size.decrementAndGet() == 0 && total > 0) {
AbstractTitle.sendTitle(player, "", C.INBOX_NOTIFICATION.s().replaceAll("%s", "" + total), ChatColor.GOLD, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()));
}
}
});
}
}
}, 20);
}
示例15: getComments
import com.intellectualcrafters.plot.object.RunnableVal; //导入依赖的package包/类
@Override
public boolean getComments(final Plot plot, final RunnableVal whenDone) {
DBFunc.getComments(null, null, toString(), new RunnableVal() {
@Override
public void run() {
whenDone.value = value;
TaskManager.runTask(whenDone);
}
});
return true;
}