forked from SteamWar/SteamWar
Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a07067725f | ||
|
|
264e541fc7 | ||
|
|
82a59f772e | ||
|
|
2c44e50846 | ||
|
|
f51bce6a69 | ||
|
|
bf26dfed56 | ||
|
|
395303d04f | ||
|
|
b466216b3a | ||
|
|
5a862b251b | ||
|
|
60a82a685d | ||
|
|
573b0c14ae | ||
|
|
82abe7e20f | ||
|
|
34da59714e | ||
|
|
97071165cd | ||
|
|
634465fbf1 |
@@ -440,6 +440,13 @@ public final class GameModeConfig<M, W> {
|
|||||||
*/
|
*/
|
||||||
public final boolean DisableSnowMelt;
|
public final boolean DisableSnowMelt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable ice forming
|
||||||
|
*
|
||||||
|
* @implSpec {@code false} by default
|
||||||
|
*/
|
||||||
|
public final boolean DisableIceForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow leaving the arena area as spectator
|
* Allow leaving the arena area as spectator
|
||||||
*
|
*
|
||||||
@@ -470,6 +477,7 @@ public final class GameModeConfig<M, W> {
|
|||||||
BorderFromSchematic = loader.getInt("BorderFromSchematic", 21);
|
BorderFromSchematic = loader.getInt("BorderFromSchematic", 21);
|
||||||
GroundWalkable = loader.getBoolean("GroundWalkable", true);
|
GroundWalkable = loader.getBoolean("GroundWalkable", true);
|
||||||
DisableSnowMelt = loader.getBoolean("DisableSnowMelt", false);
|
DisableSnowMelt = loader.getBoolean("DisableSnowMelt", false);
|
||||||
|
DisableIceForm = loader.getBoolean("DisableIceForm", false);
|
||||||
Leaveable = loader.getBoolean("Leaveable", false);
|
Leaveable = loader.getBoolean("Leaveable", false);
|
||||||
AllowMissiles = loader.getBoolean("AllowMissiles", !EnterStages.isEmpty());
|
AllowMissiles = loader.getBoolean("AllowMissiles", !EnterStages.isEmpty());
|
||||||
NoFloor = loader.getBoolean("NoFloor", false);
|
NoFloor = loader.getBoolean("NoFloor", false);
|
||||||
|
|||||||
@@ -254,27 +254,12 @@ class SteamwarUser(id: EntityID<Int>): IntEntity(id) {
|
|||||||
punishments[punishment] = Punishment.createPunishment(this@SteamwarUser.id.value, from, punishment, reason, time, perma)
|
punishments[punishment] = Punishment.createPunishment(this@SteamwarUser.id.value, from, punishment, reason, time, perma)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setJoinLocale(locale: Locale?) {
|
fun setLocale(locale: Locale?, manualeLocale: Boolean) {
|
||||||
if (locale == null || this.manualLocale) return
|
if (locale == null || (this.manualLocale && !manualLocale)) return
|
||||||
setCurrentLocale(locale)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setCurrentLocale(locale: Locale?) {
|
|
||||||
if (locale == null) return
|
|
||||||
useDb {
|
useDb {
|
||||||
this@SteamwarUser.locale = locale
|
this@SteamwarUser.locale = locale
|
||||||
}
|
this@SteamwarUser.manualLocale = manualeLocale
|
||||||
}
|
|
||||||
|
|
||||||
fun lockLocale() {
|
|
||||||
useDb {
|
|
||||||
this@SteamwarUser.manualLocale = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun unlockLocale() {
|
|
||||||
useDb {
|
|
||||||
this@SteamwarUser.manualLocale = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ object TeamTable : IntIdTable("Team", "TeamID") {
|
|||||||
|
|
||||||
class Team(id: EntityID<Int>) : IntEntity(id) {
|
class Team(id: EntityID<Int>) : IntEntity(id) {
|
||||||
companion object : IntEntityClass<Team>(TeamTable) {
|
companion object : IntEntityClass<Team>(TeamTable) {
|
||||||
const val PUBLIC: Int = 0
|
|
||||||
|
|
||||||
private val teamCache = mutableMapOf<Int, Team>()
|
private val teamCache = mutableMapOf<Int, Team>()
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|||||||
@@ -33,9 +33,6 @@ import de.steamwar.fightsystem.states.FightState;
|
|||||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.fightsystem.utils.*;
|
import de.steamwar.fightsystem.utils.*;
|
||||||
import de.steamwar.fightsystem.winconditions.Wincondition;
|
|
||||||
import de.steamwar.fightsystem.winconditions.WinconditionComparisonTimeout;
|
|
||||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
|
||||||
import de.steamwar.linkage.AbstractLinker;
|
import de.steamwar.linkage.AbstractLinker;
|
||||||
import de.steamwar.linkage.SpigotLinker;
|
import de.steamwar.linkage.SpigotLinker;
|
||||||
import de.steamwar.message.Message;
|
import de.steamwar.message.Message;
|
||||||
@@ -43,6 +40,7 @@ import de.steamwar.sql.NodeData;
|
|||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameRule;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class FightSystem extends JavaPlugin {
|
public class FightSystem extends JavaPlugin {
|
||||||
@@ -100,6 +98,11 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
|
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
|
||||||
new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
|
new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
|
||||||
new OneShotStateDependent(ArenaMode.Test, FightState.All, WorldEditRendererCUIEditor::new);
|
new OneShotStateDependent(ArenaMode.Test, FightState.All, WorldEditRendererCUIEditor::new);
|
||||||
|
try {
|
||||||
|
Bukkit.getWorlds().get(0).setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(Config.mode));
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Ignore if failed!
|
||||||
|
}
|
||||||
|
|
||||||
techHider = new TechHiderWrapper();
|
techHider = new TechHiderWrapper();
|
||||||
hullHider = new HullHider();
|
hullHider = new HullHider();
|
||||||
|
|||||||
@@ -23,14 +23,12 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.fight.JoinRequest;
|
import de.steamwar.fightsystem.fight.JoinRequest;
|
||||||
import de.steamwar.fightsystem.listener.Chat;
|
import de.steamwar.fightsystem.listener.Chat;
|
||||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
import de.steamwar.fightsystem.utils.Region;
|
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -54,7 +52,6 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.entity.Villager;
|
import org.bukkit.entity.Villager;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -87,6 +84,8 @@ public abstract class AI {
|
|||||||
private final BukkitTask task;
|
private final BukkitTask task;
|
||||||
private final Queue<Action> queue = new ArrayDeque<>();
|
private final Queue<Action> queue = new ArrayDeque<>();
|
||||||
|
|
||||||
|
protected final NavMesh navMesh;
|
||||||
|
|
||||||
protected AI(FightTeam team, SteamwarUser user) {
|
protected AI(FightTeam team, SteamwarUser user) {
|
||||||
this.team = team;
|
this.team = team;
|
||||||
|
|
||||||
@@ -98,6 +97,8 @@ public abstract class AI {
|
|||||||
ais.put(entity.getUniqueId(), this);
|
ais.put(entity.getUniqueId(), this);
|
||||||
team.addMember(entity, user);
|
team.addMember(entity, user);
|
||||||
|
|
||||||
|
navMesh = new NavMesh(team);
|
||||||
|
|
||||||
if(FightState.Schem.contains(FightState.getFightState()))
|
if(FightState.Schem.contains(FightState.getFightState()))
|
||||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> schematic(team.getClipboard()));
|
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> schematic(team.getClipboard()));
|
||||||
}
|
}
|
||||||
@@ -134,58 +135,61 @@ public abstract class AI {
|
|||||||
Chat.broadcastChat("PARTICIPANT_CHAT", team.getColoredName(), entity.getName(), message);
|
Chat.broadcastChat("PARTICIPANT_CHAT", team.getColoredName(), entity.getName(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getPosition() {
|
public LocalCoordinate getPosition() {
|
||||||
Location location = entity.getLocation();
|
return WorldCoordinate.from(entity.getLocation()).toLocal(team);
|
||||||
Region extend = team.getExtendRegion();
|
|
||||||
if(Fight.getUnrotated() == team)
|
|
||||||
return new Vector(
|
|
||||||
location.getX() - extend.getMinX(),
|
|
||||||
location.getY() - team.getSchemRegion().getMinY(),
|
|
||||||
location.getZ() - extend.getMinZ()
|
|
||||||
);
|
|
||||||
else
|
|
||||||
return new Vector(
|
|
||||||
extend.getMaxX() - location.getX(),
|
|
||||||
location.getY() - team.getSchemRegion().getMinY(),
|
|
||||||
extend.getMaxZ() - location.getZ()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Material getBlock(Vector pos) {
|
public Material getBlock(WorldCoordinate pos) {
|
||||||
|
return getBlock(pos.toLocal(team));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getBlock(LocalCoordinate pos) {
|
||||||
queue.add(new Action(1));
|
queue.add(new Action(1));
|
||||||
return translate(pos).getBlock().getType();
|
return pos.toWorld(team).toLocation(Config.world).getBlock().getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData getBlockData(Vector pos) {
|
public BlockData getBlockData(WorldCoordinate pos) {
|
||||||
|
return getBlockData(pos.toLocal(team));
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockData getBlockData(LocalCoordinate pos) {
|
||||||
queue.add(new Action(1));
|
queue.add(new Action(1));
|
||||||
return translate(pos).getBlock().getBlockData();
|
return pos.toWorld(team).toLocation(Config.world).getBlock().getBlockData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTNT(Vector pos) {
|
public void setTNT(WorldCoordinate pos) {
|
||||||
|
setTNT(pos.toLocal(team));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTNT(LocalCoordinate pos) {
|
||||||
queue.add(new Action(1) {
|
queue.add(new Action(1) {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(FightState.getFightState() != FightState.RUNNING)
|
if(FightState.getFightState() != FightState.RUNNING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Location location = translate(pos);
|
Location location = pos.toWorld(team).toLocation(Config.world);
|
||||||
if(interactionDistanceViolation(location)) {
|
if(interactionDistanceViolation(location)) {
|
||||||
chat("InteractionDistanceViolation: setTNT");
|
chat("InteractionDistanceViolation: setTNT");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
if(block.getType() == Material.AIR)
|
if(block.getType() == Material.AIR || block.getType() == Material.WATER || block.getType() == Material.LAVA || block.getType() == Material.TNT)
|
||||||
block.setType(Material.TNT);
|
block.setType(Material.TNT);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void interact(Vector pos) {
|
public void interact(WorldCoordinate pos) {
|
||||||
|
interact(pos.toLocal(team));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void interact(LocalCoordinate pos) {
|
||||||
queue.add(new Action(1) {
|
queue.add(new Action(1) {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Location location = translate(pos);
|
Location location = pos.toWorld(team).toLocation(Config.world);
|
||||||
if(interactionDistanceViolation(location)) {
|
if(interactionDistanceViolation(location)) {
|
||||||
chat("InteractionDistanceViolation: interact");
|
chat("InteractionDistanceViolation: interact");
|
||||||
return;
|
return;
|
||||||
@@ -196,11 +200,15 @@ public abstract class AI {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void interact(Vector pos, int n) {
|
public void interact(WorldCoordinate pos, int n) {
|
||||||
|
interact(pos.toLocal(team), n);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void interact(LocalCoordinate pos, int n) {
|
||||||
queue.add(new Action(1) {
|
queue.add(new Action(1) {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Location location = translate(pos);
|
Location location = pos.toWorld(team).toLocation(Config.world);
|
||||||
if (interactionDistanceViolation(location))
|
if (interactionDistanceViolation(location))
|
||||||
return;
|
return;
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
@@ -217,39 +225,75 @@ public abstract class AI {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void move(Vector pos) {
|
public MoveResult checkMove(WorldCoordinate target) {
|
||||||
|
Location location = entity.getLocation();
|
||||||
|
if(!entity.isOnGround() && location.getBlock().getType() != Material.LADDER) {
|
||||||
|
return MoveResult.FALLING;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Math.abs(location.getX() - target.getX()) > 1.5 || Math.abs(location.getY() - target.getY()) > 1.5 || Math.abs(location.getZ() - target.getZ()) > 1.5) {
|
||||||
|
return MoveResult.OVERDISTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!team.getFightPlayer(entity).canEntern() && !team.getExtendRegion().inRegion(target.toLocation(null)))
|
||||||
|
return MoveResult.OUT_OF_BORDER;
|
||||||
|
return MoveResult.OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum MoveResult {
|
||||||
|
FALLING,
|
||||||
|
OVERDISTANCE,
|
||||||
|
OUT_OF_BORDER,
|
||||||
|
OK,
|
||||||
|
}
|
||||||
|
|
||||||
|
public void move(WorldCoordinate pos) {
|
||||||
queue.add(new Action(MOVEMENT_DELAY) {
|
queue.add(new Action(MOVEMENT_DELAY) {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Location location = entity.getLocation();
|
MoveResult moveResult = checkMove(pos);
|
||||||
if(!entity.isOnGround() && location.getBlock().getType() != Material.LADDER) {
|
switch (moveResult) {
|
||||||
|
case FALLING:
|
||||||
FightSystem.getPlugin().getLogger().log(Level.INFO, "Entity falling");
|
FightSystem.getPlugin().getLogger().log(Level.INFO, "Entity falling");
|
||||||
return;
|
return;
|
||||||
|
case OVERDISTANCE:
|
||||||
|
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + ": Overdistance movement " + entity.getLocation().toVector() + " " + pos);
|
||||||
|
return;
|
||||||
|
case OUT_OF_BORDER:
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location target = translate(pos);
|
Location currentLocation = entity.getLocation();
|
||||||
if(Math.abs(location.getX() - target.getX()) > 1.0 || Math.abs(location.getY() - target.getY()) > 1.5 || Math.abs(location.getZ() - target.getZ()) > 1.0) {
|
Location target = pos.toLocation(Config.world);
|
||||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + ": Overdistance movement " + location.toVector() + " " + target.toVector());
|
if (currentLocation.getBlockX() != target.getBlockX() || currentLocation.getBlockY() != target.getBlockY() || currentLocation.getBlockZ() != target.getBlockZ()) {
|
||||||
return;
|
target.setDirection(target.toVector().subtract(currentLocation.toVector()));
|
||||||
|
}
|
||||||
|
if (currentLocation.getBlockX() == target.getBlockX() && currentLocation.getBlockZ() == target.getBlockZ()) {
|
||||||
|
target.setYaw(currentLocation.getYaw());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!team.getFightPlayer(entity).canEntern() && !team.getExtendRegion().inRegion(target))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(!entity.teleport(target, PlayerTeleportEvent.TeleportCause.PLUGIN))
|
if(!entity.teleport(target, PlayerTeleportEvent.TeleportCause.PLUGIN))
|
||||||
FightSystem.getPlugin().getLogger().log(Level.INFO, "Entity not teleported: " + entity.isValid());
|
FightSystem.getPlugin().getLogger().log(Level.INFO, "Entity not teleported: " + entity.isValid());
|
||||||
|
|
||||||
GlobalRecorder.getInstance().entityMoves(entity);
|
GlobalRecorder.getInstance().entityMoves(entity);
|
||||||
|
navMesh.update(getPosition().toWorld(team));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void move(LocalCoordinate pos) {
|
||||||
|
move(pos.toWorld(team));
|
||||||
|
}
|
||||||
|
|
||||||
private boolean interactionDistanceViolation(Location location) {
|
private boolean interactionDistanceViolation(Location location) {
|
||||||
return location.distance(entity.getEyeLocation()) > INTERACTION_RANGE;
|
return location.distance(entity.getEyeLocation()) > INTERACTION_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void interact(Block block) {
|
private void interact(Block block) {
|
||||||
BlockData data = block.getBlockData(); //TODO only 1.14+ compatible at the moment
|
BlockData data = block.getBlockData(); //TODO only 1.14+ compatible at the moment
|
||||||
|
System.out.println(block + " " + data);
|
||||||
if (data instanceof NoteBlock) {
|
if (data instanceof NoteBlock) {
|
||||||
NoteBlock noteBlock = (NoteBlock) data;
|
NoteBlock noteBlock = (NoteBlock) data;
|
||||||
Note note = noteBlock.getNote();
|
Note note = noteBlock.getNote();
|
||||||
@@ -280,6 +324,7 @@ public abstract class AI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
powerable.setPowered(!isPowered);
|
powerable.setPowered(!isPowered);
|
||||||
|
System.out.println(powerable);
|
||||||
}
|
}
|
||||||
block.setBlockData(data);
|
block.setBlockData(data);
|
||||||
if(data instanceof Switch) {
|
if(data instanceof Switch) {
|
||||||
@@ -319,24 +364,6 @@ public abstract class AI {
|
|||||||
queue.poll().run();
|
queue.poll().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location translate(Vector pos) {
|
|
||||||
Region extend = team.getExtendRegion();
|
|
||||||
if(Fight.getUnrotated() == team)
|
|
||||||
return new Location(
|
|
||||||
Config.world,
|
|
||||||
pos.getX() + extend.getMinX(),
|
|
||||||
pos.getY() + team.getSchemRegion().getMinY(),
|
|
||||||
pos.getZ() + extend.getMinZ()
|
|
||||||
);
|
|
||||||
else
|
|
||||||
return new Location(
|
|
||||||
Config.world,
|
|
||||||
extend.getMaxX() - pos.getX(),
|
|
||||||
pos.getY() + team.getSchemRegion().getMinY(),
|
|
||||||
extend.getMaxZ() - pos.getZ()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Action {
|
private static class Action {
|
||||||
private int delay;
|
private int delay;
|
||||||
public Action(int delay) {
|
public Action(int delay) {
|
||||||
|
|||||||
@@ -20,8 +20,10 @@
|
|||||||
package de.steamwar.fightsystem.ai;
|
package de.steamwar.fightsystem.ai;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import de.steamwar.Reflection;
|
||||||
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.ai.yoyonow.YoyoNowAI;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -35,7 +37,8 @@ import java.util.stream.Collectors;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class AIManager {
|
public class AIManager {
|
||||||
private static final List<AIManager> AIs = Arrays.asList(
|
private static final List<AIManager> AIs = Arrays.asList(
|
||||||
new AIManager(DummyAI.class, Material.STONE, () -> ArenaMode.Test.contains(Config.mode))
|
new AIManager(DummyAI.class, Material.STONE, () -> ArenaMode.Test.contains(Config.mode)),
|
||||||
|
new AIManager(YoyoNowAI.class, Material.SLIME_BLOCK, () -> Config.GameModeConfig.Schematic.Type.toDB().equals("miniwargear") && Core.getVersion() >= 14)
|
||||||
);
|
);
|
||||||
|
|
||||||
public static List<AIManager> availableAIs() {
|
public static List<AIManager> availableAIs() {
|
||||||
|
|||||||
@@ -0,0 +1,180 @@
|
|||||||
|
/*
|
||||||
|
* 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.ai;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ai.schematic.Cannon;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface Action {
|
||||||
|
|
||||||
|
Result step(AI ai);
|
||||||
|
|
||||||
|
enum Result {
|
||||||
|
ONGOING,
|
||||||
|
FINISHED,
|
||||||
|
FAILED,
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MultiAction implements Action {
|
||||||
|
|
||||||
|
protected final List<Action> actions = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result step(AI ai) {
|
||||||
|
if (!actions.isEmpty()) {
|
||||||
|
Action.Result result = actions.get(0).step(ai);
|
||||||
|
if (result == Action.Result.FAILED) {
|
||||||
|
ai.chat(this + " + " + actions.get(0) + " failed");
|
||||||
|
actions.clear();
|
||||||
|
return Result.FAILED;
|
||||||
|
}
|
||||||
|
if (result == Action.Result.FINISHED) {
|
||||||
|
ai.chat(this + " + " + actions.get(0) + " finished");
|
||||||
|
actions.remove(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return actions.isEmpty() ? Result.FINISHED : Result.ONGOING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class WaitAction implements Action {
|
||||||
|
|
||||||
|
private int delay;
|
||||||
|
|
||||||
|
public WaitAction(int delay) {
|
||||||
|
this.delay = delay;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result step(AI ai) {
|
||||||
|
if (--delay > 0) {
|
||||||
|
return Result.ONGOING;
|
||||||
|
} else {
|
||||||
|
return Result.FINISHED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MoveAction implements Action {
|
||||||
|
|
||||||
|
private final WorldCoordinate destination;
|
||||||
|
private List<WorldCoordinate> path;
|
||||||
|
private int overDistanceCounter = 0;
|
||||||
|
|
||||||
|
public MoveAction(AI ai, LocalCoordinate destination) {
|
||||||
|
this(ai, destination.toWorld(ai.team));
|
||||||
|
}
|
||||||
|
|
||||||
|
public MoveAction(AI ai, WorldCoordinate destination) {
|
||||||
|
this.destination = destination;
|
||||||
|
this.path = ai.navMesh.pathToNearest(ai.getPosition().toWorld(ai.team), destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result step(AI ai) {
|
||||||
|
if (this.path.isEmpty()) return Result.FAILED;
|
||||||
|
WorldCoordinate coordinate = path.get(0);
|
||||||
|
|
||||||
|
if (!ai.navMesh.isWalkable(coordinate)) {
|
||||||
|
path = ai.navMesh.pathToNearest(ai.getPosition().toWorld(ai.team), destination);
|
||||||
|
if (path.isEmpty()) return Result.FAILED;
|
||||||
|
coordinate = path.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
AI.MoveResult moveResult = ai.checkMove(coordinate);
|
||||||
|
if (moveResult == AI.MoveResult.OVERDISTANCE) {
|
||||||
|
if (overDistanceCounter == 5) {
|
||||||
|
path = ai.navMesh.pathToNearest(ai.getPosition().toWorld(ai.team), destination);
|
||||||
|
return path.isEmpty() ? Result.FAILED : Result.ONGOING;
|
||||||
|
}
|
||||||
|
if (overDistanceCounter++ > 5) {
|
||||||
|
return Result.FAILED;
|
||||||
|
}
|
||||||
|
return Result.ONGOING;
|
||||||
|
}
|
||||||
|
overDistanceCounter = 0;
|
||||||
|
|
||||||
|
if (moveResult == AI.MoveResult.FALLING) {
|
||||||
|
return Result.ONGOING;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (moveResult == AI.MoveResult.OK) {
|
||||||
|
path.remove(0);
|
||||||
|
ai.move(coordinate);
|
||||||
|
}
|
||||||
|
return path.isEmpty() ? Result.FINISHED : Result.ONGOING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class InteractAction implements Action {
|
||||||
|
private final LocalCoordinate destination;
|
||||||
|
|
||||||
|
public InteractAction(LocalCoordinate destination) {
|
||||||
|
this.destination = destination;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result step(AI ai) {
|
||||||
|
ai.interact(destination);
|
||||||
|
return Result.FINISHED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ReadyAction implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result step(AI ai) {
|
||||||
|
ai.setReady();
|
||||||
|
return Result.FINISHED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PlaceTNTAction implements Action {
|
||||||
|
|
||||||
|
private final LocalCoordinate destination;
|
||||||
|
|
||||||
|
public PlaceTNTAction(LocalCoordinate destination) {
|
||||||
|
this.destination = destination;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result step(AI ai) {
|
||||||
|
ai.setTNT(destination);
|
||||||
|
return Result.FINISHED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class LoadCannon extends MultiAction {
|
||||||
|
|
||||||
|
public LoadCannon(AI ai, Cannon cannon) {
|
||||||
|
for (LocalCoordinate tntPosition : cannon.getTntPositions()) {
|
||||||
|
actions.add(new MoveAction(ai, tntPosition.toWorld(ai.team)));
|
||||||
|
actions.add(new PlaceTNTAction(tntPosition));
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalCoordinate trigger = cannon.getTriggerPositions().iterator().next();
|
||||||
|
actions.add(new MoveAction(ai, trigger.toWorld(ai.team)));
|
||||||
|
actions.add(new InteractAction(trigger));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* 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.ai;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.util.NumberConversions;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class LocalCoordinate {
|
||||||
|
private double x;
|
||||||
|
private double y;
|
||||||
|
private double z;
|
||||||
|
|
||||||
|
public int getBlockX() {
|
||||||
|
return NumberConversions.floor(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBlockY() {
|
||||||
|
return NumberConversions.floor(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBlockZ() {
|
||||||
|
return NumberConversions.floor(z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double distanceSquared(LocalCoordinate coordinate) {
|
||||||
|
return NumberConversions.square(x - coordinate.x) + NumberConversions.square(y - coordinate.y) + NumberConversions.square(z - coordinate.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldCoordinate toWorld(FightTeam team) {
|
||||||
|
// TODO: Fix the of by one blue/red
|
||||||
|
// Team Red is not correct!
|
||||||
|
// NightTown is team blue unrotated!
|
||||||
|
Region extend = team.getExtendRegion();
|
||||||
|
if(Fight.getUnrotated() == team) {
|
||||||
|
return new WorldCoordinate(
|
||||||
|
x + extend.getMinX(),
|
||||||
|
y + team.getSchemRegion().getMinY(),
|
||||||
|
z + extend.getMinZ()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return new WorldCoordinate(
|
||||||
|
extend.getMaxX() - x - 1,
|
||||||
|
y + team.getSchemRegion().getMinY(),
|
||||||
|
extend.getMaxZ() - z - 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalCoordinate add(LocalCoordinate localCoordinate) {
|
||||||
|
this.x += localCoordinate.x;
|
||||||
|
this.y += localCoordinate.y;
|
||||||
|
this.z += localCoordinate.z;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalCoordinate add(double x, double y, double z) {
|
||||||
|
this.x += x;
|
||||||
|
this.y += y;
|
||||||
|
this.z += z;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Local{" + x + "," + y + "," + z + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,402 @@
|
|||||||
|
/*
|
||||||
|
* 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.ai;
|
||||||
|
|
||||||
|
import de.steamwar.entity.RBlockDisplay;
|
||||||
|
import de.steamwar.entity.REntity;
|
||||||
|
import de.steamwar.entity.REntityServer;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.util.BoundingBox;
|
||||||
|
import org.bukkit.util.NumberConversions;
|
||||||
|
import org.bukkit.util.Transformation;
|
||||||
|
import org.bukkit.util.VoxelShape;
|
||||||
|
import org.joml.AxisAngle4f;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class NavMesh {
|
||||||
|
|
||||||
|
private static final double PLAYER_FALL_DISTANCE = 3;
|
||||||
|
private static final double PLAYER_JUMP_HEIGHT = 1.25;
|
||||||
|
private static final double PLAYER_HEIGHT = 1.8;
|
||||||
|
private static final Cuboid PLAYER_SHADOW = new Cuboid(0.2, 0, 0.2, 0.6, 1, 0.6);
|
||||||
|
|
||||||
|
private static final Set<Pos> RELATIVE_BLOCKS = new HashSet<>();
|
||||||
|
protected static final BlockData PATH_BLOCK = Material.LIME_STAINED_GLASS.createBlockData();
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (int y = (int) -Math.ceil(PLAYER_FALL_DISTANCE); y <= Math.ceil(PLAYER_JUMP_HEIGHT); y++) {
|
||||||
|
RELATIVE_BLOCKS.add(new Pos(-1, y, 0));
|
||||||
|
RELATIVE_BLOCKS.add(new Pos(1, y, 0));
|
||||||
|
RELATIVE_BLOCKS.add(new Pos(0, y, -1));
|
||||||
|
RELATIVE_BLOCKS.add(new Pos(0, y, 1));
|
||||||
|
}
|
||||||
|
RELATIVE_BLOCKS.add(new Pos(0, 1, 0));
|
||||||
|
RELATIVE_BLOCKS.add(new Pos(0, -1, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
private FightTeam fightTeam;
|
||||||
|
private REntityServer server = new REntityServer();
|
||||||
|
|
||||||
|
private Map<Pos, Pos> walkable = new HashMap<>();
|
||||||
|
private Map<Pos, Set<Pos>> connections = new HashMap<>(); // Reverse connections!
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private boolean ready = false;
|
||||||
|
|
||||||
|
public NavMesh(FightTeam fightTeam) {
|
||||||
|
this.fightTeam = fightTeam;
|
||||||
|
|
||||||
|
new OneShotStateDependent(ArenaMode.All, FightState.PostSchemSetup, () -> {
|
||||||
|
Bukkit.getOnlinePlayers().forEach(server::addPlayer);
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
fightTeam.getExtendRegion().forEach((x, y, z) -> {
|
||||||
|
if (y < fightTeam.getSchemRegion().getMinY()) return;
|
||||||
|
calculatePosition(new Pos(x, y, z), walkable);
|
||||||
|
});
|
||||||
|
|
||||||
|
walkable.values().forEach(this::checkNeighbouring);
|
||||||
|
|
||||||
|
System.out.println("NavMesh initialized in " + (System.currentTimeMillis() - time) + " ms");
|
||||||
|
ready = true;
|
||||||
|
}, 20);
|
||||||
|
});
|
||||||
|
new OneShotStateDependent(ArenaMode.All, FightState.Spectate, () -> {
|
||||||
|
ready = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculatePosition(Pos pos, Map<Pos, Pos> walkable) {
|
||||||
|
Block block = Config.world.getBlockAt(pos.x, pos.y, pos.z);
|
||||||
|
// Air is not walkable
|
||||||
|
if (block.isPassable()) return;
|
||||||
|
|
||||||
|
// Ignore Ladders from floor calculation!
|
||||||
|
if (block.getType() != Material.LADDER) {
|
||||||
|
// Floor Position
|
||||||
|
pos.floor = playerCollisionMax(block.getCollisionShape());
|
||||||
|
// If no walkable block remove
|
||||||
|
if (pos.floor == 0) return;
|
||||||
|
} else {
|
||||||
|
pos.floor = 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ceiling Position
|
||||||
|
pos.ceiling = fightTeam.getExtendRegion().getMaxY() - pos.y;
|
||||||
|
for (int y = pos.y + 1; y <= fightTeam.getExtendRegion().getMaxY() + 3; y++) {
|
||||||
|
block = Config.world.getBlockAt(pos.x, y, pos.z);
|
||||||
|
if (block.isPassable()) continue;
|
||||||
|
double min = playerCollisionMin(block.getCollisionShape());
|
||||||
|
if (min >= 1.0) continue;
|
||||||
|
pos.ceiling = y + min - pos.y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// If player cannot fit remove
|
||||||
|
if (pos.ceiling - pos.floor < PLAYER_HEIGHT) return;
|
||||||
|
|
||||||
|
walkable.put(pos, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
private static class Pos {
|
||||||
|
private final int x;
|
||||||
|
private final int y;
|
||||||
|
private final int z;
|
||||||
|
private double floor = 0;
|
||||||
|
private double ceiling = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return x + "," + y + "(" + floor + ".." + ceiling + ")" + "," + z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (!(o instanceof Pos)) return false;
|
||||||
|
Pos pos = (Pos) o;
|
||||||
|
return x == pos.x && y == pos.y && z == pos.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pos add(Pos pos) {
|
||||||
|
return new Pos(x + pos.x, y + pos.y, z + pos.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldCoordinate toWorld() {
|
||||||
|
return new WorldCoordinate(x, y + floor, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double floorPosition() {
|
||||||
|
return y + floor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double ceilingPosition() {
|
||||||
|
return y + ceiling;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double playerCollisionMax(VoxelShape voxelShape) {
|
||||||
|
List<Double> yList = voxelShape.getBoundingBoxes().stream()
|
||||||
|
.flatMap(boundingBox -> Stream.of(boundingBox.getMinY(), boundingBox.getMaxY()))
|
||||||
|
.sorted()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
double collisionY = 0;
|
||||||
|
for (double y : yList) {
|
||||||
|
if (voxelShape.getBoundingBoxes()
|
||||||
|
.stream()
|
||||||
|
.noneMatch(boundingBox -> collides(y, boundingBox))) {
|
||||||
|
collisionY = y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return collisionY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double playerCollisionMin(VoxelShape voxelShape) {
|
||||||
|
List<Double> yList = voxelShape.getBoundingBoxes().stream()
|
||||||
|
.flatMap(boundingBox -> Stream.of(boundingBox.getMinY(), boundingBox.getMaxY()))
|
||||||
|
.sorted(Comparator.reverseOrder())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
double collisionY = 1.5;
|
||||||
|
for (double y : yList) {
|
||||||
|
if (voxelShape.getBoundingBoxes()
|
||||||
|
.stream()
|
||||||
|
.noneMatch(boundingBox -> collides(y - 1, boundingBox))) {
|
||||||
|
collisionY = y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return collisionY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean collides(double y, BoundingBox boundingBox) {
|
||||||
|
Cuboid second = new Cuboid(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getWidthX(), boundingBox.getHeight(), boundingBox.getWidthZ());
|
||||||
|
return PLAYER_SHADOW.setY(y).intersects(second);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
private static class Cuboid {
|
||||||
|
private double x;
|
||||||
|
private double y;
|
||||||
|
private double z;
|
||||||
|
private double dx;
|
||||||
|
private double dy;
|
||||||
|
private double dz;
|
||||||
|
|
||||||
|
public boolean intersects(Cuboid cuboid) {
|
||||||
|
double minx = x - cuboid.dx;
|
||||||
|
double miny = y - cuboid.dy;
|
||||||
|
double minz = z - cuboid.dz;
|
||||||
|
double maxx = minx + dx + cuboid.dx;
|
||||||
|
double maxy = miny + dy + cuboid.dy;
|
||||||
|
double maxz = minz + dz + cuboid.dz;
|
||||||
|
return maxx > cuboid.x && maxy > cuboid.y && maxz > cuboid.z && minx < cuboid.x && miny < cuboid.y && minz < cuboid.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cuboid setY(double y) {
|
||||||
|
return new Cuboid(x, y, z, dx, dy, dz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(WorldCoordinate coordinate) {
|
||||||
|
final int px = coordinate.getBlockX();
|
||||||
|
final int py = coordinate.getBlockY();
|
||||||
|
final int pz = coordinate.getBlockZ();
|
||||||
|
|
||||||
|
for (int x = -2; x <= 2; x++) {
|
||||||
|
for (int z = -2; z <= 2; z++) {
|
||||||
|
for (int y = fightTeam.getSchemRegion().getMinY(); y <= py + 2; y++) {
|
||||||
|
Pos current = new Pos(px + x, y, pz + z);
|
||||||
|
walkable.remove(current);
|
||||||
|
calculatePosition(current, walkable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
walkable.values().forEach(this::checkNeighbouring);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkNeighbouring(Pos pos) {
|
||||||
|
for (Set<Pos> value : connections.values()) {
|
||||||
|
value.remove(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Pos relative : RELATIVE_BLOCKS) {
|
||||||
|
Pos other = walkable.get(pos.add(relative));
|
||||||
|
if (other == null) continue;
|
||||||
|
|
||||||
|
Block thisBlock = Config.world.getBlockAt(pos.x, pos.y, pos.z);
|
||||||
|
Block otherBlock = Config.world.getBlockAt(other.x, other.y, other.z);
|
||||||
|
|
||||||
|
if (thisBlock.getType() != Material.LADDER && otherBlock.getType() == Material.LADDER) {
|
||||||
|
if ((relative.x != 0 || relative.z != 0) && pos.y != other.y) continue;
|
||||||
|
} else {
|
||||||
|
// Check if jumpable vertical distance
|
||||||
|
if (other.floorPosition() - pos.floorPosition() > PLAYER_JUMP_HEIGHT) continue;
|
||||||
|
// Check if Ceiling is high enough for player walking down!
|
||||||
|
if (other.ceilingPosition() < pos.floorPosition() + PLAYER_HEIGHT) continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
connections.computeIfAbsent(other, __ -> new LinkedHashSet<>()).add(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Pos toPos(WorldCoordinate coordinate) {
|
||||||
|
Pos pos = new Pos(coordinate.getBlockX(), coordinate.getBlockY(), coordinate.getBlockZ());
|
||||||
|
if (walkable.containsKey(pos)) return walkable.get(pos);
|
||||||
|
pos = new Pos(pos.x, pos.y - 1, pos.z);
|
||||||
|
if (walkable.containsKey(pos)) return walkable.get(pos);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWalkable(WorldCoordinate coordinate) {
|
||||||
|
Pos pos = new Pos(coordinate.getBlockX(), NumberConversions.floor(coordinate.getY() - 0.0625), coordinate.getBlockZ());
|
||||||
|
return walkable.containsKey(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WorldCoordinate> walkable() {
|
||||||
|
return walkable.values().stream().map(Pos::toWorld).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WorldCoordinate> pathToNearest(WorldCoordinate fromCoordinate, WorldCoordinate toCoordinate) {
|
||||||
|
Pos to = toPos(toCoordinate);
|
||||||
|
if (walkable.containsKey(to)) return path(toPos(fromCoordinate), to);
|
||||||
|
|
||||||
|
Pos closestTo = walkable.values()
|
||||||
|
.stream()
|
||||||
|
.filter(pos -> {
|
||||||
|
double distance = pos.toWorld().distanceSquared(toCoordinate);
|
||||||
|
return distance < AI.INTERACTION_RANGE * AI.INTERACTION_RANGE && distance > 1.5 * 1.5;
|
||||||
|
})
|
||||||
|
.min(Comparator.comparing(pos -> pos.toWorld().distanceSquared(toCoordinate)))
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (closestTo == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return path(toPos(fromCoordinate), closestTo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WorldCoordinate> path(WorldCoordinate fromCoordinate, WorldCoordinate toCoordinate) {
|
||||||
|
Pos from = toPos(fromCoordinate);
|
||||||
|
Pos to = toPos(toCoordinate);
|
||||||
|
return path(from, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<WorldCoordinate> path(Pos from, Pos to) {
|
||||||
|
server.getEntities().forEach(REntity::die);
|
||||||
|
|
||||||
|
if (from == null || to == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
if (from.equals(to)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Pos> checking = new ArrayList<>(Arrays.asList(to));
|
||||||
|
Map<Pos, Pos> route = new HashMap<>();
|
||||||
|
while (!checking.isEmpty()) {
|
||||||
|
Set<Pos> toCheck = new HashSet<>();
|
||||||
|
for (Pos pos : checking) {
|
||||||
|
boolean foundFrom = false;
|
||||||
|
Set<Pos> successors = connections.get(pos);
|
||||||
|
if (successors == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
for (Pos p : successors) {
|
||||||
|
if (route.containsKey(p)) continue;
|
||||||
|
route.put(p, pos);
|
||||||
|
toCheck.add(p);
|
||||||
|
foundFrom = p.equals(from);
|
||||||
|
if (foundFrom) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundFrom) {
|
||||||
|
List<Pos> path = new ArrayList<>();
|
||||||
|
path.add(from);
|
||||||
|
|
||||||
|
while (path.get(path.size() - 1) != to) {
|
||||||
|
path.add(route.get(path.get(path.size() - 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < path.size(); i++) {
|
||||||
|
path.set(i, walkable.get(path.get(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while (i < path.size() - 1) {
|
||||||
|
Pos current = path.get(i);
|
||||||
|
Pos next = path.get(i + 1);
|
||||||
|
|
||||||
|
if (current.floorPosition() > next.floorPosition() + 1) {
|
||||||
|
Pos between = new Pos(next.x, current.y, next.z);
|
||||||
|
between.floor = current.floor;
|
||||||
|
path.add(i + 1, between);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<WorldCoordinate> coordinates = path.stream().skip(1).map(Pos::toWorld).collect(Collectors.toList());
|
||||||
|
coordinates.forEach(coordinate -> {
|
||||||
|
RBlockDisplay block = new RBlockDisplay(server, coordinate.toLocation(Config.world));
|
||||||
|
block.setBlock(PATH_BLOCK);
|
||||||
|
block.setTransform(new Transformation(new Vector3f(0, 0, 0), new AxisAngle4f(0, 0, 0, 0), new Vector3f(1, 0.001F, 1), new AxisAngle4f(0, 0, 0, 0)));
|
||||||
|
});
|
||||||
|
|
||||||
|
coordinates.forEach(vector -> vector.add(0.5, 0, 0.5));
|
||||||
|
return coordinates;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checking.clear();
|
||||||
|
checking.addAll(toCheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* 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.ai;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.utils.Region;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.util.NumberConversions;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class WorldCoordinate {
|
||||||
|
private double x;
|
||||||
|
private double y;
|
||||||
|
private double z;
|
||||||
|
|
||||||
|
public static WorldCoordinate from(Location location) {
|
||||||
|
return new WorldCoordinate(location.getX(), location.getY(), location.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WorldCoordinate from(Vector vector) {
|
||||||
|
return new WorldCoordinate(vector.getX(), vector.getY(), vector.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBlockX() {
|
||||||
|
return NumberConversions.floor(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBlockY() {
|
||||||
|
return NumberConversions.floor(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBlockZ() {
|
||||||
|
return NumberConversions.floor(z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double distanceSquared(WorldCoordinate coordinate) {
|
||||||
|
return NumberConversions.square(x - coordinate.x) + NumberConversions.square(y - coordinate.y) + NumberConversions.square(z - coordinate.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalCoordinate toLocal(FightTeam team) {
|
||||||
|
// TODO: Fix the of by one blue/red
|
||||||
|
Region extend = team.getExtendRegion();
|
||||||
|
if (Fight.getUnrotated() == team) {
|
||||||
|
return new LocalCoordinate(
|
||||||
|
x - extend.getMinX(),
|
||||||
|
y - team.getSchemRegion().getMinY(),
|
||||||
|
z - extend.getMinZ()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return new LocalCoordinate(
|
||||||
|
extend.getMaxX() - x + 1,
|
||||||
|
y - team.getSchemRegion().getMinY(),
|
||||||
|
extend.getMaxZ() - z + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldCoordinate add(WorldCoordinate worldCoordinate) {
|
||||||
|
this.x += worldCoordinate.x;
|
||||||
|
this.y += worldCoordinate.y;
|
||||||
|
this.z += worldCoordinate.z;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldCoordinate add(double x, double y, double z) {
|
||||||
|
this.x += x;
|
||||||
|
this.y += y;
|
||||||
|
this.z += z;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector toVector() {
|
||||||
|
return new Vector(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location toLocation(World world) {
|
||||||
|
return new Location(world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "World{" + x + "," + y + "," + z + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* 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.ai.schematic;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ai.LocalCoordinate;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class Bridge {
|
||||||
|
|
||||||
|
private final Set<LocalCoordinate> shieldActivators = new HashSet<>();
|
||||||
|
private LocalCoordinate automaticActivator = null;
|
||||||
|
private int automaticActivatorTime = 0;
|
||||||
|
|
||||||
|
public Bridge addShieldActivator(LocalCoordinate shieldActivator) {
|
||||||
|
this.shieldActivators.add(shieldActivator);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bridge addAutomaticActivator(LocalCoordinate automaticActivator, int automaticActivatorTime) {
|
||||||
|
this.automaticActivator = automaticActivator;
|
||||||
|
this.automaticActivatorTime = automaticActivatorTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* 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.ai.schematic;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ai.LocalCoordinate;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class Cannon {
|
||||||
|
|
||||||
|
private final List<LocalCoordinate> tntPositions = new ArrayList<>();
|
||||||
|
private final Set<LocalCoordinate> triggerPositions = new HashSet<>();
|
||||||
|
|
||||||
|
public Cannon addTnt(LocalCoordinate tnt) {
|
||||||
|
tntPositions.add(tnt);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cannon addTrigger(LocalCoordinate trigger) {
|
||||||
|
triggerPositions.add(trigger);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* 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.ai.schematic;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ai.LocalCoordinate;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.util.Consumer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class WarMachine {
|
||||||
|
|
||||||
|
private int schematicId = 0;
|
||||||
|
private Bridge bridge = new Bridge();
|
||||||
|
private List<Cannon> cannons = new ArrayList<>();
|
||||||
|
private List<LocalCoordinate> tntChests = new ArrayList<>();
|
||||||
|
|
||||||
|
public WarMachine setSchematicId(int schematicId) {
|
||||||
|
this.schematicId = schematicId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WarMachine editBridge(Consumer<Bridge> initializer) {
|
||||||
|
initializer.accept(bridge);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WarMachine addCannon(Consumer<Cannon> initializer) {
|
||||||
|
Cannon cannon = new Cannon();
|
||||||
|
initializer.accept(cannon);
|
||||||
|
cannons.add(cannon);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WarMachine addTnTChest(LocalCoordinate chest) {
|
||||||
|
tntChests.add(chest);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WarMachine finish(List<WarMachine> list) {
|
||||||
|
list.add(this);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
+71
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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.ai.schematic.impl;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ai.LocalCoordinate;
|
||||||
|
import de.steamwar.fightsystem.ai.schematic.WarMachine;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class MiniWarGear20 {
|
||||||
|
|
||||||
|
private static final Random RANDOM = new Random();
|
||||||
|
private static final List<WarMachine> MiniWarGear20 = new ArrayList<>();
|
||||||
|
|
||||||
|
public static WarMachine select() {
|
||||||
|
return MiniWarGear20.get(RANDOM.nextInt(MiniWarGear20.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WarMachine select(int schematicId) {
|
||||||
|
return MiniWarGear20.stream()
|
||||||
|
.filter(warMachine -> warMachine.getSchematicId() == schematicId)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final WarMachine DPR_PV1_Reaper = new WarMachine()
|
||||||
|
.setSchematicId(135745)
|
||||||
|
.editBridge(bridge -> {
|
||||||
|
bridge.addShieldActivator(new LocalCoordinate(22, 15, 18));
|
||||||
|
bridge.addShieldActivator(new LocalCoordinate(31, 3, 12));
|
||||||
|
bridge.addShieldActivator(new LocalCoordinate(19, 3, 12));
|
||||||
|
})
|
||||||
|
.addCannon(cannon -> {
|
||||||
|
cannon.addTnt(new LocalCoordinate(29, 1, 21));
|
||||||
|
cannon.addTnt(new LocalCoordinate(29, 1, 22));
|
||||||
|
cannon.addTnt(new LocalCoordinate(29, 1, 23));
|
||||||
|
cannon.addTnt(new LocalCoordinate(30, 1, 22));
|
||||||
|
cannon.addTnt(new LocalCoordinate(30, 1, 23));
|
||||||
|
cannon.addTnt(new LocalCoordinate(29, 2, 24));
|
||||||
|
cannon.addTnt(new LocalCoordinate(30, 2, 24));
|
||||||
|
cannon.addTnt(new LocalCoordinate(29, 2, 25));
|
||||||
|
cannon.addTnt(new LocalCoordinate(30, 2, 25));
|
||||||
|
cannon.addTnt(new LocalCoordinate(29, 3, 24));
|
||||||
|
cannon.addTnt(new LocalCoordinate(30, 3, 24));
|
||||||
|
cannon.addTnt(new LocalCoordinate(29, 3, 25));
|
||||||
|
cannon.addTnt(new LocalCoordinate(30, 3, 25));
|
||||||
|
cannon.addTrigger(new LocalCoordinate(30, 3, 19));
|
||||||
|
cannon.addTrigger(new LocalCoordinate(31, 3, 18));
|
||||||
|
cannon.addTrigger(new LocalCoordinate(31, 3, 20));
|
||||||
|
})
|
||||||
|
.finish(MiniWarGear20);
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* 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.ai.yoyonow;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import de.steamwar.fightsystem.ai.AI;
|
||||||
|
import de.steamwar.fightsystem.ai.Action;
|
||||||
|
import de.steamwar.fightsystem.ai.schematic.Cannon;
|
||||||
|
import de.steamwar.fightsystem.ai.schematic.WarMachine;
|
||||||
|
import de.steamwar.fightsystem.ai.schematic.impl.MiniWarGear20;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.sql.SchematicNode;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class YoyoNowAI extends AI {
|
||||||
|
|
||||||
|
private WarMachine selectedSchematic;
|
||||||
|
|
||||||
|
protected YoyoNowAI(FightTeam team) {
|
||||||
|
super(team, SteamwarUser.get("YoyoNow.AI"));
|
||||||
|
getEntity().setGlowing(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SchematicNode chooseSchematic() {
|
||||||
|
selectedSchematic = MiniWarGear20.select();
|
||||||
|
return SchematicNode.getSchematicNode(selectedSchematic.getSchematicId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void schematic(Clipboard clipboard) {
|
||||||
|
selectedSchematic = MiniWarGear20.select(team.getSchematic());
|
||||||
|
if (selectedSchematic == null) stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Random random = new Random();
|
||||||
|
|
||||||
|
private List<Action> actions = new ArrayList<>();
|
||||||
|
|
||||||
|
private boolean setupDone = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void plan() {
|
||||||
|
if (!navMesh.isReady()) return;
|
||||||
|
|
||||||
|
if (!actions.isEmpty()) {
|
||||||
|
Action.Result result = actions.get(0).step(this);
|
||||||
|
if (result == Action.Result.FAILED) {
|
||||||
|
chat(actions.get(0) + " failed");
|
||||||
|
actions.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (result == Action.Result.FINISHED) {
|
||||||
|
chat(actions.get(0) + " finished");
|
||||||
|
actions.remove(0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!setupDone && FightState.getFightState() == FightState.POST_SCHEM_SETUP) {
|
||||||
|
chat("Setup actions to perform!");
|
||||||
|
selectedSchematic.getBridge().getShieldActivators().forEach(localCoordinate -> {
|
||||||
|
actions.add(new Action.MoveAction(this, localCoordinate.toWorld(getTeam())));
|
||||||
|
actions.add(new Action.InteractAction(localCoordinate));
|
||||||
|
});
|
||||||
|
actions.add(new Action.ReadyAction());
|
||||||
|
chat("Actions: " + actions.size());
|
||||||
|
setupDone = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FightState.getFightState() == FightState.RUNNING) {
|
||||||
|
Cannon cannon = selectedSchematic.getCannons().get(random.nextInt(selectedSchematic.getCannons().size()));
|
||||||
|
actions.add(new Action.LoadCannon(this, cannon));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+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.Material;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockFormEvent;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
public class BlockFormListener implements Listener {
|
||||||
|
|
||||||
|
public BlockFormListener() {
|
||||||
|
new StateDependentListener(Config.GameModeConfig.Arena.DisableIceForm, FightState.All, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockForm(BlockFormEvent event) {
|
||||||
|
if (Config.ArenaRegion.inRegion(event.getBlock()) && event.getNewState().getType() == Material.ICE) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -92,3 +92,13 @@ tasks.register<FightServer>("QuickGear20") {
|
|||||||
worldName = "arenas/WarGearPark"
|
worldName = "arenas/WarGearPark"
|
||||||
config = "QuickGear20.yml"
|
config = "QuickGear20.yml"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.register<FightServer>("MiniWarGear20") {
|
||||||
|
group = "run"
|
||||||
|
description = "Run a MiniWarGear 1.20 Fight Server"
|
||||||
|
dependsOn(":SpigotCore:shadowJar")
|
||||||
|
dependsOn(":FightSystem:shadowJar")
|
||||||
|
template = "MiniWarGear20"
|
||||||
|
worldName = "arenas/NightTown"
|
||||||
|
config = "MiniWarGear20.yml"
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ package de.steamwar.towerrun.commands;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserPerm;
|
import de.steamwar.sql.UserPerm;
|
||||||
import de.steamwar.towerrun.TowerRun;
|
import de.steamwar.towerrun.TowerRun;
|
||||||
@@ -30,6 +31,8 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class StartCommand extends SWCommand {
|
public class StartCommand extends SWCommand {
|
||||||
|
|
||||||
|
@LinkedInstance
|
||||||
private LobbyCountdown countdown;
|
private LobbyCountdown countdown;
|
||||||
|
|
||||||
public StartCommand() {
|
public StartCommand() {
|
||||||
|
|||||||
@@ -159,8 +159,8 @@ public class TowerGenerator {
|
|||||||
noKeyFloors--;
|
noKeyFloors--;
|
||||||
if (!chestBlocks.isEmpty() && noKeyFloors < 0 && random.nextDouble() < config.keyChance) {
|
if (!chestBlocks.isEmpty() && noKeyFloors < 0 && random.nextDouble() < config.keyChance) {
|
||||||
noKeyFloors = random.nextInt(config.maxNoKeyFloors - config.minNoKeyFloors) + config.minNoKeyFloors;
|
noKeyFloors = random.nextInt(config.maxNoKeyFloors - config.minNoKeyFloors) + config.minNoKeyFloors;
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2 && !chestBlocks.isEmpty(); i++) {
|
||||||
Container container = chestBlocks.get(random.nextInt(chestBlocks.size()));
|
Container container = chestBlocks.remove(random.nextInt(chestBlocks.size()));
|
||||||
keys.add(container.getLocation());
|
keys.add(container.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
|
|||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -158,10 +159,16 @@ public class IngameListener extends GameStateBukkitListener {
|
|||||||
public void onKeyUse(PlayerInteractEvent event) {
|
public void onKeyUse(PlayerInteractEvent event) {
|
||||||
if (!event.hasItem()) return;
|
if (!event.hasItem()) return;
|
||||||
if (event.getItem().getType() != Material.LEVER) return;
|
if (event.getItem().getType() != Material.LEVER) return;
|
||||||
event.setCancelled(true);
|
|
||||||
if (!event.hasBlock()) return;
|
if (!event.hasBlock()) return;
|
||||||
if (event.getClickedBlock().getType() != Material.IRON_DOOR) return;
|
if (event.getClickedBlock().getType() != Material.IRON_DOOR) return;
|
||||||
event.getPlayer().getInventory().setItemInMainHand(null);
|
if (event.getHand() == null) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
ItemStack itemStack = event.getItem();
|
||||||
|
itemStack.setAmount(event.getItem().getAmount() - 1);
|
||||||
|
switch (event.getHand()) {
|
||||||
|
case OFF_HAND -> event.getPlayer().getInventory().setItemInOffHand(itemStack);
|
||||||
|
case HAND -> event.getPlayer().getInventory().setItemInMainHand(itemStack);
|
||||||
|
}
|
||||||
event.getClickedBlock().breakNaturally();
|
event.getClickedBlock().breakNaturally();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,6 +230,8 @@ public class IngameListener extends GameStateBukkitListener {
|
|||||||
shouldMelt(block.getRelative(0, 0, -1));
|
shouldMelt(block.getRelative(0, 0, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Random RANDOM = new Random();
|
||||||
|
|
||||||
private void shouldMelt(Block block) {
|
private void shouldMelt(Block block) {
|
||||||
if (block.getType().isBurnable()) return;
|
if (block.getType().isBurnable()) return;
|
||||||
if (block.getType().isAir()) return;
|
if (block.getType().isAir()) return;
|
||||||
@@ -269,7 +278,9 @@ public class IngameListener extends GameStateBukkitListener {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Pos pos = new Pos(block.getLocation().getBlockX(), block.getLocation().getBlockY(), block.getLocation().getBlockZ());
|
Pos pos = new Pos(block.getLocation().getBlockX(), block.getLocation().getBlockY(), block.getLocation().getBlockZ());
|
||||||
blocksToMelt.putIfAbsent(pos, time + meltingTime + 1);
|
int delay = meltingTime + 1 + RANDOM.nextInt(30*20)-30*10;
|
||||||
|
if (delay < 0) delay = meltingTime + 1;
|
||||||
|
blocksToMelt.putIfAbsent(pos, time + delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ public abstract class OutsideWincondition extends WinCondition {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
if (event.getTo().getY() > WorldConfig.ESCAPE_HEIGHT) {
|
if (event.getTo().getY() > WorldConfig.ESCAPE_HEIGHT) {
|
||||||
|
if (event.getTo().getY() > WorldConfig.ESCAPE_HEIGHT + 10 && Arrays.stream(WorldConfig.REGIONS).noneMatch(region -> region.contains(event.getTo().toVector()))) {
|
||||||
|
TowerRunPlayer tPlayer = TowerRunPlayer.get(event.getPlayer());
|
||||||
|
tPlayer.player().damage(Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,19 +17,6 @@
|
|||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
LOCALE = English
|
|
||||||
|
|
||||||
SETTINGS_TITLE = Settings
|
|
||||||
SETTINGS_LOCALE_ITEM = §fLocale
|
|
||||||
SETTINGS_LOCALE_CURRENT = §fCurrent locale §e{0}§8.
|
|
||||||
SETTINGS_LOCALE_LOCKED = §cLocked§f to the current locale§8.
|
|
||||||
SETTINGS_LOCALE_UNLOCKED = §aChanged§f by Client locale§8.
|
|
||||||
SETTINGS_PREFIX_ITEM = §fChat prefix
|
|
||||||
SETTINGS_PREFIX_SELECTED = §a> {0}
|
|
||||||
SETTINGS_PREFIX_UNSELECTED = §f> {0}
|
|
||||||
SETTINGS_PREFIX_SW = §eS§8W
|
|
||||||
SETTINGS_PREFIX_TEAM = §{0}{1}
|
|
||||||
|
|
||||||
COMMAND_SYSTEM_ERROR = §cError executing the command!
|
COMMAND_SYSTEM_ERROR = §cError executing the command!
|
||||||
COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
|
COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
LOCALE = Deutsch
|
|
||||||
|
|
||||||
COMMAND_SYSTEM_ERROR = §cFehler beim Ausführen des Befehls!
|
COMMAND_SYSTEM_ERROR = §cFehler beim Ausführen des Befehls!
|
||||||
|
|
||||||
PREFIX=§eSteam§8War»
|
PREFIX=§eSteam§8War»
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* 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.commands;
|
||||||
|
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
|
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
||||||
|
import de.steamwar.velocitycore.network.NetworkSender;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
public class SetLocaleCommand extends SWCommand {
|
||||||
|
|
||||||
|
public SetLocaleCommand() {
|
||||||
|
super("setlocale", "setlanguage");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericCommand(PlayerChatter sender) {
|
||||||
|
sender.user().setLocale(sender.getPlayer().getPlayerSettings().getLocale(), true);
|
||||||
|
sender.withPlayer(player -> NetworkSender.send(player, new LocaleInvalidationPacket(sender.user().getId())));
|
||||||
|
sender.system("LOCK_LOCALE_CHANGED");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,74 +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.velocitycore.commands;
|
|
||||||
|
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import de.steamwar.messages.Message;
|
|
||||||
import de.steamwar.messages.PlayerChatter;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.sql.Team;
|
|
||||||
import de.steamwar.sql.UserPerm;
|
|
||||||
import de.steamwar.velocitycore.inventory.SWInventory;
|
|
||||||
import de.steamwar.velocitycore.inventory.SWItem;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class SettingsCommand extends SWCommand {
|
|
||||||
|
|
||||||
public SettingsCommand() {
|
|
||||||
super("settings");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register
|
|
||||||
public void genericCommand(PlayerChatter sender) {
|
|
||||||
SWInventory inventory = new SWInventory(sender, 9, new Message("SETTINGS_TITLE"));
|
|
||||||
SteamwarUser user = sender.user();
|
|
||||||
String localeItem = user.getManualLocale() ? "BOOK" : "BOOK_AND_QUILL";
|
|
||||||
SWItem localeSwItem = new SWItem(localeItem, new Message("SETTINGS_LOCALE_ITEM"));
|
|
||||||
localeSwItem.addLore(new Message("SETTINGS_LOCALE_CURRENT", new Message("LOCALE")));
|
|
||||||
if (user.getManualLocale()) {
|
|
||||||
localeSwItem.addLore(new Message("SETTINGS_LOCALE_LOCKED"));
|
|
||||||
} else {
|
|
||||||
localeSwItem.addLore(new Message("SETTINGS_LOCALE_UNLOCKED"));
|
|
||||||
}
|
|
||||||
inventory.addItem(2, localeSwItem, click -> {
|
|
||||||
if (user.getManualLocale()) {
|
|
||||||
user.unlockLocale();
|
|
||||||
} else {
|
|
||||||
user.lockLocale();
|
|
||||||
}
|
|
||||||
genericCommand(sender);
|
|
||||||
});
|
|
||||||
|
|
||||||
Team team = Team.byId(user.getTeam());
|
|
||||||
String chatPrefixItem = !user.hasPerm(UserPerm.TEAM) ? "BARRIER" : "NAME_TAG";
|
|
||||||
SWItem swItem = new SWItem(chatPrefixItem, new Message("SETTINGS_PREFIX_ITEM"));
|
|
||||||
if (user.hasPerm(UserPerm.TEAM)) {
|
|
||||||
swItem.addLore(new Message("SETTINGS_PREFIX_SELECTED", new Message("SETTINGS_PREFIX_SW")));
|
|
||||||
}
|
|
||||||
if (user.getTeam() != Team.PUBLIC) {
|
|
||||||
swItem.addLore(new Message("SETTINGS_PREFIX_UNSELECTED", new Message("SETTINGS_PREFIX_TEAM", team.getTeamColor(), team.getTeamKuerzel())));
|
|
||||||
}
|
|
||||||
inventory.addItem(6, swItem, click -> {
|
|
||||||
});
|
|
||||||
|
|
||||||
inventory.open();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -60,7 +60,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
helpMessages(sender, "TEAM_HELP_HEADER", "TEAM_HELP_LIST", "TEAM_HELP_INFO");
|
helpMessages(sender, "TEAM_HELP_HEADER", "TEAM_HELP_LIST", "TEAM_HELP_INFO");
|
||||||
|
|
||||||
SteamwarUser user = sender.user();
|
SteamwarUser user = sender.user();
|
||||||
if(user.getTeam() == Team.PUBLIC) {
|
if(user.getTeam() == 0) {
|
||||||
helpMessages(sender, "TEAM_HELP_CREATE", "TEAM_HELP_JOIN");
|
helpMessages(sender, "TEAM_HELP_CREATE", "TEAM_HELP_JOIN");
|
||||||
}else{
|
}else{
|
||||||
helpMessages(sender, "TEAM_HELP_CHAT", "TEAM_HELP_EVENT", "TEAM_HELP_LEAVE");
|
helpMessages(sender, "TEAM_HELP_CHAT", "TEAM_HELP_EVENT", "TEAM_HELP_LEAVE");
|
||||||
@@ -162,7 +162,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.setTeam(Team.PUBLIC);
|
user.setTeam(0);
|
||||||
|
|
||||||
if(teamSize == 1)
|
if(teamSize == 1)
|
||||||
team.disband(user);
|
team.disband(user);
|
||||||
@@ -182,7 +182,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
if(notDuringEvent(sender))
|
if(notDuringEvent(sender))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(target.getTeam() != Team.PUBLIC){
|
if(target.getTeam() != 0){
|
||||||
sender.system("TEAM_INVITE_IN_TEAM");
|
sender.system("TEAM_INVITE_IN_TEAM");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -218,7 +218,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.setTeam(Team.PUBLIC);
|
target.setTeam(0);
|
||||||
|
|
||||||
sender.system("TEAM_REMOVE_REMOVED");
|
sender.system("TEAM_REMOVE_REMOVED");
|
||||||
Chatter.of(target).system("TEAM_REMOVE_REMOVED_TARGET");
|
Chatter.of(target).system("TEAM_REMOVE_REMOVED_TARGET");
|
||||||
@@ -493,7 +493,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
@Validator(value = "isNotInTeam", local = true)
|
@Validator(value = "isNotInTeam", local = true)
|
||||||
public TypeValidator<Chatter> isNotInTeamValidator() {
|
public TypeValidator<Chatter> isNotInTeamValidator() {
|
||||||
return (sender, value, messageSender) -> {
|
return (sender, value, messageSender) -> {
|
||||||
if (sender.user().getTeam() != Team.PUBLIC) {
|
if (sender.user().getTeam() != 0) {
|
||||||
messageSender.send("TEAM_IN_TEAM");
|
messageSender.send("TEAM_IN_TEAM");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -504,7 +504,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
@Validator(value = "isInTeam", local = true)
|
@Validator(value = "isInTeam", local = true)
|
||||||
public TypeValidator<Chatter> isInTeamValidator() {
|
public TypeValidator<Chatter> isInTeamValidator() {
|
||||||
return (sender, value, messageSender) -> {
|
return (sender, value, messageSender) -> {
|
||||||
if (sender.user().getTeam() == Team.PUBLIC) {
|
if (sender.user().getTeam() == 0) {
|
||||||
messageSender.send("TEAM_NOT_IN_TEAM");
|
messageSender.send("TEAM_NOT_IN_TEAM");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -516,7 +516,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
public TypeValidator<Chatter> isLeaderValidator() {
|
public TypeValidator<Chatter> isLeaderValidator() {
|
||||||
return (sender, value, messageSender) -> {
|
return (sender, value, messageSender) -> {
|
||||||
SteamwarUser user = sender.user();
|
SteamwarUser user = sender.user();
|
||||||
if (user.getTeam() == Team.PUBLIC) {
|
if (user.getTeam() == 0) {
|
||||||
messageSender.send("TEAM_NOT_IN_TEAM");
|
messageSender.send("TEAM_NOT_IN_TEAM");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ public class BanListener extends BasicListener {
|
|||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
String ip = IPSanitizer.getTrueAddress(player).getHostAddress();
|
String ip = IPSanitizer.getTrueAddress(player).getHostAddress();
|
||||||
if (user.isPunished(Punishment.PunishmentType.Ban)) {
|
if (user.isPunished(Punishment.PunishmentType.Ban)) {
|
||||||
|
if (!player.getUsername().startsWith(".")) {
|
||||||
BannedUserIPs.banIP(user.getId(), ip);
|
BannedUserIPs.banIP(user.getId(), ip);
|
||||||
|
}
|
||||||
Chatter.of(event).system(PunishmentCommand.punishmentMessage(user, Punishment.PunishmentType.Ban));
|
Chatter.of(event).system(PunishmentCommand.punishmentMessage(user, Punishment.PunishmentType.Ban));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class SettingsChangedListener extends BasicListener {
|
|||||||
VelocityCore.schedule(() -> {
|
VelocityCore.schedule(() -> {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
user.setJoinLocale(event.getPlayerSettings().getLocale());
|
user.setLocale(event.getPlayerSettings().getLocale(), false);
|
||||||
NetworkSender.send(player, new LocaleInvalidationPacket(user.getId()));
|
NetworkSender.send(player, new LocaleInvalidationPacket(user.getId()));
|
||||||
}).schedule();
|
}).schedule();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user