Skip to content

Commit b17ad3d

Browse files
author
Pascal
committed
add: remove sign from config if directly destroyed
1 parent 6055472 commit b17ad3d

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
group 'de.paskl.chestcounter'
6-
version '1.2-SNAPSHOT'
6+
version '1.3-SNAPSHOT'
77

88
sourceCompatibility = 1.8
99

src/main/java/de/paskl/chestcounter/ChestListener.java

+18
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.bukkit.event.EventHandler;
99
import org.bukkit.event.Listener;
1010
import org.bukkit.event.block.Action;
11+
import org.bukkit.event.block.BlockBreakEvent;
1112
import org.bukkit.event.player.PlayerInteractEvent;
1213
import org.bukkit.inventory.DoubleChestInventory;
1314
import org.bukkit.inventory.Inventory;
@@ -53,6 +54,23 @@ public void updateSign(PlayerInteractEvent ev, Block block, Sign sign) {
5354
}
5455
}
5556

57+
@EventHandler
58+
public void onBreak(BlockBreakEvent e) {
59+
if (e.getBlock().getType().toString().endsWith("_WALL_SIGN")) {
60+
//Directly hit wall sign
61+
Sign s = (Sign) e.getBlock().getState();
62+
if (s.getLine(0).equals(COUNTER_LINE)) {
63+
this.plugin.reloadConfig();
64+
String keyVal = s.getLocation().getBlockX() + ";" + s.getLocation().getBlockY() + ";" + s.getLocation().getBlockZ();
65+
String signType = (s.getType() == COUNT_CHILDREN_SIGN_MATERIAL ? "mainsigns" : "wallsigns") + ".";
66+
this.plugin.getConfig().set(signType + keyVal, null);
67+
this.plugin.saveConfig();
68+
}
69+
} else {
70+
//TODO check if wall-sign was (is?) attached to this block and follows rules
71+
}
72+
}
73+
5674
public void updateMainSign(Block block, Sign sign) {
5775
WallSign data = (WallSign) sign.getBlockData();
5876
List<Block> nextblocksY = getBlocks(block, BLOCK_LOOKUP_DOWN);

src/main/resources/plugin.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: ChestCounter
22
main: de.paskl.chestcounter.ChestCounter
3-
version: 1.2
3+
version: 1.3
44
api-version: 1.14
55
commands:
66
signupdater:

0 commit comments

Comments
 (0)