Merge pull request 'Add CommandTNT with extension explode message' (#189) from ExtensionTNT into master
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
02d509a3ab
@ -55,10 +55,6 @@ public class CommandTNT implements CommandExecutor, Listener {
|
|||||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNoPermMessage() {
|
|
||||||
return "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getEnableMessage() {
|
private String getEnableMessage() {
|
||||||
return "§aTNT-Schaden aktiviert";
|
return "§aTNT-Schaden aktiviert";
|
||||||
}
|
}
|
||||||
@ -71,17 +67,13 @@ public class CommandTNT implements CommandExecutor, Listener {
|
|||||||
return "§aTNT-Schaden außerhalb Baurahmen aktiviert";
|
return "§aTNT-Schaden außerhalb Baurahmen aktiviert";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDamageMessage() {
|
|
||||||
return "§cEine Explosion hätte Blöcke im Baubereich zerstört";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||||
if (!(sender instanceof Player)) return false;
|
if (!(sender instanceof Player)) return false;
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (Welt.noPermission(player, Permission.world)) {
|
if (Welt.noPermission(player, Permission.world)) {
|
||||||
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
|
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,13 +135,16 @@ public class CommandTNT implements CommandExecutor, Listener {
|
|||||||
public void onExplode(EntityExplodeEvent event) {
|
public void onExplode(EntityExplodeEvent event) {
|
||||||
event.blockList().removeIf(block -> {
|
event.blockList().removeIf(block -> {
|
||||||
Region region = Region.getRegion(block.getLocation());
|
Region region = Region.getRegion(block.getLocation());
|
||||||
if (region.getTntMode() == TNTMode.OFF) return true;
|
|
||||||
if (region.getTntMode() == TNTMode.ON) return false;
|
if (region.getTntMode() == TNTMode.ON) return false;
|
||||||
if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) {
|
if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) {
|
||||||
RegionToggleCommand.actionBar(region, getDamageMessage());
|
RegionToggleCommand.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
if (region.hasBuildRegion() && region.inBuildRegionExtension(block.getLocation())) {
|
||||||
|
RegionToggleCommand.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return region.getTntMode() == TNTMode.OFF;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +162,10 @@ public class Region {
|
|||||||
return prototype.buildArea.inRegion(this, l);
|
return prototype.buildArea.inRegion(this, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean inBuildRegionExtension(Location l) {
|
||||||
|
return prototype.buildArea.inRegionExtension(this, l);
|
||||||
|
}
|
||||||
|
|
||||||
public void fastreset(){
|
public void fastreset(){
|
||||||
prototype.fastreset(this);
|
prototype.fastreset(this);
|
||||||
}
|
}
|
||||||
@ -212,11 +216,6 @@ public class Region {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean inBuildRegion(Location l) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasTestblock() {
|
public boolean hasTestblock() {
|
||||||
return false;
|
return false;
|
||||||
@ -288,6 +287,12 @@ public class Region {
|
|||||||
inRange(l.getZ(), region.minZ + offsetZ, sizeZ);
|
inRange(l.getZ(), region.minZ + offsetZ, sizeZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean inRegionExtension(Region region, Location l) {
|
||||||
|
return inRange(l.getX(), region.minX + offsetX - extensionAxisX + 1, sizeX + extensionAxisX * 2 - 1) &&
|
||||||
|
inRange(l.getY(), region.minY + offsetY, sizeY + extensionPositiveY - 1) &&
|
||||||
|
inRange(l.getZ(), region.minZ + offsetZ - extensionNegativeZ + 1, sizeZ + extensionNegativeZ - 1 + extensionPositiveZ);
|
||||||
|
}
|
||||||
|
|
||||||
public void fastreset(Region region){
|
public void fastreset(Region region){
|
||||||
File file = new File(schematic);
|
File file = new File(schematic);
|
||||||
int x = region.minX + offsetX + sizeX/2;
|
int x = region.minX + offsetX + sizeX/2;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren