Fix PR stuff
Dieser Commit ist enthalten in:
Ursprung
28b3733b83
Commit
ae6d5ee671
@ -31,9 +31,10 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
public class CommandTNT implements CommandExecutor {
|
||||
public class CommandTNT implements CommandExecutor, Listener {
|
||||
|
||||
private static TNTMode tntMode = TNTMode.OFF;
|
||||
|
||||
@ -58,6 +59,10 @@ public class CommandTNT implements CommandExecutor {
|
||||
|
||||
}
|
||||
|
||||
public CommandTNT() {
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
}
|
||||
|
||||
private String getNoPermMessage() {
|
||||
return "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren";
|
||||
}
|
||||
@ -71,11 +76,11 @@ public class CommandTNT implements CommandExecutor {
|
||||
}
|
||||
|
||||
private String getTestblockEnableMessage() {
|
||||
return "§aTNT-Schaden beim Testblock aktiviert";
|
||||
return "§aTNT-Schaden am Testblock aktiviert";
|
||||
}
|
||||
|
||||
private String getDamageMessage() {
|
||||
return "§cEs ist etwas explodiert und hätte blöcke zerstört";
|
||||
return "§cEine Explosion hätte Blöcke im Baubereich zerstört";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,22 +115,25 @@ public class CommandTNT implements CommandExecutor {
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent event) {
|
||||
if (tntMode == TNTMode.ON) return;
|
||||
if (tntMode == TNTMode.OFF) {
|
||||
event.blockList().clear();
|
||||
} else {
|
||||
boolean blocksDestroyed = event.blockList().removeIf(block -> {
|
||||
for (Region region : Region.getRegions()) {
|
||||
if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) {
|
||||
return true;
|
||||
switch (tntMode) {
|
||||
case ON:
|
||||
break;
|
||||
case OFF:
|
||||
event.blockList().clear();
|
||||
break;
|
||||
case ONLY_TB:
|
||||
boolean blocksDestroyed = event.blockList().removeIf(block -> {
|
||||
for (Region region : Region.getRegions()) {
|
||||
if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (blocksDestroyed) {
|
||||
sendToActionBar(getDamageMessage());
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (!blocksDestroyed) {
|
||||
return;
|
||||
}
|
||||
sendToActionBar(getDamageMessage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren