SteamWar/FightSystem
Archiviert
13
1

AI API
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2023-08-29 13:45:46 +02:00
Ursprung d7b63841a1
Commit 1cc247f6dd
12 geänderte Dateien mit 252 neuen und 110 gelöschten Zeilen

Datei anzeigen

@ -32,7 +32,10 @@ import de.steamwar.fightsystem.fight.FightWorld;
import de.steamwar.fightsystem.fight.HotbarKit;
import de.steamwar.fightsystem.listener.Shutdown;
import de.steamwar.fightsystem.listener.*;
import de.steamwar.fightsystem.record.*;
import de.steamwar.fightsystem.record.FileRecorder;
import de.steamwar.fightsystem.record.FileSource;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.record.LiveRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.utils.*;
@ -106,7 +109,7 @@ public class FightSystem extends JavaPlugin {
techHider = new TechHiderWrapper();
new FightWorld();
new FightUI();
//new FightStatistics();
new FightStatistics();
new BungeeFightInfo();
new WinconditionAllDead();
@ -164,8 +167,6 @@ public class FightSystem extends JavaPlugin {
}else if(Config.mode == ArenaMode.PREPARE) {
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID));
}
new LixfelAI(Fight.getBlueTeam());
}
@Override

Datei anzeigen

@ -19,29 +19,46 @@
package de.steamwar.fightsystem.ai;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.listener.Chat;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Note;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Openable;
import org.bukkit.block.data.Powerable;
import org.bukkit.block.data.type.NoteBlock;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.*;
import java.util.logging.Level;
public abstract class AI {
private static final Map<UUID, AI> ais = new HashMap<>();
static {
new OneShotStateDependent(ArenaMode.All, FightState.Spectate, () -> {
ais.values().forEach(AI::stop);
ais.clear();
});
}
public static AI getAI(UUID uuid) {
return ais.get(uuid);
}
@ -49,20 +66,18 @@ public abstract class AI {
private final FightTeam team;
private final LivingEntity entity;
private final BukkitTask task;
private int cooldown;
private final Queue<Action> queue = new ArrayDeque<>();
private static final Reflection.MethodInvoker getHandle = Reflection.getMethod("{obc}.entity.CraftEntity", "getHandle");
private static final Reflection.FieldAccessor<UUID> entityUUID = Reflection.getField("{nms.world.entity}.Entity", UUID.class, 0);
protected AI(FightTeam team, SteamwarUser user) {
this.team = team;
entity = Config.world.spawn(Config.SpecSpawn, Villager.class, entity -> entityUUID.set(getHandle.invoke(entity), user.getUUID()));
entity = (LivingEntity) Config.world.spawnEntity(Config.SpecSpawn, EntityType.VILLAGER);
entity.setCustomName(user.getUserName());
entity.setAI(false);
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::run, 1, 1);
ais.put(user.getUUID(), this);
team.addMember(entity);
ais.put(entity.getUniqueId(), this);
team.addMember(entity, user);
}
public abstract SchematicNode chooseSchematic();
@ -73,8 +88,11 @@ public abstract class AI {
protected abstract void plan();
public void cleanup() {
ais.remove(entity.getUniqueId());
public void stop() {
if(!entity.isDead())
entity.remove();
if(!task.isCancelled())
task.cancel();
}
@ -92,36 +110,151 @@ public abstract class AI {
team.setReady(true);
}
protected void chat(String message) {
FightSystem.getPlugin().getLogger().log(Level.INFO, entity.getName() + "» " + message);
Chat.broadcastChat("PARTICIPANT_CHAT", team.getColoredName(), entity.getName(), message);
}
protected Vector getPosition() {
Location location = entity.getLocation();
Region extend = team.getExtendRegion();
if(Fight.getUnrotated() == team)
return new Vector(
location.getX() - extend.getMinX(),
location.getY() - extend.getMinY(),
location.getZ() - extend.getMinZ()
);
else
return new Vector(
extend.getMaxX() - location.getX(),
location.getY() - extend.getMinY(),
extend.getMaxZ() - location.getZ()
);
}
protected Material getBlock(Vector pos) {
//TODO position translation
cooldown++;
return pos.toLocation(Config.world).getBlock().getType();
queue.add(new Action(1));
return translate(pos, true).getBlock().getType();
}
protected boolean isPowered(Vector pos) {
queue.add(new Action(1));
return translate(pos, true).getBlock().isBlockPowered();
}
protected void setTNT(Vector pos) {
//TODO position translation
//TODO Check position
//TODO Check AIR is there
cooldown++;
pos.toLocation(Config.world).getBlock().setType(Material.TNT);
queue.add(new Action(1) {
@Override
public void run() {
Location location = translate(pos, true);
if(interactionDistanceViolation(location))
return;
Block block = location.getBlock();
if(block.getType() == Material.AIR)
block.setType(Material.TNT);
}
});
}
protected void interact(Vector pos) {
queue.add(new Action(1) {
@Override
public void run() {
Location location = translate(pos, true);
if(interactionDistanceViolation(location))
return;
interact(location.getBlock());
}
});
}
protected void move(Vector pos) {
//TODO position translation
//TODO Check position
//TODO falling check
//TODO pathfinding
cooldown += 5;
entity.teleport(pos.toLocation(Config.world));
queue.add(new Action(2) {
@Override
public void run() {
if(!entity.isOnGround())
return;
Location location = entity.getLocation();
Location target = translate(pos, false);
if(Math.abs(location.getX() - target.getX()) > 1 || Math.abs(location.getY() - target.getY()) > 1 || Math.abs(location.getZ() - target.getZ()) > 1)
return;
entity.teleport(target);
}
});
}
private boolean interactionDistanceViolation(Location location) {
return location.distance(entity.getEyeLocation()) > 5;
}
private void interact(Block block) {
BlockData data = block.getBlockData(); //TODO only 1.14+ compatible at the moment
if (data instanceof NoteBlock) {
NoteBlock noteBlock = (NoteBlock) data;
Note note = noteBlock.getNote();
noteBlock.setNote(note.isSharped() ? note.flattened() : note.sharped());
} else if (data instanceof Openable) {
Openable openable = (Openable) data;
openable.setOpen(!openable.isOpen());
} else if (data instanceof Powerable) {
Material type = block.getType();
Powerable powerable = (Powerable) data;
boolean isPowered = powerable.isPowered();
if(type.name().endsWith("BUTTON")) {
if(isPowered)
return;
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
if(!block.getType().name().endsWith("BUTTON"))
return;
powerable.setPowered(false);
block.setBlockData(powerable);
}, type.name().endsWith("STONE_BUTTON") ? 20 : 30);
}
powerable.setPowered(!isPowered);
}
block.setBlockData(data);
}
private void run() {
if(cooldown > 0)
cooldown--;
if(cooldown > 0)
return;
if(queue.isEmpty())
plan();
if(!queue.isEmpty() && --queue.peek().delay == 0)
queue.poll().run();
}
private Location translate(Vector pos, boolean blockPos) {
Region extend = team.getExtendRegion();
if(Fight.getUnrotated() == team)
return new Location(
Config.world,
pos.getX() + extend.getMinX(),
pos.getY() + extend.getMinY(),
pos.getZ() + extend.getMinZ()
);
else
return new Location(
Config.world,
extend.getMaxX() - pos.getX() - (blockPos ? 1 : 0),
pos.getY() + extend.getMinY(),
extend.getMaxZ() - pos.getZ() - (blockPos ? 1 : 0)
);
}
private static class Action {
private int delay;
public Action(int delay) {
this.delay = delay;
}
public void run() {}
}
}

Datei anzeigen

@ -88,7 +88,7 @@ public class Fight {
}
public static FightTeam getUnrotated() {
return Config.BlueRotate ? Fight.getRedTeam() : Fight.getBlueTeam();
return Config.blueNegZ() ? Fight.getBlueTeam() : Fight.getRedTeam();
}
public static void playSound(Sound sound, float volume, float pitch) {

Datei anzeigen

@ -28,12 +28,11 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import java.util.UUID;
import java.util.function.Consumer;
public class FightPlayer {
private final UUID uuid;
private final int id;
private LivingEntity entity;
private final FightTeam team;
private boolean isOut;
@ -41,14 +40,14 @@ public class FightPlayer {
private int kills;
private EnternCountdown enternCountdown = null;
FightPlayer(LivingEntity player, FightTeam team) {
this.uuid = player.getUniqueId();
this.entity = player;
FightPlayer(LivingEntity entity, SteamwarUser user, FightTeam team) {
this.id = user.getId();
this.entity = entity;
this.team = team;
this.isOut = false;
kit = Kit.getKitByName(Config.MemberDefault);
if(Config.PersonalKits){
PersonalKit personalKit = PersonalKit.getKitInUse(SteamwarUser.get(uuid).getId(), Config.SchematicType.toDB());
PersonalKit personalKit = PersonalKit.getKitInUse(user.getId(), Config.SchematicType.toDB());
if(personalKit != null){
kit = new Kit(personalKit);
}
@ -63,7 +62,7 @@ public class FightPlayer {
public void setOut() {
isOut = true;
stopEnternCountdown();
ifAI(AI::cleanup);
ifAI(AI::stop);
}
public void startEnternCountdown() {
@ -79,15 +78,19 @@ public class FightPlayer {
}
public LivingEntity getEntity() {
Player bukkit = Bukkit.getPlayer(uuid);
LivingEntity bukkit = (LivingEntity) Bukkit.getEntity(entity.getUniqueId());
if(bukkit != null)
entity = bukkit;
return entity;
}
public SteamwarUser getUser() {
return SteamwarUser.get(id);
}
public void ifAI(Consumer<AI> function) {
if(!(entity instanceof Player))
function.accept(AI.getAI(uuid));
function.accept(AI.getAI(entity.getUniqueId()));
}
public void ifPlayer(Consumer<Player> function) {

Datei anzeigen

@ -203,21 +203,21 @@ public class FightTeam {
Set<UUID> playerSet = new HashSet<>(players.keySet());
for(UUID uuid : playerSet){
LivingEntity player = (LivingEntity) Bukkit.getEntity(uuid);
Player player = Bukkit.getPlayer(uuid);
if(player == null)
removePlayer(players.get(uuid).getEntity());
}
FightPlayer leaderBackup = leader;
playerSet.removeIf(uuid -> Bukkit.getEntity(uuid) == null);
playerSet.removeIf(uuid -> Bukkit.getPlayer(uuid) == null);
players.clear();
leader = null;
if(leaderBackup != null){
playerSet.remove(leaderBackup.getEntity().getUniqueId());
addMember(leaderBackup.getEntity(), true);
addMember(leaderBackup.getEntity(), leaderBackup.getUser(), true);
}
playerSet.forEach(uuid -> addMember((LivingEntity) Bukkit.getEntity(uuid), true));
playerSet.forEach(uuid -> addMember(Bukkit.getPlayer(uuid), SteamwarUser.get(uuid), true));
if(ArenaMode.VariableTeams.contains(Config.mode) && isLeaderless()){
List<Player> onlinePlayers = new ArrayList<>(Bukkit.getOnlinePlayers());
@ -251,72 +251,76 @@ public class FightTeam {
});
}
public void addMember(LivingEntity player) {
addMember(player, false);
public void addMember(Player player) {
addMember(player, SteamwarUser.get(player.getUniqueId()), false);
}
private void addMember(LivingEntity player, boolean silent) {
final List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, false);
FightPlayer fightPlayer = getFightPlayer(player) != null ? getFightPlayer(player) : new FightPlayer(player, this);
public void addMember(LivingEntity entity, SteamwarUser user) {
addMember(entity, user, false);
}
public void addMember(LivingEntity entity, SteamwarUser user, boolean silent) {
final List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(entity, false);
FightPlayer fightPlayer = getFightPlayer(entity) != null ? getFightPlayer(entity) : new FightPlayer(entity, user, this);
fightPlayer.revive();
players.put(player.getUniqueId(), fightPlayer);
Permanent.getSpectatorTeam().removeEntry(player.getName());
team.addEntry(player.getName());
players.put(entity.getUniqueId(), fightPlayer);
Permanent.getSpectatorTeam().removeEntry(entity.getName());
team.addEntry(entity.getName());
player.setHealth(20);
player.teleport(spawn);
entity.setHealth(20);
entity.teleport(spawn);
fightPlayer.ifPlayer(p -> {
BountifulWrapper.impl.setAttackSpeed(p);
p.setFoodLevel(20);
p.getInventory().clear();
fightPlayer.ifPlayer(player -> {
BountifulWrapper.impl.setAttackSpeed(player);
player.setFoodLevel(20);
player.getInventory().clear();
if(FightState.Spectate.contains(FightState.getFightState())) {
Fight.setPlayerGamemode(p, GameMode.SPECTATOR);
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
} else {
Fight.setPlayerGamemode(p, GameMode.SURVIVAL);
(FightState.ingame() ? fightPlayer.getKit() : memberKit).loadToPlayer(p);
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
(FightState.ingame() ? fightPlayer.getKit() : memberKit).loadToPlayer(player);
}
});
if(FightState.Running.contains(FightState.getFightState()))
fightPlayer.startEnternCountdown();
GlobalRecorder.getInstance().playerJoins(player);
fightPlayer.ifPlayer(p -> FightSystem.getTechHider().reloadChunks(p, chunksToReload, false));
GlobalRecorder.getInstance().playerJoins(entity, user);
fightPlayer.ifPlayer(player -> FightSystem.getTechHider().reloadChunks(player, chunksToReload, false));
if(isLeaderless())
setLeader(fightPlayer, silent);
else if(!silent)
FightUI.addSubtitle("UI_PLAYER_JOINS", prefix, player.getName());
FightUI.addSubtitle("UI_PLAYER_JOINS", prefix, entity.getName());
}
public void removePlayer(LivingEntity player) {
FightPlayer fightPlayer = getFightPlayer(player);
public void removePlayer(LivingEntity entity) {
FightPlayer fightPlayer = getFightPlayer(entity);
fightPlayer.ifPlayer(PersonalKitCreator::closeIfInKitCreator);
List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, true);
players.remove(player.getUniqueId());
team.removeEntry(player.getName());
Permanent.getSpectatorTeam().addEntry(player.getName());
List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(entity, true);
players.remove(entity.getUniqueId());
team.removeEntry(entity.getName());
Permanent.getSpectatorTeam().addEntry(entity.getName());
FightUI.addSubtitle("UI_PLAYER_LEAVES", prefix, player.getName());
FightUI.addSubtitle("UI_PLAYER_LEAVES", prefix, entity.getName());
if(fightPlayer.equals(leader))
removeLeader();
GlobalRecorder.getInstance().entityDespawns(player);
player.teleport(Config.SpecSpawn);
GlobalRecorder.getInstance().entityDespawns(entity);
entity.teleport(Config.SpecSpawn);
fightPlayer.ifPlayer(p -> {
Fight.setPlayerGamemode(p, GameMode.SPECTATOR);
p.getInventory().clear();
fightPlayer.ifPlayer(player -> {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.getInventory().clear();
if(p.isOnline()){
FightSystem.getTechHider().reloadChunks(p, chunksToReload, true);
if(player.isOnline()){
FightSystem.getTechHider().reloadChunks(player, chunksToReload, true);
if(ArenaMode.VariableTeams.contains(Config.mode))
HotbarKit.SPECTATOR_KIT.loadToPlayer(p);
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
}
});
}
@ -353,7 +357,7 @@ public class FightTeam {
if(!silent)
FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getEntity().getName());
Optional<Integer> maxRank = SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(leader.getEntity().getUniqueId()).getId(), Config.SchematicType.toDB()).stream().map(SchematicNode::getRank).max(Integer::compare);
Optional<Integer> maxRank = SchematicNode.getAllAccessibleSchematicsOfType(leader.getUser().getId(), Config.SchematicType.toDB()).stream().map(SchematicNode::getRank).max(Integer::compare);
if(Config.RanksEnabled)
schemRank = maxRank.orElse(1);
else
@ -373,7 +377,7 @@ public class FightTeam {
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
}
leader.ifAI(ai -> setSchem(ai.chooseSchematic()));
leader.ifAI(ai -> pasteSchem(ai.chooseSchematic()));
}
public Collection<FightPlayer> getPlayers() {

Datei anzeigen

@ -63,6 +63,7 @@ public class JoinRequest {
this.player = player;
this.team = team;
this.waitOnApproval = new HashSet<>(FightState.ingame() ? Fight.teams() : Collections.singleton(team));
Set<FightTeam> alreadyAccepted = new HashSet<>();
activeRequests.put(player, this);
for(FightTeam t : waitOnApproval) {
@ -76,11 +77,12 @@ public class JoinRequest {
leader.ifPlayer(leaderPlayer -> FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_NOTIFICATION", leaderPlayer, "REQUESTS", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/requests"), player.getName(), team.getColoredName()));
leader.ifAI(ai -> {
if(ai.acceptJoinRequest(player, team))
accept(t);
alreadyAccepted.add(t);
});
}
FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_CONFIRMATION", player, ChatMessageType.ACTION_BAR);
alreadyAccepted.forEach(this::accept);
}
public boolean required(FightTeam decider) {

Datei anzeigen

@ -23,14 +23,15 @@ import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -69,10 +70,12 @@ public class ArenaBorder implements Listener {
}
private void damage() {
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
FightTeam team = Fight.getPlayerTeam(player);
if(team != null && player.getLocation().getY() <= Config.PlayerRegion.getMinY())
player.damage(1);
Fight.teams().forEach(team -> {
for(FightPlayer fp : team.getPlayers()) {
LivingEntity entity = fp.getEntity();
if(fp.isLiving() && entity.getLocation().getY() <= Config.PlayerRegion.getMinY())
entity.damage(1);
}
});
}
}

Datei anzeigen

@ -63,7 +63,7 @@ public class Chat implements Listener {
event.setCancelled(true);
}
private void broadcastChat(String message, Object... params) {
public static void broadcastChat(String message, Object... params) {
GlobalRecorder.getInstance().chat(message, params);
FightSystem.getMessage().chat(message, params);
}

Datei anzeigen

@ -32,7 +32,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.function.Consumer;
@ -57,7 +56,7 @@ public class IngameDeath implements Listener {
}
@EventHandler(priority = EventPriority.MONITOR)
public void handlePlayerDeath(PlayerDeathEvent event) {
public void handlePlayerDeath(EntityDeathEvent event) {
onPlayerEnd(event.getEntity(), FightPlayer::setOut);
}

Datei anzeigen

@ -69,7 +69,7 @@ public interface Recorder {
if(FightState.AntiSpectate.contains(FightState.getFightState())){
for(FightPlayer player : team.getPlayers()){
if(player.isLiving()){
playerJoins(player.getEntity());
playerJoins(player.getEntity(), player.getUser());
}
}
}
@ -149,9 +149,7 @@ public interface Recorder {
* 0x08: Message following
* */
default void playerJoins(LivingEntity p){
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
default void playerJoins(LivingEntity p, SteamwarUser user){
write(0x00, p.getEntityId(), user.getId());
entityMoves(p);
}

Datei anzeigen

@ -52,12 +52,12 @@ public class BungeeFightInfo {
Fight.getRedTeam().getColoredName(),
FightState.getFightState().name(),
StateDependentCountdown.getMainCountdown() != null ? StateDependentCountdown.getMainCountdown().getTimeLeft() : 0,
Fight.getBlueTeam().getLeader() != null ? SteamwarUser.get(Fight.getBlueTeam().getLeader().getEntity().getUniqueId()).getId() : 0,
Fight.getRedTeam().getLeader() != null ? SteamwarUser.get(Fight.getRedTeam().getLeader().getEntity().getUniqueId()).getId() : 0,
Fight.getBlueTeam().getLeader() != null ? Fight.getBlueTeam().getLeader().getUser().getId() : 0,
Fight.getRedTeam().getLeader() != null ? Fight.getRedTeam().getLeader().getUser().getId() : 0,
Fight.getBlueTeam().getSchematic(),
Fight.getRedTeam().getSchematic(),
Fight.getBlueTeam().getPlayers().stream().map(p -> SteamwarUser.get(p.getEntity().getUniqueId()).getId()).collect(Collectors.toList()),
Fight.getRedTeam().getPlayers().stream().map(p -> SteamwarUser.get(p.getEntity().getUniqueId()).getId()).collect(Collectors.toList()),
Fight.getBlueTeam().getPlayers().stream().map(p -> p.getUser().getId()).collect(Collectors.toList()),
Fight.getRedTeam().getPlayers().stream().map(p -> p.getUser().getId()).collect(Collectors.toList()),
Bukkit.getOnlinePlayers().stream().filter(p -> Fight.getPlayerTeam(p) == null).map(p -> SteamwarUser.get(p.getUniqueId()).getId()).collect(Collectors.toList())
));
}

Datei anzeigen

@ -136,7 +136,7 @@ public class FightStatistics {
}
if (!Bukkit.getOnlinePlayers().isEmpty() && !unranked) {
NetworkSender.send(new FightEndsPacket((byte) win, blueSchem == null ? 0 : blueSchem, redSchem == null ? 0 : redSchem, Fight.getBlueTeam().getPlayers().stream().map(FightPlayer::getEntity).map(p -> SteamwarUser.get(p.getUniqueId())).map(SteamwarUser::getId).collect(Collectors.toList()), Fight.getRedTeam().getPlayers().stream().map(FightPlayer::getEntity).map(p -> SteamwarUser.get(p.getUniqueId())).map(SteamwarUser::getId).collect(Collectors.toList()), gameMode, (int)(endTime.getEpochSecond() - starttime.toInstant().getEpochSecond())));
NetworkSender.send(new FightEndsPacket((byte) win, blueSchem == null ? 0 : blueSchem, redSchem == null ? 0 : redSchem, Fight.getBlueTeam().getPlayers().stream().map(FightPlayer::getUser).map(SteamwarUser::getId).collect(Collectors.toList()), Fight.getRedTeam().getPlayers().stream().map(FightPlayer::getUser).map(SteamwarUser::getId).collect(Collectors.toList()), gameMode, (int)(endTime.getEpochSecond() - starttime.toInstant().getEpochSecond())));
}
unranked = false;
@ -144,14 +144,13 @@ public class FightStatistics {
private int getLeader(FightTeam team) {
if (team.getLeader() != null)
return SteamwarUser.get(team.getLeader().getEntity().getUniqueId()).getId();
return team.getLeader().getUser().getId();
else if (team.getDesignatedLeader() != null)
return SteamwarUser.get(team.getDesignatedLeader()).getId();
return 0;
}
private void savePlayerStats(FightPlayer fp, int fightId) {
SteamwarUser user = SteamwarUser.get(fp.getEntity().getUniqueId());
de.steamwar.sql.FightPlayer.create(fightId, user.getId(), fp.getTeam().isBlue(), fp.getKit().getName(), fp.getKills(), !fp.isLiving());
de.steamwar.sql.FightPlayer.create(fightId, fp.getUser().getId(), fp.getTeam().isBlue(), fp.getKit().getName(), fp.getKills(), !fp.isLiving());
}
}