Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
783474c958
Commit
a9453aa859
@ -105,7 +105,7 @@ public class FightSystem extends JavaPlugin {
|
||||
techHider = new TechHiderWrapper();
|
||||
new FightWorld();
|
||||
new FightUI();
|
||||
//new FightStatistics();
|
||||
new FightStatistics();
|
||||
new BungeeFightInfo();
|
||||
|
||||
new WinconditionAllDead();
|
||||
|
@ -51,7 +51,7 @@ public class InfoCommand implements CommandExecutor {
|
||||
FightSystem.getMessage().send("INFO_RANKED", player, !FightStatistics.isUnranked());
|
||||
for(FightTeam team : Fight.teams()) {
|
||||
if(!team.isLeaderless())
|
||||
FightSystem.getMessage().send("INFO_LEADER", player, team.getColoredName(), team.getLeader().getPlayer().getName());
|
||||
FightSystem.getMessage().send("INFO_LEADER", player, team.getColoredName(), team.getLeader().getEntity().getName());
|
||||
|
||||
if(team.getSchematic() != 0) {
|
||||
SchematicNode schematic = SchematicNode.getSchematicNode(team.getSchematic());
|
||||
|
@ -57,18 +57,18 @@ public class EnternCountdown extends Countdown {
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getPlayer(), ChatMessageType.ACTION_BAR);
|
||||
fightPlayer.withPlayer(player -> FightSystem.getTechHider().reloadChunks(player, chunkPos, false));
|
||||
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getEntity(), ChatMessageType.ACTION_BAR);
|
||||
fightPlayer.ifPlayer(player -> FightSystem.getTechHider().reloadChunks(player, chunkPos, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareFinish() {
|
||||
chunkPos = FightSystem.getTechHider().prepareChunkReload(fightPlayer.getPlayer(), false);
|
||||
chunkPos = FightSystem.getTechHider().prepareChunkReload(fightPlayer.getEntity(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void broadcast(String message, int divisor) {
|
||||
fightPlayer.withPlayer(player -> {
|
||||
fightPlayer.ifPlayer(player -> {
|
||||
player.playSound(player.getLocation(), sound, 100.0f, 1.0f);
|
||||
sendCountdownMessage(player, message, time / divisor, appendix);
|
||||
});
|
||||
|
@ -76,14 +76,14 @@ public class FightPlayer {
|
||||
enternCountdown = null;
|
||||
}
|
||||
|
||||
public LivingEntity getPlayer() {
|
||||
public LivingEntity getEntity() {
|
||||
Player bukkit = Bukkit.getPlayer(uuid);
|
||||
if(bukkit != null)
|
||||
entity = bukkit;
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void withPlayer(Consumer<Player> function) {
|
||||
public void ifPlayer(Consumer<Player> function) {
|
||||
if(entity instanceof Player)
|
||||
function.accept((Player) entity);
|
||||
}
|
||||
@ -94,7 +94,7 @@ public class FightPlayer {
|
||||
|
||||
public boolean isLeader() {
|
||||
FightPlayer leader = team.getLeader();
|
||||
return leader != null && leader.getPlayer() == entity;
|
||||
return leader != null && leader.getEntity() == entity;
|
||||
}
|
||||
|
||||
public Kit getKit() {
|
||||
|
@ -135,7 +135,7 @@ public class FightTeam {
|
||||
new OneShotStateDependent(Config.replayserver(), FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::reset));
|
||||
new OneShotStateDependent(ArenaMode.All, FightState.PostSchemSetup, () -> {
|
||||
if(leader != null)
|
||||
leader.withPlayer(notReadyKit::loadToPlayer);
|
||||
leader.ifPlayer(notReadyKit::loadToPlayer);
|
||||
});
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ public class FightTeam {
|
||||
}
|
||||
|
||||
public void teleportToSpawn(){
|
||||
players.forEach((player, fp) -> fp.getPlayer().teleport(spawn));
|
||||
players.forEach((player, fp) -> fp.getEntity().teleport(spawn));
|
||||
}
|
||||
|
||||
public FightPlayer getFightPlayer(LivingEntity player) {
|
||||
@ -191,7 +191,7 @@ public class FightTeam {
|
||||
|
||||
public boolean isPlayerLeader(LivingEntity player) {
|
||||
if(leader != null)
|
||||
return leader.getPlayer().equals(player);
|
||||
return leader.getEntity().equals(player);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@ -205,7 +205,7 @@ public class FightTeam {
|
||||
for(UUID uuid : playerSet){
|
||||
LivingEntity player = (LivingEntity) Bukkit.getEntity(uuid);
|
||||
if(player == null)
|
||||
removePlayer(players.get(uuid).getPlayer());
|
||||
removePlayer(players.get(uuid).getEntity());
|
||||
}
|
||||
FightPlayer leaderBackup = leader;
|
||||
playerSet.removeIf(uuid -> Bukkit.getEntity(uuid) == null);
|
||||
@ -213,8 +213,8 @@ public class FightTeam {
|
||||
leader = null;
|
||||
|
||||
if(leaderBackup != null){
|
||||
playerSet.remove(leaderBackup.getPlayer().getUniqueId());
|
||||
addMember(leaderBackup.getPlayer(), true);
|
||||
playerSet.remove(leaderBackup.getEntity().getUniqueId());
|
||||
addMember(leaderBackup.getEntity(), true);
|
||||
}
|
||||
|
||||
playerSet.forEach(uuid -> addMember((LivingEntity) Bukkit.getEntity(uuid), true));
|
||||
@ -266,7 +266,7 @@ public class FightTeam {
|
||||
player.setHealth(20);
|
||||
player.teleport(spawn);
|
||||
|
||||
fightPlayer.withPlayer(p -> {
|
||||
fightPlayer.ifPlayer(p -> {
|
||||
BountifulWrapper.impl.setAttackSpeed(p);
|
||||
p.setFoodLevel(20);
|
||||
p.getInventory().clear();
|
||||
@ -283,7 +283,7 @@ public class FightTeam {
|
||||
fightPlayer.startEnternCountdown();
|
||||
|
||||
GlobalRecorder.getInstance().playerJoins(player);
|
||||
fightPlayer.withPlayer(p -> FightSystem.getTechHider().reloadChunks(p, chunksToReload, false));
|
||||
fightPlayer.ifPlayer(p -> FightSystem.getTechHider().reloadChunks(p, chunksToReload, false));
|
||||
|
||||
if(isLeaderless())
|
||||
setLeader(fightPlayer, silent);
|
||||
@ -294,7 +294,7 @@ public class FightTeam {
|
||||
public void removePlayer(LivingEntity player) {
|
||||
FightPlayer fightPlayer = getFightPlayer(player);
|
||||
|
||||
fightPlayer.withPlayer(PersonalKitCreator::closeIfInKitCreator);
|
||||
fightPlayer.ifPlayer(PersonalKitCreator::closeIfInKitCreator);
|
||||
List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, true);
|
||||
players.remove(player.getUniqueId());
|
||||
team.removeEntry(player.getName());
|
||||
@ -308,7 +308,7 @@ public class FightTeam {
|
||||
GlobalRecorder.getInstance().entityDespawns(player);
|
||||
player.teleport(Config.SpecSpawn);
|
||||
|
||||
fightPlayer.withPlayer(p -> {
|
||||
fightPlayer.ifPlayer(p -> {
|
||||
Fight.setPlayerGamemode(p, GameMode.SPECTATOR);
|
||||
p.getInventory().clear();
|
||||
|
||||
@ -343,7 +343,7 @@ public class FightTeam {
|
||||
}
|
||||
|
||||
private void setLeader(FightPlayer leader, boolean silent) {
|
||||
leader.withPlayer(PersonalKitCreator::closeIfInKitCreator);
|
||||
leader.ifPlayer(PersonalKitCreator::closeIfInKitCreator);
|
||||
|
||||
this.leader = leader;
|
||||
designatedLeader = null;
|
||||
@ -351,9 +351,9 @@ public class FightTeam {
|
||||
setReady(false);
|
||||
|
||||
if(!silent)
|
||||
FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getPlayer().getName());
|
||||
FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getEntity().getName());
|
||||
|
||||
Optional<Integer> maxRank = SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(leader.getPlayer().getUniqueId()).getId(), Config.SchematicType.toDB()).stream().map(SchematicNode::getRank).max(Integer::compare);
|
||||
Optional<Integer> maxRank = SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(leader.getEntity().getUniqueId()).getId(), Config.SchematicType.toDB()).stream().map(SchematicNode::getRank).max(Integer::compare);
|
||||
if(Config.RanksEnabled)
|
||||
schemRank = maxRank.orElse(1);
|
||||
else
|
||||
@ -362,7 +362,7 @@ public class FightTeam {
|
||||
if(!Config.PersonalKits)
|
||||
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
|
||||
|
||||
leader.withPlayer(player -> {
|
||||
leader.ifPlayer(player -> {
|
||||
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||
chooseSchemKit.loadToPlayer(player);
|
||||
else
|
||||
@ -414,7 +414,7 @@ public class FightTeam {
|
||||
}
|
||||
|
||||
public void setReady(boolean ready) {
|
||||
LivingEntity l = leader.getPlayer();
|
||||
LivingEntity l = leader.getEntity();
|
||||
|
||||
if(!schematic.hasSchematic()){
|
||||
FightSystem.getMessage().sendPrefixless("SCHEMATIC_REQUIRED", l, ChatMessageType.ACTION_BAR);
|
||||
@ -424,12 +424,12 @@ public class FightTeam {
|
||||
this.ready = ready;
|
||||
if(ready) {
|
||||
broadcast("TEAM_READY");
|
||||
leader.withPlayer(readyKit::loadToPlayer);
|
||||
leader.ifPlayer(readyKit::loadToPlayer);
|
||||
if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode))
|
||||
FightState.setFightState(FightState.PRE_RUNNING);
|
||||
} else {
|
||||
broadcast("TEAM_NOT_READY");
|
||||
leader.withPlayer(notReadyKit::loadToPlayer);
|
||||
leader.ifPlayer(notReadyKit::loadToPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -468,7 +468,7 @@ public class FightTeam {
|
||||
}
|
||||
|
||||
public double getCurrentHearts() {
|
||||
return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getPlayer().getHealth()).sum();
|
||||
return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getEntity().getHealth()).sum();
|
||||
}
|
||||
|
||||
public double getHeartRatio(){
|
||||
@ -502,7 +502,7 @@ public class FightTeam {
|
||||
@Override
|
||||
public void enable() {
|
||||
for(FightPlayer fightPlayer : players.values()) {
|
||||
fightPlayer.withPlayer(player -> {
|
||||
fightPlayer.ifPlayer(player -> {
|
||||
PersonalKitCreator.closeIfInKitCreator(player);
|
||||
|
||||
player.closeInventory();
|
||||
@ -513,7 +513,7 @@ public class FightTeam {
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
players.values().forEach(fightPlayer -> fightPlayer.withPlayer(p -> p.getInventory().clear()));
|
||||
players.values().forEach(fightPlayer -> fightPlayer.ifPlayer(p -> p.getInventory().clear()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -526,14 +526,14 @@ public class FightTeam {
|
||||
@Override
|
||||
public void enable() {
|
||||
players.values().forEach(fightPlayer -> {
|
||||
fightPlayer.withPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SPECTATOR));
|
||||
fightPlayer.getPlayer().teleport(FightTeam.this.spawn);
|
||||
fightPlayer.ifPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SPECTATOR));
|
||||
fightPlayer.getEntity().teleport(FightTeam.this.spawn);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
players.values().forEach(fightPlayer -> fightPlayer.withPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SURVIVAL)));
|
||||
players.values().forEach(fightPlayer -> fightPlayer.ifPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SURVIVAL)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,10 +68,10 @@ public class JoinRequest {
|
||||
if(leader == null)
|
||||
continue;
|
||||
|
||||
if(leader.getPlayer() == null)
|
||||
if(leader.getEntity() == null)
|
||||
continue;
|
||||
|
||||
leader.withPlayer(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"), player.getName(), team.getColoredName()));
|
||||
}
|
||||
|
||||
activeRequests.put(player, this);
|
||||
|
@ -46,14 +46,14 @@ public class IngameDeath implements Listener {
|
||||
@EventHandler
|
||||
public void broadcastDeath(EntityDeathEvent event) {
|
||||
onPlayerEnd(event.getEntity(), fightPlayer -> {
|
||||
FightUI.addSubtitle("UI_PLAYER_DEATH", fightPlayer.getTeam().getPrefix(), fightPlayer.getPlayer().getName());
|
||||
FightUI.addSubtitle("UI_PLAYER_DEATH", fightPlayer.getTeam().getPrefix(), fightPlayer.getEntity().getName());
|
||||
Fight.playSound(SWSound.ENTITY_WITHER_DEATH.getSound(), 100.0F, 1.0F);
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void broadcastQuit(PlayerQuitEvent event) {
|
||||
onPlayerEnd(event.getPlayer(), fightPlayer -> FightUI.addSubtitle("UI_PLAYER_LEAVE", fightPlayer.getTeam().getPrefix(), fightPlayer.getPlayer().getName()));
|
||||
onPlayerEnd(event.getPlayer(), fightPlayer -> FightUI.addSubtitle("UI_PLAYER_LEAVE", fightPlayer.getTeam().getPrefix(), fightPlayer.getEntity().getName()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
|
@ -284,7 +284,7 @@ public class Recording implements Listener {
|
||||
if(!fp.isLiving())
|
||||
continue;
|
||||
|
||||
fp.withPlayer(player -> {
|
||||
fp.ifPlayer(player -> {
|
||||
BountifulWrapper.impl.recordHandItems(player);
|
||||
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getHelmet()), "HEAD");
|
||||
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getChestplate()), "CHEST");
|
||||
@ -297,7 +297,7 @@ public class Recording implements Listener {
|
||||
private void despawnTeam(FightTeam team){
|
||||
for(FightPlayer player : team.getPlayers()){
|
||||
if(player.isLiving())
|
||||
GlobalRecorder.getInstance().entityDespawns(player.getPlayer());
|
||||
GlobalRecorder.getInstance().entityDespawns(player.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public interface Recorder {
|
||||
if(FightState.AntiSpectate.contains(FightState.getFightState())){
|
||||
for(FightPlayer player : team.getPlayers()){
|
||||
if(player.isLiving()){
|
||||
playerJoins(player.getPlayer());
|
||||
playerJoins(player.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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().getPlayer().getUniqueId()).getId() : 0,
|
||||
Fight.getRedTeam().getLeader() != null ? SteamwarUser.get(Fight.getRedTeam().getLeader().getPlayer().getUniqueId()).getId() : 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().getSchematic(),
|
||||
Fight.getRedTeam().getSchematic(),
|
||||
Fight.getBlueTeam().getPlayers().stream().map(p -> SteamwarUser.get(p.getPlayer().getUniqueId()).getId()).collect(Collectors.toList()),
|
||||
Fight.getRedTeam().getPlayers().stream().map(p -> SteamwarUser.get(p.getPlayer().getUniqueId()).getId()).collect(Collectors.toList()),
|
||||
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()),
|
||||
Bukkit.getOnlinePlayers().stream().filter(p -> Fight.getPlayerTeam(p) == null).map(p -> SteamwarUser.get(p.getUniqueId()).getId()).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
@ -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::getPlayer).map(p -> SteamwarUser.get(p.getUniqueId())).map(SteamwarUser::getId).collect(Collectors.toList()), Fight.getRedTeam().getPlayers().stream().map(FightPlayer::getPlayer).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::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())));
|
||||
}
|
||||
|
||||
unranked = false;
|
||||
@ -144,14 +144,14 @@ public class FightStatistics {
|
||||
|
||||
private int getLeader(FightTeam team) {
|
||||
if (team.getLeader() != null)
|
||||
return SteamwarUser.get(team.getLeader().getPlayer().getUniqueId()).getId();
|
||||
return SteamwarUser.get(team.getLeader().getEntity().getUniqueId()).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.getPlayer().getUniqueId());
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class WinconditionAllDead extends Wincondition implements Listener {
|
||||
return;
|
||||
|
||||
for(FightPlayer fp : team.getPlayers()) {
|
||||
if(fp.isLiving() && fp.getPlayer() != player)
|
||||
if(fp.isLiving() && fp.getEntity() != player)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -54,9 +54,9 @@ public class WinconditionAmongUs extends Wincondition implements Listener {
|
||||
FightPlayer imposter = fightPlayerList.get(random.nextInt(fightPlayerList.size()));
|
||||
for (FightPlayer fightPlayer : fightPlayerList) {
|
||||
if (fightPlayer == imposter) {
|
||||
FightSystem.getMessage().send("AMONG_US_IMPOSTER_MESSAGE", fightPlayer.getPlayer());
|
||||
FightSystem.getMessage().send("AMONG_US_IMPOSTER_MESSAGE", fightPlayer.getEntity());
|
||||
} else {
|
||||
FightSystem.getMessage().send("AMONG_US_IMPOSTER_AMONG_MESSAGE", fightPlayer.getPlayer());
|
||||
FightSystem.getMessage().send("AMONG_US_IMPOSTER_AMONG_MESSAGE", fightPlayer.getEntity());
|
||||
}
|
||||
}
|
||||
return imposter;
|
||||
|
@ -53,7 +53,7 @@ public class WinconditionCaptainDead extends Wincondition implements Listener {
|
||||
return;
|
||||
|
||||
if(team.isPlayerLeader((LivingEntity) player)) {
|
||||
win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + team.getLeader().getPlayer().getName());
|
||||
win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + team.getLeader().getEntity().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren