SteamWar/FightSystem
Archiviert
13
1

WIP villager AI
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2023-08-28 23:31:00 +02:00
Ursprung a24585e497
Commit 783474c958
17 geänderte Dateien mit 196 neuen und 104 gelöschten Zeilen

Datei anzeigen

@ -105,7 +105,7 @@ public class FightSystem extends JavaPlugin {
techHider = new TechHiderWrapper();
new FightWorld();
new FightUI();
new FightStatistics();
//new FightStatistics();
new BungeeFightInfo();
new WinconditionAllDead();

Datei anzeigen

@ -0,0 +1,45 @@
/*
* 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.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.Config;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Villager;
import java.util.UUID;
public class AIPlayer {
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);
private final LivingEntity player;
public AIPlayer(SteamwarUser user) {
player = Config.world.spawn(Config.SpecSpawn, Villager.class, entity -> entityUUID.set(getHandle.invoke(entity), user.getUUID()));
player.setCustomName(user.getUserName());
player.setAI(false);
}
public LivingEntity getEntity() {
return player;
}
}

Datei anzeigen

@ -33,6 +33,7 @@ import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -101,7 +102,7 @@ public class GUI {
FightTeam team = Fight.getPlayerTeam(p);
if(team == null)
return;
players.removeIf(swItemUUIDPair -> !team.equals(Fight.getPlayerTeam(Bukkit.getPlayer(swItemUUIDPair.getObject()))));
players.removeIf(swItemUUIDPair -> !team.equals(Fight.getPlayerTeam((LivingEntity) Bukkit.getEntity(swItemUUIDPair.getObject()))));
SWListInv<UUID> inv = new SWListInv<>(p, msg.parse("REMOVE_TITLE", p), players, (ClickType click, UUID player) -> {
Commands.kick(p, SteamwarUser.get(player).getUserName());
p.closeInventory();

Datei anzeigen

@ -58,7 +58,7 @@ public class EnternCountdown extends Countdown {
@Override
public void countdownFinished() {
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getPlayer(), ChatMessageType.ACTION_BAR);
FightSystem.getTechHider().reloadChunks(fightPlayer.getPlayer(), chunkPos, false);
fightPlayer.withPlayer(player -> FightSystem.getTechHider().reloadChunks(player, chunkPos, false));
}
@Override
@ -68,7 +68,9 @@ public class EnternCountdown extends Countdown {
@Override
protected void broadcast(String message, int divisor) {
fightPlayer.getPlayer().playSound(fightPlayer.getPlayer().getLocation(), sound, 100.0f, 1.0f);
sendCountdownMessage(fightPlayer.getPlayer(), message, time / divisor, appendix);
fightPlayer.withPlayer(player -> {
player.playSound(player.getLocation(), sound, 100.0f, 1.0f);
sendCountdownMessage(player, message, time / divisor, appendix);
});
}
}

Datei anzeigen

@ -29,6 +29,7 @@ import de.steamwar.fightsystem.record.GlobalRecorder;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import java.util.Collection;
@ -45,7 +46,7 @@ public class Fight {
teams.add(blueTeam);
}
public static FightTeam getPlayerTeam(Player player) {
public static FightTeam getPlayerTeam(LivingEntity player) {
if(redTeam.isPlayerInTeam(player))
return redTeam;
if(blueTeam.isPlayerInTeam(player))
@ -62,7 +63,7 @@ public class Fight {
throw new IllegalArgumentException();
}
public static FightPlayer getFightPlayer(Player player) {
public static FightPlayer getFightPlayer(LivingEntity player) {
if(redTeam.isPlayerInTeam(player))
return redTeam.getFightPlayer(player);
if(blueTeam.isPlayerInTeam(player))
@ -70,7 +71,7 @@ public class Fight {
return null;
}
public static boolean fighting(Player player) {
public static boolean fighting(LivingEntity player) {
return getPlayerTeam(player) != null;
}

Datei anzeigen

@ -24,28 +24,30 @@ import de.steamwar.fightsystem.countdown.EnternCountdown;
import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SteamwarUser;
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 Player player;
private LivingEntity entity;
private final FightTeam team;
private boolean isOut;
private Kit kit;
private int kills;
private EnternCountdown enternCountdown = null;
FightPlayer(Player player, FightTeam team) {
FightPlayer(LivingEntity player, FightTeam team) {
this.uuid = player.getUniqueId();
this.player = player;
this.entity = player;
this.team = team;
this.isOut = false;
kit = Kit.getKitByName(Config.MemberDefault);
if(Config.PersonalKits){
PersonalKit personalKit = PersonalKit.getKitInUse(SteamwarUser.get(player.getUniqueId()).getId(), Config.SchematicType.toDB());
PersonalKit personalKit = PersonalKit.getKitInUse(SteamwarUser.get(uuid).getId(), Config.SchematicType.toDB());
if(personalKit != null){
kit = new Kit(personalKit);
}
@ -74,11 +76,16 @@ public class FightPlayer {
enternCountdown = null;
}
public Player getPlayer() {
public LivingEntity getPlayer() {
Player bukkit = Bukkit.getPlayer(uuid);
if(bukkit != null)
player = bukkit;
return player;
entity = bukkit;
return entity;
}
public void withPlayer(Consumer<Player> function) {
if(entity instanceof Player)
function.accept((Player) entity);
}
public boolean isLiving() {
@ -87,7 +94,7 @@ public class FightPlayer {
public boolean isLeader() {
FightPlayer leader = team.getLeader();
return leader != null && leader.getPlayer() == player;
return leader != null && leader.getPlayer() == entity;
}
public Kit getKit() {

Datei anzeigen

@ -41,6 +41,7 @@ import de.steamwar.techhider.ProtocolUtils;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team;
@ -134,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)
notReadyKit.loadToPlayer(leader.getPlayer());
leader.withPlayer(notReadyKit::loadToPlayer);
});
}
@ -165,10 +166,10 @@ public class FightTeam {
}
public void teleportToSpawn(){
players.forEach((player, fp) -> Objects.requireNonNull(Bukkit.getPlayer(player)).teleport(spawn));
players.forEach((player, fp) -> fp.getPlayer().teleport(spawn));
}
public FightPlayer getFightPlayer(Player player) {
public FightPlayer getFightPlayer(LivingEntity player) {
return players.get(player.getUniqueId());
}
@ -180,15 +181,15 @@ public class FightTeam {
return true;
}
public boolean isPlayerInTeam(Player player) {
public boolean isPlayerInTeam(LivingEntity player) {
return players.containsKey(player.getUniqueId());
}
public boolean canPlayerEntern(Player player) {
public boolean canPlayerEntern(LivingEntity player) {
return getFightPlayer(player).canEntern();
}
public boolean isPlayerLeader(Player player) {
public boolean isPlayerLeader(LivingEntity player) {
if(leader != null)
return leader.getPlayer().equals(player);
else
@ -202,12 +203,12 @@ public class FightTeam {
Set<UUID> playerSet = new HashSet<>(players.keySet());
for(UUID uuid : playerSet){
Player player = Bukkit.getPlayer(uuid);
LivingEntity player = (LivingEntity) Bukkit.getEntity(uuid);
if(player == null)
removePlayer(players.get(uuid).getPlayer());
}
FightPlayer leaderBackup = leader;
playerSet.removeIf(uuid -> Bukkit.getPlayer(uuid) == null);
playerSet.removeIf(uuid -> Bukkit.getEntity(uuid) == null);
players.clear();
leader = null;
@ -216,7 +217,7 @@ public class FightTeam {
addMember(leaderBackup.getPlayer(), true);
}
playerSet.forEach(uuid -> addMember(Bukkit.getPlayer(uuid), true));
playerSet.forEach(uuid -> addMember((LivingEntity) Bukkit.getEntity(uuid), true));
if(ArenaMode.VariableTeams.contains(Config.mode) && isLeaderless()){
List<Player> onlinePlayers = new ArrayList<>(Bukkit.getOnlinePlayers());
@ -250,11 +251,11 @@ public class FightTeam {
});
}
public void addMember(Player player) {
public void addMember(LivingEntity player) {
addMember(player, false);
}
private void addMember(Player player, boolean silent) {
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);
fightPlayer.revive();
@ -263,22 +264,26 @@ public class FightTeam {
team.addEntry(player.getName());
player.setHealth(20);
player.setFoodLevel(20);
player.getInventory().clear();
BountifulWrapper.impl.setAttackSpeed(player);
player.teleport(spawn);
if(FightState.Spectate.contains(FightState.getFightState())) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
} else {
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
(FightState.ingame() ? fightPlayer.getKit() : memberKit).loadToPlayer(player);
}
fightPlayer.withPlayer(p -> {
BountifulWrapper.impl.setAttackSpeed(p);
p.setFoodLevel(20);
p.getInventory().clear();
if(FightState.Spectate.contains(FightState.getFightState())) {
Fight.setPlayerGamemode(p, GameMode.SPECTATOR);
} else {
Fight.setPlayerGamemode(p, GameMode.SURVIVAL);
(FightState.ingame() ? fightPlayer.getKit() : memberKit).loadToPlayer(p);
}
});
if(FightState.Running.contains(FightState.getFightState()))
fightPlayer.startEnternCountdown();
GlobalRecorder.getInstance().playerJoins(player);
FightSystem.getTechHider().reloadChunks(player, chunksToReload, false);
fightPlayer.withPlayer(p -> FightSystem.getTechHider().reloadChunks(p, chunksToReload, false));
if(isLeaderless())
setLeader(fightPlayer, silent);
@ -286,10 +291,10 @@ public class FightTeam {
FightUI.addSubtitle("UI_PLAYER_JOINS", prefix, player.getName());
}
public void removePlayer(Player player) {
public void removePlayer(LivingEntity player) {
FightPlayer fightPlayer = getFightPlayer(player);
PersonalKitCreator.closeIfInKitCreator(player);
fightPlayer.withPlayer(PersonalKitCreator::closeIfInKitCreator);
List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, true);
players.remove(player.getUniqueId());
team.removeEntry(player.getName());
@ -301,16 +306,19 @@ public class FightTeam {
removeLeader();
GlobalRecorder.getInstance().entityDespawns(player);
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn);
player.getInventory().clear();
if(player.isOnline()){
FightSystem.getTechHider().reloadChunks(player, chunksToReload, true);
fightPlayer.withPlayer(p -> {
Fight.setPlayerGamemode(p, GameMode.SPECTATOR);
p.getInventory().clear();
if(ArenaMode.VariableTeams.contains(Config.mode))
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
}
if(p.isOnline()){
FightSystem.getTechHider().reloadChunks(p, chunksToReload, true);
if(ArenaMode.VariableTeams.contains(Config.mode))
HotbarKit.SPECTATOR_KIT.loadToPlayer(p);
}
});
}
public boolean isLeaderless() {
@ -335,7 +343,7 @@ public class FightTeam {
}
private void setLeader(FightPlayer leader, boolean silent) {
PersonalKitCreator.closeIfInKitCreator(leader.getPlayer());
leader.withPlayer(PersonalKitCreator::closeIfInKitCreator);
this.leader = leader;
designatedLeader = null;
@ -354,11 +362,12 @@ public class FightTeam {
if(!Config.PersonalKits)
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
Player player = leader.getPlayer();
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
chooseSchemKit.loadToPlayer(player);
else
notReadyKit.loadToPlayer(player);
leader.withPlayer(player -> {
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
chooseSchemKit.loadToPlayer(player);
else
notReadyKit.loadToPlayer(player);
});
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
@ -405,7 +414,7 @@ public class FightTeam {
}
public void setReady(boolean ready) {
Player l = leader.getPlayer();
LivingEntity l = leader.getPlayer();
if(!schematic.hasSchematic()){
FightSystem.getMessage().sendPrefixless("SCHEMATIC_REQUIRED", l, ChatMessageType.ACTION_BAR);
@ -415,12 +424,12 @@ public class FightTeam {
this.ready = ready;
if(ready) {
broadcast("TEAM_READY");
readyKit.loadToPlayer(l);
leader.withPlayer(readyKit::loadToPlayer);
if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode))
FightState.setFightState(FightState.PRE_RUNNING);
} else {
broadcast("TEAM_NOT_READY");
notReadyKit.loadToPlayer(l);
leader.withPlayer(notReadyKit::loadToPlayer);
}
}
@ -493,17 +502,18 @@ public class FightTeam {
@Override
public void enable() {
for(FightPlayer fightPlayer : players.values()) {
Player player = fightPlayer.getPlayer();
PersonalKitCreator.closeIfInKitCreator(player);
fightPlayer.withPlayer(player -> {
PersonalKitCreator.closeIfInKitCreator(player);
player.closeInventory();
fightPlayer.getKit().loadToPlayer(player);
player.closeInventory();
fightPlayer.getKit().loadToPlayer(player);
});
}
}
@Override
public void disable() {
players.values().forEach(fightPlayer -> fightPlayer.getPlayer().getInventory().clear());
players.values().forEach(fightPlayer -> fightPlayer.withPlayer(p -> p.getInventory().clear()));
}
}
@ -516,14 +526,14 @@ public class FightTeam {
@Override
public void enable() {
players.values().forEach(fightPlayer -> {
Fight.setPlayerGamemode(fightPlayer.getPlayer(), GameMode.SPECTATOR);
fightPlayer.withPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SPECTATOR));
fightPlayer.getPlayer().teleport(FightTeam.this.spawn);
});
}
@Override
public void disable() {
players.values().forEach(fightPlayer -> Fight.setPlayerGamemode(fightPlayer.getPlayer(), GameMode.SURVIVAL));
players.values().forEach(fightPlayer -> fightPlayer.withPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SURVIVAL)));
}
}
}

Datei anzeigen

@ -68,11 +68,10 @@ public class JoinRequest {
if(leader == null)
continue;
Player leaderPlayer = leader.getPlayer();
if(leaderPlayer == null)
if(leader.getPlayer() == null)
continue;
FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_NOTIFICATION", leaderPlayer, "REQUESTS", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/requests"), player.getName(), team.getColoredName());
leader.withPlayer(leaderPlayer -> FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_NOTIFICATION", leaderPlayer, "REQUESTS", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/requests"), player.getName(), team.getColoredName()));
}
activeRequests.put(player, this);

Datei anzeigen

@ -19,7 +19,6 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@ -28,7 +27,7 @@ import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.winconditions.Winconditions;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -43,25 +42,25 @@ public class InFightDamage implements Listener {
@EventHandler
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(!(event.getEntity() instanceof Player))
if(!(event.getEntity() instanceof LivingEntity))
//Target is not a player
return;
Player player = ((Player) event.getEntity());
LivingEntity player = ((LivingEntity) event.getEntity());
if(!Fight.fighting(player))
return;
Player damager;
LivingEntity damager;
if(event.getDamager() instanceof Player) {
damager = ((Player) event.getDamager()).getPlayer();
if(event.getDamager() instanceof LivingEntity) {
damager = (LivingEntity) event.getDamager();
}else if(event.getDamager() instanceof Arrow) {
Arrow damagerArrow = (Arrow) event.getDamager();
if(!(damagerArrow.getShooter() instanceof Player))
if(!(damagerArrow.getShooter() instanceof LivingEntity))
//Shooter is not a player
return;
damager = (Player) damagerArrow.getShooter();
damager = (LivingEntity) damagerArrow.getShooter();
}else{
//Damager is not a player
return;

Datei anzeigen

@ -26,10 +26,12 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.FightUI;
import de.steamwar.fightsystem.utils.SWSound;
import org.bukkit.entity.Player;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
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;
@ -42,7 +44,7 @@ public class IngameDeath implements Listener {
}
@EventHandler
public void broadcastDeath(PlayerDeathEvent event) {
public void broadcastDeath(EntityDeathEvent event) {
onPlayerEnd(event.getEntity(), fightPlayer -> {
FightUI.addSubtitle("UI_PLAYER_DEATH", fightPlayer.getTeam().getPrefix(), fightPlayer.getPlayer().getName());
Fight.playSound(SWSound.ENTITY_WITHER_DEATH.getSound(), 100.0F, 1.0F);
@ -64,8 +66,11 @@ public class IngameDeath implements Listener {
onPlayerEnd(event.getPlayer(), FightPlayer::setOut);
}
private void onPlayerEnd(Player player, Consumer<FightPlayer> withLivingPlayer) {
FightPlayer fightPlayer = Fight.getFightPlayer(player);
private void onPlayerEnd(Entity player, Consumer<FightPlayer> withLivingPlayer) {
if(!(player instanceof LivingEntity))
return;
FightPlayer fightPlayer = Fight.getFightPlayer((LivingEntity) player);
if(fightPlayer == null || !fightPlayer.isLiving())
return;

Datei anzeigen

@ -20,10 +20,14 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.ai.AIPlayer;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -43,7 +47,15 @@ public class NormalJoin implements Listener {
FightTeam team = Fight.teams().stream().filter(t -> player.getUniqueId().equals(t.getDesignatedLeader())).findAny( // Player is designated leader of a team
).orElse(Fight.teams().stream().filter(t -> t.canbeLeader(player)).findAny().orElse(null)); // Else search empty team
if(team != null)
if(team != null) {
team.addMember(player);
FightTeam aiTeam = Fight.getOpposite(team);
AIPlayer aiPlayer = new AIPlayer(SteamwarUser.get(0));
aiTeam.addMember(aiPlayer.getEntity());
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
FightState.setFightState(FightState.POST_SCHEM_SETUP);
aiTeam.setReady(true);
}, 1);
}
}
}

Datei anzeigen

@ -31,7 +31,10 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.utils.BountifulWrapper;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.fightsystem.utils.SWSound;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -281,12 +284,13 @@ public class Recording implements Listener {
if(!fp.isLiving())
continue;
Player player = fp.getPlayer();
BountifulWrapper.impl.recordHandItems(player);
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getHelmet()), "HEAD");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getChestplate()), "CHEST");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getLeggings()), "LEGS");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getBoots()), "FEET");
fp.withPlayer(player -> {
BountifulWrapper.impl.recordHandItems(player);
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getHelmet()), "HEAD");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getChestplate()), "CHEST");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getLeggings()), "LEGS");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getBoots()), "FEET");
});
}
}

Datei anzeigen

@ -36,6 +36,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
@ -148,7 +149,7 @@ public interface Recorder {
* 0x08: Message following
* */
default void playerJoins(Player p){
default void playerJoins(LivingEntity p){
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
write(0x00, p.getEntityId(), user.getId());

Datei anzeigen

@ -30,6 +30,7 @@ import de.steamwar.techhider.ProtocolUtils;
import de.steamwar.techhider.TechHider;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import java.util.ArrayList;
@ -58,13 +59,13 @@ public class TechHiderWrapper extends StateDependent {
techHider.disable();
}
public List<ProtocolUtils.ChunkPos> prepareChunkReload(Player p, boolean hide) {
if(!ENABLED)
public List<ProtocolUtils.ChunkPos> prepareChunkReload(LivingEntity p, boolean hide) {
if(!ENABLED || !(p instanceof Player))
return Collections.emptyList();
List<ProtocolUtils.ChunkPos> chunksToReload = new ArrayList<>();
Config.ArenaRegion.forEachChunk((x, z) -> {
if(bypass(p, x, z) == hide)
if(bypass((Player) p, x, z) == hide)
chunksToReload.add(new ProtocolUtils.ChunkPos(x, z));
});
return chunksToReload;

Datei anzeigen

@ -24,7 +24,8 @@ import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import org.bukkit.entity.Player;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
@ -53,8 +54,11 @@ public abstract class Wincondition {
FightSystem.setSpectateState(team, windescription, subtitle, params);
}
protected FightTeam isTarget(Player player){
return Fight.getPlayerTeam(player);
protected FightTeam isTarget(Entity player){
if(!(player instanceof LivingEntity))
return null;
return Fight.getPlayerTeam((LivingEntity) player);
}
public static List<PrintableWincondition> getPrintableWinconditions(){

Datei anzeigen

@ -24,10 +24,10 @@ 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 org.bukkit.entity.Player;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionAllDead extends Wincondition implements Listener {
@ -38,8 +38,8 @@ public class WinconditionAllDead extends Wincondition implements Listener {
}
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
handleDeath(event.getEntity().getPlayer());
public void handlePlayerDeath(EntityDeathEvent event) {
handleDeath(event.getEntity());
}
@EventHandler
@ -47,7 +47,7 @@ public class WinconditionAllDead extends Wincondition implements Listener {
handleDeath(event.getPlayer());
}
private void handleDeath(Player player){
private void handleDeath(Entity player){
FightTeam team = isTarget(player);
if(team == null)
return;

Datei anzeigen

@ -23,10 +23,11 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.entity.Player;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class WinconditionCaptainDead extends Wincondition implements Listener {
@ -37,8 +38,8 @@ public class WinconditionCaptainDead extends Wincondition implements Listener {
}
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
handleDeath(event.getEntity().getPlayer());
public void handlePlayerDeath(EntityDeathEvent event) {
handleDeath(event.getEntity());
}
@EventHandler
@ -46,12 +47,12 @@ public class WinconditionCaptainDead extends Wincondition implements Listener {
handleDeath(event.getPlayer());
}
private void handleDeath(Player player){
private void handleDeath(Entity player){
FightTeam team = isTarget(player);
if(team == null)
return;
if(team.isPlayerLeader(player)) {
if(team.isPlayerLeader((LivingEntity) player)) {
win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + team.getLeader().getPlayer().getName());
}
}