forked from SteamWar/SteamWar
Fix pull Request comment
This commit is contained in:
@@ -488,6 +488,27 @@ public final class GameModeConfig<M, W> {
|
||||
*/
|
||||
public final boolean NoFloor;
|
||||
|
||||
/**
|
||||
* Allows Wind Charges to cross the Middle.
|
||||
*
|
||||
* @implSpec {@code false} by default
|
||||
*/
|
||||
public final boolean WindchargesCanCrossMiddle;
|
||||
|
||||
/**
|
||||
* Allows Wind Charge interaction with Blocks.
|
||||
*
|
||||
* @implSpec {@code true} by default
|
||||
*/
|
||||
public final boolean WindchargesInteractWithBlocks;
|
||||
|
||||
/**
|
||||
* Allows Wind Charge to destroy Water.
|
||||
*
|
||||
* @implSpec {@code false} by default
|
||||
*/
|
||||
public final boolean WindchargesDestroyWater;
|
||||
|
||||
private ArenaConfig(YMLWrapper<M, W> loader, SchematicConfig.SizeConfig Size, List<Integer> EnterStages) {
|
||||
loaded = loader.canLoad();
|
||||
WaterDepth = loader.getInt("WaterDepth", 0);
|
||||
@@ -505,6 +526,9 @@ public final class GameModeConfig<M, W> {
|
||||
Leaveable = loader.getBoolean("Leaveable", false);
|
||||
AllowMissiles = loader.getBoolean("AllowMissiles", !EnterStages.isEmpty());
|
||||
NoFloor = loader.getBoolean("NoFloor", false);
|
||||
WindchargesCanCrossMiddle = loader.getBoolean("WindchargesCanCrossMiddle", false);
|
||||
WindchargesInteractWithBlocks = loader.getBoolean("WindchargesInteractWithBlocks", true);
|
||||
WindchargesDestroyWater = loader.getBoolean("WindchargesDestroyWater", false);
|
||||
}
|
||||
|
||||
@ToString
|
||||
|
||||
@@ -64,8 +64,10 @@ Arena:
|
||||
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
|
||||
windchargesCanCrossMiddle: false # defaults to false if missing
|
||||
windchargesInteractWithBlocks: false # defaults to false if missing
|
||||
# Allows Wind Charges to cross the Middle.
|
||||
WindchargesCanCrossMiddle: false # defaults to false if missing
|
||||
# Allows Wind Charge interaction with Blocks.
|
||||
WindchargesInteractWithBlocks: false # defaults to false if missing
|
||||
|
||||
Schematic:
|
||||
# The size of the schematics
|
||||
|
||||
@@ -64,9 +64,6 @@ public class Config {
|
||||
private static final int BlueToRedY;
|
||||
public static final int BlueToRedZ;
|
||||
|
||||
public static final boolean WindchargesCanCrossMiddle;
|
||||
public static final boolean WindchargesInteractWithBlocks;
|
||||
|
||||
//schematic parameter
|
||||
public static final boolean OnlyPublicSchematics;
|
||||
|
||||
@@ -105,8 +102,6 @@ public class Config {
|
||||
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
||||
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
|
||||
ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
|
||||
WindchargesCanCrossMiddle = Boolean.getBoolean(System.getProperty("windchargesCanCrossMiddle", "false"));
|
||||
WindchargesInteractWithBlocks = Boolean.getBoolean(System.getProperty("windchargesInteractWithBlocks", "false"));
|
||||
|
||||
String configFile = System.getProperty("config", "config.yml");
|
||||
if (!new File(FightSystem.getPlugin().getDataFolder(), configFile).exists()) {
|
||||
|
||||
@@ -72,7 +72,9 @@ public class WaterRemover implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handleEntityExplode(EntityExplodeEvent event) {
|
||||
if (event.getEntityType() != EntityType.TNT) return;
|
||||
if (event.getEntityType() == EntityType.WIND_CHARGE && !Config.GameModeConfig.Arena.WindchargesDestroyWater) {
|
||||
return;
|
||||
}
|
||||
event.setYield(0); //No drops (additionally to world config)
|
||||
|
||||
FightTeam spawn = tnt.remove(event.getEntity().getEntityId());
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* 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.listener;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class Windcharge implements Listener {
|
||||
|
||||
private static final int middleLine = Config.SpecSpawn.getBlockZ();
|
||||
|
||||
private final Set<Entity> windcharges = new HashSet<>();
|
||||
|
||||
public Windcharge() {
|
||||
new StateDependentListener(true, FightState.Running, this);
|
||||
new StateDependentTask(true, FightState.Running, this::run, 1, 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleEntityExplode(EntityExplodeEvent event) {
|
||||
if (event.getEntityType() != EntityType.WIND_CHARGE) return;
|
||||
if (!Config.WindchargesInteractWithBlocks) {
|
||||
event.blockList().clear();
|
||||
}
|
||||
if (!Config.WindchargesCanCrossMiddle) {
|
||||
windcharges.remove(event.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleEntitySpawnEvent(EntitySpawnEvent event) {
|
||||
if (event.getEntityType() != EntityType.WIND_CHARGE) return;
|
||||
if (!Config.WindchargesCanCrossMiddle) {
|
||||
windcharges.add(event.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (!Config.WindchargesCanCrossMiddle) {
|
||||
windcharges.forEach(entity -> {
|
||||
Location nextlocation = entity.getLocation().add(entity.getVelocity());
|
||||
Location location = entity.getLocation();
|
||||
|
||||
boolean passedMiddle = nextlocation.getBlockZ() >= middleLine && location.getBlockZ() <= middleLine ||
|
||||
nextlocation.getBlockZ() <= middleLine && location.getBlockZ() >= middleLine;
|
||||
|
||||
if (passedMiddle) {
|
||||
windcharges.remove(entity);
|
||||
entity.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.listener;
|
||||
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
@Linked
|
||||
public class WindchargeInteractionDisabler implements Listener {
|
||||
|
||||
public WindchargeInteractionDisabler() {
|
||||
new StateDependentListener(!Config.GameModeConfig.Arena.WindchargesInteractWithBlocks, FightState.Running, this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void handleEntityExplode(EntityExplodeEvent event) {
|
||||
if (event.getEntityType() != EntityType.WIND_CHARGE) return;
|
||||
event.blockList().clear();
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -23,14 +23,14 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.world.entity.projectile.windcharge.WindCharge;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.WindCharge;
|
||||
|
||||
@Linked
|
||||
public class WindchargeStopper {
|
||||
|
||||
public WindchargeStopper() {
|
||||
new StateDependentTask(true, FightState.Running, this::run, 1, 1);
|
||||
new StateDependentTask(!Config.GameModeConfig.Arena.WindchargesCanCrossMiddle, FightState.Running, this::run, 1, 1);
|
||||
}
|
||||
|
||||
private static final int middleLine = Config.SpecSpawn.getBlockZ();
|
||||
@@ -39,13 +39,13 @@ public class WindchargeStopper {
|
||||
|
||||
private void run() {
|
||||
Recording.iterateOverEntities(windChargeClass::isInstance, entity -> {
|
||||
Location nextlocation = entity.getLocation().add(entity.getVelocity());
|
||||
Location location = entity.getLocation();
|
||||
Location prevLocation = location.clone().subtract(entity.getVelocity());
|
||||
|
||||
boolean passedMiddle = location.getBlockZ() > middleLine && prevLocation.getBlockZ() > middleLine ||
|
||||
location.getBlockZ() < middleLine && prevLocation.getBlockZ() < middleLine;
|
||||
boolean passedMiddle = nextlocation.getBlockZ() >= middleLine && location.getBlockZ() <= middleLine ||
|
||||
nextlocation.getBlockZ() <= middleLine && location.getBlockZ() >= middleLine;
|
||||
|
||||
if (!passedMiddle) {
|
||||
if (passedMiddle) {
|
||||
entity.remove();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user