forked from SteamWar/SteamWar
Add Unified GameModeConfig
This commit is contained in:
+1
-1
@@ -129,7 +129,7 @@ public class AutostartListener implements Listener {
|
|||||||
if (!regionStartTime.containsKey(region)) return;
|
if (!regionStartTime.containsKey(region)) return;
|
||||||
if (!region.getTestblockArea().inRegion(block.getLocation(), true)) return;
|
if (!region.getTestblockArea().inRegion(block.getLocation(), true)) return;
|
||||||
long tickDiff = TPSUtils.currentRealTick.get() - regionStartTime.remove(region);
|
long tickDiff = TPSUtils.currentRealTick.get() - regionStartTime.remove(region);
|
||||||
long preFightDurationInSeconds = region.getGameModeConfig().getTimes().getPreFightDuration();
|
long preFightDurationInSeconds = region.getGameModeConfig().Times.PreFightDuration;
|
||||||
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT1", tickDiff);
|
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT1", tickDiff);
|
||||||
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT2", preFightDurationInSeconds, ((preFightDurationInSeconds * 20) - tickDiff));
|
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT2", preFightDurationInSeconds, ((preFightDurationInSeconds * 20) - tickDiff));
|
||||||
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT3");
|
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT3");
|
||||||
|
|||||||
+6
-6
@@ -29,10 +29,12 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DesignEndStone {
|
public class DesignEndStone {
|
||||||
@@ -54,15 +56,13 @@ public class DesignEndStone {
|
|||||||
this.maxY = region.getBuildArea().getMaxPoint(false).getY();
|
this.maxY = region.getBuildArea().getMaxPoint(false).getY();
|
||||||
this.maxZ = region.getBuildArea().getMaxPoint(false).getZ();
|
this.maxZ = region.getBuildArea().getMaxPoint(false).getZ();
|
||||||
|
|
||||||
limited = region.getGameModeConfig()
|
limited = region.getGameModeConfig().Schematic.Limited
|
||||||
.getSchematic()
|
|
||||||
.getLimited()
|
|
||||||
.entrySet()
|
.entrySet()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entry -> entry.getValue() == 0)
|
.filter(entry -> entry.getValue() == 0)
|
||||||
.flatMap(entry -> entry.getKey().stream())
|
.flatMap(entry -> entry.getKey().stream())
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
calculateFromBottom = region.getGameModeConfig().getArena().isNoFloor();
|
calculateFromBottom = region.getGameModeConfig().Arena.NoFloor;
|
||||||
|
|
||||||
entityServer.setCallback((player, rEntity, entityAction) -> {
|
entityServer.setCallback((player, rEntity, entityAction) -> {
|
||||||
if (entityAction != REntityServer.EntityAction.ATTACK) return;
|
if (entityAction != REntityServer.EntityAction.ATTACK) return;
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ public class DesignEndStoneCommand extends SWCommand implements Listener {
|
|||||||
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!region.getGameModeConfig().isLoaded()) {
|
if (!region.getGameModeConfig().loaded) {
|
||||||
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -43,8 +43,8 @@ public class RegionScoreboardElement implements ScoreboardElement {
|
|||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.getType().isGlobal()) return null;
|
if (region.getType().isGlobal()) return null;
|
||||||
if (!region.getGameModeConfig().isLoaded()) return null;
|
if (!region.getGameModeConfig().loaded) return null;
|
||||||
List<String> names = region.getGameModeConfig().getServer().getChatNames();
|
List<String> names = region.getGameModeConfig().Server.ChatNames;
|
||||||
if (names.isEmpty()) return null;
|
if (names.isEmpty()) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + names.get(0);
|
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + names.get(0);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ public class RegionLib implements LuaLib {
|
|||||||
if (rg.getType().isGlobal()) {
|
if (rg.getType().isGlobal()) {
|
||||||
return "global";
|
return "global";
|
||||||
}
|
}
|
||||||
List<String> chatNames = rg.getGameModeConfig().getServer().getChatNames();
|
List<String> chatNames = rg.getGameModeConfig().Server.ChatNames;
|
||||||
if (chatNames.isEmpty()) {
|
if (chatNames.isEmpty()) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -65,7 +65,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
|
|||||||
}
|
}
|
||||||
|
|
||||||
Optional<TechHider> techHider = techHiders.computeIfAbsent(region, rg -> {
|
Optional<TechHider> techHider = techHiders.computeIfAbsent(region, rg -> {
|
||||||
if (!region.getGameModeConfig().getTechhider().isActive()) {
|
if (!region.getGameModeConfig().Techhider.Active) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
|
|||||||
TechHider current = new TechHider((p, cX, cY) -> {
|
TechHider current = new TechHider((p, cX, cY) -> {
|
||||||
if (rg.getBuildArea().isChunkOutside(cX, cY)) return true;
|
if (rg.getBuildArea().isChunkOutside(cX, cY)) return true;
|
||||||
return !hidden.get(rg).contains(p);
|
return !hidden.get(rg).contains(p);
|
||||||
}, region.getGameModeConfig().getTechhider().getObfuscateWith(), region.getGameModeConfig().getTechhider().getHiddenBlocks(), region.getGameModeConfig().getTechhider().getHiddenBlockEntities());
|
}, region.getGameModeConfig().Techhider.ObfuscateWith, region.getGameModeConfig().Techhider.HiddenBlocks, region.getGameModeConfig().Techhider.HiddenBlockEntities);
|
||||||
current.enable();
|
current.enable();
|
||||||
|
|
||||||
return Optional.of(current);
|
return Optional.of(current);
|
||||||
|
|||||||
@@ -67,13 +67,13 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
Optional<TechHider> techHider = techHiders.computeIfAbsent(region, rg -> {
|
Optional<TechHider> techHider = techHiders.computeIfAbsent(region, rg -> {
|
||||||
if (!region.getGameModeConfig().getTechhider().isActive()) {
|
if (!region.getGameModeConfig().Techhider.Active) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
hidden.put(rg, new HashSet<>());
|
hidden.put(rg, new HashSet<>());
|
||||||
|
|
||||||
Set<Material> blocks = new HashSet<>(Arrays.asList(region.getGameModeConfig().getTechhider().getObfuscateWith()));
|
Set<Material> blocks = new HashSet<>(Arrays.asList(region.getGameModeConfig().Techhider.ObfuscateWith));
|
||||||
if (blocks.contains(Material.END_STONE)) blocks.add(Material.END_STONE_BRICKS);
|
if (blocks.contains(Material.END_STONE)) blocks.add(Material.END_STONE_BRICKS);
|
||||||
xrayedBlocks.put(region, blocks);
|
xrayedBlocks.put(region, blocks);
|
||||||
return Optional.of(createXray(rg, blocks));
|
return Optional.of(createXray(rg, blocks));
|
||||||
|
|||||||
@@ -1,128 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2025 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(String::toUpperCase).map(FlatteningWrapper.impl::getMaterial).filter(Objects::nonNull).collect(Collectors.toUnmodifiableSet());
|
|
||||||
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(section.getStringList("HiddenBlockEntities")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,8 +22,11 @@ package de.steamwar.bausystem.region;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -64,7 +67,7 @@ public interface Region {
|
|||||||
Area getTestblockArea();
|
Area getTestblockArea();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
GameModeConfig getGameModeConfig();
|
GameModeConfig<Material, SchematicType, String> getGameModeConfig();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
RegionHistory getHistory();
|
RegionHistory getHistory();
|
||||||
|
|||||||
+5
-1
@@ -22,9 +22,13 @@ package de.steamwar.bausystem.region.fixed;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import de.steamwar.bausystem.region.*;
|
import de.steamwar.bausystem.region.*;
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
|
import de.steamwar.data.YMLWrapperImpl;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -90,7 +94,7 @@ public final class FixedGlobalRegion implements Region {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final GameModeConfig GLOBAL_CONFIG = new GameModeConfig(null);
|
private static final GameModeConfig<Material, SchematicType, String> GLOBAL_CONFIG = new GameModeConfig<>(YMLWrapperImpl.ofTyped(null));
|
||||||
|
|
||||||
private FixedGlobalRegion() {
|
private FixedGlobalRegion() {
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -28,9 +28,12 @@ import de.steamwar.bausystem.utils.FlatteningWrapper;
|
|||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import de.steamwar.bausystem.worlddata.WorldData;
|
import de.steamwar.bausystem.worlddata.WorldData;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
|
import de.steamwar.data.YMLWrapperImpl;
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import yapion.hierarchy.types.YAPIONObject;
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -57,7 +60,7 @@ public class FixedRegion implements Region {
|
|||||||
private final Area testblock;
|
private final Area testblock;
|
||||||
private final int floorLevel;
|
private final int floorLevel;
|
||||||
private final int waterLevel;
|
private final int waterLevel;
|
||||||
private final GameModeConfig gameModeConfig;
|
private final GameModeConfig<Material, SchematicType, String> gameModeConfig;
|
||||||
private final RegionData regionData;
|
private final RegionData regionData;
|
||||||
private final RegionHistory regionHistory = new RegionHistory.Impl(20);
|
private final RegionHistory regionHistory = new RegionHistory.Impl(20);
|
||||||
|
|
||||||
@@ -336,7 +339,7 @@ public class FixedRegion implements Region {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.gameModeConfig = new GameModeConfig(found);
|
this.gameModeConfig = new GameModeConfig<>(YMLWrapperImpl.ofTyped(found));
|
||||||
this.regionData = new RegionData.RegionDataImpl(regionData, WorldData::write);
|
this.regionData = new RegionData.RegionDataImpl(regionData, WorldData::write);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,4 +22,5 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
api(project(":CommonCore:SQL"))
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,821 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2025 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.data;
|
||||||
|
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public final class GameModeConfig<M, ST, W> {
|
||||||
|
|
||||||
|
private static final Random random = new Random();
|
||||||
|
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||||
|
|
||||||
|
public final boolean loaded;
|
||||||
|
public final File configFile;
|
||||||
|
|
||||||
|
public final Server Server;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submission deadline for schematics in 'dd.MM.yyyy HH:mm' format
|
||||||
|
* @implSpec {@code null} by default
|
||||||
|
*/
|
||||||
|
public final Date Deadline;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The questions that have to be answered to accept the schematic
|
||||||
|
*
|
||||||
|
* @implSpec Disables check schem type if missing
|
||||||
|
*/
|
||||||
|
public final List<String> CheckQuestions;
|
||||||
|
public final Times Times;
|
||||||
|
public final Arena Arena;
|
||||||
|
public final Schematic<M, ST> Schematic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the game mode presented to the players
|
||||||
|
*
|
||||||
|
* @implSpec {@code YMLWrapper.getDefaultGameName()} by default
|
||||||
|
*/
|
||||||
|
public final String GameName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The months this game mode should be active and playable<br/>
|
||||||
|
* The empty List means all of them
|
||||||
|
*
|
||||||
|
* @implNote 1 is January - 12 is December
|
||||||
|
*/
|
||||||
|
public final List<Integer> ActiveMonths;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The prefix used for team chats
|
||||||
|
*
|
||||||
|
* @implSpec {@code +} by default
|
||||||
|
*/
|
||||||
|
public final String TeamChatPrefix;
|
||||||
|
public final Blue Blue;
|
||||||
|
public final Red Red;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of active win conditions
|
||||||
|
*/
|
||||||
|
public final List<W> WinConditions;
|
||||||
|
public final WinConditionParams<M> WinConditionParams;
|
||||||
|
public final Kits<M> Kits;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of integers containing the waiting time of this enter stage in the fight
|
||||||
|
*/
|
||||||
|
public final List<Integer> EnterStages;
|
||||||
|
public final Techhider<M> Techhider;
|
||||||
|
|
||||||
|
public GameModeConfig(YMLWrapper<M, ST, W> loader) {
|
||||||
|
configFile = loader.getFile();
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
Server = new Server(loader.with("Server"));
|
||||||
|
|
||||||
|
String deadlineString = loader.getString("Deadline", null);
|
||||||
|
if (deadlineString != null) {
|
||||||
|
Date Deadline = null;
|
||||||
|
try {
|
||||||
|
Deadline = DATE_FORMAT.parse(deadlineString);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
Deadline = null;
|
||||||
|
}
|
||||||
|
this.Deadline = Deadline;
|
||||||
|
} else {
|
||||||
|
Deadline = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckQuestions = loader.getStringList("CheckQuestions");
|
||||||
|
Times = new Times(loader.with("Times"));
|
||||||
|
// Arena would be here to be in config order but needs Schematic.Size and EnterStages loaded afterwards
|
||||||
|
Schematic = new Schematic<>(loader.with("Schematic"));
|
||||||
|
GameName = loader.getString("GameName", loader.getDefaultGameName());
|
||||||
|
ActiveMonths = loader.getIntList("ActiveMonths");
|
||||||
|
TeamChatPrefix = loader.getString("TeamChatPrefix", "+");
|
||||||
|
Blue = new Blue(loader.with("Blue"));
|
||||||
|
Red = new Red(loader.with("Red"));
|
||||||
|
WinConditions = Collections.unmodifiableList(loader.getStringList("WinConditions").stream().map(loader.winconditionMapper).collect(Collectors.toList()));
|
||||||
|
WinConditionParams = new WinConditionParams<>(loader.with("WinConditionParams"));
|
||||||
|
Kits = new Kits<>(loader.with("Kits"));
|
||||||
|
EnterStages = loader.getIntList("EnterStages");
|
||||||
|
Techhider = new Techhider<>(loader.with("Techhider"));
|
||||||
|
|
||||||
|
Arena = new Arena(loader.with("Arena"), Schematic.Size, EnterStages);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public static final class Server {
|
||||||
|
|
||||||
|
public final boolean loaded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base server folder
|
||||||
|
*/
|
||||||
|
public final String Folder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Server java archive
|
||||||
|
*/
|
||||||
|
public final String ServerJar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Available arenas
|
||||||
|
*/
|
||||||
|
public final List<String> Maps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Names to address the game mode in the chat interface
|
||||||
|
*/
|
||||||
|
public final List<String> ChatNames;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the Server is a Spigot server
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean Spigot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the game mode should be marked as a historic game mode
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean Historic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If ranked matches should be available for the game mode
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean Ranked;
|
||||||
|
|
||||||
|
private Server(YMLWrapper loader) {
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
Folder = loader.getString("Folder", null);
|
||||||
|
ServerJar = loader.getString("ServerJar", null);
|
||||||
|
Maps = loader.getStringList("Maps");
|
||||||
|
ChatNames = loader.getStringList("ChatNames");
|
||||||
|
Spigot = loader.getBoolean("Spigot", false);
|
||||||
|
Historic = loader.getBoolean("Historic", false);
|
||||||
|
Ranked = loader.getBoolean("Ranked", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public static final class Times {
|
||||||
|
public final boolean loaded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time in seconds the server stops after starting if nobody joins
|
||||||
|
*
|
||||||
|
* @implSpec {@code 300} by default
|
||||||
|
*/
|
||||||
|
public final int NoPlayersOnlineDuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time in seconds the team leaders have to choose their schematic
|
||||||
|
*
|
||||||
|
* @implSpec {@code 120} by default
|
||||||
|
*/
|
||||||
|
public final int PreSchemPasteDuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time in seconds for preparing
|
||||||
|
*
|
||||||
|
* @implSpec {@code 300} by default
|
||||||
|
*/
|
||||||
|
public final int SetupDuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time in seconds the final countdown is long
|
||||||
|
*
|
||||||
|
* @implSpec {@code 30} by default
|
||||||
|
*/
|
||||||
|
public final int PreFightDuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time in seconds to spectate the arena after the fight
|
||||||
|
*
|
||||||
|
* @implSpec {@code 30} by default
|
||||||
|
*/
|
||||||
|
public final int SpectatorDuration;
|
||||||
|
|
||||||
|
private Times(YMLWrapper loader) {
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
NoPlayersOnlineDuration = loader.getInt("NoPlayersOnlineDuration", 300);
|
||||||
|
PreSchemPasteDuration = loader.getInt("PreSchemPasteDuration", 120);
|
||||||
|
SetupDuration = loader.getInt("SetupDuration", 300);
|
||||||
|
PreFightDuration = loader.getInt("PreFightDuration", 30);
|
||||||
|
SpectatorDuration = loader.getInt("SpectatorDuration", 60);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public static final class Arena {
|
||||||
|
|
||||||
|
public final boolean loaded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of blocks the schematics should be pasted under the surface
|
||||||
|
*
|
||||||
|
* @implSpec {@code 0} by default
|
||||||
|
*/
|
||||||
|
public final int WaterDepth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The outer border of the arena, measured in blocks around the schematic areas
|
||||||
|
*/
|
||||||
|
public final Schem2Border Schem2Border;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The offset the teams spawn relative to the center of their area
|
||||||
|
*/
|
||||||
|
public final SpawnOffset SpawnOffset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The size of the team areas are expanded around the schematics
|
||||||
|
*
|
||||||
|
* @implSpec {@code 12} by default
|
||||||
|
*/
|
||||||
|
public final int BorderFromSchematic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If ground walkable, teams can walk below the lower arena border during setup
|
||||||
|
*
|
||||||
|
* @implSpec {@code true} by default
|
||||||
|
*/
|
||||||
|
public final boolean GroundWalkable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable snow and ice melting
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean DisableSnowMelt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow leaving the arena area as spectator
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean Leaveable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow missiles to fly to the enemy and not stop at the schem border.
|
||||||
|
*
|
||||||
|
* @implSpec {@code !EnterStages.isEmpty()} by default
|
||||||
|
*/
|
||||||
|
public final boolean AllowMissiles;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denotes that there is no floor for this GameMode
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean NoFloor;
|
||||||
|
|
||||||
|
private Arena(YMLWrapper loader, Schematic.Size Size, List<Integer> EnterStages) {
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
WaterDepth = loader.getInt("WaterDepth", 0);
|
||||||
|
Schem2Border = new Schem2Border(loader.with("Schem2Border"));
|
||||||
|
SpawnOffset = new SpawnOffset(loader.with("SpawnOffset"), Size);
|
||||||
|
BorderFromSchematic = loader.getInt("BorderFromSchematic", 21);
|
||||||
|
GroundWalkable = loader.getBoolean("GroundWalkable", true);
|
||||||
|
DisableSnowMelt = loader.getBoolean("DisableSnowMelt", false);
|
||||||
|
Leaveable = loader.getBoolean("Leaveable", false);
|
||||||
|
AllowMissiles = loader.getBoolean("AllowMissiles", !EnterStages.isEmpty());
|
||||||
|
NoFloor = loader.getBoolean("NoFloor", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public static final class Schem2Border {
|
||||||
|
|
||||||
|
public final boolean loaded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code 24} by default
|
||||||
|
*/
|
||||||
|
public final int x;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code 24} by default
|
||||||
|
*/
|
||||||
|
public final int z;
|
||||||
|
|
||||||
|
private Schem2Border(YMLWrapper loader) {
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
x = loader.getInt("x", 24);
|
||||||
|
z = loader.getInt("z", 24);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public static final class SpawnOffset {
|
||||||
|
|
||||||
|
public final boolean loaded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code 0} by default
|
||||||
|
*/
|
||||||
|
public final double x;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code Schematic.Size.y} by default
|
||||||
|
*/
|
||||||
|
public final double y;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code 0} by default
|
||||||
|
*/
|
||||||
|
public final double z;
|
||||||
|
|
||||||
|
private SpawnOffset(YMLWrapper loader, Schematic.Size Size) {
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
x = loader.getDouble("x", 0);
|
||||||
|
y = loader.getDouble("y", Size.y);
|
||||||
|
z = loader.getDouble("z", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public static final class Schematic<M, ST> {
|
||||||
|
|
||||||
|
public final boolean loaded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The size of the schematics
|
||||||
|
*/
|
||||||
|
public final Size Size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for GameModes with a technic area
|
||||||
|
*/
|
||||||
|
public final Inset Inset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The schematic type that can be chosen in this arena
|
||||||
|
*
|
||||||
|
* @implSpec {@code Normal} by default
|
||||||
|
*/
|
||||||
|
public final ST Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The schematic types that are also allowed to be chosen in this arena
|
||||||
|
*/
|
||||||
|
public final List<ST> SubTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut of the schematic type
|
||||||
|
*
|
||||||
|
* @implSpec {@code ""} by default
|
||||||
|
*/
|
||||||
|
public final String Shortcut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spigot (1.8) material for GUIs
|
||||||
|
*
|
||||||
|
* @implSpec {@code STONE_BUTTON} by default
|
||||||
|
*/
|
||||||
|
public final M Material;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manual check of schematic necessary
|
||||||
|
*
|
||||||
|
* @implSpec {@code true} by default
|
||||||
|
*/
|
||||||
|
public final boolean ManualCheck;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the schematics should be rotated during pasting
|
||||||
|
*
|
||||||
|
* @implSpec {@code true} by default
|
||||||
|
*/
|
||||||
|
public final boolean Rotate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the schematics should be pasted aligned to the borders instead of centered
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean PasteAligned;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If only public schematics are allowed
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean OnlyPublicSchematics;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the public only force should be completely disabled
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean IgnorePublicOnly;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If obsidian and bedrock should be replaced during PRE_RUNNING
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean ReplaceObsidianBedrock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the replacement should happen with block updates
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean ReplaceWithBlockupdates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the schematic perparation arena mode is time limited
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean UnlimitedPrepare;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximal amount of blocks allowed in the schematic
|
||||||
|
*
|
||||||
|
* @implSpec {@code 0} by default
|
||||||
|
*/
|
||||||
|
public final int MaxBlocks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximal amount of items per dispenser
|
||||||
|
*
|
||||||
|
* @implSpec {@code 128} by default
|
||||||
|
*/
|
||||||
|
public final int MaxDispenserItems;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximal blast resistance for the design blocks
|
||||||
|
*
|
||||||
|
* @implSpec {@code Double.MAX_VALUE} by default
|
||||||
|
*/
|
||||||
|
public final double MaxDesignBlastResistance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of limited material (combinations)<br/>
|
||||||
|
* List contains tags Amount (integer) and Materials (List of material names in Spigot 1.12 AND Spigot 1.15 format)
|
||||||
|
*/
|
||||||
|
public final Map<Set<M>, Integer> Limited;
|
||||||
|
|
||||||
|
private Schematic(YMLWrapper<M, ST, ?> loader) {
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
Size = new Size(loader.with("Size"));
|
||||||
|
Inset = new Inset(loader.with("Inset"));
|
||||||
|
Type = loader.getSchematicType("Type", "Normal");
|
||||||
|
SubTypes = loader.getSchematicTypeList("SubTypes");
|
||||||
|
Shortcut = loader.getString("Shortcut", "");
|
||||||
|
Material = loader.getMaterial("Material", "STONE_BUTTON");
|
||||||
|
ManualCheck = loader.getBoolean("ManualCheck", true);
|
||||||
|
Rotate = loader.getBoolean("Rotate", true);
|
||||||
|
PasteAligned = loader.getBoolean("PasteAligned", false);
|
||||||
|
OnlyPublicSchematics = loader.getBoolean("OnlyPublicSchematics", false);
|
||||||
|
IgnorePublicOnly = loader.getBoolean("IgnorePublicOnly", false);
|
||||||
|
ReplaceObsidianBedrock = loader.getBoolean("ReplaceObsidianBedrock", false);
|
||||||
|
ReplaceWithBlockupdates = loader.getBoolean("ReplaceWithBlockupdates", false);
|
||||||
|
UnlimitedPrepare = loader.getBoolean("UnlimitedPrepare", false);
|
||||||
|
MaxBlocks = loader.getInt("MaxBlocks", 0);
|
||||||
|
MaxDispenserItems = loader.getInt("MaxDispenserItems", 128);
|
||||||
|
MaxDesignBlastResistance = loader.getDouble("MaxDesignBlastResistance", Double.MAX_VALUE);
|
||||||
|
|
||||||
|
Map<Set<M>, Integer> Limited = new HashMap<>();
|
||||||
|
for (Map<?, ?> entry : loader.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(loader.materialMapper.apply(material.toUpperCase())), 0);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Limited.put(Collections.unmodifiableSet(materials.stream().map(String::toUpperCase).map(loader.materialMapper).collect(Collectors.toSet())), amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Limited = Collections.unmodifiableMap(Limited);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public static final class Size {
|
||||||
|
|
||||||
|
public final boolean loaded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code 0} by default
|
||||||
|
*/
|
||||||
|
public final int x;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code 0} by default
|
||||||
|
*/
|
||||||
|
public final int y;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code 0} by default
|
||||||
|
*/
|
||||||
|
public final int z;
|
||||||
|
|
||||||
|
private Size(YMLWrapper loader) {
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
x = loader.getInt("x", 0);
|
||||||
|
y = loader.getInt("y", 0);
|
||||||
|
z = loader.getInt("z", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public static final class Inset {
|
||||||
|
|
||||||
|
public final boolean loaded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code 0} by default
|
||||||
|
*/
|
||||||
|
public final int x;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code 0} by default
|
||||||
|
*/
|
||||||
|
public final int z;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code 0} by default
|
||||||
|
*/
|
||||||
|
public final int top;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code 0} by default
|
||||||
|
*/
|
||||||
|
public final int bottom;
|
||||||
|
|
||||||
|
private Inset(YMLWrapper loader) {
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
x = loader.getInt("x", 0);
|
||||||
|
z = loader.getInt("z", 0);
|
||||||
|
top = loader.getInt("top", 0);
|
||||||
|
bottom = loader.getInt("bottom", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public static final class Blue {
|
||||||
|
|
||||||
|
public final boolean loaded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code Blau} by default
|
||||||
|
*/
|
||||||
|
public final String Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code §3} by default
|
||||||
|
*/
|
||||||
|
public final String Prefix;
|
||||||
|
|
||||||
|
private Blue(YMLWrapper loader) {
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
Name = loader.getString("Name", "Blau");
|
||||||
|
Prefix = loader.getString("Prefix", "§3");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public static final class Red {
|
||||||
|
|
||||||
|
public final boolean loaded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code Rot} by default
|
||||||
|
*/
|
||||||
|
public final String Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implSpec {@code §c} by default
|
||||||
|
*/
|
||||||
|
public final String Prefix;
|
||||||
|
|
||||||
|
private Red(YMLWrapper loader) {
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
Name = loader.getString("Name", "Rot");
|
||||||
|
Prefix = loader.getString("Prefix", "§c");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public static final class WinConditionParams<M> {
|
||||||
|
|
||||||
|
public final boolean loaded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time of any of the timeout win conditions in seconds
|
||||||
|
*
|
||||||
|
* @implSpec {@code 1200} by default
|
||||||
|
*/
|
||||||
|
public final int TimeoutTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The percentage when any of the percent win conditions limits or triggers a win
|
||||||
|
*
|
||||||
|
* @implSpec {@code 7.0} by default
|
||||||
|
*/
|
||||||
|
public final double PercentWin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the percentage still change after the start of the enter phase
|
||||||
|
*
|
||||||
|
* @implSpec {@code true} by default
|
||||||
|
*/
|
||||||
|
public final boolean PercentEntern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is Blocks a whitelist (true) or blacklist (false)
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean BlocksWhitelist;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Special Blocks (Valid spigot material values) used by the percent win conditions
|
||||||
|
*/
|
||||||
|
public final List<M> Blocks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time for being declared TechKo without a shot given.
|
||||||
|
*
|
||||||
|
* @implSpec {@code 90} by default
|
||||||
|
*/
|
||||||
|
public final int TechKoTime;
|
||||||
|
|
||||||
|
private WinConditionParams(YMLWrapper<M, ?, ?> loader) {
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
TimeoutTime = loader.getInt("TimeoutTime", 1200);
|
||||||
|
PercentWin = loader.getDouble("PercentWin", 7.0);
|
||||||
|
PercentEntern = loader.getBoolean("PercentEntern", true);
|
||||||
|
BlocksWhitelist = loader.getBoolean("BlocksWhitelist", false);
|
||||||
|
Blocks = loader.getMaterialList("Blocks");
|
||||||
|
TechKoTime = loader.getInt("TechKoTime", 90);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public static final class Kits<M> {
|
||||||
|
|
||||||
|
public final boolean loaded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The kit file for this configuration
|
||||||
|
*
|
||||||
|
* @implSpec {@code kits.yml} by default
|
||||||
|
*/
|
||||||
|
public final String File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default kit for team members
|
||||||
|
*
|
||||||
|
* @implSpec {@code default} by default
|
||||||
|
*/
|
||||||
|
public final String MemberDefault;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default kit for team leaders
|
||||||
|
*
|
||||||
|
* @implSpec {@code default} by default
|
||||||
|
*/
|
||||||
|
public final String LeaderDefault;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the personal kit system is active
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean PersonalKits;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Items (Valid spigot material values) that are not allowed in the personal kit
|
||||||
|
*/
|
||||||
|
public final List<M> ForbiddenItems;
|
||||||
|
|
||||||
|
private Kits(YMLWrapper<M, ?, ?> loader) {
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
File = loader.getString("File", "kits.yml");
|
||||||
|
MemberDefault = loader.getString("MemberDefault", "default");
|
||||||
|
LeaderDefault = loader.getString("LeaderDefault", "default");
|
||||||
|
PersonalKits = loader.getBoolean("PersonalKits", false);
|
||||||
|
ForbiddenItems = loader.getMaterialList("ForbiddenItems");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public static final class Techhider<M> {
|
||||||
|
|
||||||
|
public final boolean loaded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activates the tech hider
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean Active;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Which block the tech hider replaces to.
|
||||||
|
*
|
||||||
|
* @implSpec {@code end_stone} by default
|
||||||
|
*/
|
||||||
|
public final M ObfuscateWith;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of all hidden blocks. "water" results in the hiding of all waterlogged blocks as well.
|
||||||
|
*/
|
||||||
|
public final Set<M> HiddenBlocks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The block entity contents that are hidden (here with minecraft:nametag)
|
||||||
|
*/
|
||||||
|
public final Set<String> HiddenBlockEntities;
|
||||||
|
|
||||||
|
private Techhider(YMLWrapper<M, ?, ?> loader) {
|
||||||
|
loaded = loader.canLoad();
|
||||||
|
Active = loader.getBoolean("Active", false);
|
||||||
|
ObfuscateWith = loader.getMaterial("ObfuscateWith", "end_stone");
|
||||||
|
HiddenBlocks = Collections.unmodifiableSet(new HashSet<>(loader.getMaterialList("HiddenBlocks")));
|
||||||
|
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(loader.getStringList("HiddenBlockEntities")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAfterDeadline() {
|
||||||
|
return Deadline != null && Deadline.before(Date.from(Instant.now()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String hasMap(String map) {
|
||||||
|
for (String m : Server.Maps) {
|
||||||
|
if (m.equalsIgnoreCase(map))
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRandomMap() {
|
||||||
|
return Server.Maps.get(random.nextInt(Server.Maps.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String convertToRealMapName(String map) {
|
||||||
|
for (String m : Server.Maps) {
|
||||||
|
if (m.equalsIgnoreCase(map))
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChatName() {
|
||||||
|
return Server.ChatNames.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
if (Server.ChatNames.isEmpty()) return false;
|
||||||
|
if (ActiveMonths.isEmpty()) return true;
|
||||||
|
return ActiveMonths.contains(LocalDateTime.now().getMonth().getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSchemTypeOrInternalName() {
|
||||||
|
if (Schematic.loaded) {
|
||||||
|
ST type = Schematic.Type;
|
||||||
|
if (type instanceof SchematicType) {
|
||||||
|
return ((SchematicType) type).toDB();
|
||||||
|
} else if (type instanceof String) {
|
||||||
|
return (String) type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return configFile.getName().replace(".yml", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2025 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.data;
|
||||||
|
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public abstract class YMLWrapper<M, ST, W> {
|
||||||
|
|
||||||
|
public static final Function<String, String> ToString = Function.identity();
|
||||||
|
public static final Function<String, SchematicType> ToSchematicType = SchematicType::fromDB;
|
||||||
|
|
||||||
|
protected final File file;
|
||||||
|
public final Function<String, M> materialMapper;
|
||||||
|
public final Function<String, ST> schematicTypeMapper;
|
||||||
|
public final Function<String, W> winconditionMapper;
|
||||||
|
|
||||||
|
protected YMLWrapper(File file, Function<String, M> materialMapper, Function<String, ST> schematicTypeMapper, Function<String, W> winconditionMapper) {
|
||||||
|
this.file = file;
|
||||||
|
this.materialMapper = materialMapper;
|
||||||
|
this.schematicTypeMapper = schematicTypeMapper;
|
||||||
|
this.winconditionMapper = winconditionMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final File getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract boolean canLoad();
|
||||||
|
|
||||||
|
public abstract YMLWrapper<M, ST, W> with(String path);
|
||||||
|
|
||||||
|
public abstract String getDefaultGameName();
|
||||||
|
|
||||||
|
public abstract String getString(String path, String defaultValue);
|
||||||
|
|
||||||
|
public abstract int getInt(String path, int defaultValue);
|
||||||
|
|
||||||
|
public abstract double getDouble(String path, double defaultValue);
|
||||||
|
|
||||||
|
public abstract boolean getBoolean(String path, boolean defaultValue);
|
||||||
|
|
||||||
|
public final ST getSchematicType(String path, String defaultValue) {
|
||||||
|
String schematicType = getString(path, defaultValue);
|
||||||
|
return schematicTypeMapper.apply(schematicType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final M getMaterial(String path, String defaultValue) {
|
||||||
|
return materialMapper.apply(getString(path, defaultValue).toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract List<String> getStringList(String path);
|
||||||
|
|
||||||
|
public abstract List<Integer> getIntList(String path);
|
||||||
|
|
||||||
|
public final List<ST> getSchematicTypeList(String path) {
|
||||||
|
List<String> list = getStringList(path);
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
} else {
|
||||||
|
return Collections.unmodifiableList(list.stream().map(schematicTypeMapper).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final List<M> getMaterialList(String path) {
|
||||||
|
List<String> list = getStringList(path);
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
} else {
|
||||||
|
return Collections.unmodifiableList(list.stream().map(String::toUpperCase).map(materialMapper).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract List<Map<?, ?>> getMapList(String path);
|
||||||
|
}
|
||||||
@@ -21,9 +21,11 @@ package de.steamwar.sql;
|
|||||||
|
|
||||||
import de.steamwar.sql.internal.SqlTypeMapper;
|
import de.steamwar.sql.internal.SqlTypeMapper;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class SchematicType {
|
public class SchematicType {
|
||||||
|
|
||||||
public static final SchematicType Normal = new SchematicType("Normal", "", Type.NORMAL, null, "STONE_BUTTON", false);
|
public static final SchematicType Normal = new SchematicType("Normal", "", Type.NORMAL, null, "STONE_BUTTON", false);
|
||||||
@@ -38,7 +40,10 @@ public class SchematicType {
|
|||||||
tmpTypes.add(Normal);
|
tmpTypes.add(Normal);
|
||||||
tmpFromDB.put(Normal.name().toLowerCase(), Normal);
|
tmpFromDB.put(Normal.name().toLowerCase(), Normal);
|
||||||
|
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
SQLWrapper.impl.loadSchemTypes(tmpTypes, tmpFromDB);
|
SQLWrapper.impl.loadSchemTypes(tmpTypes, tmpFromDB);
|
||||||
|
time = System.currentTimeMillis() - time;
|
||||||
|
log.info("Loaded {} Schematic Types in {}ms", tmpTypes.size(), time);
|
||||||
|
|
||||||
fromDB = Collections.unmodifiableMap(tmpFromDB);
|
fromDB = Collections.unmodifiableMap(tmpFromDB);
|
||||||
types = Collections.unmodifiableList(tmpTypes);
|
types = Collections.unmodifiableList(tmpTypes);
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ Server:
|
|||||||
# If ranked matches should be available for the game mode
|
# If ranked matches should be available for the game mode
|
||||||
Ranked: false # defaults to false if missing
|
Ranked: false # defaults to false if missing
|
||||||
|
|
||||||
# The questions that have to be answered to accept the schematic
|
# Submission deadline for schematics in 'dd.MM.yyyy HH:mm' format
|
||||||
CheckQuestions: [] # Disables check schem type if missing
|
Deadline: null # defaults to null if missing
|
||||||
|
|
||||||
# The available schematic ranks
|
# The questions that have to be answered to accept the schematic
|
||||||
Ranks: [] # Disables ranks for this schematic type if missing
|
CheckQuestions: [] # Disables check schem type if missing
|
||||||
|
|
||||||
Times:
|
Times:
|
||||||
# Time in seconds the server stops after starting if nobody joins
|
# Time in seconds the server stops after starting if nobody joins
|
||||||
@@ -52,6 +52,8 @@ Arena:
|
|||||||
Leaveable: false # defaults to false if missing
|
Leaveable: false # defaults to false if missing
|
||||||
# Allow missiles to fly to the enemy and not stop at the schem border.
|
# Allow missiles to fly to the enemy and not stop at the schem border.
|
||||||
AllowMissiles: false # defaults to true if EnterStages are present otherwise 'false'
|
AllowMissiles: false # defaults to true if EnterStages are present otherwise 'false'
|
||||||
|
# Denotes that there is no floor for this GameMode
|
||||||
|
NoFloor: false # defaults to false if missing
|
||||||
|
|
||||||
Schematic:
|
Schematic:
|
||||||
# The size of the schematics
|
# The size of the schematics
|
||||||
@@ -59,6 +61,12 @@ Schematic:
|
|||||||
x: 0
|
x: 0
|
||||||
y: 0
|
y: 0
|
||||||
z: 0
|
z: 0
|
||||||
|
# Used for GameModes with a technic area
|
||||||
|
Inset:
|
||||||
|
x: 0
|
||||||
|
z: 0
|
||||||
|
top: 0
|
||||||
|
bottom: 0
|
||||||
# The schematic type that can be chosen in this arena
|
# The schematic type that can be chosen in this arena
|
||||||
Type: Normal # defaults to Normal if missing
|
Type: Normal # defaults to Normal if missing
|
||||||
# The schematic types that are also allowed to be chosen in this arena
|
# The schematic types that are also allowed to be chosen in this arena
|
||||||
@@ -87,6 +95,8 @@ Schematic:
|
|||||||
MaxBlocks: 0 # defaults to 0 (ignored) if missing
|
MaxBlocks: 0 # defaults to 0 (ignored) if missing
|
||||||
# Maximal amount of items per dispenser
|
# Maximal amount of items per dispenser
|
||||||
MaxDispenserItems: 128 # defaults to 128 if missing
|
MaxDispenserItems: 128 # defaults to 128 if missing
|
||||||
|
# Maximal blast resistance for the design blocks
|
||||||
|
MaxDesignBlastResistance: 100000000 # defaults to Double.MAX_VALUE if missing
|
||||||
# List of limited material (combinations)
|
# List of limited material (combinations)
|
||||||
# List contains tags Amount (integer) and Materials (List of material names in Spigot 1.12 AND Spigot 1.15 format)
|
# List contains tags Amount (integer) and Materials (List of material names in Spigot 1.12 AND Spigot 1.15 format)
|
||||||
Limited:
|
Limited:
|
||||||
@@ -95,6 +105,9 @@ Schematic:
|
|||||||
|
|
||||||
# The name of the game mode presented to the players
|
# The name of the game mode presented to the players
|
||||||
GameName: WarGear # defaults to WarGear if missing
|
GameName: WarGear # defaults to WarGear if missing
|
||||||
|
# The months this game mode should be active and playable
|
||||||
|
# The empty List means all of them
|
||||||
|
ActiveMonths: [] # defaults to none if missing
|
||||||
# The prefix used for team chats
|
# The prefix used for team chats
|
||||||
TeamChatPrefix: + # defaults to + if missing
|
TeamChatPrefix: + # defaults to + if missing
|
||||||
Blue:
|
Blue:
|
||||||
@@ -137,6 +150,8 @@ WinConditionParams:
|
|||||||
BlocksWhitelist: false # defaults to false if missing
|
BlocksWhitelist: false # defaults to false if missing
|
||||||
# Special Blocks (Valid spigot material values) used by the percent win conditions
|
# Special Blocks (Valid spigot material values) used by the percent win conditions
|
||||||
Blocks: [] # defaults to none if missing
|
Blocks: [] # defaults to none if missing
|
||||||
|
# Time for being declared TechKo without a shot given.
|
||||||
|
TechKoTime: 90 # defaults to 90 if missing
|
||||||
|
|
||||||
Kits:
|
Kits:
|
||||||
# The kit file for this configuration
|
# The kit file for this configuration
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem;
|
package de.steamwar.fightsystem;
|
||||||
|
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
|
import de.steamwar.data.YMLWrapperImpl;
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.*;
|
||||||
@@ -32,9 +34,10 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
|
|
||||||
@@ -42,15 +45,7 @@ public class Config {
|
|||||||
|
|
||||||
public static final World world = Bukkit.getWorlds().get(0);
|
public static final World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
//Fight sequence
|
public static final GameModeConfig<Material, SchematicType, Winconditions> GameModeConfig;
|
||||||
public static final int NoPlayerOnlineDuration;
|
|
||||||
public static final int PreSchemPasteDuration;
|
|
||||||
public static final int SetupDuration;
|
|
||||||
public static final int PreFightDuration;
|
|
||||||
public static final int SpectatorDuration;
|
|
||||||
|
|
||||||
// entern parameter
|
|
||||||
public static final List<Integer> EnterStages;
|
|
||||||
|
|
||||||
//arena parameter
|
//arena parameter
|
||||||
public static final Region BluePasteRegion;
|
public static final Region BluePasteRegion;
|
||||||
@@ -69,60 +64,20 @@ public class Config {
|
|||||||
private static final int BlueToRedY;
|
private static final int BlueToRedY;
|
||||||
public static final int BlueToRedZ;
|
public static final int BlueToRedZ;
|
||||||
|
|
||||||
public static final int PreperationArea;
|
|
||||||
public static final int WaterDepth;
|
|
||||||
public static final boolean GroundWalkable;
|
|
||||||
public static final boolean DisableSnowMelt;
|
|
||||||
public static final boolean ArenaLeaveable;
|
|
||||||
public static final boolean AllowMissiles;
|
|
||||||
|
|
||||||
//schematic parameter
|
//schematic parameter
|
||||||
public static final boolean RanksEnabled;
|
|
||||||
public static final boolean OnlyPublicSchematics;
|
public static final boolean OnlyPublicSchematics;
|
||||||
public static final boolean IgnorePublicOnly;
|
|
||||||
public static final de.steamwar.sql.SchematicType SchematicType;
|
|
||||||
public static final List<de.steamwar.sql.SchematicType> SubTypes;
|
|
||||||
public static final boolean RedRotate;
|
public static final boolean RedRotate;
|
||||||
public static final boolean BlueRotate;
|
public static final boolean BlueRotate;
|
||||||
public static final boolean PasteAligned;
|
|
||||||
public static final boolean ReplaceObsidianBedrock;
|
|
||||||
public static final boolean ReplaceWithBlockupdates;
|
|
||||||
public static final boolean UnlimitedPrepare;
|
|
||||||
|
|
||||||
//team parameter
|
//team parameter
|
||||||
public static final String TeamRedName;
|
public static final String TeamRedName;
|
||||||
public static final String TeamBlueName;
|
public static final String TeamBlueName;
|
||||||
public static final String TeamRedColor;
|
public static final String TeamRedColor;
|
||||||
public static final String TeamBlueColor;
|
public static final String TeamBlueColor;
|
||||||
public static final String GameName;
|
|
||||||
public static final String TeamChatDetection;
|
|
||||||
public static final UUID BlueLeader;
|
public static final UUID BlueLeader;
|
||||||
public static final UUID RedLeader;
|
public static final UUID RedLeader;
|
||||||
|
|
||||||
//Active win conditions
|
|
||||||
public static final Set<Winconditions> ActiveWinconditions;
|
|
||||||
|
|
||||||
//win condition parameters
|
|
||||||
public static final int TimeoutTime;
|
|
||||||
public static final double PercentWin;
|
|
||||||
public static final boolean PercentEntern;
|
|
||||||
public static final boolean PercentBlocksWhitelist;
|
|
||||||
public static final Set<Material> PercentBlocks;
|
|
||||||
public static final int TechKoTime;
|
|
||||||
|
|
||||||
//default kits
|
|
||||||
public static final String MemberDefault;
|
|
||||||
public static final String LeaderDefault;
|
|
||||||
public static final boolean PersonalKits;
|
|
||||||
public static final Set<Material> ForbiddenItems;
|
|
||||||
public static final String KitFile;
|
|
||||||
|
|
||||||
//tech hider parameter
|
|
||||||
public static final boolean TechhiderActive;
|
|
||||||
public static final Set<Material> HiddenBlocks;
|
|
||||||
public static final Set<String> HiddenBlockEntities;
|
|
||||||
public static final Material ObfuscateWith;
|
|
||||||
|
|
||||||
//event parameter
|
//event parameter
|
||||||
public static final EventFight EventKampf;
|
public static final EventFight EventKampf;
|
||||||
private static final Set<Integer> Referees;
|
private static final Set<Integer> Referees;
|
||||||
@@ -154,7 +109,7 @@ public class Config {
|
|||||||
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
|
Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!");
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
}
|
}
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(FightSystem.getPlugin().getDataFolder(), configFile));
|
GameModeConfig = new GameModeConfig<>(YMLWrapperImpl.ofTyped(new File(FightSystem.getPlugin().getDataFolder(), configFile), Winconditions::valueOf));
|
||||||
|
|
||||||
File worldConfigFile = new File(world.getWorldFolder(), "config.yml");
|
File worldConfigFile = new File(world.getWorldFolder(), "config.yml");
|
||||||
if(!worldConfigFile.exists()) {
|
if(!worldConfigFile.exists()) {
|
||||||
@@ -163,111 +118,37 @@ public class Config {
|
|||||||
}
|
}
|
||||||
FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile);
|
FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile);
|
||||||
|
|
||||||
NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration", 300);
|
|
||||||
PreSchemPasteDuration = config.getInt("Times.PreSchemPasteDuration", 120);
|
|
||||||
SetupDuration = config.getInt("Times.SetupDuration", 300);
|
|
||||||
PreFightDuration = config.getInt("Times.PreFightDuration", 30);
|
|
||||||
SpectatorDuration = config.getInt("Times.SpectatorDuration", 30);
|
|
||||||
|
|
||||||
int blueCornerX = worldconfig.getInt("BlueCorner.x");
|
int blueCornerX = worldconfig.getInt("BlueCorner.x");
|
||||||
int blueCornerY = worldconfig.getInt("BlueCorner.y");
|
int blueCornerY = worldconfig.getInt("BlueCorner.y");
|
||||||
int blueCornerZ = worldconfig.getInt("BlueCorner.z");
|
int blueCornerZ = worldconfig.getInt("BlueCorner.z");
|
||||||
int underBorder = worldconfig.getInt("UnderBorder", blueCornerY);
|
int underBorder = worldconfig.getInt("UnderBorder", blueCornerY);
|
||||||
|
|
||||||
WaterDepth = config.getInt("Arena.WaterDepth", 0);
|
|
||||||
int schem2BorderX = config.getInt("Arena.Schem2Border.x", 24);
|
|
||||||
int schem2BorderZ = config.getInt("Arena.Schem2Border.z", 24);
|
|
||||||
PreperationArea = config.getInt("Arena.BorderFromSchematic", 12);
|
|
||||||
GroundWalkable = config.getBoolean("Arena.GroundWalkable", true);
|
|
||||||
DisableSnowMelt = config.getBoolean("Arena.DisableSnowMelt", false);
|
|
||||||
ArenaLeaveable = config.getBoolean("Arena.Leaveable", false);
|
|
||||||
|
|
||||||
int schemsizeX = config.getInt("Schematic.Size.x");
|
|
||||||
int schemsizeY = config.getInt("Schematic.Size.y");
|
|
||||||
int schemsizeZ = config.getInt("Schematic.Size.z");
|
|
||||||
RanksEnabled = !config.getStringList("Ranks").isEmpty();
|
|
||||||
SchematicType = de.steamwar.sql.SchematicType.fromDB(Objects.requireNonNull(config.getString("Schematic.Type", "normal")));
|
|
||||||
SubTypes = config.getStringList("Schematic.SubTypes").stream().map(de.steamwar.sql.SchematicType::fromDB).collect(Collectors.toList());
|
|
||||||
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly", false);
|
|
||||||
boolean rotate = config.getBoolean("Schematic.Rotate", true);
|
|
||||||
PasteAligned = config.getBoolean("Schematic.PasteAligned", false);
|
|
||||||
ReplaceObsidianBedrock = config.getBoolean("Schematic.ReplaceObsidianBedrock", false);
|
|
||||||
ReplaceWithBlockupdates = config.getBoolean("Schematic.ReplaceWithBlockupdates", false);
|
|
||||||
UnlimitedPrepare = config.getBoolean("Schematic.UnlimitedPrepare", false);
|
|
||||||
|
|
||||||
int schemInsetX = config.getInt("Schematic.Inset.x", 0);
|
|
||||||
int schemInsetZ = config.getInt("Schematic.Inset.z", 0);
|
|
||||||
int schemInsetBottom = config.getInt("Schematic.Inset.bottom", 0);
|
|
||||||
int schemInsetTop = config.getInt("Schematic.Inset.top", 0);
|
|
||||||
|
|
||||||
GameName = config.getString("GameName", "WarGear");
|
|
||||||
TeamChatDetection = config.getString("TeamChatPrefix", "+");
|
|
||||||
|
|
||||||
ActiveWinconditions = Collections.unmodifiableSet(config.getStringList("WinConditions").stream().map(Winconditions::valueOf).collect(Collectors.toSet()));
|
|
||||||
|
|
||||||
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime", 1200);
|
|
||||||
PercentWin = config.getDouble("WinConditionParams.PercentWin", 7.0);
|
|
||||||
PercentEntern = config.getBoolean("WinConditionParams.PercentEntern", true);
|
|
||||||
PercentBlocksWhitelist = config.getBoolean("WinConditionParams.BlocksWhitelist", false);
|
|
||||||
PercentBlocks = Collections.unmodifiableSet(config.getStringList("WinConditionParams.Blocks").stream().map(Material::valueOf).collect(Collectors.toSet()));
|
|
||||||
TechKoTime = config.getInt("WinConditionParams.TechKoTime", 90);
|
|
||||||
|
|
||||||
EnterStages = Collections.unmodifiableList(config.getIntegerList("EnterStages"));
|
|
||||||
AllowMissiles = config.getBoolean("Arena.AllowMissiles", !EnterStages.isEmpty());
|
|
||||||
|
|
||||||
KitFile = config.getString("Kits.File", "kits.yml");
|
|
||||||
MemberDefault = config.getString("Kits.MemberDefault", "default");
|
|
||||||
LeaderDefault = config.getString("Kits.LeaderDefault", "default");
|
|
||||||
PersonalKits = config.getBoolean("Kits.PersonalKits", false);
|
|
||||||
ForbiddenItems = Collections.unmodifiableSet(config.getStringList("Kits.ForbiddenItems").stream().map(Material::valueOf).collect(Collectors.toSet()));
|
|
||||||
|
|
||||||
TechhiderActive = config.getBoolean("Techhider.Active", false);
|
|
||||||
ObfuscateWith = Material.getMaterial(config.getString("Techhider.ObfuscateWith", "end_stone").toUpperCase());
|
|
||||||
HiddenBlocks = config.getStringList("Techhider.HiddenBlocks").stream().map(String::toUpperCase).map(Material::getMaterial).collect(Collectors.toSet());
|
|
||||||
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
|
|
||||||
|
|
||||||
if(schemsizeX < 0){
|
|
||||||
schemsizeX = -schemsizeX;
|
|
||||||
blueCornerX = blueCornerX - schemsizeX;
|
|
||||||
}
|
|
||||||
if(schemsizeY < 0){
|
|
||||||
schemsizeY = -schemsizeY;
|
|
||||||
blueCornerY = blueCornerY - schemsizeY;
|
|
||||||
}
|
|
||||||
if(schemsizeZ < 0){
|
|
||||||
schemsizeZ = -schemsizeZ;
|
|
||||||
blueCornerZ = blueCornerZ - schemsizeZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlueToRedX = worldconfig.getInt("BlueToRed.x", 0);
|
BlueToRedX = worldconfig.getInt("BlueToRed.x", 0);
|
||||||
BlueToRedY = worldconfig.getInt("BlueToRed.y", 0);
|
BlueToRedY = worldconfig.getInt("BlueToRed.y", 0);
|
||||||
BlueToRedZ = worldconfig.getInt("BlueToRed.z", schemsizeZ + 50);
|
BlueToRedZ = worldconfig.getInt("BlueToRed.z", GameModeConfig.Schematic.Size.z + 50);
|
||||||
double teamBlueSpawnOffsetX = config.getDouble("Arena.SpawnOffset.x", 0);
|
|
||||||
double teamBlueSpawnOffsetY = config.getDouble("Arena.SpawnOffset.y", schemsizeY);
|
|
||||||
double teamBlueSpawnOffsetZ = config.getDouble("Arena.SpawnOffset.z", 0);
|
|
||||||
|
|
||||||
int teamRedCornerX = BlueToRedX + blueCornerX;
|
int teamRedCornerX = BlueToRedX + blueCornerX;
|
||||||
int teamRedCornerY = BlueToRedY + blueCornerY;
|
int teamRedCornerY = BlueToRedY + blueCornerY;
|
||||||
int teamRedCornerZ = BlueToRedZ + blueCornerZ;
|
int teamRedCornerZ = BlueToRedZ + blueCornerZ;
|
||||||
|
|
||||||
int teamBluePasteX = blueCornerX + schemsizeX / 2;
|
int teamBluePasteX = blueCornerX + GameModeConfig.Schematic.Size.x / 2;
|
||||||
int teamBluePasteZ = blueCornerZ + schemsizeZ / 2;
|
int teamBluePasteZ = blueCornerZ + GameModeConfig.Schematic.Size.z / 2;
|
||||||
int teamRedPasteX = teamBluePasteX + BlueToRedX;
|
int teamRedPasteX = teamBluePasteX + BlueToRedX;
|
||||||
int teamRedPasteZ = teamBluePasteZ + BlueToRedZ;
|
int teamRedPasteZ = teamBluePasteZ + BlueToRedZ;
|
||||||
|
|
||||||
TeamBlueSpawn = new Location(world,
|
TeamBlueSpawn = new Location(world,
|
||||||
teamBluePasteX + 0.5 + teamBlueSpawnOffsetX,
|
teamBluePasteX + 0.5 + GameModeConfig.Arena.SpawnOffset.x,
|
||||||
blueCornerY + 0.5 + teamBlueSpawnOffsetY,
|
blueCornerY + 0.5 + GameModeConfig.Arena.SpawnOffset.y,
|
||||||
teamBluePasteZ + 0.5 + teamBlueSpawnOffsetZ);
|
teamBluePasteZ + 0.5 + GameModeConfig.Arena.SpawnOffset.z);
|
||||||
|
|
||||||
TeamRedSpawn = new Location(world,
|
TeamRedSpawn = new Location(world,
|
||||||
teamRedPasteX + 0.5 - teamBlueSpawnOffsetX,
|
teamRedPasteX + 0.5 - GameModeConfig.Arena.SpawnOffset.x,
|
||||||
teamRedCornerY + 0.5 + teamBlueSpawnOffsetY,
|
teamRedCornerY + 0.5 + GameModeConfig.Arena.SpawnOffset.y,
|
||||||
teamRedPasteZ + 0.5 - teamBlueSpawnOffsetZ);
|
teamRedPasteZ + 0.5 - GameModeConfig.Arena.SpawnOffset.z);
|
||||||
|
|
||||||
SpecSpawn = new Location(world,
|
SpecSpawn = new Location(world,
|
||||||
teamBluePasteX + BlueToRedX /2.0,
|
teamBluePasteX + BlueToRedX /2.0,
|
||||||
blueCornerY + BlueToRedY /2.0 + schemsizeY/2.0,
|
blueCornerY + BlueToRedY /2.0 + GameModeConfig.Schematic.Size.y/2.0,
|
||||||
teamBluePasteZ + BlueToRedZ /2.0);
|
teamBluePasteZ + BlueToRedZ /2.0);
|
||||||
|
|
||||||
Vector v1 = TeamBlueSpawn.toVector().subtract(TeamRedSpawn.toVector());
|
Vector v1 = TeamBlueSpawn.toVector().subtract(TeamRedSpawn.toVector());
|
||||||
@@ -288,45 +169,45 @@ public class Config {
|
|||||||
int arenaMinZ;
|
int arenaMinZ;
|
||||||
int arenaMaxZ;
|
int arenaMaxZ;
|
||||||
if(BlueToRedX > 0){
|
if(BlueToRedX > 0){
|
||||||
arenaMinX = blueCornerX - schem2BorderX;
|
arenaMinX = blueCornerX - GameModeConfig.Arena.Schem2Border.x;
|
||||||
arenaMaxX = teamRedCornerX + schemsizeX + schem2BorderX;
|
arenaMaxX = teamRedCornerX + GameModeConfig.Schematic.Size.x + GameModeConfig.Arena.Schem2Border.x;
|
||||||
teamRedRotate = true;
|
teamRedRotate = true;
|
||||||
teamBlueRotate = false;
|
teamBlueRotate = false;
|
||||||
}else{
|
}else{
|
||||||
arenaMinX = teamRedCornerX - schem2BorderX;
|
arenaMinX = teamRedCornerX - GameModeConfig.Arena.Schem2Border.x;
|
||||||
arenaMaxX = blueCornerX + schemsizeX + schem2BorderX;
|
arenaMaxX = blueCornerX + GameModeConfig.Schematic.Size.x + GameModeConfig.Arena.Schem2Border.x;
|
||||||
teamRedRotate = false;
|
teamRedRotate = false;
|
||||||
teamBlueRotate = true;
|
teamBlueRotate = true;
|
||||||
}
|
}
|
||||||
if(BlueToRedZ > 0){
|
if(BlueToRedZ > 0){
|
||||||
arenaMinZ = blueCornerZ - schem2BorderZ;
|
arenaMinZ = blueCornerZ - GameModeConfig.Arena.Schem2Border.z;
|
||||||
arenaMaxZ = teamRedCornerZ + schemsizeZ + schem2BorderZ;
|
arenaMaxZ = teamRedCornerZ + GameModeConfig.Schematic.Size.z + GameModeConfig.Arena.Schem2Border.z;
|
||||||
teamRedRotate = true;
|
teamRedRotate = true;
|
||||||
teamBlueRotate = false;
|
teamBlueRotate = false;
|
||||||
}else{
|
}else{
|
||||||
arenaMinZ = teamRedCornerZ - schem2BorderZ;
|
arenaMinZ = teamRedCornerZ - GameModeConfig.Arena.Schem2Border.z;
|
||||||
arenaMaxZ = blueCornerZ + schemsizeZ + schem2BorderZ;
|
arenaMaxZ = blueCornerZ + GameModeConfig.Schematic.Size.z + GameModeConfig.Arena.Schem2Border.z;
|
||||||
if(BlueToRedZ != 0){
|
if(BlueToRedZ != 0){
|
||||||
teamRedRotate = false;
|
teamRedRotate = false;
|
||||||
teamBlueRotate = true;
|
teamBlueRotate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!rotate){
|
if(!GameModeConfig.Schematic.Rotate){
|
||||||
teamRedRotate = false;
|
teamRedRotate = false;
|
||||||
teamBlueRotate = false;
|
teamBlueRotate = false;
|
||||||
}
|
}
|
||||||
RedRotate = teamRedRotate;
|
RedRotate = teamRedRotate;
|
||||||
BlueRotate = teamBlueRotate;
|
BlueRotate = teamBlueRotate;
|
||||||
|
|
||||||
RedPasteRegion = Region.fromSize(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
RedPasteRegion = Region.fromSize(teamRedCornerX, teamRedCornerY, teamRedCornerZ, GameModeConfig.Schematic.Size.x, GameModeConfig.Schematic.Size.y, GameModeConfig.Schematic.Size.z);
|
||||||
BluePasteRegion = Region.fromSize(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
|
BluePasteRegion = Region.fromSize(blueCornerX, blueCornerY, blueCornerZ, GameModeConfig.Schematic.Size.x, GameModeConfig.Schematic.Size.y, GameModeConfig.Schematic.Size.z);
|
||||||
|
|
||||||
RedExtendRegion = Region.withExtension(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
|
RedExtendRegion = Region.withExtension(teamRedCornerX, teamRedCornerY, teamRedCornerZ, GameModeConfig.Schematic.Size.x, GameModeConfig.Schematic.Size.y, GameModeConfig.Schematic.Size.z, GameModeConfig.Arena.BorderFromSchematic, GameModeConfig.Arena.BorderFromSchematic, GameModeConfig.Arena.BorderFromSchematic);
|
||||||
BlueExtendRegion = Region.withExtension(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
|
BlueExtendRegion = Region.withExtension(blueCornerX, blueCornerY, blueCornerZ, GameModeConfig.Schematic.Size.x, GameModeConfig.Schematic.Size.y, GameModeConfig.Schematic.Size.z, GameModeConfig.Arena.BorderFromSchematic, GameModeConfig.Arena.BorderFromSchematic, GameModeConfig.Arena.BorderFromSchematic);
|
||||||
ArenaRegion = Region.withExtension(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0);
|
ArenaRegion = Region.withExtension(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, GameModeConfig.Schematic.Size.y, arenaMaxZ - arenaMinZ, 0, GameModeConfig.Arena.BorderFromSchematic, 0);
|
||||||
PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX, world.getMaxHeight(), arenaMaxZ);
|
PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX, world.getMaxHeight(), arenaMaxZ);
|
||||||
|
|
||||||
BlueInsetRegion = new Region(BluePasteRegion.getMinX() + schemInsetX, BluePasteRegion.getMinY() + schemInsetBottom, BluePasteRegion.getMinZ() + schemInsetZ, BluePasteRegion.getMaxX() - schemInsetX, BluePasteRegion.getMaxY() - schemInsetTop, BluePasteRegion.getMaxZ() - schemInsetZ);
|
BlueInsetRegion = new Region(BluePasteRegion.getMinX() + GameModeConfig.Schematic.Inset.x, BluePasteRegion.getMinY() + GameModeConfig.Schematic.Inset.bottom, BluePasteRegion.getMinZ() + GameModeConfig.Schematic.Inset.z, BluePasteRegion.getMaxX() - GameModeConfig.Schematic.Inset.x, BluePasteRegion.getMaxY() - GameModeConfig.Schematic.Inset.top, BluePasteRegion.getMaxZ() - GameModeConfig.Schematic.Inset.z);
|
||||||
|
|
||||||
int eventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
int eventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||||
if(eventKampfID >= 1){
|
if(eventKampfID >= 1){
|
||||||
@@ -368,11 +249,11 @@ public class Config {
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//No event
|
//No event
|
||||||
TeamRedColor = config.getString("Red.Prefix", "§c");
|
TeamRedColor = GameModeConfig.Red.Prefix;
|
||||||
TeamBlueColor = config.getString("Blue.Prefix", "§9");
|
TeamBlueColor = GameModeConfig.Blue.Prefix;
|
||||||
TeamRedName = config.getString("Red.Name", "Rot");
|
TeamRedName = GameModeConfig.Red.Name;
|
||||||
TeamBlueName = config.getString("Blue.Name", "Blau");
|
TeamBlueName = GameModeConfig.Blue.Name;
|
||||||
OnlyPublicSchematics = config.getBoolean("Schematic.OnlyPublicSchematics", false);
|
OnlyPublicSchematics = GameModeConfig.Schematic.OnlyPublicSchematics;
|
||||||
EventTeamBlueID = 0;
|
EventTeamBlueID = 0;
|
||||||
EventTeamRedID = 0;
|
EventTeamRedID = 0;
|
||||||
EventKampf = null;
|
EventKampf = null;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class DummyAI extends AI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SchematicNode chooseSchematic() {
|
public SchematicNode chooseSchematic() {
|
||||||
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.SchematicType.toDB());
|
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.GameModeConfig.Schematic.Type.toDB());
|
||||||
return publics.get(random.nextInt(publics.size()));
|
return publics.get(random.nextInt(publics.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,8 +149,8 @@ public class Commands {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Kit k = null;
|
Kit k = null;
|
||||||
if(Config.PersonalKits){
|
if(Config.GameModeConfig.Kits.PersonalKits){
|
||||||
PersonalKit kit = PersonalKit.get(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB(), kitName);
|
PersonalKit kit = PersonalKit.get(SteamwarUser.get(p.getUniqueId()).getId(), Config.GameModeConfig.Schematic.Type.toDB(), kitName);
|
||||||
if(kit != null){
|
if(kit != null){
|
||||||
kit.setInUse();
|
kit.setInUse();
|
||||||
k = new Kit(kit);
|
k = new Kit(kit);
|
||||||
|
|||||||
@@ -152,8 +152,8 @@ public class GUI {
|
|||||||
|
|
||||||
List<SWListInv.SWListEntry<Kit>> entries = new ArrayList<>();
|
List<SWListInv.SWListEntry<Kit>> entries = new ArrayList<>();
|
||||||
|
|
||||||
if(Config.PersonalKits){
|
if(Config.GameModeConfig.Kits.PersonalKits){
|
||||||
List<PersonalKit> kits = PersonalKit.get(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB());
|
List<PersonalKit> kits = PersonalKit.get(SteamwarUser.get(p.getUniqueId()).getId(), Config.GameModeConfig.Schematic.Type.toDB());
|
||||||
kits.forEach(kit -> entries.add(new SWListInv.SWListEntry<>(new SWItem(Material.LEATHER_CHESTPLATE, "§e" + kit.getName(), new ArrayList<>(), kit.isInUse(), clickType -> {}), new Kit(kit))));
|
kits.forEach(kit -> entries.add(new SWListInv.SWListEntry<>(new SWItem(Material.LEATHER_CHESTPLATE, "§e" + kit.getName(), new ArrayList<>(), kit.isInUse(), clickType -> {}), new Kit(kit))));
|
||||||
}else{
|
}else{
|
||||||
List<Kit> kitList = Kit.getAvailableKits(fightPlayer.isLeader());
|
List<Kit> kitList = Kit.getAvailableKits(fightPlayer.isLeader());
|
||||||
@@ -169,19 +169,19 @@ public class GUI {
|
|||||||
if(entries.isEmpty()) {
|
if(entries.isEmpty()) {
|
||||||
inv.setItem(22, new SWItem(Material.BARRIER, msg.parse("KIT_NO_KITS", p)));
|
inv.setItem(22, new SWItem(Material.BARRIER, msg.parse("KIT_NO_KITS", p)));
|
||||||
}
|
}
|
||||||
if(Config.PersonalKits){
|
if(Config.GameModeConfig.Kits.PersonalKits){
|
||||||
inv.setItem(48, Material.NETHER_STAR, msg.parse("KIT_CREATE", p), clickType -> {
|
inv.setItem(48, Material.NETHER_STAR, msg.parse("KIT_CREATE", p), clickType -> {
|
||||||
SWAnvilInv anvilInv = new SWAnvilInv(p, msg.parse("KITNAME_TITLE", p));
|
SWAnvilInv anvilInv = new SWAnvilInv(p, msg.parse("KITNAME_TITLE", p));
|
||||||
anvilInv.setItem(Material.LEATHER_CHESTPLATE);
|
anvilInv.setItem(Material.LEATHER_CHESTPLATE);
|
||||||
anvilInv.setCallback(s -> {
|
anvilInv.setCallback(s -> {
|
||||||
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
||||||
if(PersonalKit.get(user.getId(), Config.SchematicType.toDB(), s) != null) {
|
if(PersonalKit.get(user.getId(), Config.GameModeConfig.Schematic.Type.toDB(), s) != null) {
|
||||||
msg.sendPrefixless("KITNAME_IN_USE", p, ChatMessageType.ACTION_BAR);
|
msg.sendPrefixless("KITNAME_IN_USE", p, ChatMessageType.ACTION_BAR);
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Kit prototype = Kit.getAvailableKits(Fight.getFightPlayer(p).isLeader()).get(0);
|
Kit prototype = Kit.getAvailableKits(Fight.getFightPlayer(p).isLeader()).get(0);
|
||||||
PersonalKit kit = PersonalKit.create(user.getId(), Config.SchematicType.toDB(), s, prototype.getInventory(), prototype.getArmor());
|
PersonalKit kit = PersonalKit.create(user.getId(), Config.GameModeConfig.Schematic.Type.toDB(), s, prototype.getInventory(), prototype.getArmor());
|
||||||
PersonalKitCreator.openKitCreator(p, kit);
|
PersonalKitCreator.openKitCreator(p, kit);
|
||||||
});
|
});
|
||||||
anvilInv.open();
|
anvilInv.open();
|
||||||
@@ -202,14 +202,14 @@ public class GUI {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int invSize = (Config.SubTypes.size() + 1) * 9;
|
int invSize = (Config.GameModeConfig.Schematic.SubTypes.size() + 1) * 9;
|
||||||
SWInventory inv = new SWInventory(p, invSize, msg.parse("SCHEM_TITLE", p, Config.GameName));
|
SWInventory inv = new SWInventory(p, invSize, msg.parse("SCHEM_TITLE", p, Config.GameModeConfig.GameName));
|
||||||
setupSchemTypeRow(p, inv, Config.SchematicType, 0);
|
setupSchemTypeRow(p, inv, Config.GameModeConfig.Schematic.Type, 0);
|
||||||
for (int i = 0; i < Config.SubTypes.size(); i++) {
|
for (int i = 0; i < Config.GameModeConfig.Schematic.SubTypes.size(); i++) {
|
||||||
setupSchemTypeRow(p, inv, Config.SubTypes.get(i), i + 1);
|
setupSchemTypeRow(p, inv, Config.GameModeConfig.Schematic.SubTypes.get(i), i + 1);
|
||||||
}
|
}
|
||||||
if (!Config.test() && SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.TEAM)) {
|
if (!Config.test() && SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.TEAM)) {
|
||||||
SchematicNode node = SchematicNode.getSchematicNode(-1, Config.GameName, (Integer) null);
|
SchematicNode node = SchematicNode.getSchematicNode(-1, Config.GameModeConfig.GameName, (Integer) null);
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
inv.setItem(2, new SWItem(SWItem.getMaterial(node.getItem()), msg.parse("SCHEM_DIRT", p), click -> {
|
inv.setItem(2, new SWItem(SWItem.getMaterial(node.getItem()), msg.parse("SCHEM_DIRT", p), click -> {
|
||||||
schemSelect(p, node);
|
schemSelect(p, node);
|
||||||
|
|||||||
+2
-2
@@ -36,10 +36,10 @@ import java.util.List;
|
|||||||
public class EnternCountdown extends Countdown {
|
public class EnternCountdown extends Countdown {
|
||||||
|
|
||||||
private static int calcTime(FightPlayer fp, Countdown countdown) {
|
private static int calcTime(FightPlayer fp, Countdown countdown) {
|
||||||
int time = Config.EnterStages.get(fp.getKit().getEnterStage());
|
int time = Config.GameModeConfig.EnterStages.get(fp.getKit().getEnterStage());
|
||||||
|
|
||||||
if(countdown != null) {
|
if(countdown != null) {
|
||||||
time -= Config.TimeoutTime - countdown.getTimeLeft();
|
time -= Config.GameModeConfig.WinConditionParams.TimeoutTime - countdown.getTimeLeft();
|
||||||
|
|
||||||
if(time < 0)
|
if(time < 0)
|
||||||
time = 0;
|
time = 0;
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ import de.steamwar.linkage.Linked;
|
|||||||
public class EventSpectateCountdown extends Countdown {
|
public class EventSpectateCountdown extends Countdown {
|
||||||
|
|
||||||
public EventSpectateCountdown() {
|
public EventSpectateCountdown() {
|
||||||
super(Config.SpectatorDuration, new Message("SHUTDOWN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
super(Config.GameModeConfig.Times.SpectatorDuration, new Message("SHUTDOWN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
||||||
new StateDependentCountdown(ArenaMode.NotRestartable.contains(Config.mode) && !Config.replayserver(), FightState.Spectate, this);
|
new StateDependentCountdown(ArenaMode.NotRestartable.contains(Config.mode) && !Config.replayserver(), FightState.Spectate, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -31,9 +31,9 @@ import org.bukkit.Bukkit;
|
|||||||
public class NoPlayersOnlineCountdown extends Countdown {
|
public class NoPlayersOnlineCountdown extends Countdown {
|
||||||
|
|
||||||
public NoPlayersOnlineCountdown() {
|
public NoPlayersOnlineCountdown() {
|
||||||
super(Config.NoPlayerOnlineDuration, new Message("SHUTDOWN_COUNTDOWN"), null, false);
|
super(Config.GameModeConfig.Times.NoPlayersOnlineDuration, new Message("SHUTDOWN_COUNTDOWN"), null, false);
|
||||||
|
|
||||||
if (!Config.ArenaLeaveable)
|
if (!Config.GameModeConfig.Arena.Leaveable)
|
||||||
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this);
|
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -30,8 +30,8 @@ import de.steamwar.linkage.Linked;
|
|||||||
public class PostSchemCountdown extends Countdown {
|
public class PostSchemCountdown extends Countdown {
|
||||||
|
|
||||||
public PostSchemCountdown() {
|
public PostSchemCountdown() {
|
||||||
super(Config.SetupDuration, new Message("POST_SCHEM_COUNTDOWN"), null, false);
|
super(Config.GameModeConfig.Times.SetupDuration, new Message("POST_SCHEM_COUNTDOWN"), null, false);
|
||||||
if(Config.mode == ArenaMode.PREPARE && Config.UnlimitedPrepare)
|
if(Config.mode == ArenaMode.PREPARE && Config.GameModeConfig.Schematic.UnlimitedPrepare)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
new StateDependentCountdown(ArenaMode.SeriousFight, FightState.PostSchemSetup, this);
|
new StateDependentCountdown(ArenaMode.SeriousFight, FightState.PostSchemSetup, this);
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ import de.steamwar.linkage.Linked;
|
|||||||
public class PreRunningCountdown extends Countdown {
|
public class PreRunningCountdown extends Countdown {
|
||||||
|
|
||||||
public PreRunningCountdown() {
|
public PreRunningCountdown() {
|
||||||
super(Config.PreFightDuration, new Message("PRE_RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, true);
|
super(Config.GameModeConfig.Times.PreFightDuration, new Message("PRE_RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, true);
|
||||||
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreRunning, this);
|
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreRunning, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ import de.steamwar.linkage.Linked;
|
|||||||
public class PreSchemCountdown extends Countdown {
|
public class PreSchemCountdown extends Countdown {
|
||||||
|
|
||||||
public PreSchemCountdown() {
|
public PreSchemCountdown() {
|
||||||
super(Config.PreSchemPasteDuration, new Message("PRE_SCHEM_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
super(Config.GameModeConfig.Times.PreSchemPasteDuration, new Message("PRE_SCHEM_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
||||||
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreSchemSetup, this);
|
new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreSchemSetup, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ import de.steamwar.linkage.Linked;
|
|||||||
public class SpectateOverCountdown extends Countdown {
|
public class SpectateOverCountdown extends Countdown {
|
||||||
|
|
||||||
public SpectateOverCountdown() {
|
public SpectateOverCountdown() {
|
||||||
super(Config.test() ? 3600 : Config.SpectatorDuration, new Message("SPECTATE_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
super(Config.test() ? 3600 : Config.GameModeConfig.Times.SpectatorDuration, new Message("SPECTATE_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
||||||
new StateDependentCountdown(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Spectate, this);
|
new StateDependentCountdown(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Spectate, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ public class TimeOverCountdown extends Countdown {
|
|||||||
private final Runnable timeOver;
|
private final Runnable timeOver;
|
||||||
|
|
||||||
public TimeOverCountdown(Runnable timeOver) {
|
public TimeOverCountdown(Runnable timeOver) {
|
||||||
super(Config.TimeoutTime, new Message("RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, false);
|
super(Config.GameModeConfig.WinConditionParams.TimeoutTime, new Message("RUNNING_COUNTDOWN"), SWSound.BLOCK_NOTE_BASS, false);
|
||||||
this.timeOver = timeOver;
|
this.timeOver = timeOver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class Fight {
|
|||||||
if (Config.OnlyPublicSchematics) {
|
if (Config.OnlyPublicSchematics) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)) {
|
if (Config.GameModeConfig.Schematic.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (redTeam.getLeader() == null || blueTeam.getLeader() == null) {
|
if (redTeam.getLeader() == null || blueTeam.getLeader() == null) {
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ public class FightPlayer {
|
|||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.team = team;
|
this.team = team;
|
||||||
this.isOut = false;
|
this.isOut = false;
|
||||||
kit = Kit.getKitByName(Config.MemberDefault);
|
kit = Kit.getKitByName(Config.GameModeConfig.Kits.MemberDefault);
|
||||||
if(Config.PersonalKits){
|
if(Config.GameModeConfig.Kits.PersonalKits){
|
||||||
PersonalKit personalKit = PersonalKit.getKitInUse(user.getId(), Config.SchematicType.toDB());
|
PersonalKit personalKit = PersonalKit.getKitInUse(user.getId(), Config.GameModeConfig.Schematic.Type.toDB());
|
||||||
if(personalKit != null){
|
if(personalKit != null){
|
||||||
kit = new Kit(personalKit);
|
kit = new Kit(personalKit);
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ public class FightPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startEnternCountdown(Countdown countdown) {
|
public void startEnternCountdown(Countdown countdown) {
|
||||||
if(Config.EnterStages.size() > kit.getEnterStage() && kit.getEnterStage() >= 0)
|
if(Config.GameModeConfig.EnterStages.size() > kit.getEnterStage() && kit.getEnterStage() >= 0)
|
||||||
enternCountdown = new EnternCountdown(this, countdown);
|
enternCountdown = new EnternCountdown(this, countdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,9 +115,9 @@ public class FightSchematic extends StateDependent {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if(clipboard == null){
|
if(clipboard == null){
|
||||||
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.SchematicType.toDB());
|
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.GameModeConfig.Schematic.Type.toDB());
|
||||||
if(publics.isEmpty()) {
|
if(publics.isEmpty()) {
|
||||||
for (SchematicType type : Config.SubTypes) {
|
for (SchematicType type : Config.GameModeConfig.Schematic.SubTypes) {
|
||||||
publics = SchematicNode.getAllSchematicsOfType(0, type.toDB());
|
publics = SchematicNode.getAllSchematicsOfType(0, type.toDB());
|
||||||
if (!publics.isEmpty()) {
|
if (!publics.isEmpty()) {
|
||||||
break;
|
break;
|
||||||
@@ -133,7 +133,7 @@ public class FightSchematic extends StateDependent {
|
|||||||
|
|
||||||
if(ArenaMode.AntiReplay.contains(Config.mode)) {
|
if(ArenaMode.AntiReplay.contains(Config.mode)) {
|
||||||
boolean changeRotation = false;
|
boolean changeRotation = false;
|
||||||
if (Config.ActiveWinconditions.contains(Winconditions.RANDOM_ROTATE)) {
|
if (Config.GameModeConfig.WinConditions.contains(Winconditions.RANDOM_ROTATE)) {
|
||||||
changeRotation = new Random().nextBoolean();
|
changeRotation = new Random().nextBoolean();
|
||||||
usedRotate = rotate ^ changeRotation;
|
usedRotate = rotate ^ changeRotation;
|
||||||
}
|
}
|
||||||
@@ -163,9 +163,9 @@ public class FightSchematic extends StateDependent {
|
|||||||
clipboard,
|
clipboard,
|
||||||
new Location(Config.world, region.centerX(), region.getMinY(), region.centerZ()),
|
new Location(Config.world, region.centerX(), region.getMinY(), region.centerZ()),
|
||||||
new Vector(
|
new Vector(
|
||||||
Config.PasteAligned && Config.BlueToRedX != 0 ? region.getSizeX()/2.0 - dims.getBlockX() : -dims.getBlockX()/2.0,
|
Config.GameModeConfig.Schematic.PasteAligned && Config.BlueToRedX != 0 ? region.getSizeX()/2.0 - dims.getBlockX() : -dims.getBlockX()/2.0,
|
||||||
Config.WaterDepth != 0 ? Config.WaterDepth - WorldeditWrapper.impl.getWaterDepth(clipboard) : 0,
|
Config.GameModeConfig.Arena.WaterDepth != 0 ? Config.GameModeConfig.Arena.WaterDepth - WorldeditWrapper.impl.getWaterDepth(clipboard) : 0,
|
||||||
Config.PasteAligned && Config.BlueToRedZ != 0 ? region.getSizeZ()/2.0 - dims.getBlockZ() : -dims.getBlockZ()/2.0
|
Config.GameModeConfig.Schematic.PasteAligned && Config.BlueToRedZ != 0 ? region.getSizeZ()/2.0 - dims.getBlockZ() : -dims.getBlockZ()/2.0
|
||||||
).add(new Vector(usedRotate ? 1 : 0, 0, usedRotate ? 1 : 0)),
|
).add(new Vector(usedRotate ? 1 : 0, 0, usedRotate ? 1 : 0)),
|
||||||
new AffineTransform().rotateY(usedRotate ? 180 : 0)
|
new AffineTransform().rotateY(usedRotate ? 180 : 0)
|
||||||
);
|
);
|
||||||
@@ -179,17 +179,17 @@ public class FightSchematic extends StateDependent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
if(!Config.ReplaceObsidianBedrock || Config.mode == ArenaMode.PREPARE)
|
if(!Config.GameModeConfig.Schematic.ReplaceObsidianBedrock || Config.mode == ArenaMode.PREPARE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FreezeWorld freezer = null;
|
FreezeWorld freezer = null;
|
||||||
if(!Config.ReplaceWithBlockupdates)
|
if(!Config.GameModeConfig.Schematic.ReplaceWithBlockupdates)
|
||||||
freezer = new FreezeWorld();
|
freezer = new FreezeWorld();
|
||||||
|
|
||||||
replaceSync(Material.OBSIDIAN, Material.TNT);
|
replaceSync(Material.OBSIDIAN, Material.TNT);
|
||||||
replaceSync(Material.BEDROCK, Material.SLIME_BLOCK);
|
replaceSync(Material.BEDROCK, Material.SLIME_BLOCK);
|
||||||
|
|
||||||
if(!Config.ReplaceWithBlockupdates)
|
if(!Config.GameModeConfig.Schematic.ReplaceWithBlockupdates)
|
||||||
freezer.disable();
|
freezer.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ import java.util.function.Consumer;
|
|||||||
public class FightTeam {
|
public class FightTeam {
|
||||||
|
|
||||||
private static void setKitButton(HotbarKit kit, boolean leader) {
|
private static void setKitButton(HotbarKit kit, boolean leader) {
|
||||||
if (Kit.getAvailableKits(leader).size() > 1 || Config.PersonalKits)
|
if (Kit.getAvailableKits(leader).size() > 1 || Config.GameModeConfig.Kits.PersonalKits)
|
||||||
kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).enchant().build(), player -> GUI.kitSelection(player, ""));
|
kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).enchant().build(), player -> GUI.kitSelection(player, ""));
|
||||||
else
|
else
|
||||||
kit.setItem(1, null, null, null);
|
kit.setItem(1, null, null, null);
|
||||||
@@ -144,7 +144,7 @@ public class FightTeam {
|
|||||||
WorldOfColorWrapper.impl.setTeamColor(team, color);
|
WorldOfColorWrapper.impl.setTeamColor(team, color);
|
||||||
BountifulWrapper.impl.setNametagVisibility(team);
|
BountifulWrapper.impl.setNametagVisibility(team);
|
||||||
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
|
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
|
||||||
if (!Config.ActiveWinconditions.contains(Winconditions.AMONG_US)) {
|
if (!Config.GameModeConfig.WinConditions.contains(Winconditions.AMONG_US)) {
|
||||||
team.setAllowFriendlyFire(false);
|
team.setAllowFriendlyFire(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,10 +357,10 @@ public class FightTeam {
|
|||||||
if(!silent)
|
if(!silent)
|
||||||
FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getEntity().getName());
|
FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getEntity().getName());
|
||||||
|
|
||||||
publicsOnly = SchematicNode.getAllAccessibleSchematicsOfType(leader.getUser().getId(), Config.SchematicType.toDB()).isEmpty();
|
publicsOnly = SchematicNode.getAllAccessibleSchematicsOfType(leader.getUser().getId(), Config.GameModeConfig.Schematic.Type.toDB()).isEmpty();
|
||||||
|
|
||||||
if(!Config.PersonalKits)
|
if(!Config.GameModeConfig.Kits.PersonalKits)
|
||||||
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
|
leader.setKit(Kit.getKitByName(Config.GameModeConfig.Kits.LeaderDefault));
|
||||||
|
|
||||||
leader.ifPlayer(player -> {
|
leader.ifPlayer(player -> {
|
||||||
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||||
@@ -417,7 +417,7 @@ public class FightTeam {
|
|||||||
|
|
||||||
public void setSchem(SchematicNode schematic, int revision){
|
public void setSchem(SchematicNode schematic, int revision){
|
||||||
this.schematic.setSchematic(schematic, revision);
|
this.schematic.setSchematic(schematic, revision);
|
||||||
broadcast("SCHEMATIC_CHOSEN", Config.GameName, schematic.getName());
|
broadcast("SCHEMATIC_CHOSEN", Config.GameModeConfig.GameName, schematic.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReady(boolean ready) {
|
public void setReady(boolean ready) {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class FightWorld extends StateDependent {
|
|||||||
public static void resetWorld(){
|
public static void resetWorld(){
|
||||||
List<Entity> entities = new ArrayList<>();
|
List<Entity> entities = new ArrayList<>();
|
||||||
Recording.iterateOverEntities(Objects::nonNull, entity -> {
|
Recording.iterateOverEntities(Objects::nonNull, entity -> {
|
||||||
if(entity.getType() != EntityType.PLAYER && (!Config.ArenaLeaveable || Config.ArenaRegion.inRegion(entity.getLocation())))
|
if(entity.getType() != EntityType.PLAYER && (!Config.GameModeConfig.Arena.Leaveable || Config.ArenaRegion.inRegion(entity.getLocation())))
|
||||||
entities.add(entity);
|
entities.add(entity);
|
||||||
});
|
});
|
||||||
entities.forEach(Entity::remove);
|
entities.forEach(Entity::remove);
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class HotbarKit extends Kit {
|
|||||||
for(int i = 0; i < HOTBAR_SIZE; i++) {
|
for(int i = 0; i < HOTBAR_SIZE; i++) {
|
||||||
if(nameTags[i] != null) {
|
if(nameTags[i] != null) {
|
||||||
ItemMeta meta = Objects.requireNonNull(getInventory()[i].getItemMeta());
|
ItemMeta meta = Objects.requireNonNull(getInventory()[i].getItemMeta());
|
||||||
meta.setDisplayName(FightSystem.getMessage().parse(nameTags[i], player, Config.GameName));
|
meta.setDisplayName(FightSystem.getMessage().parse(nameTags[i], player, Config.GameModeConfig.GameName));
|
||||||
getInventory()[i].setItemMeta(meta);
|
getInventory()[i].setItemMeta(meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ import java.util.*;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Kit {
|
public class Kit {
|
||||||
private static final File kits = new File(FightSystem.getPlugin().getDataFolder(), Config.KitFile);
|
private static final File kits = new File(FightSystem.getPlugin().getDataFolder(), Config.GameModeConfig.Kits.File);
|
||||||
private static final ArrayList<Kit> loadedKits = new ArrayList<>();
|
private static final ArrayList<Kit> loadedKits = new ArrayList<>();
|
||||||
|
|
||||||
protected static final Map<Player, Kit> activeKits = new HashMap<>();
|
protected static final Map<Player, Kit> activeKits = new HashMap<>();
|
||||||
@@ -179,7 +179,7 @@ public class Kit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeBadItems(){
|
public void removeBadItems(){
|
||||||
Kit normal = Kit.getKitByName(Config.MemberDefault);
|
Kit normal = Kit.getKitByName(Config.GameModeConfig.Kits.MemberDefault);
|
||||||
assert normal != null;
|
assert normal != null;
|
||||||
|
|
||||||
for(int i = 0; i < inventory.length; i++){
|
for(int i = 0; i < inventory.length; i++){
|
||||||
@@ -194,7 +194,7 @@ public class Kit {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
//Check for forbidden item
|
//Check for forbidden item
|
||||||
if(Config.ForbiddenItems.contains(stack.getType()))
|
if(Config.GameModeConfig.Kits.ForbiddenItems.contains(stack.getType()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//Check for attribute modifiers
|
//Check for attribute modifiers
|
||||||
@@ -211,7 +211,7 @@ public class Kit {
|
|||||||
return true; //Blocks prefilled inventories
|
return true; //Blocks prefilled inventories
|
||||||
}
|
}
|
||||||
|
|
||||||
Kit normal = Kit.getKitByName(Config.MemberDefault);
|
Kit normal = Kit.getKitByName(Config.GameModeConfig.Kits.MemberDefault);
|
||||||
assert normal != null;
|
assert normal != null;
|
||||||
return !normal.isEnchantmentInKit(stack) && !stack.getEnchantments().isEmpty();
|
return !normal.isEnchantmentInKit(stack) && !stack.getEnchantments().isEmpty();
|
||||||
}
|
}
|
||||||
@@ -303,8 +303,8 @@ public class Kit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inv.setCallback(-999, click -> player.closeInventory());
|
inv.setCallback(-999, click -> player.closeInventory());
|
||||||
if(Config.PersonalKits){
|
if(Config.GameModeConfig.Kits.PersonalKits){
|
||||||
inv.setItem(49, SWItem.getMaterial("WOOD_AXE"), FightSystem.getMessage().parse("KIT_PREVIEW_EDIT", player), clickType -> PersonalKitCreator.openKitCreator(player, PersonalKit.get(SteamwarUser.get(player.getUniqueId()).getId(), Config.SchematicType.toDB(), name)));
|
inv.setItem(49, SWItem.getMaterial("WOOD_AXE"), FightSystem.getMessage().parse("KIT_PREVIEW_EDIT", player), clickType -> PersonalKitCreator.openKitCreator(player, PersonalKit.get(SteamwarUser.get(player.getUniqueId()).getId(), Config.GameModeConfig.Schematic.Type.toDB(), name)));
|
||||||
inv.setItem(53, Material.BARRIER, FightSystem.getMessage().parse("KIT_PREVIEW_DELETE", player), clickType -> {
|
inv.setItem(53, Material.BARRIER, FightSystem.getMessage().parse("KIT_PREVIEW_DELETE", player), clickType -> {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
SWInventory conf = new SWInventory(player, 9, FightSystem.getMessage().parse("KIT_DELETION_CONFIRMATION", player));
|
SWInventory conf = new SWInventory(player, 9, FightSystem.getMessage().parse("KIT_DELETION_CONFIRMATION", player));
|
||||||
@@ -312,9 +312,9 @@ public class Kit {
|
|||||||
conf.setItem(0, SWItem.getDye(10), FightSystem.getMessage().parse("KIT_DELETION_DELETE", player), click -> {
|
conf.setItem(0, SWItem.getDye(10), FightSystem.getMessage().parse("KIT_DELETION_DELETE", player), click -> {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
PersonalKit kit = PersonalKit.get(user.getId(), Config.SchematicType.toDB(), name);
|
PersonalKit kit = PersonalKit.get(user.getId(), Config.GameModeConfig.Schematic.Type.toDB(), name);
|
||||||
if(kit.isInUse()) {
|
if(kit.isInUse()) {
|
||||||
List<PersonalKit> kits = PersonalKit.get(user.getId(), Config.SchematicType.toDB());
|
List<PersonalKit> kits = PersonalKit.get(user.getId(), Config.GameModeConfig.Schematic.Type.toDB());
|
||||||
if(!kits.isEmpty()){
|
if(!kits.isEmpty()){
|
||||||
PersonalKit kit1 = kits.get(0);
|
PersonalKit kit1 = kits.get(0);
|
||||||
kit1.setInUse();
|
kit1.setInUse();
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class ArenaBorder implements Listener {
|
|||||||
public ArenaBorder() {
|
public ArenaBorder() {
|
||||||
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
new StateDependentListener(ArenaMode.All, FightState.All, this);
|
||||||
new StateDependentTask(ArenaMode.All, FightState.Running, this::damage, 2, 2);
|
new StateDependentTask(ArenaMode.All, FightState.Running, this::damage, 2, 2);
|
||||||
new StateDependentListener(!Config.GroundWalkable, FightState.AntiRunning, new Listener() {
|
new StateDependentListener(!Config.GameModeConfig.Arena.GroundWalkable, FightState.AntiRunning, new Listener() {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onMove(PlayerMoveEvent e) {
|
public void onMove(PlayerMoveEvent e) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
@@ -102,7 +102,7 @@ public class ArenaBorder implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addToSpectator(Player player) {
|
private void addToSpectator(Player player) {
|
||||||
if(Config.ArenaLeaveable || !player.isOnline() || playerBorder.contains(player))
|
if(Config.GameModeConfig.Arena.Leaveable || !player.isOnline() || playerBorder.contains(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
spectatorBorder.addPlayer(player);
|
spectatorBorder.addPlayer(player);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class ArrowStopper {
|
|||||||
private static final BlockFace[] BLOCK_FACES = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
|
private static final BlockFace[] BLOCK_FACES = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
|
||||||
|
|
||||||
public ArrowStopper() {
|
public ArrowStopper() {
|
||||||
new StateDependentTask(Config.TechhiderActive, FightState.Running, this::run, 1, 1);
|
new StateDependentTask(Config.GameModeConfig.Techhider.Active, FightState.Running, this::run, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> entityArrow = Reflection.getClass("net.minecraft.world.entity.projectile.AbstractArrow");
|
private static final Class<?> entityArrow = Reflection.getClass("net.minecraft.world.entity.projectile.AbstractArrow");
|
||||||
@@ -87,7 +87,7 @@ public class ArrowStopper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkBlock(Block block) {
|
private boolean checkBlock(Block block) {
|
||||||
return Config.HiddenBlocks.contains(block.getType());
|
return Config.GameModeConfig.Techhider.HiddenBlocks.contains(block.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean invalidEntity(Projectile entity) {
|
private boolean invalidEntity(Projectile entity) {
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ import org.bukkit.event.block.BlockFadeEvent;
|
|||||||
public class BlockFadeListener implements Listener {
|
public class BlockFadeListener implements Listener {
|
||||||
|
|
||||||
public BlockFadeListener() {
|
public BlockFadeListener() {
|
||||||
new StateDependentListener(Config.DisableSnowMelt, FightState.All, this);
|
new StateDependentListener(Config.GameModeConfig.Arena.DisableSnowMelt, FightState.All, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class Chat implements Listener {
|
|||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
if(fightTeam != null) {
|
if(fightTeam != null) {
|
||||||
String teamName = fightTeam.getColoredName();
|
String teamName = fightTeam.getColoredName();
|
||||||
if(message.startsWith(Config.TeamChatDetection)) {
|
if(message.startsWith(Config.GameModeConfig.TeamChatPrefix)) {
|
||||||
fightTeam.broadcastChat(player, message.substring(1));
|
fightTeam.broadcastChat(player, message.substring(1));
|
||||||
} else {
|
} else {
|
||||||
broadcastChat("PARTICIPANT_CHAT", teamName, player.getName(), message);
|
broadcastChat("PARTICIPANT_CHAT", teamName, player.getName(), message);
|
||||||
|
|||||||
+2
-2
@@ -82,13 +82,13 @@ public class DenyWorldInteraction implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleEntityExplode(EntityExplodeEvent event) {
|
public void handleEntityExplode(EntityExplodeEvent event) {
|
||||||
if(!Config.ArenaLeaveable || Config.ArenaRegion.inRegion(event.getLocation()))
|
if(!Config.GameModeConfig.Arena.Leaveable || Config.ArenaRegion.inRegion(event.getLocation()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleBlockBurn(BlockIgniteEvent event) {
|
public void handleBlockBurn(BlockIgniteEvent event) {
|
||||||
if(!Config.ArenaLeaveable || Config.ArenaRegion.inRegion(event.getBlock()))
|
if(!Config.GameModeConfig.Arena.Leaveable || Config.ArenaRegion.inRegion(event.getBlock()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ import java.util.Objects;
|
|||||||
public class InFightDamage implements Listener {
|
public class InFightDamage implements Listener {
|
||||||
|
|
||||||
public InFightDamage() {
|
public InFightDamage() {
|
||||||
new StateDependentListener(!Config.ActiveWinconditions.contains(Winconditions.AMONG_US), FightState.Running, this);
|
new StateDependentListener(!Config.GameModeConfig.WinConditions.contains(Winconditions.AMONG_US), FightState.Running, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ public class JoinRequestListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
FightPlayer fp = Fight.getFightPlayer(player);
|
FightPlayer fp = Fight.getFightPlayer(player);
|
||||||
|
|
||||||
if (!Config.ArenaLeaveable && (fp == null || !fp.isLiving())) {
|
if (!Config.GameModeConfig.Arena.Leaveable && (fp == null || !fp.isLiving())) {
|
||||||
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
|
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ public class LeaveableArena implements Listener {
|
|||||||
private final Map<Player, GameMode> spectatorsInArena = new HashMap<>();
|
private final Map<Player, GameMode> spectatorsInArena = new HashMap<>();
|
||||||
|
|
||||||
public LeaveableArena() {
|
public LeaveableArena() {
|
||||||
new StateDependentListener(Config.ArenaLeaveable, FightState.All, this);
|
new StateDependentListener(Config.GameModeConfig.Arena.Leaveable, FightState.All, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class Permanent implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
FightPlayer fp = Fight.getFightPlayer(player);
|
FightPlayer fp = Fight.getFightPlayer(player);
|
||||||
|
|
||||||
if (!Config.ArenaLeaveable && fp == null) {
|
if (!Config.GameModeConfig.Arena.Leaveable && fp == null) {
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
spectatorTeam.addEntry(player.getName());
|
spectatorTeam.addEntry(player.getName());
|
||||||
player.teleport(Config.SpecSpawn);
|
player.teleport(Config.SpecSpawn);
|
||||||
@@ -111,13 +111,13 @@ public class Permanent implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void handlePlayerDeath(PlayerDeathEvent event) {
|
public void handlePlayerDeath(PlayerDeathEvent event) {
|
||||||
if(!Config.ArenaLeaveable || Fight.fighting(event.getEntity()))
|
if(!Config.GameModeConfig.Arena.Leaveable || Fight.fighting(event.getEntity()))
|
||||||
event.setDeathMessage(null);
|
event.setDeathMessage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void handlePlayerLeave(PlayerQuitEvent event) {
|
public void handlePlayerLeave(PlayerQuitEvent event) {
|
||||||
if(!Config.ArenaLeaveable)
|
if(!Config.GameModeConfig.Arena.Leaveable)
|
||||||
event.setQuitMessage(null);
|
event.setQuitMessage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,8 +163,8 @@ public class Permanent implements Listener {
|
|||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
|
|
||||||
ItemStack stack = e.getItem().getItemStack();
|
ItemStack stack = e.getItem().getItemStack();
|
||||||
if(Config.PersonalKits) {
|
if(Config.GameModeConfig.Kits.PersonalKits) {
|
||||||
if(Config.ForbiddenItems.contains(stack.getType())) {
|
if(Config.GameModeConfig.Kits.ForbiddenItems.contains(stack.getType())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -192,7 +192,7 @@ public class Permanent implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWorldLoad(WorldLoadEvent e) {
|
public void onWorldLoad(WorldLoadEvent e) {
|
||||||
if(!Config.ArenaLeaveable)
|
if(!Config.GameModeConfig.Arena.Leaveable)
|
||||||
e.getWorld().setAutoSave(false);
|
e.getWorld().setAutoSave(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ public class PersonalKitCreator implements Listener {
|
|||||||
private static final Map<HumanEntity, InventoryBackup> openKitCreators = new HashMap<>();
|
private static final Map<HumanEntity, InventoryBackup> openKitCreators = new HashMap<>();
|
||||||
|
|
||||||
public PersonalKitCreator(){
|
public PersonalKitCreator(){
|
||||||
new StateDependentListener(Config.PersonalKits, FightState.Setup, this);
|
new StateDependentListener(Config.GameModeConfig.Kits.PersonalKits, FightState.Setup, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openKitCreator(Player player, PersonalKit kit){
|
public static void openKitCreator(Player player, PersonalKit kit){
|
||||||
|
|||||||
+2
-2
@@ -45,8 +45,8 @@ public class PistonListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
//Wenn Entern aktiv ist, sollen Raketen etc. entern können
|
//Wenn Entern aktiv ist, sollen Raketen etc. entern können
|
||||||
new StateDependentListener(!Config.AllowMissiles, FightState.All, this);
|
new StateDependentListener(!Config.GameModeConfig.Arena.AllowMissiles, FightState.All, this);
|
||||||
new StateDependentListener(Config.AllowMissiles, FightState.Setup, this);
|
new StateDependentListener(Config.GameModeConfig.Arena.AllowMissiles, FightState.Setup, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class PrepareSchem implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
schem.setSchemtype(Config.SchematicType.checkType());
|
schem.setSchemtype(Config.GameModeConfig.Schematic.Type.checkType());
|
||||||
schem.setPrepared(true);
|
schem.setPrepared(true);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class Shutdown implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||||
if(Config.replayserver() || Config.ArenaLeaveable)
|
if(Config.replayserver() || Config.GameModeConfig.Arena.Leaveable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Shutdown server if nobody online
|
//Shutdown server if nobody online
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import java.util.Map;
|
|||||||
@Linked
|
@Linked
|
||||||
public class WaterRemover implements Listener {
|
public class WaterRemover implements Listener {
|
||||||
|
|
||||||
private static final int MIN_Y = Config.BluePasteRegion.getMinY() + Config.WaterDepth;
|
private static final int MIN_Y = Config.BluePasteRegion.getMinY() + Config.GameModeConfig.Arena.WaterDepth;
|
||||||
|
|
||||||
private final Map<Integer, FightTeam> tnt = new HashMap<>();
|
private final Map<Integer, FightTeam> tnt = new HashMap<>();
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -90,8 +90,8 @@ public class PacketProcessor implements Listener {
|
|||||||
private final PacketSource source;
|
private final PacketSource source;
|
||||||
private final BukkitTask task;
|
private final BukkitTask task;
|
||||||
private final LinkedList<Runnable> syncList = new LinkedList<>();
|
private final LinkedList<Runnable> syncList = new LinkedList<>();
|
||||||
private final Set<Integer> hiddenBlockIds = Config.HiddenBlocks.stream().flatMap(m -> BlockIds.impl.materialToAllIds(m).stream()).collect(Collectors.toSet());
|
private final Set<Integer> hiddenBlockIds = Config.GameModeConfig.Techhider.HiddenBlocks.stream().flatMap(m -> BlockIds.impl.materialToAllIds(m).stream()).collect(Collectors.toSet());
|
||||||
private final int obfuscateWith = BlockIds.impl.materialToId(Config.ObfuscateWith);
|
private final int obfuscateWith = BlockIds.impl.materialToId(Config.GameModeConfig.Techhider.ObfuscateWith);
|
||||||
private final FreezeWorld freezer = new FreezeWorld();
|
private final FreezeWorld freezer = new FreezeWorld();
|
||||||
private final REntityServer entityServer = new REntityServer();
|
private final REntityServer entityServer = new REntityServer();
|
||||||
private final Map<Integer, REntity> entities = new HashMap<>();
|
private final Map<Integer, REntity> entities = new HashMap<>();
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ public class OneShotStateDependent extends StateDependent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OneShotStateDependent(Winconditions wincondition, Set<FightState> states, Runnable runnable) {
|
public OneShotStateDependent(Winconditions wincondition, Set<FightState> states, Runnable runnable) {
|
||||||
super(Config.ActiveWinconditions.contains(wincondition), states);
|
super(Config.GameModeConfig.WinConditions.contains(wincondition), states);
|
||||||
this.runnable = runnable;
|
this.runnable = runnable;
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public abstract class StateDependent implements IStateDependent {
|
|||||||
private final boolean register;
|
private final boolean register;
|
||||||
|
|
||||||
protected StateDependent(Winconditions wincondition, Set<FightState> states){
|
protected StateDependent(Winconditions wincondition, Set<FightState> states){
|
||||||
this(Config.ActiveWinconditions.contains(wincondition), states);
|
this(Config.GameModeConfig.WinConditions.contains(wincondition), states);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StateDependent(Set<ArenaMode> mode, Set<FightState> states){
|
protected StateDependent(Set<ArenaMode> mode, Set<FightState> states){
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ public class StateDependentCountdown extends StateDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public StateDependentCountdown(Winconditions wincondition, Set<FightState> states, Countdown countdown) {
|
public StateDependentCountdown(Winconditions wincondition, Set<FightState> states, Countdown countdown) {
|
||||||
this(Config.ActiveWinconditions.contains(wincondition), states, countdown);
|
this(Config.GameModeConfig.WinConditions.contains(wincondition), states, countdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StateDependentCountdown(boolean active, Set<FightState> states, Countdown countdown) {
|
public StateDependentCountdown(boolean active, Set<FightState> states, Countdown countdown) {
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ public class StateDependentListener extends StateDependent{
|
|||||||
private final Listener listener;
|
private final Listener listener;
|
||||||
|
|
||||||
public StateDependentListener(Winconditions wincondition, Set<FightState> states, Listener listener){
|
public StateDependentListener(Winconditions wincondition, Set<FightState> states, Listener listener){
|
||||||
super(Config.ActiveWinconditions.contains(wincondition), states);
|
super(Config.GameModeConfig.WinConditions.contains(wincondition), states);
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ public class StateDependentTask extends StateDependent {
|
|||||||
private BukkitTask task = null;
|
private BukkitTask task = null;
|
||||||
|
|
||||||
public StateDependentTask(Winconditions wincondition, Set<FightState> states, Runnable runnable, long delay, long period){
|
public StateDependentTask(Winconditions wincondition, Set<FightState> states, Runnable runnable, long delay, long period){
|
||||||
this(Config.ActiveWinconditions.contains(wincondition), states, runnable, delay, period);
|
this(Config.GameModeConfig.WinConditions.contains(wincondition), states, runnable, delay, period);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StateDependentTask(boolean enabled, Set<FightState> states, Runnable runnable, long delay, long period){
|
public StateDependentTask(boolean enabled, Set<FightState> states, Runnable runnable, long delay, long period){
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class BungeeFightInfo {
|
|||||||
private void send() {
|
private void send() {
|
||||||
NetworkSender.send(new FightInfoPacket(
|
NetworkSender.send(new FightInfoPacket(
|
||||||
Config.world.getName(),
|
Config.world.getName(),
|
||||||
Config.SchematicType.toDB(),
|
Config.GameModeConfig.Schematic.Type.toDB(),
|
||||||
"",
|
"",
|
||||||
Fight.getBlueTeam().getColoredName(),
|
Fight.getBlueTeam().getColoredName(),
|
||||||
Fight.getRedTeam().getColoredName(),
|
Fight.getRedTeam().getColoredName(),
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class FightStatistics {
|
|||||||
private void disable() {
|
private void disable() {
|
||||||
FightTeam winner = FightSystem.getLastWinner();
|
FightTeam winner = FightSystem.getLastWinner();
|
||||||
String windescription = FightSystem.getLastWinreason();
|
String windescription = FightSystem.getLastWinreason();
|
||||||
String gameMode = Config.SchematicType.toDB();
|
String gameMode = Config.GameModeConfig.Schematic.Type.toDB();
|
||||||
Instant endTime = Instant.now();
|
Instant endTime = Instant.now();
|
||||||
|
|
||||||
int blueLeader = getLeader(Fight.getBlueTeam());
|
int blueLeader = getLeader(Fight.getBlueTeam());
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class Hull {
|
|||||||
private static final IntVector[] NO_BRANCHES = new IntVector[0];
|
private static final IntVector[] NO_BRANCHES = new IntVector[0];
|
||||||
|
|
||||||
private static boolean isOccluding(Material material) {
|
private static boolean isOccluding(Material material) {
|
||||||
return material.isOccluding() || Config.HiddenBlocks.contains(material);
|
return material.isOccluding() || Config.GameModeConfig.Techhider.HiddenBlocks.contains(material);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
+2
-2
@@ -50,7 +50,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
|
|
||||||
public class TechHiderWrapper extends StateDependent implements TechHider.LocationEvaluator, Listener {
|
public class TechHiderWrapper extends StateDependent implements TechHider.LocationEvaluator, Listener {
|
||||||
|
|
||||||
public static final boolean ENABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
|
public static final boolean ENABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.GameModeConfig.Techhider.Active;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final ConcurrentHashMap<Player, Region> hiddenRegion = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Player, Region> hiddenRegion = new ConcurrentHashMap<>();
|
||||||
@@ -60,7 +60,7 @@ public class TechHiderWrapper extends StateDependent implements TechHider.Locati
|
|||||||
|
|
||||||
public TechHiderWrapper() {
|
public TechHiderWrapper() {
|
||||||
super(ENABLED, FightState.Schem);
|
super(ENABLED, FightState.Schem);
|
||||||
techHider = new TechHider(this, Config.ObfuscateWith, Config.HiddenBlocks, Config.HiddenBlockEntities);
|
techHider = new TechHider(this, Config.GameModeConfig.Techhider.ObfuscateWith, Config.GameModeConfig.Techhider.HiddenBlocks, Config.GameModeConfig.Techhider.HiddenBlockEntities);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
key = new SecretKeySpec(Files.readAllBytes(new File(System.getProperty("user.home"), "hullhider.key").toPath()), "AES");
|
key = new SecretKeySpec(Files.readAllBytes(new File(System.getProperty("user.home"), "hullhider.key").toPath()), "AES");
|
||||||
|
|||||||
+6
-6
@@ -40,7 +40,7 @@ public abstract class WinconditionBasePercent extends Wincondition implements Pr
|
|||||||
private final Map<FightTeam, TeamPercent> teamMap = new HashMap<>();
|
private final Map<FightTeam, TeamPercent> teamMap = new HashMap<>();
|
||||||
|
|
||||||
protected Consumer<FightTeam> checkWin = team -> {
|
protected Consumer<FightTeam> checkWin = team -> {
|
||||||
if (getPercent(team) >= Config.PercentWin) {
|
if (getPercent(team) >= Config.GameModeConfig.WinConditionParams.PercentWin) {
|
||||||
win(Fight.getOpposite(team), "WIN_PERCENT", team.getColoredName());
|
win(Fight.getOpposite(team), "WIN_PERCENT", team.getColoredName());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -49,7 +49,7 @@ public abstract class WinconditionBasePercent extends Wincondition implements Pr
|
|||||||
public WinconditionBasePercent(Winconditions wincondition, String windescription) {
|
public WinconditionBasePercent(Winconditions wincondition, String windescription) {
|
||||||
super(windescription);
|
super(windescription);
|
||||||
|
|
||||||
if (Config.ActiveWinconditions.contains(wincondition)) {
|
if (Config.GameModeConfig.WinConditions.contains(wincondition)) {
|
||||||
printableWinconditions.add(this);
|
printableWinconditions.add(this);
|
||||||
percentWincondition = this;
|
percentWincondition = this;
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ public abstract class WinconditionBasePercent extends Wincondition implements Pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Message getDisplay(FightTeam team) {
|
public Message getDisplay(FightTeam team) {
|
||||||
return new Message("BAR_PERCENT", team.getPrefix() + (Math.round(10000.0 * (1.0 - getPercent(team) / Config.PercentWin)) / 100.0));
|
return new Message("BAR_PERCENT", team.getPrefix() + (Math.round(10000.0 * (1.0 - getPercent(team) / Config.GameModeConfig.WinConditionParams.PercentWin)) / 100.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPercent(FightTeam team) {
|
public double getPercent(FightTeam team) {
|
||||||
@@ -93,13 +93,13 @@ public abstract class WinconditionBasePercent extends Wincondition implements Pr
|
|||||||
if (
|
if (
|
||||||
event.getEntityType() == EntityType.FIREBALL ||
|
event.getEntityType() == EntityType.FIREBALL ||
|
||||||
!team.getExtendRegion().inRegion(event.getEntity().getLocation()) ||
|
!team.getExtendRegion().inRegion(event.getEntity().getLocation()) ||
|
||||||
(!Config.PercentEntern && !Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Wincondition.getTimeOverCountdown().getTimeLeft())
|
(!Config.GameModeConfig.WinConditionParams.PercentEntern && !Config.GameModeConfig.EnterStages.isEmpty() && Config.GameModeConfig.EnterStages.get(0) >= Wincondition.getTimeOverCountdown().getTimeLeft())
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.blockList().forEach(block -> {
|
event.blockList().forEach(block -> {
|
||||||
if (countAnyBlock || Config.PercentBlocks.contains(block.getType()) == Config.PercentBlocksWhitelist) {
|
if (countAnyBlock || Config.GameModeConfig.WinConditionParams.Blocks.contains(block.getType()) == Config.GameModeConfig.WinConditionParams.BlocksWhitelist) {
|
||||||
currentBlocks--;
|
currentBlocks--;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -111,7 +111,7 @@ public abstract class WinconditionBasePercent extends Wincondition implements Pr
|
|||||||
totalBlocks = 0;
|
totalBlocks = 0;
|
||||||
countAnyBlock = false;
|
countAnyBlock = false;
|
||||||
team.getSchemRegion().forEach((x, y, z) -> {
|
team.getSchemRegion().forEach((x, y, z) -> {
|
||||||
if (Config.PercentBlocks.contains(Config.world.getBlockAt(x, y, z).getType()) == Config.PercentBlocksWhitelist)
|
if (Config.GameModeConfig.WinConditionParams.Blocks.contains(Config.world.getBlockAt(x, y, z).getType()) == Config.GameModeConfig.WinConditionParams.BlocksWhitelist)
|
||||||
totalBlocks++;
|
totalBlocks++;
|
||||||
});
|
});
|
||||||
// Edge Case for DirtBlock
|
// Edge Case for DirtBlock
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ public abstract class WinconditionBlocks extends Wincondition implements Printab
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if(Config.ActiveWinconditions.contains(wincondition))
|
if(Config.GameModeConfig.WinConditions.contains(wincondition))
|
||||||
printableWinconditions.add(this);
|
printableWinconditions.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ public abstract class WinconditionComparisonTimeout extends Wincondition {
|
|||||||
|
|
||||||
public WinconditionComparisonTimeout(Winconditions wincondition, String windescription, String winMessage, ToDoubleFunction<FightTeam> evaluate) {
|
public WinconditionComparisonTimeout(Winconditions wincondition, String windescription, String winMessage, ToDoubleFunction<FightTeam> evaluate) {
|
||||||
super(windescription);
|
super(windescription);
|
||||||
if(Config.ActiveWinconditions.contains(wincondition)) {
|
if(Config.GameModeConfig.WinConditions.contains(wincondition)) {
|
||||||
timeOverCountdown = new StateDependentCountdown(wincondition, FightState.Running, new TimeOverCountdown(() -> comparisonWin(evaluate, winMessage, "WIN_TIME_OVER")));
|
timeOverCountdown = new StateDependentCountdown(wincondition, FightState.Running, new TimeOverCountdown(() -> comparisonWin(evaluate, winMessage, "WIN_TIME_OVER")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ public class WinconditionPoints extends WinconditionBasePercent implements Liste
|
|||||||
|
|
||||||
new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this);
|
new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this);
|
||||||
|
|
||||||
if(Config.ActiveWinconditions.contains(Winconditions.POINTS)){
|
if(Config.GameModeConfig.WinConditions.contains(Winconditions.POINTS)){
|
||||||
timeOverCountdown = new StateDependentCountdown(Winconditions.POINTS, FightState.Running, new TimeOverCountdown(this::timeOver));
|
timeOverCountdown = new StateDependentCountdown(Winconditions.POINTS, FightState.Running, new TimeOverCountdown(this::timeOver));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ import java.util.Map;
|
|||||||
@Linked
|
@Linked
|
||||||
public class WinconditionTimeTechKO extends Wincondition implements Listener {
|
public class WinconditionTimeTechKO extends Wincondition implements Listener {
|
||||||
|
|
||||||
private static final int TECH_KO_HALF_TIME = Config.TechKoTime/2;
|
private static final int TECH_KO_HALF_TIME = Config.GameModeConfig.WinConditionParams.TechKoTime/2;
|
||||||
|
|
||||||
private final Map<Integer, FightTeam> spawnLocations = new HashMap<>();
|
private final Map<Integer, FightTeam> spawnLocations = new HashMap<>();
|
||||||
private final Map<FightTeam, TechKOCountdown> countdowns = new HashMap<>();
|
private final Map<FightTeam, TechKOCountdown> countdowns = new HashMap<>();
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ public class WinconditionTimedDamageTechKO extends Wincondition implements Print
|
|||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
Fight.teams().forEach(team -> {
|
Fight.teams().forEach(team -> {
|
||||||
TechKOCountdown countdown = new TechKOCountdown(team, Config.TechKoTime);
|
TechKOCountdown countdown = new TechKOCountdown(team, Config.GameModeConfig.WinConditionParams.TechKoTime);
|
||||||
countdowns.put(team, countdown);
|
countdowns.put(team, countdown);
|
||||||
countdown.enable();
|
countdown.enable();
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ public class WinconditionTimeout extends Wincondition {
|
|||||||
|
|
||||||
public WinconditionTimeout() {
|
public WinconditionTimeout() {
|
||||||
super("Timeout");
|
super("Timeout");
|
||||||
if(Config.ActiveWinconditions.contains(Winconditions.TIMEOUT)){
|
if(Config.GameModeConfig.WinConditions.contains(Winconditions.TIMEOUT)){
|
||||||
timeOverCountdown = new StateDependentCountdown(Winconditions.TIMEOUT, FightState.Running, new TimeOverCountdown(this::timeOver));
|
timeOverCountdown = new StateDependentCountdown(Winconditions.TIMEOUT, FightState.Running, new TimeOverCountdown(this::timeOver));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -24,7 +24,8 @@ import com.sk89q.worldedit.entity.Entity;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
import de.steamwar.data.GameModeConfig;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -118,7 +119,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCheckerResult check(Clipboard clipboard, CheckSchemType type) {
|
public AutoCheckerResult check(Clipboard clipboard, GameModeConfig<Material, SchematicType, String> type) {
|
||||||
return AutoCheckerResult.builder()
|
return AutoCheckerResult.builder()
|
||||||
.type(type)
|
.type(type)
|
||||||
.height(clipboard.getDimensions().getBlockY())
|
.height(clipboard.getDimensions().getBlockY())
|
||||||
@@ -130,7 +131,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCheckerResult sizeCheck(Clipboard clipboard, CheckSchemType type) {
|
public AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig<Material, SchematicType, String> type) {
|
||||||
return AutoCheckerResult.builder()
|
return AutoCheckerResult.builder()
|
||||||
.type(type)
|
.type(type)
|
||||||
.height(clipboard.getDimensions().getBlockY())
|
.height(clipboard.getDimensions().getBlockY())
|
||||||
|
|||||||
+7
-8
@@ -31,10 +31,10 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
||||||
import de.steamwar.schematicsystem.autocheck.BlockPos;
|
import de.steamwar.schematicsystem.autocheck.BlockPos;
|
||||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
import de.steamwar.sql.SchematicType;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -42,7 +42,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class SchematicCommand15 implements SchematicCommand.ISchematicCommand {
|
public class SchematicCommand15 implements SchematicCommand.ISchematicCommand {
|
||||||
@Override
|
@Override
|
||||||
public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType type) throws Exception {
|
public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig<Material, SchematicType, String> type) throws Exception {
|
||||||
for (BlockPos blockPos : result.getBlockScanResult().getRecords()) {
|
for (BlockPos blockPos : result.getBlockScanResult().getRecords()) {
|
||||||
BlockVector3 vector = BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
BlockVector3 vector = BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||||
clipboard.setBlock(vector, clipboard.getFullBlock(vector).toBaseBlock(new CompoundTag(Collections.emptyMap())));
|
clipboard.setBlock(vector, clipboard.getFullBlock(vector).toBaseBlock(new CompoundTag(Collections.emptyMap())));
|
||||||
@@ -76,9 +76,9 @@ public class SchematicCommand15 implements SchematicCommand.ISchematicCommand {
|
|||||||
clipboard.setBlock(vector, block.toBaseBlock(builder.build()));
|
clipboard.setBlock(vector, block.toBaseBlock(builder.build()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type.getMaxDispenserItems() > 0 ) {
|
if(type.Schematic.MaxDispenserItems > 0 ) {
|
||||||
for (Map.Entry<BlockPos, Integer> entry : result.getBlockScanResult().getDispenserItems().entrySet()) {
|
for (Map.Entry<BlockPos, Integer> entry : result.getBlockScanResult().getDispenserItems().entrySet()) {
|
||||||
if(entry.getValue() <= type.getMaxDispenserItems()) {
|
if(entry.getValue() <= type.Schematic.MaxDispenserItems) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ public class SchematicCommand15 implements SchematicCommand.ISchematicCommand {
|
|||||||
List<CompoundTag> items = tag.getList("Items", CompoundTag.class);
|
List<CompoundTag> items = tag.getList("Items", CompoundTag.class);
|
||||||
Collections.reverse(items); // To let the first item be in the Dispenser
|
Collections.reverse(items); // To let the first item be in the Dispenser
|
||||||
List<CompoundTag> list = new ArrayList<>();
|
List<CompoundTag> list = new ArrayList<>();
|
||||||
int diff = entry.getValue() - type.getMaxDispenserItems();
|
int diff = entry.getValue() - type.Schematic.MaxDispenserItems;
|
||||||
for (CompoundTag item : items) {
|
for (CompoundTag item : items) {
|
||||||
if(item == null) {
|
if(item == null) {
|
||||||
continue;
|
continue;
|
||||||
@@ -117,10 +117,9 @@ public class SchematicCommand15 implements SchematicCommand.ISchematicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!result.isLimitedBlocksOK()) {
|
if(!result.isLimitedBlocksOK()) {
|
||||||
Set<Material> toReplace = type.getLimits().entrySet().stream()
|
Set<Material> toReplace = type.Schematic.Limited.entrySet().stream()
|
||||||
.filter(setIntegerEntry -> setIntegerEntry.getValue() == 0)
|
.filter(setIntegerEntry -> setIntegerEntry.getValue() == 0)
|
||||||
.flatMap(setIntegerEntry -> setIntegerEntry.getKey().stream())
|
.flatMap(setIntegerEntry -> setIntegerEntry.getKey().stream())
|
||||||
.map(Material::matchMaterial)
|
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
BlockState replaceType = Objects.requireNonNull(toReplace.contains(Material.END_STONE) ? BlockTypes.IRON_BLOCK : BlockTypes.END_STONE).getDefaultState();
|
BlockState replaceType = Objects.requireNonNull(toReplace.contains(Material.END_STONE) ? BlockTypes.IRON_BLOCK : BlockTypes.END_STONE).getDefaultState();
|
||||||
BlockVector3 min = clipboard.getMinimumPoint();
|
BlockVector3 min = clipboard.getMinimumPoint();
|
||||||
|
|||||||
+4
-3
@@ -25,7 +25,8 @@ import com.sk89q.worldedit.blocks.BaseBlock;
|
|||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
import de.steamwar.data.GameModeConfig;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -148,7 +149,7 @@ public class AutoChecker8 implements AutoChecker.IAutoChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCheckerResult check(Clipboard clipboard, CheckSchemType type) {
|
public AutoCheckerResult check(Clipboard clipboard, GameModeConfig<Material, SchematicType, String> type) {
|
||||||
AutoChecker.BlockScanResult blockScanResult = new AutoChecker.BlockScanResult();
|
AutoChecker.BlockScanResult blockScanResult = new AutoChecker.BlockScanResult();
|
||||||
scan(blockScanResult, clipboard);
|
scan(blockScanResult, clipboard);
|
||||||
|
|
||||||
@@ -163,7 +164,7 @@ public class AutoChecker8 implements AutoChecker.IAutoChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCheckerResult sizeCheck(Clipboard clipboard, CheckSchemType type) {
|
public AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig<Material, SchematicType, String> type) {
|
||||||
return AutoCheckerResult.builder()
|
return AutoCheckerResult.builder()
|
||||||
.type(type)
|
.type(type)
|
||||||
.height(clipboard.getDimensions().getBlockY())
|
.height(clipboard.getDimensions().getBlockY())
|
||||||
|
|||||||
+4
-3
@@ -24,14 +24,15 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
||||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
import de.steamwar.sql.SchematicType;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
public class SchematicCommand8 implements SchematicCommand.ISchematicCommand {
|
public class SchematicCommand8 implements SchematicCommand.ISchematicCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType type) throws Exception {
|
public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig<Material, SchematicType, String> type) throws Exception {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-113
@@ -1,113 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2025 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.schematicsystem;
|
|
||||||
|
|
||||||
import de.steamwar.sql.SchematicType;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class CheckSchemType {
|
|
||||||
|
|
||||||
private static final Map<SchematicType, CheckSchemType> types = new HashMap<>();
|
|
||||||
|
|
||||||
private final int width;
|
|
||||||
private final int height;
|
|
||||||
private final int depth;
|
|
||||||
private final int maxDispenserItems;
|
|
||||||
|
|
||||||
private final Map<Set<String>, Integer> limits;
|
|
||||||
private final int maxBlocks;
|
|
||||||
|
|
||||||
private final Date deadline;
|
|
||||||
private final float maxBlastResistance;
|
|
||||||
|
|
||||||
private CheckSchemType(ConfigurationSection section) {
|
|
||||||
String name = section.getString("Schematic.Type");
|
|
||||||
width = section.getInt("Schematic.Size.x");
|
|
||||||
height = section.getInt("Schematic.Size.y");
|
|
||||||
depth = section.getInt("Schematic.Size.z");
|
|
||||||
|
|
||||||
maxDispenserItems = section.getInt("Schematic.MaxDispenserItems", 128);
|
|
||||||
maxBlocks = section.getInt("Schematic.MaxBlocks", 0);
|
|
||||||
|
|
||||||
maxBlastResistance = (float) section.getDouble("Schematic.MaxDesignBlastResistance", Double.MAX_VALUE);
|
|
||||||
|
|
||||||
limits = new HashMap<>();
|
|
||||||
for(Map<?, ?> entry : section.getMapList("Schematic.Limited")) {
|
|
||||||
int amount = (Integer) entry.get("Amount");
|
|
||||||
Set<String> materials = new HashSet<>((List<String>) entry.get("Materials"));
|
|
||||||
if(amount == 0) {
|
|
||||||
materials.forEach(material -> limits.put(Collections.singleton(material), 0));
|
|
||||||
} else {
|
|
||||||
limits.put(materials, amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String deadlineString = section.getString("deadline", null);
|
|
||||||
if (deadlineString != null) {
|
|
||||||
try {
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
|
||||||
deadline = dateFormat.parse(deadlineString);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new SecurityException(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
deadline = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
types.put(SchematicType.fromDB(name.toLowerCase()), this);
|
|
||||||
types.put(SchematicType.fromDB("c" + name.toLowerCase()), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
File folder = new File(SchematicSystem.getInstance().getDataFolder().getParentFile(), "FightSystem");
|
|
||||||
|
|
||||||
if(folder.exists()) {
|
|
||||||
for(File configFile : folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))) {
|
|
||||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
|
||||||
if (!config.isList("CheckQuestions") && config.getBoolean("Schematic.ManualCheck", true))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
new CheckSchemType(config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CheckSchemType get(SchematicType type){
|
|
||||||
return types.get(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<Set<String>, Integer> getLimits() {
|
|
||||||
return new HashMap<>(limits);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAfterDeadline() {
|
|
||||||
return deadline != null && deadline.before(Date.from(Instant.now()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+56
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2025 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.schematicsystem;
|
||||||
|
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
|
import de.steamwar.data.YMLWrapperImpl;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public class CheckSchemTypeManager {
|
||||||
|
|
||||||
|
private static final Map<SchematicType, GameModeConfig<Material, SchematicType, String>> types = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
File folder = new File(SchematicSystem.getInstance().getDataFolder().getParentFile(), "FightSystem");
|
||||||
|
|
||||||
|
if(folder.exists()) {
|
||||||
|
for(File configFile : folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))) {
|
||||||
|
GameModeConfig<Material, SchematicType, String> gameModeConfig = new GameModeConfig<>(YMLWrapperImpl.ofTyped(configFile));
|
||||||
|
if (gameModeConfig.CheckQuestions.isEmpty() && gameModeConfig.Schematic.ManualCheck)
|
||||||
|
continue;
|
||||||
|
types.put(gameModeConfig.Schematic.Type, gameModeConfig);
|
||||||
|
if (gameModeConfig.Schematic.Type.checkType() != null) {
|
||||||
|
types.put(gameModeConfig.Schematic.Type.checkType(), gameModeConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameModeConfig<Material, SchematicType, String> get(SchematicType type){
|
||||||
|
return types.get(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
-5
@@ -21,8 +21,9 @@ package de.steamwar.schematicsystem.autocheck;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import de.steamwar.core.VersionDependent;
|
import de.steamwar.core.VersionDependent;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -31,19 +32,19 @@ import java.util.*;
|
|||||||
|
|
||||||
public class AutoChecker {
|
public class AutoChecker {
|
||||||
|
|
||||||
public static AutoCheckerResult check(Clipboard clipboard, CheckSchemType type) {
|
public static AutoCheckerResult check(Clipboard clipboard, GameModeConfig<Material, SchematicType, String> type) {
|
||||||
return impl.check(clipboard, type);
|
return impl.check(clipboard, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AutoCheckerResult sizeCheck(Clipboard clipboard, CheckSchemType type) {
|
public static AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig<Material, SchematicType, String> type) {
|
||||||
return impl.sizeCheck(clipboard, type);
|
return impl.sizeCheck(clipboard, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final IAutoChecker impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance());
|
private static final IAutoChecker impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance());
|
||||||
|
|
||||||
public interface IAutoChecker {
|
public interface IAutoChecker {
|
||||||
AutoCheckerResult check(Clipboard clipboard, CheckSchemType type);
|
AutoCheckerResult check(Clipboard clipboard, GameModeConfig<Material, SchematicType, String> type);
|
||||||
AutoCheckerResult sizeCheck(Clipboard clipboard, CheckSchemType type);
|
AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig<Material, SchematicType, String> type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
+25
-23
@@ -20,8 +20,9 @@
|
|||||||
package de.steamwar.schematicsystem.autocheck;
|
package de.steamwar.schematicsystem.autocheck;
|
||||||
|
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
@@ -29,13 +30,15 @@ import net.md_5.bungee.api.chat.ClickEvent;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
@Getter
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
public class AutoCheckerResult {
|
public class AutoCheckerResult {
|
||||||
private final CheckSchemType type;
|
private final GameModeConfig<Material, SchematicType, String> type;
|
||||||
private final int width;
|
private final int width;
|
||||||
private final int height;
|
private final int height;
|
||||||
private final int depth;
|
private final int depth;
|
||||||
@@ -61,7 +64,7 @@ public class AutoCheckerResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDispenserItemsOK() {
|
public boolean isDispenserItemsOK() {
|
||||||
return blockScanResult.getDispenserItems().values().stream().allMatch(i -> i <= type.getMaxDispenserItems());
|
return blockScanResult.getDispenserItems().values().stream().allMatch(i -> i <= type.Schematic.MaxDispenserItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasWarnings() {
|
public boolean hasWarnings() {
|
||||||
@@ -73,25 +76,25 @@ public class AutoCheckerResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTooWide() {
|
public boolean isTooWide() {
|
||||||
return width > type.getWidth();
|
return width > type.Schematic.Size.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTooHigh() {
|
public boolean isTooHigh() {
|
||||||
return height > type.getHeight();
|
return height > type.Schematic.Size.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTooDeep() {
|
public boolean isTooDeep() {
|
||||||
return depth > type.getDepth();
|
return depth > type.Schematic.Size.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlockCountOk() {
|
public boolean isBlockCountOk() {
|
||||||
return type.getMaxBlocks() == 0 || blockScanResult.getBlockCounts().entrySet().stream().filter(entry -> entry.getKey() != Material.AIR).map(Map.Entry::getValue).reduce(Integer::sum).map(i -> i <= type.getMaxBlocks()).orElse(false);
|
return type.Schematic.MaxBlocks == 0 || blockScanResult.getBlockCounts().entrySet().stream().filter(entry -> entry.getKey() != Material.AIR).map(Map.Entry::getValue).reduce(Integer::sum).map(i -> i <= type.Schematic.MaxBlocks).orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLimitedBlocksOK() {
|
public boolean isLimitedBlocksOK() {
|
||||||
try {
|
try {
|
||||||
return type.getLimits().entrySet().stream()
|
return type.Schematic.Limited.entrySet().stream()
|
||||||
.map(setIntegerEntry -> setIntegerEntry.getKey().stream().map(Material::getMaterial).map(blockScanResult.getBlockCounts()::get).map(i -> i == null || i <= setIntegerEntry.getValue()).reduce(Boolean::logicalAnd).orElse(false))
|
.map(setIntegerEntry -> setIntegerEntry.getKey().stream().map(blockScanResult.getBlockCounts()::get).map(i -> i == null || i <= setIntegerEntry.getValue()).reduce(Boolean::logicalAnd).orElse(false))
|
||||||
.reduce(Boolean::logicalAnd).orElse(true);
|
.reduce(Boolean::logicalAnd).orElse(true);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
return false;
|
return false;
|
||||||
@@ -99,21 +102,20 @@ public class AutoCheckerResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDesignBlastResistanceOK() {
|
public boolean isDesignBlastResistanceOK() {
|
||||||
return blockScanResult.getDesignBlocks().keySet().stream().map(Material::getBlastResistance).noneMatch(i -> i > type.getMaxBlastResistance());
|
return blockScanResult.getDesignBlocks().keySet().stream().map(Material::getBlastResistance).noneMatch(i -> i > type.Schematic.MaxDesignBlastResistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendErrorMessage(Player p, String schemName) {
|
public void sendErrorMessage(Player p, String schemName) {
|
||||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_HEADER", p, schemName);
|
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_HEADER", p, schemName);
|
||||||
if(isTooWide()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_WIDTH", p, width, type.getWidth());
|
if(isTooWide()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_WIDTH", p, width, type.Schematic.Size.x);
|
||||||
if(isTooHigh()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_HEIGHT", p, height, type.getHeight());
|
if(isTooHigh()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_HEIGHT", p, height, type.Schematic.Size.y);
|
||||||
if(isTooDeep()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_LENGTH", p, depth, type.getDepth());
|
if(isTooDeep()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_LENGTH", p, depth, type.Schematic.Size.z);
|
||||||
if(type.getMaxBlocks() != 0 && !isBlockCountOk()) {
|
if(type.Schematic.MaxBlocks != 0 && !isBlockCountOk()) {
|
||||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_BLOCKS", p, blockScanResult.getBlockCounts().values().stream().reduce(Integer::sum).orElse(0), type.getMaxBlocks());
|
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_BLOCKS", p, blockScanResult.getBlockCounts().values().stream().reduce(Integer::sum).orElse(0), type.Schematic.MaxBlocks);
|
||||||
}
|
}
|
||||||
if(!isLimitedBlocksOK()) {
|
if(!isLimitedBlocksOK()) {
|
||||||
type.getLimits().forEach((strings, integer) -> {
|
type.Schematic.Limited.forEach((materials, integer) -> {
|
||||||
for (String string : strings) {
|
for (Material mat : materials) {
|
||||||
Material mat = Material.matchMaterial(string);
|
|
||||||
if(mat != null && blockScanResult.getBlockCounts().getOrDefault(mat, 0) > integer) {
|
if(mat != null && blockScanResult.getBlockCounts().getOrDefault(mat, 0) > integer) {
|
||||||
if(integer == 0) {
|
if(integer == 0) {
|
||||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK", p, mat.name());
|
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK", p, mat.name());
|
||||||
@@ -124,13 +126,13 @@ public class AutoCheckerResult {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
blockScanResult.getDispenserItems().entrySet().stream().filter(blockVector3IntegerEntry -> blockVector3IntegerEntry.getValue() > type.getMaxDispenserItems()).forEach(blockVector3IntegerEntry -> {
|
blockScanResult.getDispenserItems().entrySet().stream().filter(blockVector3IntegerEntry -> blockVector3IntegerEntry.getValue() > type.Schematic.MaxDispenserItems).forEach(blockVector3IntegerEntry -> {
|
||||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3IntegerEntry.getKey()),
|
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3IntegerEntry.getKey()),
|
||||||
blockVector3IntegerEntry.getKey().getBlockX(),
|
blockVector3IntegerEntry.getKey().getBlockX(),
|
||||||
blockVector3IntegerEntry.getKey().getBlockY(),
|
blockVector3IntegerEntry.getKey().getBlockY(),
|
||||||
blockVector3IntegerEntry.getKey().getBlockZ(),
|
blockVector3IntegerEntry.getKey().getBlockZ(),
|
||||||
blockVector3IntegerEntry.getValue(),
|
blockVector3IntegerEntry.getValue(),
|
||||||
type.getMaxDispenserItems());
|
type.Schematic.MaxDispenserItems);
|
||||||
});
|
});
|
||||||
blockScanResult.getRecords().forEach(blockVector3 -> {
|
blockScanResult.getRecords().forEach(blockVector3 -> {
|
||||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_RECORD", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ());
|
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_RECORD", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ());
|
||||||
@@ -146,7 +148,7 @@ public class AutoCheckerResult {
|
|||||||
});
|
});
|
||||||
if(Core.getVersion() > 12) {
|
if(Core.getVersion() > 12) {
|
||||||
blockScanResult.getDesignBlocks().forEach((material, poss) -> {
|
blockScanResult.getDesignBlocks().forEach((material, poss) -> {
|
||||||
if(material.getBlastResistance() > type.getMaxBlastResistance()) {
|
if(material.getBlastResistance() > type.Schematic.MaxDesignBlastResistance) {
|
||||||
poss.forEach(pos -> {
|
poss.forEach(pos -> {
|
||||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DESIGN_BLOCK", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(pos), material.name(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DESIGN_BLOCK", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(pos), material.name(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||||
});
|
});
|
||||||
@@ -157,7 +159,7 @@ public class AutoCheckerResult {
|
|||||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_ENTITY", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockPos), blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_ENTITY", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockPos), blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||||
});
|
});
|
||||||
if(type.isAfterDeadline()) {
|
if(type.isAfterDeadline()) {
|
||||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_AFTER_DEADLINE", p, type.getDeadline());
|
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_AFTER_DEADLINE", p, type.Deadline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -23,7 +23,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.data.CMDs;
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.*;
|
import de.steamwar.inventory.*;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
import de.steamwar.schematicsystem.CheckSchemTypeManager;
|
||||||
import de.steamwar.schematicsystem.SafeSchematicNode;
|
import de.steamwar.schematicsystem.SafeSchematicNode;
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import de.steamwar.schematicsystem.autocheck.AutoChecker;
|
import de.steamwar.schematicsystem.autocheck.AutoChecker;
|
||||||
@@ -245,7 +245,7 @@ public class GUI {
|
|||||||
Clipboard finalClipboard = clipboard;
|
Clipboard finalClipboard = clipboard;
|
||||||
List<SchematicType> types = SchematicType.values().parallelStream()
|
List<SchematicType> types = SchematicType.values().parallelStream()
|
||||||
.filter(SchematicType::isAssignable)
|
.filter(SchematicType::isAssignable)
|
||||||
.filter(type -> finalClipboard == null || CheckSchemType.get(type) == null || AutoChecker.sizeCheck(finalClipboard, CheckSchemType.get(type)).fastOk())
|
.filter(type -> finalClipboard == null || CheckSchemTypeManager.get(type) == null || AutoChecker.sizeCheck(finalClipboard, CheckSchemTypeManager.get(type)).fastOk())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
List<SWListInv.SWListEntry<SchematicType>> items = types.stream()
|
List<SWListInv.SWListEntry<SchematicType>> items = types.stream()
|
||||||
|
|||||||
+13
-8
@@ -19,20 +19,25 @@
|
|||||||
|
|
||||||
package de.steamwar.schematicsystem.commands.schematiccommand;
|
package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import de.steamwar.command.*;
|
import de.steamwar.command.AbstractSWCommand;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeMapper;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.core.VersionDependent;
|
import de.steamwar.core.VersionDependent;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.*;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandHelp.*;
|
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandHelp.*;
|
||||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*;
|
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.togglePublic;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Linked
|
@Linked
|
||||||
@@ -107,9 +112,9 @@ public class SchematicCommand extends SWCommand {
|
|||||||
return SchematicMapper.nodeTypeMapper();
|
return SchematicMapper.nodeTypeMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassMapper(value = CheckSchemType.class, local = true)
|
@ClassMapper(value = GameModeConfig.class, local = true)
|
||||||
public static TypeMapper<CheckSchemType> checkSchemTypeTypeMapper() {
|
public static TypeMapper<GameModeConfig<Material, SchematicType, String>> gameModeConfigTypeMapper() {
|
||||||
return SchematicMapper.checkSchemTypeTypeMapper();
|
return SchematicMapper.gameModeConfigTypeMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -145,7 +150,7 @@ public class SchematicCommand extends SWCommand {
|
|||||||
public static final ISchematicCommand impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance());
|
public static final ISchematicCommand impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance());
|
||||||
|
|
||||||
public interface ISchematicCommand {
|
public interface ISchematicCommand {
|
||||||
Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType type) throws Exception;
|
Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig<Material, SchematicType, String> type) throws Exception;
|
||||||
void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException;
|
void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-4
@@ -20,12 +20,13 @@
|
|||||||
package de.steamwar.schematicsystem.commands.schematiccommand;
|
package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.network.NetworkSender;
|
import de.steamwar.network.NetworkSender;
|
||||||
import de.steamwar.network.packets.client.PrepareSchemPacket;
|
import de.steamwar.network.packets.client.PrepareSchemPacket;
|
||||||
import de.steamwar.providers.BauServerInfo;
|
import de.steamwar.providers.BauServerInfo;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
import de.steamwar.schematicsystem.CheckSchemTypeManager;
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import de.steamwar.schematicsystem.autocheck.AutoChecker;
|
import de.steamwar.schematicsystem.autocheck.AutoChecker;
|
||||||
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
||||||
@@ -40,6 +41,7 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
|
|||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -311,7 +313,7 @@ public class SchematicCommandUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void check(Player player, Clipboard clipboard, CheckSchemType type, String schemName, boolean gui) {
|
public static void check(Player player, Clipboard clipboard, GameModeConfig<Material, SchematicType, String> type, String schemName, boolean gui) {
|
||||||
AutoCheckerResult result = AutoChecker.check(clipboard, type);
|
AutoCheckerResult result = AutoChecker.check(clipboard, type);
|
||||||
if(!result.isOk()) {
|
if(!result.isOk()) {
|
||||||
result.sendErrorMessage(player, schemName);
|
result.sendErrorMessage(player, schemName);
|
||||||
@@ -454,9 +456,9 @@ public class SchematicCommandUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckSchemType checkSchemType = CheckSchemType.get(type);
|
GameModeConfig<Material, SchematicType, String> checkSchemType = CheckSchemTypeManager.get(type);
|
||||||
if (checkSchemType.isAfterDeadline()) {
|
if (checkSchemType.isAfterDeadline()) {
|
||||||
SchematicSystem.MESSAGE.send("UTIL_TYPE_AFTER_DEADLINE", player, checkSchemType.getDeadline());
|
SchematicSystem.MESSAGE.send("UTIL_TYPE_AFTER_DEADLINE", player, checkSchemType.Deadline);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-6
@@ -20,11 +20,13 @@
|
|||||||
package de.steamwar.schematicsystem.commands.schematiccommand;
|
package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||||
|
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
import de.steamwar.data.GameModeConfig;
|
||||||
|
import de.steamwar.schematicsystem.CheckSchemTypeManager;
|
||||||
import de.steamwar.sql.NodeMember;
|
import de.steamwar.sql.NodeMember;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -175,16 +177,16 @@ public class SchematicMapper {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TypeMapper<CheckSchemType> checkSchemTypeTypeMapper() {
|
public static TypeMapper<GameModeConfig<Material, SchematicType, String>> gameModeConfigTypeMapper() {
|
||||||
return new TypeMapper<CheckSchemType>() {
|
return new TypeMapper<GameModeConfig<Material, SchematicType, String>>() {
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
public Collection<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||||
return SchematicType.values().stream().filter(type -> CheckSchemType.get(type) != null).map(SchematicType::name).collect(Collectors.toList());
|
return SchematicType.values().stream().filter(type -> CheckSchemTypeManager.get(type) != null).map(SchematicType::name).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CheckSchemType map(CommandSender commandSender, String[] previousArguments, String s) {
|
public GameModeConfig<Material, SchematicType, String> map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
return SchematicType.values().stream().filter(type -> type.name().equalsIgnoreCase(s)).map(CheckSchemType::get).findAny().orElse(null);
|
return SchematicType.values().stream().filter(type -> type.name().equalsIgnoreCase(s)).map(CheckSchemTypeManager::get).findAny().orElse(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.schematicsystem.commands.schematiccommand;
|
package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||||
|
|
||||||
import de.steamwar.command.AbstractSWCommand;
|
|
||||||
import de.steamwar.command.AbstractValidator;
|
import de.steamwar.command.AbstractValidator;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
|
|||||||
+8
-6
@@ -28,21 +28,23 @@ import com.sk89q.worldedit.session.ClipboardHolder;
|
|||||||
import de.steamwar.command.AbstractSWCommand;
|
import de.steamwar.command.AbstractSWCommand;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import de.steamwar.schematicsystem.autocheck.AutoChecker;
|
import de.steamwar.schematicsystem.autocheck.AutoChecker;
|
||||||
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
||||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
||||||
import de.steamwar.sql.SchematicData;
|
import de.steamwar.sql.SchematicData;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.check;
|
|
||||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand.impl;
|
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand.impl;
|
||||||
|
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.check;
|
||||||
|
|
||||||
@AbstractSWCommand.PartOf(SchematicCommand.class)
|
@AbstractSWCommand.PartOf(SchematicCommand.class)
|
||||||
@Linked
|
@Linked
|
||||||
@@ -52,7 +54,7 @@ public class CheckPart extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register("check")
|
@Register("check")
|
||||||
public void checkCommand(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node, CheckSchemType type) {
|
public void checkCommand(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node, GameModeConfig<Material, SchematicType, String> type) {
|
||||||
try {
|
try {
|
||||||
check(player, new SchematicData(node).load(), type, node.getName(), false);
|
check(player, new SchematicData(node).load(), type, node.getName(), false);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -61,7 +63,7 @@ public class CheckPart extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = {"check", "clipboard"})
|
@Register(value = {"check", "clipboard"})
|
||||||
public void checkClipboardCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") CheckSchemType type) {
|
public void checkClipboardCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") GameModeConfig<Material, SchematicType, String> type) {
|
||||||
try {
|
try {
|
||||||
check(player, WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getClipboard().getClipboard(), type, "clipboard", false);
|
check(player, WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getClipboard().getClipboard(), type, "clipboard", false);
|
||||||
} catch (EmptyClipboardException e) {
|
} catch (EmptyClipboardException e) {
|
||||||
@@ -70,7 +72,7 @@ public class CheckPart extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = {"check", "selection"})
|
@Register(value = {"check", "selection"})
|
||||||
public void checkSelectionCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") CheckSchemType type) {
|
public void checkSelectionCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") GameModeConfig<Material, SchematicType, String> type) {
|
||||||
try {
|
try {
|
||||||
Clipboard clipboard = new BlockArrayClipboard(WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getSelection(new BukkitWorld(player.getWorld())));
|
Clipboard clipboard = new BlockArrayClipboard(WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getSelection(new BukkitWorld(player.getWorld())));
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(player.getWorld()), -1);
|
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(player.getWorld()), -1);
|
||||||
@@ -86,7 +88,7 @@ public class CheckPart extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register("fix")
|
@Register("fix")
|
||||||
public void fixSchematicCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") CheckSchemType type) {
|
public void fixSchematicCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") GameModeConfig<Material, SchematicType, String> type) {
|
||||||
if(Core.getVersion() < 15) {
|
if(Core.getVersion() < 15) {
|
||||||
SchematicSystem.MESSAGE.send("COMMAND_FIX_WRONG_VERSION", player);
|
SchematicSystem.MESSAGE.send("COMMAND_FIX_WRONG_VERSION", player);
|
||||||
return;
|
return;
|
||||||
|
|||||||
+2
-2
@@ -23,7 +23,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|||||||
import de.steamwar.command.AbstractSWCommand;
|
import de.steamwar.command.AbstractSWCommand;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
import de.steamwar.schematicsystem.CheckSchemTypeManager;
|
||||||
import de.steamwar.schematicsystem.SafeSchematicNode;
|
import de.steamwar.schematicsystem.SafeSchematicNode;
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import de.steamwar.schematicsystem.autocheck.AutoChecker;
|
import de.steamwar.schematicsystem.autocheck.AutoChecker;
|
||||||
@@ -63,7 +63,7 @@ public class ModifyPart extends SWCommand {
|
|||||||
|
|
||||||
SchematicType.values().parallelStream()
|
SchematicType.values().parallelStream()
|
||||||
.filter(SchematicType::isAssignable)
|
.filter(SchematicType::isAssignable)
|
||||||
.filter(type -> finalClipboard == null || CheckSchemType.get(type) == null || AutoChecker.sizeCheck(finalClipboard, CheckSchemType.get(type)).fastOk())
|
.filter(type -> finalClipboard == null || CheckSchemTypeManager.get(type) == null || AutoChecker.sizeCheck(finalClipboard, CheckSchemTypeManager.get(type)).fastOk())
|
||||||
.forEach(type -> {
|
.forEach(type -> {
|
||||||
TextComponent component = new TextComponent(type.name() + " ");
|
TextComponent component = new TextComponent(type.name() + " ");
|
||||||
component.setColor(ChatColor.GRAY);
|
component.setColor(ChatColor.GRAY);
|
||||||
|
|||||||
+1
-1
@@ -22,8 +22,8 @@ package de.steamwar.schematicsystem.commands.schematiccommand.parts;
|
|||||||
import de.steamwar.command.*;
|
import de.steamwar.command.*;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils;
|
|
||||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
||||||
|
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
|||||||
@@ -0,0 +1,154 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2025 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.data;
|
||||||
|
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class YMLWrapperImpl<M, ST, W> extends YMLWrapper<M, ST, W> {
|
||||||
|
|
||||||
|
public static YMLWrapperImpl<Material, SchematicType, String> ofTyped(File file) {
|
||||||
|
return new YMLWrapperImpl<>(file, ToMaterial, ToSchematicType, ToString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <W> YMLWrapperImpl<Material, SchematicType, W> ofTyped(File file, Function<String, W> ToWincondtion) {
|
||||||
|
return new YMLWrapperImpl<>(file, ToMaterial, ToSchematicType, ToWincondtion);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static YMLWrapperImpl<String, String, String> ofRaw(File file) {
|
||||||
|
return new YMLWrapperImpl<>(file, ToString, ToString, ToString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Function<String, Material> ToMaterial = material -> {
|
||||||
|
Material mat = Material.getMaterial(material);
|
||||||
|
if (mat == null) {
|
||||||
|
try {
|
||||||
|
mat = Material.valueOf(material);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mat;
|
||||||
|
};
|
||||||
|
|
||||||
|
private final FileConfiguration config;
|
||||||
|
private final String pathPrefix;
|
||||||
|
|
||||||
|
private YMLWrapperImpl(File file, Function<String, M> materialMapper, Function<String, ST> schematicTypeMapper, Function<String, W> winconditionMapper) {
|
||||||
|
super(file, materialMapper, schematicTypeMapper, winconditionMapper);
|
||||||
|
if (file == null || !file.exists()) {
|
||||||
|
config = null;
|
||||||
|
pathPrefix = "";
|
||||||
|
} else {
|
||||||
|
config = YamlConfiguration.loadConfiguration(file);
|
||||||
|
pathPrefix = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private YMLWrapperImpl(FileConfiguration config, String pathPrefix, Function<String, M> materialMapper, Function<String, ST> schematicTypeMapper, Function<String, W> winconditionMapper) {
|
||||||
|
super(null, materialMapper, schematicTypeMapper, winconditionMapper);
|
||||||
|
this.config = config;
|
||||||
|
this.pathPrefix = pathPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canLoad() {
|
||||||
|
return config != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public YMLWrapper<M, ST, W> with(String path) {
|
||||||
|
if (pathPrefix.isEmpty()) {
|
||||||
|
path = path + ".";
|
||||||
|
} else {
|
||||||
|
path = pathPrefix + path + ".";
|
||||||
|
}
|
||||||
|
if (config != null && config.isConfigurationSection(path)) {
|
||||||
|
return new YMLWrapperImpl<>(this.config, path, materialMapper, schematicTypeMapper, winconditionMapper);
|
||||||
|
} else {
|
||||||
|
return new YMLWrapperImpl<>(null, path, materialMapper, schematicTypeMapper, winconditionMapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDefaultGameName() {
|
||||||
|
return "WarGear";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getString(String path, String defaultValue) {
|
||||||
|
if (config == null) return defaultValue;
|
||||||
|
return config.getString(pathPrefix + path, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInt(String path, int defaultValue) {
|
||||||
|
if (config == null) return defaultValue;
|
||||||
|
return config.getInt(pathPrefix + path, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getDouble(String path, double defaultValue) {
|
||||||
|
if (config == null) return defaultValue;
|
||||||
|
return config.getDouble(pathPrefix + path, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getBoolean(String path, boolean defaultValue) {
|
||||||
|
if (config == null) return defaultValue;
|
||||||
|
return config.getBoolean(pathPrefix + path, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getStringList(String path) {
|
||||||
|
if (config == null) return Collections.emptyList();
|
||||||
|
List<String> list = config.getStringList(pathPrefix + path);
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
} else {
|
||||||
|
return Collections.unmodifiableList(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Integer> getIntList(String path) {
|
||||||
|
if (config == null) return Collections.emptyList();
|
||||||
|
List<Integer> list = config.getIntegerList(pathPrefix + path);
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
} else {
|
||||||
|
return Collections.unmodifiableList(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<?, ?>> getMapList(String path) {
|
||||||
|
if (config == null) return Collections.emptyList();
|
||||||
|
return config.getMapList(pathPrefix + path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,9 +20,10 @@
|
|||||||
package de.steamwar.sql;
|
package de.steamwar.sql;
|
||||||
|
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
|
import de.steamwar.data.YMLWrapperImpl;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -36,33 +37,30 @@ public class SQLWrapperImpl implements SQLWrapper {
|
|||||||
@Override
|
@Override
|
||||||
public void loadSchemTypes(List<SchematicType> tmpTypes, Map<String, SchematicType> tmpFromDB) {
|
public void loadSchemTypes(List<SchematicType> tmpTypes, Map<String, SchematicType> tmpFromDB) {
|
||||||
File folder = new File(Core.getInstance().getDataFolder().getParentFile(), "FightSystem");
|
File folder = new File(Core.getInstance().getDataFolder().getParentFile(), "FightSystem");
|
||||||
if(folder.exists()) {
|
if (!folder.exists()) return;
|
||||||
for(File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().collect(Collectors.toList())) {
|
for (File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().collect(Collectors.toList())) {
|
||||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
GameModeConfig<String, String, String> gameModeConfig = new GameModeConfig<>(YMLWrapperImpl.ofRaw(configFile));
|
||||||
if(!config.isConfigurationSection("Schematic"))
|
if (!gameModeConfig.Schematic.loaded) continue;
|
||||||
continue;
|
String type = gameModeConfig.Schematic.Type;
|
||||||
|
assert type != null;
|
||||||
|
String shortcut = gameModeConfig.Schematic.Shortcut;
|
||||||
|
if (tmpFromDB.containsKey(type.toLowerCase()))
|
||||||
|
continue;
|
||||||
|
|
||||||
String type = config.getString("Schematic.Type");
|
SchematicType checktype = null;
|
||||||
assert type != null;
|
String material = gameModeConfig.Schematic.Material;
|
||||||
String shortcut = config.getString("Schematic.Shortcut");
|
|
||||||
if(tmpFromDB.containsKey(type.toLowerCase()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
SchematicType checktype = null;
|
if (!gameModeConfig.CheckQuestions.isEmpty()) {
|
||||||
String material = config.getString("Schematic.Material", "STONE_BUTTON");
|
checktype = new SchematicType("C" + type, "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material, true);
|
||||||
|
tmpTypes.add(checktype);
|
||||||
if(!config.getStringList("CheckQuestions").isEmpty()) {
|
tmpFromDB.put(checktype.toDB(), checktype);
|
||||||
checktype = new SchematicType("C" + type, "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material, true);
|
|
||||||
tmpTypes.add(checktype);
|
|
||||||
tmpFromDB.put(checktype.toDB(), checktype);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean manualCheck = config.getBoolean("Schematic.ManualCheck", true);
|
|
||||||
|
|
||||||
SchematicType current = new SchematicType(type, shortcut, config.isConfigurationSection("Server") ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material, manualCheck);
|
|
||||||
tmpTypes.add(current);
|
|
||||||
tmpFromDB.put(type.toLowerCase(), current);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean manualCheck = gameModeConfig.Schematic.ManualCheck;
|
||||||
|
|
||||||
|
SchematicType current = new SchematicType(type, shortcut, gameModeConfig.Server.loaded ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material, manualCheck);
|
||||||
|
tmpTypes.add(current);
|
||||||
|
tmpFromDB.put(type.toLowerCase(), current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,10 +69,10 @@ public class SQLWrapperImpl implements SQLWrapper {
|
|||||||
@Override
|
@Override
|
||||||
public void additionalExceptionMetadata(StringBuilder builder) {
|
public void additionalExceptionMetadata(StringBuilder builder) {
|
||||||
builder.append("\nPlayers: ");
|
builder.append("\nPlayers: ");
|
||||||
for(Player player : Bukkit.getOnlinePlayers())
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
builder.append(player.getName()).append(" ");
|
builder.append(player.getName()).append(" ");
|
||||||
builder.append("\nWorlds: ");
|
builder.append("\nWorlds: ");
|
||||||
for(World world : Bukkit.getWorlds())
|
for (World world : Bukkit.getWorlds())
|
||||||
builder.append(world.getName()).append(" ");
|
builder.append(world.getName()).append(" ");
|
||||||
builder.append("\nServer: ").append(SERVER_VERSION);
|
builder.append("\nServer: ").append(SERVER_VERSION);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,159 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2025 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.data;
|
||||||
|
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class YMLWrapperImpl<ST> extends YMLWrapper<String, ST, String> {
|
||||||
|
|
||||||
|
public static YMLWrapperImpl<SchematicType> ofTyped(File file) {
|
||||||
|
return new YMLWrapperImpl<>(file, ToSchematicType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static YMLWrapperImpl<String> ofRaw(File file) {
|
||||||
|
return new YMLWrapperImpl<>(file, ToString);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final boolean canLoad;
|
||||||
|
private final Map<String, Object> document;
|
||||||
|
|
||||||
|
private YMLWrapperImpl(File file, Function<String, ST> schematicTypeMapper) {
|
||||||
|
super(file, ToString, schematicTypeMapper, ToString);
|
||||||
|
if (file == null || !file.exists()) {
|
||||||
|
canLoad = false;
|
||||||
|
document = new HashMap<>();
|
||||||
|
} else {
|
||||||
|
canLoad = true;
|
||||||
|
Yaml yaml = new Yaml();
|
||||||
|
try {
|
||||||
|
document = yaml.load(new FileInputStream(file));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new SecurityException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private YMLWrapperImpl(boolean canLoad, Map<String, Object> document, Function<String, ST> schematicTypeMapper) {
|
||||||
|
super(null, ToString, schematicTypeMapper, ToString);
|
||||||
|
this.canLoad = canLoad;
|
||||||
|
this.document = document;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canLoad() {
|
||||||
|
return canLoad;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public YMLWrapper<String, ST, String> with(String path) {
|
||||||
|
if (document.containsKey(path)) {
|
||||||
|
Object value = this.document.get(path);
|
||||||
|
if (value instanceof Map) {
|
||||||
|
return new YMLWrapperImpl(this.canLoad, (Map) value, schematicTypeMapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new YMLWrapperImpl(false, Collections.emptyMap(), schematicTypeMapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDefaultGameName() {
|
||||||
|
return file.getName().replace(".yml", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getString(String path, String defaultValue) {
|
||||||
|
Object value = this.document.get(path);
|
||||||
|
if (value instanceof String) {
|
||||||
|
return (String) value;
|
||||||
|
} else {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInt(String path, int defaultValue) {
|
||||||
|
Object value = this.document.get(path);
|
||||||
|
if (value instanceof Integer) {
|
||||||
|
return (Integer) value;
|
||||||
|
} else {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getDouble(String path, double defaultValue) {
|
||||||
|
Object value = this.document.get(path);
|
||||||
|
if (value instanceof Double) {
|
||||||
|
return (Double) value;
|
||||||
|
} else {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getBoolean(String path, boolean defaultValue) {
|
||||||
|
Object value = this.document.get(path);
|
||||||
|
if (value instanceof Boolean) {
|
||||||
|
return (Boolean) value;
|
||||||
|
} else {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getStringList(String path) {
|
||||||
|
Object value = this.document.get(path);
|
||||||
|
if (value instanceof List) {
|
||||||
|
return Collections.unmodifiableList((List<String>) value);
|
||||||
|
} else {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Integer> getIntList(String path) {
|
||||||
|
Object value = this.document.get(path);
|
||||||
|
if (value instanceof List) {
|
||||||
|
return Collections.unmodifiableList((List<Integer>) value);
|
||||||
|
} else {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<?, ?>> getMapList(String path) {
|
||||||
|
Object value = this.document.get(path);
|
||||||
|
if (value instanceof List) {
|
||||||
|
return Collections.unmodifiableList((List<Map<?, ?>>) value);
|
||||||
|
} else {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,52 +21,46 @@ package de.steamwar.sql;
|
|||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import de.steamwar.velocitycore.GameModeConfig;
|
import de.steamwar.data.GameModeConfig;
|
||||||
|
import de.steamwar.data.YMLWrapperImpl;
|
||||||
import de.steamwar.velocitycore.VelocityCore;
|
import de.steamwar.velocitycore.VelocityCore;
|
||||||
import de.steamwar.velocitycore.commands.CheckCommand;
|
import de.steamwar.velocitycore.commands.CheckCommand;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class SQLWrapperImpl implements SQLWrapper {
|
public class SQLWrapperImpl implements SQLWrapper {
|
||||||
private static final SimpleDateFormat deadlineFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
|
||||||
private static Date parseDeadline(String deadline) {
|
|
||||||
if(deadline == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
return deadlineFormat.parse(deadline);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new SecurityException(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadSchemTypes(List<SchematicType> tmpTypes, Map<String, SchematicType> tmpFromDB) {
|
public void loadSchemTypes(List<SchematicType> tmpTypes, Map<String, SchematicType> tmpFromDB) {
|
||||||
GameModeConfig.loadAll(GameModeConfig.class, (file, config) -> {
|
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||||
if(config.getSchematic() == null || tmpFromDB.containsKey(config.getSchemType().toLowerCase()))
|
if(!folder.exists())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String shortcut = config.getSchematic().getShortcut();
|
for(File file : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().toList()) {
|
||||||
String material = config.getSchematic().getMaterial();
|
GameModeConfig<String, String, String> gameModeConfig = new GameModeConfig<>(YMLWrapperImpl.ofRaw(file));
|
||||||
|
if (!gameModeConfig.Schematic.loaded) continue;
|
||||||
|
if (tmpFromDB.containsKey(gameModeConfig.Schematic.Type.toLowerCase())) continue;
|
||||||
|
|
||||||
|
String shortcut = gameModeConfig.Schematic.Shortcut;
|
||||||
|
String material = gameModeConfig.Schematic.Material;
|
||||||
|
|
||||||
SchematicType checktype = null;
|
SchematicType checktype = null;
|
||||||
if(!config.getCheckQuestions().isEmpty()) {
|
if (!gameModeConfig.CheckQuestions.isEmpty()) {
|
||||||
checktype = new SchematicType("C" + config.getSchemType(), "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material, true);
|
checktype = new SchematicType("C" + gameModeConfig.Schematic.Type, "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material, true);
|
||||||
tmpTypes.add(checktype);
|
tmpTypes.add(checktype);
|
||||||
tmpFromDB.put(checktype.toDB(), checktype);
|
tmpFromDB.put(checktype.toDB(), checktype);
|
||||||
CheckCommand.setCheckQuestions(checktype, config.getCheckQuestions());
|
CheckCommand.setCheckQuestions(checktype, gameModeConfig.CheckQuestions);
|
||||||
}
|
}
|
||||||
|
|
||||||
SchematicType current = new SchematicType(config.getSchemType(), shortcut, config.getServer() != null ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material, parseDeadline(config.getDeadline()), config.getSchematic().isManualCheck());
|
SchematicType current = new SchematicType(gameModeConfig.Schematic.Type, shortcut, gameModeConfig.Server.loaded ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material, gameModeConfig.Deadline, gameModeConfig.Schematic.ManualCheck);
|
||||||
tmpTypes.add(current);
|
tmpTypes.add(current);
|
||||||
tmpFromDB.put(config.getSchemType().toLowerCase(), current);
|
tmpFromDB.put(gameModeConfig.Schematic.Type.toLowerCase(), current);
|
||||||
if(checktype != null)
|
if(checktype != null)
|
||||||
CheckCommand.addFightType(checktype, current);
|
CheckCommand.addFightType(checktype, current);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -19,21 +19,23 @@
|
|||||||
|
|
||||||
package de.steamwar.velocitycore;
|
package de.steamwar.velocitycore;
|
||||||
|
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
|
import de.steamwar.data.YMLWrapperImpl;
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ArenaMode extends GameModeConfig {
|
@UtilityClass
|
||||||
|
public class ArenaMode {
|
||||||
|
|
||||||
private static final Random random = new Random();
|
private static final Map<String, GameModeConfig<String, SchematicType, String>> byChat = new HashMap<>();
|
||||||
|
private static final Map<String, GameModeConfig<String, SchematicType, String>> byInternal = new HashMap<>();
|
||||||
private static final Map<String, ArenaMode> byChat = new HashMap<>();
|
private static final Map<SchematicType, GameModeConfig<String, SchematicType, String>> bySchemType = new HashMap<>();
|
||||||
private static final Map<String, ArenaMode> byInternal = new HashMap<>();
|
|
||||||
private static final Map<SchematicType, ArenaMode> bySchemType = new HashMap<>();
|
|
||||||
@Getter
|
@Getter
|
||||||
private static final List<ArenaMode> allModes = new LinkedList<>();
|
private static final List<GameModeConfig<String, SchematicType, String>> allModes = new LinkedList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
init();
|
init();
|
||||||
@@ -45,90 +47,43 @@ public class ArenaMode extends GameModeConfig {
|
|||||||
bySchemType.clear();
|
bySchemType.clear();
|
||||||
allModes.clear();
|
allModes.clear();
|
||||||
|
|
||||||
GameModeConfig.loadAll(ArenaMode.class, (file, mode) -> {
|
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||||
if(mode.getServer() == null)
|
if(!folder.exists())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mode.config = file.getName();
|
for(File file : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().toList()) {
|
||||||
mode.internalName = file.getName().replace(".yml", "");
|
de.steamwar.data.GameModeConfig<String, SchematicType, String> gameModeConfig = new de.steamwar.data.GameModeConfig<>(YMLWrapperImpl.ofTyped(file));
|
||||||
mode.getMaps().forEach(map -> mode.lowerToRealMapNames.put(map.toLowerCase(), map));
|
if (!gameModeConfig.Server.loaded) continue;
|
||||||
if(mode.getGameName() == null)
|
|
||||||
mode.setGameName(mode.internalName);
|
|
||||||
|
|
||||||
allModes.add(mode);
|
allModes.add(gameModeConfig);
|
||||||
byInternal.put(mode.internalName, mode);
|
byInternal.put(file.getName().replace(".yml", ""), gameModeConfig);
|
||||||
for(String name : mode.getServer().getChatNames()){
|
for (String name : gameModeConfig.Server.ChatNames) {
|
||||||
byChat.put(name.toLowerCase(), mode);
|
byChat.put(name.toLowerCase(), gameModeConfig);
|
||||||
}
|
}
|
||||||
|
if (gameModeConfig.Schematic.loaded && gameModeConfig.Schematic.Type != SchematicType.Normal) {
|
||||||
if(mode.getSchematic() != null && mode.getSchemType() != null)
|
bySchemType.put(gameModeConfig.Schematic.Type, gameModeConfig);
|
||||||
bySchemType.put(SchematicType.fromDB(mode.getSchemType()), mode);
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArenaMode getByChat(String name){
|
public static GameModeConfig<String, SchematicType, String> getByChat(String name){
|
||||||
return byChat.get(name.toLowerCase());
|
return byChat.get(name.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArenaMode getByInternal(String name){
|
public static GameModeConfig<String, SchematicType, String> getByInternal(String name){
|
||||||
return byInternal.get(name);
|
return byInternal.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getAllChatNames(boolean historic) {
|
public static List<String> getAllChatNames(boolean historic) {
|
||||||
List<String> chatNames = new LinkedList<>();
|
List<String> chatNames = new LinkedList<>();
|
||||||
for(ArenaMode mode : byInternal.values()){
|
for(GameModeConfig<String, SchematicType, String> mode : byInternal.values()){
|
||||||
if(mode.isActive() && historic == mode.isHistoric())
|
if(mode.isActive() && historic == mode.Server.Historic)
|
||||||
chatNames.addAll(mode.getServer().getChatNames());
|
chatNames.addAll(mode.Server.ChatNames);
|
||||||
}
|
}
|
||||||
return chatNames;
|
return chatNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArenaMode getBySchemType(SchematicType schemType){
|
public static GameModeConfig<String, SchematicType, String> getBySchemType(SchematicType schemType){
|
||||||
return bySchemType.get(schemType);
|
return bySchemType.get(schemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final Map<String, String> lowerToRealMapNames = new HashMap<>();
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private String internalName;
|
|
||||||
@Getter
|
|
||||||
private String config;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private List<Integer> ActiveMonths = Collections.emptyList();
|
|
||||||
|
|
||||||
public String hasMap(String map){
|
|
||||||
for(String m : getMaps()) {
|
|
||||||
if(m.equalsIgnoreCase(map))
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRandomMap(){
|
|
||||||
return getMaps().get(random.nextInt(getMaps().size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String convertToRealMapName(String map){
|
|
||||||
return lowerToRealMapNames.get(map.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getChatName(){
|
|
||||||
return getServer().getChatNames().get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isActive() {
|
|
||||||
if (getServer().getChatNames().isEmpty()) return false;
|
|
||||||
if (ActiveMonths.isEmpty()) return true;
|
|
||||||
return ActiveMonths.contains(LocalDateTime.now().getMonth().getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSchemTypeOrInternalName() {
|
|
||||||
Schematic schematic = getSchematic();
|
|
||||||
if (schematic == null) {
|
|
||||||
return internalName;
|
|
||||||
}
|
|
||||||
return schematic.getType();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2025 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.velocitycore;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class GameModeConfig {
|
|
||||||
|
|
||||||
private static final Pattern terminatingNumber = Pattern.compile("(\\d+)$");
|
|
||||||
|
|
||||||
public static <T extends GameModeConfig> void loadAll(Class<T> config, BiConsumer<File, T> consumer) {
|
|
||||||
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
|
||||||
if(!folder.exists())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for(File file : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().toList()) {
|
|
||||||
consumer.accept(file, Config.load(config, file, description -> {}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Server Server = null;
|
|
||||||
private List<String> CheckQuestions = Collections.emptyList();
|
|
||||||
private String deadline = null;
|
|
||||||
private Schematic Schematic = null;
|
|
||||||
@Setter
|
|
||||||
private String GameName;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public static class Server {
|
|
||||||
private String Folder;
|
|
||||||
private List<String> ChatNames = Collections.emptyList();
|
|
||||||
private List<String> Maps;
|
|
||||||
private boolean Spigot = false;
|
|
||||||
private boolean Ranked = false;
|
|
||||||
private boolean Historic = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public static class Schematic {
|
|
||||||
private String Type;
|
|
||||||
private String Shortcut;
|
|
||||||
private String Material;
|
|
||||||
private boolean ManualCheck = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerVersion getVersion() {
|
|
||||||
Matcher matcher = terminatingNumber.matcher(getServer().getFolder());
|
|
||||||
matcher.find();
|
|
||||||
return ServerVersion.valueOf((getServer().isSpigot() ? "SPIGOT_" : "PAPER_") + matcher.group(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFolder() {
|
|
||||||
return getServer().getFolder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getMaps() {
|
|
||||||
return getServer().getMaps();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isHistoric() {
|
|
||||||
return getServer().isHistoric();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRanked() {
|
|
||||||
return getServer().isRanked();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSchemType() {
|
|
||||||
return getSchematic().getType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,6 +22,7 @@ package de.steamwar.velocitycore;
|
|||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.velocity.platform.VelocityViaConfig;
|
import com.viaversion.viaversion.velocity.platform.VelocityViaConfig;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.persistent.Arenaserver;
|
import de.steamwar.persistent.Arenaserver;
|
||||||
import de.steamwar.persistent.Bauserver;
|
import de.steamwar.persistent.Bauserver;
|
||||||
@@ -79,16 +80,16 @@ public class ServerStarter {
|
|||||||
private final Set<Player> playersToSend = new HashSet<>();
|
private final Set<Player> playersToSend = new HashSet<>();
|
||||||
private final Map<String, String> arguments = new HashMap<>();
|
private final Map<String, String> arguments = new HashMap<>();
|
||||||
|
|
||||||
public ServerStarter arena(ArenaMode mode, String map) {
|
public ServerStarter arena(GameModeConfig<String, SchematicType, String> mode, String map) {
|
||||||
portrange = ARENA_PORTS;
|
portrange = ARENA_PORTS;
|
||||||
serverNameProvider = port -> mode.getGameName() + (port - portrange.start);
|
serverNameProvider = port -> mode.GameName + (port - portrange.start);
|
||||||
version = mode.getVersion();
|
version = ServerVersion.from(mode);
|
||||||
allowMerge = true;
|
allowMerge = true;
|
||||||
fightMap = map;
|
fightMap = map;
|
||||||
gameMode = mode.getInternalName();
|
gameMode = mode.configFile.getName().replace(".yml", "");
|
||||||
directory = new File(SERVER_PATH, mode.getFolder());
|
directory = new File(SERVER_PATH, mode.Server.Folder);
|
||||||
arguments.put("config", mode.getConfig());
|
arguments.put("config", mode.configFile.getName());
|
||||||
tempWorld(SERVER_PATH + mode.getFolder() + "/arenas/" + map);
|
tempWorld(SERVER_PATH + mode.Server.Folder + "/arenas/" + map);
|
||||||
startCondition = () -> {
|
startCondition = () -> {
|
||||||
if(playersToSend.stream().anyMatch(player -> Subserver.isArena(Subserver.getSubserver(player)))) {
|
if(playersToSend.stream().anyMatch(player -> Subserver.isArena(Subserver.getSubserver(player)))) {
|
||||||
playersToSend.forEach(player -> Chatter.of(player).system("FIGHT_IN_ARENA"));
|
playersToSend.forEach(player -> Chatter.of(player).system("FIGHT_IN_ARENA"));
|
||||||
@@ -115,7 +116,7 @@ public class ServerStarter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStarter test(ArenaMode mode, String map, Player owner) {
|
public ServerStarter test(GameModeConfig<String, SchematicType, String> mode, String map, Player owner) {
|
||||||
arena(mode, map);
|
arena(mode, map);
|
||||||
buildWithTemp(owner);
|
buildWithTemp(owner);
|
||||||
portrange = BAU_PORTS;
|
portrange = BAU_PORTS;
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
package de.steamwar.velocitycore;
|
package de.steamwar.velocitycore;
|
||||||
|
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -27,6 +29,8 @@ import java.io.File;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@@ -108,4 +112,12 @@ public enum ServerVersion {
|
|||||||
public File getServerDirectory(String base) {
|
public File getServerDirectory(String base) {
|
||||||
return new File(ServerStarter.SERVER_PATH, base + versionSuffix);
|
return new File(ServerStarter.SERVER_PATH, base + versionSuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Pattern terminatingNumber = Pattern.compile("(\\d+)$");
|
||||||
|
|
||||||
|
public static ServerVersion from(GameModeConfig<String, SchematicType, String> type) {
|
||||||
|
Matcher matcher = terminatingNumber.matcher(type.Server.Folder);
|
||||||
|
matcher.find();
|
||||||
|
return ServerVersion.valueOf((type.Server.Spigot ? "SPIGOT_" : "PAPER_") + matcher.group(1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import de.steamwar.command.PreviousArguments;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.linkage.EventMode;
|
import de.steamwar.linkage.EventMode;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
@@ -32,6 +33,7 @@ import de.steamwar.messages.PlayerChatter;
|
|||||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||||
import de.steamwar.persistent.Bauserver;
|
import de.steamwar.persistent.Bauserver;
|
||||||
import de.steamwar.sql.BauweltMember;
|
import de.steamwar.sql.BauweltMember;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.velocitycore.*;
|
import de.steamwar.velocitycore.*;
|
||||||
import de.steamwar.velocitycore.inventory.SWInventory;
|
import de.steamwar.velocitycore.inventory.SWInventory;
|
||||||
@@ -238,7 +240,7 @@ public class BauCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register("test")
|
@Register("test")
|
||||||
@Register("testarena")
|
@Register("testarena")
|
||||||
public void testarena(PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
public void testarena(PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull GameModeConfig<String, SchematicType, String> arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||||
FightCommand.createArena(sender, "/bau testarena ", false, arenaMode, map, false, (chatter, mode, m) ->
|
FightCommand.createArena(sender, "/bau testarena ", false, arenaMode, map, false, (chatter, mode, m) ->
|
||||||
new ServerStarter().test(mode, m, sender.getPlayer()).start()
|
new ServerStarter().test(mode, m, sender.getPlayer()).start()
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
|
|
||||||
package de.steamwar.velocitycore.commands;
|
package de.steamwar.velocitycore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.velocitycore.ArenaMode;
|
import de.steamwar.velocitycore.ArenaMode;
|
||||||
import de.steamwar.velocitycore.ServerStarter;
|
import de.steamwar.velocitycore.ServerStarter;
|
||||||
import de.steamwar.velocitycore.ServerVersion;
|
import de.steamwar.velocitycore.ServerVersion;
|
||||||
@@ -85,14 +87,14 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "deploy", description = "BUILDERCLOUD_DEPLOY_USAGE")
|
@Register(value = "deploy", description = "BUILDERCLOUD_DEPLOY_USAGE")
|
||||||
public void deploy(Chatter sender, @Mapper("nonHistoricArenaMode") ArenaMode arenaMode, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map) {
|
public void deploy(Chatter sender, @Mapper("nonHistoricArenaMode") GameModeConfig<String, SchematicType, String> arenaMode, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map) {
|
||||||
if(!mapFile(version, map).exists()) {
|
if(!mapFile(version, map).exists()) {
|
||||||
sender.system("BUILDERCLOUD_UNKNOWN_MAP");
|
sender.system("BUILDERCLOUD_UNKNOWN_MAP");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VelocityCore.schedule(() -> {
|
VelocityCore.schedule(() -> {
|
||||||
VelocityCore.local.execute("deployarena.py", arenaMode.getConfig(), Integer.toString(version.getVersionSuffix()), map);
|
VelocityCore.local.execute("deployarena.py", arenaMode.configFile.getName(), Integer.toString(version.getVersionSuffix()), map);
|
||||||
ArenaMode.init();
|
ArenaMode.init();
|
||||||
sender.system("BUILDERCLOUD_DEPLOY_FINISHED");
|
sender.system("BUILDERCLOUD_DEPLOY_FINISHED");
|
||||||
}).schedule();
|
}).schedule();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ package de.steamwar.velocitycore.commands;
|
|||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.linkage.EventMode;
|
import de.steamwar.linkage.EventMode;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
@@ -29,6 +30,7 @@ import de.steamwar.messages.Message;
|
|||||||
import de.steamwar.messages.PlayerChatter;
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import de.steamwar.persistent.Subserver;
|
import de.steamwar.persistent.Subserver;
|
||||||
import de.steamwar.sql.IgnoreSystem;
|
import de.steamwar.sql.IgnoreSystem;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.velocitycore.ArenaMode;
|
import de.steamwar.velocitycore.ArenaMode;
|
||||||
import de.steamwar.velocitycore.ServerStarter;
|
import de.steamwar.velocitycore.ServerStarter;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
@@ -46,7 +48,7 @@ public class ChallengeCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "CHALLENGE_USAGE")
|
@Register(description = "CHALLENGE_USAGE")
|
||||||
public void challenge(@Validator("arenaPlayer") PlayerChatter sender, @Validator("target") Player target, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
public void challenge(@Validator("arenaPlayer") PlayerChatter sender, @Validator("target") Player target, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull GameModeConfig<String, SchematicType, String> arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||||
FightCommand.createArena(sender, "/challenge " + target.getUsername() + " ", false, arenaMode, map, false, (chatter, mode, m) -> {
|
FightCommand.createArena(sender, "/challenge " + target.getUsername() + " ", false, arenaMode, map, false, (chatter, mode, m) -> {
|
||||||
Player p = sender.getPlayer();
|
Player p = sender.getPlayer();
|
||||||
if(challenges.containsKey(target) && challenges.get(target).contains(p)){
|
if(challenges.containsKey(target) && challenges.get(target).contains(p)){
|
||||||
@@ -54,7 +56,7 @@ public class ChallengeCommand extends SWCommand {
|
|||||||
challenges.remove(p);
|
challenges.remove(p);
|
||||||
|
|
||||||
new ServerStarter().arena(mode, map).blueLeader(sender.getPlayer()).redLeader(target).callback(
|
new ServerStarter().arena(mode, map).blueLeader(sender.getPlayer()).redLeader(target).callback(
|
||||||
arena -> Chatter.broadcast().system("CHALLENGE_BROADCAST", new Message("CHALLENGE_BROADCAST_HOVER"), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.getGameName(), p, target)
|
arena -> Chatter.broadcast().system("CHALLENGE_BROADCAST", new Message("CHALLENGE_BROADCAST_HOVER"), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.GameName, p, target)
|
||||||
).start();
|
).start();
|
||||||
}else{
|
}else{
|
||||||
if(!challenges.containsKey(p)){
|
if(!challenges.containsKey(p)){
|
||||||
@@ -63,8 +65,8 @@ public class ChallengeCommand extends SWCommand {
|
|||||||
|
|
||||||
challenges.get(p).add(target);
|
challenges.get(p).add(target);
|
||||||
|
|
||||||
sender.system("CHALLENGE_CHALLENGED", target, mode.getGameName());
|
sender.system("CHALLENGE_CHALLENGED", target, mode.GameName);
|
||||||
Chatter.of(target).system("CHALLENGE_CHALLENGED_TARGET", p, mode.getGameName(), mode.getMaps().size() != 1 ? new Message("CHALLENGE_CHALLENGED_MAP", m) : "");
|
Chatter.of(target).system("CHALLENGE_CHALLENGED_TARGET", p, mode.GameName, mode.Server.Maps.size() != 1 ? new Message("CHALLENGE_CHALLENGED_MAP", m) : "");
|
||||||
|
|
||||||
Chatter.of(target).system("CHALLENGE_ACCEPT", new Message("CHALLENGE_ACCEPT_HOVER"), ClickEvent.runCommand("/challenge " + p.getUsername() + " " + mode.getChatName() + " " + m));
|
Chatter.of(target).system("CHALLENGE_ACCEPT", new Message("CHALLENGE_ACCEPT_HOVER"), ClickEvent.runCommand("/challenge " + p.getUsername() + " " + mode.getChatName() + " " + m));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ package de.steamwar.velocitycore.commands;
|
|||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.messages.Message;
|
import de.steamwar.messages.Message;
|
||||||
@@ -39,8 +40,8 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -220,7 +221,7 @@ public class CheckCommand extends SWCommand {
|
|||||||
this.startTime = Timestamp.from(Instant.now());
|
this.startTime = Timestamp.from(Instant.now());
|
||||||
this.checkList = checkQuestions.get(schematic.getSchemtype()).listIterator();
|
this.checkList = checkQuestions.get(schematic.getSchemtype()).listIterator();
|
||||||
|
|
||||||
ArenaMode mode = ArenaMode.getBySchemType(fightTypes.get(schematic.getSchemtype()));
|
GameModeConfig<String, SchematicType, String> mode = ArenaMode.getBySchemType(fightTypes.get(schematic.getSchemtype()));
|
||||||
new ServerStarter().test(mode, mode.getRandomMap(), checker.getPlayer()).check(schematic.getId()).callback(subserver -> {
|
new ServerStarter().test(mode, mode.getRandomMap(), checker.getPlayer()).check(schematic.getId()).callback(subserver -> {
|
||||||
currentCheckers.put(checker.user().getUUID(), this);
|
currentCheckers.put(checker.user().getUUID(), this);
|
||||||
currentSchems.put(schematic.getId(), this);
|
currentSchems.put(schematic.getId(), this);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ package de.steamwar.velocitycore.commands;
|
|||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.linkage.EventMode;
|
import de.steamwar.linkage.EventMode;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
@@ -28,6 +29,7 @@ import de.steamwar.messages.Message;
|
|||||||
import de.steamwar.messages.PlayerChatter;
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import de.steamwar.persistent.Arenaserver;
|
import de.steamwar.persistent.Arenaserver;
|
||||||
import de.steamwar.persistent.Subserver;
|
import de.steamwar.persistent.Subserver;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.velocitycore.ArenaMode;
|
import de.steamwar.velocitycore.ArenaMode;
|
||||||
import de.steamwar.velocitycore.ServerStarter;
|
import de.steamwar.velocitycore.ServerStarter;
|
||||||
import de.steamwar.velocitycore.inventory.SWInventory;
|
import de.steamwar.velocitycore.inventory.SWInventory;
|
||||||
@@ -48,8 +50,8 @@ public class FightCommand extends SWCommand {
|
|||||||
|
|
||||||
private static void getModes(Chatter sender, String precommand, boolean historic){
|
private static void getModes(Chatter sender, String precommand, boolean historic){
|
||||||
Component start = Component.empty();
|
Component start = Component.empty();
|
||||||
for(ArenaMode mode : ArenaMode.getAllModes()){
|
for(GameModeConfig<String, SchematicType, String> mode : ArenaMode.getAllModes()){
|
||||||
if (!mode.isActive() || mode.isHistoric() != historic)
|
if (!mode.isActive() || mode.Server.Historic != historic)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String command = precommand + mode.getChatName();
|
String command = precommand + mode.getChatName();
|
||||||
@@ -64,7 +66,7 @@ public class FightCommand extends SWCommand {
|
|||||||
sender.sendMessage(start);
|
sender.sendMessage(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createArena(PlayerChatter sender, String precommand, boolean allowMerging, ArenaMode arenaMode, String map, boolean historic, FightCallback callback) {
|
static void createArena(PlayerChatter sender, String precommand, boolean allowMerging, GameModeConfig<String, SchematicType, String> arenaMode, String map, boolean historic, FightCallback callback) {
|
||||||
if (arenaMode == null) {
|
if (arenaMode == null) {
|
||||||
getModes(sender, precommand, historic);
|
getModes(sender, precommand, historic);
|
||||||
return;
|
return;
|
||||||
@@ -80,12 +82,12 @@ public class FightCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void suggestMerging(PlayerChatter sender, ArenaMode mode, String map, FightCallback declineMerge) {
|
private static void suggestMerging(PlayerChatter sender, GameModeConfig<String, SchematicType, String> mode, String map, FightCallback declineMerge) {
|
||||||
Arenaserver mergable = null;
|
Arenaserver mergable = null;
|
||||||
synchronized (Subserver.getServerList()) {
|
synchronized (Subserver.getServerList()) {
|
||||||
for (Subserver subserver : Subserver.getServerList()) {
|
for (Subserver subserver : Subserver.getServerList()) {
|
||||||
if(subserver instanceof Arenaserver arenaserver &&
|
if(subserver instanceof Arenaserver arenaserver &&
|
||||||
(mode.getInternalName().equals(arenaserver.getMode()) && arenaserver.isAllowMerge() && arenaserver.getRegisteredServer().getPlayersConnected().size() == 1)) {
|
(mode.configFile.getName().replace(".yml", "").equals(arenaserver.getMode()) && arenaserver.isAllowMerge() && arenaserver.getRegisteredServer().getPlayersConnected().size() == 1)) {
|
||||||
mergable = arenaserver;
|
mergable = arenaserver;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -103,7 +105,7 @@ public class FightCommand extends SWCommand {
|
|||||||
declineMerge.run(sender, mode, map);
|
declineMerge.run(sender, mode, map);
|
||||||
});
|
});
|
||||||
Arenaserver finalMergable = mergable;
|
Arenaserver finalMergable = mergable;
|
||||||
SWItem item = new SWItem(new Message("FIGHT_MERGE_INFO", mode.getGameName(), finalMergable.getMap()), 11);
|
SWItem item = new SWItem(new Message("FIGHT_MERGE_INFO", mode.GameName, finalMergable.getMap()), 11);
|
||||||
item.addLore(new Message("FIGHT_MERGE_INFO_LORE_1", finalMergable.getRegisteredServer().getPlayersConnected().toArray(new Player[1])[0].getUsername()));
|
item.addLore(new Message("FIGHT_MERGE_INFO_LORE_1", finalMergable.getRegisteredServer().getPlayersConnected().toArray(new Player[1])[0].getUsername()));
|
||||||
inventory.addItem(4, item, click -> {});
|
inventory.addItem(4, item, click -> {});
|
||||||
inventory.addItem(8, new SWItem(new Message("FIGHT_MERGE_ACCEPT"), 10), click -> {
|
inventory.addItem(8, new SWItem(new Message("FIGHT_MERGE_ACCEPT"), 10), click -> {
|
||||||
@@ -118,15 +120,15 @@ public class FightCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void fight(@Validator("arenaPlayer") PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
public void fight(@Validator("arenaPlayer") PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull GameModeConfig<String, SchematicType, String> arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||||
createArena(sender, "/fight ", true, arenaMode, map, false,
|
createArena(sender, "/fight ", true, arenaMode, map, false,
|
||||||
(p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p.getPlayer()).callback(
|
(p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p.getPlayer()).callback(
|
||||||
arena -> Chatter.broadcast().system("FIGHT_BROADCAST", new Message("FIGHT_BROADCAST_HOVER", p.getPlayer().getUsername()), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.getGameName(), p.getPlayer().getUsername())
|
arena -> Chatter.broadcast().system("FIGHT_BROADCAST", new Message("FIGHT_BROADCAST_HOVER", p.getPlayer().getUsername()), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.GameName, p.getPlayer().getUsername())
|
||||||
).start()
|
).start()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface FightCallback {
|
public interface FightCallback {
|
||||||
void run(PlayerChatter player, ArenaMode mode, String map);
|
void run(PlayerChatter player, GameModeConfig<String, SchematicType, String> mode, String map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,13 @@
|
|||||||
package de.steamwar.velocitycore.commands;
|
package de.steamwar.velocitycore.commands;
|
||||||
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.linkage.EventMode;
|
import de.steamwar.linkage.EventMode;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.messages.Message;
|
import de.steamwar.messages.Message;
|
||||||
import de.steamwar.messages.PlayerChatter;
|
import de.steamwar.messages.PlayerChatter;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.velocitycore.ArenaMode;
|
import de.steamwar.velocitycore.ArenaMode;
|
||||||
import de.steamwar.velocitycore.ServerStarter;
|
import de.steamwar.velocitycore.ServerStarter;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
@@ -37,9 +39,9 @@ public class HistoricCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void historic(@Validator("arenaPlayer") PlayerChatter player, @Mapper("historicArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
public void historic(@Validator("arenaPlayer") PlayerChatter player, @Mapper("historicArenaMode") @OptionalValue("") @AllowNull GameModeConfig<String, SchematicType, String> arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||||
FightCommand.createArena(player, "/historic ", true, arenaMode, map, true, (p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p.getPlayer()).callback(
|
FightCommand.createArena(player, "/historic ", true, arenaMode, map, true, (p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p.getPlayer()).callback(
|
||||||
arena -> Chatter.broadcast().system("HISTORIC_BROADCAST", new Message("HISTORIC_BROADCAST_HOVER", p), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.getGameName(), p.getPlayer())
|
arena -> Chatter.broadcast().system("HISTORIC_BROADCAST", new Message("HISTORIC_BROADCAST_HOVER", p), ClickEvent.runCommand("/arena " + arena.getServer().getName()), mode.GameName, p.getPlayer())
|
||||||
).start());
|
).start());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,11 @@
|
|||||||
package de.steamwar.velocitycore.commands;
|
package de.steamwar.velocitycore.commands;
|
||||||
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.messages.Message;
|
import de.steamwar.messages.Message;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserElo;
|
import de.steamwar.sql.UserElo;
|
||||||
import de.steamwar.velocitycore.ArenaMode;
|
import de.steamwar.velocitycore.ArenaMode;
|
||||||
@@ -46,8 +48,8 @@ public class RankCommand extends SWCommand {
|
|||||||
if (!sender.user().equals(user))
|
if (!sender.user().equals(user))
|
||||||
sender.prefixless("RANK_PLAYER_FOUND", user);
|
sender.prefixless("RANK_PLAYER_FOUND", user);
|
||||||
|
|
||||||
for(ArenaMode mode : ArenaMode.getAllModes()) {
|
for(GameModeConfig<String, SchematicType, String> mode : ArenaMode.getAllModes()) {
|
||||||
if (!mode.isRanked())
|
if (!mode.Server.Ranked)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Optional<Integer> elo = UserElo.getElo(user.getId(), mode.getSchemTypeOrInternalName());
|
Optional<Integer> elo = UserElo.getElo(user.getId(), mode.getSchemTypeOrInternalName());
|
||||||
|
|||||||
@@ -19,17 +19,18 @@
|
|||||||
|
|
||||||
package de.steamwar.velocitycore.commands;
|
package de.steamwar.velocitycore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.linkage.EventMode;
|
import de.steamwar.linkage.EventMode;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.velocitycore.ArenaMode;
|
|
||||||
import de.steamwar.messages.Message;
|
import de.steamwar.messages.Message;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
|
import de.steamwar.sql.*;
|
||||||
|
import de.steamwar.velocitycore.ArenaMode;
|
||||||
import de.steamwar.velocitycore.ServerStarter;
|
import de.steamwar.velocitycore.ServerStarter;
|
||||||
import de.steamwar.velocitycore.inventory.SWItem;
|
import de.steamwar.velocitycore.inventory.SWItem;
|
||||||
import de.steamwar.velocitycore.inventory.SWListInv;
|
import de.steamwar.velocitycore.inventory.SWListInv;
|
||||||
import de.steamwar.velocitycore.inventory.SWStreamInv;
|
import de.steamwar.velocitycore.inventory.SWStreamInv;
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.messages.PlayerChatter;
|
|
||||||
import de.steamwar.sql.*;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -68,7 +69,7 @@ public class ReplayCommand extends SWCommand {
|
|||||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ArenaMode mode = ArenaMode.getBySchemType(fight.getSchemType());
|
GameModeConfig<String, SchematicType, String> mode = ArenaMode.getBySchemType(fight.getSchemType());
|
||||||
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(sender.getPlayer());
|
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(sender.getPlayer());
|
||||||
|
|
||||||
String map = mode.getRandomMap();
|
String map = mode.getRandomMap();
|
||||||
|
|||||||
@@ -19,14 +19,16 @@
|
|||||||
|
|
||||||
package de.steamwar.velocitycore.commands;
|
package de.steamwar.velocitycore.commands;
|
||||||
|
|
||||||
import de.steamwar.velocitycore.ArenaMode;
|
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.messages.PlayerChatter;
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import de.steamwar.sql.Punishment;
|
import de.steamwar.sql.Punishment;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
|
import de.steamwar.velocitycore.ArenaMode;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -45,13 +47,13 @@ public class TypeMappers {
|
|||||||
return (sender, player, messageSender) -> !PunishmentCommand.isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer);
|
return (sender, player, messageSender) -> !PunishmentCommand.isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TypeMapper<ArenaMode> arenaModeTypeMapper(boolean historic) {
|
private static TypeMapper<GameModeConfig<String, SchematicType, String>> arenaModeTypeMapper(boolean historic) {
|
||||||
return new TypeMapper<>() {
|
return new TypeMapper<>() {
|
||||||
@Override
|
@Override
|
||||||
public ArenaMode map(Chatter sender, PreviousArguments previousArguments, String s) {
|
public GameModeConfig<String, SchematicType, String> map(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
ArenaMode arenaMode = ArenaMode.getByChat(s);
|
GameModeConfig<String, SchematicType, String> arenaMode = ArenaMode.getByChat(s);
|
||||||
if (arenaMode == null) return null;
|
if (arenaMode == null) return null;
|
||||||
if (arenaMode.isHistoric() != historic) return null;
|
if (arenaMode.Server.Historic != historic) return null;
|
||||||
if (!arenaMode.isActive()) return null;
|
if (!arenaMode.isActive()) return null;
|
||||||
return arenaMode;
|
return arenaMode;
|
||||||
}
|
}
|
||||||
@@ -74,9 +76,9 @@ public class TypeMappers {
|
|||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
if (previousArguments.userArgs.length == 0) return null;
|
if (previousArguments.userArgs.length == 0) return null;
|
||||||
ArenaMode arenaMode = ArenaMode.getByChat(previousArguments.userArgs[previousArguments.userArgs.length - 1]);
|
GameModeConfig<String, SchematicType, String> arenaMode = ArenaMode.getByChat(previousArguments.userArgs[previousArguments.userArgs.length - 1]);
|
||||||
if (arenaMode == null) return null;
|
if (arenaMode == null) return null;
|
||||||
return arenaMode.getMaps();
|
return arenaMode.Server.Maps;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
|||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||||
|
import de.steamwar.data.GameModeConfig;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.messages.ChatterGroup;
|
import de.steamwar.messages.ChatterGroup;
|
||||||
@@ -56,7 +57,7 @@ public class ChatListener extends BasicListener {
|
|||||||
|
|
||||||
private static final Logger cmdLogger = Logger.getLogger("Command logger");
|
private static final Logger cmdLogger = Logger.getLogger("Command logger");
|
||||||
|
|
||||||
private static final List<String> rankedModes = ArenaMode.getAllModes().stream().filter(ArenaMode::isRanked).map(ArenaMode::getSchemTypeOrInternalName).toList();
|
private static final List<String> rankedModes = ArenaMode.getAllModes().stream().filter(gameModeConfig -> gameModeConfig.Server.Ranked).map(GameModeConfig::getSchemTypeOrInternalName).toList();
|
||||||
|
|
||||||
private static final Set<String> noLogCommands = Set.of("webpw", "webpassword", "web");
|
private static final Set<String> noLogCommands = Set.of("webpw", "webpassword", "web");
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user