SteamWar/BauSystem
Archiviert
13
0
Dieser Commit ist enthalten in:
jojo 2021-01-25 17:37:21 +01:00
Ursprung e0e3eb2a84
Commit ddcbec834e
8 geänderte Dateien mit 25 neuen und 53 gelöschten Zeilen

Datei anzeigen

@ -41,7 +41,7 @@ public class CommandInfo implements CommandExecutor {
Player player = (Player) sender;
sender.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName());
Region region = Region.getRegion(player);
Region region = Region.getRegion(player.getLocation());
if (region == null) {
sender.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + Region.NoRegion.tnt.getName() + " §eFire§8: " + (Region.NoRegion.fire ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (Region.NoRegion.freeze ? "§aAN" : "§cAUS"));
} else {

Datei anzeigen

@ -45,7 +45,7 @@ public class CommandProtect implements CommandExecutor {
return false;
}
Region region = Region.getRegion(player);
Region region = Region.getRegion(player.getLocation());
if (region == null || !region.hasProtection()) {
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner (M)WG-Region");
return false;

Datei anzeigen

@ -45,7 +45,7 @@ public class CommandReset implements CommandExecutor {
return false;
}
Region region = Region.getRegion(player);
Region region = Region.getRegion(player.getLocation());
if (region == null) {
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
return false;

Datei anzeigen

@ -45,7 +45,7 @@ public class CommandTestblock implements CommandExecutor {
return false;
}
Region region = Region.getRegion(player);
Region region = Region.getRegion(player.getLocation());
if (region == null || !region.hasTestblock()) {
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
return false;

Datei anzeigen

@ -51,7 +51,7 @@ public abstract class RegionToggleCommand implements CommandExecutor, Listener {
return false;
}
Region region = Region.getRegion(player);
Region region = Region.getRegion(player.getLocation());
if (region == null) {
if (toggleGlobal()) {
actionBar(player, getEnableMessage());

Datei anzeigen

@ -59,7 +59,7 @@ public class BauScoreboard implements Listener {
strings.add("§1");
strings.add("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()));
strings.add("§2");
Region region = Region.getRegion(p);
Region region = Region.getRegion(p.getLocation());
if (region != null) {
strings.add("§eTNT§8: " + region.getTntMode().getName());
strings.add("§eFreeze§8: " + (region.isFreeze() ? "§aan" : "§caus"));

Datei anzeigen

@ -29,7 +29,6 @@ import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
@ -74,10 +73,6 @@ public class Region {
return buildArea;
}
public static Region getRegion(Player player) {
return getRegion(player.getLocation());
}
public static Region getRegion(Location location) {
for (Region region : regions) {
if (region.inRegion(location)) return region;
@ -93,20 +88,7 @@ public class Region {
b = false;
}
}
if (b) {
noRegion.run();
}
}
public static List<Region> getRegions(){
return regions;
}
private static Region getRegionByName(String name) {
for (Region region : regions) {
if (region.name.equals(name)) return region;
}
return null;
if (b) noRegion.run();
}
private final String name;
@ -131,9 +113,20 @@ public class Region {
regions.add(this);
}
private void link() {
if (optionsLinkedWith != null && linkedRegion == null) {
linkedRegion = getRegionByName(optionsLinkedWith);
private void setLinkedRegion(Consumer<Region> regionConsumer) {
if (optionsLinkedWith == null) {
return;
}
if (linkedRegion != null) {
regionConsumer.accept(linkedRegion);
return;
}
for (Region region : regions) {
if (region.name.equals(name)) {
linkedRegion = region;
regionConsumer.accept(linkedRegion);
return;
}
}
}
@ -143,14 +136,7 @@ public class Region {
public void setTntMode(TNTMode tntMode) {
this.tntMode = tntMode;
link();
if (linkedRegion != null) {
linkedRegion.setTntModeOther(tntMode);
}
}
private void setTntModeOther(TNTMode tntMode) {
this.tntMode = tntMode;
setLinkedRegion(region -> region.tntMode = tntMode);
}
public boolean isFreeze() {
@ -159,14 +145,7 @@ public class Region {
public void setFreeze(boolean freeze) {
this.freeze = freeze;
link();
if (linkedRegion != null) {
linkedRegion.setFreezeOther(freeze);
}
}
public void setFreezeOther(boolean freeze) {
this.freeze = freeze;
setLinkedRegion(region -> region.freeze = freeze);
}
public boolean isFire() {
@ -175,14 +154,7 @@ public class Region {
public void setFire(boolean fire) {
this.fire = fire;
link();
if (linkedRegion != null) {
linkedRegion.setFireOther(fire);
}
}
public void setFireOther(boolean fire) {
this.fire = fire;
setLinkedRegion(region -> region.fire = fire);
}
public boolean inRegion(Location l){

Datei anzeigen

@ -282,7 +282,7 @@ public class ScriptListener implements Listener {
}
private static int getValue(ScriptExecutor scriptExecutor, String key) {
Region region = Region.getRegion(scriptExecutor.player);
Region region = Region.getRegion(scriptExecutor.player.getLocation());
switch (key) {
case "trace":
return RecordStateMachine.getRecordStatus().isTracing() ? 1 : 0;