本文整理汇总了Java中com.intellectualcrafters.plot.database.DBFunc类的典型用法代码示例。如果您正苦于以下问题:Java DBFunc类的具体用法?Java DBFunc怎么用?Java DBFunc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DBFunc类属于com.intellectualcrafters.plot.database包,在下文中一共展示了DBFunc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的package包/类
@Override
public boolean execute(final PlotPlayer plr, final String... args) {
if (plr == null) {
try {
final Field fPlots = PlotSquared.class.getDeclaredField("plots");
fPlots.setAccessible(true);
fPlots.set(null, DBFunc.getPlots());
} catch (final Exception e) {
PlotSquared.log("&3==== 请无视下方报错代码 &3====");
e.printStackTrace();
PlotSquared.log("&3==== 请无视上方报错代码 &3====");
}
} else {
MainUtil.sendMessage(plr, "&6这个指令只能通过控制台使用.");
}
return true;
}
示例2: execute
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的package包/类
@Override
public boolean execute(final PlotPlayer plr, final String... args) {
if (plr == null) {
final ArrayList<Plot> plots = new ArrayList<Plot>();
plots.addAll(PlotSquared.getPlots());
MainUtil.sendMessage(null, "&6正在开始 `DEBUGSAVETEST`");
DBFunc.createPlotsAndData(plots, new Runnable() {
@Override
public void run() {
MainUtil.sendMessage(null, "&6数据库同步完成!");
}
});
} else {
MainUtil.sendMessage(plr, "这个指令只能通过控制台使用.");
}
return true;
}
示例3: isAdded
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的package包/类
public static boolean isAdded(Plot plot, final UUID uuid) {
if (plot.owner == null) {
return false;
}
if (isOwner(plot, uuid)) {
return true;
}
if (plot.denied.contains(uuid)) {
return false;
}
if (plot.trusted.contains(uuid) || plot.trusted.contains(DBFunc.everyone)) {
return true;
}
if (plot.members.contains(uuid) || plot.members.contains(DBFunc.everyone)) {
if (PlotHandler.isOnline(plot)) {
return true;
}
}
return PlotHandler.isOwner(plot, uuid);
}
示例4: getComments
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的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;
}
示例5: swap
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的package包/类
public static boolean swap(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
Plot p1 = PlotSquared.getPlots(world).get(current);
Plot p2 = PlotSquared.getPlots(world).get(newPlot);
if (p1==null || p2 == null || p1.owner == null || !p1.owner.equals(p2.owner)) {
return false;
}
// Swap blocks
ChunkManager.manager.swap(world, current, newPlot);
// Swap cached
PlotId temp = new PlotId(p1.id.x.intValue(), p1.id.y.intValue());
p1.id.x = p2.id.x.intValue();
p1.id.y = p2.id.y.intValue();
p2.id.x = temp.x;
p2.id.y = temp.y;
PlotSquared.getPlots(world).remove(p1.id);
PlotSquared.getPlots(world).remove(p2.id);
p1.id.recalculateHash();
p2.id.recalculateHash();
PlotSquared.getPlots(world).put(p1.id, p1);
PlotSquared.getPlots(world).put(p2.id, p2);
// Swap database
DBFunc.dbManager.swapPlots(p2, p1);
return true;
}
示例6: onLeave
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的package包/类
@EventHandler(priority= EventPriority.MONITOR)
public void onLeave(final PlayerQuitEvent event) {
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
ExpireManager.dates.put(pp.getUUID(), System.currentTimeMillis());
EventUtil.unregisterPlayer(pp);
if (PlotSquared.worldEdit != null) {
WEManager.bypass.remove(pp.getName());
}
if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) {
final Collection<Plot> plots = PlotSquared.getPlots(pp.getName()).values();
for (final Plot plot : plots) {
final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
final PlotManager manager = PlotSquared.getPlotManager(plot.world);
manager.clearPlot(plotworld, plot, true, null);
DBFunc.delete(plot.world, plot);
PlotSquared.log(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
}
}
BukkitUtil.removePlayer(pp.getName());
}
示例7: onCommand
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的package包/类
@Override
public boolean onCommand(PlotPlayer player, String[] args) {
PlotArea area = PS.get().getPlotAreaByString(args[0]);
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) {
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD, args[0]);
return false;
}
MainUtil.sendMessage(player, "&8--- &6Starting task &8 ---");
for (Plot plot : area.getPlots()) {
HashMap<Flag<?>, Object> flags = plot.getFlags();
Iterator<Entry<Flag<?>, Object>> i = flags.entrySet().iterator();
boolean changed = false;
while (i.hasNext()) {
if (i.next().getKey() == null) {
changed = true;
i.remove();
}
}
if (changed) {
DBFunc.setFlags(plot, plot.getFlags());
}
}
MainUtil.sendMessage(player, "&aDone!");
return true;
}
示例8: startUuidCatching
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的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);
}
示例9: disable
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的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!");
}
}
示例10: removePlotFlag
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的package包/类
/**
* Removes a flag from a certain plot.
* @param origin the plot to remove the flag from
* @param id the flag to remove
* @return true if the plot contained the flag and was removed successfully
*/
public static boolean removePlotFlag(Plot origin, Flag<?> id) {
for (Plot plot : origin.getConnectedPlots()) {
Object value = plot.getFlags().remove(id);
if (value == null) {
return false;
}
if (plot == origin) {
boolean result = EventUtil.manager.callFlagRemove(id, plot, value);
if (!result) {
plot.getFlags().put(id, value);
return false;
}
}
plot.reEnter();
DBFunc.setFlags(plot, plot.getFlags());
}
return true;
}
示例11: setPlotFlags
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的package包/类
public static void setPlotFlags(Plot origin, HashMap<Flag<?>, Object> flags) {
for (Plot plot : origin.getConnectedPlots()) {
if (flags != null && !flags.isEmpty()) {
plot.getFlags().clear();
for (Map.Entry<Flag<?>, Object> flag : flags.entrySet()) {
plot.getFlags().put(flag.getKey(), flag.getValue());
}
} else if (plot.getFlags().isEmpty()) {
return;
} else {
plot.getFlags().clear();
}
plot.reEnter();
DBFunc.setFlags(plot, plot.getFlags());
}
}
示例12: isAdded
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的package包/类
/**
* Check if the player is either the owner or on the trusted/added list.
*
* @param uuid
*
* @return true if the player is added/trusted or is the owner
*/
public boolean isAdded(UUID uuid) {
if (this.owner == null || getDenied().contains(uuid)) {
return false;
}
if (isOwner(uuid)) {
return true;
}
if (getMembers().contains(uuid)) {
return isOnline();
}
if (getTrusted().contains(uuid) || getTrusted().contains(DBFunc.everyone)) {
return true;
}
if (getMembers().contains(DBFunc.everyone)) {
return isOnline();
}
return false;
}
示例13: setOwner
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的package包/类
/**
* Set the plot owner (and update the database)
* @param owner
*/
public void setOwner(UUID owner) {
if (!hasOwner()) {
this.owner = owner;
create();
return;
}
if (!isMerged()) {
if (!this.owner.equals(owner)) {
this.owner = owner;
DBFunc.setOwner(this, owner);
}
return;
}
for (Plot current : getConnectedPlots()) {
if (!owner.equals(current.owner)) {
current.owner = owner;
DBFunc.setOwner(current, owner);
}
}
}
示例14: moveData
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的package包/类
/**
* Move the settings for a plot.
* @param plot the plot to move
* @param whenDone
* @return
*/
public boolean moveData(Plot plot, Runnable whenDone) {
if (this.owner == null) {
PS.debug(plot + " is unowned (single)");
TaskManager.runTask(whenDone);
return false;
}
if (plot.hasOwner()) {
PS.debug(plot + " is unowned (multi)");
TaskManager.runTask(whenDone);
return false;
}
this.area.removePlot(this.id);
this.getId().x = plot.getId().x;
this.getId().y = plot.getId().y;
this.getId().recalculateHash();
this.area.addPlotAbs(this);
DBFunc.movePlot(this, plot);
TaskManager.runTaskLater(whenDone, 1);
return true;
}
示例15: setMerged
import com.intellectualcrafters.plot.database.DBFunc; //导入依赖的package包/类
/**
* Set the raw merge data<br>
* - Updates DB<br>
* - Does not modify terrain<br>
* ----------<br>
* 0 = north<br>
* 1 = east<br>
* 2 = south<br>
* 3 = west<br>
* ----------<br>
* @param direction
* @param value
*/
public void setMerged(int direction, boolean value) {
if (this.getSettings().setMerged(direction, value)) {
if (value) {
Plot other = this.getRelative(direction).getBasePlot(false);
if (!other.equals(this.getBasePlot(false))) {
Plot base = other.id.y < this.id.y || other.id.y == this.id.y && other.id.x < this.id.x ? other : this.origin;
this.origin.origin = base;
other.origin = base;
this.origin = base;
connected_cache = null;
}
} else {
if (this.origin != null) {
this.origin.origin = null;
this.origin = null;
}
connected_cache = null;
}
DBFunc.setMerged(this, this.getSettings().getMerged());
regions_cache = null;
}
}