Skip to content

Commit

Permalink
add: remove sign from config if directly destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal committed Jun 15, 2019
1 parent 6055472 commit b17ad3d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'de.paskl.chestcounter'
version '1.2-SNAPSHOT'
version '1.3-SNAPSHOT'

sourceCompatibility = 1.8

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/de/paskl/chestcounter/ChestListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.DoubleChestInventory;
import org.bukkit.inventory.Inventory;
Expand Down Expand Up @@ -53,6 +54,23 @@ public void updateSign(PlayerInteractEvent ev, Block block, Sign sign) {
}
}

@EventHandler
public void onBreak(BlockBreakEvent e) {
if (e.getBlock().getType().toString().endsWith("_WALL_SIGN")) {
//Directly hit wall sign
Sign s = (Sign) e.getBlock().getState();
if (s.getLine(0).equals(COUNTER_LINE)) {
this.plugin.reloadConfig();
String keyVal = s.getLocation().getBlockX() + ";" + s.getLocation().getBlockY() + ";" + s.getLocation().getBlockZ();
String signType = (s.getType() == COUNT_CHILDREN_SIGN_MATERIAL ? "mainsigns" : "wallsigns") + ".";
this.plugin.getConfig().set(signType + keyVal, null);
this.plugin.saveConfig();
}
} else {
//TODO check if wall-sign was (is?) attached to this block and follows rules
}
}

public void updateMainSign(Block block, Sign sign) {
WallSign data = (WallSign) sign.getBlockData();
List<Block> nextblocksY = getBlocks(block, BLOCK_LOOKUP_DOWN);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ChestCounter
main: de.paskl.chestcounter.ChestCounter
version: 1.2
version: 1.3
api-version: 1.14
commands:
signupdater:
Expand Down

0 comments on commit b17ad3d

Please sign in to comment.