/b demolish blocks abuse & barrack abuse! Works all versions (not my mistake, i've fixed it long time ago)
Closed this issue · 1 comments
/b demolish:
So, let's debug our BreakEvents and PlaceEvents.
we got this
Ye, we got right ids, but when we saving undo file we can catch a bug.
here
We must build this construction
Let's see what we got, if we will build CoreEmpire Monument
Then build it!
After complete type /b demolishnearest yes (demolish monument)
Blocks, which are was before sugar_cane (or redstone) will be not replaced!
I know, u will say: It's not my version, but try it on your server, working elsewhere, i've fixed it ~6months ago, but im tried say it for you, you rejected PR.
We must demolish all blocks, before undo from template
// Town.java
public void demolish(Structure struct, boolean isAdmin) throws CivException {
if (!struct.allowDemolish() && !isAdmin)
throw new CivException(CivSettings.localize.localizedString("town_demolish_Cannot"));
try {
struct.onDemolish();
this.removeStructure(struct);
struct.onDestroyFancy();
struct.deleteSkipUndo();
} catch (SQLException e) {
e.printStackTrace();
throw new CivException(
CivSettings.localize.localizedString("internalDatabaseException"));
}
}
// Structure.java
public void onDestroyFancy() {
this.hitpoints = 0;
this.fancyDestroyStructure();
this.save();
}
public void fancyDestroyStructure() {
class DemolishStructureBlocks extends BukkitRunnable {
public Buildable buildable;
public DemolishStructureBlocks(Buildable buildable) {
this.buildable = buildable;
}
@Override
public void run() {
for (StructureChest structureChests : buildable.structureChests.values())
CivGlobal.removeStructureChest(structureChests);
for (BlockCoord blockCoord : buildable.getStructureBlocks().keySet())
CivGlobal.removeStructureBlock(blockCoord);
for (StructureSign structureSign : buildable.structureSigns.values())
CivGlobal.removeStructureSign(structureSign);
for (BlockCoord coord : structureBlocks.keySet()) {
if (ItemManager.getId(coord.getBlock()) != CivData.AIR) {
ItemManager.setTypeId(coord.getBlock(), CivData.AIR);
ItemManager.setData(coord.getBlock(), 0, true);
}
}
}
}
DemolishStructureBlocks syncTask = new DemolishStructureBlocks(this);
syncTask.runTask(CivCraft.getPlugin());
}
Barracks:
After demolish barracks and rebuild price for settler going to 25000. Bug here: we checking for structure with old id, but when we demolish and build new id new =)
We must save settler cost to Civilization object or write sessionkey for civ, instead structure id (i've fixed, by saving to civ)
"Blocks, which are was before sugar_cane (or redstone) will be not replaced!"
That's correct. Because often times those blocks will break, and leave the items on the ground. allowing players to effective dupe them with roads and camps very easily. You already have #134 open for the Barracks.