mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00:00
Added a permission node to set NBT data, allowing servers to disallow NBT interactions.
This commit is contained in:
parent
59447c6ee3
commit
38607f387a
@ -232,6 +232,9 @@ public class LocalSession {
|
|||||||
newEditSession.enableStandardMode();
|
newEditSession.enableStandardMode();
|
||||||
newEditSession.setReorderMode(reorderMode);
|
newEditSession.setReorderMode(reorderMode);
|
||||||
newEditSession.setFastMode(fastMode);
|
newEditSession.setFastMode(fastMode);
|
||||||
|
if (newEditSession.getSurvivalExtent() != null) {
|
||||||
|
newEditSession.getSurvivalExtent().setStripNbt(!player.hasPermission("worldedit.setnbt"));
|
||||||
|
}
|
||||||
editSession.undo(newEditSession);
|
editSession.undo(newEditSession);
|
||||||
}
|
}
|
||||||
return editSession;
|
return editSession;
|
||||||
@ -257,6 +260,9 @@ public class LocalSession {
|
|||||||
newEditSession.enableStandardMode();
|
newEditSession.enableStandardMode();
|
||||||
newEditSession.setReorderMode(reorderMode);
|
newEditSession.setReorderMode(reorderMode);
|
||||||
newEditSession.setFastMode(fastMode);
|
newEditSession.setFastMode(fastMode);
|
||||||
|
if (newEditSession.getSurvivalExtent() != null) {
|
||||||
|
newEditSession.getSurvivalExtent().setStripNbt(!player.hasPermission("worldedit.setnbt"));
|
||||||
|
}
|
||||||
editSession.redo(newEditSession);
|
editSession.redo(newEditSession);
|
||||||
}
|
}
|
||||||
++historyPointer;
|
++historyPointer;
|
||||||
@ -887,6 +893,9 @@ public class LocalSession {
|
|||||||
editSession.setFastMode(fastMode);
|
editSession.setFastMode(fastMode);
|
||||||
editSession.setReorderMode(reorderMode);
|
editSession.setReorderMode(reorderMode);
|
||||||
editSession.setMask(mask);
|
editSession.setMask(mask);
|
||||||
|
if (editSession.getSurvivalExtent() != null) {
|
||||||
|
editSession.getSurvivalExtent().setStripNbt(!player.hasPermission("worldedit.setnbt"));
|
||||||
|
}
|
||||||
|
|
||||||
return editSession;
|
return editSession;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ public class SurvivalModeExtent extends AbstractDelegateExtent {
|
|||||||
|
|
||||||
private final World world;
|
private final World world;
|
||||||
private boolean toolUse = false;
|
private boolean toolUse = false;
|
||||||
|
private boolean stripNbt = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
@ -78,14 +79,27 @@ public class SurvivalModeExtent extends AbstractDelegateExtent {
|
|||||||
this.toolUse = toolUse;
|
this.toolUse = toolUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasStripNbt() {
|
||||||
|
return stripNbt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStripNbt(boolean stripNbt) {
|
||||||
|
this.stripNbt = stripNbt;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||||
if (toolUse && block.getBlockType().getMaterial().isAir()) {
|
if (toolUse && block.getBlockType().getMaterial().isAir()) {
|
||||||
world.simulateBlockMine(location);
|
world.simulateBlockMine(location);
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
// Can't be an inlined check due to inconsistent generic return type
|
||||||
|
if (stripNbt) {
|
||||||
|
return super.setBlock(location, block.toBaseBlock(null));
|
||||||
} else {
|
} else {
|
||||||
return super.setBlock(location, block);
|
return super.setBlock(location, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user