@Override public void delete() throws SQLException { if (this.getTown() != null) { /* Remove any protected item frames. */ for (ItemFrameStorage framestore : goodieFrames) { BonusGoodie goodie = CivGlobal.getBonusGoodie(framestore.getItem()); if (goodie != null) { goodie.replenish(); } CivGlobal.removeProtectedItemFrame(framestore.getFrameID()); } } super.delete(); }
@Override public void onDemolish() throws CivException { /* * If the trade goodie is not in our frame, we should not allow * the trade outpost to be demolished. As it may result in an inconsistent state. */ if (this.frameStore == null) { return; } ItemStack frameItem = this.frameStore.getItem(); if (frameItem != null) { BonusGoodie goodie = CivGlobal.getBonusGoodie(frameItem); if (goodie != null) { if (goodie.getOutpost() == this) { return; } } } throw new CivException("Cannot demolish when bonus goodie is not in item frame."); }