Skip to content

Commit a793e28

Browse files
committed
Fixed ConfigBug && TNT Bug
1 parent 4bb23de commit a793e28

4 files changed

Lines changed: 18 additions & 9 deletions

File tree

src/main/java/de/timecoding/cc/file/ConfigHandler.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ public Integer getInteger(String key) {
7070
public String getString(String key) {
7171
if (keyExists(key)) {
7272
return ChatColor.translateAlternateColorCodes('&', cfg.getString(key));
73-
} else {
74-
cfg.set(key, key);
75-
save();
7673
}
7774
return "";
7875
}

src/main/java/de/timecoding/cc/file/DataHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public String getString(String key) {
7979
if (keyExists(key)) {
8080
return ChatColor.translateAlternateColorCodes('&', cfg.getString(key));
8181
}
82-
return null;
82+
return "";
8383
}
8484

8585
public Boolean getBoolean(String key) {

src/main/java/de/timecoding/cc/listener/CubicListener.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@
99
import de.timecoding.cc.util.type.Cube;
1010
import org.bukkit.Bukkit;
1111
import org.bukkit.Location;
12+
import org.bukkit.block.Block;
1213
import org.bukkit.entity.Player;
1314
import org.bukkit.event.EventHandler;
1415
import org.bukkit.event.Listener;
1516
import org.bukkit.event.block.BlockBreakEvent;
1617
import org.bukkit.event.block.BlockExplodeEvent;
1718
import org.bukkit.event.block.BlockPlaceEvent;
19+
import org.bukkit.event.entity.EntityExplodeEvent;
1820

1921
import java.util.ConcurrentModificationException;
22+
import java.util.concurrent.atomic.AtomicBoolean;
2023
import java.util.concurrent.atomic.AtomicReference;
2124

2225
public class CubicListener implements Listener {
@@ -55,11 +58,16 @@ public void onBlockBreak(BlockBreakEvent event) {
5558
}
5659

5760
@EventHandler
58-
public void onBlockExplode(BlockExplodeEvent event) {
59-
proof(null, event.getBlock().getLocation(), true);
61+
public void onEntityExplode(EntityExplodeEvent event) {
62+
boolean stop = false;
63+
for(Block block : event.blockList()){
64+
if(!stop && proof(null, block.getLocation(), true)){
65+
stop = true;
66+
}
67+
}
6068
}
6169

62-
public CubicListener proof(Player player, Location origin, boolean breakBlock) {
70+
public boolean proof(Player player, Location origin, boolean breakBlock) {
6371
DataHandler dataHandler = plugin.getDataHandler();
6472
AtomicReference<Cube> atomicCube = new AtomicReference<>();
6573
plugin.getCubes().forEach(searchedCube -> {
@@ -78,21 +86,25 @@ public CubicListener proof(Player player, Location origin, boolean breakBlock) {
7886
Bukkit.getPluginManager().callEvent(event);
7987
if (!event.isCancelled()) {
8088
countdownModule.start();
89+
return true;
8190
}
8291
} else if (atomicCube.get() != null && breakBlock) {
92+
AtomicBoolean r = new AtomicBoolean(false);
8393
try {
8494
plugin.getCountdownList().forEach(countdownModule -> {
8595
if (countdownModule.getCubicSettings().getCube() != null && countdownModule.getCubicSettings().getCube().isSimilar(atomicCube.get())) {
8696
CubeUnFilledEvent event = new CubeUnFilledEvent(player, countdownModule);
8797
Bukkit.getPluginManager().callEvent(event);
8898
if (!event.isCancelled()) {
8999
countdownModule.cancel();
100+
r.set(true);
90101
}
91102
}
92103
});
93104
//TODO
94105
}catch(ConcurrentModificationException exception){}
106+
return r.get();
95107
}
96-
return this;
108+
return false;
97109
}
98110
}

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: CubicCountdown
2-
version: 1.0.0-BETA
2+
version: 1.0.1-BETA
33
main: de.timecoding.cc.CubicCountdown
44
api-version: 1.13
55
description: "A plugin which is able to start a countdown when a cube is full of blocks"

0 commit comments

Comments
 (0)