forked from SteamWar/SteamWar
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea3aad3bd2 | ||
|
|
d307f890e2 | ||
|
|
97c1da1b2a | ||
|
|
8a53aecfac | ||
|
|
5236afba17 | ||
|
|
d3c8b6e1c6 | ||
|
|
00ea792eee | ||
|
|
38e845b0e4 | ||
|
|
c60a8caed8 | ||
|
|
2e390286b2 | ||
|
|
6476125a3f | ||
|
|
311437d451 | ||
|
|
5a52771ec1 | ||
|
|
72b70a62e1 | ||
|
|
8575dcac33 | ||
|
|
cb744f6aa0 | ||
|
|
227f63c9ff |
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.features.world;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
@Linked
|
||||
public class AntiPlayerCollision implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Scoreboard board = event.getPlayer().getScoreboard();
|
||||
Team team = board.getTeam("players");
|
||||
if (team == null) team = board.registerNewTeam("players");
|
||||
team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
|
||||
team.addPlayer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
plugins {
|
||||
steamwar.kotlin
|
||||
kotlin("plugin.lombok")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@@ -40,4 +41,8 @@ dependencies {
|
||||
compileOnlyApi(libs.exposedDao)
|
||||
compileOnlyApi(libs.exposedJdbc)
|
||||
compileOnlyApi(libs.exposedTime)
|
||||
testImplementation(kotlin("test"))
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
@@ -688,13 +688,6 @@ public final class GameModeConfig<M, W> {
|
||||
*/
|
||||
public final int MaxBlocks;
|
||||
|
||||
/**
|
||||
* Maximal amount of items per dispenser
|
||||
*
|
||||
* @implSpec {@code 128} by default
|
||||
*/
|
||||
public final int MaxDispenserItems;
|
||||
|
||||
/**
|
||||
* Maximal blast resistance for the blocks
|
||||
*
|
||||
@@ -710,10 +703,12 @@ public final class GameModeConfig<M, W> {
|
||||
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)
|
||||
* List of limited block materials
|
||||
*
|
||||
* @implSpec {@link SQLWrapper#getInventoryMaterials)} are all disallowed by default to have any content but are unlimited in number.
|
||||
* @implSpec Any Block that has more Blast Resistance than {@link #MaxBlastResistance} will be defaulted to 0.
|
||||
*/
|
||||
public final Map<Set<M>, Integer> Limited;
|
||||
public final List<BlockRule<M>> Limited;
|
||||
|
||||
private SchematicConfig(YMLWrapper<M, ?> loader) {
|
||||
loaded = loader.canLoad();
|
||||
@@ -731,32 +726,140 @@ public final class GameModeConfig<M, W> {
|
||||
IgnorePublicOnly = loader.getBoolean("IgnorePublicOnly", false);
|
||||
UnlimitedPrepare = loader.getBoolean("UnlimitedPrepare", false);
|
||||
MaxBlocks = loader.getInt("MaxBlocks", 0);
|
||||
MaxDispenserItems = loader.getInt("MaxDispenserItems", 128);
|
||||
MaxBlastResistance = loader.getDouble("MaxBlastResistance", Double.MAX_VALUE);
|
||||
MaxDesignBlastResistance = loader.getDouble("MaxDesignBlastResistance", MaxBlastResistance);
|
||||
|
||||
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);
|
||||
List<BlockRule<M>> limited = new ArrayList<>();
|
||||
Set<M> blocks = new HashSet<>();
|
||||
for (YMLWrapper<M, ?> limitedLoader : loader.withAsList("Limited")) {
|
||||
BlockRule<M> blockRule = new BlockRule<>(limitedLoader);
|
||||
blocks.addAll(blockRule.Materials);
|
||||
limited.add(blockRule);
|
||||
}
|
||||
for (M material : (List<M>) SQLWrapper.impl.getMaterialWithGreaterBlastResistance(MaxBlastResistance)) {
|
||||
if (material == null || !blocks.add(material)) continue;
|
||||
limited.add(new BlockRule<>(material, 0));
|
||||
}
|
||||
SQLWrapper.impl.getMaterialWithGreaterBlastResistance(MaxBlastResistance).forEach(material -> {
|
||||
if (Limited.entrySet().stream().anyMatch(entry -> entry.getKey().contains(material))) return;
|
||||
Limited.put(Collections.singleton((M) material), 0);
|
||||
});
|
||||
this.Limited = Collections.unmodifiableMap(Limited);
|
||||
for (M material : (Set<M>) SQLWrapper.impl.getInventoryMaterials()) {
|
||||
if (material == null || !blocks.add(material)) continue;
|
||||
limited.add(new BlockRule<>(material, Integer.MAX_VALUE));
|
||||
}
|
||||
this.Limited = Collections.unmodifiableList(limited);
|
||||
|
||||
this.ReplacementsWithoutBlockUpdates = loader.getMap("ReplacementsWithoutBlockUpdates", loader.materialMapper, loader.materialMapper);
|
||||
this.ReplacementsWithBlockUpdates = loader.getMap("ReplacementsWithBlockUpdates", loader.materialMapper, loader.materialMapper);
|
||||
}
|
||||
|
||||
public int getMaxCount(M material) {
|
||||
return Limited.stream()
|
||||
.filter(rule -> rule.Materials.contains(material))
|
||||
.mapToInt(rule -> rule.Amount)
|
||||
.max()
|
||||
.orElse(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public boolean isInventory(M material) {
|
||||
return Limited.stream()
|
||||
.filter(rule -> rule.Materials.contains(material))
|
||||
.anyMatch(rule -> rule.Content.loaded);
|
||||
}
|
||||
|
||||
public Integer getItemAmount(M material, M item) {
|
||||
return Limited.stream()
|
||||
.filter(rule -> rule.Materials.contains(material))
|
||||
.filter(rule -> rule.Content.Items.contains(item))
|
||||
.mapToInt(rule -> rule.Content.Amount)
|
||||
.max()
|
||||
.orElse(0);
|
||||
}
|
||||
|
||||
@ToString
|
||||
public static final class BlockRule<M> {
|
||||
|
||||
/**
|
||||
* The block materials this rule applies to
|
||||
*/
|
||||
public final Set<M> Materials;
|
||||
|
||||
/**
|
||||
* Maximal amount of Blocks allowed in the schematic
|
||||
*
|
||||
* @implSpec {@code 0} by default
|
||||
*/
|
||||
public final int Amount;
|
||||
|
||||
/**
|
||||
* The item content filter for Blocks
|
||||
*
|
||||
* @implSpec no Items with {@code Amount 0} (denies any item) by default
|
||||
*/
|
||||
public final Content<M> Content;
|
||||
|
||||
/**
|
||||
* Resolves one {@code Materials} entry to the concrete materials it denotes: {@code storage}
|
||||
* for {@link SQLWrapper#getStorageMaterials()}, {@code all} for
|
||||
* {@link SQLWrapper#getInventoryMaterials()}, or the material itself otherwise.
|
||||
*/
|
||||
private Set<M> expandInventoryGroup(YMLWrapper<M, ?> loader, String name) {
|
||||
switch (name.toUpperCase()) {
|
||||
case "STORAGE":
|
||||
return (Set<M>) SQLWrapper.impl.getStorageMaterials();
|
||||
case "INVENTORY":
|
||||
return (Set<M>) SQLWrapper.impl.getInventoryMaterials();
|
||||
default:
|
||||
M material = loader.materialMapper.apply(name.toUpperCase());
|
||||
return material != null ? Collections.singleton(material) : Collections.emptySet();
|
||||
}
|
||||
}
|
||||
|
||||
private BlockRule(YMLWrapper<M, ?> loader) {
|
||||
Set<M> blocks = loader.getStringList("Materials")
|
||||
.stream()
|
||||
.flatMap(value -> expandInventoryGroup(loader, value).stream())
|
||||
.collect(Collectors.toSet());
|
||||
Materials = Collections.unmodifiableSet(blocks);
|
||||
Amount = loader.getInt("Amount", 0);
|
||||
Content = new Content<>(loader.with("Content"));
|
||||
}
|
||||
|
||||
private BlockRule(M block, int amount) {
|
||||
Materials = Collections.singleton(block);
|
||||
Amount = amount;
|
||||
Content = new Content<>();
|
||||
}
|
||||
|
||||
@ToString
|
||||
public static final class Content<M> {
|
||||
|
||||
public final boolean loaded;
|
||||
|
||||
/**
|
||||
* Items allowed by this rule
|
||||
*/
|
||||
public final Set<M> Items;
|
||||
|
||||
/**
|
||||
* Maximal amount of an allowed item per single block instance
|
||||
*
|
||||
* @implSpec {@code 0} by default
|
||||
*/
|
||||
public final int Amount;
|
||||
|
||||
private Content(YMLWrapper<M, ?> loader) {
|
||||
loaded = loader.canLoad();
|
||||
List<M> items = loader.getMaterialList("Items");
|
||||
Items = Collections.unmodifiableSet(new HashSet<>(items));
|
||||
Amount = loader.getInt("Amount", 0);
|
||||
}
|
||||
|
||||
private Content() {
|
||||
loaded = false;
|
||||
Items = new HashSet<>();
|
||||
Amount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ToString
|
||||
public static final class SizeConfig {
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import de.steamwar.ImplementationProvider;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface SQLWrapper<M> {
|
||||
SQLWrapper<?> impl = ImplementationProvider.getImpl("de.steamwar.sql.SQLWrapperImpl");
|
||||
@@ -36,5 +37,21 @@ public interface SQLWrapper<M> {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage-type inventory materials (chests, barrels, shulker boxes of any color) - the
|
||||
* {@code storage} group usable in {@code GameModeConfig}'s {@code Limited}.
|
||||
*/
|
||||
default Set<M> getStorageMaterials() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Every inventory material - the {@code all} group usable in {@code GameModeConfig}'s
|
||||
* {@code Limited}. Expected to be a superset of {@link #getStorageMaterials()}.
|
||||
*/
|
||||
default Set<M> getInventoryMaterials() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
void additionalExceptionMetadata(StringBuilder builder);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,25 @@ final class YMLWrapper<M, W> {
|
||||
return new YMLWrapper<>(false, Collections.emptyMap(), materialMapper, winconditionMapper);
|
||||
}
|
||||
|
||||
public List<YMLWrapper<M, W>> withAsList(String path) {
|
||||
if (document.containsKey(path)) {
|
||||
Object value = document.get(path);
|
||||
if (value instanceof List) {
|
||||
List<?> list = (List<?>) value;
|
||||
List<Map> maps = list.stream()
|
||||
.filter(Map.class::isInstance)
|
||||
.map(Map.class::cast)
|
||||
.collect(Collectors.toList());
|
||||
if (maps.size() == list.size()) {
|
||||
return (List) maps.stream()
|
||||
.map(map -> new YMLWrapper(true, map, materialMapper, winconditionMapper))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public <T> T get(String path, T defaultValue, Function<Object, T> mapper) {
|
||||
Object value = this.document.get(path);
|
||||
if (value == null) return defaultValue;
|
||||
|
||||
@@ -107,15 +107,23 @@ Schematic:
|
||||
UnlimitedPrepare: false # defaults to false if missing
|
||||
# Maximal amount of blocks allowed in the schematic
|
||||
MaxBlocks: 0 # defaults to 0 (ignored) if missing
|
||||
# Maximal amount of items per dispenser
|
||||
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 contains tags Amount (integer) and Materials (List of material names in Spigot 1.12 AND Spigot 1.15 format)
|
||||
# List of limited block materials
|
||||
# InventoryMaterials are all disallowed by default to have any content but are unlimited in number
|
||||
# Any Block that has more Blast Resistance than MaxBlastResistance will be defaulted to 0.
|
||||
Limited:
|
||||
- Materials: [ ]
|
||||
Amount: 0
|
||||
- Blocks: [ DISPENSER ]
|
||||
MaxCount: 64
|
||||
- Blocks: [ DISPENSER ]
|
||||
MaxCount: 16
|
||||
Content:
|
||||
Items: [ ARROW, FIRE_CHARGE ]
|
||||
Amount: 128
|
||||
- Blocks: [ storage ]
|
||||
Content:
|
||||
Items: [ TNT ]
|
||||
Amount: 1728
|
||||
|
||||
# The name of the game mode presented to the players
|
||||
GameName: WarGear # defaults to WarGear if missing
|
||||
|
||||
@@ -39,6 +39,7 @@ public enum ArenaMode {
|
||||
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
||||
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
|
||||
public static final Set<ArenaMode> Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST));
|
||||
public static final Set<ArenaMode> TestOrReferee = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, EVENT));
|
||||
|
||||
public static final Set<ArenaMode> AntiReplay = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(REPLAY)));
|
||||
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
|
||||
|
||||
@@ -22,7 +22,6 @@ package de.steamwar.fightsystem;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||
import de.steamwar.fightsystem.commands.TechareaCommand;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.ClickAnalyzer;
|
||||
@@ -127,8 +126,6 @@ public class FightSystem extends JavaPlugin {
|
||||
if (checkSchematicNode.isPrepared()) {
|
||||
Fight.getRedTeam().setSchem(checkSchematicNode, NodeData.getRevisions(checkSchematicNode) - 1);
|
||||
}
|
||||
|
||||
new TechareaCommand();
|
||||
} else if (Config.mode == ArenaMode.PREPARE) {
|
||||
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID));
|
||||
}
|
||||
|
||||
@@ -24,35 +24,25 @@ import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Kit;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class AkCommand implements CommandExecutor {
|
||||
public class AkCommand extends FightSWCommand {
|
||||
|
||||
public AkCommand() {
|
||||
new StateDependentCommand(ArenaMode.Test, FightState.All, "ak", this);
|
||||
super(ArenaMode.Test, FightState.All, "ak");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if (!player.isOp()) return false;
|
||||
|
||||
if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.ADMINISTRATION) && Core.getInstance() != FightSystem.getPlugin()) {
|
||||
return false;
|
||||
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||
return player.isOp() && user.hasPerm(UserPerm.ADMINISTRATION) && Core.getInstance() != FightSystem.getPlugin();
|
||||
}
|
||||
|
||||
Kit.createKit(args[0], player);
|
||||
return false;
|
||||
@Register
|
||||
public void run(@Validator Player player, String name) {
|
||||
Kit.createKit(name, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 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.fightsystem.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class FightSWCommand extends SWCommand implements Listener {
|
||||
|
||||
private final String command;
|
||||
private final String[] aliases;
|
||||
|
||||
protected FightSWCommand(Set<ArenaMode> mode, Set<FightState> states, String command) {
|
||||
super(command);
|
||||
this.command = command;
|
||||
this.aliases = new String[0];
|
||||
stateDependant(mode, states);
|
||||
}
|
||||
|
||||
protected FightSWCommand(Set<ArenaMode> mode, Set<FightState> states, String command, String... aliases) {
|
||||
super(command, aliases);
|
||||
this.command = command;
|
||||
this.aliases = aliases;
|
||||
stateDependant(mode, states);
|
||||
}
|
||||
|
||||
private void stateDependant(Set<ArenaMode> mode, Set<FightState> states) {
|
||||
FightSWCommand.this.unregister();
|
||||
new StateDependent(mode, states) {
|
||||
@Override
|
||||
public void enable() {
|
||||
System.out.println("--- Enable: " + command);
|
||||
FightSWCommand.this.register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
System.out.println("--- Disable: " + command);
|
||||
FightSWCommand.this.unregister();
|
||||
}
|
||||
}.register();
|
||||
}
|
||||
|
||||
public static void postFightStateChange() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.updateCommands();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public final void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||
if (hasPerm(event.getPlayer(), SteamwarUser.get(event.getPlayer().getUniqueId()))) return;
|
||||
event.getCommands().remove(command);
|
||||
for (String alias : aliases) {
|
||||
event.getCommands().remove(alias);
|
||||
}
|
||||
}
|
||||
|
||||
@ClassValidator(value = Player.class, local = true)
|
||||
public final TypeValidator<Player> permissionCheck() {
|
||||
return (sender, value, messageSender) -> hasPerm(value, SteamwarUser.get(value.getUniqueId()));
|
||||
}
|
||||
}
|
||||
+10
-74
@@ -19,92 +19,28 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Linked
|
||||
public class GamemodeCommand extends BukkitCommand {
|
||||
|
||||
private static final List<String> GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival",
|
||||
"spectator");
|
||||
public class GamemodeCommand extends FightSWCommand {
|
||||
|
||||
public GamemodeCommand() {
|
||||
super("gamemode");
|
||||
List<String> aliases = new ArrayList<>();
|
||||
aliases.add("gm");
|
||||
this.setAliases(aliases);
|
||||
|
||||
Map<String, Command> knownCommands = ((CraftServer) Bukkit.getServer()).getCommandMap().getKnownCommands();
|
||||
knownCommands.remove("gamemode");
|
||||
Commands.injectCommand(this);
|
||||
super(ArenaMode.TestOrReferee, FightState.All, "gamemode", "gm");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
} else if (args.length == 0) {
|
||||
FightSystem.getMessage().sendPrefixless("GAMEMODE_HELP", sender);
|
||||
return false;
|
||||
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||
return Config.test() || Config.isReferee(player);
|
||||
}
|
||||
|
||||
Player p = (Player) sender;
|
||||
|
||||
if (!(Config.test() || Config.isReferee(p))) {
|
||||
FightSystem.getMessage().sendPrefixless("GAMEMODE_NOT_ALLOWED", p, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
}
|
||||
|
||||
GameMode mode = createMode(args[0]);
|
||||
|
||||
if (mode == null) {
|
||||
FightSystem.getMessage().sendPrefixless("GAMEMODE_UNKNOWN", p, ChatMessageType.ACTION_BAR, args[0]);
|
||||
return false;
|
||||
}
|
||||
|
||||
p.setGameMode(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private GameMode createMode(String modeArg) {
|
||||
try {
|
||||
return GameMode.getByValue(Integer.parseInt(modeArg));
|
||||
} catch (NumberFormatException ignored) {
|
||||
if ((modeArg.equalsIgnoreCase("creative")) || (modeArg.equalsIgnoreCase("c"))) {
|
||||
return GameMode.CREATIVE;
|
||||
} else if ((modeArg.equalsIgnoreCase("adventure")) || (modeArg.equalsIgnoreCase("a"))) {
|
||||
return GameMode.ADVENTURE;
|
||||
} else if ((modeArg.equalsIgnoreCase("spectator")) || (modeArg.equalsIgnoreCase("sp"))) {
|
||||
return GameMode.SPECTATOR;
|
||||
} else if ((modeArg.equalsIgnoreCase("survival")) || (modeArg.equalsIgnoreCase("s"))) {
|
||||
return GameMode.SURVIVAL;
|
||||
@Register(description = "GAMEMODE_HELP")
|
||||
public void execute(@Validator Player player, GameMode gameMode) {
|
||||
player.setGameMode(gameMode);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, new ArrayList<>(GAMEMODE_NAMES.size()));
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,34 +20,31 @@
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.Check;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class InfoCommand implements CommandExecutor {
|
||||
public class InfoCommand extends FightSWCommand {
|
||||
|
||||
public InfoCommand() {
|
||||
new StateDependentCommand(ArenaMode.All, FightState.All, "fightinfo", this);
|
||||
super(ArenaMode.All, FightState.All, "fightinfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) return false;
|
||||
|
||||
Player player = (Player) sender;
|
||||
if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK)) return false;
|
||||
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||
return Check.checkPermission(user, Config.GameModeConfig);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void run(@Validator Player player) {
|
||||
for (FightTeam team : Fight.teams()) {
|
||||
if (!team.isLeaderless()) {
|
||||
FightSystem.getMessage().send("INFO_LEADER", player, team.getColoredName(), team.getLeader().getEntity().getName());
|
||||
@@ -58,6 +55,5 @@ public class InfoCommand implements CommandExecutor {
|
||||
FightSystem.getMessage().send("INFO_SCHEMATIC", player, team.getColoredName(), schematic.getName(), SteamwarUser.byId(schematic.getOwner()).getUserName(), schematic.getRank());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,32 +21,23 @@ package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class KitCommand implements CommandExecutor {
|
||||
public class KitCommand extends FightSWCommand {
|
||||
|
||||
public KitCommand() {
|
||||
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "kit", this);
|
||||
super(ArenaMode.AntiReplay, FightState.Setup, "kit");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (args.length != 1) {
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
GUI.kitSelection(player, "");
|
||||
} else {
|
||||
Commands.kit(player, args[0]);
|
||||
}
|
||||
return false;
|
||||
|
||||
@Register
|
||||
public void execute(Player player, String query) { // TODO: TabCompletion of Kit Names!
|
||||
GUI.kitSelection(player, query);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-14
@@ -21,28 +21,18 @@ package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class LeaveCommand implements CommandExecutor {
|
||||
public class LeaveCommand extends FightSWCommand {
|
||||
|
||||
public LeaveCommand() {
|
||||
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "leave", this);
|
||||
super(ArenaMode.AntiReplay, FightState.Setup, "leave");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
Commands.leaveTeam(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-19
@@ -20,52 +20,42 @@
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.Check;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserPerm;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class LockschemCommand implements CommandExecutor {
|
||||
public class LockschemCommand extends FightSWCommand {
|
||||
|
||||
public LockschemCommand() {
|
||||
new StateDependentCommand(ArenaMode.All, FightState.Schem, "lockschem", this);
|
||||
super(ArenaMode.All, FightState.Schem, "lockschem");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) return false;
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK)) return false;
|
||||
|
||||
if (args.length != 1) {
|
||||
FightSystem.getMessage().sendPrefixless("LOCKSCHEM_HELP", player);
|
||||
return false;
|
||||
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||
return Check.checkPermission(user, Config.GameModeConfig);
|
||||
}
|
||||
|
||||
String teamName = args[0];
|
||||
@Register(description = "LOCKSCHEM_HELP")
|
||||
public void execute(@Validator Player player, String teamName) {
|
||||
FightTeam fightTeam = Fight.getTeamByName(teamName);
|
||||
|
||||
if (fightTeam == null) {
|
||||
FightSystem.getMessage().sendPrefixless("UNKNOWN_TEAM", player, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
SchematicNode.getSchematicNode(fightTeam.getSchematic()).setSchemtype(SchematicType.Normal);
|
||||
FightSystem.getMessage().sendPrefixless("LOCKSCHEM_LOCKED", player, ChatMessageType.ACTION_BAR);
|
||||
fightTeam.broadcastSystem("LOCKSCHEM_LOCKED_BY", player.getName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-14
@@ -21,28 +21,18 @@ package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class ReadyCommand implements CommandExecutor {
|
||||
public class ReadyCommand extends FightSWCommand {
|
||||
|
||||
public ReadyCommand() {
|
||||
new StateDependentCommand(ArenaMode.AntiPrepare, FightState.PostSchemSetup, "ready", this);
|
||||
super(ArenaMode.AntiPrepare, FightState.PostSchemSetup, "ready");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
Commands.toggleReady(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-21
@@ -20,35 +20,19 @@
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class RemoveCommand implements CommandExecutor {
|
||||
public class RemoveCommand extends FightSWCommand {
|
||||
|
||||
public RemoveCommand() {
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "remove", this);
|
||||
super(ArenaMode.VariableTeams, FightState.Setup, "remove");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (args.length != 1) {
|
||||
FightSystem.getMessage().sendPrefixless("REMOVE_HELP", player);
|
||||
return false;
|
||||
}
|
||||
|
||||
Commands.kick(player, args[0]);
|
||||
return false;
|
||||
@Register(description = "REMOVE_HELP")
|
||||
public void execute(Player player, Player teamMember) {
|
||||
Commands.kick(player, teamMember.getName());
|
||||
}
|
||||
}
|
||||
|
||||
+6
-15
@@ -26,37 +26,28 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.fight.JoinRequest;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
@Linked
|
||||
public class RequestsCommand implements CommandExecutor {
|
||||
public class RequestsCommand extends FightSWCommand {
|
||||
|
||||
public RequestsCommand() {
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.AntiSpectate, "request", this);
|
||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.AntiSpectate, "requests", this);
|
||||
super(ArenaMode.VariableTeams, FightState.AntiSpectate, "request", "requests");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) return false;
|
||||
Player player = (Player) sender;
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
FightPlayer fp = Fight.getFightPlayer(player);
|
||||
if (fp == null || !(fp.isLeader() || fp.isLiving())) {
|
||||
GUI.joinRequest(player);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Commands.checkGetLeader(player) == null) return false;
|
||||
|
||||
if (Commands.checkGetLeader(player) == null) return;
|
||||
GUI.chooseJoinRequests(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void onJoinRequest(Player player, JoinRequest request, BiConsumer<JoinRequest, FightTeam> handleJoinRequest) {
|
||||
|
||||
@@ -24,32 +24,22 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.record.PacketProcessor;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class SkipCommand implements CommandExecutor {
|
||||
public class SkipCommand extends FightSWCommand {
|
||||
|
||||
public SkipCommand() {
|
||||
new StateDependentCommand(ArenaMode.AntiPrepare, ArenaMode.Replay.contains(Config.mode) ? FightState.All : FightState.TeamFix, "skip", this);
|
||||
super(ArenaMode.AntiPrepare, ArenaMode.Replay.contains(Config.mode) ? FightState.All : FightState.TeamFix, "skip");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
if (PacketProcessor.isReplaying() && player.getUniqueId().equals(Fight.getBlueTeam().getDesignatedLeader())) {
|
||||
PacketProcessor.currentReplay().skipToSubtitle();
|
||||
} else {
|
||||
Commands.toggleSkip(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-14
@@ -21,27 +21,18 @@ package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class StateCommand implements CommandExecutor {
|
||||
public class StateCommand extends FightSWCommand {
|
||||
|
||||
public StateCommand() {
|
||||
new StateDependentCommand(ArenaMode.Test, FightState.All, "state", this);
|
||||
super(ArenaMode.Test, FightState.All, "state");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GUI.state((Player) sender);
|
||||
return false;
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
GUI.state(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,26 +22,18 @@ package de.steamwar.fightsystem.commands;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class TBCommand implements CommandExecutor {
|
||||
public class TBCommand extends FightSWCommand {
|
||||
|
||||
public TBCommand() {
|
||||
new StateDependentCommand(ArenaMode.Check, FightState.All, "resettb", this);
|
||||
super(ArenaMode.Check, FightState.All, "resettb");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
Fight.getRedTeam().pasteSchem();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-19
@@ -20,34 +20,20 @@ package de.steamwar.fightsystem.commands;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class TPSWarpCommand implements CommandExecutor {
|
||||
public class TPSWarpCommand extends FightSWCommand {
|
||||
|
||||
public TPSWarpCommand() {
|
||||
new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpswarp", this);
|
||||
new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpslimit", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
float tps;
|
||||
try {
|
||||
tps = Float.parseFloat(args[0]);
|
||||
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
|
||||
FightSystem.getMessage().send("TPSWARP_HELP", sender);
|
||||
return false;
|
||||
super(ArenaMode.Prepare, FightState.PostSchemSetup, "tpswarp", "tpslimit");
|
||||
}
|
||||
|
||||
@Register(description = "TPSWARP_HELP")
|
||||
public void execute(Player player, float tps) {
|
||||
MinecraftServer.getServer().tickRateManager().setTickRate(tps);
|
||||
|
||||
FightSystem.getMessage().broadcastActionbar("TPSWARP_SET", tps);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+18
-21
@@ -19,42 +19,39 @@
|
||||
|
||||
package de.steamwar.fightsystem.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.entity.CWireframe;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import org.bukkit.Bukkit;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TechareaCommand extends SWCommand {
|
||||
private final Map<UUID, REntityServer> servers = new HashMap<>();
|
||||
@Linked
|
||||
public class TechareaCommand extends FightSWCommand {
|
||||
private REntityServer entityServer = new REntityServer();
|
||||
|
||||
public TechareaCommand() {
|
||||
super("techarea");
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> servers.forEach((uuid, rEntityServer) -> rEntityServer.tick()), 2, 2);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player player) {
|
||||
if (servers.containsKey(player.getUniqueId())) {
|
||||
servers.get(player.getUniqueId()).close();
|
||||
} else {
|
||||
super(ArenaMode.Check, FightState.All, "techarea");
|
||||
new OneShotStateDependent(ArenaMode.Check, FightState.All, () -> {
|
||||
if (!entityServer.getEntities().isEmpty()) return;
|
||||
REntityServer server = new REntityServer();
|
||||
CWireframe wireframe = new CWireframe(server);
|
||||
|
||||
wireframe.setPos1(Config.BlueInsetRegion.getMinLocation(Config.world));
|
||||
wireframe.setPos2(Config.BlueInsetRegion.getMaxLocation(Config.world).subtract(1, 1, 1));
|
||||
wireframe.setBlock(Material.RED_CONCRETE.createBlockData());
|
||||
});
|
||||
}
|
||||
|
||||
server.addPlayer(player);
|
||||
servers.put(player.getUniqueId(), server);
|
||||
@Register
|
||||
public void genericCommand(Player player) {
|
||||
if (entityServer.getPlayers().contains(player)) {
|
||||
entityServer.removePlayer(player);
|
||||
} else {
|
||||
entityServer.addPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-10
@@ -25,27 +25,24 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.SWException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Linked
|
||||
public class TechhiderbugCommand implements CommandExecutor {
|
||||
public class TechhiderbugCommand extends FightSWCommand {
|
||||
|
||||
public TechhiderbugCommand() {
|
||||
new StateDependentCommand(ArenaMode.All, FightState.All, "techhiderbug", this);
|
||||
super(ArenaMode.All, FightState.All, "techhiderbug");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
@Register
|
||||
public void execute(Player player, String... args) {
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
try {
|
||||
@@ -76,7 +73,6 @@ public class TechhiderbugCommand implements CommandExecutor {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error while generating bug report", e);
|
||||
}
|
||||
|
||||
SWException.log("Techhider-Bug reported by " + sender.getName() + ": " + Arrays.toString(args), writer.toString());
|
||||
return false;
|
||||
SWException.log("Techhider-Bug reported by " + player.getName() + ": " + Arrays.toString(args), writer.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,28 +23,20 @@ import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class WGCommand implements CommandExecutor {
|
||||
public class WGCommand extends FightSWCommand {
|
||||
|
||||
public WGCommand() {
|
||||
new StateDependentCommand(ArenaMode.Check, FightState.All, "resetwg", this);
|
||||
super(ArenaMode.Check, FightState.All, "resetwg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
@Register
|
||||
public void execute(Player player) {
|
||||
FightWorld.resetWorld();
|
||||
Fight.getBlueTeam().pasteSchem();
|
||||
Fight.getRedTeam().pasteSchem();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,49 +25,34 @@ import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class WinCommand implements CommandExecutor {
|
||||
public class WinCommand extends FightSWCommand {
|
||||
|
||||
public WinCommand() {
|
||||
new StateDependentCommand(ArenaMode.Event, FightState.Ingame, "win", this);
|
||||
super(ArenaMode.Event, FightState.Ingame, "win");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
|
||||
if (!Config.isReferee(p)) {
|
||||
FightSystem.getMessage().sendPrefixless("NOT_FIGHTLEADER", p, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||
return Config.isReferee(player);
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
FightSystem.getMessage().sendPrefixless("WIN_HELP", p);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("tie")) {
|
||||
@Register
|
||||
public void execute(@Validator Player player, String teamName) {
|
||||
if (teamName.equalsIgnoreCase("tie")) {
|
||||
FightSystem.setSpectateState(null, "Referee", "WIN_FIGHTLEADER");
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
for (FightTeam team : Fight.teams()) {
|
||||
if (args[0].equalsIgnoreCase(team.getName())) {
|
||||
if (teamName.equalsIgnoreCase(team.getName())) {
|
||||
FightSystem.setSpectateState(team, "Referee", "WIN_FIGHTLEADER");
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,10 +47,14 @@ public class Check implements Listener {
|
||||
|
||||
private boolean checkPermission(SteamwarUser user, SchematicNode schematic) {
|
||||
GameModeConfig<Object, String> gameModeConfig = GameModeConfig.getAll().stream()
|
||||
.filter(gmc -> gmc.Schematic.Type != null && gmc.Schematic.Type.equals(schematic.getSchemtype()))
|
||||
.filter(gmc -> gmc.Schematic.Type != null && gmc.Schematic.Type.checkType() != null && schematic.getSchemtype().name().equals(gmc.Schematic.Type.checkType().name()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (gameModeConfig == null) gameModeConfig = GameModeConfig.getDefaults();
|
||||
return checkPermission(user, gameModeConfig);
|
||||
}
|
||||
|
||||
public static boolean checkPermission(SteamwarUser user, GameModeConfig gameModeConfig) {
|
||||
if (user.hasPerm(UserPerm.ADMINISTRATION)) return true;
|
||||
if (gameModeConfig.Checkers.isEmpty() && user.hasPerm(UserPerm.CHECK)) return true;
|
||||
return gameModeConfig.Checkers.contains(user.getId());
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.states;
|
||||
|
||||
import de.steamwar.fightsystem.commands.FightSWCommand;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.*;
|
||||
@@ -62,6 +63,7 @@ public enum FightState {
|
||||
}
|
||||
|
||||
public static void setFightState(FightState state) {
|
||||
if (fightState.equals(state)) return;
|
||||
fightState = state;
|
||||
|
||||
for (Map.Entry<IStateDependent, Boolean> feature : stateDependentFeatures.entrySet()) {
|
||||
@@ -77,6 +79,7 @@ public enum FightState {
|
||||
feature.setValue(false);
|
||||
}
|
||||
}
|
||||
FightSWCommand.postFightStateChange();
|
||||
}
|
||||
|
||||
public static boolean setup() {
|
||||
|
||||
-58
@@ -1,58 +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.fightsystem.states;
|
||||
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class StateDependentCommand extends StateDependent {
|
||||
|
||||
private static final CommandExecutor unavailable = (sender, cmd, s, strings) -> {
|
||||
FightSystem.getMessage().sendPrefixless("COMMAND_CURRENTLY_UNAVAILABLE", sender, ChatMessageType.ACTION_BAR);
|
||||
return false;
|
||||
};
|
||||
|
||||
private final PluginCommand command;
|
||||
private final CommandExecutor executor;
|
||||
|
||||
public StateDependentCommand(Set<ArenaMode> mode, Set<FightState> states, String name, CommandExecutor executor) {
|
||||
super(mode, states);
|
||||
this.executor = executor;
|
||||
this.command = FightSystem.getPlugin().getCommand(name);
|
||||
assert command != null;
|
||||
disable();
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
command.setExecutor(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
command.setExecutor(unavailable);
|
||||
}
|
||||
}
|
||||
@@ -11,21 +11,3 @@ depend:
|
||||
api-version: "1.13"
|
||||
|
||||
commands:
|
||||
ak:
|
||||
request:
|
||||
requests:
|
||||
fightinfo:
|
||||
leave:
|
||||
ready:
|
||||
kit:
|
||||
remove:
|
||||
lockschem:
|
||||
state:
|
||||
skip:
|
||||
win:
|
||||
resetwg:
|
||||
resettb:
|
||||
tpslimit:
|
||||
tpswarp:
|
||||
techhiderbug:
|
||||
unrank:
|
||||
@@ -53,3 +53,15 @@ tasks.register<FightServer>("WarGear21") {
|
||||
config = "WarGear21.yml"
|
||||
jar = "/jars/paper-1.21.6.jar"
|
||||
}
|
||||
|
||||
tasks.register<FightServer>("WarShip21") {
|
||||
group = "run"
|
||||
description = "Run a WarShip 1.21 Fight Server"
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":FightSystem:shadowJar")
|
||||
dependsOn(":KotlinCore:shadowJar")
|
||||
template = "WarShip21"
|
||||
worldName = "arenas/Artic"
|
||||
config = "WarShip21.yml"
|
||||
jar = "/jars/paper-1.21.6.jar"
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public class CustomItem extends SpecialItem {
|
||||
}
|
||||
for (File itemFile : Objects.requireNonNull(itemsFolder.listFiles())) {
|
||||
if (!itemFile.canRead() || !itemFile.isFile()) continue;
|
||||
if (!itemFile.getName().endsWith(".json")) continue;
|
||||
try {
|
||||
JsonObject jsonObject = new JsonParser().parse(new FileReader(itemFile)).getAsJsonObject();
|
||||
new CustomItem(new ScriptedItem(jsonObject));
|
||||
|
||||
@@ -25,6 +25,7 @@ import de.steamwar.misslewars.scripts.RunnableScriptEvent;
|
||||
import de.steamwar.misslewars.scripts.ScriptedItem;
|
||||
import de.steamwar.misslewars.scripts.utils.EntityUtils;
|
||||
import de.steamwar.misslewars.scripts.utils.EntityUtils.ScriptShortcut;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Projectile;
|
||||
|
||||
public class LaunchScript implements RunnableScript {
|
||||
|
||||
@@ -75,6 +75,11 @@ public class EntityUtils {
|
||||
});
|
||||
case "arrow":
|
||||
return new ScriptShortcut<>(Arrow.class, (jsonObject, entity, runnableScriptEvent) -> setProjectileOptions(entity, jsonObject));
|
||||
case "windcharge":
|
||||
return new ScriptShortcut<>(WindCharge.class, (jsonObject, entity, runnableScriptEvent) -> {
|
||||
setFireballOptions(entity, jsonObject);
|
||||
entity.setDirection(runnableScriptEvent.getLocation().getDirection());
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ AUTO_CHECKER_RESULT_DEFUNCT_NBT = §7Defunct NBT: §7[{0}, {1}, {2}]
|
||||
AUTO_CHECKER_RESULT_DESIGN_BLOCK = §7{0} in Design: [{1}, {2}, {3}]
|
||||
AUTO_CHECKER_RESULT_ENTITY = §7Entity: §7[{0}, {1}, {2}]
|
||||
AUTO_CHECKER_RESULT_RECORD = §7Record: §c[{0}, {1}, {2}]
|
||||
AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS = §7Dispenser: §c[{0}, {1}, {2}]§7, §c{3} §7items, Max: §e{4}
|
||||
AUTO_CHECKER_RESULT_TOO_MANY_INVENTORY_ITEMS = §7{6}: §c[{0}, {1}, {2}]§7, §c{3}x {5}§7, Max: §e{4}
|
||||
AUTO_CHECKER_RESULT_FORBIDDEN_ITEM_NBT = §7Forbidden Item NBT: [{0}, {1}, {2}] -> §c{3}
|
||||
AUTO_CHECKER_RESULT_TELEPORT_HERE = §7Teleport to block
|
||||
AUTO_CHECKER_RESULT_AFTER_DEADLINE = §cThe deadline has expired: {0}
|
||||
|
||||
@@ -248,7 +248,7 @@ AUTO_CHECKER_RESULT_FORBIDDEN_ITEM = §7Verbotener gegenstand: [{0}, {1}, {2}] -
|
||||
AUTO_CHECKER_RESULT_DEFUNCT_NBT = §7Keine NBT-Daten: §c[{0}, {1}, {2}]
|
||||
AUTO_CHECKER_RESULT_DESIGN_BLOCK = §7{0} im Design: [{1}, {2}, {3}]
|
||||
AUTO_CHECKER_RESULT_RECORD = §7Schallplatte: §c[{0}, {1}, {2}]
|
||||
AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS = §7Dispenser: §c[{0}, {1}, {2}]§7, §c{3} §7gegenstände, Max: §e{4}
|
||||
AUTO_CHECKER_RESULT_TOO_MANY_INVENTORY_ITEMS = §7{6}: §c[{0}, {1}, {2}]§7, §c{3}x {5}§7, Max: §e{4}
|
||||
AUTO_CHECKER_RESULT_FORBIDDEN_ITEM_NBT = §7Verbotene NBT-Daten: [{0}, {1}, {2}] -> §c{3}
|
||||
AUTO_CHECKER_RESULT_TELEPORT_HERE = §7Zum block teleportieren
|
||||
AUTO_CHECKER_RESULT_AFTER_DEADLINE = §cDer einsendeschluss ist bereits vorbei: {0}
|
||||
|
||||
@@ -75,9 +75,9 @@ public class AutoChecker {
|
||||
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
if (AutoCheckerItems.impl.getInventoryMaterials().contains(material)) {
|
||||
if (type.Schematic.isInventory(material)) {
|
||||
checkInventory(result, block, material, pos, type);
|
||||
if (result.getDispenserItems().getOrDefault(pos, 0) > 0) {
|
||||
if (!result.getInventoryItemCounts().getOrDefault(pos, Collections.emptyMap()).isEmpty()) {
|
||||
result.getBlockCounts().merge(material, 1, Integer::sum);
|
||||
}
|
||||
} else {
|
||||
@@ -93,19 +93,6 @@ public class AutoChecker {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final Map<Material, Set<Material>> itemsInInv = new EnumMap<>(Material.class);
|
||||
|
||||
static {
|
||||
itemsInInv.put(Material.BUCKET, EnumSet.of(Material.DISPENSER));
|
||||
itemsInInv.put(Material.TNT, EnumSet.of(Material.CHEST, Material.BARREL, Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX,
|
||||
Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX,
|
||||
Material.LIGHT_GRAY_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.ORANGE_SHULKER_BOX,
|
||||
Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX));
|
||||
itemsInInv.put(Material.FIRE_CHARGE, EnumSet.of(Material.DISPENSER));
|
||||
itemsInInv.put(Material.ARROW, EnumSet.of(Material.DISPENSER));
|
||||
AutoCheckerItems.impl.getAllowedMaterialsInInventory().forEach(material -> itemsInInv.put(material, AutoCheckerItems.impl.getInventoryMaterials()));
|
||||
}
|
||||
|
||||
private void checkInventory(AutoChecker.BlockScanResult result, BaseBlock block, Material material, BlockPos pos, GameModeConfig<Material, String> type) {
|
||||
CompoundTag nbt = block.getNbtData();
|
||||
if (nbt == null) {
|
||||
@@ -122,7 +109,7 @@ public class AutoChecker {
|
||||
List<CompoundTag> items = nbt.getList("Items", CompoundTag.class);
|
||||
if (items.isEmpty()) return; // Leeres Inventar
|
||||
|
||||
int counter = 0;
|
||||
Map<Material, Integer> itemCounts = new EnumMap<>(Material.class);
|
||||
int windChargeCount = 0;
|
||||
for (CompoundTag item : items) {
|
||||
if (!item.containsKey("id")) {
|
||||
@@ -136,16 +123,19 @@ public class AutoChecker {
|
||||
|
||||
if (type.Schematic.Type.getName().equals("wargearseason26") && material == Material.DISPENSER && itemType == Material.WIND_CHARGE) {
|
||||
windChargeCount += item.getInt("count");
|
||||
} else if (!itemsInInv.getOrDefault(itemType, EnumSet.noneOf(Material.class)).contains(material)) {
|
||||
} else if (type.Schematic.getItemAmount(material, itemType) == 0) {
|
||||
result.getForbiddenItems().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType);
|
||||
} else if (material == Material.DISPENSER && (itemType == Material.ARROW || itemType == Material.FIRE_CHARGE)) {
|
||||
counter += item.getInt("count");
|
||||
} else {
|
||||
itemCounts.merge(itemType, item.getInt("count"), Integer::sum);
|
||||
}
|
||||
if (item.containsKey("tag")) {
|
||||
result.getForbiddenNbt().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType);
|
||||
}
|
||||
}
|
||||
result.getDispenserItems().put(pos, counter);
|
||||
if (!itemCounts.isEmpty()) {
|
||||
result.getInventoryItemCounts().put(pos, itemCounts);
|
||||
result.getInventoryBlockType().put(pos, material);
|
||||
}
|
||||
result.getWindChargeCount().put(pos, windChargeCount);
|
||||
}
|
||||
|
||||
@@ -156,7 +146,8 @@ public class AutoChecker {
|
||||
private final List<BlockPos> defunctNbt = new ArrayList<>();
|
||||
private final List<BlockPos> records = new ArrayList<>();
|
||||
private final Map<Material, List<BlockPos>> designBlocks = new EnumMap<>(Material.class);
|
||||
private final Map<BlockPos, Integer> dispenserItems = new HashMap<>();
|
||||
private final Map<BlockPos, Map<Material, Integer>> inventoryItemCounts = new HashMap<>();
|
||||
private final Map<BlockPos, Material> inventoryBlockType = new HashMap<>();
|
||||
private final Map<BlockPos, Integer> windChargeCount = new HashMap<>();
|
||||
private final Map<BlockPos, Set<Material>> forbiddenItems = new HashMap<>();
|
||||
private final Map<BlockPos, Set<Material>> forbiddenNbt = new HashMap<>();
|
||||
|
||||
@@ -1,51 +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.autocheck;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class AutoCheckerItems {
|
||||
|
||||
public static final AutoCheckerItems impl = new AutoCheckerItems();
|
||||
|
||||
private static final Set<Material> INVENTORY = EnumSet.of(Material.BARREL, Material.BLAST_FURNACE, Material.BREWING_STAND, Material.CAMPFIRE,
|
||||
Material.CHEST, Material.DISPENSER, Material.DROPPER, Material.FURNACE, Material.HOPPER, Material.JUKEBOX, Material.SHULKER_BOX,
|
||||
Material.WHITE_SHULKER_BOX, Material.ORANGE_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX,
|
||||
Material.LIME_SHULKER_BOX, Material.PINK_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.LIGHT_GRAY_SHULKER_BOX, Material.CYAN_SHULKER_BOX,
|
||||
Material.PURPLE_SHULKER_BOX, Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.RED_SHULKER_BOX,
|
||||
Material.BLACK_SHULKER_BOX, Material.SMOKER, Material.TRAPPED_CHEST);
|
||||
|
||||
private static final Set<Material> FLOWERS = EnumSet.of(Material.CORNFLOWER, Material.POPPY, Material.FERN, Material.DANDELION, Material.BLUE_ORCHID,
|
||||
Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY,
|
||||
Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SUNFLOWER, Material.DIAMOND_HORSE_ARMOR, Material.IRON_HORSE_ARMOR,
|
||||
Material.GOLDEN_HORSE_ARMOR, Material.LEATHER_HORSE_ARMOR, Material.HONEY_BOTTLE, Material.LILAC, Material.ROSE_BUSH, Material.PEONY,
|
||||
Material.TALL_GRASS, Material.LARGE_FERN);
|
||||
|
||||
public Set<Material> getInventoryMaterials() {
|
||||
return INVENTORY;
|
||||
}
|
||||
|
||||
public Set<Material> getAllowedMaterialsInInventory() {
|
||||
return FLOWERS;
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class AutoCheckerResult {
|
||||
isSizeOk() &&
|
||||
isBlockCountOk() &&
|
||||
isLimitedBlocksOK() &&
|
||||
isDispenserItemsOK() &&
|
||||
isInventoryItemsOK() &&
|
||||
isWindchargeCountOK() &&
|
||||
!type.isAfterDeadline() &&
|
||||
entities.isEmpty() &&
|
||||
@@ -71,8 +71,14 @@ public class AutoCheckerResult {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDispenserItemsOK() {
|
||||
return blockScanResult.getDispenserItems().values().stream().allMatch(i -> i <= type.Schematic.MaxDispenserItems);
|
||||
public boolean isInventoryItemsOK() {
|
||||
return blockScanResult.getInventoryItemCounts().entrySet().stream().allMatch(posEntry -> {
|
||||
Material inventory = blockScanResult.getInventoryBlockType().get(posEntry.getKey());
|
||||
return posEntry.getValue().entrySet().stream().allMatch(itemEntry -> {
|
||||
int cap = type.Schematic.getItemAmount(inventory, itemEntry.getKey());
|
||||
return itemEntry.getValue() <= cap;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public boolean hasWarnings() {
|
||||
@@ -100,13 +106,8 @@ public class AutoCheckerResult {
|
||||
}
|
||||
|
||||
public boolean isLimitedBlocksOK() {
|
||||
try {
|
||||
return type.Schematic.Limited.entrySet().stream()
|
||||
.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);
|
||||
} catch (NullPointerException e) {
|
||||
return false;
|
||||
}
|
||||
return blockScanResult.getBlockCounts().entrySet().stream()
|
||||
.allMatch(entry -> entry.getValue() <= type.Schematic.getMaxCount(entry.getKey()));
|
||||
}
|
||||
|
||||
public boolean isDesignBlastResistanceOK() {
|
||||
@@ -130,14 +131,13 @@ public class AutoCheckerResult {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_BLOCKS", p, blockScanResult.getBlockCounts().values().stream().reduce(Integer::sum).orElse(0), type.Schematic.MaxBlocks);
|
||||
}
|
||||
if (!isLimitedBlocksOK()) {
|
||||
type.Schematic.Limited.forEach((materials, integer) -> {
|
||||
for (Material mat : materials) {
|
||||
if (mat != null && blockScanResult.getBlockCounts().getOrDefault(mat, 0) > integer) {
|
||||
if (integer == 0) {
|
||||
blockScanResult.getBlockCounts().forEach((mat, count) -> {
|
||||
int maxCount = type.Schematic.getMaxCount(mat);
|
||||
if (count > maxCount) {
|
||||
if (maxCount == 0) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK", p, mat.name());
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_TOO_MANY_BLOCK", p, mat.name(), blockScanResult.getBlockCounts().getOrDefault(mat, 0), integer);
|
||||
}
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_TOO_MANY_BLOCK", p, mat.name(), count, maxCount);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -155,13 +155,20 @@ public class AutoCheckerResult {
|
||||
});
|
||||
}
|
||||
|
||||
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()),
|
||||
blockVector3IntegerEntry.getKey().getBlockX(),
|
||||
blockVector3IntegerEntry.getKey().getBlockY(),
|
||||
blockVector3IntegerEntry.getKey().getBlockZ(),
|
||||
blockVector3IntegerEntry.getValue(),
|
||||
type.Schematic.MaxDispenserItems);
|
||||
blockScanResult.getInventoryItemCounts().forEach((pos, itemCounts) -> {
|
||||
Material inventory = blockScanResult.getInventoryBlockType().get(pos);
|
||||
itemCounts.forEach((itemType, count) -> {
|
||||
int cap = type.Schematic.getItemAmount(inventory, itemType);
|
||||
if (count <= cap) return;
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_TOO_MANY_INVENTORY_ITEMS", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(pos),
|
||||
pos.getBlockX(),
|
||||
pos.getBlockY(),
|
||||
pos.getBlockZ(),
|
||||
count,
|
||||
cap,
|
||||
itemType.name(),
|
||||
inventory.name());
|
||||
});
|
||||
});
|
||||
|
||||
blockScanResult.getRecords().forEach(blockVector3 -> {
|
||||
|
||||
+14
-10
@@ -197,27 +197,31 @@ public class SchematicCommand extends SWCommand {
|
||||
clipboard.setBlock(vector, block.toBaseBlock(builder.build()));
|
||||
}
|
||||
|
||||
if (type.Schematic.MaxDispenserItems > 0) {
|
||||
for (Map.Entry<BlockPos, Integer> entry : result.getBlockScanResult().getDispenserItems().entrySet()) {
|
||||
if (entry.getValue() <= type.Schematic.MaxDispenserItems) {
|
||||
for (Map.Entry<BlockPos, Map<Material, Integer>> posEntry : result.getBlockScanResult().getInventoryItemCounts().entrySet()) {
|
||||
BlockPos pos = posEntry.getKey();
|
||||
Material inventory = result.getBlockScanResult().getInventoryBlockType().get(pos);
|
||||
|
||||
for (Map.Entry<Material, Integer> itemEntry : posEntry.getValue().entrySet()) {
|
||||
Material itemType = itemEntry.getKey();
|
||||
Integer cap = type.Schematic.getItemAmount(inventory, itemType);
|
||||
if (itemEntry.getValue() <= cap) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockPos pos = entry.getKey();
|
||||
BlockVector3 vector = BlockVector3.at(pos.getX(), pos.getY(), pos.getZ());
|
||||
BaseBlock block = clipboard.getFullBlock(vector);
|
||||
CompoundTag tag = block.getNbtData();
|
||||
CompoundTagBuilder builder = tag.createBuilder();
|
||||
List<CompoundTag> items = new ArrayList<>(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 inventory
|
||||
List<CompoundTag> list = new ArrayList<>();
|
||||
int diff = entry.getValue() - type.Schematic.MaxDispenserItems;
|
||||
int diff = itemEntry.getValue() - cap;
|
||||
for (CompoundTag item : items) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (diff == 0) {
|
||||
if (diff == 0 || Material.matchMaterial(item.getString("id")) != itemType) {
|
||||
list.add(item);
|
||||
continue;
|
||||
}
|
||||
@@ -238,9 +242,9 @@ public class SchematicCommand extends SWCommand {
|
||||
}
|
||||
|
||||
if (!result.isLimitedBlocksOK()) {
|
||||
Set<Material> toReplace = type.Schematic.Limited.entrySet().stream()
|
||||
.filter(setIntegerEntry -> setIntegerEntry.getValue() == 0)
|
||||
.flatMap(setIntegerEntry -> setIntegerEntry.getKey().stream())
|
||||
Set<Material> toReplace = type.Schematic.Limited.stream()
|
||||
.filter(rule -> rule.Amount == 0)
|
||||
.flatMap(rule -> rule.Materials.stream())
|
||||
.collect(Collectors.toSet());
|
||||
BlockState replaceType = Objects.requireNonNull(toReplace.contains(Material.END_STONE) ? BlockTypes.IRON_BLOCK : BlockTypes.END_STONE).getDefaultState();
|
||||
BlockVector3 min = clipboard.getMinimumPoint();
|
||||
|
||||
@@ -28,7 +28,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SQLWrapperImpl implements SQLWrapper<Material> {
|
||||
@@ -52,6 +55,45 @@ public class SQLWrapperImpl implements SQLWrapper<Material> {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage-type inventory materials (chests, barrels, shulker boxes of any color).
|
||||
*/
|
||||
private static final Set<Material> STORAGE_MATERIALS = Collections.unmodifiableSet(EnumSet.of(
|
||||
Material.CHEST, Material.TRAPPED_CHEST, Material.BARREL, Material.SHULKER_BOX,
|
||||
Material.WHITE_SHULKER_BOX, Material.ORANGE_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX,
|
||||
Material.YELLOW_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.PINK_SHULKER_BOX, Material.GRAY_SHULKER_BOX,
|
||||
Material.LIGHT_GRAY_SHULKER_BOX, Material.CYAN_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.BLUE_SHULKER_BOX,
|
||||
Material.BROWN_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.BLACK_SHULKER_BOX
|
||||
));
|
||||
|
||||
/**
|
||||
* Every inventory material - {@link #STORAGE_MATERIALS} plus the "functional" containers that
|
||||
* are not storage (dispenser, dropper, hopper, the furnace family, brewing stand, campfire,
|
||||
* jukebox). Built on top of {@link #STORAGE_MATERIALS} so anything added there is automatically
|
||||
* included here.
|
||||
*/
|
||||
private static final Set<Material> INVENTORY_MATERIALS;
|
||||
|
||||
static {
|
||||
Set<Material> materials = EnumSet.copyOf(STORAGE_MATERIALS);
|
||||
materials.addAll(EnumSet.of(
|
||||
Material.DISPENSER, Material.DROPPER, Material.HOPPER,
|
||||
Material.FURNACE, Material.BLAST_FURNACE, Material.SMOKER,
|
||||
Material.BREWING_STAND, Material.CAMPFIRE, Material.JUKEBOX
|
||||
));
|
||||
INVENTORY_MATERIALS = Collections.unmodifiableSet(materials);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Material> getStorageMaterials() {
|
||||
return STORAGE_MATERIALS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Material> getInventoryMaterials() {
|
||||
return INVENTORY_MATERIALS;
|
||||
}
|
||||
|
||||
private static final String SERVER_VERSION = Bukkit.getServer().getVersion();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.velocitypowered.api.event.player.KickedFromServerEvent;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.api.permission.Tristate;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.util.ServerLink;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.messages.Chatter;
|
||||
import de.steamwar.messages.Message;
|
||||
@@ -45,9 +46,7 @@ import de.steamwar.velocitycore.mods.ModUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Linked
|
||||
@@ -79,9 +78,27 @@ public class ConnectionListener extends BasicListener {
|
||||
});
|
||||
}
|
||||
|
||||
private static final List<ServerLink> SERVER_LINKS = getServerLinks();
|
||||
|
||||
private static List<ServerLink> getServerLinks() {
|
||||
List<ServerLink> serverLinks = new ArrayList<>();
|
||||
serverLinks.add(ServerLink.serverLink(ServerLink.Type.BUG_REPORT, "https://git.steamwar.de/SteamWar/SteamWar/issues/new"));
|
||||
serverLinks.add(ServerLink.serverLink(ServerLink.Type.COMMUNITY_GUIDELINES, "https://steamwar.de/verhaltensrichtlinien/"));
|
||||
serverLinks.add(ServerLink.serverLink(ServerLink.Type.SUPPORT, "https://discord.com/channels/690530484920385586/870028487455571999"));
|
||||
serverLinks.add(ServerLink.serverLink(ServerLink.Type.COMMUNITY, "https://steamwar.de/discord"));
|
||||
serverLinks.add(ServerLink.serverLink(ServerLink.Type.WEBSITE, "https://steamwar.de/"));
|
||||
serverLinks.add(ServerLink.serverLink(ServerLink.Type.NEWS, "https://discord.com/channels/690530484920385586/690535200865910794"));
|
||||
serverLinks.add(ServerLink.serverLink(ServerLink.Type.ANNOUNCEMENTS, "https://discord.com/channels/690530484920385586/690535200865910794"));
|
||||
return serverLinks;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.getProtocolVersion().noLessThan(ProtocolVersion.MINECRAFT_1_21)) {
|
||||
player.setServerLinks(SERVER_LINKS);
|
||||
}
|
||||
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Chatter chatter = Chatter.of(player);
|
||||
CheckCommand.sendReminder(chatter);
|
||||
|
||||
@@ -21,6 +21,12 @@ import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import java.net.URI
|
||||
import java.util.*
|
||||
|
||||
pluginManagement {
|
||||
plugins {
|
||||
kotlin("plugin.lombok") version "2.3.20"
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "SteamWar"
|
||||
|
||||
private val isInCi by lazy { Os.isFamily(Os.FAMILY_UNIX) && ProcessBuilder("hostname").start().inputStream.bufferedReader().readText().startsWith("steamwar.de") }
|
||||
|
||||
Reference in New Issue
Block a user