Merge pull request 'Modular BauSystem Regions' (#26) from BauSystem/RegionSystem into main
All checks were successful
SteamWarCI Build successful
All checks were successful
SteamWarCI Build successful
Reviewed-on: #26 Reviewed-by: D4rkr34lm <dark@steamwar.de>
This commit is contained in:
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||
import de.steamwar.bausystem.utils.tps.TPSFreezeUtils;
|
||||
import de.steamwar.bausystem.utils.tps.TPSLimitUtils;
|
||||
@ -46,7 +46,7 @@ public class TickManager15 implements TickManager, Listener {
|
||||
if (currentlyStepping) {
|
||||
currentlyStepping = false;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
|
||||
BossBarService.instance.remove(player, Region.getGlobalRegion(), "TickStep");
|
||||
});
|
||||
}
|
||||
TPSWarpUtils.warp(tickRate);
|
||||
|
||||
@ -403,6 +403,7 @@ KILLCHECKER_INFO=§7Shows the overlaps of cannon kills in your build area.
|
||||
KILLCHECKER_INFO2=§7Only colorable blocks like Wool, Terractotta, Stained Glass and Concrete are counted.
|
||||
KILLCHECKER_ENABLE=§aKillchecker activated
|
||||
KILLCHECKER_DISABLE=§cKillchecker deactivated
|
||||
KILLCHECKER_NO_BUILD=§cThere is no Build Area in this Region
|
||||
KILLCHECKER_BOSSBAR=§e§l{0} §7(§e{1}%§7) §e§l{2}§7 cannons
|
||||
# BlockCounter
|
||||
BLOCK_COUNTER_HELP_TOGGLE=§8/§eblockcounter §8- §7Toggle on/off
|
||||
@ -737,12 +738,10 @@ REGION_ITEM_RESET=§eReset
|
||||
REGION_ITEM_TESTBLOCK=§eDummy
|
||||
REGION_ITEM_TNT_OFF=§7TNT: §eDeactivated
|
||||
REGION_ITEM_TNT_ONLY_TB=§7TNT: §eonly dummy
|
||||
REGION_ITEM_TNT_ONLY_BUILD=§7TNT: §eonly build
|
||||
REGION_ITEM_TNT_ON=§7TNT: §eActivated
|
||||
REGION_ITEM_SELECTOR_TITLE=Tnt Mode
|
||||
REGION_ITEM_SELECTOR_ON=§eActivate
|
||||
REGION_ITEM_SELECTOR_ONLY_TB=§eonly dummy
|
||||
REGION_ITEM_SELECTOR_ONLY_BUILD=§eonly build
|
||||
REGION_ITEM_SELECTOR_OFF=§eDeactivate
|
||||
#Region
|
||||
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Sets the color of the region
|
||||
@ -939,7 +938,6 @@ SELECT_HELP=§8/§eselect §8[§7RegionsTyp§8] §8- §7Select a region type
|
||||
SELECT_EXTENSION_HELP=§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Select a region type with or without extension
|
||||
SELECT_GLOBAL_REGION=§cThe global region cannot be selected
|
||||
SELECT_NO_TYPE=§cThis region has no {0}
|
||||
SELECT_NO_EXTENSION=§cThis region has no extension
|
||||
SELECT_MESSAGE=§7WorldEdit selection set to {0}, {1}, {2} and {3}, {4}, {5}
|
||||
SKULL_HELP=§8/§eskull §8[§eplayer§8] §8-§7 Receive a player head
|
||||
SKULL_INVALID=§cInvalid player name
|
||||
|
||||
@ -362,6 +362,7 @@ KILLCHECKER_INFO=§7Zeigt Überlappungen der Kanonen Kills im Baubereich an.
|
||||
KILLCHECKER_INFO2=§7Nur farbige Blöcke wie Wolle, Terracotta, Stained Glass und Concrete wird gezählt.
|
||||
KILLCHECKER_ENABLE=§aKillchecker aktiviert
|
||||
KILLCHECKER_DISABLE=§cKillchecker deaktiviert
|
||||
KILLCHECKER_NO_BUILD=§cEs gibt keinen Baubereich in dieser Region
|
||||
KILLCHECKER_BOSSBAR=§e§l{0} §7(§e{1}%§7) §e§l{2}§7 Kanonnen
|
||||
# BlockCounter
|
||||
BLOCK_COUNTER_HELP_TOGGLE=§8/§eblockcounter §8- §7Wechsel zwischen an und aus
|
||||
@ -680,12 +681,10 @@ REGION_ITEM_RESET=§eReset
|
||||
REGION_ITEM_TESTBLOCK=§eTestblock
|
||||
REGION_ITEM_TNT_OFF=§7TNT: §eAusgeschaltet
|
||||
REGION_ITEM_TNT_ONLY_TB=§7TNT: §enur Testblock
|
||||
REGION_ITEM_TNT_ONLY_BUILD=§7TNT: §enur Baubereich
|
||||
REGION_ITEM_TNT_ON=§7TNT: §eEingeschaltet
|
||||
REGION_ITEM_SELECTOR_TITLE=Tnt Modus
|
||||
REGION_ITEM_SELECTOR_ON=§eEinschalten
|
||||
REGION_ITEM_SELECTOR_ONLY_TB=§enur Testblock
|
||||
REGION_ITEM_SELECTOR_ONLY_BUILD=§enur Baubereich
|
||||
REGION_ITEM_SELECTOR_OFF=§eAusschalten
|
||||
#Region
|
||||
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region
|
||||
@ -877,7 +876,6 @@ SELECT_HELP=§8/§eselect §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp
|
||||
SELECT_EXTENSION_HELP=§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension
|
||||
SELECT_GLOBAL_REGION=§cDie globale Region kannst du nicht auswählen
|
||||
SELECT_NO_TYPE=§cDiese Region hat keinen {0}
|
||||
SELECT_NO_EXTENSION=§cDiese Region hat keine Ausfahrmaße
|
||||
SELECT_MESSAGE=§7WorldEdit auswahl auf {0}, {1}, {2} und {3}, {4}, {5} gesetzt
|
||||
SKULL_HELP=§8/§eskull §8[§eSpieler§8] §8-§7 Gibt einen SpielerKopf
|
||||
SKULL_INVALID=§cUngültiger Spieler
|
||||
|
||||
@ -32,9 +32,7 @@ import de.steamwar.bausystem.features.tracer.TraceManager;
|
||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
||||
import de.steamwar.bausystem.features.world.BauScoreboard;
|
||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||
import de.steamwar.bausystem.region.loader.PrototypeLoader;
|
||||
import de.steamwar.bausystem.region.loader.RegionLoader;
|
||||
import de.steamwar.bausystem.region.loader.Updater;
|
||||
import de.steamwar.bausystem.region.RegionSystem;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.bausystem.utils.TickListener;
|
||||
import de.steamwar.bausystem.utils.TickManager;
|
||||
@ -42,6 +40,7 @@ import de.steamwar.bausystem.worlddata.WorldData;
|
||||
import de.steamwar.command.AbstractValidator;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.core.CRIUSleepEvent;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
@ -56,6 +55,7 @@ import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -74,7 +74,7 @@ import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BauSystem extends JavaPlugin {
|
||||
public class BauSystem extends JavaPlugin implements Listener {
|
||||
|
||||
// This should be treated as final!
|
||||
public static Message MESSAGE;
|
||||
@ -95,6 +95,8 @@ public class BauSystem extends JavaPlugin {
|
||||
instance = this;
|
||||
SWUtils.setBausystem(instance);
|
||||
|
||||
RegionSystem.INSTANCE.load();
|
||||
/*
|
||||
try {
|
||||
PrototypeLoader.load();
|
||||
RegionLoader.load();
|
||||
@ -107,6 +109,7 @@ public class BauSystem extends JavaPlugin {
|
||||
|
||||
new Updater(PrototypeLoader.file, PrototypeLoader::load);
|
||||
new Updater(RegionLoader.file, RegionLoader::load);
|
||||
*/
|
||||
|
||||
SWCommandUtils.addValidator(Player.class, validator(Permission.BUILD));
|
||||
SWCommandUtils.addValidator(CommandSender.class, validator(Permission.BUILD));
|
||||
@ -211,6 +214,11 @@ public class BauSystem extends JavaPlugin {
|
||||
new WorldEditRendererCUIEditor();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCRIUSleep(CRIUSleepEvent event) {
|
||||
RegionSystem.INSTANCE.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
instances.forEach((aClass, o) -> {
|
||||
@ -223,6 +231,7 @@ public class BauSystem extends JavaPlugin {
|
||||
});
|
||||
|
||||
WorldData.write();
|
||||
RegionSystem.INSTANCE.save();
|
||||
Config.getInstance().saveAll();
|
||||
}
|
||||
|
||||
|
||||
@ -21,11 +21,9 @@ package de.steamwar.bausystem;
|
||||
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.features.world.BauMemberUpdate;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
@ -24,7 +24,6 @@ import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -24,8 +24,6 @@ import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.ItemUtils;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@ -33,8 +31,6 @@ import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.type.Chest;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -43,9 +39,9 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Linked
|
||||
public class AutostartListener implements Listener {
|
||||
@ -106,11 +102,11 @@ public class AutostartListener implements Listener {
|
||||
|
||||
public void activate(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.isGlobal()) {
|
||||
if (region.getType().isGlobal()) {
|
||||
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
|
||||
return;
|
||||
}
|
||||
if (!region.hasType(RegionType.TESTBLOCK)) {
|
||||
if (region.getTestblockArea().isEmpty()) {
|
||||
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
|
||||
return;
|
||||
}
|
||||
@ -131,20 +127,12 @@ public class AutostartListener implements Listener {
|
||||
event.blockList().forEach(block -> {
|
||||
Region region = Region.getRegion(block.getLocation());
|
||||
if (!regionStartTime.containsKey(region)) return;
|
||||
if (!region.hasType(RegionType.TESTBLOCK)) return;
|
||||
if (!region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) return;
|
||||
if (!region.getTestblockArea().inRegion(block.getLocation(), true)) return;
|
||||
long tickDiff = TPSUtils.currentRealTick.get() - regionStartTime.remove(region);
|
||||
long preFightDurationInSeconds = getPreFightDurationInSeconds(region);
|
||||
long preFightDurationInSeconds = region.getGameModeConfig().getTimes().getPreFightDuration();
|
||||
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT1", tickDiff);
|
||||
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT2", preFightDurationInSeconds, ((preFightDurationInSeconds * 20) - tickDiff));
|
||||
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT3");
|
||||
});
|
||||
}
|
||||
|
||||
private int getPreFightDurationInSeconds(Region region) {
|
||||
File file = region.gameModeConfig();
|
||||
if (file == null) return 30;
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
return config.getInt("Times.PreFightDuration", 30);
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,31 +19,23 @@
|
||||
|
||||
package de.steamwar.bausystem.features.backup;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.region.Color;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionBackups;
|
||||
import de.steamwar.bausystem.region.flags.ChangedMode;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.bausystem.region.tags.Tag;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Linked
|
||||
@ -54,7 +46,7 @@ public class BackupCommand extends SWCommand {
|
||||
}
|
||||
|
||||
static boolean checkGlobalRegion(Region region, Player p) {
|
||||
if (region.isGlobal()) {
|
||||
if (region.getType().isGlobal()) {
|
||||
BauSystem.MESSAGE.send("BACKUP_REGION_NO_REGION", p);
|
||||
return true;
|
||||
}
|
||||
@ -67,11 +59,12 @@ public class BackupCommand extends SWCommand {
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
}
|
||||
if (!region.get(Tag.CHANGED)) {
|
||||
if (region.getFlags().get(Flag.CHANGED).isWithDefault(ChangedMode.NO_CHANGE)) {
|
||||
BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p);
|
||||
return;
|
||||
}
|
||||
if (region.backup()) {
|
||||
Optional<RegionBackups.Backup> backup = region.getBackups().create(RegionBackups.BackupType.MANUAL);
|
||||
if (backup.isPresent()) {
|
||||
BauSystem.MESSAGE.send("BACKUP_CREATE_SUCCESS", p);
|
||||
} else {
|
||||
BauSystem.MESSAGE.send("BACKUP_CREATE_FAILURE", p);
|
||||
@ -79,25 +72,12 @@ public class BackupCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register(value = "load", description = "BACKUP_HELP_LOAD")
|
||||
public void backupLoad(@Validator("owner") Player p, @Mapper("backupName") String backupName) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
File backupFile = region.getBackupFile(backupName.replace('_', ' '));
|
||||
if (backupFile == null) {
|
||||
public void backupLoad(@Validator("owner") Player p, @Mapper("backup") @ErrorMessage("BACKUP_LOAD_FAILURE") RegionBackups.Backup backup) {
|
||||
if (backup.load()) {
|
||||
BauSystem.MESSAGE.send("BACKUP_LOAD", p);
|
||||
} else {
|
||||
BauSystem.MESSAGE.send("BACKUP_LOAD_FAILURE", p);
|
||||
return;
|
||||
}
|
||||
EditSession editSession = new PasteBuilder(new PasteBuilder.FileProvider(backupFile))
|
||||
.pastePoint(region.getMinPoint().add(region.getPrototype().getSizeX() / 2, 0, region.getPrototype().getSizeZ() / 2))
|
||||
.minPoint(region.getMinPoint())
|
||||
.maxPoint(region.getMaxPoint())
|
||||
.waterLevel(region.getWaterLevel())
|
||||
.run();
|
||||
region.remember(editSession);
|
||||
BauSystem.MESSAGE.send("BACKUP_LOAD", p);
|
||||
}
|
||||
|
||||
@Register(value = "list", description = "BACKUP_HELP_LIST")
|
||||
@ -106,10 +86,10 @@ public class BackupCommand extends SWCommand {
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
}
|
||||
List<String> backups = listBackup(p);
|
||||
List<RegionBackups.Backup> backups = listBackup(p);
|
||||
BauSystem.MESSAGE.send("BACKUP_LIST_HEAD", p, backups.size());
|
||||
backups.forEach(s -> {
|
||||
BauSystem.MESSAGE.send("BACKUP_LIST_ENTRY", p, "/backup load " + s, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/backup load " + s), s);
|
||||
backups.forEach(backup -> {
|
||||
BauSystem.MESSAGE.send("BACKUP_LIST_ENTRY", p, "/backup load " + backup.getName(), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/backup load " + backup.getName()), backup.getName());
|
||||
});
|
||||
}
|
||||
|
||||
@ -119,34 +99,44 @@ public class BackupCommand extends SWCommand {
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
}
|
||||
List<String> backups = listBackup(p);
|
||||
List<SWListInv.SWListEntry<String>> swListEntries = new ArrayList<>();
|
||||
List<RegionBackups.Backup> backups = listBackup(p);
|
||||
List<SWListInv.SWListEntry<RegionBackups.Backup>> swListEntries = new ArrayList<>();
|
||||
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("BACKUP_LORE", p));
|
||||
for (int i = 0; i < backups.size(); i++) {
|
||||
String s = backups.get(i);
|
||||
SWItem swItem = new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("BACKUP_ITEM_NAME", p, s), lore, false, clickType -> {});
|
||||
RegionBackups.Backup backup = backups.get(i);
|
||||
SWItem swItem = new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("BACKUP_ITEM_NAME", p, backup.getName()), lore, false, clickType -> {});
|
||||
swItem.getItemStack().setAmount(i + 1);
|
||||
swListEntries.add(new SWListInv.SWListEntry<>(swItem, s));
|
||||
swListEntries.add(new SWListInv.SWListEntry<>(swItem, backup));
|
||||
}
|
||||
SWListInv<String> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("BACKUP_INV_NAME", p), swListEntries, (clickType, s) -> {
|
||||
SWListInv<RegionBackups.Backup> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("BACKUP_INV_NAME", p), swListEntries, (clickType, s) -> {
|
||||
p.getOpenInventory().close();
|
||||
p.performCommand("backup load " + s);
|
||||
});
|
||||
swListInv.open();
|
||||
}
|
||||
|
||||
@Mapper(value = "backupName", local = true)
|
||||
public TypeMapper<String> backupMapper() {
|
||||
return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> listBackup((Player) commandSender));
|
||||
@Mapper(value = "backup", local = true)
|
||||
public TypeMapper<RegionBackups.Backup> backupMapper() {
|
||||
return new TypeMapper<RegionBackups.Backup>() {
|
||||
@Override
|
||||
public RegionBackups.Backup map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return Region.getRegion(((Player) commandSender).getLocation()).getBackups().get(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||
return listBackup((Player) sender).stream().map(RegionBackups.Backup::getName).collect(Collectors.toList());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private List<String> listBackup(Player p) {
|
||||
private List<RegionBackups.Backup> listBackup(Player p) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
try {
|
||||
return region.listBackup().stream().map(s -> s.substring(0, s.length() - 6).replace(' ', '_')).collect(Collectors.toList());
|
||||
return region.getBackups().list();
|
||||
} catch (NullPointerException e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||
import de.steamwar.bausystem.region.FlagOptional;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.core.Core;
|
||||
@ -56,15 +57,10 @@ public class BauInfoBauGuiItem extends BauGuiItem {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
List<String> stringList = new ArrayList<>();
|
||||
for (Flag flag : Flag.getFlags()) {
|
||||
if (flag == Flag.PROTECT && region.getFloorLevel() == 0) {
|
||||
continue;
|
||||
}
|
||||
if (flag == Flag.ITEMS && Core.getVersion() < 19) {
|
||||
continue;
|
||||
}
|
||||
Flag.Value<?> value = region.get(flag);
|
||||
if (value != null) {
|
||||
stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getChatValue(), player)));
|
||||
if (!region.getFlags().has(flag).isApplicable()) continue;
|
||||
FlagOptional<?> value = region.getFlags().get(flag);
|
||||
if (value.isPresent()) {
|
||||
stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), player)));
|
||||
}
|
||||
}
|
||||
itemStack.setLore(stringList);
|
||||
|
||||
@ -19,13 +19,11 @@
|
||||
|
||||
package de.steamwar.bausystem.features.bau;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.techhider.TechHider;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -3,6 +3,7 @@ package de.steamwar.bausystem.features.bau;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.region.FlagOptional;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.command.SWCommand;
|
||||
@ -30,12 +31,10 @@ public class InfoCommand extends SWCommand {
|
||||
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_OWNER", p, SteamwarUser.get(bauServer.getOwnerID()).getUserName());
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
for (Flag flag : Flag.getFlags()) {
|
||||
if (flag == Flag.PROTECT && region.getFloorLevel() == 0) {
|
||||
continue;
|
||||
}
|
||||
Flag.Value<?> value = region.get(flag);
|
||||
if (value != null) {
|
||||
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getChatValue(), p));
|
||||
if (!region.getFlags().has(flag).isApplicable()) continue;
|
||||
FlagOptional<?> value = region.getFlags().get(flag);
|
||||
if (value.isPresent()) {
|
||||
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), p));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.cannon.depth.Depth;
|
||||
import de.steamwar.bausystem.features.cannon.depth.DepthManager;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
@ -85,8 +84,8 @@ public class CannonDetector implements Listener {
|
||||
grouped.forEach((cannonKey, tntPrimeds) -> {
|
||||
if (tntPrimeds.size() <= 5) return;
|
||||
Region region = Region.getRegion(tntPrimeds.get(0).getLocation());
|
||||
if (region.isGlobal()) return;
|
||||
if (!region.hasType(RegionType.TESTBLOCK)) return;
|
||||
if (region.getType().isGlobal()) return;
|
||||
if (region.getTestblockArea().isEmpty()) return;
|
||||
Depth depth = new Depth(region);
|
||||
DepthManager.init(tntPrimeds, depth);
|
||||
});
|
||||
|
||||
@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.cannon;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ -23,8 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@ -50,7 +48,7 @@ public class Depth {
|
||||
|
||||
public void update(List<Block> blocks) {
|
||||
List<Block> blocksList = blocks.stream()
|
||||
.filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION))
|
||||
.filter(block -> region.getTestblockArea().inRegion(block.getLocation(), true))
|
||||
.collect(Collectors.toList());
|
||||
tntCount++;
|
||||
for (Block block : blocksList) {
|
||||
|
||||
@ -29,12 +29,11 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DesignEndStone {
|
||||
|
||||
@ -44,18 +43,26 @@ public class DesignEndStone {
|
||||
private REntityServer entityServer = new REntityServer();
|
||||
private List<REntity> entities = new ArrayList<>();
|
||||
private Set<Location> locations = new HashSet<>();
|
||||
private boolean wsOrAs;
|
||||
private double maxBlastResistance;
|
||||
private Set<Material> limited;
|
||||
private boolean calculateFromBottom;
|
||||
|
||||
public DesignEndStone(Region region) {
|
||||
this.minX = region.getMinPointBuild().getX();
|
||||
this.minY = region.getMinPointBuild().getY();
|
||||
this.minZ = region.getMinPointBuild().getZ();
|
||||
this.maxX = region.getMaxPointBuild().getX();
|
||||
this.maxY = region.getMaxPointBuild().getY();
|
||||
this.maxZ = region.getMaxPointBuild().getZ();
|
||||
wsOrAs = region.getName().startsWith("ws") || region.getName().startsWith("as");
|
||||
maxBlastResistance = wsOrAs ? 6.1 : 9.0;
|
||||
this.minX = region.getBuildArea().getMinPoint(false).getX();
|
||||
this.minY = region.getBuildArea().getMinPoint(false).getY();
|
||||
this.minZ = region.getBuildArea().getMinPoint(false).getZ();
|
||||
this.maxX = region.getBuildArea().getMaxPoint(false).getX();
|
||||
this.maxY = region.getBuildArea().getMaxPoint(false).getY();
|
||||
this.maxZ = region.getBuildArea().getMaxPoint(false).getZ();
|
||||
|
||||
limited = region.getGameModeConfig()
|
||||
.getSchematic()
|
||||
.getLimited()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(entry -> entry.getValue() == 0)
|
||||
.flatMap(entry -> entry.getKey().stream())
|
||||
.collect(Collectors.toSet());
|
||||
calculateFromBottom = region.getGameModeConfig().getArena().isNoFloor();
|
||||
|
||||
entityServer.setCallback((player, rEntity, entityAction) -> {
|
||||
if (entityAction != REntityServer.EntityAction.ATTACK) return;
|
||||
@ -76,7 +83,7 @@ public class DesignEndStone {
|
||||
calc(minX, minY, maxZ, maxX, maxY, maxZ, 0, 0, -1, maxZ - minZ);
|
||||
calc(minX, minY, minZ, minX, maxY, maxZ, 1, 0, 0, maxX - minX);
|
||||
calc(maxX, minY, minZ, maxX, maxY, maxZ, -1, 0, 0, maxX - minX);
|
||||
if (wsOrAs) {
|
||||
if (calculateFromBottom) {
|
||||
calc(minX, minY, minZ, maxX, minY, maxZ, 0, 1, 0, maxY - minY + 1);
|
||||
} else {
|
||||
int airBlocks = 0;
|
||||
@ -106,7 +113,7 @@ public class DesignEndStone {
|
||||
int cz = z + step * dirZ;
|
||||
Material material = WORLD.getBlockAt(cx, cy, cz).getType();
|
||||
|
||||
if (material != Material.WATER && material != Material.LAVA && material.getBlastResistance() >= maxBlastResistance) {
|
||||
if (material != Material.WATER && material != Material.LAVA && limited.contains(material)) {
|
||||
Location location = new Location(WORLD, cx + 0.5, cy, cz + 0.5);
|
||||
if (!locations.add(location)) break;
|
||||
RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, location, Material.RED_STAINED_GLASS);
|
||||
|
||||
@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.design.endstone;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@ -49,7 +48,11 @@ public class DesignEndStoneCommand extends SWCommand implements Listener {
|
||||
@Register(description = "DESIGN_ENDSTONE_COMMAND_HELP")
|
||||
public void genericCommand(@Validator Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (!region.hasType(RegionType.BUILD)) {
|
||||
if (region.getBuildArea().isEmpty()) {
|
||||
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
||||
return;
|
||||
}
|
||||
if (!region.getGameModeConfig().isLoaded()) {
|
||||
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -38,7 +38,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class KillcheckerCommand extends SWCommand implements Listener {
|
||||
@ -57,6 +56,10 @@ public class KillcheckerCommand extends SWCommand implements Listener {
|
||||
@Register(value = "enable", description = "KILLCHECKER_HELP_ENABLE")
|
||||
public void genericCommand(@Validator Player player, @OptionalValue("-outline") @StaticValue(value = {"-area", "-outline"}, allowISE = true) boolean onlyOutline) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.getBuildArea().isEmpty()) {
|
||||
BauSystem.MESSAGE.send("KILLCHECKER_NO_BUILD", player);
|
||||
return;
|
||||
}
|
||||
KillcheckerVisualizer killcheckerVisualizer = visualizers.computeIfAbsent(region, region1 -> new KillcheckerVisualizer(region1, bossBarService));
|
||||
killcheckerVisualizer.recalc();
|
||||
killcheckerVisualizer.show(player, onlyOutline);
|
||||
|
||||
@ -22,8 +22,6 @@ package de.steamwar.bausystem.features.killchecker;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||
import de.steamwar.entity.REntity;
|
||||
@ -75,8 +73,8 @@ public class KillcheckerVisualizer {
|
||||
|
||||
public KillcheckerVisualizer(Region region, BossBarService bossBarService) {
|
||||
this.region = region;
|
||||
this.minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
|
||||
this.maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
|
||||
this.minPoint = region.getBuildArea().getMinPoint(false);
|
||||
this.maxPoint = region.getBuildArea().getMaxPoint(false);
|
||||
|
||||
yArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getZ() - minPoint.getZ());
|
||||
zArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getY() - minPoint.getY());
|
||||
|
||||
@ -44,7 +44,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class LoaderRecorder implements Listener {
|
||||
|
||||
|
||||
@ -22,8 +22,6 @@ package de.steamwar.bausystem.features.loadtimer;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -158,7 +156,7 @@ public class Loadtimer implements Listener {
|
||||
}
|
||||
|
||||
public void onTntExplode(EntityExplodeEvent event) {
|
||||
if (region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION) && stage == Stage.IGNITION) {
|
||||
if (region.getBuildArea().inRegion(event.getLocation(), true) && stage == Stage.IGNITION) {
|
||||
stage = Stage.END;
|
||||
explode = TPSUtils.currentRealTick.get();
|
||||
print();
|
||||
|
||||
@ -39,7 +39,7 @@ public class LoadtimerCommand extends SWCommand {
|
||||
@Register(value = "start", description = {"LOADTIMER_HELP_START_2", "LOADTIMER_HELP_START_3"})
|
||||
public void start(@Validator Player p, TimerMode mode) {
|
||||
Region r = Region.getRegion(p.getLocation());
|
||||
if (r.isGlobal()) return;
|
||||
if (r.getType().isGlobal()) return;
|
||||
if (!Loadtimer.hasTimer(r))
|
||||
Loadtimer.createLoadtimer(r, mode == TimerMode.HALF);
|
||||
}
|
||||
@ -47,7 +47,7 @@ public class LoadtimerCommand extends SWCommand {
|
||||
@Register(value = "stop", description = "LOADTIMER_HELP_STOP")
|
||||
public void stop(@Validator Player p) {
|
||||
Region r = Region.getRegion(p.getLocation());
|
||||
if (r.isGlobal()) return;
|
||||
if (r.getType().isGlobal()) return;
|
||||
if (Loadtimer.hasTimer(r))
|
||||
Loadtimer.getTimer(r).delete();
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ public class LoadtimerGuiItem extends BauGuiItem {
|
||||
@Override
|
||||
public ItemStack getItem(Player player) {
|
||||
Region r = Region.getRegion(player.getLocation());
|
||||
if (r.isGlobal())
|
||||
if (r.getType().isGlobal())
|
||||
return new SWItem(Material.BOWL, BauSystem.MESSAGE.parse("LOADTIMER_GUI_GLOBAL", player)).getItemStack();
|
||||
if (Loadtimer.hasTimer(r)) {
|
||||
return new SWItem(Material.BOW, BauSystem.MESSAGE.parse("LOADTIMER_GUI_STOP", player)).getItemStack();
|
||||
@ -58,7 +58,7 @@ public class LoadtimerGuiItem extends BauGuiItem {
|
||||
@Override
|
||||
public boolean click(ClickType click, Player p) {
|
||||
Region r = Region.getRegion(p.getLocation());
|
||||
if (r.isGlobal()) return false;
|
||||
if (r.getType().isGlobal()) return false;
|
||||
if (Loadtimer.hasTimer(r)) {
|
||||
p.performCommand("lt stop");
|
||||
} else {
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
package de.steamwar.bausystem.features.observer;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -23,8 +23,8 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
@ -52,22 +52,24 @@ public class ColorCommand extends SWCommand {
|
||||
@Register(description = "REGION_COLOR_HELP_COLOR_TYPE")
|
||||
public void genericColorSet(@Validator Player p, ColorMode color, ColorizationType colorizationType) {
|
||||
if (colorizationType == ColorizationType.GLOBAL) {
|
||||
Region.setGlobal(Flag.COLOR, color);
|
||||
Region.getRegions().forEach(region -> {
|
||||
region.getFlags().set(Flag.COLOR, color);
|
||||
});
|
||||
BauSystem.MESSAGE.send("REGION_COLOR_GLOBAL", p, BauSystem.MESSAGE.parse(color.getChatValue(), p));
|
||||
return;
|
||||
}
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (region.isGlobal()) {
|
||||
if (!region.getFlags().has(Flag.COLOR).isWritable()) {
|
||||
BauSystem.MESSAGE.send("REGION_COLOR_NO_REGION", p);
|
||||
return;
|
||||
}
|
||||
region.set(Flag.COLOR, color);
|
||||
region.getFlags().set(Flag.COLOR, color);
|
||||
try {
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||
.ignoreAir(true)
|
||||
.onlyColors(true)
|
||||
.color(color.getColor());
|
||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
||||
.color(color);
|
||||
region.getArea().reset(pasteBuilder, false);
|
||||
RegionUtils.message(region, "REGION_REGION_COLORED");
|
||||
RegionUtils.message(region, "REGION_REGION_COLORED_FAILED");
|
||||
} catch (SecurityException e) {
|
||||
|
||||
@ -19,13 +19,11 @@
|
||||
|
||||
package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.FireMode;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -55,14 +53,12 @@ public class FireCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private boolean toggle(Region region) {
|
||||
switch (region.getPlain(Flag.FIRE, FireMode.class)) {
|
||||
case ALLOW:
|
||||
region.set(Flag.FIRE, FireMode.DENY);
|
||||
return true;
|
||||
default:
|
||||
case DENY:
|
||||
region.set(Flag.FIRE, FireMode.ALLOW);
|
||||
return false;
|
||||
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
|
||||
region.getFlags().set(Flag.FIRE, FireMode.DENY);
|
||||
return true;
|
||||
} else {
|
||||
region.getFlags().set(Flag.FIRE, FireMode.ALLOW);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,8 +2,8 @@ package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.FireMode;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -17,12 +17,12 @@ public class FireListener implements Listener, ScoreboardElement {
|
||||
|
||||
@EventHandler
|
||||
public void onFireDamage(BlockBurnEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FIRE, FireMode.class) == FireMode.DENY) e.setCancelled(true);
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFireSpread(BlockSpreadEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FIRE, FireMode.class) == FireMode.DENY) e.setCancelled(true);
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -37,7 +37,7 @@ public class FireListener implements Listener, ScoreboardElement {
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (region.get(Flag.FIRE) == Flag.FIRE.getDefaultValue()) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.FIRE).getChatValue(), p);
|
||||
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.FIRE).getWithDefault().getChatValue(), p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,13 +19,11 @@
|
||||
|
||||
package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
||||
import de.steamwar.bausystem.region.flags.FreezeMode;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -55,14 +53,12 @@ public class FreezeCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private boolean toggle(Region region) {
|
||||
switch (region.getPlain(Flag.FREEZE, FreezeMode.class)) {
|
||||
case ACTIVE:
|
||||
region.set(Flag.FREEZE, FreezeMode.INACTIVE);
|
||||
return false;
|
||||
default:
|
||||
case INACTIVE:
|
||||
region.set(Flag.FREEZE, FreezeMode.ACTIVE);
|
||||
return true;
|
||||
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
region.getFlags().set(Flag.FREEZE, FreezeMode.INACTIVE);
|
||||
return false;
|
||||
} else {
|
||||
region.getFlags().set(Flag.FREEZE, FreezeMode.ACTIVE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package de.steamwar.bausystem.features.region;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
||||
import de.steamwar.bausystem.region.flags.FreezeMode;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
@ -29,9 +29,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||
if (Region.getRegion(e.getLocation()).get(Flag.FREEZE) == FreezeMode.INACTIVE) {
|
||||
return;
|
||||
}
|
||||
if (Region.getRegion(e.getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
|
||||
e.setCancelled(true);
|
||||
if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
@ -43,8 +41,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
||||
@EventHandler
|
||||
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||
if (!e.isBuildable()) return;
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.INACTIVE)
|
||||
return;
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
|
||||
if (e.getMaterial() == Material.TNT) {
|
||||
e.setBuildable(false);
|
||||
e.getBlock().setType(Material.TNT, false);
|
||||
@ -53,14 +50,14 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
||||
|
||||
@EventHandler
|
||||
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPhysicsEvent(BlockPhysicsEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
if (e.getSourceBlock().getType() == Material.NOTE_BLOCK) {
|
||||
BlockState state = e.getSourceBlock().getState();
|
||||
NoteBlock noteBlock = (NoteBlock) state.getBlockData();
|
||||
@ -85,143 +82,44 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
||||
|
||||
@EventHandler
|
||||
public void onPistonExtend(BlockPistonExtendEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onNotePlay(NotePlayEvent event) {
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=45, z=98},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=44, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=97},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=97},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=96},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-108, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=45, z=98},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-104, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
|
||||
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=49, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
////[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=102},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-108, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-104, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPistonRetract(BlockPistonRetractEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockGrow(BlockGrowEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRedstoneEvent(BlockRedstoneEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setNewCurrent(e.getOldCurrent());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockDispense(BlockDispenseEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
|
||||
if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
} else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
} else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -230,7 +128,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
if (Core.getVersion() < 19) return;
|
||||
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
e.getBlock().setType(Material.BARRIER, false);
|
||||
e.getBlock().setType(Material.AIR, false);
|
||||
@ -253,35 +151,35 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
||||
|
||||
@EventHandler
|
||||
public void onFluidLevelChange(FluidLevelChangeEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockSpread(BlockSpreadEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockFromTo(BlockFromToEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSpongeAbsorb(SpongeAbsorbEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockForm(BlockFormEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -289,7 +187,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent e) {
|
||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||
if (Region.getRegion(e.getClickedBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (Region.getRegion(e.getClickedBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
Block block = e.getClickedBlock();
|
||||
if (block.getType() == Material.LEVER) {
|
||||
Switch data = ((Switch) block.getBlockData());
|
||||
@ -300,9 +198,9 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockFade(BlockFadeEvent event) {
|
||||
if (Region.getRegion(event.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
event.setCancelled(true);
|
||||
public void onBlockFade(BlockFadeEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,7 +216,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (region.get(Flag.FREEZE) == Flag.FREEZE.getDefaultValue()) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.FREEZE).getChatValue(), p);
|
||||
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.FREEZE).getWithDefault().getChatValue(), p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,14 +19,11 @@
|
||||
|
||||
package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ItemMode;
|
||||
import de.steamwar.bausystem.region.flags.ItemMode;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -58,14 +55,12 @@ public class ItemsCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private boolean toggle(Region region) {
|
||||
switch (region.getPlain(Flag.ITEMS, ItemMode.class)) {
|
||||
case ACTIVE:
|
||||
region.set(Flag.ITEMS, ItemMode.INACTIVE);
|
||||
return false;
|
||||
default:
|
||||
case INACTIVE:
|
||||
region.set(Flag.ITEMS, ItemMode.ACTIVE);
|
||||
return true;
|
||||
if (region.getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.ACTIVE)) {
|
||||
region.getFlags().set(Flag.ITEMS, ItemMode.INACTIVE);
|
||||
return false;
|
||||
} else {
|
||||
region.getFlags().set(Flag.ITEMS, ItemMode.ACTIVE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ItemMode;
|
||||
import de.steamwar.bausystem.region.flags.ItemMode;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
@ -35,13 +35,9 @@ import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
@MinVersion(19)
|
||||
public class ItemsListener implements Listener, ScoreboardElement {
|
||||
|
||||
private static ItemMode getMode(Region region) {
|
||||
return region.getPlain(Flag.ITEMS, ItemMode.class);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemSpawn(ItemSpawnEvent event) {
|
||||
if (getMode(Region.getRegion(event.getLocation())) == ItemMode.INACTIVE) {
|
||||
if (Region.getRegion(event.getLocation()).getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -58,7 +54,7 @@ public class ItemsListener implements Listener, ScoreboardElement {
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (region.get(Flag.ITEMS) == Flag.ITEMS.getDefaultValue()) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.ITEMS).getChatValue(), p);
|
||||
if (region.getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.ITEMS).getWithDefault().getChatValue(), p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.NoGravityMode;
|
||||
import de.steamwar.bausystem.region.flags.NoGravityMode;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -53,14 +53,12 @@ public class NoGravityCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private boolean toggle(Region region) {
|
||||
switch (region.getPlain(Flag.NO_GRAVITY, NoGravityMode.class)) {
|
||||
case ACTIVE:
|
||||
region.set(Flag.NO_GRAVITY, NoGravityMode.INACTIVE);
|
||||
return false;
|
||||
default:
|
||||
case INACTIVE:
|
||||
region.set(Flag.NO_GRAVITY, NoGravityMode.ACTIVE);
|
||||
return true;
|
||||
if (region.getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
|
||||
region.getFlags().set(Flag.NO_GRAVITY, NoGravityMode.INACTIVE);
|
||||
return false;
|
||||
} else {
|
||||
region.getFlags().set(Flag.NO_GRAVITY, NoGravityMode.ACTIVE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.NoGravityMode;
|
||||
import de.steamwar.bausystem.region.flags.NoGravityMode;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -34,14 +34,10 @@ import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
@Linked
|
||||
public class NoGravityListener implements Listener, ScoreboardElement {
|
||||
|
||||
private static NoGravityMode getMode(Region region) {
|
||||
return region.getPlain(Flag.NO_GRAVITY, NoGravityMode.class);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
||||
if (event.getEntityType() == EntityType.PLAYER) return;
|
||||
if (getMode(Region.getRegion(event.getLocation())) == NoGravityMode.ACTIVE) {
|
||||
if (Region.getRegion(event.getLocation()).getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
|
||||
event.getEntity().setGravity(false);
|
||||
}
|
||||
}
|
||||
@ -58,7 +54,7 @@ public class NoGravityListener implements Listener, ScoreboardElement {
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (region.get(Flag.NO_GRAVITY) == Flag.NO_GRAVITY.getDefaultValue()) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.NO_GRAVITY).getChatValue(), p);
|
||||
if (region.getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.INACTIVE)) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.NO_GRAVITY).getWithDefault().getChatValue(), p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,13 +20,11 @@
|
||||
package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
||||
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -41,22 +39,18 @@ public class ProtectCommand extends SWCommand {
|
||||
public void genericProtectCommand(@Validator Player p) {
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
switch (region.getPlain(Flag.PROTECT, ProtectMode.class)) {
|
||||
case ACTIVE:
|
||||
region.set(Flag.PROTECT, ProtectMode.INACTIVE);
|
||||
RegionUtils.actionBar(region, "REGION_PROTECT_DISABLE");
|
||||
break;
|
||||
default:
|
||||
case INACTIVE:
|
||||
region.set(Flag.PROTECT, ProtectMode.ACTIVE);
|
||||
RegionUtils.actionBar(region, "REGION_PROTECT_ENABLE");
|
||||
break;
|
||||
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
|
||||
region.getFlags().set(Flag.PROTECT, ProtectMode.INACTIVE);
|
||||
RegionUtils.actionBar(region, "REGION_PROTECT_DISABLE");
|
||||
} else {
|
||||
region.getFlags().set(Flag.PROTECT, ProtectMode.ACTIVE);
|
||||
RegionUtils.actionBar(region, "REGION_PROTECT_ENABLE");
|
||||
}
|
||||
}
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.getFloorLevel() == 0) {
|
||||
if (!region.getFlags().has(Flag.PROTECT).isApplicable()) {
|
||||
BauSystem.MESSAGE.send("REGION_PROTECT_FALSE_REGION", player);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
||||
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Location;
|
||||
@ -21,13 +22,11 @@ public class ProtectListener implements Listener, ScoreboardElement {
|
||||
|
||||
private void explode(List<Block> blockList, Location location) {
|
||||
Region region = Region.getRegion(location);
|
||||
if (region.getFloorLevel() == 0) {
|
||||
return;
|
||||
}
|
||||
if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.INACTIVE) {
|
||||
return;
|
||||
}
|
||||
blockList.removeIf(block -> block.getY() < region.getFloorLevel());
|
||||
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return;
|
||||
Point p1 = region.getBuildArea().getMinPoint(true);
|
||||
Point p2 = region.getTestblockArea().getMinPoint(true);
|
||||
int floorLevel = Math.min(p1.getY(), p2.getY());
|
||||
blockList.removeIf(block -> block.getY() < floorLevel);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -52,8 +51,7 @@ public class ProtectListener implements Listener, ScoreboardElement {
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (region.getFloorLevel() == 0) return null;
|
||||
if (region.get(Flag.PROTECT) != Flag.PROTECT.getDefaultValue()) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.PROTECT).getChatValue(), p);
|
||||
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.PROTECT).getWithDefault().getChatValue(), p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,30 +32,20 @@ import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Linked
|
||||
public class RegionCommand extends SWCommand {
|
||||
@ -71,7 +61,7 @@ public class RegionCommand extends SWCommand {
|
||||
}
|
||||
|
||||
static boolean checkGlobalRegion(Region region, Player p) {
|
||||
if (region.isGlobal()) {
|
||||
if (region.getType().isGlobal()) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_NO_REGION", p);
|
||||
return true;
|
||||
}
|
||||
@ -83,7 +73,7 @@ public class RegionCommand extends SWCommand {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (checkGlobalRegion(region, p)) return;
|
||||
|
||||
if (region.undo()) {
|
||||
if (region.getHistory().undo()) {
|
||||
RegionUtils.message(region, "REGION_REGION_UNDID");
|
||||
} else {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_NOTHING_UNDO", p);
|
||||
@ -97,7 +87,7 @@ public class RegionCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (region.redo()) {
|
||||
if (region.getHistory().redo()) {
|
||||
RegionUtils.message(region, "REGION_REGION_REDID");
|
||||
} else {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_NOTHING_REDO", p);
|
||||
@ -110,10 +100,10 @@ public class RegionCommand extends SWCommand {
|
||||
if(checkGlobalRegion(region, p)) return;
|
||||
|
||||
try {
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||
.ignoreAir(true)
|
||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
||||
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||
region.getArea().reset(pasteBuilder, true);
|
||||
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
||||
} catch (SecurityException e) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
||||
@ -134,8 +124,8 @@ public class RegionCommand extends SWCommand {
|
||||
try {
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
||||
.ignoreAir(true)
|
||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
||||
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||
region.getArea().reset(pasteBuilder, true);
|
||||
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
||||
} catch (SecurityException e) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
||||
@ -149,11 +139,11 @@ public class RegionCommand extends SWCommand {
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
}
|
||||
if (region.getCopyPoint() == null) {
|
||||
if (region.getBuildArea().isEmpty()) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
||||
return;
|
||||
}
|
||||
p.teleport(region.getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||
p.teleport(region.getBuildArea().getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||
BauSystem.MESSAGE.send("REGION_REGION_TP_COPY", p);
|
||||
}
|
||||
|
||||
@ -164,70 +154,33 @@ public class RegionCommand extends SWCommand {
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
}
|
||||
if (region.getTestBlockPoint() == null) {
|
||||
if (region.getTestblockArea().isEmpty()) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
||||
return;
|
||||
}
|
||||
p.teleport(region.getTestBlockPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||
p.teleport(region.getTestblockArea().getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||
BauSystem.MESSAGE.send("REGION_REGION_TP_TEST_BLOCK", p);
|
||||
}
|
||||
|
||||
@Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN_INFO")
|
||||
@Register("skin")
|
||||
public void changeSkinCommand(Player p) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
}
|
||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INFO", p, region.getSkin());
|
||||
String creator = region.getPrototype().getSkinMap().get(region.getSkin()).getCreator();
|
||||
if (creator != null) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INFO_CREATOR", p, creator);
|
||||
}
|
||||
}
|
||||
|
||||
@Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN")
|
||||
@Register("skin")
|
||||
public void changeSkinCommand(@Validator Player p, @Mapper("skinTypeMapper") String s) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
}
|
||||
if (!region.getPrototype().getSkinMap().containsKey(s)) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_UNKNOWN", p);
|
||||
} else {
|
||||
if (region.setSkin(s)) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_CHANGE", p, s);
|
||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_CHANGE_UPDATE", p, BauSystem.MESSAGE.parse("REGION_REGION_CHANGESKIN_CHANGE_UPDATE_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/reset"));
|
||||
} else {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INVALID", p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Register(value = "copy", description = "REGION_REGION_HELP_COPY")
|
||||
public void copyCommand(@Validator Player p, @OptionalValue("") @StaticValue(value = {"", "-e", "-s"}, allowISE = true) int option) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
}
|
||||
if (!region.hasType(RegionType.BUILD)) {
|
||||
if (region.getBuildArea().isEmpty()) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p);
|
||||
return;
|
||||
}
|
||||
if (region.getCopyPoint() == null) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
||||
return;
|
||||
}
|
||||
|
||||
Point minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
|
||||
Point maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
|
||||
Point minPoint = region.getBuildArea().getMinPoint(false);
|
||||
Point maxPoint = region.getBuildArea().getMaxPoint(false);
|
||||
switch (option) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.EXTENSION);
|
||||
maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.EXTENSION);
|
||||
minPoint = region.getBuildArea().getMinPoint(true);
|
||||
maxPoint = region.getBuildArea().getMaxPoint(true);
|
||||
break;
|
||||
case 2:
|
||||
Pair<Location, Location> selection = WorldEditUtils.getSelection(p);
|
||||
@ -238,7 +191,7 @@ public class RegionCommand extends SWCommand {
|
||||
break;
|
||||
}
|
||||
|
||||
Clipboard clipboard = FlatteningWrapper.impl.copy(minPoint, maxPoint, region.getCopyPoint());
|
||||
Clipboard clipboard = FlatteningWrapper.impl.copy(minPoint, maxPoint, region.getBuildArea().getCopyPoint());
|
||||
WorldEdit.getInstance()
|
||||
.getSessionManager()
|
||||
.get(BukkitAdapter.adapt(p))
|
||||
@ -252,14 +205,10 @@ public class RegionCommand extends SWCommand {
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
}
|
||||
if (!region.hasType(RegionType.BUILD)) {
|
||||
if (region.getBuildArea().isEmpty()) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p);
|
||||
return;
|
||||
}
|
||||
if (region.getCopyPoint() == null) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
||||
return;
|
||||
}
|
||||
|
||||
ClipboardHolder clipboardHolder = WorldEdit.getInstance()
|
||||
.getSessionManager()
|
||||
@ -287,13 +236,13 @@ public class RegionCommand extends SWCommand {
|
||||
}
|
||||
|
||||
try (EditSession e = WorldEditUtils.getEditSession(p)) {
|
||||
Operations.completeBlindly(clipboardHolder.createPaste(e).ignoreAirBlocks(ignoreAir).to(toBlockVector3(region.getCopyPoint())).build());
|
||||
Operations.completeBlindly(clipboardHolder.createPaste(e).ignoreAirBlocks(ignoreAir).to(toBlockVector3(region.getBuildArea().getCopyPoint())).build());
|
||||
WorldEditUtils.addToPlayer(p, e);
|
||||
|
||||
if (selectPasted) {
|
||||
Clipboard clipboard = clipboardHolder.getClipboards().get(0);
|
||||
BlockVector3 minPointSelection = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getCopyPoint()));
|
||||
BlockVector3 maxPointSelection = clipboard.getRegion().getMaximumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getCopyPoint()));
|
||||
BlockVector3 minPointSelection = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getBuildArea().getCopyPoint()));
|
||||
BlockVector3 maxPointSelection = clipboard.getRegion().getMaximumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getBuildArea().getCopyPoint()));
|
||||
FlatteningWrapper.impl.setSelection(p, Point.fromBlockVector3(minPointSelection), Point.fromBlockVector3(maxPointSelection));
|
||||
}
|
||||
BauSystem.MESSAGE.send("REGION_REGION_PASTE_DONE", p);
|
||||
@ -303,25 +252,4 @@ public class RegionCommand extends SWCommand {
|
||||
private BlockVector3 toBlockVector3(Point point) {
|
||||
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
|
||||
}
|
||||
|
||||
|
||||
@Mapper(value = "skinTypeMapper", local = true)
|
||||
private TypeMapper<String> skinTypeMapper() {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||
Player p = (Player) commandSender;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (region.isGlobal()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return region.getPrototype().getSkinMap().keySet().stream().map(c -> c.replace(' ', '_')).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||
return s.replace('_', ' ');
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,8 @@ package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.tags.Tag;
|
||||
import de.steamwar.bausystem.region.flags.ChangedMode;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -185,7 +186,7 @@ public class RegionListener implements Listener {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Region.getRegion(location).set(Tag.CHANGED);
|
||||
Region.getRegion(location).getFlags().set(Flag.CHANGED, ChangedMode.HAS_CHANGE);
|
||||
}
|
||||
}.runTaskAsynchronously(BauSystem.getInstance());
|
||||
}
|
||||
|
||||
@ -20,12 +20,16 @@
|
||||
package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Linked
|
||||
public class RegionScoreboardElement implements ScoreboardElement {
|
||||
|
||||
@ -41,7 +45,10 @@ public class RegionScoreboardElement implements ScoreboardElement {
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (GlobalRegion.getInstance() == region) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getDisplayName();
|
||||
if (region.getType().isGlobal()) return null;
|
||||
if (!region.getGameModeConfig().isLoaded()) return null;
|
||||
List<String> names = region.getGameModeConfig().getServer().getChatNames();
|
||||
if (names.isEmpty()) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + names.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,13 +21,10 @@ package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionSystem;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@ -55,12 +52,10 @@ public class ResetCommand extends SWCommand {
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
try {
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
||||
for (Flag value : Flag.getResetFlags()) {
|
||||
region.set(value, value.getDefaultValue());
|
||||
}
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||
region.getArea().reset(pasteBuilder, false);
|
||||
region.getFlags().clear();
|
||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||
} catch (SecurityException e) {
|
||||
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
||||
@ -88,8 +83,8 @@ public class ResetCommand extends SWCommand {
|
||||
}
|
||||
try {
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
||||
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||
region.getArea().reset(pasteBuilder, true);
|
||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||
} catch (SecurityException e) {
|
||||
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
||||
@ -99,7 +94,7 @@ public class ResetCommand extends SWCommand {
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region == GlobalRegion.getInstance()) {
|
||||
if (region == RegionSystem.INSTANCE.getGlobalRegion()) {
|
||||
BauSystem.MESSAGE.send("REGION_RESET_NO_REGION", player);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -20,16 +20,14 @@
|
||||
package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||
import de.steamwar.bausystem.region.flags.TestblockMode;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -74,9 +72,6 @@ public class TNTCommand extends SWCommand {
|
||||
case ONLY_TB:
|
||||
requestedMessage = getTestblockEnableMessage();
|
||||
break;
|
||||
case ONLY_BUILD:
|
||||
requestedMessage = getBuildEnableMessage();
|
||||
break;
|
||||
}
|
||||
tntToggle(region, tntMode, requestedMessage);
|
||||
}
|
||||
@ -92,13 +87,12 @@ public class TNTCommand extends SWCommand {
|
||||
Map<String, TNTMode> tntModeMap = new HashMap<>(tntModeMapReduced);
|
||||
tntModeMap.put("testblock", TNTMode.ONLY_TB);
|
||||
tntModeMap.put("tb", TNTMode.ONLY_TB);
|
||||
tntModeMap.put("build", TNTMode.ONLY_BUILD);
|
||||
|
||||
return new TypeMapper<TNTMode>() {
|
||||
return new TypeMapper<>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||
Region region = Region.getRegion(((Player) sender).getLocation());
|
||||
if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) {
|
||||
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||
return new ArrayList<>(tntModeMap.keySet());
|
||||
} else {
|
||||
return new ArrayList<>(tntModeMapReduced.keySet());
|
||||
@ -108,7 +102,7 @@ public class TNTCommand extends SWCommand {
|
||||
@Override
|
||||
public TNTMode map(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||
Region region = Region.getRegion(((Player) sender).getLocation());
|
||||
if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) {
|
||||
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||
return tntModeMap.getOrDefault(s, null);
|
||||
} else {
|
||||
return tntModeMapReduced.getOrDefault(s, null);
|
||||
@ -134,24 +128,23 @@ public class TNTCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
|
||||
if (requestedMode != null && region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) {
|
||||
region.set(Flag.TNT, requestedMode);
|
||||
if (requestedMode != null && region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||
region.getFlags().set(Flag.TNT, requestedMode);
|
||||
RegionUtils.actionBar(region, requestedMessage);
|
||||
return;
|
||||
}
|
||||
switch (region.getPlain(Flag.TNT, TNTMode.class)) {
|
||||
switch (region.getFlags().get(Flag.TNT).getWithDefault()) {
|
||||
case ALLOW:
|
||||
case ONLY_TB:
|
||||
case ONLY_BUILD:
|
||||
region.set(Flag.TNT, TNTMode.DENY);
|
||||
region.getFlags().set(Flag.TNT, TNTMode.DENY);
|
||||
RegionUtils.actionBar(region, getDisableMessage());
|
||||
break;
|
||||
case DENY:
|
||||
if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) {
|
||||
region.set(Flag.TNT, TNTMode.ONLY_TB);
|
||||
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||
region.getFlags().set(Flag.TNT, TNTMode.ONLY_TB);
|
||||
RegionUtils.actionBar(region, getTestblockEnableMessage());
|
||||
} else {
|
||||
region.set(Flag.TNT, TNTMode.ALLOW);
|
||||
region.getFlags().set(Flag.TNT, TNTMode.ALLOW);
|
||||
RegionUtils.actionBar(region, getEnableMessage());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -23,9 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.Block;
|
||||
@ -37,7 +35,6 @@ import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@Linked
|
||||
public class TNTListener implements Listener, ScoreboardElement {
|
||||
@ -45,27 +42,14 @@ public class TNTListener implements Listener, ScoreboardElement {
|
||||
private void explode(List<Block> blockList) {
|
||||
blockList.removeIf(block -> {
|
||||
Region region = Region.getRegion(block.getLocation());
|
||||
TNTMode value = region.getPlain(Flag.TNT);
|
||||
TNTMode value = region.getFlags().get(Flag.TNT).getWithDefault();
|
||||
if (value == TNTMode.ALLOW) {
|
||||
return false;
|
||||
} else if (value == TNTMode.ONLY_TB) {
|
||||
if (region.hasType(RegionType.BUILD) && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.NORMAL)) {
|
||||
if (region.getBuildArea().inRegion(block.getLocation(), true)) {
|
||||
RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY");
|
||||
return true;
|
||||
}
|
||||
if (region.hasType(RegionType.BUILD) && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)) {
|
||||
RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY");
|
||||
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;
|
||||
});
|
||||
@ -93,6 +77,7 @@ public class TNTListener implements Listener, ScoreboardElement {
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.TNT).getChatValue(), p);
|
||||
if (region.getFlags().get(Flag.TNT).isWithDefault(TNTMode.ALLOW)) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.TNT).getWithDefault().getChatValue(), p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,19 +20,16 @@
|
||||
package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.sql.Punishment;
|
||||
@ -43,10 +40,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
@ -99,14 +94,14 @@ public class TestblockCommand extends SWCommand {
|
||||
}
|
||||
|
||||
try {
|
||||
PasteBuilder.ClipboardProvider clipboardProvider = node == null ? new PasteBuilder.FileProvider(region.getResetFile(RegionType.TESTBLOCK)) : new PasteBuilder.SchematicProvider(node);
|
||||
PasteBuilder.ClipboardProvider clipboardProvider = node == null ? new PasteBuilder.FileProvider(region.getTestblockArea().getResetFile()) : new PasteBuilder.SchematicProvider(node);
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
||||
.ignoreAir(ignoreAir)
|
||||
.onlyColors(onlyColors)
|
||||
.removeTNT(removeTNT)
|
||||
.removeWater(removeWater)
|
||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
||||
region.reset(pasteBuilder, RegionType.TESTBLOCK, regionExtensionType);
|
||||
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||
region.getTestblockArea().reset(pasteBuilder, regionExtensionType == RegionExtensionType.EXTENSION);
|
||||
RegionUtils.message(region, "REGION_TB_DONE");
|
||||
} catch (SecurityException e) {
|
||||
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
|
||||
@ -159,7 +154,7 @@ public class TestblockCommand extends SWCommand {
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (!region.hasType(RegionType.TESTBLOCK)) {
|
||||
if (region.getTestblockArea().isEmpty()) {
|
||||
BauSystem.MESSAGE.send("REGION_TB_NO_REGION", player);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -22,10 +22,9 @@ package de.steamwar.bausystem.features.region.items;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||
import de.steamwar.bausystem.region.Color;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@ -45,7 +44,7 @@ public class ColorBauGuiItem extends BauGuiItem {
|
||||
super(2);
|
||||
}
|
||||
|
||||
private static Material mapColor(Color color) {
|
||||
private static Material mapColor(ColorMode color) {
|
||||
switch (color) {
|
||||
case RED:
|
||||
return Material.RED_CONCRETE;
|
||||
@ -85,17 +84,17 @@ public class ColorBauGuiItem extends BauGuiItem {
|
||||
@Override
|
||||
public ItemStack getItem(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
ColorMode mode = region.getPlain(Flag.COLOR, ColorMode.class);
|
||||
return new SWItem(mapColor(mode.getColor()), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack();
|
||||
ColorMode mode = region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK);
|
||||
return new SWItem(mapColor(mode), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean click(ClickType click, Player p) {
|
||||
p.closeInventory();
|
||||
ColorMode current = Region.getRegion(p.getLocation()).getPlain(Flag.COLOR, ColorMode.class);
|
||||
ColorMode current = Region.getRegion(p.getLocation()).getFlags().get(Flag.COLOR).orElse(ColorMode.PINK);
|
||||
List<SWListInv.SWListEntry<ColorMode>> items = new ArrayList<>();
|
||||
for (ColorMode value : ColorMode.values()) {
|
||||
items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value.getColor()), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> {
|
||||
items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> {
|
||||
}), value));
|
||||
}
|
||||
SWListInv<ColorMode> inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("REGION_ITEM_COLOR_CHOOSE", p), items, (clickType, colorMode) -> {
|
||||
|
||||
@ -23,8 +23,8 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.FireMode;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
@ -42,7 +42,10 @@ public class FireBauGuiItem extends BauGuiItem {
|
||||
@Override
|
||||
public ItemStack getItem(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.getPlain(Flag.FIRE, FireMode.class) == FireMode.ALLOW) {
|
||||
if (!region.getFlags().has(Flag.FIRE).isApplicable()) {
|
||||
return new SWItem(Material.BARRIER, "").getItemStack();
|
||||
}
|
||||
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
|
||||
return new SWItem(Material.FIRE_CHARGE, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_ALLOW", player)).getItemStack();
|
||||
} else {
|
||||
return new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_DISALLOW", player)).getItemStack();
|
||||
|
||||
@ -24,7 +24,7 @@ import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
||||
import de.steamwar.bausystem.region.flags.FreezeMode;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
@ -42,7 +42,10 @@ public class FreezeBauGuiItem extends BauGuiItem {
|
||||
@Override
|
||||
public ItemStack getItem(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE) {
|
||||
if (!region.getFlags().has(Flag.FREEZE).isApplicable()) {
|
||||
return new SWItem(Material.BARRIER, "").getItemStack();
|
||||
}
|
||||
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||
return new SWItem(Material.GUNPOWDER, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_ALLOW", player)).getItemStack();
|
||||
} else {
|
||||
return new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_DISALLOW", player)).getItemStack();
|
||||
|
||||
@ -25,7 +25,7 @@ import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
||||
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
@ -43,7 +43,10 @@ public class ProtectBauGuiItem extends BauGuiItem {
|
||||
@Override
|
||||
public ItemStack getItem(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.ACTIVE) {
|
||||
if (!region.getFlags().has(Flag.PROTECT).isApplicable()) {
|
||||
return new SWItem(Material.BARRIER, "").getItemStack();
|
||||
}
|
||||
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
|
||||
return SWUtils.setCustomModelData(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)), 1).getItemStack();
|
||||
} else {
|
||||
return SWUtils.setCustomModelData(new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)), 1).getItemStack();
|
||||
|
||||
@ -24,8 +24,7 @@ import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@ -43,13 +42,11 @@ public class TntBauGuiItem extends BauGuiItem {
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(Player player) {
|
||||
switch (Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class)) {
|
||||
switch (Region.getRegion(player.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) {
|
||||
case DENY:
|
||||
return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack();
|
||||
case ONLY_TB:
|
||||
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:
|
||||
return new SWItem(Material.TNT, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ON", player)).getItemStack();
|
||||
}
|
||||
@ -58,12 +55,12 @@ public class TntBauGuiItem extends BauGuiItem {
|
||||
@Override
|
||||
public boolean click(ClickType click, Player p) {
|
||||
if (click == ClickType.LEFT) {
|
||||
switch (Region.getRegion(p.getLocation()).getPlain(Flag.TNT, TNTMode.class)) {
|
||||
switch (Region.getRegion(p.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) {
|
||||
case DENY:
|
||||
updateTntMode(TNTMode.ALLOW, p);
|
||||
break;
|
||||
case ALLOW:
|
||||
if (Region.getRegion(p.getLocation()).hasType(RegionType.BUILD) && Region.getRegion(p.getLocation()).hasType(RegionType.TESTBLOCK)) {
|
||||
if (!Region.getRegion(p.getLocation()).getBuildArea().isEmpty() && !Region.getRegion(p.getLocation()).getTestblockArea().isEmpty()) {
|
||||
updateTntMode(TNTMode.ONLY_TB, p);
|
||||
break;
|
||||
}
|
||||
@ -77,15 +74,11 @@ public class TntBauGuiItem extends BauGuiItem {
|
||||
updateTntMode(TNTMode.ALLOW, p);
|
||||
p.closeInventory();
|
||||
}));
|
||||
if (Region.getRegion(p.getLocation()).hasType(RegionType.BUILD) && Region.getRegion(p.getLocation()).hasType(RegionType.TESTBLOCK)) {
|
||||
if (!Region.getRegion(p.getLocation()).getBuildArea().isEmpty() && !Region.getRegion(p.getLocation()).getTestblockArea().isEmpty()) {
|
||||
selector.setItem(3, new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_TB", p), clickType -> {
|
||||
updateTntMode(TNTMode.ONLY_TB, p);
|
||||
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 -> {
|
||||
updateTntMode(TNTMode.DENY, p);
|
||||
@ -101,9 +94,6 @@ public class TntBauGuiItem extends BauGuiItem {
|
||||
case ONLY_TB:
|
||||
p.performCommand("tnt tb");
|
||||
break;
|
||||
case ONLY_BUILD:
|
||||
p.performCommand("tnt build");
|
||||
break;
|
||||
case ALLOW:
|
||||
p.performCommand("tnt on");
|
||||
break;
|
||||
|
||||
@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.script;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.features.script.lua.SteamWarPlatform;
|
||||
import de.steamwar.bausystem.utils.ItemUtils;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
|
||||
@ -28,7 +28,6 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
@ -153,7 +153,7 @@ public class EventListener implements Listener {
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if(!Permission.BUILD.hasPermission(player)) continue;
|
||||
if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
|
||||
if (tntRegion.getArea().inRegion(player.getLocation(), false)) {
|
||||
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event);
|
||||
}
|
||||
}
|
||||
@ -171,11 +171,11 @@ public class EventListener implements Listener {
|
||||
table.set("y", event.getLocation().getY());
|
||||
table.set("z", event.getLocation().getZ());
|
||||
|
||||
boolean inBuild = event.blockList().stream().anyMatch(block -> tntRegion.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION));
|
||||
boolean inBuild = event.blockList().stream().anyMatch(block -> tntRegion.getBuildArea().inRegion(block.getLocation(), true));
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if(!Permission.BUILD.hasPermission(player)) continue;
|
||||
if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
|
||||
if (tntRegion.getArea().inRegion(player.getLocation(), false)) {
|
||||
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event);
|
||||
if (inBuild) {
|
||||
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplodeInBuild, table, event);
|
||||
|
||||
@ -22,19 +22,14 @@ package de.steamwar.bausystem.features.script.lua;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.features.script.ScriptRunner;
|
||||
import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
||||
import de.steamwar.bausystem.features.world.WorldEditListener;
|
||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -47,8 +42,6 @@ import org.luaj.vm2.LuaValue;
|
||||
import org.luaj.vm2.Varargs;
|
||||
import org.luaj.vm2.lib.*;
|
||||
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
@ -20,19 +20,16 @@
|
||||
package de.steamwar.bausystem.features.script.lua.libs;
|
||||
|
||||
import de.steamwar.bausystem.features.loader.Loader;
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
||||
import de.steamwar.bausystem.region.RegionSystem;
|
||||
import de.steamwar.bausystem.region.flags.*;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.luaj.vm2.LuaTable;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
import org.luaj.vm2.lib.OneArgFunction;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Linked
|
||||
@ -46,27 +43,25 @@ public class RegionLib implements LuaLib {
|
||||
private LuaTable create(Supplier<Region> region, Player player) {
|
||||
LuaTable table = LuaValue.tableOf();
|
||||
|
||||
table.set("name", getter(() -> region.get().getName()));
|
||||
table.set("name", getter(() -> region.get().getID().toString()));
|
||||
table.set("id", getter(() -> region.get().getID().toString()));
|
||||
table.set("type", getter(() -> {
|
||||
Region region1 = region.get();
|
||||
if (region1 instanceof GlobalRegion) {
|
||||
if (region1.getType().isGlobal()) {
|
||||
return "global";
|
||||
} else {
|
||||
return region1.getPrototype().getName();
|
||||
}
|
||||
return region1.getType().name().toLowerCase();
|
||||
}));
|
||||
|
||||
LuaValue tntLib = LuaValue.tableOf();
|
||||
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("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));
|
||||
|
||||
tntLib.set("mode", getter(() -> region.get().getFlags().get(Flag.TNT).nameWithDefault()));
|
||||
tntLib.set("enabled", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) != TNTMode.DENY));
|
||||
tntLib.set("onlyTb", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) == TNTMode.ONLY_TB));
|
||||
table.set("tnt", tntLib);
|
||||
|
||||
table.set("fire", getter(() -> region.get().getPlain(Flag.FIRE, FireMode.class) == FireMode.ALLOW));
|
||||
table.set("freeze", getter(() -> region.get().getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE));
|
||||
table.set("protect", getter(() -> region.get().getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.ACTIVE));
|
||||
table.set("fire", getter(() -> region.get().getFlags().get(Flag.FIRE).orElse(null) == FireMode.ALLOW));
|
||||
table.set("freeze", getter(() -> region.get().getFlags().get(Flag.FREEZE).orElse(null) == FreezeMode.ACTIVE));
|
||||
table.set("protect", getter(() -> region.get().getFlags().get(Flag.PROTECT).orElse(null) == ProtectMode.ACTIVE));
|
||||
|
||||
//LuaValue traceLib = LuaValue.tableOf();
|
||||
//traceLib.set("active", getter(() -> !region.get().isGlobal() && Recorder.INSTANCE.get(region.get()) instanceof ActiveTracer));
|
||||
@ -79,16 +74,16 @@ public class RegionLib implements LuaLib {
|
||||
Loader loader = Loader.getLoader(player);
|
||||
table.set("loader", getter(() -> loader == null ? "OFF" : loader.getStage().name()));
|
||||
|
||||
table.set("copyPoint", getter(() -> toPos(region.get().getCopyPoint())));
|
||||
table.set("minPointBuild", getter(() -> toPos(region.get().getMinPointBuild())));
|
||||
table.set("maxPointBuild", getter(() -> toPos(region.get().getMaxPointBuild())));
|
||||
table.set("minPointBuildExtension", getter(() -> toPos(region.get().getMinPointBuildExtension())));
|
||||
table.set("maxPointBuildExtension", getter(() -> toPos(region.get().getMaxPointBuildExtension())));
|
||||
table.set("testblockPoint", getter(() -> toPos(region.get().getTestBlockPoint())));
|
||||
table.set("minPointTestblock", getter(() -> toPos(region.get().getMinPointTestblock())));
|
||||
table.set("maxPointTestblock", getter(() -> toPos(region.get().getMaxPointTestblock())));
|
||||
table.set("minPointTestblockExtension", getter(() -> toPos(region.get().getMinPointTestblockExtension())));
|
||||
table.set("maxPointTestblockExtension", getter(() -> toPos(region.get().getMaxPointTestblockExtension())));
|
||||
table.set("copyPoint", getter(() -> toPos(region.get().getBuildArea().getCopyPoint())));
|
||||
table.set("minPointBuild", getter(() -> toPos(region.get().getBuildArea().getMinPoint(false))));
|
||||
table.set("maxPointBuild", getter(() -> toPos(region.get().getBuildArea().getMinPoint(false))));
|
||||
table.set("minPointBuildExtension", getter(() -> toPos(region.get().getBuildArea().getMinPoint(true))));
|
||||
table.set("maxPointBuildExtension", getter(() -> toPos(region.get().getBuildArea().getMinPoint(true))));
|
||||
table.set("testblockPoint", getter(() -> toPos(region.get().getTestblockArea().getCopyPoint())));
|
||||
table.set("minPointTestblock", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(false))));
|
||||
table.set("maxPointTestblock", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(false))));
|
||||
table.set("minPointTestblockExtension", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(true))));
|
||||
table.set("maxPointTestblockExtension", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(true))));
|
||||
|
||||
return table;
|
||||
}
|
||||
@ -99,11 +94,11 @@ public class RegionLib implements LuaLib {
|
||||
table.set("get", new OneArgFunction() {
|
||||
@Override
|
||||
public LuaValue call(LuaValue arg) {
|
||||
return create(() -> Region.getREGION_MAP().get(arg.checkjstring()), player);
|
||||
return create(() -> RegionSystem.INSTANCE.getRegion(UUID.fromString(arg.checkjstring())).orElse(RegionSystem.INSTANCE.getGlobalRegion()), player);
|
||||
}
|
||||
});
|
||||
|
||||
table.set("list", getter(() -> LuaValue.listOf(Region.getREGION_MAP().values().stream().map(region -> create(() -> region, player)).toArray(LuaTable[]::new))));
|
||||
table.set("list", getter(() -> LuaValue.listOf(RegionSystem.INSTANCE.getRegions().map(region -> create(() -> region, player)).toArray(LuaTable[]::new))));
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
@ -24,9 +24,7 @@ import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.luaj.vm2.LuaTable;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
import org.luaj.vm2.Varargs;
|
||||
import org.luaj.vm2.lib.TwoArgFunction;
|
||||
import org.luaj.vm2.lib.VarArgFunction;
|
||||
|
||||
@Linked
|
||||
|
||||
@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.script.lua.libs;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.features.loader.Loader;
|
||||
import de.steamwar.bausystem.features.loader.LoaderRecorder;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
|
||||
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.script.lua.libs;
|
||||
|
||||
import com.google.gson.*;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionSystem;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.api.Disable;
|
||||
@ -74,7 +75,7 @@ public class StorageLib implements LuaLib, Enable, Disable {
|
||||
jsonObject.keySet().forEach(key -> {
|
||||
map.put(key, fromJson(jsonObject.get(key)));
|
||||
});
|
||||
Region region = Region.getREGION_MAP().get(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length()));
|
||||
Region region = RegionSystem.INSTANCE.getRegion(UUID.fromString(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length()))).orElse(null);
|
||||
REGION_STORAGE.put(region, map);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
@ -143,7 +144,7 @@ public class StorageLib implements LuaLib, Enable, Disable {
|
||||
regionStorageDirectory.mkdirs();
|
||||
for (Map.Entry<Region, HashMap<String, LuaValue>> entry : REGION_STORAGE.entrySet()) {
|
||||
try {
|
||||
FileWriter fileWriter = new FileWriter(new File(regionStorageDirectory, entry.getKey().getName() + ".json"));
|
||||
FileWriter fileWriter = new FileWriter(new File(regionStorageDirectory, entry.getKey().getID().toString() + ".json"));
|
||||
gson.toJson(toJson(entry.getValue()), fileWriter);
|
||||
fileWriter.close();
|
||||
} catch (IOException e) {}
|
||||
|
||||
@ -54,7 +54,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
|
||||
@Register
|
||||
public void genericCommand(@Validator Player player, ShieldPrintingState shieldPrintingState) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.isGlobal()) {
|
||||
if (region.getType().isGlobal()) {
|
||||
BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player);
|
||||
return;
|
||||
}
|
||||
@ -90,7 +90,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
|
||||
@Register("stop")
|
||||
public void stopCommand(@Validator Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.isGlobal()) {
|
||||
if (region.getType().isGlobal()) {
|
||||
BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player);
|
||||
return;
|
||||
}
|
||||
@ -111,7 +111,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
|
||||
return false;
|
||||
}
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.isGlobal()) {
|
||||
if (region.getType().isGlobal()) {
|
||||
messageSender.send("SHIELD_PRINTING_NO_REGION", player);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.shieldprinting.BlockDataConfiguration;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Piston;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@ -33,7 +33,6 @@ import yapion.hierarchy.types.YAPIONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
@Getter
|
||||
|
||||
@ -25,8 +25,6 @@ import lombok.Setter;
|
||||
import org.bukkit.util.Vector;
|
||||
import yapion.hierarchy.types.YAPIONObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
@Getter
|
||||
|
||||
@ -23,7 +23,6 @@ import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
|
||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@ -65,7 +64,7 @@ public final class TNTPhase extends SimulatorPhase {
|
||||
@Override
|
||||
public void accept(World world) {
|
||||
Location location = position.toLocation(world);
|
||||
if (Region.getRegion(location).get(Flag.FREEZE) == FreezeMode.ACTIVE) return;
|
||||
if (Region.getRegion(location).getFlags().get(Flag.FREEZE).isPresent()) return;
|
||||
TNTPrimed tnt = world.spawn(location, TNTPrimed.class);
|
||||
if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0));
|
||||
if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0));
|
||||
|
||||
@ -45,7 +45,7 @@ public class StabDirection extends StabStep {
|
||||
@Override
|
||||
protected void start() {
|
||||
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
|
||||
e.setBlocks((com.sk89q.worldedit.regions.Region) new CuboidRegion(data.region.getMinPointTestblockExtension().toBlockVector3(), data.region.getMaxPointTestblockExtension().toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
|
||||
e.setBlocks((com.sk89q.worldedit.regions.Region) new CuboidRegion(data.region.getTestblockArea().getMinPoint(true).toBlockVector3(), data.region.getTestblockArea().getMaxPoint(true).toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
|
||||
}
|
||||
|
||||
Trace trace = TraceRecorder.instance.startRecording(data.region);
|
||||
|
||||
@ -19,12 +19,8 @@
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.execute;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.Trace;
|
||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||
|
||||
@ -38,9 +34,11 @@ public class StabFinalizer extends StabStep {
|
||||
protected void start() {
|
||||
try {
|
||||
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
||||
.color(data.region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
||||
data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION);
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
|
||||
if (data.region.getFlags().has(Flag.COLOR).isReadable()) {
|
||||
pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||
}
|
||||
data.region.getTestblockArea().reset(pasteBuilder, true);
|
||||
} catch (SecurityException e) {
|
||||
stop();
|
||||
throw e;
|
||||
|
||||
@ -22,9 +22,6 @@ package de.steamwar.bausystem.features.simulator.execute;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -56,7 +53,8 @@ public class StabGenerator extends StabStep implements Listener {
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
if (Region.getRegion(event.getEntity().getLocation()) == data.region) {
|
||||
event.blockList().forEach(block -> {
|
||||
if (!data.region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) return;
|
||||
if (!data.region.getTestblockArea().inRegion(block.getLocation(), true))
|
||||
return;
|
||||
int component = data.direction.component.apply(block.getLocation().toVector());
|
||||
destroyedBlocksPerSlice.computeIfAbsent(component, __ -> new HashSet<>())
|
||||
.add(block.getLocation());
|
||||
@ -72,9 +70,11 @@ public class StabGenerator extends StabStep implements Listener {
|
||||
protected void start() {
|
||||
try {
|
||||
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
||||
.color(data.region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
||||
data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION);
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
|
||||
if (data.region.getFlags().has(Flag.COLOR).isReadable()) {
|
||||
pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||
}
|
||||
data.region.getTestblockArea().reset(pasteBuilder, true);
|
||||
} catch (SecurityException e) {
|
||||
stop();
|
||||
throw e;
|
||||
|
||||
@ -72,7 +72,7 @@ public class StabSetup extends StabStep {
|
||||
if (TraceRecorder.instance.isAutoTraceEnabledInRegion(data.region)) {
|
||||
TraceRecorder.instance.removeAutoTraceRegion(data.region);
|
||||
}
|
||||
data.clipboard = FlatteningWrapper.impl.copy(data.region.getMinPointTestblockExtension(), data.region.getMaxPointTestblockExtension(), data.region.getTestBlockPoint());
|
||||
data.clipboard = FlatteningWrapper.impl.copy(data.region.getTestblockArea().getMinPoint(true), data.region.getTestblockArea().getMaxPoint(true), data.region.getTestblockArea().getCopyPoint());
|
||||
|
||||
new StabDirection(data);
|
||||
}
|
||||
|
||||
@ -20,12 +20,10 @@
|
||||
package de.steamwar.bausystem.features.slaves.laufbau;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
@ -20,14 +20,12 @@
|
||||
package de.steamwar.bausystem.features.slaves.panzern;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
@ -19,11 +19,10 @@
|
||||
|
||||
package de.steamwar.bausystem.features.team;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.team.boundary.BoundaryViewer;
|
||||
import de.steamwar.bausystem.region.Prototype;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
@ -69,14 +68,14 @@ public class SkinCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (region.isGlobal()) {
|
||||
if (region.getType().isGlobal()) {
|
||||
BauSystem.MESSAGE.send("SKIN_NO_REGION", p);
|
||||
return;
|
||||
}
|
||||
|
||||
String name = String.join(" ", names);
|
||||
File arenaFile = new File("sections19/" + name + "/" + typeKuerzel + "Arena.schem");
|
||||
File testblockFile = region.hasType(RegionType.TESTBLOCK) ? new File("sections19/" + name + "/" + typeKuerzel + "Testblock.schem") : null;
|
||||
File testblockFile = !region.getTestblockArea().isEmpty() ? new File("sections19/" + name + "/" + typeKuerzel + "Testblock.schem") : null;
|
||||
|
||||
arenaFile.getParentFile().mkdirs();
|
||||
if (testblockFile != null) {
|
||||
@ -91,9 +90,11 @@ public class SkinCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
Region.copy(region.getMinPoint(), region.getMaxPoint(), arenaFile);
|
||||
EditSession editSession = region.getArea().copy(false);
|
||||
// TODO: Save editSession to file
|
||||
if (testblockFile != null) {
|
||||
Region.copy(region.getMinPointTestblock(), region.getMaxPointTestblock(), testblockFile);
|
||||
editSession = region.getTestblockArea().copy(false);
|
||||
// TODO: Save editSession to file
|
||||
}
|
||||
|
||||
YAPIONObject yapionObject = new YAPIONObject();
|
||||
@ -22,9 +22,7 @@ package de.steamwar.bausystem.features.team.boundary;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.core.TrickyParticleWrapper;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Particle;
|
||||
@ -48,22 +46,19 @@ public class BoundaryViewer implements Listener {
|
||||
}
|
||||
viewers.forEach(player -> {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.isGlobal()) return;
|
||||
if (region.getType().isGlobal()) return;
|
||||
showRegion(region, player);
|
||||
if (region.getLinkedRegion() != null) {
|
||||
showRegion(region.getLinkedRegion(), player);
|
||||
}
|
||||
});
|
||||
}, 20, 20);
|
||||
}
|
||||
|
||||
private void showRegion(Region region, Player player) {
|
||||
drawCuboid(player, TrickyParticleWrapper.impl.getVillagerHappy(), region.getMinPoint(), region.getMaxPoint());
|
||||
if (region.hasType(RegionType.TESTBLOCK)) {
|
||||
drawCuboid(player, Particle.END_ROD, region.getMinPointTestblockExtension(), region.getMaxPointTestblockExtension());
|
||||
drawCuboid(player, TrickyParticleWrapper.impl.getVillagerHappy(), region.getArea().getMinPoint(false), region.getArea().getMaxPoint(false));
|
||||
if (!region.getTestblockArea().isEmpty()) {
|
||||
drawCuboid(player, Particle.END_ROD, region.getTestblockArea().getMinPoint(true), region.getTestblockArea().getMaxPoint(true));
|
||||
}
|
||||
if (region.hasType(RegionType.BUILD)) {
|
||||
drawCuboid(player, Particle.END_ROD, region.getMinPointBuildExtension(), region.getMaxPointBuildExtension());
|
||||
if (!region.getBuildArea().isEmpty()) {
|
||||
drawCuboid(player, Particle.END_ROD, region.getBuildArea().getMinPoint(true), region.getBuildArea().getMaxPoint(true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -63,32 +63,22 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
|
||||
@Register(description = "TECHHIDER_HELP")
|
||||
public void toggleHider(@Validator Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.isGlobal()) {
|
||||
if (region.getType().isGlobal()) {
|
||||
BauSystem.MESSAGE.send("TECHHIDER_GLOBAL", player);
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<TechHider> techHider = techHiders.computeIfAbsent(region, rg -> {
|
||||
File file = rg.gameModeConfig();
|
||||
if (file == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
if (!config.getBoolean("Techhider.Active", false)) {
|
||||
if (!region.getGameModeConfig().getTechhider().isActive()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
hidden.put(rg, new HashSet<>());
|
||||
|
||||
String obfuscateWith = config.getString("Techhider.ObfuscateWith", "end_stone");
|
||||
Set<String> hiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlocks")));
|
||||
Set<String> hiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
|
||||
|
||||
TechHider current = new TechHider((TechHider.LocationEvaluator) (p, cX, cY) -> {
|
||||
if (rg.buildChunkOutside(cX, cY)) return true;
|
||||
TechHider current = new TechHider((p, cX, cY) -> {
|
||||
if (rg.getBuildArea().isChunkOutside(cX, cY)) return true;
|
||||
return !hidden.get(rg).contains(p);
|
||||
}, Material.valueOf(obfuscateWith.toUpperCase()), hiddenBlocks.stream().map(String::toUpperCase).map(Material::valueOf).collect(Collectors.toSet()), hiddenBlockEntities);
|
||||
}, region.getGameModeConfig().getTechhider().getObfuscateWith(), region.getGameModeConfig().getTechhider().getHiddenBlocks(), region.getGameModeConfig().getTechhider().getHiddenBlockEntities());
|
||||
current.enable();
|
||||
|
||||
return Optional.of(current);
|
||||
@ -105,7 +95,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
|
||||
hidden.get(region).add(player);
|
||||
BauSystem.MESSAGE.sendPrefixless("TECHHIDER_ON", player, ChatMessageType.ACTION_BAR);
|
||||
}
|
||||
region.forEachChunk((x, z) -> {
|
||||
region.getBuildArea().forEachChunk((x, z) -> {
|
||||
CraftbukkitWrapper.impl.sendChunk(player, x, z);
|
||||
});
|
||||
}
|
||||
|
||||
@ -24,7 +24,6 @@ import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import lombok.ToString;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
|
||||
@ -20,8 +20,6 @@
|
||||
package de.steamwar.bausystem.features.testblock.blockcounter;
|
||||
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -37,11 +35,13 @@ public class BlockCounterListener implements Listener {
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
Region region = Region.getRegion(event.getLocation());
|
||||
if (region.isGlobal()) {
|
||||
if (region.getType().isGlobal()) {
|
||||
return;
|
||||
}
|
||||
List<Block> blockList = event.blockList();
|
||||
blockList = blockList.stream().filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)).collect(Collectors.toList());
|
||||
blockList = blockList.stream()
|
||||
.filter(block -> region.getTestblockArea().inRegion(block.getLocation(), true))
|
||||
.collect(Collectors.toList());
|
||||
if (blockList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.bausystem.utils.TickEndEvent;
|
||||
@ -85,14 +84,14 @@ public class TPSSystem implements Listener {
|
||||
private void bossbar() {
|
||||
if ((TickManager.impl.isStepping() || TickManager.impl.isSprinting()) && TickManager.impl.getRemainingTicks() > 0) {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "TickStep");
|
||||
BauSystemBossbar bossbar = BossBarService.instance.get(player, Region.getGlobalRegion(), "TickStep");
|
||||
bossbar.setColor(BarColor.YELLOW);
|
||||
bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, TickManager.impl.getDoneTicks(), TickManager.impl.getTotalTicks()));
|
||||
bossbar.setProgress(TickManager.impl.getDoneTicks() / (double) TickManager.impl.getTotalTicks());
|
||||
});
|
||||
} else {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
|
||||
BossBarService.instance.remove(player, Region.getGlobalRegion(), "TickStep");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,8 +20,6 @@
|
||||
package de.steamwar.bausystem.features.tracer;
|
||||
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.core.Core;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -39,7 +37,7 @@ import java.util.Optional;
|
||||
*/
|
||||
@AllArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
@Getter
|
||||
public class TNTPoint{
|
||||
public class TNTPoint {
|
||||
/**
|
||||
* Unique number to identify records being of the same tnt
|
||||
*/
|
||||
@ -99,7 +97,7 @@ public class TNTPoint{
|
||||
* Constructor for object creation in trace recording
|
||||
*/
|
||||
protected TNTPoint(int tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart,
|
||||
List<TNTPoint> history, List<Block> destroyedBlocks) {
|
||||
List<TNTPoint> history, List<Block> destroyedBlocks) {
|
||||
this.tntId = tntId;
|
||||
this.explosion = explosion;
|
||||
if (Core.getVersion() > 15) {
|
||||
@ -117,12 +115,10 @@ public class TNTPoint{
|
||||
boolean buildDestroy = false;
|
||||
boolean testblockDestroy = false;
|
||||
for (Block destroyedBlock : destroyedBlocks) {
|
||||
if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(), RegionType.BUILD,
|
||||
RegionExtensionType.EXTENSION)) {
|
||||
if (Region.getRegion(destroyedBlock.getLocation()).getBuildArea().inRegion(destroyedBlock.getLocation(), true)) {
|
||||
buildDestroy = true;
|
||||
}
|
||||
if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(),
|
||||
RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) {
|
||||
if (Region.getRegion(destroyedBlock.getLocation()).getTestblockArea().inRegion(destroyedBlock.getLocation(), true)) {
|
||||
testblockDestroy = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,12 +25,10 @@ import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.AtFlag;
|
||||
import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.IsolateFlag;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package de.steamwar.bausystem.features.tracer;
|
||||
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionSystem;
|
||||
import lombok.Cleanup;
|
||||
import lombok.SneakyThrows;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -17,7 +18,7 @@ public class TraceRepository {
|
||||
/**
|
||||
* Increment this when changing serialisation format
|
||||
*/
|
||||
public static final int SERIALISATION_VERSION = 2;
|
||||
public static final int SERIALISATION_VERSION = 3;
|
||||
public static final int WRITE_TICK_DATA = 0b00000001;
|
||||
public static final int EXPLOSION = 0b00000010;
|
||||
public static final int IN_WATER = 0b00000100;
|
||||
@ -31,7 +32,8 @@ public class TraceRepository {
|
||||
@Cleanup
|
||||
ObjectInputStream reader = new ObjectInputStream(new GZIPInputStream(new FileInputStream(recordsFile)));
|
||||
UUID uuid = UUID.fromString(reader.readUTF());
|
||||
Region region = Region.getREGION_MAP().get(reader.readUTF());
|
||||
Region region = RegionSystem.INSTANCE.getRegion(UUID.fromString(reader.readUTF())).orElse(null);
|
||||
if (region == null) return null;
|
||||
Date date = (Date) reader.readObject();
|
||||
int serialisationVersion = reader.readInt();
|
||||
if (serialisationVersion != SERIALISATION_VERSION) {
|
||||
@ -46,7 +48,7 @@ public class TraceRepository {
|
||||
protected static void writeTrace(Trace trace, List<TNTPoint> records) {
|
||||
ObjectOutputStream outputStream = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(trace.getRecordsSaveFile())));
|
||||
outputStream.writeUTF(trace.getUuid().toString());
|
||||
outputStream.writeUTF(trace.getRegion().getName());
|
||||
outputStream.writeUTF(trace.getRegion().getID().toString());
|
||||
outputStream.writeObject(trace.getDate());
|
||||
outputStream.writeInt(SERIALISATION_VERSION);
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.features.script.ScriptCommand;
|
||||
import de.steamwar.bausystem.features.script.ScriptRunner;
|
||||
import de.steamwar.bausystem.features.world.WorldEditListener;
|
||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||
@ -28,10 +27,12 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@ -20,9 +20,7 @@
|
||||
package de.steamwar.bausystem.features.util;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -21,12 +21,8 @@ package de.steamwar.bausystem.features.util;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionSelectionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -53,7 +49,7 @@ public class KillAllCommand extends SWCommand {
|
||||
public void genericCommand(@Validator Player player, RegionSelectionType regionSelectionType) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
AtomicLong count = new AtomicLong(0);
|
||||
if (regionSelectionType == RegionSelectionType.GLOBAL || GlobalRegion.getInstance() == region) {
|
||||
if (regionSelectionType == RegionSelectionType.GLOBAL || region.getType().isGlobal()) {
|
||||
WORLD.getEntities()
|
||||
.stream()
|
||||
.filter(e -> !(e instanceof Player))
|
||||
@ -66,7 +62,7 @@ public class KillAllCommand extends SWCommand {
|
||||
WORLD.getEntities()
|
||||
.stream()
|
||||
.filter(e -> !(e instanceof Player))
|
||||
.filter(e -> region.inRegion(e.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL))
|
||||
.filter(e -> region.getArea().inRegion(e.getLocation(), false))
|
||||
.forEach(entity -> {
|
||||
entity.remove();
|
||||
count.incrementAndGet();
|
||||
@ -74,5 +70,4 @@ public class KillAllCommand extends SWCommand {
|
||||
RegionUtils.actionBar(region, "OTHER_KILLALL_REGION", count.get());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
package de.steamwar.bausystem.features.util;
|
||||
|
||||
public enum RegionSelectionType {
|
||||
LOCAL,
|
||||
GLOBAL,
|
||||
;
|
||||
}
|
||||
@ -1,14 +1,12 @@
|
||||
package de.steamwar.bausystem.features.util;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -23,19 +21,15 @@ public class SelectCommand extends SWCommand {
|
||||
public void baurahmenCommand(@Validator Player p, RegionType regionType, @OptionalValue("NORMAL") RegionExtensionType regionExtensionType) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
|
||||
if (region.isGlobal()) {
|
||||
if (region.getType().isGlobal()) {
|
||||
BauSystem.MESSAGE.send("SELECT_GLOBAL_REGION", p);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!region.hasType(regionType)) {
|
||||
if (!regionType.getHasType().test(region)) {
|
||||
BauSystem.MESSAGE.send("SELECT_NO_TYPE", p, BauSystem.MESSAGE.parse(regionType.getChatValue(), p));
|
||||
return;
|
||||
}
|
||||
if (regionExtensionType == RegionExtensionType.EXTENSION && !region.hasExtensionType(regionType)) {
|
||||
BauSystem.MESSAGE.send("SELECT_NO_EXTENSION", p);
|
||||
return;
|
||||
}
|
||||
|
||||
setSelection(regionType, regionExtensionType, region, p);
|
||||
}
|
||||
@ -46,8 +40,8 @@ public class SelectCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private void setSelection(RegionType regionType, RegionExtensionType regionExtensionType, Region region, Player p) {
|
||||
Point minPoint = region.getMinPoint(regionType, regionExtensionType);
|
||||
Point maxPoint = region.getMaxPoint(regionType, regionExtensionType);
|
||||
Point minPoint = regionType.getToMinPoint().apply(region, regionExtensionType.isExtension());
|
||||
Point maxPoint = regionType.getToMaxPoint().apply(region, regionExtensionType.isExtension());
|
||||
|
||||
FlatteningWrapper.impl.setSelection(p, minPoint, maxPoint);
|
||||
BauSystem.MESSAGE.send("SELECT_MESSAGE", p, minPoint.getX(), minPoint.getY(), minPoint.getZ(), maxPoint.getX(), maxPoint.getY(), maxPoint.getZ());
|
||||
|
||||
@ -20,8 +20,9 @@
|
||||
package de.steamwar.bausystem.features.util;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.command.*;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -23,7 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.features.util.KillAllCommand;
|
||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||
import de.steamwar.bausystem.region.utils.RegionSelectionType;
|
||||
import de.steamwar.bausystem.features.util.RegionSelectionType;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
|
||||
@ -19,8 +19,8 @@
|
||||
|
||||
package de.steamwar.bausystem.features.warp;
|
||||
|
||||
import de.steamwar.bausystem.region.RegionSystem;
|
||||
import de.steamwar.bausystem.worlddata.WorldData;
|
||||
import de.steamwar.core.Core;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -36,7 +36,7 @@ public class Warp {
|
||||
|
||||
public static void enable() {
|
||||
Warp worldSpawn = new Warp("WorldSpawn");
|
||||
worldSpawn.setLocation(Bukkit.getWorlds().get(0).getSpawnLocation().clone().add(0.5, Core.getVersion() >= 20 ? 124 : 1, 0.5));
|
||||
worldSpawn.setLocation(RegionSystem.INSTANCE.getWorldSpawn());
|
||||
worldSpawn.setMat(Material.NETHER_STAR);
|
||||
warpMap.put("WorldSpawn", worldSpawn);
|
||||
}
|
||||
|
||||
@ -20,13 +20,11 @@
|
||||
package de.steamwar.bausystem.features.warp;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.utils.ListChatView;
|
||||
import de.steamwar.bausystem.worlddata.WorldData;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.api.Disable;
|
||||
import de.steamwar.linkage.api.Enable;
|
||||
|
||||
@ -91,11 +91,11 @@ public class WarpListener implements Listener {
|
||||
locations.put(warp.getName(), warp.getLocation());
|
||||
});
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (region.getCopyPoint() != null) {
|
||||
locations.put("Copy", region.getCopyPoint().toLocation(p).add(0.5, 0, 0.5));
|
||||
if (!region.getBuildArea().isEmpty()) {
|
||||
locations.put("Copy", region.getBuildArea().getCopyPoint().toLocation(p).add(0.5, 0, 0.5));
|
||||
}
|
||||
if (region.getTestBlockPoint() != null) {
|
||||
locations.put("TestBlock", region.getTestBlockPoint().toLocation(p).add(0.5, 0, 0.5));
|
||||
if (!region.getTestblockArea().isEmpty()) {
|
||||
locations.put("TestBlock", region.getTestblockArea().getCopyPoint().toLocation(p).add(0.5, 0, 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ package de.steamwar.bausystem.features.world;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.RegionSystem;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||
@ -75,7 +75,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
|
||||
SPECTATORS.remove(player);
|
||||
newBuilder.add(player);
|
||||
player.removePotionEffect(PotionEffectType.GLOWING);
|
||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "spectator");
|
||||
BossBarService.instance.remove(player, RegionSystem.INSTANCE.getGlobalRegion(), "spectator");
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -94,7 +94,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
|
||||
}
|
||||
|
||||
private static void showSpectatorNotice(Player player) {
|
||||
BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "spectator");
|
||||
BauSystemBossbar bossbar = BossBarService.instance.get(player, RegionSystem.INSTANCE.getGlobalRegion(), "spectator");
|
||||
bossbar.setTitle(BauSystem.MESSAGE.parse("SPECTATOR", player));
|
||||
bossbar.setColor(BarColor.WHITE);
|
||||
bossbar.setStyle(BarStyle.SOLID);
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
package de.steamwar.bausystem.features.world;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@ -101,8 +100,11 @@ public class BauScoreboard implements Listener {
|
||||
@Override
|
||||
public String getTitle() {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (GlobalRegion.getInstance() == region) return "§eSteam§8War";
|
||||
String colorCode = BauSystem.MESSAGE.parse(region.get(Flag.COLOR).getChatValue(), player).substring(0, 2);
|
||||
if (region.getType().isGlobal()) return "§eSteam§8War";
|
||||
String colorCode = "§e";
|
||||
if (region.getFlags().has(Flag.COLOR).isReadable()) {
|
||||
colorCode = "§" + region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK).getColorCode();
|
||||
}
|
||||
return colorCode + "■ §eSteam§8War " + colorCode + "■"; // ■
|
||||
}
|
||||
});
|
||||
|
||||
@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.world;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@ -32,7 +32,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.checkerframework.checker.units.qual.min;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
@ -28,7 +28,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import de.steamwar.bausystem.features.world.WorldEditListener;
|
||||
import de.steamwar.bausystem.features.worldedit.utils.SpecialReplace;
|
||||
import de.steamwar.bausystem.region.Color;
|
||||
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
@ -63,7 +63,7 @@ public class ColorReplaceCommand extends SWCommand {
|
||||
|
||||
@Register(description = "COLORREPLACE_HELP")
|
||||
@SneakyThrows
|
||||
public void genericCommand(@Validator Player player, Pair<Integer, Color> from, Color to) {
|
||||
public void genericCommand(@Validator Player player, Pair<Integer, ColorMode> from, ColorMode to) {
|
||||
if (from.getValue() == to) {
|
||||
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)}));
|
||||
return;
|
||||
@ -89,23 +89,23 @@ public class ColorReplaceCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@ClassMapper(value = Pair.class, local = true)
|
||||
public TypeMapper<Pair<Integer, Color>> typeMapper() {
|
||||
return new TypeMapper<Pair<Integer, Color>>() {
|
||||
public TypeMapper<Pair<Integer, ColorMode>> typeMapper() {
|
||||
return new TypeMapper<Pair<Integer, ColorMode>>() {
|
||||
@Override
|
||||
public Pair<Integer, Color> map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||
public Pair<Integer, ColorMode> map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||
if (s.contains("%")) {
|
||||
String[] split = s.split("%");
|
||||
if (split.length != 2) {
|
||||
return null;
|
||||
}
|
||||
Color color = Color.valueOf(split[1].toUpperCase());
|
||||
ColorMode color = ColorMode.valueOf(split[1].toUpperCase());
|
||||
try {
|
||||
return new Pair<>(Integer.parseInt(split[0]), color);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new Pair<>(100, Color.valueOf(s.toUpperCase()));
|
||||
return new Pair<>(100, ColorMode.valueOf(s.toUpperCase()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -113,12 +113,12 @@ public class ColorReplaceCommand extends SWCommand {
|
||||
if (s.matches("[0-9].*")) {
|
||||
if (s.contains("%")) {
|
||||
String sub = s.substring(0, s.indexOf("%") + 1);
|
||||
return Arrays.stream(Color.values()).map(Color::name).map(t -> sub + t.toLowerCase()).collect(Collectors.toSet());
|
||||
return Arrays.stream(ColorMode.values()).map(ColorMode::name).map(t -> sub + t.toLowerCase()).collect(Collectors.toSet());
|
||||
} else {
|
||||
return Arrays.asList(s);
|
||||
}
|
||||
} else {
|
||||
return Arrays.stream(Color.values()).map(Color::name).map(String::toLowerCase).collect(Collectors.toSet());
|
||||
return Arrays.stream(ColorMode.values()).map(ColorMode::name).map(String::toLowerCase).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -19,8 +19,8 @@
|
||||
|
||||
package de.steamwar.bausystem.features.xray;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.techhider.TechHiderCommand;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
@ -34,8 +34,6 @@ import de.steamwar.techhider.TechHider;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -43,7 +41,6 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@ -64,30 +61,20 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
||||
@Register(description = "XRAY_HELP")
|
||||
public void toggleHider(@Validator Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.isGlobal()) {
|
||||
if (region.getType().isGlobal()) {
|
||||
BauSystem.MESSAGE.send("XRAY_GLOBAL", player);
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<TechHider> techHider = techHiders.computeIfAbsent(region, rg -> {
|
||||
File file = rg.gameModeConfig();
|
||||
if (file == null) {
|
||||
if (!region.getGameModeConfig().getTechhider().isActive()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
if (!config.getBoolean("Techhider.Active", false)) {
|
||||
Set<Material> blocks = new HashSet<>(Arrays.asList(Material.END_STONE, Material.IRON_BLOCK));
|
||||
xrayedBlocks.put(region, blocks);
|
||||
return Optional.of(createXray(rg, blocks));
|
||||
}
|
||||
|
||||
hidden.put(rg, new HashSet<>());
|
||||
|
||||
String obfuscateWith = config.getString("Techhider.ObfuscateWith", "end_stone");
|
||||
|
||||
Set<Material> blocks = new HashSet<>(Arrays.asList(Material.getMaterial(obfuscateWith.toUpperCase())));
|
||||
if (obfuscateWith.equals("end_stone")) blocks.add(Material.END_STONE_BRICKS);
|
||||
Set<Material> blocks = new HashSet<>(Arrays.asList(region.getGameModeConfig().getTechhider().getObfuscateWith()));
|
||||
if (blocks.contains(Material.END_STONE)) blocks.add(Material.END_STONE_BRICKS);
|
||||
xrayedBlocks.put(region, blocks);
|
||||
return Optional.of(createXray(rg, blocks));
|
||||
});
|
||||
@ -103,7 +90,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
||||
hidden.get(region).add(player);
|
||||
BauSystem.MESSAGE.sendPrefixless("XRAY_ON", player, ChatMessageType.ACTION_BAR);
|
||||
}
|
||||
region.forEachChunk((x, z) -> {
|
||||
region.getBuildArea().forEachChunk((x, z) -> {
|
||||
CraftbukkitWrapper.impl.sendChunk(player, x, z);
|
||||
});
|
||||
}
|
||||
@ -149,7 +136,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
||||
|
||||
private TechHider createXray(Region rg, Set<Material> obfuscate) {
|
||||
TechHider current = new TechHider((TechHider.LocationEvaluator) (p, cX, cY) -> {
|
||||
if (rg.buildChunkOutside(cX, cY)) return true;
|
||||
if (rg.getBuildArea().isChunkOutside(cX, cY)) return true;
|
||||
return !hidden.get(rg).contains(p);
|
||||
}, Material.STRUCTURE_VOID, obfuscate, new HashSet<>());
|
||||
current.enable();
|
||||
|
||||
@ -1,32 +1,14 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.tags.Tag;
|
||||
import de.steamwar.bausystem.region.flags.ChangedMode;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.api.Enable;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Linked
|
||||
public class BackupScheduler implements Enable {
|
||||
@ -39,24 +21,30 @@ public class BackupScheduler implements Enable {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Iterator<Region> regions = Region.getREGION_MAP().values().stream().filter(region -> region.get(Tag.CHANGED)).iterator();
|
||||
BackupScheduler.this.doBackup(regions);
|
||||
Iterator<Region> regionsToBackup = RegionSystem.INSTANCE.getRegions()
|
||||
.filter(region -> region.getFlags().has(Flag.CHANGED).isReadable())
|
||||
.filter(region -> region.getFlags().get(Flag.CHANGED).get() == ChangedMode.HAS_CHANGE)
|
||||
.iterator();
|
||||
if (!regionsToBackup.hasNext()) return;
|
||||
doBackup(regionsToBackup);
|
||||
}
|
||||
}.runTaskTimer(BauSystem.getInstance(), INITIAL, PERIOD);
|
||||
}
|
||||
|
||||
public void doBackup(final Iterator<Region> regionIterator) {
|
||||
private void doBackup(Iterator<Region> regionsToBackup) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!regionIterator.hasNext()) {
|
||||
if (!regionsToBackup.hasNext()) {
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
final Region region = regionIterator.next();
|
||||
if (region.backup()) {
|
||||
region.remove(Tag.CHANGED);
|
||||
Region region = regionsToBackup.next();
|
||||
Optional<RegionBackups.Backup> backup = region.getBackups()
|
||||
.create(RegionBackups.BackupType.AUTOMATIC);
|
||||
if (backup.isPresent()) {
|
||||
region.getFlags().set(Flag.CHANGED, ChangedMode.NO_CHANGE);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(BauSystem.getInstance(), 0, 20 * 60);
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
public enum Color {
|
||||
WHITE,
|
||||
ORANGE,
|
||||
MAGENTA,
|
||||
LIGHT_BLUE,
|
||||
YELLOW,
|
||||
LIME,
|
||||
PINK,
|
||||
GRAY,
|
||||
LIGHT_GRAY,
|
||||
CYAN,
|
||||
PURPLE,
|
||||
BLUE,
|
||||
BROWN,
|
||||
GREEN,
|
||||
RED,
|
||||
BLACK;
|
||||
}
|
||||
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class FlagOptional<T extends Enum<T> & Flag.Value<T>> {
|
||||
|
||||
private final Flag<T> flag;
|
||||
private final T value;
|
||||
|
||||
public static <T extends Enum<T> & Flag.Value<T>> FlagOptional<T> of(Flag<T> flag) {
|
||||
return new FlagOptional<>(flag, null);
|
||||
}
|
||||
|
||||
public static <T extends Enum<T> & Flag.Value<T>> FlagOptional<T> of(Flag<T> flag, T value) {
|
||||
return new FlagOptional<>(flag, value);
|
||||
}
|
||||
|
||||
public boolean isPresent() {
|
||||
return value != null;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return value == null;
|
||||
}
|
||||
|
||||
public boolean is(T value) {
|
||||
if (isEmpty()) return false;
|
||||
return this.value.equals(value);
|
||||
}
|
||||
|
||||
public boolean isNot(T value) {
|
||||
return !is(value);
|
||||
}
|
||||
|
||||
public boolean isWithDefault(T value) {
|
||||
if (isEmpty()) {
|
||||
return flag.getDefaultValue().equals(value);
|
||||
} else {
|
||||
return this.value.equals(value);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNotWithDefault(T value) {
|
||||
return !isWithDefault(value);
|
||||
}
|
||||
|
||||
public T get() {
|
||||
if (isEmpty()) {
|
||||
throw new NoSuchElementException("No value present");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public T getWithDefault() {
|
||||
if (isEmpty()) {
|
||||
return flag.getDefaultValue();
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public T orElse(T defaultValue) {
|
||||
if (isEmpty()) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<String> name() {
|
||||
if (isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(value.name());
|
||||
}
|
||||
|
||||
public String nameWithDefault() {
|
||||
return getWithDefault().name();
|
||||
}
|
||||
}
|
||||
@ -1,107 +1,40 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.tags.Tag;
|
||||
import yapion.hierarchy.types.YAPIONObject;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Tags and Flags are not allowed to have overlaping names.
|
||||
*/
|
||||
public class FlagStorage {
|
||||
public interface FlagStorage {
|
||||
|
||||
public static FlagStorage createStorage(YAPIONObject yapionObject) {
|
||||
FlagStorage flagStorage = new FlagStorage();
|
||||
for (final Flag flag : Flag.getFlags()) {
|
||||
try {
|
||||
String s = yapionObject.getPlainValue(flag.name());
|
||||
flagStorage.set(flag, flag.getFlagValueOf(s));
|
||||
} catch (Exception e) {
|
||||
flagStorage.set(flag, flag.getDefaultValue());
|
||||
}
|
||||
}
|
||||
for (final Tag tag : Tag.values()) {
|
||||
if (yapionObject.containsKey(tag.name())) {
|
||||
flagStorage.set(tag);
|
||||
}
|
||||
}
|
||||
return flagStorage;
|
||||
}
|
||||
@NonNull
|
||||
<T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy has(@NonNull Flag<T> flag);
|
||||
|
||||
public static YAPIONObject toYAPION(FlagStorage flagStorage) {
|
||||
YAPIONObject yapionObject = new YAPIONObject();
|
||||
for (final Flag flag : Flag.getFlags()) {
|
||||
if (flag.getDefaultValue() == flagStorage.flags.getOrDefault(flag, flag.getDefaultValue())) {
|
||||
yapionObject.remove(flag.name());
|
||||
} else {
|
||||
yapionObject.add(flag.name(), flagStorage.get(flag).getValue().name());
|
||||
}
|
||||
}
|
||||
for (Tag tag : Tag.values()) {
|
||||
if (flagStorage.tagSet.contains(tag)) {
|
||||
yapionObject.add(tag.name(), "");
|
||||
} else {
|
||||
yapionObject.remove(tag.name());
|
||||
}
|
||||
}
|
||||
return yapionObject;
|
||||
}
|
||||
<T extends Enum<T> & Flag.Value<T>> boolean set(@NonNull Flag<T> flag, @NonNull T value);
|
||||
|
||||
protected Map<Flag, Flag.Value<?>> flags;
|
||||
protected Set<Tag> tagSet;
|
||||
@NonNull
|
||||
<T extends Enum<T> & Flag.Value<T>> FlagOptional<T> get(@NonNull Flag<T> flag);
|
||||
|
||||
public FlagStorage() {
|
||||
flags = new EnumMap<>(Flag.class);
|
||||
tagSet = new HashSet<>();
|
||||
readKeys();
|
||||
}
|
||||
void clear();
|
||||
|
||||
public boolean set(final Flag flagType, final Flag.Value<?> value) {
|
||||
return flags.put(flagType, value) != value;
|
||||
}
|
||||
|
||||
public Flag.Value<?> get(final Flag flagType) {
|
||||
return flags.getOrDefault(flagType, flagType.getDefaultValue());
|
||||
}
|
||||
|
||||
public boolean set(final Tag tag) {
|
||||
return tagSet.add(tag);
|
||||
}
|
||||
|
||||
public boolean remove(final Tag tag) {
|
||||
return tagSet.remove(tag);
|
||||
}
|
||||
|
||||
public boolean is(final Tag tag) {
|
||||
return tagSet.contains(tag);
|
||||
}
|
||||
|
||||
private void readKeys() {
|
||||
for (final Flag flag : Flag.getFlags()) {
|
||||
flags.put(flag, flag.getDefaultValue());
|
||||
}
|
||||
}
|
||||
Map<Flag<?>, Flag.Value<?>> getBackedMap();
|
||||
}
|
||||
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import de.steamwar.core.FlatteningWrapper;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
public class GameModeConfig {
|
||||
|
||||
private final boolean loaded;
|
||||
|
||||
/**
|
||||
* See gamemode config Times key
|
||||
*/
|
||||
private Times Times = new Times();
|
||||
private Schematic Schematic = new Schematic();
|
||||
private Arena Arena = new Arena();
|
||||
private Server Server = new Server();
|
||||
private Techhider Techhider = new Techhider();
|
||||
|
||||
public GameModeConfig(File file) {
|
||||
if (file == null || !file.exists()) {
|
||||
loaded = false;
|
||||
return;
|
||||
}
|
||||
loaded = true;
|
||||
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
Times.load(config.getConfigurationSection("Times"));
|
||||
Schematic.load(config.getConfigurationSection("Schematic"));
|
||||
Arena.load(config.getConfigurationSection("Arena"));
|
||||
Server.load(config.getConfigurationSection("Server"));
|
||||
Techhider.load(config.getConfigurationSection("Techhider"));
|
||||
}
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@Getter
|
||||
public static class Times {
|
||||
private int PreFightDuration = 30;
|
||||
|
||||
private void load(ConfigurationSection section) {
|
||||
PreFightDuration = section.getInt("PreFightDuration", 30);
|
||||
}
|
||||
}
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@Getter
|
||||
public static class Schematic {
|
||||
private Map<Set<Material>, Integer> Limited = new HashMap<>();
|
||||
|
||||
private void load(ConfigurationSection section) {
|
||||
for(Map<?, ?> entry : section.getMapList("Limited")) {
|
||||
int amount = (Integer) entry.get("Amount");
|
||||
Set<String> materials = new HashSet<>((List<String>) entry.get("Materials"));
|
||||
if (amount == 0) {
|
||||
materials.forEach(material -> Limited.put(Collections.singleton(Material.getMaterial(material)), 0));
|
||||
} else {
|
||||
Limited.put(materials.stream().map(Material::getMaterial).collect(Collectors.toSet()), amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@Getter
|
||||
public static class Arena {
|
||||
private boolean NoFloor = false;
|
||||
|
||||
private void load(ConfigurationSection section) {
|
||||
NoFloor = section.getBoolean("NoFloor", false);
|
||||
}
|
||||
}
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@Getter
|
||||
public static class Server {
|
||||
private List<String> ChatNames;
|
||||
|
||||
private void load(ConfigurationSection section) {
|
||||
ChatNames = section.getStringList("ChatNames");
|
||||
}
|
||||
}
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@Getter
|
||||
public static class Techhider {
|
||||
private boolean Active = false;
|
||||
private Material ObfuscateWith = Material.END_STONE;
|
||||
private Set<Material> HiddenBlocks = new HashSet<>();
|
||||
private Set<String> HiddenBlockEntities = new HashSet<>();
|
||||
|
||||
private void load(ConfigurationSection section) {
|
||||
Active = section.getBoolean("Active", false);
|
||||
ObfuscateWith = Material.getMaterial(section.getString("ObfuscateWith", "END_STONE"));
|
||||
HiddenBlocks = section.getStringList("HiddenBlocks").stream().map(FlatteningWrapper.impl::getMaterial).filter(Objects::nonNull).collect(Collectors.toUnmodifiableSet());
|
||||
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(section.getStringList("HiddenBlockEntities")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
import yapion.hierarchy.types.YAPIONObject;
|
||||
|
||||
public class GlobalRegion extends Region {
|
||||
|
||||
@Getter
|
||||
static GlobalRegion instance;
|
||||
|
||||
public GlobalRegion(FlagStorage flagStorage, YAPIONObject regionData) {
|
||||
super("global", null, new YAPIONObject(), flagStorage, regionData);
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inRegion(Location location, RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,20 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.region;
|
||||
@ -34,6 +34,8 @@ import org.bukkit.entity.Player;
|
||||
@AllArgsConstructor
|
||||
public class Point {
|
||||
|
||||
public static final Point ZERO = new Point(0, 0, 0);
|
||||
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
|
||||
@ -1,584 +1,176 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
||||
import de.steamwar.bausystem.region.tags.Tag;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.shared.SizedStack;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import yapion.hierarchy.types.YAPIONObject;
|
||||
import yapion.hierarchy.types.YAPIONType;
|
||||
import yapion.hierarchy.types.YAPIONValue;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.ObjIntConsumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Getter
|
||||
public class Region {
|
||||
public interface Region {
|
||||
|
||||
@Getter
|
||||
private static final Map<String, Region> REGION_MAP = new HashMap<>();
|
||||
private static final File backupFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "backup");
|
||||
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd' 'HH:mm:ss");
|
||||
|
||||
public static Region getRegion(Location location) {
|
||||
return REGION_MAP.values().stream()
|
||||
.filter(r -> r.inRegion(location, r.minPoint, r.maxPoint))
|
||||
.findFirst()
|
||||
.orElse(GlobalRegion.instance);
|
||||
static Stream<Region> getRegions() {
|
||||
return RegionSystem.INSTANCE.getRegions();
|
||||
}
|
||||
|
||||
public static Set<Region> getRegion(Prototype prototype) {
|
||||
return REGION_MAP.values().stream()
|
||||
.filter(r -> r.getPrototype() == prototype)
|
||||
.collect(Collectors.toSet());
|
||||
static Region getRegion(Location location) {
|
||||
return RegionSystem.INSTANCE.get(location);
|
||||
}
|
||||
|
||||
public static void setGlobal(Flag flagType, Flag.Value<?> value) {
|
||||
REGION_MAP.values().forEach(region -> region.set(flagType, value));
|
||||
static Region getGlobalRegion() {
|
||||
return RegionSystem.INSTANCE.getGlobalRegion();
|
||||
}
|
||||
|
||||
YAPIONObject regionData;
|
||||
@NonNull
|
||||
UUID getID();
|
||||
|
||||
private String name;
|
||||
private Prototype prototype;
|
||||
private Set<String> prototypes;
|
||||
private String skin;
|
||||
@NonNull
|
||||
RegionType getType();
|
||||
|
||||
private Point minPoint;
|
||||
private Point maxPoint;
|
||||
@NonNull
|
||||
FlagStorage getFlags();
|
||||
|
||||
private Point minPointTestblock;
|
||||
private Point maxPointTestblock;
|
||||
@NonNull
|
||||
Area getArea();
|
||||
|
||||
private Point minPointTestblockExtension;
|
||||
private Point maxPointTestblockExtension;
|
||||
@NonNull
|
||||
Area getBuildArea();
|
||||
|
||||
private Point minPointBuild;
|
||||
private Point maxPointBuild;
|
||||
@NonNull
|
||||
Area getTestblockArea();
|
||||
|
||||
private Point minPointBuildExtension;
|
||||
private Point maxPointBuildExtension;
|
||||
@NonNull
|
||||
GameModeConfig getGameModeConfig();
|
||||
|
||||
private int floorLevel;
|
||||
private int waterLevel;
|
||||
@NonNull
|
||||
RegionHistory getHistory();
|
||||
|
||||
private Point copyPoint; // Nullable
|
||||
private Point testBlockPoint; // Nullable
|
||||
@NonNull
|
||||
RegionBackups getBackups();
|
||||
|
||||
private String linkedRegionName = null; // Nullable
|
||||
private Region linkedRegion = null; // Nullable
|
||||
interface Area {
|
||||
|
||||
private FlagStorage flagStorage;
|
||||
|
||||
@Getter(AccessLevel.PRIVATE)
|
||||
private SizedStack<EditSession> undoSessions;
|
||||
|
||||
@Getter(AccessLevel.PRIVATE)
|
||||
private SizedStack<EditSession> redoSessions;
|
||||
|
||||
public Region(String name, Prototype prototype, YAPIONObject regionConfig, FlagStorage flagStorage, YAPIONObject regionData) {
|
||||
this.name = name;
|
||||
this.regionData = regionData;
|
||||
if (prototype != null) {
|
||||
REGION_MAP.put(name, this);
|
||||
}
|
||||
|
||||
linkedRegionName = regionConfig.getPlainValueOrDefault("optionsLinkedWith", null);
|
||||
|
||||
prototypes = new HashSet<>();
|
||||
if (regionConfig.containsKey("prototypes", YAPIONType.ARRAY)) {
|
||||
regionConfig.getArray("prototypes").forEach(yapionAnyType -> {
|
||||
if (yapionAnyType instanceof YAPIONValue) {
|
||||
prototypes.add(((YAPIONValue<String>) yapionAnyType).get());
|
||||
}
|
||||
});
|
||||
}
|
||||
if (regionConfig.containsKey("prototype")) {
|
||||
prototypes.add(regionConfig.getPlainValue("prototype"));
|
||||
}
|
||||
|
||||
this.flagStorage = flagStorage;
|
||||
Point point = null;
|
||||
if (regionConfig.containsKey("minX", Integer.class) && regionConfig.containsKey("minY", Integer.class) && regionConfig.containsKey("minZ", Integer.class)) {
|
||||
point = new Point(regionConfig.getPlainValue("minX"), regionConfig.getPlainValue("minY"), regionConfig.getPlainValue("minZ"));
|
||||
}
|
||||
if (prototype != null && prototypes.contains(prototype.getName())) {
|
||||
generatePrototypeData(prototype, point);
|
||||
} else if (regionConfig.containsKey("prototype")) {
|
||||
generatePrototypeData(Prototype.getByName(regionConfig.getPlainValue("prototype")), point);
|
||||
}
|
||||
if (prototype != null) {
|
||||
skin = regionData.getPlainValueOrDefault("skin", prototype.getDefaultSkin());
|
||||
if (!prototype.getSkinMap().containsKey(skin)) {
|
||||
skin = prototype.getDefaultSkin();
|
||||
}
|
||||
}
|
||||
regionData.add("skin", skin);
|
||||
|
||||
if (!hasType(RegionType.BUILD) || !hasType(RegionType.TESTBLOCK)) {
|
||||
flagStorage.set(Flag.TNT, TNTMode.DENY);
|
||||
}
|
||||
}
|
||||
|
||||
private void generatePrototypeData(Prototype prototype, Point point) {
|
||||
if (prototype == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.prototype = prototype;
|
||||
this.skin = prototype.getDefaultSkin();
|
||||
|
||||
this.minPoint = point;
|
||||
this.maxPoint = point.add(prototype.getSizeX() - 1, prototype.getSizeY() - 1, prototype.getSizeZ() - 1);
|
||||
|
||||
if (prototype.getTestblock() != null) {
|
||||
this.minPointTestblock = point.add(prototype.getTestblock().getOffsetX(), prototype.getTestblock().getOffsetY(), prototype.getTestblock().getOffsetZ());
|
||||
this.maxPointTestblock = this.minPointTestblock.add(prototype.getTestblock().getSizeX() - 1, prototype.getTestblock().getSizeY() - 1, prototype.getTestblock().getSizeZ() - 1);
|
||||
|
||||
this.minPointTestblockExtension = this.minPointTestblock.subtract(prototype.getTestblock().getExtensionNegativeX(), prototype.getTestblock().getExtensionNegativeY(), prototype.getTestblock().getExtensionNegativeZ());
|
||||
this.maxPointTestblockExtension = this.maxPointTestblock.add(prototype.getTestblock().getExtensionPositiveX(), prototype.getTestblock().getExtensionPositiveY(), prototype.getTestblock().getExtensionPositiveZ());
|
||||
|
||||
if (prototype.getTestblock().getCopyOffsetX() != 0 || prototype.getTestblock().getCopyOffsetY() != 0 || prototype.getTestblock().getCopyOffsetZ() != 0) {
|
||||
this.testBlockPoint = this.minPointTestblock.add(prototype.getTestblock().getCopyOffsetX(), prototype.getTestblock().getCopyOffsetY(), prototype.getTestblock().getCopyOffsetZ());
|
||||
} else {
|
||||
this.testBlockPoint = this.minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
if (prototype.getBuild() != null) {
|
||||
this.minPointBuild = point.add(prototype.getBuild().getOffsetX(), prototype.getBuild().getOffsetY(), prototype.getBuild().getOffsetZ());
|
||||
this.maxPointBuild = this.minPointBuild.add(prototype.getBuild().getSizeX() - 1, prototype.getBuild().getSizeY() - 1, prototype.getBuild().getSizeZ() - 1);
|
||||
|
||||
this.minPointBuildExtension = this.minPointBuild.subtract(prototype.getBuild().getExtensionNegativeX(), prototype.getBuild().getExtensionNegativeY(), prototype.getBuild().getExtensionNegativeZ());
|
||||
this.maxPointBuildExtension = this.maxPointBuild.add(prototype.getBuild().getExtensionPositiveX(), prototype.getBuild().getExtensionPositiveY(), prototype.getBuild().getExtensionPositiveZ());
|
||||
|
||||
if (!prototype.getBuild().isHasCopyPoint() && (prototype.getCopyPointOffsetX() != 0 || prototype.getCopyPointOffsetY() != 0 || prototype.getCopyPointOffsetZ() != 0)) {
|
||||
this.copyPoint = minPoint.add(prototype.getCopyPointOffsetX(), prototype.getCopyPointOffsetY(), prototype.getCopyPointOffsetZ());
|
||||
} else if (prototype.getBuild().getCopyOffsetX() != 0 || prototype.getBuild().getCopyOffsetY() != 0 || prototype.getBuild().getCopyOffsetZ() != 0) {
|
||||
this.copyPoint = this.minPointBuild.add(prototype.getBuild().getCopyOffsetX(), prototype.getBuild().getCopyOffsetY(), prototype.getBuild().getCopyOffsetZ());
|
||||
} else {
|
||||
this.copyPoint = this.minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ());
|
||||
}
|
||||
} else if (prototype.getCopyPointOffsetX() != 0 || prototype.getCopyPointOffsetY() != 0 || prototype.getCopyPointOffsetZ() != 0) {
|
||||
this.copyPoint = minPoint.add(prototype.getCopyPointOffsetX(), prototype.getCopyPointOffsetY(), prototype.getCopyPointOffsetZ());
|
||||
}
|
||||
|
||||
if (prototype.getFloorOffset() != 0) {
|
||||
floorLevel = minPoint.getY() + prototype.getFloorOffset();
|
||||
} else {
|
||||
floorLevel = 0;
|
||||
}
|
||||
|
||||
if (prototype.getWaterOffset() != 0) {
|
||||
waterLevel = minPoint.getY() + prototype.getWaterOffset();
|
||||
} else {
|
||||
waterLevel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean inRegion(Location location, RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
if (!hasType(regionType)) {
|
||||
return false;
|
||||
}
|
||||
switch (regionType) {
|
||||
case BUILD:
|
||||
Point minBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? minPointBuildExtension : minPointBuild;
|
||||
Point maxBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? maxPointBuildExtension : maxPointBuild;
|
||||
return inRegion(location, minBPoint, maxBPoint);
|
||||
case TESTBLOCK:
|
||||
Point minTBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? minPointTestblockExtension : minPointTestblock;
|
||||
Point maxTBPoint = regionExtensionType == RegionExtensionType.EXTENSION ? maxPointTestblockExtension : maxPointTestblock;
|
||||
return inRegion(location, minTBPoint, maxTBPoint);
|
||||
default:
|
||||
case NORMAL:
|
||||
return inRegion(location, minPoint, maxPoint);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean inRegion(Location location, Point minPoint, Point maxPoint) {
|
||||
int blockX = location.getBlockX();
|
||||
int blockY = location.getBlockY();
|
||||
int blockZ = location.getBlockZ();
|
||||
return blockX >= minPoint.getX() && blockX <= maxPoint.getX() &&
|
||||
blockY >= minPoint.getY() && blockY <= maxPoint.getY() &&
|
||||
blockZ >= minPoint.getZ() && blockZ <= maxPoint.getZ();
|
||||
}
|
||||
|
||||
public boolean hasType(RegionType regionType) {
|
||||
if (prototype == null) {
|
||||
return false;
|
||||
}
|
||||
if (regionType == null) {
|
||||
return false;
|
||||
}
|
||||
switch (regionType) {
|
||||
case BUILD:
|
||||
return prototype.getBuild() != null;
|
||||
case TESTBLOCK:
|
||||
return prototype.getTestblock() != null;
|
||||
default:
|
||||
case NORMAL:
|
||||
Area EMPTY = new Area() {
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasExtensionType(RegionType regionType) {
|
||||
if (!hasType(regionType)) {
|
||||
return false;
|
||||
}
|
||||
switch (regionType) {
|
||||
case BUILD:
|
||||
return prototype.getBuild().isExtensionRegistered();
|
||||
case TESTBLOCK:
|
||||
return prototype.getTestblock().isExtensionRegistered();
|
||||
default:
|
||||
case NORMAL:
|
||||
@Override
|
||||
public Point getMinPoint(boolean extension) {
|
||||
return Point.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getMaxPoint(boolean extension) {
|
||||
return Point.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getCopyPoint() {
|
||||
return Point.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inRegion(Location location, boolean extension) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return prototype != null ? prototype.getSkinMap().get(skin).getName() : "";
|
||||
}
|
||||
|
||||
private void setLinkedRegion(Predicate<Region> regionConsumer) {
|
||||
if (linkedRegionName == null) {
|
||||
return;
|
||||
}
|
||||
if (linkedRegion != null) {
|
||||
if (regionConsumer.test(linkedRegion)) {
|
||||
RegionUtils.save(linkedRegion);
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (Region region : REGION_MAP.values()) {
|
||||
if (region.name.equals(linkedRegionName)) {
|
||||
linkedRegion = region;
|
||||
if (regionConsumer.test(linkedRegion)) {
|
||||
RegionUtils.save(linkedRegion);
|
||||
}
|
||||
return;
|
||||
|
||||
@Override
|
||||
public Clipboard copy(boolean extension) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Region getLinkedRegion() {
|
||||
if (linkedRegion == null && linkedRegionName != null) {
|
||||
setLinkedRegion(region -> false);
|
||||
}
|
||||
return linkedRegion;
|
||||
}
|
||||
@Override
|
||||
public File getResetFile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean setPrototype(@NonNull Prototype prototype) {
|
||||
if (!prototypes.contains(prototype.getName())) {
|
||||
@Override
|
||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachChunk(BiConsumer<Integer, Integer> executor) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkOutside(int chunkX, int chunkZ) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
default boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
return _setPrototype(prototype);
|
||||
}
|
||||
|
||||
boolean _setPrototype(@NonNull Prototype prototype) {
|
||||
generatePrototypeData(prototype, minPoint);
|
||||
RegionUtils.save(this);
|
||||
return true;
|
||||
}
|
||||
@NonNull
|
||||
Point getMinPoint(boolean extension);
|
||||
|
||||
public boolean setSkin(@NonNull String skinName) {
|
||||
if (!prototype.getSkinMap().containsKey(skinName)) {
|
||||
return false;
|
||||
}
|
||||
this.skin = skinName;
|
||||
setLinkedRegion(region -> {
|
||||
region.skin = skinName;
|
||||
@NonNull
|
||||
Point getMaxPoint(boolean extension);
|
||||
|
||||
@NonNull
|
||||
Point getCopyPoint();
|
||||
|
||||
default boolean inRegion(Location location, boolean extension) {
|
||||
Point minPoint = getMinPoint(extension);
|
||||
Point maxPoint = getMaxPoint(extension);
|
||||
if (location.getBlockX() < minPoint.getX() || location.getBlockX() > maxPoint.getX()) return false;
|
||||
if (location.getBlockY() < minPoint.getY() || location.getBlockY() > maxPoint.getY()) return false;
|
||||
if (location.getBlockZ() < minPoint.getZ() || location.getBlockZ() > maxPoint.getZ()) return false;
|
||||
return true;
|
||||
});
|
||||
regionData.add("skin", skin);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void set(Flag flagType, Flag.Value<?> value) {
|
||||
if (flagStorage.set(flagType, value)) {
|
||||
RegionUtils.save(this);
|
||||
}
|
||||
setLinkedRegion(region -> region.flagStorage.set(flagType, value));
|
||||
}
|
||||
|
||||
public void set(Tag tag) {
|
||||
if (flagStorage.set(tag)) {
|
||||
RegionUtils.save(this);
|
||||
}
|
||||
setLinkedRegion(region -> region.flagStorage.set(tag));
|
||||
}
|
||||
|
||||
public void remove(Tag tag) {
|
||||
if (flagStorage.remove(tag)) {
|
||||
RegionUtils.save(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Flag.Value<?> get(Flag flagType) {
|
||||
return flagStorage.get(flagType);
|
||||
}
|
||||
|
||||
public boolean get(Tag tagType) {
|
||||
return flagStorage.is(tagType);
|
||||
}
|
||||
|
||||
public <T extends Enum<T> & Flag.Value<T>> T getPlain(Flag flagType) {
|
||||
return (T) flagStorage.get(flagType).getValue();
|
||||
}
|
||||
|
||||
public <T extends Enum<T> & Flag.Value<T>> T getPlain(Flag flagType, Class<T> type) {
|
||||
return (T) flagStorage.get(flagType).getValue();
|
||||
}
|
||||
|
||||
public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
switch (regionType) {
|
||||
case TESTBLOCK:
|
||||
return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? minPointTestblock : minPointTestblockExtension;
|
||||
case BUILD:
|
||||
return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? minPointBuild : minPointBuildExtension;
|
||||
default:
|
||||
case NORMAL:
|
||||
return minPoint;
|
||||
}
|
||||
}
|
||||
|
||||
public Point getMaxPoint(RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
switch (regionType) {
|
||||
case TESTBLOCK:
|
||||
return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? maxPointTestblock : maxPointTestblockExtension;
|
||||
case BUILD:
|
||||
return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? maxPointBuild : maxPointBuildExtension;
|
||||
default:
|
||||
case NORMAL:
|
||||
return maxPoint;
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasReset(RegionType regionType) {
|
||||
if (!hasType(regionType)) {
|
||||
return false;
|
||||
}
|
||||
switch (regionType) {
|
||||
case TESTBLOCK:
|
||||
return prototype.getSkinMap().get(skin).getTestblockSchematicFile() != null;
|
||||
case BUILD:
|
||||
return prototype.getSkinMap().get(skin).getBuildSchematicFile() != null;
|
||||
default:
|
||||
case NORMAL:
|
||||
return prototype.getSkinMap().get(skin).getSchematicFile() != null;
|
||||
}
|
||||
}
|
||||
|
||||
public File getResetFile(RegionType regionType) {
|
||||
if (!hasReset(regionType)) {
|
||||
return null;
|
||||
}
|
||||
switch (regionType) {
|
||||
case TESTBLOCK:
|
||||
return prototype.getSkinMap().get(skin).getTestblockSchematicFile();
|
||||
case BUILD:
|
||||
return prototype.getSkinMap().get(skin).getBuildSchematicFile();
|
||||
default:
|
||||
case NORMAL:
|
||||
return prototype.getSkinMap().get(skin).getSchematicFile();
|
||||
}
|
||||
}
|
||||
|
||||
public void reset(PasteBuilder pasteBuilder, RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
if (!hasReset(regionType)) {
|
||||
return;
|
||||
}
|
||||
if (regionExtensionType == RegionExtensionType.EXTENSION && !hasExtensionType(regionType)) {
|
||||
regionExtensionType = RegionExtensionType.NORMAL;
|
||||
}
|
||||
|
||||
pasteBuilder.reset(regionExtensionType == RegionExtensionType.EXTENSION)
|
||||
.minPoint(getMinPoint(regionType, regionExtensionType))
|
||||
.maxPoint(getMaxPoint(regionType, regionExtensionType))
|
||||
.waterLevel(waterLevel);
|
||||
if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) {
|
||||
SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype();
|
||||
pasteBuilder.rotate(schematicType.fightType() || schematicType.check());
|
||||
@Nullable
|
||||
default Clipboard copy(boolean extension) {
|
||||
return FlatteningWrapper.impl.copy(getMinPoint(extension), getMaxPoint(extension), getCopyPoint());
|
||||
}
|
||||
|
||||
switch (regionType) {
|
||||
case BUILD:
|
||||
pasteBuilder.pastePoint(minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ() / 2));
|
||||
break;
|
||||
case TESTBLOCK:
|
||||
Point pastePoint = minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, prototype.getTestblock().getSizeZ() / 2);
|
||||
if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) {
|
||||
SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype();
|
||||
if (schematicType.getKuerzel().equalsIgnoreCase("wg")) {
|
||||
pastePoint = pastePoint.add(0, 0, 1);
|
||||
}
|
||||
if (schematicType.getKuerzel().equalsIgnoreCase("ws")) {
|
||||
pastePoint = pastePoint.add(-1, 0, 1);
|
||||
}
|
||||
if (schematicType.getKuerzel().equalsIgnoreCase("as")) {
|
||||
pastePoint = pastePoint.add(-1, 0, 1);
|
||||
}
|
||||
@Nullable
|
||||
File getResetFile();
|
||||
|
||||
void reset(PasteBuilder pasteBuilder, boolean extension);
|
||||
|
||||
default void forEachChunk(BiConsumer<Integer, Integer> executor) {
|
||||
Point minPoint = getMinPoint(false);
|
||||
Point maxPoint = getMaxPoint(false);
|
||||
for (int x = (int) Math.floor(minPoint.getX() / 16.0); x <= (int) Math.ceil(maxPoint.getX() / 16.0); x++) {
|
||||
for (int z = (int) Math.floor(minPoint.getZ() / 16.0); z <= (int) Math.ceil(maxPoint.getZ() / 16.0); z++) {
|
||||
executor.accept(x, z);
|
||||
}
|
||||
pasteBuilder.pastePoint(pastePoint);
|
||||
break;
|
||||
default:
|
||||
case NORMAL:
|
||||
pasteBuilder.pastePoint(minPoint.add(prototype.getSizeX() / 2, 0, prototype.getSizeZ() / 2));
|
||||
break;
|
||||
}
|
||||
|
||||
initSessions();
|
||||
undoSessions.push(pasteBuilder.run());
|
||||
}
|
||||
|
||||
public void remember(EditSession editSession) {
|
||||
initSessions();
|
||||
undoSessions.push(editSession);
|
||||
}
|
||||
|
||||
public boolean isGlobal() {
|
||||
return this == GlobalRegion.getInstance();
|
||||
}
|
||||
|
||||
private void initSessions() {
|
||||
if (undoSessions == null) {
|
||||
undoSessions = new SizedStack<>(20);
|
||||
redoSessions = new SizedStack<>(20);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean undo() {
|
||||
initSessions();
|
||||
EditSession session = undoSessions.pop();
|
||||
if (session == null)
|
||||
return false;
|
||||
|
||||
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
|
||||
session.undo(e);
|
||||
redoSessions.push(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean redo() {
|
||||
initSessions();
|
||||
EditSession session = redoSessions.pop();
|
||||
if (session == null)
|
||||
return false;
|
||||
|
||||
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
|
||||
session.redo(e);
|
||||
undoSessions.push(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean backup() {
|
||||
final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name);
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
definedBackupFolder.mkdirs();
|
||||
|
||||
File[] currentBackups = definedBackupFolder.listFiles();
|
||||
if (currentBackups != null && currentBackups.length >= 20) {
|
||||
List<File> files = new ArrayList<>(Arrays.asList(currentBackups));
|
||||
files.sort(Comparator.comparingLong(File::lastModified));
|
||||
while (files.size() >= 20) files.remove(0).delete();
|
||||
}
|
||||
|
||||
final File backupFile = new File(definedBackupFolder, LocalDateTime.now().format(formatter) + ".schem");
|
||||
return FlatteningWrapper.impl.backup(minPoint, maxPoint, backupFile);
|
||||
}
|
||||
|
||||
public static boolean copy(Point minPoint, Point maxPoint, File file) {
|
||||
return FlatteningWrapper.impl.backup(minPoint, maxPoint, file);
|
||||
}
|
||||
|
||||
public List<String> listBackup() {
|
||||
final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name);
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
definedBackupFolder.mkdirs();
|
||||
|
||||
File[] currentBackups = definedBackupFolder.listFiles();
|
||||
List<File> files = new ArrayList<>(Arrays.asList(currentBackups));
|
||||
files.sort(Comparator.comparingLong(File::lastModified));
|
||||
return files.stream().map(File::getName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public File getBackupFile(String backupName) {
|
||||
final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name);
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
definedBackupFolder.mkdirs();
|
||||
File[] files = definedBackupFolder.listFiles((dir, name) -> name.equals(backupName + ".schem"));
|
||||
if (files == null || files.length == 0) return null;
|
||||
return files[0];
|
||||
}
|
||||
|
||||
public void forEachChunk(ObjIntConsumer<Integer> executor) {
|
||||
for (int x = (int) Math.floor(minPoint.getX() / 16.0); x <= (int) Math.ceil(maxPoint.getX() / 16.0); x++) {
|
||||
for (int z = (int) Math.floor(minPoint.getZ() / 16.0); z <= (int) Math.ceil(maxPoint.getZ() / 16.0); z++) {
|
||||
executor.accept(x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean buildChunkOutside(int chunkX, int chunkY) {
|
||||
if (!hasType(RegionType.BUILD)) {
|
||||
default boolean isChunkOutside(int chunkX, int chunkZ) {
|
||||
Point minPoint = getMinPoint(true);
|
||||
Point maxPoint = getMaxPoint(true);
|
||||
return Math.floor(minPoint.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPoint.getX() / 16.0) ||
|
||||
Math.floor(minPoint.getZ() / 16.0) > chunkY || chunkY >= Math.ceil(maxPoint.getZ() / 16.0);
|
||||
Math.floor(minPoint.getZ() / 16.0) > chunkZ || chunkZ >= Math.ceil(maxPoint.getZ() / 16.0);
|
||||
}
|
||||
if (!hasExtensionType(RegionType.BUILD)) {
|
||||
return Math.floor(minPointBuild.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPointBuild.getX() / 16.0) ||
|
||||
Math.floor(minPointBuild.getZ() / 16.0) > chunkY || chunkY >= Math.ceil(maxPointBuild.getZ() / 16.0);
|
||||
}
|
||||
return Math.floor(minPointBuildExtension.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPointBuildExtension.getX() / 16.0) ||
|
||||
Math.floor(minPointBuildExtension.getZ() / 16.0) > chunkY || chunkY >= Math.ceil(maxPointBuildExtension.getZ() / 16.0);
|
||||
}
|
||||
|
||||
public File gameModeConfig() {
|
||||
File baseFile = new File(BauSystem.getInstance().getDataFolder().getParentFile(), "FightSystem");
|
||||
for (int version = Core.getVersion(); version >= 15; version--) {
|
||||
File specific = new File(baseFile, prototype.getDisplayName() + version + ".yml");
|
||||
if (specific.exists()) return specific;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import javax.annotation.CheckReturnValue;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface RegionBackups {
|
||||
|
||||
@RequiredArgsConstructor
|
||||
enum BackupType {
|
||||
MANUAL(5),
|
||||
AUTOMATIC(20),
|
||||
;
|
||||
|
||||
public final int maxBackups;
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
abstract class Backup {
|
||||
@NonNull
|
||||
private final BackupType type;
|
||||
|
||||
@NonNull
|
||||
private final String name;
|
||||
|
||||
@NonNull
|
||||
private final FlagStorage flags;
|
||||
|
||||
@CheckReturnValue
|
||||
public abstract boolean load();
|
||||
|
||||
public abstract void delete();
|
||||
}
|
||||
|
||||
@CheckReturnValue
|
||||
Optional<Backup> create(BackupType backupType);
|
||||
|
||||
@NonNull
|
||||
List<Backup> list();
|
||||
|
||||
@Nullable
|
||||
Backup get(String name);
|
||||
|
||||
RegionBackups EMPTY = new RegionBackups() {
|
||||
@Override
|
||||
public Optional<Backup> create(BackupType backupType) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull List<Backup> list() {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Backup get(String name) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum RegionFlagPolicy {
|
||||
NOT_APPLICABLE(false, false),
|
||||
READ_ONLY(true, false),
|
||||
WRITABLE(true, true);
|
||||
|
||||
private final boolean readable;
|
||||
private final boolean writable;
|
||||
|
||||
public boolean isApplicable() {
|
||||
return readable || writable;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user