SteamWar/BauSystem2.0
Archiviert
12
0

Add TNTMode.ONLY_BUILD
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2023-09-17 16:37:20 +02:00
Ursprung 42e8df6b53
Commit 23fba7074d
9 geänderte Dateien mit 66 neuen und 27 gelöschten Zeilen

Datei anzeigen

@ -60,6 +60,7 @@ FLAG_PROTECT_INACTIVE = §coff
FLAG_TNT_ALLOW = §aon FLAG_TNT_ALLOW = §aon
FLAG_TNT_DENY = §coff FLAG_TNT_DENY = §coff
FLAG_TNT_ONLY_TB = §7no §ebuild area FLAG_TNT_ONLY_TB = §7no §ebuild area
FLAG_TNT_ONLY_BUILD = §7no §etestblock area
FLAG_ITEMS_ACTIVE = §aon FLAG_ITEMS_ACTIVE = §aon
FLAG_ITEMS_INACTIVE = §coff FLAG_ITEMS_INACTIVE = §coff
@ -790,10 +791,12 @@ REGION_ITEM_RESET=§eReset
REGION_ITEM_TESTBLOCK=§eDummy REGION_ITEM_TESTBLOCK=§eDummy
REGION_ITEM_TNT_OFF=§7TNT: §eDeactivated REGION_ITEM_TNT_OFF=§7TNT: §eDeactivated
REGION_ITEM_TNT_ONLY_TB=§7TNT: §eonly dummy REGION_ITEM_TNT_ONLY_TB=§7TNT: §eonly dummy
REGION_ITEM_TNT_ONLY_BUILD=§7TNT: §eonly build
REGION_ITEM_TNT_ON=§7TNT: §eActivated REGION_ITEM_TNT_ON=§7TNT: §eActivated
REGION_ITEM_SELECTOR_TITLE=Tnt Mode REGION_ITEM_SELECTOR_TITLE=Tnt Mode
REGION_ITEM_SELECTOR_ON=§eActivate REGION_ITEM_SELECTOR_ON=§eActivate
REGION_ITEM_SELECTOR_ONLY_TB=§eonly dummy REGION_ITEM_SELECTOR_ONLY_TB=§eonly dummy
REGION_ITEM_SELECTOR_ONLY_BUILD=§eonly build
REGION_ITEM_SELECTOR_OFF=§eDeactivate REGION_ITEM_SELECTOR_OFF=§eDeactivate
#Region #Region
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Sets the color of the region REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Sets the color of the region
@ -877,8 +880,10 @@ REGION_TNT_HELP_MODE=§8/§etnt §8[§7Mode§8] §8- §7Set TNT behaviour to a g
REGION_TNT_ON=§aTNT-Damage activated REGION_TNT_ON=§aTNT-Damage activated
REGION_TNT_OFF=§cTNT-Damage deactivated REGION_TNT_OFF=§cTNT-Damage deactivated
REGION_TNT_TB=§aTNT-Damage activated outside the building area REGION_TNT_TB=§aTNT-Damage activated outside the building area
REGION_TNT_BUILD=§aTNT-Damage activated outside the testblok area
REGION_TNT_NO_PERMS=§cYou are not allowed to toggle tnt damage here REGION_TNT_NO_PERMS=§cYou are not allowed to toggle tnt damage here
REGION_TNT_BUILD=§cAn explosion would have destroyed blocks in the building area REGION_TNT_BUILD_DESTROY=§cAn explosion would have destroyed blocks in the building area
REGION_TNT_TB_DESTROY=§cAn explosion would have destroyed blocks in the testblock area
AFK_KICK_MESSAGE=§cNothing happened on this server for 5 minutes. AFK_KICK_MESSAGE=§cNothing happened on this server for 5 minutes.
AFK_WARNING_MESSAGE=§cThis server will stop in one minute if you remain inactive AFK_WARNING_MESSAGE=§cThis server will stop in one minute if you remain inactive

Datei anzeigen

@ -60,6 +60,7 @@ FLAG_PROTECT_INACTIVE = §caus
FLAG_TNT_ALLOW = §aan FLAG_TNT_ALLOW = §aan
FLAG_TNT_DENY = §caus FLAG_TNT_DENY = §caus
FLAG_TNT_ONLY_TB = §7Kein §eBaurahmen FLAG_TNT_ONLY_TB = §7Kein §eBaurahmen
FLAG_TNT_ONLY_BUILD = §7Kein §eTestblock
FLAG_ITEMS_ACTIVE = §aan FLAG_ITEMS_ACTIVE = §aan
FLAG_ITEMS_INACTIVE = §caus FLAG_ITEMS_INACTIVE = §caus
@ -754,10 +755,12 @@ REGION_ITEM_RESET=§eReset
REGION_ITEM_TESTBLOCK=§eTestblock REGION_ITEM_TESTBLOCK=§eTestblock
REGION_ITEM_TNT_OFF=§7TNT: §eAusgeschaltet REGION_ITEM_TNT_OFF=§7TNT: §eAusgeschaltet
REGION_ITEM_TNT_ONLY_TB=§7TNT: §enur Testblock REGION_ITEM_TNT_ONLY_TB=§7TNT: §enur Testblock
REGION_ITEM_TNT_ONLY_BUILD=§7TNT: §enur Baubereich
REGION_ITEM_TNT_ON=§7TNT: §eEingeschaltet REGION_ITEM_TNT_ON=§7TNT: §eEingeschaltet
REGION_ITEM_SELECTOR_TITLE=Tnt Modus REGION_ITEM_SELECTOR_TITLE=Tnt Modus
REGION_ITEM_SELECTOR_ON=§eEinschalten REGION_ITEM_SELECTOR_ON=§eEinschalten
REGION_ITEM_SELECTOR_ONLY_TB=§enur Testblock REGION_ITEM_SELECTOR_ONLY_TB=§enur Testblock
REGION_ITEM_SELECTOR_ONLY_BUILD=§enur Baubereich
REGION_ITEM_SELECTOR_OFF=§eAusschalten REGION_ITEM_SELECTOR_OFF=§eAusschalten
#Region #Region
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region
@ -842,7 +845,8 @@ REGION_TNT_ON=§aTNT-Schaden aktiviert
REGION_TNT_OFF=§cTNT-Schaden deaktiviert REGION_TNT_OFF=§cTNT-Schaden deaktiviert
REGION_TNT_TB=§aTNT-Schaden außerhalb Baurahmen aktiviert REGION_TNT_TB=§aTNT-Schaden außerhalb Baurahmen aktiviert
REGION_TNT_NO_PERMS=§cDu darfst hier nicht TNT-Schaden (de-)aktivieren REGION_TNT_NO_PERMS=§cDu darfst hier nicht TNT-Schaden (de-)aktivieren
REGION_TNT_BUILD=§cEine Explosion hätte Blöcke im Baubereich zerstört REGION_TNT_BUILD_DESTROY=§cEine Explosion hätte Blöcke im Baubereich zerstört
REGION_TNT_TB_DESTROY=§cEine Explosion hätte Blöcke im Testblockbereich zerstört
AFK_KICK_MESSAGE=§cAuf diesem Server ist seit 5 Minuten nichts passiert. AFK_KICK_MESSAGE=§cAuf diesem Server ist seit 5 Minuten nichts passiert.
AFK_WARNING_MESSAGE=§cDieser Server wird bei weiterer Inaktivität in einer Minute gestoppt AFK_WARNING_MESSAGE=§cDieser Server wird bei weiterer Inaktivität in einer Minute gestoppt

Datei anzeigen

@ -74,6 +74,9 @@ public class TNTCommand extends SWCommand {
case ONLY_TB: case ONLY_TB:
requestedMessage = getTestblockEnableMessage(); requestedMessage = getTestblockEnableMessage();
break; break;
case ONLY_BUILD:
requestedMessage = getBuildEnableMessage();
break;
} }
tntToggle(region, tntMode, requestedMessage); tntToggle(region, tntMode, requestedMessage);
} }
@ -89,6 +92,7 @@ public class TNTCommand extends SWCommand {
Map<String, TNTMode> tntModeMap = new HashMap<>(tntModeMapReduced); Map<String, TNTMode> tntModeMap = new HashMap<>(tntModeMapReduced);
tntModeMap.put("testblock", TNTMode.ONLY_TB); tntModeMap.put("testblock", TNTMode.ONLY_TB);
tntModeMap.put("tb", TNTMode.ONLY_TB); tntModeMap.put("tb", TNTMode.ONLY_TB);
tntModeMap.put("build", TNTMode.ONLY_BUILD);
return new TypeMapper<TNTMode>() { return new TypeMapper<TNTMode>() {
@Override @Override
@ -125,6 +129,10 @@ public class TNTCommand extends SWCommand {
return "REGION_TNT_TB"; return "REGION_TNT_TB";
} }
private String getBuildEnableMessage() {
return "REGION_TNT_BUILD";
}
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) { private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
if (requestedMode != null && region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) { if (requestedMode != null && region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) {
region.set(Flag.TNT, requestedMode); region.set(Flag.TNT, requestedMode);
@ -134,6 +142,7 @@ public class TNTCommand extends SWCommand {
switch (region.getPlain(Flag.TNT, TNTMode.class)) { switch (region.getPlain(Flag.TNT, TNTMode.class)) {
case ALLOW: case ALLOW:
case ONLY_TB: case ONLY_TB:
case ONLY_BUILD:
region.set(Flag.TNT, TNTMode.DENY); region.set(Flag.TNT, TNTMode.DENY);
RegionUtils.actionBar(region, getDisableMessage()); RegionUtils.actionBar(region, getDisableMessage());
break; break;

Datei anzeigen

@ -28,12 +28,8 @@ import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import de.steamwar.linkage.LinkedInstance;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -47,23 +43,30 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class TNTListener implements Listener, ScoreboardElement { public class TNTListener implements Listener, ScoreboardElement {
private void explode(List<Block> blockList) { private void explode(List<Block> blockList) {
AtomicBoolean inBuild = new AtomicBoolean();
blockList.removeIf(block -> { blockList.removeIf(block -> {
Region region = Region.getRegion(block.getLocation()); Region region = Region.getRegion(block.getLocation());
TNTMode value = region.getPlain(Flag.TNT); TNTMode value = region.getPlain(Flag.TNT);
if (value == TNTMode.ALLOW) { if (value == TNTMode.ALLOW) {
return false; return false;
} } else if (value == TNTMode.ONLY_TB) {
if (region.hasType(RegionType.BUILD) && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.NORMAL)) { if (region.hasType(RegionType.BUILD) && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.NORMAL)) {
RegionUtils.actionBar(region, "REGION_TNT_BUILD"); RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY");
inBuild.set(true);
return true; return true;
} }
if (region.hasType(RegionType.BUILD) && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)) { if (region.hasType(RegionType.BUILD) && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)) {
RegionUtils.actionBar(region, "REGION_TNT_BUILD"); RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY");
inBuild.set(true);
return true; return true;
} }
} else if (value == TNTMode.ONLY_BUILD) {
if (region.hasType(RegionType.TESTBLOCK) && region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.NORMAL)) {
RegionUtils.actionBar(region, "REGION_TNT_TB_DESTROY");
return true;
}
if (region.hasType(RegionType.TESTBLOCK) && region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) {
RegionUtils.actionBar(region, "REGION_TNT_TB_DESTROY");
return true;
}
}
return value == TNTMode.DENY; return value == TNTMode.DENY;
}); });
} }

Datei anzeigen

@ -25,6 +25,7 @@ import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
@ -47,6 +48,8 @@ public class TntBauGuiItem extends BauGuiItem {
return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack(); return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack();
case ONLY_TB: case ONLY_TB:
return new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ONLY_TB", player)).getItemStack(); return new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ONLY_TB", player)).getItemStack();
case ONLY_BUILD:
return new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ONLY_BUILD", player)).getItemStack();
default: default:
return new SWItem(Material.TNT, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ON", player)).getItemStack(); return new SWItem(Material.TNT, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ON", player)).getItemStack();
} }
@ -60,8 +63,10 @@ public class TntBauGuiItem extends BauGuiItem {
updateTntMode(TNTMode.ALLOW, p); updateTntMode(TNTMode.ALLOW, p);
break; break;
case ALLOW: case ALLOW:
if (Region.getRegion(p.getLocation()).hasType(RegionType.BUILD) && Region.getRegion(p.getLocation()).hasType(RegionType.TESTBLOCK)) {
updateTntMode(TNTMode.ONLY_TB, p); updateTntMode(TNTMode.ONLY_TB, p);
break; break;
}
default: default:
updateTntMode(TNTMode.DENY, p); updateTntMode(TNTMode.DENY, p);
} }
@ -72,11 +77,15 @@ public class TntBauGuiItem extends BauGuiItem {
updateTntMode(TNTMode.ALLOW, p); updateTntMode(TNTMode.ALLOW, p);
p.closeInventory(); p.closeInventory();
})); }));
if (!Region.getRegion(p.getLocation()).isGlobal()) { if (Region.getRegion(p.getLocation()).hasType(RegionType.BUILD) && Region.getRegion(p.getLocation()).hasType(RegionType.TESTBLOCK)) {
selector.setItem(4, new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_TB", p), clickType -> { selector.setItem(3, new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_TB", p), clickType -> {
updateTntMode(TNTMode.ONLY_TB, p); updateTntMode(TNTMode.ONLY_TB, p);
p.closeInventory(); p.closeInventory();
})); }));
selector.setItem(5, new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_BUILD", p), clickType -> {
updateTntMode(TNTMode.ONLY_BUILD, p);
p.closeInventory();
}));
} }
selector.setItem(7, new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_OFF", p), clickType -> { selector.setItem(7, new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_OFF", p), clickType -> {
updateTntMode(TNTMode.DENY, p); updateTntMode(TNTMode.DENY, p);
@ -92,6 +101,9 @@ public class TntBauGuiItem extends BauGuiItem {
case ONLY_TB: case ONLY_TB:
p.performCommand("tnt tb"); p.performCommand("tnt tb");
break; break;
case ONLY_BUILD:
p.performCommand("tnt build");
break;
case ALLOW: case ALLOW:
p.performCommand("tnt on"); p.performCommand("tnt on");
break; break;

Datei anzeigen

@ -55,6 +55,7 @@ public class RegionLib implements LuaLib {
tntLib.set("mode", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class).name())); tntLib.set("mode", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class).name()));
tntLib.set("enabled", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) != TNTMode.DENY)); tntLib.set("enabled", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) != TNTMode.DENY));
tntLib.set("onlyTb", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) == TNTMode.ONLY_TB)); tntLib.set("onlyTb", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) == TNTMode.ONLY_TB));
tntLib.set("onlyBuild", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) == TNTMode.ONLY_BUILD));
table.set("tnt", tntLib); table.set("tnt", tntLib);

Datei anzeigen

@ -29,7 +29,8 @@ public enum TNTMode implements Flag.Value<TNTMode> {
ALLOW("FLAG_TNT_ALLOW"), ALLOW("FLAG_TNT_ALLOW"),
DENY("FLAG_TNT_DENY"), DENY("FLAG_TNT_DENY"),
ONLY_TB("FLAG_TNT_ONLY_TB"); ONLY_TB("FLAG_TNT_ONLY_TB"),
ONLY_BUILD("FLAG_TNT_ONLY_BUILD");
private static TNTMode[] values; private static TNTMode[] values;
private final String chatValue; private final String chatValue;

Datei anzeigen

@ -145,10 +145,11 @@ Das `tnt`-Modul stellt Funktionen zur Verfügung, die den TNT-Modus in der Regio
Es gibt folgende Funktionen: Es gibt folgende Funktionen:
| Name | Signature | Beschreibung | | Name | Signature | Beschreibung |
|-----------|--------------------|-------------------------------------------------------------------------------------| |-------------|----------------------|-------------------------------------------------------------------------------------|
| `mode` | mode(): String | Gibt den Aktuellen TNT-Modus zurück, die werte sind: `ALLOW`, `DENY` oder `ONLY_TB` | | `mode` | mode(): String | Gibt den Aktuellen TNT-Modus zurück, die werte sind: `ALLOW`, `DENY` oder `ONLY_TB` |
| `enabled` | enabled(): Boolean | Gibt zurück, ob der TNT-Modus in der Region des Spielers aktiviert ist oder nicht | | `enabled` | enabled(): Boolean | Gibt zurück, ob der TNT-Modus in der Region des Spielers aktiviert ist oder nicht |
| `onlyTb` | onlyTb(): Boolean | Gibt zurück, ob der TNT-Modus auf Only-Tb ist | | `onlyTb` | onlyTb(): Boolean | Gibt zurück, ob der TNT-Modus auf Only-Tb ist |
| `onlyBuild` | onlyBuild(): Boolean | Gibt zurück, ob der TNT-Modus auf Only-Build ist |
#### trace #### trace

Datei anzeigen

@ -167,6 +167,9 @@ function tnt.enabled() return nil end
---@return boolean ---@return boolean
function tnt.onlyTb() return nil end function tnt.onlyTb() return nil end
---@return boolean
function tnt.onlyBuild() return nil end
---@class trace ---@class trace
local trace = {} local trace = {}