use of com.sk89q.worldedit.extent.AbstractDelegateExtent in project FastAsyncWorldEdit by IntellectualSites.
the class WEManager method cancelEditSafe.
public void cancelEditSafe(AbstractDelegateExtent parent, FaweException reason) throws FaweException {
LOGGER.warn("CancelEditSafe was hit. Please ignore this message.");
Extent currentExtent = parent.getExtent();
if (!(currentExtent instanceof NullExtent)) {
parent.extent = new NullExtent(parent.extent, reason);
}
throw reason;
}
use of com.sk89q.worldedit.extent.AbstractDelegateExtent in project ChuoCity by jaoafa.
the class Event_WGNonProtection method onWEEdit.
@Subscribe
public void onWEEdit(EditSessionEvent event) {
if (Main.getWorldGuard() == null) {
return;
}
if (event.getStage() == EditSession.Stage.BEFORE_REORDER) {
return;
}
Actor actor = event.getActor();
if (actor == null || !actor.isPlayer()) {
return;
}
Player player = Bukkit.getPlayer(actor.getUniqueId());
if (player == null) {
return;
}
if (player.hasPermission("worldguard.region.bypass")) {
return;
}
event.setExtent(new AbstractDelegateExtent(event.getExtent()) {
private boolean canBuild(int x, int y, int z) {
LocalPlayer localPlayer = Main.getWorldGuard().wrapPlayer(player);
if (Main.isChuoCity(new Location(player.getWorld(), x, y, z))) {
return true;
}
if (!player.getWorld().getName().equalsIgnoreCase("Jao_Afa")) {
// Jao_Afa以外では適用しない
return true;
}
ProtectedRegion region = Main.getTopRegion(new Location(player.getWorld(), x, y, z));
if (region == null) {
// 誰も保護していない
return false;
}
if (region.isOwner(localPlayer)) {
// オーナー
return true;
}
// メンバー
return region.isMember(localPlayer);
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
return canBuild(location.getBlockX(), location.getBlockY(), location.getBlockZ()) && super.setBlock(location, block);
}
});
}
use of com.sk89q.worldedit.extent.AbstractDelegateExtent in project FastAsyncWorldEdit by IntellectualSites.
the class ExtentTraverser method next.
@SuppressWarnings("unchecked")
public ExtentTraverser<T> next() {
try {
if (root instanceof AbstractDelegateExtent) {
AbstractDelegateExtent root = (AbstractDelegateExtent) this.root;
T value = (T) root.getExtent();
if (value == null) {
return null;
}
return new ExtentTraverser<>(value, this);
}
return null;
} catch (Throwable e) {
e.printStackTrace();
return null;
}
}
use of com.sk89q.worldedit.extent.AbstractDelegateExtent in project buildinggame by stefvanschie.
the class WorldEditBoundaryAssertion method onEditSession.
/**
* Cancels any edits being made for blocks outside the plot the actor is (possibly) on.
*
* @param event the event fired when a session is being edited
* @since 5.8.0
*/
@Subscribe
public void onEditSession(EditSessionEvent event) {
if (event.getActor() == null || !event.getActor().isPlayer())
return;
var player = Bukkit.getPlayer(event.getActor().getUniqueId());
var arena = ArenaManager.getInstance().getArena(player);
// don't do anything if the player isn't in an arena
if (arena == null)
return;
event.setExtent(new AbstractDelegateExtent(event.getExtent()) {
@Override
public boolean setBlock(BlockVector3 vector, BlockStateHolder block) throws WorldEditException {
var world = Bukkit.getWorld(event.getWorld().getName());
var loc = new Location(world, vector.getX(), vector.getY(), vector.getZ());
if (!arena.getPlot(player).getBoundary().isInside(loc)) {
return false;
}
return super.setBlock(vector, block);
}
});
}
Aggregations