SteamWar/BauSystem
Archiviert
13
0

Merge pull request 'ProtectUpgrade' (#244) from ProtectUpgrade into master

Reviewed-on: #244
Reviewed-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
YoyoNow 2021-04-10 18:45:37 +02:00
Commit 3cc10dfbb7
4 geänderte Dateien mit 77 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -20,8 +20,8 @@
package de.steamwar.bausystem.commands; package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.bausystem.world.TPSUtils; import de.steamwar.bausystem.world.TPSUtils;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.core.TPSWatcher; import de.steamwar.core.TPSWatcher;
import de.steamwar.sql.BauweltMember; import de.steamwar.sql.BauweltMember;
@ -52,6 +52,9 @@ public class CommandInfo extends SWCommand {
p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName()); p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName());
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
p.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.getTntMode().getName() + " §eFire§8: " + (region.isFire() ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (region.isFreeze() ? "§aAN" : "§cAUS")); p.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.getTntMode().getName() + " §eFire§8: " + (region.isFire() ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (region.isFreeze() ? "§aAN" : "§cAUS"));
if (region.hasProtection()) {
p.sendMessage(BauSystem.PREFIX + "§eProtect§8: " + (region.isProtect() ? "§aAN" : "§cAUS"));
}
List<BauweltMember> members = BauweltMember.getMembers(BauSystem.getOwnerID()); List<BauweltMember> members = BauweltMember.getMembers(BauSystem.getOwnerID());
StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: "); StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: ");

Datei anzeigen

@ -27,14 +27,20 @@ import de.steamwar.command.SWCommand;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
public class CommandProtect extends SWCommand { public class CommandProtect extends SWCommand implements Listener {
public CommandProtect() { public CommandProtect() {
super("protect"); super("protect");
if (Region.buildAreaEnabled()) {
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
}
} }
@Register(help = true) @Register(help = true)
@ -48,6 +54,15 @@ public class CommandProtect extends SWCommand {
if (!permissionCheck(p)) return; if (!permissionCheck(p)) return;
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; if (region == null) return;
if (Region.buildAreaEnabled()) {
region.setProtect(!region.isProtect());
if (region.isProtect()) {
RegionUtils.actionBar(region, "§aBoden geschützt");
} else {
RegionUtils.actionBar(region, "§cBoden Schutz aufgehoben");
}
return;
}
try { try {
region.protect(null); region.protect(null);
p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt"); p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt");
@ -60,6 +75,10 @@ public class CommandProtect extends SWCommand {
@Register @Register
public void schematicProtectCommand(Player p, String s) { public void schematicProtectCommand(Player p, String s) {
if (!permissionCheck(p)) return; if (!permissionCheck(p)) return;
if (Region.buildAreaEnabled()) {
genericHelp(p);
return;
}
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; if (region == null) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId()); Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
@ -92,4 +111,15 @@ public class CommandProtect extends SWCommand {
} }
return region; return region;
} }
@EventHandler
public void onExplode(EntityExplodeEvent event) {
Region region = Region.getRegion(event.getLocation());
if (!region.isProtect() && !region.hasProtection()) {
return;
}
event.blockList().removeIf(block -> {
return block.getY() < region.getProtectYLevel();
});
}
} }

Datei anzeigen

@ -66,6 +66,9 @@ public class BauScoreboard implements Listener {
strings.add("§eFire§8: " + (region.isFire() ? "§aaus" : "§can")); strings.add("§eFire§8: " + (region.isFire() ? "§aaus" : "§can"));
strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName()); strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName());
strings.add("§eLoader§8: " + (AutoLoader.hasLoader(p) ? "§aan" : "§caus")); strings.add("§eLoader§8: " + (AutoLoader.hasLoader(p) ? "§aan" : "§caus"));
if (region.hasProtection()) {
strings.add("§eProtect§8: " + (region.isProtect() ? "§aan" : "§caus"));
}
if (RecordStateMachine.getRecordStatus().isTracing()) { if (RecordStateMachine.getRecordStatus().isTracing()) {
strings.add("§3"); strings.add("§3");

Datei anzeigen

@ -29,6 +29,7 @@ import de.steamwar.bausystem.world.Color;
import de.steamwar.bausystem.world.SizedStack; import de.steamwar.bausystem.world.SizedStack;
import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -133,10 +134,19 @@ public class Region {
private JsonObject regionOptions = new JsonObject(); private JsonObject regionOptions = new JsonObject();
@Getter
private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF; private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF;
@Getter
private boolean freeze = false; private boolean freeze = false;
@Getter
private boolean fire = false; private boolean fire = false;
@Getter
private boolean protect = false;
@Getter
private Color color = Color.YELLOW; private Color color = Color.YELLOW;
private Region(ConfigurationSection config) { private Region(ConfigurationSection config) {
@ -178,6 +188,10 @@ public class Region {
freeze = regionOptions.getAsJsonPrimitive("freeze").getAsBoolean(); freeze = regionOptions.getAsJsonPrimitive("freeze").getAsBoolean();
} }
if (regionOptions.has("protect")) {
protect = regionOptions.getAsJsonPrimitive("protect").getAsBoolean();
}
if (regionOptions.has("color")) { if (regionOptions.has("color")) {
String colorName = regionOptions.getAsJsonPrimitive("color").getAsString(); String colorName = regionOptions.getAsJsonPrimitive("color").getAsString();
try { try {
@ -191,10 +205,6 @@ public class Region {
} }
} }
public Color getColor() {
return color;
}
public void setColor(Color color) { public void setColor(Color color) {
this.color = color; this.color = color;
regionOptions.add("color", new JsonPrimitive(color.name())); regionOptions.add("color", new JsonPrimitive(color.name()));
@ -217,36 +227,42 @@ public class Region {
} }
} }
public TNTMode getTntMode() {
return tntMode;
}
public void setTntMode(TNTMode tntMode) { public void setTntMode(TNTMode tntMode) {
this.tntMode = tntMode; this.tntMode = tntMode;
setLinkedRegion(region -> region.tntMode = tntMode); setLinkedRegion(region -> {
region.tntMode = tntMode;
region.regionOptions.add("tnt", new JsonPrimitive(tntMode.name()));
});
regionOptions.add("tnt", new JsonPrimitive(tntMode.name())); regionOptions.add("tnt", new JsonPrimitive(tntMode.name()));
} }
public boolean isFreeze() {
return freeze;
}
public void setFreeze(boolean freeze) { public void setFreeze(boolean freeze) {
this.freeze = freeze; this.freeze = freeze;
setLinkedRegion(region -> region.freeze = freeze); setLinkedRegion(region -> {
region.freeze = freeze;
region.regionOptions.add("freeze", new JsonPrimitive(freeze));
});
regionOptions.add("freeze", new JsonPrimitive(freeze)); regionOptions.add("freeze", new JsonPrimitive(freeze));
} }
public boolean isFire() {
return fire;
}
public void setFire(boolean fire) { public void setFire(boolean fire) {
this.fire = fire; this.fire = fire;
setLinkedRegion(region -> region.fire = fire); setLinkedRegion(region -> {
region.fire = fire;
region.regionOptions.add("fire", new JsonPrimitive(fire));
});
regionOptions.add("fire", new JsonPrimitive(fire)); regionOptions.add("fire", new JsonPrimitive(fire));
} }
public void setProtect(boolean protect) {
this.protect = protect;
setLinkedRegion(region -> {
region.protect = protect;
region.regionOptions.add("protect", new JsonPrimitive(protect));
});
regionOptions.add("protect", new JsonPrimitive(protect));
}
public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) { public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) {
switch (regionType) { switch (regionType) {
case BUILD: case BUILD:
@ -310,6 +326,10 @@ public class Region {
undosessions.push(prototype.protect(this, schem)); undosessions.push(prototype.protect(this, schem));
} }
public int getProtectYLevel() {
return getMinPoint(RegionType.TESTBLOCK, RegionExtensionType.NORMAL).getY();
}
public boolean hasExtensionArea(RegionType regionType) { public boolean hasExtensionArea(RegionType regionType) {
switch (regionType) { switch (regionType) {
case BUILD: case BUILD: