forked from SteamWar/SteamWar
Merge branch 'KotlinCore/message-update' into TNTLeague/finish
This commit is contained in:
@@ -27,8 +27,8 @@ java {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":BauSystem:BauSystem_Main"))
|
compileOnly(project(":BauSystem:BauSystem_Main", "default"))
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms15)
|
compileOnly(libs.nms15)
|
||||||
compileOnly(libs.worldedit15)
|
compileOnly(libs.worldedit15)
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ java {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":BauSystem:BauSystem_Main"))
|
compileOnly(project(":BauSystem:BauSystem_Main", "default"))
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
compileOnly(libs.nms18)
|
compileOnly(libs.nms18)
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ java {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":BauSystem:BauSystem_Main"))
|
compileOnly(project(":BauSystem:BauSystem_Main", "default"))
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
compileOnly(libs.paperapi)
|
compileOnly(libs.paperapi)
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ java {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":BauSystem:BauSystem_Main"))
|
compileOnly(project(":BauSystem:BauSystem_Main", "default"))
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ java {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(libs.classindex)
|
compileOnly(libs.classindex)
|
||||||
annotationProcessor(libs.classindex)
|
annotationProcessor(libs.classindex)
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
compileOnly(libs.axiom)
|
compileOnly(libs.axiom)
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core"))
|
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms10)
|
compileOnly(libs.nms10)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core"))
|
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_8"))
|
compileOnly(project(":FightSystem:FightSystem_8", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms12)
|
compileOnly(libs.nms12)
|
||||||
compileOnly(libs.worldedit12)
|
compileOnly(libs.worldedit12)
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core"))
|
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_8"))
|
compileOnly(project(":FightSystem:FightSystem_8", "default"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_9"))
|
compileOnly(project(":FightSystem:FightSystem_9", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms14)
|
compileOnly(libs.nms14)
|
||||||
compileOnly(libs.worldedit15)
|
compileOnly(libs.worldedit15)
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core"))
|
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms15)
|
compileOnly(libs.nms15)
|
||||||
compileOnly(libs.worldedit15)
|
compileOnly(libs.worldedit15)
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core"))
|
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core"))
|
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_18"))
|
compileOnly(project(":FightSystem:FightSystem_18", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core"))
|
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_18"))
|
compileOnly(project(":FightSystem:FightSystem_18", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core"))
|
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms8)
|
compileOnly(libs.nms8)
|
||||||
compileOnly(libs.worldedit12)
|
compileOnly(libs.worldedit12)
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core"))
|
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_8"))
|
compileOnly(project(":FightSystem:FightSystem_8", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms9)
|
compileOnly(libs.nms9)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ SCHEM_PRIVATE=§ePrivate {0}
|
|||||||
SCHEM_NO_PRIVATE=§7No private {0} present
|
SCHEM_NO_PRIVATE=§7No private {0} present
|
||||||
SCHEM_PRIVATE_FORBIDDEN=§7No private {0} allowed
|
SCHEM_PRIVATE_FORBIDDEN=§7No private {0} allowed
|
||||||
|
|
||||||
|
ADD_AI_TITLE=Add AI
|
||||||
|
|
||||||
|
|
||||||
# Countdowns
|
# Countdowns
|
||||||
COUNTDOWN_MINUTES=§e{0} §7Minutes {1}
|
COUNTDOWN_MINUTES=§e{0} §7Minutes {1}
|
||||||
@@ -114,6 +116,7 @@ RESPAWN=§eRespawn
|
|||||||
REMOVE_PLAYERS=§cKick player
|
REMOVE_PLAYERS=§cKick player
|
||||||
CHOOSE_SCHEMATIC=§eChoose {0}
|
CHOOSE_SCHEMATIC=§eChoose {0}
|
||||||
SCHEMATIC_REQUIRED=§cChoose a schematic first
|
SCHEMATIC_REQUIRED=§cChoose a schematic first
|
||||||
|
ADD_AI=§eAdd AI
|
||||||
|
|
||||||
KIT_PREVIEW_EDIT=§7Edit kit
|
KIT_PREVIEW_EDIT=§7Edit kit
|
||||||
KIT_PREVIEW_CHOOSE=§aSelect kit
|
KIT_PREVIEW_CHOOSE=§aSelect kit
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ SCHEM_PRIVATE=§ePrivates {0}
|
|||||||
SCHEM_NO_PRIVATE=§7Kein privates {0} vorhanden
|
SCHEM_NO_PRIVATE=§7Kein privates {0} vorhanden
|
||||||
SCHEM_PRIVATE_FORBIDDEN=§7Kein privates {0} erlaubt
|
SCHEM_PRIVATE_FORBIDDEN=§7Kein privates {0} erlaubt
|
||||||
|
|
||||||
|
ADD_AI_TITLE=KI hinzufügen
|
||||||
|
|
||||||
|
|
||||||
# Countdowns
|
# Countdowns
|
||||||
COUNTDOWN_MINUTES=§e{0} §7Minuten {1}
|
COUNTDOWN_MINUTES=§e{0} §7Minuten {1}
|
||||||
@@ -107,6 +109,7 @@ RESPAWN=§eRespawn
|
|||||||
REMOVE_PLAYERS=§cSpieler rauswerfen
|
REMOVE_PLAYERS=§cSpieler rauswerfen
|
||||||
CHOOSE_SCHEMATIC=§e{0} wählen
|
CHOOSE_SCHEMATIC=§e{0} wählen
|
||||||
SCHEMATIC_REQUIRED=§cZuerst muss eine Schematic gewählt sein
|
SCHEMATIC_REQUIRED=§cZuerst muss eine Schematic gewählt sein
|
||||||
|
ADD_AI=§eKI hinzufügen
|
||||||
|
|
||||||
KIT_PREVIEW_EDIT=§7Kit bearbeiten
|
KIT_PREVIEW_EDIT=§7Kit bearbeiten
|
||||||
KIT_PREVIEW_CHOOSE=§aKit wählen
|
KIT_PREVIEW_CHOOSE=§aKit wählen
|
||||||
|
|||||||
@@ -19,32 +19,38 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.ai;
|
package de.steamwar.fightsystem.ai;
|
||||||
|
|
||||||
|
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.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
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.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.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 org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Note;
|
import org.bukkit.Note;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Lectern;
|
import org.bukkit.block.Lectern;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.block.data.FaceAttachable;
|
||||||
import org.bukkit.block.data.Openable;
|
import org.bukkit.block.data.Openable;
|
||||||
import org.bukkit.block.data.Powerable;
|
import org.bukkit.block.data.Powerable;
|
||||||
import org.bukkit.block.data.type.Comparator;
|
import org.bukkit.block.data.type.Comparator;
|
||||||
import org.bukkit.block.data.type.NoteBlock;
|
import org.bukkit.block.data.type.NoteBlock;
|
||||||
import org.bukkit.block.data.type.Repeater;
|
import org.bukkit.block.data.type.Repeater;
|
||||||
|
import org.bukkit.block.data.type.Switch;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
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;
|
||||||
@@ -55,10 +61,16 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public abstract class AI {
|
public abstract class AI {
|
||||||
|
|
||||||
|
public static final int MOVEMENT_DELAY = 4;
|
||||||
|
public static final double INTERACTION_RANGE = 5.0;
|
||||||
|
|
||||||
private static final Map<UUID, AI> ais = new HashMap<>();
|
private static final Map<UUID, AI> ais = new HashMap<>();
|
||||||
|
public static void printPos() {
|
||||||
|
ais.values().forEach(ai -> ai.chat(ai.entity.isValid() + " " + ai.entity.isDead() + " " + ai.entity.getLocation()));
|
||||||
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
new OneShotStateDependent(ArenaMode.All, FightState.Spectate, () -> {
|
new OneShotStateDependent(ArenaMode.AntiReplay, FightState.Spectate, () -> {
|
||||||
ais.values().forEach(AI::stop);
|
ais.values().forEach(AI::stop);
|
||||||
ais.clear();
|
ais.clear();
|
||||||
});
|
});
|
||||||
@@ -68,7 +80,9 @@ public abstract class AI {
|
|||||||
return ais.get(uuid);
|
return ais.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final FightTeam team;
|
@Getter
|
||||||
|
protected final FightTeam team;
|
||||||
|
@Getter
|
||||||
private final LivingEntity entity;
|
private final LivingEntity entity;
|
||||||
private final BukkitTask task;
|
private final BukkitTask task;
|
||||||
private final Queue<Action> queue = new ArrayDeque<>();
|
private final Queue<Action> queue = new ArrayDeque<>();
|
||||||
@@ -83,11 +97,15 @@ public abstract class AI {
|
|||||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::run, 1, 1);
|
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::run, 1, 1);
|
||||||
ais.put(entity.getUniqueId(), this);
|
ais.put(entity.getUniqueId(), this);
|
||||||
team.addMember(entity, user);
|
team.addMember(entity, user);
|
||||||
|
|
||||||
|
if(FightState.Schem.contains(FightState.getFightState()))
|
||||||
|
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> schematic(team.getClipboard()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract SchematicNode chooseSchematic();
|
public abstract SchematicNode chooseSchematic();
|
||||||
|
public abstract void schematic(Clipboard clipboard);
|
||||||
|
|
||||||
public boolean acceptJoinRequest(Player player, FightTeam team) {
|
public boolean acceptJoinRequest(JoinRequest.Enquirer enquirer, FightTeam team) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,11 +119,7 @@ public abstract class AI {
|
|||||||
task.cancel();
|
task.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LivingEntity getEntity() {
|
public void setReady() {
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setReady() {
|
|
||||||
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -115,12 +129,12 @@ public abstract class AI {
|
|||||||
team.setReady(true);
|
team.setReady(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void chat(String message) {
|
public void chat(String message) {
|
||||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + "» " + message);
|
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + "» " + message);
|
||||||
Chat.broadcastChat("PARTICIPANT_CHAT", team.getColoredName(), entity.getName(), message);
|
Chat.broadcastChat("PARTICIPANT_CHAT", team.getColoredName(), entity.getName(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Vector getPosition() {
|
public Vector getPosition() {
|
||||||
Location location = entity.getLocation();
|
Location location = entity.getLocation();
|
||||||
Region extend = team.getExtendRegion();
|
Region extend = team.getExtendRegion();
|
||||||
if(Fight.getUnrotated() == team)
|
if(Fight.getUnrotated() == team)
|
||||||
@@ -137,26 +151,28 @@ public abstract class AI {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Material getBlock(Vector pos) {
|
public Material getBlock(Vector pos) {
|
||||||
queue.add(new Action(1));
|
queue.add(new Action(1));
|
||||||
return translate(pos, true).getBlock().getType();
|
return translate(pos).getBlock().getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isPowered(Vector pos) {
|
public BlockData getBlockData(Vector pos) {
|
||||||
queue.add(new Action(1));
|
queue.add(new Action(1));
|
||||||
return translate(pos, true).getBlock().isBlockPowered();
|
return translate(pos).getBlock().getBlockData();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setTNT(Vector pos) {
|
public void setTNT(Vector 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, true);
|
Location location = translate(pos);
|
||||||
if(interactionDistanceViolation(location))
|
if(interactionDistanceViolation(location)) {
|
||||||
|
chat("InteractionDistanceViolation: setTNT");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
if(block.getType() == Material.AIR)
|
if(block.getType() == Material.AIR)
|
||||||
@@ -165,24 +181,26 @@ public abstract class AI {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void interact(Vector pos) {
|
public void interact(Vector pos) {
|
||||||
queue.add(new Action(1) {
|
queue.add(new Action(1) {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Location location = translate(pos, true);
|
Location location = translate(pos);
|
||||||
if(interactionDistanceViolation(location))
|
if(interactionDistanceViolation(location)) {
|
||||||
|
chat("InteractionDistanceViolation: interact");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
interact(location.getBlock());
|
interact(location.getBlock());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void interact(Vector pos, int n) {
|
public void interact(Vector 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, true);
|
Location location = translate(pos);
|
||||||
if (interactionDistanceViolation(location))
|
if (interactionDistanceViolation(location))
|
||||||
return;
|
return;
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
@@ -199,13 +217,18 @@ public abstract class AI {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void move(Vector pos) {
|
public void move(Vector pos) {
|
||||||
queue.add(new Action(2) {
|
queue.add(new Action(MOVEMENT_DELAY) {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Location location = entity.getLocation();
|
Location location = entity.getLocation();
|
||||||
Location target = translate(pos, false);
|
if(!entity.isOnGround() && location.getBlock().getType() != Material.LADDER) {
|
||||||
if(Math.abs(location.getX() - target.getX()) > 1 || Math.abs(location.getY() - target.getY()) > 1.2 || Math.abs(location.getZ() - target.getZ()) > 1) {
|
FightSystem.getPlugin().getLogger().log(Level.INFO, "Entity falling");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location target = translate(pos);
|
||||||
|
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) {
|
||||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + ": Overdistance movement " + location.toVector() + " " + target.toVector());
|
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + ": Overdistance movement " + location.toVector() + " " + target.toVector());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -213,13 +236,16 @@ public abstract class AI {
|
|||||||
if(!team.getFightPlayer(entity).canEntern() && !team.getExtendRegion().inRegion(target))
|
if(!team.getFightPlayer(entity).canEntern() && !team.getExtendRegion().inRegion(target))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
entity.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
|
if(!entity.teleport(target, PlayerTeleportEvent.TeleportCause.PLUGIN))
|
||||||
|
FightSystem.getPlugin().getLogger().log(Level.INFO, "Entity not teleported: " + entity.isValid());
|
||||||
|
|
||||||
|
GlobalRecorder.getInstance().entityMoves(entity);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean interactionDistanceViolation(Location location) {
|
private boolean interactionDistanceViolation(Location location) {
|
||||||
return location.distance(entity.getEyeLocation()) > 5;
|
return location.distance(entity.getEyeLocation()) > INTERACTION_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void interact(Block block) {
|
private void interact(Block block) {
|
||||||
@@ -249,23 +275,51 @@ public abstract class AI {
|
|||||||
|
|
||||||
powerable.setPowered(false);
|
powerable.setPowered(false);
|
||||||
block.setBlockData(powerable);
|
block.setBlockData(powerable);
|
||||||
|
updateButton(block);
|
||||||
}, type.name().endsWith("STONE_BUTTON") ? 20 : 30);
|
}, type.name().endsWith("STONE_BUTTON") ? 20 : 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
powerable.setPowered(!isPowered);
|
powerable.setPowered(!isPowered);
|
||||||
}
|
}
|
||||||
block.setBlockData(data);
|
block.setBlockData(data);
|
||||||
|
if(data instanceof Switch) {
|
||||||
|
updateButton(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateButton(Block block) {
|
||||||
|
Switch sw = (Switch) block.getBlockData();
|
||||||
|
FaceAttachable.AttachedFace face = sw.getAttachedFace();
|
||||||
|
if (face == FaceAttachable.AttachedFace.FLOOR) {
|
||||||
|
update(block.getRelative(BlockFace.DOWN));
|
||||||
|
} else if (face == FaceAttachable.AttachedFace.CEILING) {
|
||||||
|
update(block.getRelative(BlockFace.UP));
|
||||||
|
} else {
|
||||||
|
update(block.getRelative(sw.getFacing().getOppositeFace()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update(Block block) {
|
||||||
|
BlockData data = block.getBlockData();
|
||||||
|
block.setType(Material.BARRIER);
|
||||||
|
block.setBlockData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run() {
|
private void run() {
|
||||||
if(queue.isEmpty())
|
if(queue.isEmpty()) {
|
||||||
plan();
|
try {
|
||||||
|
plan();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
stop();
|
||||||
|
throw t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!queue.isEmpty() && --queue.peek().delay == 0)
|
if(!queue.isEmpty() && --queue.peek().delay == 0)
|
||||||
queue.poll().run();
|
queue.poll().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Location translate(Vector pos, boolean blockPos) {
|
public Location translate(Vector pos) {
|
||||||
Region extend = team.getExtendRegion();
|
Region extend = team.getExtendRegion();
|
||||||
if(Fight.getUnrotated() == team)
|
if(Fight.getUnrotated() == team)
|
||||||
return new Location(
|
return new Location(
|
||||||
@@ -277,9 +331,9 @@ public abstract class AI {
|
|||||||
else
|
else
|
||||||
return new Location(
|
return new Location(
|
||||||
Config.world,
|
Config.world,
|
||||||
extend.getMaxX() - pos.getX() - (blockPos ? 1 : 0),
|
extend.getMaxX() - pos.getX(),
|
||||||
pos.getY() + team.getSchemRegion().getMinY(),
|
pos.getY() + team.getSchemRegion().getMinY(),
|
||||||
extend.getMaxZ() - pos.getZ() - (blockPos ? 1 : 0)
|
extend.getMaxZ() - pos.getZ()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.ai;
|
||||||
|
|
||||||
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.BooleanSupplier;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class AIManager {
|
||||||
|
private static final List<AIManager> AIs = Arrays.asList(
|
||||||
|
new AIManager(DummyAI.class, Material.STONE, () -> ArenaMode.Test.contains(Config.mode))
|
||||||
|
);
|
||||||
|
|
||||||
|
public static List<AIManager> availableAIs() {
|
||||||
|
return AIs.stream().filter(manager -> manager.available.getAsBoolean()).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Class<? extends AI> aiClass;
|
||||||
|
@Getter
|
||||||
|
private final Material icon;
|
||||||
|
private final BooleanSupplier available;
|
||||||
|
|
||||||
|
public String name() {
|
||||||
|
return aiClass.getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void join(FightTeam team) {
|
||||||
|
Reflection.getConstructor(aiClass, FightTeam.class).invoke(team);
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
-18
@@ -19,42 +19,42 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.ai;
|
package de.steamwar.fightsystem.ai;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.utils.FightStatistics;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class LixfelAI extends AI {
|
public class DummyAI extends AI {
|
||||||
|
|
||||||
private final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
private LixfelPathplanner pathplanner;
|
|
||||||
|
|
||||||
public LixfelAI(FightTeam team, String user) {
|
public DummyAI(FightTeam team) {
|
||||||
super(team, SteamwarUser.get(user));
|
super(team, SteamwarUser.get("public"));
|
||||||
|
|
||||||
|
FightStatistics.unrank();
|
||||||
|
getEntity().setInvulnerable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SchematicNode chooseSchematic() {
|
public SchematicNode chooseSchematic() {
|
||||||
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.SchematicType.toDB());
|
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.SchematicType.toDB());
|
||||||
SchematicNode schem = publics.get(new Random().nextInt(publics.size()));
|
return publics.get(random.nextInt(publics.size()));
|
||||||
pathplanner = new LixfelPathplanner(schem);
|
}
|
||||||
return schem;
|
|
||||||
|
@Override
|
||||||
|
public void schematic(Clipboard clipboard) {
|
||||||
|
//does nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void plan() {
|
protected void plan() {
|
||||||
setReady();
|
if(FightState.getFightState() == FightState.POST_SCHEM_SETUP)
|
||||||
Vector destination = pathplanner.getWalkable().get(random.nextInt(pathplanner.getWalkable().size()));
|
setReady();
|
||||||
List<Vector> path = pathplanner.plan(getPosition(), destination);
|
|
||||||
if(!path.isEmpty())
|
|
||||||
chat("Path size: " + path.size());
|
|
||||||
for(Vector p : path) {
|
|
||||||
move(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2023 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 com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
|
||||||
import de.steamwar.fightsystem.Config;
|
|
||||||
import de.steamwar.sql.SchematicData;
|
|
||||||
import de.steamwar.sql.SchematicNode;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class LixfelPathplanner {
|
|
||||||
|
|
||||||
private static BlockType getBlockType(Clipboard clipboard, BlockVector3 vector) {
|
|
||||||
return clipboard.getBlock(vector).getBlockType();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean nonsolid(Clipboard clipboard, BlockVector3 vector) {
|
|
||||||
return !getBlockType(clipboard, vector).getMaterial().isSolid();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Vector toBukkit(BlockVector3 vector) {
|
|
||||||
return new Vector(vector.getX() + 0.5, vector.getY(), vector.getZ() + 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final List<Vector> walkable = new ArrayList<>();
|
|
||||||
private final Map<Vector, Vector[]> neighbours = new HashMap<>();
|
|
||||||
|
|
||||||
public LixfelPathplanner(SchematicNode schem) {
|
|
||||||
try {
|
|
||||||
fillWalkable(new SchematicData(schem).load());
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Vector> getWalkable() {
|
|
||||||
return walkable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fillWalkable(Clipboard clipboard) {
|
|
||||||
BlockVector3 min = clipboard.getRegion().getMinimumPoint().subtract(Config.PreperationArea, 0, Config.PreperationArea); //TODO assumes nonextended Schematic with maximal size
|
|
||||||
Region region = clipboard.getRegion();
|
|
||||||
clipboard.getRegion().forEach(vector -> {
|
|
||||||
BlockVector3 below = vector.subtract(0, 1, 0);
|
|
||||||
if(!region.contains(below))
|
|
||||||
return;
|
|
||||||
|
|
||||||
BlockType belowMaterial = getBlockType(clipboard, below);
|
|
||||||
BlockVector3 above = vector.add(0, 1, 0);
|
|
||||||
if(nonsolid(clipboard, vector)) {
|
|
||||||
if(
|
|
||||||
(belowMaterial.getMaterial().isSolid() || belowMaterial.getId().equals("minecraft:ladder")) &&
|
|
||||||
(!region.contains(above) || nonsolid(clipboard, above))
|
|
||||||
)
|
|
||||||
walkable.add(toBukkit(vector.subtract(min)));
|
|
||||||
} else {
|
|
||||||
if(!region.contains(above))
|
|
||||||
walkable.add(toBukkit(above.subtract(min)));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for(Vector vector : walkable) {
|
|
||||||
neighbours.put(vector, walkable.stream().filter(neighbour -> neighbouring(neighbour, vector)).filter(neighbour -> neighbour != vector).toArray(Vector[]::new));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Vector> planToAnywhere(Vector start, Vector destination) {
|
|
||||||
Vector intermediate = walkable.stream().filter(vector -> neighbouring(vector, destination)).findAny().orElse(null);
|
|
||||||
|
|
||||||
if(intermediate == null)
|
|
||||||
return Collections.emptyList();
|
|
||||||
|
|
||||||
List<Vector> plan = plan(start, intermediate);
|
|
||||||
plan.add(destination);
|
|
||||||
|
|
||||||
return plan;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Vector> plan(Vector start, Vector destination) {
|
|
||||||
if(neighbouring(start, destination))
|
|
||||||
return Collections.singletonList(destination);
|
|
||||||
|
|
||||||
Map<Vector, Vector> approach = new HashMap<>();
|
|
||||||
Set<Vector> checking = Collections.singleton(destination);
|
|
||||||
|
|
||||||
while(!checking.isEmpty()) {
|
|
||||||
Set<Vector> toCheck = new HashSet<>();
|
|
||||||
for(Vector current : checking) {
|
|
||||||
Vector firstStep = Arrays.stream(neighbours.get(current))
|
|
||||||
.filter(vector -> !approach.containsKey(vector))
|
|
||||||
.filter(next -> {
|
|
||||||
approach.put(next, current);
|
|
||||||
toCheck.add(next);
|
|
||||||
return neighbouring(next, start);
|
|
||||||
})
|
|
||||||
.findAny().orElse(null);
|
|
||||||
|
|
||||||
if(firstStep != null) {
|
|
||||||
List<Vector> path = new ArrayList<>();
|
|
||||||
path.add(firstStep);
|
|
||||||
|
|
||||||
while(path.get(path.size()-1) != destination) {
|
|
||||||
path.add(approach.get(path.get(path.size()-1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
checking = toCheck;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean neighbouring(Vector a, Vector b) {
|
|
||||||
return Math.abs(a.getX() - b.getX()) <= 1 && Math.abs(a.getY() - b.getY()) <= 1 && Math.abs(a.getZ() - b.getZ()) <= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,6 +22,7 @@ package de.steamwar.fightsystem.commands;
|
|||||||
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.ai.AIManager;
|
||||||
import de.steamwar.fightsystem.fight.*;
|
import de.steamwar.fightsystem.fight.*;
|
||||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
@@ -38,9 +39,8 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.stream.Collectors;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class GUI {
|
public class GUI {
|
||||||
private GUI(){}
|
private GUI(){}
|
||||||
@@ -53,7 +53,7 @@ public class GUI {
|
|||||||
String name = team.getLeader() != null ? team.getLeader().getEntity().getName() : team.getName();
|
String name = team.getLeader() != null ? team.getLeader().getEntity().getName() : team.getName();
|
||||||
inv.setItem(pos, SWItem.getDye(colorCode), colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColor() + name), click -> {
|
inv.setItem(pos, SWItem.getDye(colorCode), colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColor() + name), click -> {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
new JoinRequest(p, team);
|
JoinRequest.forPlayer(p, team);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,11 +89,29 @@ public class GUI {
|
|||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addAI(Player p) {
|
||||||
|
SWListInv<AIManager> inv = new SWListInv<>(
|
||||||
|
p, msg.parse("ADD_AI_TITLE", p),
|
||||||
|
AIManager.availableAIs().stream().map(manager -> new SWListInv.SWListEntry<>(new SWItem(manager.getIcon(), manager.name()), manager)).collect(Collectors.toList()),
|
||||||
|
(click, manager) -> {
|
||||||
|
FightTeam team = Fight.getPlayerTeam(p);
|
||||||
|
if(FightState.PreLeaderSetup.contains(FightState.getFightState())) {
|
||||||
|
manager.join(Fight.getOpposite(team));
|
||||||
|
} else {
|
||||||
|
JoinRequest.forAI(manager, team);
|
||||||
|
}
|
||||||
|
p.closeInventory();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
|
inv.open();
|
||||||
|
}
|
||||||
|
|
||||||
public static void chooseJoinRequests(Player p){
|
public static void chooseJoinRequests(Player p){
|
||||||
List<SWListInv.SWListEntry<Player>> players = JoinRequest.openRequests(p, Fight.getPlayerTeam(p));
|
List<SWListInv.SWListEntry<JoinRequest>> players = JoinRequest.openRequests(p, Fight.getPlayerTeam(p));
|
||||||
SWListInv<Player> inv = new SWListInv<>(p, msg.parse("REQUESTS_TITLE", p), players, (ClickType click, Player player) -> {
|
SWListInv<JoinRequest> inv = new SWListInv<>(p, msg.parse("REQUESTS_TITLE", p), players, (ClickType click, JoinRequest request) -> {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
RequestsCommand.onJoinRequest(p, player, click.isLeftClick() ? JoinRequest::accept : JoinRequest::decline);
|
RequestsCommand.onJoinRequest(p, request, click.isLeftClick() ? JoinRequest::accept : JoinRequest::decline);
|
||||||
});
|
});
|
||||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
inv.open();
|
inv.open();
|
||||||
|
|||||||
+1
-7
@@ -59,13 +59,7 @@ public class RequestsCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onJoinRequest(Player player, Player target, BiConsumer<JoinRequest, FightTeam> handleJoinRequest) {
|
public static void onJoinRequest(Player player, JoinRequest request, BiConsumer<JoinRequest, FightTeam> handleJoinRequest) {
|
||||||
JoinRequest request = JoinRequest.get(target);
|
|
||||||
if(request == null) {
|
|
||||||
FightSystem.getMessage().send("NO_JOIN_REQUEST", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FightTeam team = Fight.getPlayerTeam(player);
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
if(!request.required(team)) {
|
if(!request.required(team)) {
|
||||||
FightSystem.getMessage().send("NO_CONFIRMATION", player);
|
FightSystem.getMessage().send("NO_CONFIRMATION", player);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import de.steamwar.fightsystem.utils.WorldeditWrapper;
|
|||||||
import de.steamwar.sql.SchematicData;
|
import de.steamwar.sql.SchematicData;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -52,6 +53,7 @@ public class FightSchematic extends StateDependent {
|
|||||||
private final Region region;
|
private final Region region;
|
||||||
private final boolean rotate;
|
private final boolean rotate;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private Clipboard clipboard = null;
|
private Clipboard clipboard = null;
|
||||||
private int schematic = 0;
|
private int schematic = 0;
|
||||||
|
|
||||||
@@ -137,6 +139,7 @@ public class FightSchematic extends StateDependent {
|
|||||||
private void paste(){
|
private void paste(){
|
||||||
FreezeWorld freezer = new FreezeWorld();
|
FreezeWorld freezer = new FreezeWorld();
|
||||||
|
|
||||||
|
team.teleportToSpawn();
|
||||||
Vector dims = WorldeditWrapper.impl.getDimensions(clipboard);
|
Vector dims = WorldeditWrapper.impl.getDimensions(clipboard);
|
||||||
WorldeditWrapper.impl.pasteClipboard(
|
WorldeditWrapper.impl.pasteClipboard(
|
||||||
clipboard,
|
clipboard,
|
||||||
@@ -149,11 +152,11 @@ public class FightSchematic extends StateDependent {
|
|||||||
new AffineTransform().rotateY(rotate ? 180 : 0)
|
new AffineTransform().rotateY(rotate ? 180 : 0)
|
||||||
);
|
);
|
||||||
FightSystem.getHullHider().initialize(team);
|
FightSystem.getHullHider().initialize(team);
|
||||||
|
team.getPlayers().forEach(fightPlayer -> fightPlayer.ifAI(ai -> ai.schematic(clipboard)));
|
||||||
if(ArenaMode.Check.contains(Config.mode) && !team.isBlue())
|
if(ArenaMode.Check.contains(Config.mode) && !team.isBlue())
|
||||||
replaceSync(Material.TNT, Material.OBSIDIAN);
|
replaceSync(Material.TNT, Material.RED_WOOL);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), freezer::disable, 3);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), freezer::disable, 3);
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ 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.ai.AIManager;
|
||||||
import de.steamwar.fightsystem.commands.GUI;
|
import de.steamwar.fightsystem.commands.GUI;
|
||||||
import de.steamwar.fightsystem.countdown.Countdown;
|
import de.steamwar.fightsystem.countdown.Countdown;
|
||||||
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
||||||
@@ -70,9 +71,11 @@ public class FightTeam {
|
|||||||
static {
|
static {
|
||||||
setKitButton(notReadyKit, true);
|
setKitButton(notReadyKit, true);
|
||||||
|
|
||||||
if(!ArenaMode.RankedEvent.contains(Config.mode)){
|
if(ArenaMode.VariableTeams.contains(Config.mode)){
|
||||||
notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).build(), GUI::chooseJoinRequests);
|
notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).build(), GUI::chooseJoinRequests);
|
||||||
notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).build(), GUI::chooseRemove);
|
notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).build(), GUI::chooseRemove);
|
||||||
|
if(!AIManager.availableAIs().isEmpty())
|
||||||
|
notReadyKit.setItem(6, "ADD_AI", new ItemBuilder(Material.REDSTONE).build(), GUI::addAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.test())
|
if(Config.test())
|
||||||
@@ -452,6 +455,10 @@ public class FightTeam {
|
|||||||
return schematic.getId();
|
return schematic.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Clipboard getClipboard() {
|
||||||
|
return schematic.getClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
public double getCurrentHearts() {
|
public double getCurrentHearts() {
|
||||||
return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getEntity().getHealth()).sum();
|
return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getEntity().getHealth()).sum();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.fightsystem.fight;
|
package de.steamwar.fightsystem.fight;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.ai.AIManager;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
@@ -28,44 +29,66 @@ import net.md_5.bungee.api.chat.ClickEvent;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class JoinRequest {
|
public class JoinRequest {
|
||||||
|
|
||||||
private static final Map<Player, JoinRequest> activeRequests = new HashMap<>();
|
private static final Map<Player, JoinRequest> playerRequests = new HashMap<>();
|
||||||
|
private static final List<JoinRequest> activeRequests = new ArrayList<>();
|
||||||
|
public static JoinRequest get(Player player) {
|
||||||
|
return playerRequests.get(player);
|
||||||
|
}
|
||||||
|
|
||||||
public static List<SWListInv.SWListEntry<Player>> openRequests(Player p, FightTeam team) {
|
public static List<SWListInv.SWListEntry<JoinRequest>> openRequests(Player p, FightTeam team) {
|
||||||
return activeRequests.values().stream().filter(
|
return activeRequests.stream().filter(
|
||||||
request -> request.waitOnApproval.contains(team)
|
request -> request.waitOnApproval.contains(team)
|
||||||
).map(request -> {
|
).map(request -> {
|
||||||
SWItem item = SWItem.getPlayerSkull(request.player);
|
AtomicReference<SWItem> item = new AtomicReference<>();
|
||||||
item.setLore(Arrays.asList(
|
request.enquirer.ifPlayer(player -> item.set(SWItem.getPlayerSkull(player)));
|
||||||
|
request.enquirer.ifAI(manager -> item.set(new SWItem(manager.getIcon(), manager.name())));
|
||||||
|
item.get().setLore(Arrays.asList(
|
||||||
FightSystem.getMessage().parse("REQUESTS_LEFT_CLICK", p),
|
FightSystem.getMessage().parse("REQUESTS_LEFT_CLICK", p),
|
||||||
FightSystem.getMessage().parse("REQUESTS_RIGHT_CLICK", p)
|
FightSystem.getMessage().parse("REQUESTS_RIGHT_CLICK", p)
|
||||||
));
|
));
|
||||||
return new SWListInv.SWListEntry<>(item, request.player);
|
return new SWListInv.SWListEntry<>(item.get(), request);
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearRequests() {
|
public static void clearRequests() {
|
||||||
|
playerRequests.clear();
|
||||||
activeRequests.clear();
|
activeRequests.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JoinRequest get(Player player) {
|
public static void forPlayer(Player player, FightTeam team) {
|
||||||
return activeRequests.get(player);
|
new JoinRequest(new Enquirer() {
|
||||||
|
@Override public String name() { return player.getName(); }
|
||||||
|
@Override public void ifPlayer(Consumer<Player> function) { function.accept(player); }
|
||||||
|
@Override public void ifAI(Consumer<AIManager> function) {}
|
||||||
|
}, team, FightState.ingame() ? Fight.teams() : Collections.singleton(team));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Player player;
|
public static void forAI(AIManager manager, FightTeam team) {
|
||||||
|
new JoinRequest(new Enquirer() {
|
||||||
|
@Override public String name() { return manager.name(); }
|
||||||
|
@Override public void ifPlayer(Consumer<Player> function) {}
|
||||||
|
@Override public void ifAI(Consumer<AIManager> function) { function.accept(manager); }
|
||||||
|
}, team, Collections.singleton(Fight.getOpposite(team)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Enquirer enquirer;
|
||||||
private final FightTeam team;
|
private final FightTeam team;
|
||||||
private final Set<FightTeam> waitOnApproval;
|
private final Set<FightTeam> waitOnApproval;
|
||||||
|
|
||||||
public JoinRequest(Player player, FightTeam team) {
|
private JoinRequest(Enquirer enquirer, FightTeam team, Collection<FightTeam> waitOnApproval) {
|
||||||
this.player = player;
|
this.enquirer = enquirer;
|
||||||
this.team = team;
|
this.team = team;
|
||||||
this.waitOnApproval = new HashSet<>(FightState.ingame() ? Fight.teams() : Collections.singleton(team));
|
this.waitOnApproval = new HashSet<>(waitOnApproval);
|
||||||
Set<FightTeam> alreadyAccepted = new HashSet<>();
|
Set<FightTeam> alreadyAccepted = new HashSet<>();
|
||||||
|
|
||||||
activeRequests.put(player, this);
|
enquirer.ifPlayer(player -> playerRequests.put(player, this));
|
||||||
|
activeRequests.add(this);
|
||||||
for(FightTeam t : waitOnApproval) {
|
for(FightTeam t : waitOnApproval) {
|
||||||
FightPlayer leader = t.getLeader();
|
FightPlayer leader = t.getLeader();
|
||||||
if(leader == null)
|
if(leader == null)
|
||||||
@@ -74,14 +97,14 @@ public class JoinRequest {
|
|||||||
if(leader.getEntity() == null)
|
if(leader.getEntity() == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
leader.ifPlayer(leaderPlayer -> FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_NOTIFICATION", leaderPlayer, "REQUESTS", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/requests"), player.getName(), team.getColoredName()));
|
leader.ifPlayer(leaderPlayer -> FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_NOTIFICATION", leaderPlayer, "REQUESTS", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/requests"), enquirer.name(), team.getColoredName()));
|
||||||
leader.ifAI(ai -> {
|
leader.ifAI(ai -> {
|
||||||
if(ai.acceptJoinRequest(player, team))
|
if(ai.acceptJoinRequest(enquirer, team))
|
||||||
alreadyAccepted.add(t);
|
alreadyAccepted.add(t);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_CONFIRMATION", player, ChatMessageType.ACTION_BAR);
|
enquirer.ifPlayer(player -> FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_CONFIRMATION", player, ChatMessageType.ACTION_BAR));
|
||||||
alreadyAccepted.forEach(this::accept);
|
alreadyAccepted.forEach(this::accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,18 +116,26 @@ public class JoinRequest {
|
|||||||
waitOnApproval.remove(acceptor);
|
waitOnApproval.remove(acceptor);
|
||||||
|
|
||||||
if(waitOnApproval.isEmpty()) {
|
if(waitOnApproval.isEmpty()) {
|
||||||
team.addMember(player);
|
enquirer.ifPlayer(team::addMember);
|
||||||
activeRequests.remove(player);
|
enquirer.ifAI(manager -> manager.join(team));
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decline(FightTeam declinor) {
|
public void decline(FightTeam declinor) {
|
||||||
FightSystem.getMessage().sendPrefixless("REQUEST_YOUR_DECLINED", player, ChatMessageType.ACTION_BAR);
|
enquirer.ifPlayer(player -> FightSystem.getMessage().sendPrefixless("REQUEST_YOUR_DECLINED", player, ChatMessageType.ACTION_BAR));
|
||||||
waitOnApproval.forEach(t -> t.broadcast("REQUEST_DECLINED", player.getName()));
|
waitOnApproval.forEach(t -> t.broadcast("REQUEST_DECLINED", enquirer.name()));
|
||||||
silentDecline();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void silentDecline() {
|
public void close() {
|
||||||
activeRequests.remove(player);
|
enquirer.ifPlayer(playerRequests::remove);
|
||||||
|
activeRequests.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Enquirer {
|
||||||
|
String name();
|
||||||
|
void ifPlayer(Consumer<Player> function);
|
||||||
|
void ifAI(Consumer<AIManager> function);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -69,6 +69,6 @@ public class JoinRequestListener implements Listener {
|
|||||||
public void onLeave(PlayerQuitEvent event) {
|
public void onLeave(PlayerQuitEvent event) {
|
||||||
JoinRequest request = JoinRequest.get(event.getPlayer());
|
JoinRequest request = JoinRequest.get(event.getPlayer());
|
||||||
if(request != null)
|
if(request != null)
|
||||||
request.silentDecline();
|
request.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@@ -70,7 +71,7 @@ public class Recording implements Listener {
|
|||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNotSent(Player p){
|
public static boolean isNotSent(LivingEntity p){
|
||||||
FightPlayer fp = Fight.getFightPlayer(p);
|
FightPlayer fp = Fight.getFightPlayer(p);
|
||||||
return fp == null || !fp.isLiving() || FightState.getFightState() == FightState.SPECTATE;
|
return fp == null || !fp.isLiving() || FightState.getFightState() == FightState.SPECTATE;
|
||||||
}
|
}
|
||||||
@@ -193,10 +194,10 @@ public class Recording implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onEntityDamage(EntityDamageEvent e) {
|
public void onEntityDamage(EntityDamageEvent e) {
|
||||||
if(e.getEntityType() != EntityType.PLAYER)
|
if(!e.getEntityType().isAlive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player p = (Player) e.getEntity();
|
LivingEntity p = (LivingEntity) e.getEntity();
|
||||||
if(isNotSent(p))
|
if(isNotSent(p))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -208,10 +209,10 @@ public class Recording implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onEntityCombust(EntityCombustEvent e) {
|
public void onEntityCombust(EntityCombustEvent e) {
|
||||||
if(e.getEntityType() != EntityType.PLAYER)
|
if(!e.getEntityType().isAlive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player p = (Player) e.getEntity();
|
LivingEntity p = (LivingEntity) e.getEntity();
|
||||||
if(isNotSent(p))
|
if(isNotSent(p))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ public interface Recorder {
|
|||||||
write(0x0a, e.getEntityId(), start, offHand);
|
write(0x0a, e.getEntityId(), start, offHand);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void damageAnimation(Player p) {
|
default void damageAnimation(LivingEntity p) {
|
||||||
write(0x0b, p.getEntityId());
|
write(0x0b, p.getEntityId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,4 +32,6 @@ tasks.shadowJar {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(libs.paperapi21)
|
compileOnly(libs.paperapi21)
|
||||||
|
compileOnly(libs.nms21)
|
||||||
|
compileOnly(project(":SpigotCore"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.kotlin
|
package de.steamwar.kotlin
|
||||||
|
|
||||||
|
import de.steamwar.kotlin.message.LanguageListener
|
||||||
import org.bukkit.plugin.java.JavaPlugin
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
|
||||||
class KotlinCore : JavaPlugin() {
|
class KotlinCore : JavaPlugin() {
|
||||||
@@ -32,6 +33,7 @@ class KotlinCore : JavaPlugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onEnable() {
|
override fun onEnable() {
|
||||||
|
server.pluginManager.registerEvents(LanguageListener, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDisable() {
|
override fun onDisable() {
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.kotlin.message
|
||||||
|
|
||||||
|
import net.kyori.adventure.key.Key
|
||||||
|
import net.kyori.adventure.translation.GlobalTranslator
|
||||||
|
import net.kyori.adventure.translation.Translator
|
||||||
|
import java.text.MessageFormat
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class ComponentMessage(private val resourceBundleName: String, private val classLoader: ClassLoader) : Translator {
|
||||||
|
init {
|
||||||
|
GlobalTranslator.translator().addSource(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun name(): Key = Key.key("steamwar", resourceBundleName)
|
||||||
|
|
||||||
|
override fun translate(key: String, locale: Locale): MessageFormat = MessageFormat(ResourceBundle.getBundle(resourceBundleName, locale, classLoader).getString(key), locale)
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.kotlin.message
|
||||||
|
|
||||||
|
import de.steamwar.kotlin.KotlinCore
|
||||||
|
import de.steamwar.sql.SteamwarUser
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent
|
||||||
|
import org.bukkit.event.player.PlayerLocaleChangeEvent
|
||||||
|
|
||||||
|
object LanguageListener: Listener {
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
|
fun onPlayerJoin(event: PlayerJoinEvent) {
|
||||||
|
val user = SteamwarUser.get(event.player.uniqueId)
|
||||||
|
val player = event.player as CraftPlayer
|
||||||
|
player.handle.`adventure$locale` = user.locale
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
fun onPlayerConfig(event: PlayerLocaleChangeEvent) {
|
||||||
|
Bukkit.getScheduler().runTask(KotlinCore.plugin, Runnable {
|
||||||
|
val user = SteamwarUser.get(event.player.uniqueId)
|
||||||
|
val player = event.player as CraftPlayer
|
||||||
|
player.handle.`adventure$locale` = user.locale
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,7 +27,7 @@ java {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,12 @@ DATE=........
|
|||||||
COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
|
COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
|
||||||
|
|
||||||
# ServerTeamNPC's
|
# ServerTeamNPC's
|
||||||
NPC_CHAT_1 = §fHello, I''m {0} and I''m a(n) {1}§f.
|
NPC_CHAT_0 = §fHello, I''m {0} and I''m a(n) {1}§f.
|
||||||
NPC_CHAT_2 = §fWelcome on §eSteam§8War§f, have fun.
|
NPC_CHAT_1 = §fWelcome on §eSteam§8War§f, have fun.
|
||||||
|
NPC_CHAT_2 = §eSteam§8War§f was established in 2019.
|
||||||
|
NPC_CHAT_3 = &fBecome a part of our team by applying via our Discord server (https://steamwar.de/discord).
|
||||||
|
NPC_CHAT_4 = &fYou can develop your own buildserver features with our Lua script system.
|
||||||
|
NPC_CHAT_5 = &fThere are many secrets to discover in this lobby.
|
||||||
|
|
||||||
# Portal Command
|
# Portal Command
|
||||||
PORTAL_COMMAND_LIST_HELP = §8/§7portal §elist §8- §7Lists all portals
|
PORTAL_COMMAND_LIST_HELP = §8/§7portal §elist §8- §7Lists all portals
|
||||||
|
|||||||
@@ -4,8 +4,12 @@ DATE=........
|
|||||||
COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
|
COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
|
||||||
|
|
||||||
# ServerTeamNPC's
|
# ServerTeamNPC's
|
||||||
NPC_CHAT_1 = §fHallo, ich bin {0} und bin ein {1}§f.
|
NPC_CHAT_0 = §fHallo, ich bin {0} und bin ein {1}§f.
|
||||||
NPC_CHAT_2 = §fWillkommen auf §eSteam§8War§f, viel Spaß dir.
|
NPC_CHAT_1 = §fWillkommen auf §eSteam§8War§f, viel Spaß dir.
|
||||||
|
NPC_CHAT_2 = §eSteam§8War§f gibt es seit 2019.
|
||||||
|
NPC_CHAT_3 = &fBewerbe dich gerne für unser Team über unseren Discord-Server (https://steamwar.de/discord).
|
||||||
|
NPC_CHAT_4 = &fDu kannst mit unserm Lua Script-System deine eigenen Bau Features programmieren.
|
||||||
|
NPC_CHAT_5 = &fAuf dieser Lobby sind so einige secrets versteckt.
|
||||||
|
|
||||||
# Portal Command
|
# Portal Command
|
||||||
PORTAL_COMMAND_LIST_HELP = §8/§7portal §elist §8- §7Listet alle Portale auf
|
PORTAL_COMMAND_LIST_HELP = §8/§7portal §elist §8- §7Listet alle Portale auf
|
||||||
|
|||||||
@@ -222,11 +222,13 @@ public class FightserverPortal implements PortalHandler, Comparable<FightserverP
|
|||||||
case "PRE_SCHEM_SETUP":
|
case "PRE_SCHEM_SETUP":
|
||||||
return "Schemauswahl";
|
return "Schemauswahl";
|
||||||
case "POST_SCHEM_SETUP":
|
case "POST_SCHEM_SETUP":
|
||||||
|
case "generating_tower":
|
||||||
return "Vorbereitung";
|
return "Vorbereitung";
|
||||||
case "PRE_RUNNING":
|
case "PRE_RUNNING":
|
||||||
return "Kampfbeginn in";
|
return "Kampfbeginn in";
|
||||||
case "fighting":
|
case "fighting":
|
||||||
case "RUNNING":
|
case "RUNNING":
|
||||||
|
case "running":
|
||||||
return "Kampf läuft";
|
return "Kampf läuft";
|
||||||
case "end":
|
case "end":
|
||||||
case "SPECTATE":
|
case "SPECTATE":
|
||||||
|
|||||||
@@ -60,11 +60,6 @@ public class TeamPlayer extends BasicListener {
|
|||||||
private Set<Player> players = new HashSet<>();
|
private Set<Player> players = new HashSet<>();
|
||||||
|
|
||||||
private Random random = new Random();
|
private Random random = new Random();
|
||||||
private List<String> strings = new ArrayList<>();
|
|
||||||
{
|
|
||||||
strings.add("NPC_CHAT_1");
|
|
||||||
strings.add("NPC_CHAT_2");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void spawnTeamPlayer(World world, SteamwarUser steamwarUser) {
|
public static void spawnTeamPlayer(World world, SteamwarUser steamwarUser) {
|
||||||
Location location = new Location(world, 2790.5, 69, 1311.5);
|
Location location = new Location(world, 2790.5, 69, 1311.5);
|
||||||
@@ -149,8 +144,9 @@ public class TeamPlayer extends BasicListener {
|
|||||||
players.remove(event.getPlayer());
|
players.remove(event.getPlayer());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String message = "NPC_Chat_" + random.nextInt(6);
|
||||||
SteamwarUser user = SteamwarUser.get(event.getRightClicked().getName());
|
SteamwarUser user = SteamwarUser.get(event.getRightClicked().getName());
|
||||||
String message = strings.get(random.nextInt(strings.size()));
|
|
||||||
UserPerm.Prefix prefix = user.prefix();
|
UserPerm.Prefix prefix = user.prefix();
|
||||||
LobbySystem.getMessage().send(message, event.getPlayer(), event.getRightClicked().getName(), prefix.getColorCode() + prefix.getChatPrefix());
|
LobbySystem.getMessage().send(message, event.getPlayer(), event.getRightClicked().getName(), prefix.getColorCode() + prefix.getChatPrefix());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ java {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
compileOnly(project(":SchematicSystem:SchematicSystem_Core"))
|
compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms15)
|
compileOnly(libs.nms15)
|
||||||
compileOnly(libs.worldedit15)
|
compileOnly(libs.worldedit15)
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
compileOnly(project(":SchematicSystem:SchematicSystem_Core"))
|
compileOnly(project(":SchematicSystem:SchematicSystem_Core", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms8)
|
compileOnly(libs.nms8)
|
||||||
compileOnly(libs.worldedit12)
|
compileOnly(libs.worldedit12)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
compileOnly(libs.worldedit15)
|
compileOnly(libs.worldedit15)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_Main"))
|
compileOnly(project(":SpigotCore:SpigotCore_Main", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms10)
|
compileOnly(libs.nms10)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":CommonCore"))
|
compileOnly(project(":CommonCore", "default"))
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_Main"))
|
compileOnly(project(":SpigotCore:SpigotCore_Main", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms12)
|
compileOnly(libs.nms12)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":CommonCore"))
|
compileOnly(project(":CommonCore", "default"))
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_Main"))
|
compileOnly(project(":SpigotCore:SpigotCore_Main", "default"))
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_8"))
|
compileOnly(project(":SpigotCore:SpigotCore_8", "default"))
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_9"))
|
compileOnly(project(":SpigotCore:SpigotCore_9", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms14)
|
compileOnly(libs.nms14)
|
||||||
compileOnly(libs.worldedit15)
|
compileOnly(libs.worldedit15)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_Main"))
|
compileOnly(project(":SpigotCore:SpigotCore_Main", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms15)
|
compileOnly(libs.nms15)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ tasks.compileJava {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":CommonCore"))
|
compileOnly(project(":CommonCore", "default"))
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_Main"))
|
compileOnly(project(":SpigotCore:SpigotCore_Main", "default"))
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_14"))
|
compileOnly(project(":SpigotCore:SpigotCore_14", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
compileOnly(libs.nms18)
|
compileOnly(libs.nms18)
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_Main"))
|
compileOnly(project(":SpigotCore:SpigotCore_Main", "default"))
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_14"))
|
compileOnly(project(":SpigotCore:SpigotCore_14", "default"))
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_18"))
|
compileOnly(project(":SpigotCore:SpigotCore_18", "default"))
|
||||||
|
|
||||||
compileOnly(libs.worldedit15)
|
compileOnly(libs.worldedit15)
|
||||||
compileOnly(libs.nms19)
|
compileOnly(libs.nms19)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_Main"))
|
compileOnly(project(":SpigotCore:SpigotCore_Main", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":CommonCore"))
|
compileOnly(project(":CommonCore", "default"))
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_Main"))
|
compileOnly(project(":SpigotCore:SpigotCore_Main", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms8)
|
compileOnly(libs.nms8)
|
||||||
compileOnly(libs.worldedit12)
|
compileOnly(libs.worldedit12)
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_Main"))
|
compileOnly(project(":SpigotCore:SpigotCore_Main", "default"))
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_8"))
|
compileOnly(project(":SpigotCore:SpigotCore_8", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms9)
|
compileOnly(libs.nms9)
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ tasks.compileJava {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":CommonCore"))
|
compileOnly(project(":CommonCore", "default"))
|
||||||
compileOnly(project(":CommandFramework"))
|
compileOnly(project(":CommandFramework", "default"))
|
||||||
compileOnly(project(":SpigotCore:CRIUDummy"))
|
compileOnly(project(":SpigotCore:CRIUDummy", "default"))
|
||||||
|
|
||||||
compileOnly(libs.worldedit12)
|
compileOnly(libs.worldedit12)
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.bukkit.event.server.PluginDisableEvent;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@@ -102,7 +103,7 @@ public class TinyProtocol implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addFilter(Class<?> packetType, BiFunction<Player, Object, Object> filter) {
|
public void addFilter(Class<?> packetType, BiFunction<Player, Object, Object> filter) {
|
||||||
packetFilters.computeIfAbsent(packetType, c -> Collections.synchronizedList(new ArrayList<>(1))).add(filter);
|
packetFilters.computeIfAbsent(packetType, c -> new CopyOnWriteArrayList<>()).add(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeFilter(Class<?> packetType, BiFunction<Player, Object, Object> filter) {
|
public void removeFilter(Class<?> packetType, BiFunction<Player, Object, Object> filter) {
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ plugins {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(libs.paperapi21)
|
compileOnly(libs.paperapi21)
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
compileOnly(project(":KotlinCore"))
|
compileOnly(project(":KotlinCore", "default"))
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ dependencies {
|
|||||||
annotationProcessor(libs.spigotannotations)
|
annotationProcessor(libs.spigotannotations)
|
||||||
compileOnly(libs.spigotannotations)
|
compileOnly(libs.spigotannotations)
|
||||||
|
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms19)
|
compileOnly(libs.nms19)
|
||||||
compileOnly(libs.worldedit15)
|
compileOnly(libs.worldedit15)
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
* /
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.towerrun;
|
||||||
|
|
||||||
|
import de.steamwar.network.NetworkSender;
|
||||||
|
import de.steamwar.network.packets.common.FightInfoPacket;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import de.steamwar.towerrun.config.Config;
|
||||||
|
import de.steamwar.towerrun.game.TowerRunGame;
|
||||||
|
import de.steamwar.towerrun.state.GameState;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class FightInfoPacketSender implements Runnable {
|
||||||
|
|
||||||
|
private final World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
|
private final String serverName = Bukkit.getServer().getName();
|
||||||
|
private final String gameMode = "towerrun";
|
||||||
|
private final String worldName = world.getName();
|
||||||
|
private final String blueName = "§3Escaped";
|
||||||
|
private final String redName = "§cAlive";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (Config.test()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Integer> alivePlayers = TowerRunGame.PLAYERS_ALIVE.stream().map(player -> SteamwarUser.get(player.player().getUniqueId()).getId()).collect(Collectors.toList());
|
||||||
|
List<Integer> escapedPlayers = TowerRunGame.PLAYERS_ESCAPED.stream().map(player -> SteamwarUser.get(player.player().getUniqueId()).getId()).collect(Collectors.toList());
|
||||||
|
List<Integer> spectatorPlayers = new ArrayList<>();
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
int id = SteamwarUser.get(player.getUniqueId()).getId();
|
||||||
|
if (!alivePlayers.contains(id) && !escapedPlayers.contains(id)) {
|
||||||
|
spectatorPlayers.add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkSender.send(new FightInfoPacket(serverName, gameMode, worldName, blueName, redName, GameState.getCurrentState().name().toLowerCase(), TowerRun.getGameCountdown().getPlayTimeInSeconds(), 0, 0, 0, 0, escapedPlayers, alivePlayers, spectatorPlayers));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,7 @@ import de.steamwar.towerrun.listener.IngameListener;
|
|||||||
import de.steamwar.towerrun.listener.LobbyListener;
|
import de.steamwar.towerrun.listener.LobbyListener;
|
||||||
import de.steamwar.towerrun.listener.NotLobbyListener;
|
import de.steamwar.towerrun.listener.NotLobbyListener;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.plugin.java.annotation.dependency.Dependency;
|
import org.bukkit.plugin.java.annotation.dependency.Dependency;
|
||||||
import org.bukkit.plugin.java.annotation.plugin.ApiVersion;
|
import org.bukkit.plugin.java.annotation.plugin.ApiVersion;
|
||||||
@@ -79,6 +80,8 @@ public class TowerRun extends JavaPlugin {
|
|||||||
new StartCommand(lobbyCountdown);
|
new StartCommand(lobbyCountdown);
|
||||||
gameCountdown = new GameCountdown();
|
gameCountdown = new GameCountdown();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskTimer(this, new FightInfoPacketSender(), 20, 20);
|
||||||
|
|
||||||
TowerRunGame.reset();
|
TowerRunGame.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ public class Config {
|
|||||||
public static final int GAME_TIMER;
|
public static final int GAME_TIMER;
|
||||||
public static final int GAME_ESCAPE_TIMER;
|
public static final int GAME_ESCAPE_TIMER;
|
||||||
|
|
||||||
|
private static final int EVENT_KAMPF_ID;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
File configFile = new File(TowerRun.getInstance().getDataFolder(), "config.yml");
|
File configFile = new File(TowerRun.getInstance().getDataFolder(), "config.yml");
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
@@ -53,6 +55,11 @@ public class Config {
|
|||||||
GAME_TIMER = config.getInt("gameTimer", 20 * 60);
|
GAME_TIMER = config.getInt("gameTimer", 20 * 60);
|
||||||
GAME_ESCAPE_TIMER = config.getInt("gameEscapeTimer", 60);
|
GAME_ESCAPE_TIMER = config.getInt("gameEscapeTimer", 60);
|
||||||
DESTROYABLE_BLOCKS = EnumSet.copyOf(config.getStringList("destroyable").stream().map(Material::valueOf).collect(Collectors.toSet()));
|
DESTROYABLE_BLOCKS = EnumSet.copyOf(config.getStringList("destroyable").stream().map(Material::valueOf).collect(Collectors.toSet()));
|
||||||
|
|
||||||
|
EVENT_KAMPF_ID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean test() {
|
||||||
|
return EVENT_KAMPF_ID == -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class EndCountdown extends Countdown {
|
|||||||
private static final boolean RESETS = Objects.requireNonNull(Bukkit.getWorlds().get(0).getWorldFolder().list((dir, name) -> name.equals("backup"))).length > 0;
|
private static final boolean RESETS = Objects.requireNonNull(Bukkit.getWorlds().get(0).getWorldFolder().list((dir, name) -> name.equals("backup"))).length > 0;
|
||||||
|
|
||||||
public EndCountdown(LobbyCountdown lobbyCountdown) {
|
public EndCountdown(LobbyCountdown lobbyCountdown) {
|
||||||
super(EnumSet.of(GameStates.ENDING));
|
super(EnumSet.of(GameStates.END));
|
||||||
this.lobbyCountdown = lobbyCountdown;
|
this.lobbyCountdown = lobbyCountdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,10 @@ import java.util.EnumSet;
|
|||||||
|
|
||||||
public class GameCountdown extends Countdown {
|
public class GameCountdown extends Countdown {
|
||||||
|
|
||||||
|
private long startTime = 0;
|
||||||
|
|
||||||
public GameCountdown() {
|
public GameCountdown() {
|
||||||
super(EnumSet.of(GameStates.INGAME));
|
super(EnumSet.of(GameStates.RUNNING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -59,9 +61,21 @@ public class GameCountdown extends Countdown {
|
|||||||
TowerRun.getMessage().broadcastActionbar("GAME_TIME", String.format("%02d", timeMinutes), String.format("%02d", timeSeconds));
|
TowerRun.getMessage().broadcastActionbar("GAME_TIME", String.format("%02d", timeMinutes), String.format("%02d", timeSeconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
super.enable();
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
super.disable();
|
super.disable();
|
||||||
setTime(defaultTime());
|
setTime(defaultTime());
|
||||||
|
startTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlayTimeInSeconds() {
|
||||||
|
if (startTime == 0) return 0;
|
||||||
|
return (int) ((System.currentTimeMillis() - startTime) / 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class LobbyCountdown extends Countdown {
|
|||||||
private boolean override = false;
|
private boolean override = false;
|
||||||
|
|
||||||
public LobbyCountdown() {
|
public LobbyCountdown() {
|
||||||
super(EnumSet.of(GameStates.LOBBY));
|
super(EnumSet.of(GameStates.WAITING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class TowerRunGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void prepareTowerOrStart() {
|
public static void prepareTowerOrStart() {
|
||||||
if (GameState.getCurrentState() == GameStates.LOBBY) {
|
if (GameState.getCurrentState() == GameStates.WAITING) {
|
||||||
GameState.nextState();
|
GameState.nextState();
|
||||||
if (TowerRun.getTowerGenerator() == null) {
|
if (TowerRun.getTowerGenerator() == null) {
|
||||||
start();
|
start();
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class IngameListener extends GameStateBukkitListener {
|
|||||||
private BukkitRunnable antiCampRunnable;
|
private BukkitRunnable antiCampRunnable;
|
||||||
|
|
||||||
public IngameListener() {
|
public IngameListener() {
|
||||||
super(EnumSet.of(GameStates.INGAME));
|
super(EnumSet.of(GameStates.RUNNING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import java.util.EnumSet;
|
|||||||
|
|
||||||
public class LobbyListener extends GameStateBukkitListener {
|
public class LobbyListener extends GameStateBukkitListener {
|
||||||
public LobbyListener() {
|
public LobbyListener() {
|
||||||
super(EnumSet.of(GameStates.LOBBY));
|
super(EnumSet.of(GameStates.WAITING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import java.util.EnumSet;
|
|||||||
|
|
||||||
public class NotLobbyListener extends GameStateBukkitListener {
|
public class NotLobbyListener extends GameStateBukkitListener {
|
||||||
public NotLobbyListener() {
|
public NotLobbyListener() {
|
||||||
super(EnumSet.complementOf(EnumSet.of(GameStates.LOBBY)));
|
super(EnumSet.complementOf(EnumSet.of(GameStates.WAITING)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import java.util.List;
|
|||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class GameState {
|
public class GameState {
|
||||||
@Getter
|
@Getter
|
||||||
private static GameStates currentState = GameStates.LOBBY;
|
private static GameStates currentState = GameStates.WAITING;
|
||||||
private static final List<GameStateListener> gameStateListeners = new ArrayList<>();
|
private static final List<GameStateListener> gameStateListeners = new ArrayList<>();
|
||||||
|
|
||||||
public static void addGameStateListener(GameStateListener gameStateListener) {
|
public static void addGameStateListener(GameStateListener gameStateListener) {
|
||||||
@@ -49,7 +49,7 @@ public class GameState {
|
|||||||
|
|
||||||
public static void reset() {
|
public static void reset() {
|
||||||
final GameStates oldState = currentState;
|
final GameStates oldState = currentState;
|
||||||
currentState = GameStates.LOBBY;
|
currentState = GameStates.WAITING;
|
||||||
gameStateChanges(oldState, currentState);
|
gameStateChanges(oldState, currentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ import lombok.Getter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
public enum GameStates {
|
public enum GameStates {
|
||||||
ENDING(null),
|
END(null),
|
||||||
INGAME(ENDING),
|
RUNNING(END),
|
||||||
GENERATING_TOWER(INGAME),
|
GENERATING_TOWER(RUNNING),
|
||||||
LOBBY(GENERATING_TOWER);
|
WAITING(GENERATING_TOWER);
|
||||||
|
|
||||||
private final GameStates nextState;
|
private final GameStates nextState;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public abstract class WinCondition extends GameStateBukkitListener {
|
|||||||
private boolean active = false;
|
private boolean active = false;
|
||||||
|
|
||||||
protected WinCondition(String name) {
|
protected WinCondition(String name) {
|
||||||
super(EnumSet.of(GameStates.INGAME));
|
super(EnumSet.of(GameStates.RUNNING));
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore"))
|
compileOnly(project(":SpigotCore", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms15)
|
compileOnly(libs.nms15)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ dependencies {
|
|||||||
annotationProcessor(libs.velocityapi)
|
annotationProcessor(libs.velocityapi)
|
||||||
compileOnly(libs.velocity)
|
compileOnly(libs.velocity)
|
||||||
|
|
||||||
compileOnly(project(":VelocityCore:Persistent"))
|
compileOnly(project(":VelocityCore:Persistent", "default"))
|
||||||
|
|
||||||
implementation(project(":CommonCore"))
|
implementation(project(":CommonCore"))
|
||||||
implementation(project(":CommandFramework"))
|
implementation(project(":CommandFramework"))
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
|
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||||
import net.dv8tion.jda.api.requests.restaction.CommandListUpdateAction;
|
import net.dv8tion.jda.api.requests.restaction.CommandListUpdateAction;
|
||||||
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
||||||
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||||
@@ -99,6 +100,7 @@ public class DiscordBot {
|
|||||||
.createDefault(config.getToken())
|
.createDefault(config.getToken())
|
||||||
.setStatus(OnlineStatus.ONLINE)
|
.setStatus(OnlineStatus.ONLINE)
|
||||||
.setMemberCachePolicy(MemberCachePolicy.ONLINE)
|
.setMemberCachePolicy(MemberCachePolicy.ONLINE)
|
||||||
|
.enableIntents(GatewayIntent.MESSAGE_CONTENT)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|||||||
@@ -76,9 +76,9 @@ public class ModUtils {
|
|||||||
String message;
|
String message;
|
||||||
|
|
||||||
if(mods.size() == 1) {
|
if(mods.size() == 1) {
|
||||||
message = sender.parseToLegacy(max == ModType.RED ? "MOD_RED_SING" : "MOD_YELLOW_SING", locale, modList);
|
message = sender.parseToLegacy(max == ModType.RED ? "MOD_RED_SING" : "MOD_YELLOW_SING", modList);
|
||||||
} else {
|
} else {
|
||||||
message = sender.parseToLegacy(max == ModType.RED ? "MOD_RED_PLUR" : "MOD_YELLOW_PLUR", locale, modList);
|
message = sender.parseToLegacy(max == ModType.RED ? "MOD_RED_PLUR" : "MOD_YELLOW_PLUR", modList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(max == ModType.RED) {
|
if(max == ModType.RED) {
|
||||||
|
|||||||
+2
-1
@@ -107,7 +107,7 @@ dependencyResolutionManagement {
|
|||||||
library("netty", "io.netty:netty-all:4.1.68.Final")
|
library("netty", "io.netty:netty-all:4.1.68.Final")
|
||||||
library("junit", "junit:junit:4.13.2")
|
library("junit", "junit:junit:4.13.2")
|
||||||
library("hamcrest", "org.hamcrest:hamcrest:2.2")
|
library("hamcrest", "org.hamcrest:hamcrest:2.2")
|
||||||
library("jda", "net.dv8tion:JDA:5.0.2")
|
library("jda", "net.dv8tion:JDA:5.2.0")
|
||||||
library("msgpack", "org.msgpack:msgpack-core:0.9.8")
|
library("msgpack", "org.msgpack:msgpack-core:0.9.8")
|
||||||
library("classindex", "org.atteo.classindex:classindex:3.13")
|
library("classindex", "org.atteo.classindex:classindex:3.13")
|
||||||
|
|
||||||
@@ -130,6 +130,7 @@ dependencyResolutionManagement {
|
|||||||
library("nms18", "de.steamwar:spigot:1.18")
|
library("nms18", "de.steamwar:spigot:1.18")
|
||||||
library("nms19", "de.steamwar:spigot:1.19")
|
library("nms19", "de.steamwar:spigot:1.19")
|
||||||
library("nms20", "de.steamwar:spigot:1.20")
|
library("nms20", "de.steamwar:spigot:1.20")
|
||||||
|
library("nms21", "de.steamwar:spigot:1.21")
|
||||||
|
|
||||||
library("axiom", "de.steamwar:axiompaper:RELEASE")
|
library("axiom", "de.steamwar:axiompaper:RELEASE")
|
||||||
library("worldedit12", "de.steamwar:worldedit:1.12")
|
library("worldedit12", "de.steamwar:worldedit:1.12")
|
||||||
|
|||||||
Reference in New Issue
Block a user