Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
a24585e497
Commit
783474c958
@ -105,7 +105,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
techHider = new TechHiderWrapper();
|
techHider = new TechHiderWrapper();
|
||||||
new FightWorld();
|
new FightWorld();
|
||||||
new FightUI();
|
new FightUI();
|
||||||
new FightStatistics();
|
//new FightStatistics();
|
||||||
new BungeeFightInfo();
|
new BungeeFightInfo();
|
||||||
|
|
||||||
new WinconditionAllDead();
|
new WinconditionAllDead();
|
||||||
|
45
FightSystem_Core/src/de/steamwar/fightsystem/ai/AIPlayer.java
Normale Datei
45
FightSystem_Core/src/de/steamwar/fightsystem/ai/AIPlayer.java
Normale Datei
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -33,6 +33,7 @@ import de.steamwar.sql.SteamwarUser;
|
|||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
@ -101,7 +102,7 @@ public class GUI {
|
|||||||
FightTeam team = Fight.getPlayerTeam(p);
|
FightTeam team = Fight.getPlayerTeam(p);
|
||||||
if(team == null)
|
if(team == null)
|
||||||
return;
|
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) -> {
|
SWListInv<UUID> inv = new SWListInv<>(p, msg.parse("REMOVE_TITLE", p), players, (ClickType click, UUID player) -> {
|
||||||
Commands.kick(p, SteamwarUser.get(player).getUserName());
|
Commands.kick(p, SteamwarUser.get(player).getUserName());
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
|
@ -58,7 +58,7 @@ public class EnternCountdown extends Countdown {
|
|||||||
@Override
|
@Override
|
||||||
public void countdownFinished() {
|
public void countdownFinished() {
|
||||||
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getPlayer(), ChatMessageType.ACTION_BAR);
|
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
|
@Override
|
||||||
@ -68,7 +68,9 @@ public class EnternCountdown extends Countdown {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void broadcast(String message, int divisor) {
|
protected void broadcast(String message, int divisor) {
|
||||||
fightPlayer.getPlayer().playSound(fightPlayer.getPlayer().getLocation(), sound, 100.0f, 1.0f);
|
fightPlayer.withPlayer(player -> {
|
||||||
sendCountdownMessage(fightPlayer.getPlayer(), message, time / divisor, appendix);
|
player.playSound(player.getLocation(), sound, 100.0f, 1.0f);
|
||||||
|
sendCountdownMessage(player, message, time / divisor, appendix);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import de.steamwar.fightsystem.record.GlobalRecorder;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -45,7 +46,7 @@ public class Fight {
|
|||||||
teams.add(blueTeam);
|
teams.add(blueTeam);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FightTeam getPlayerTeam(Player player) {
|
public static FightTeam getPlayerTeam(LivingEntity player) {
|
||||||
if(redTeam.isPlayerInTeam(player))
|
if(redTeam.isPlayerInTeam(player))
|
||||||
return redTeam;
|
return redTeam;
|
||||||
if(blueTeam.isPlayerInTeam(player))
|
if(blueTeam.isPlayerInTeam(player))
|
||||||
@ -62,7 +63,7 @@ public class Fight {
|
|||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FightPlayer getFightPlayer(Player player) {
|
public static FightPlayer getFightPlayer(LivingEntity player) {
|
||||||
if(redTeam.isPlayerInTeam(player))
|
if(redTeam.isPlayerInTeam(player))
|
||||||
return redTeam.getFightPlayer(player);
|
return redTeam.getFightPlayer(player);
|
||||||
if(blueTeam.isPlayerInTeam(player))
|
if(blueTeam.isPlayerInTeam(player))
|
||||||
@ -70,7 +71,7 @@ public class Fight {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean fighting(Player player) {
|
public static boolean fighting(LivingEntity player) {
|
||||||
return getPlayerTeam(player) != null;
|
return getPlayerTeam(player) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,28 +24,30 @@ import de.steamwar.fightsystem.countdown.EnternCountdown;
|
|||||||
import de.steamwar.sql.PersonalKit;
|
import de.steamwar.sql.PersonalKit;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class FightPlayer {
|
public class FightPlayer {
|
||||||
|
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private Player player;
|
private LivingEntity entity;
|
||||||
private final FightTeam team;
|
private final FightTeam team;
|
||||||
private boolean isOut;
|
private boolean isOut;
|
||||||
private Kit kit;
|
private Kit kit;
|
||||||
private int kills;
|
private int kills;
|
||||||
private EnternCountdown enternCountdown = null;
|
private EnternCountdown enternCountdown = null;
|
||||||
|
|
||||||
FightPlayer(Player player, FightTeam team) {
|
FightPlayer(LivingEntity player, FightTeam team) {
|
||||||
this.uuid = player.getUniqueId();
|
this.uuid = player.getUniqueId();
|
||||||
this.player = player;
|
this.entity = player;
|
||||||
this.team = team;
|
this.team = team;
|
||||||
this.isOut = false;
|
this.isOut = false;
|
||||||
kit = Kit.getKitByName(Config.MemberDefault);
|
kit = Kit.getKitByName(Config.MemberDefault);
|
||||||
if(Config.PersonalKits){
|
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){
|
if(personalKit != null){
|
||||||
kit = new Kit(personalKit);
|
kit = new Kit(personalKit);
|
||||||
}
|
}
|
||||||
@ -74,11 +76,16 @@ public class FightPlayer {
|
|||||||
enternCountdown = null;
|
enternCountdown = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public LivingEntity getPlayer() {
|
||||||
Player bukkit = Bukkit.getPlayer(uuid);
|
Player bukkit = Bukkit.getPlayer(uuid);
|
||||||
if(bukkit != null)
|
if(bukkit != null)
|
||||||
player = bukkit;
|
entity = bukkit;
|
||||||
return player;
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void withPlayer(Consumer<Player> function) {
|
||||||
|
if(entity instanceof Player)
|
||||||
|
function.accept((Player) entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLiving() {
|
public boolean isLiving() {
|
||||||
@ -87,7 +94,7 @@ public class FightPlayer {
|
|||||||
|
|
||||||
public boolean isLeader() {
|
public boolean isLeader() {
|
||||||
FightPlayer leader = team.getLeader();
|
FightPlayer leader = team.getLeader();
|
||||||
return leader != null && leader.getPlayer() == player;
|
return leader != null && leader.getPlayer() == entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Kit getKit() {
|
public Kit getKit() {
|
||||||
|
@ -41,6 +41,7 @@ import de.steamwar.techhider.ProtocolUtils;
|
|||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scoreboard.NameTagVisibility;
|
import org.bukkit.scoreboard.NameTagVisibility;
|
||||||
import org.bukkit.scoreboard.Team;
|
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(Config.replayserver(), FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::reset));
|
||||||
new OneShotStateDependent(ArenaMode.All, FightState.PostSchemSetup, () -> {
|
new OneShotStateDependent(ArenaMode.All, FightState.PostSchemSetup, () -> {
|
||||||
if(leader != null)
|
if(leader != null)
|
||||||
notReadyKit.loadToPlayer(leader.getPlayer());
|
leader.withPlayer(notReadyKit::loadToPlayer);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,10 +166,10 @@ public class FightTeam {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void teleportToSpawn(){
|
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());
|
return players.get(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,15 +181,15 @@ public class FightTeam {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayerInTeam(Player player) {
|
public boolean isPlayerInTeam(LivingEntity player) {
|
||||||
return players.containsKey(player.getUniqueId());
|
return players.containsKey(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canPlayerEntern(Player player) {
|
public boolean canPlayerEntern(LivingEntity player) {
|
||||||
return getFightPlayer(player).canEntern();
|
return getFightPlayer(player).canEntern();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayerLeader(Player player) {
|
public boolean isPlayerLeader(LivingEntity player) {
|
||||||
if(leader != null)
|
if(leader != null)
|
||||||
return leader.getPlayer().equals(player);
|
return leader.getPlayer().equals(player);
|
||||||
else
|
else
|
||||||
@ -202,12 +203,12 @@ public class FightTeam {
|
|||||||
|
|
||||||
Set<UUID> playerSet = new HashSet<>(players.keySet());
|
Set<UUID> playerSet = new HashSet<>(players.keySet());
|
||||||
for(UUID uuid : playerSet){
|
for(UUID uuid : playerSet){
|
||||||
Player player = Bukkit.getPlayer(uuid);
|
LivingEntity player = (LivingEntity) Bukkit.getEntity(uuid);
|
||||||
if(player == null)
|
if(player == null)
|
||||||
removePlayer(players.get(uuid).getPlayer());
|
removePlayer(players.get(uuid).getPlayer());
|
||||||
}
|
}
|
||||||
FightPlayer leaderBackup = leader;
|
FightPlayer leaderBackup = leader;
|
||||||
playerSet.removeIf(uuid -> Bukkit.getPlayer(uuid) == null);
|
playerSet.removeIf(uuid -> Bukkit.getEntity(uuid) == null);
|
||||||
players.clear();
|
players.clear();
|
||||||
leader = null;
|
leader = null;
|
||||||
|
|
||||||
@ -216,7 +217,7 @@ public class FightTeam {
|
|||||||
addMember(leaderBackup.getPlayer(), true);
|
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()){
|
if(ArenaMode.VariableTeams.contains(Config.mode) && isLeaderless()){
|
||||||
List<Player> onlinePlayers = new ArrayList<>(Bukkit.getOnlinePlayers());
|
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);
|
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);
|
final List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, false);
|
||||||
FightPlayer fightPlayer = getFightPlayer(player) != null ? getFightPlayer(player) : new FightPlayer(player, this);
|
FightPlayer fightPlayer = getFightPlayer(player) != null ? getFightPlayer(player) : new FightPlayer(player, this);
|
||||||
fightPlayer.revive();
|
fightPlayer.revive();
|
||||||
@ -263,22 +264,26 @@ public class FightTeam {
|
|||||||
team.addEntry(player.getName());
|
team.addEntry(player.getName());
|
||||||
|
|
||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
player.setFoodLevel(20);
|
|
||||||
player.getInventory().clear();
|
|
||||||
BountifulWrapper.impl.setAttackSpeed(player);
|
|
||||||
player.teleport(spawn);
|
player.teleport(spawn);
|
||||||
|
|
||||||
if(FightState.Spectate.contains(FightState.getFightState())) {
|
fightPlayer.withPlayer(p -> {
|
||||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
BountifulWrapper.impl.setAttackSpeed(p);
|
||||||
} else {
|
p.setFoodLevel(20);
|
||||||
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
p.getInventory().clear();
|
||||||
(FightState.ingame() ? fightPlayer.getKit() : memberKit).loadToPlayer(player);
|
|
||||||
}
|
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()))
|
if(FightState.Running.contains(FightState.getFightState()))
|
||||||
fightPlayer.startEnternCountdown();
|
fightPlayer.startEnternCountdown();
|
||||||
|
|
||||||
GlobalRecorder.getInstance().playerJoins(player);
|
GlobalRecorder.getInstance().playerJoins(player);
|
||||||
FightSystem.getTechHider().reloadChunks(player, chunksToReload, false);
|
fightPlayer.withPlayer(p -> FightSystem.getTechHider().reloadChunks(p, chunksToReload, false));
|
||||||
|
|
||||||
if(isLeaderless())
|
if(isLeaderless())
|
||||||
setLeader(fightPlayer, silent);
|
setLeader(fightPlayer, silent);
|
||||||
@ -286,10 +291,10 @@ public class FightTeam {
|
|||||||
FightUI.addSubtitle("UI_PLAYER_JOINS", prefix, player.getName());
|
FightUI.addSubtitle("UI_PLAYER_JOINS", prefix, player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(Player player) {
|
public void removePlayer(LivingEntity player) {
|
||||||
FightPlayer fightPlayer = getFightPlayer(player);
|
FightPlayer fightPlayer = getFightPlayer(player);
|
||||||
|
|
||||||
PersonalKitCreator.closeIfInKitCreator(player);
|
fightPlayer.withPlayer(PersonalKitCreator::closeIfInKitCreator);
|
||||||
List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, true);
|
List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, true);
|
||||||
players.remove(player.getUniqueId());
|
players.remove(player.getUniqueId());
|
||||||
team.removeEntry(player.getName());
|
team.removeEntry(player.getName());
|
||||||
@ -301,16 +306,19 @@ public class FightTeam {
|
|||||||
removeLeader();
|
removeLeader();
|
||||||
|
|
||||||
GlobalRecorder.getInstance().entityDespawns(player);
|
GlobalRecorder.getInstance().entityDespawns(player);
|
||||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
|
||||||
player.teleport(Config.SpecSpawn);
|
player.teleport(Config.SpecSpawn);
|
||||||
player.getInventory().clear();
|
|
||||||
|
|
||||||
if(player.isOnline()){
|
fightPlayer.withPlayer(p -> {
|
||||||
FightSystem.getTechHider().reloadChunks(player, chunksToReload, true);
|
Fight.setPlayerGamemode(p, GameMode.SPECTATOR);
|
||||||
|
p.getInventory().clear();
|
||||||
|
|
||||||
if(ArenaMode.VariableTeams.contains(Config.mode))
|
if(p.isOnline()){
|
||||||
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
|
FightSystem.getTechHider().reloadChunks(p, chunksToReload, true);
|
||||||
}
|
|
||||||
|
if(ArenaMode.VariableTeams.contains(Config.mode))
|
||||||
|
HotbarKit.SPECTATOR_KIT.loadToPlayer(p);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLeaderless() {
|
public boolean isLeaderless() {
|
||||||
@ -335,7 +343,7 @@ public class FightTeam {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setLeader(FightPlayer leader, boolean silent) {
|
private void setLeader(FightPlayer leader, boolean silent) {
|
||||||
PersonalKitCreator.closeIfInKitCreator(leader.getPlayer());
|
leader.withPlayer(PersonalKitCreator::closeIfInKitCreator);
|
||||||
|
|
||||||
this.leader = leader;
|
this.leader = leader;
|
||||||
designatedLeader = null;
|
designatedLeader = null;
|
||||||
@ -354,11 +362,12 @@ public class FightTeam {
|
|||||||
if(!Config.PersonalKits)
|
if(!Config.PersonalKits)
|
||||||
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
|
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
|
||||||
|
|
||||||
Player player = leader.getPlayer();
|
leader.withPlayer(player -> {
|
||||||
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
|
||||||
chooseSchemKit.loadToPlayer(player);
|
chooseSchemKit.loadToPlayer(player);
|
||||||
else
|
else
|
||||||
notReadyKit.loadToPlayer(player);
|
notReadyKit.loadToPlayer(player);
|
||||||
|
});
|
||||||
|
|
||||||
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){
|
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){
|
||||||
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
|
||||||
@ -405,7 +414,7 @@ public class FightTeam {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setReady(boolean ready) {
|
public void setReady(boolean ready) {
|
||||||
Player l = leader.getPlayer();
|
LivingEntity l = leader.getPlayer();
|
||||||
|
|
||||||
if(!schematic.hasSchematic()){
|
if(!schematic.hasSchematic()){
|
||||||
FightSystem.getMessage().sendPrefixless("SCHEMATIC_REQUIRED", l, ChatMessageType.ACTION_BAR);
|
FightSystem.getMessage().sendPrefixless("SCHEMATIC_REQUIRED", l, ChatMessageType.ACTION_BAR);
|
||||||
@ -415,12 +424,12 @@ public class FightTeam {
|
|||||||
this.ready = ready;
|
this.ready = ready;
|
||||||
if(ready) {
|
if(ready) {
|
||||||
broadcast("TEAM_READY");
|
broadcast("TEAM_READY");
|
||||||
readyKit.loadToPlayer(l);
|
leader.withPlayer(readyKit::loadToPlayer);
|
||||||
if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode))
|
if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode))
|
||||||
FightState.setFightState(FightState.PRE_RUNNING);
|
FightState.setFightState(FightState.PRE_RUNNING);
|
||||||
} else {
|
} else {
|
||||||
broadcast("TEAM_NOT_READY");
|
broadcast("TEAM_NOT_READY");
|
||||||
notReadyKit.loadToPlayer(l);
|
leader.withPlayer(notReadyKit::loadToPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,17 +502,18 @@ public class FightTeam {
|
|||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
for(FightPlayer fightPlayer : players.values()) {
|
for(FightPlayer fightPlayer : players.values()) {
|
||||||
Player player = fightPlayer.getPlayer();
|
fightPlayer.withPlayer(player -> {
|
||||||
PersonalKitCreator.closeIfInKitCreator(player);
|
PersonalKitCreator.closeIfInKitCreator(player);
|
||||||
|
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
fightPlayer.getKit().loadToPlayer(player);
|
fightPlayer.getKit().loadToPlayer(player);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
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
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
players.values().forEach(fightPlayer -> {
|
players.values().forEach(fightPlayer -> {
|
||||||
Fight.setPlayerGamemode(fightPlayer.getPlayer(), GameMode.SPECTATOR);
|
fightPlayer.withPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SPECTATOR));
|
||||||
fightPlayer.getPlayer().teleport(FightTeam.this.spawn);
|
fightPlayer.getPlayer().teleport(FightTeam.this.spawn);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,11 +68,10 @@ public class JoinRequest {
|
|||||||
if(leader == null)
|
if(leader == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Player leaderPlayer = leader.getPlayer();
|
if(leader.getPlayer() == null)
|
||||||
if(leaderPlayer == null)
|
|
||||||
continue;
|
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);
|
activeRequests.put(player, this);
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
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;
|
||||||
@ -28,7 +27,7 @@ import de.steamwar.fightsystem.states.StateDependentListener;
|
|||||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
@ -43,25 +42,25 @@ public class InFightDamage implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||||
if(!(event.getEntity() instanceof Player))
|
if(!(event.getEntity() instanceof LivingEntity))
|
||||||
//Target is not a player
|
//Target is not a player
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = ((Player) event.getEntity());
|
LivingEntity player = ((LivingEntity) event.getEntity());
|
||||||
if(!Fight.fighting(player))
|
if(!Fight.fighting(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player damager;
|
LivingEntity damager;
|
||||||
|
|
||||||
if(event.getDamager() instanceof Player) {
|
if(event.getDamager() instanceof LivingEntity) {
|
||||||
damager = ((Player) event.getDamager()).getPlayer();
|
damager = (LivingEntity) event.getDamager();
|
||||||
}else if(event.getDamager() instanceof Arrow) {
|
}else if(event.getDamager() instanceof Arrow) {
|
||||||
Arrow damagerArrow = (Arrow) event.getDamager();
|
Arrow damagerArrow = (Arrow) event.getDamager();
|
||||||
if(!(damagerArrow.getShooter() instanceof Player))
|
if(!(damagerArrow.getShooter() instanceof LivingEntity))
|
||||||
//Shooter is not a player
|
//Shooter is not a player
|
||||||
return;
|
return;
|
||||||
|
|
||||||
damager = (Player) damagerArrow.getShooter();
|
damager = (LivingEntity) damagerArrow.getShooter();
|
||||||
}else{
|
}else{
|
||||||
//Damager is not a player
|
//Damager is not a player
|
||||||
return;
|
return;
|
||||||
|
@ -26,10 +26,12 @@ import de.steamwar.fightsystem.states.FightState;
|
|||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.fightsystem.utils.FightUI;
|
import de.steamwar.fightsystem.utils.FightUI;
|
||||||
import de.steamwar.fightsystem.utils.SWSound;
|
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.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
@ -42,7 +44,7 @@ public class IngameDeath implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void broadcastDeath(PlayerDeathEvent event) {
|
public void broadcastDeath(EntityDeathEvent event) {
|
||||||
onPlayerEnd(event.getEntity(), fightPlayer -> {
|
onPlayerEnd(event.getEntity(), fightPlayer -> {
|
||||||
FightUI.addSubtitle("UI_PLAYER_DEATH", fightPlayer.getTeam().getPrefix(), fightPlayer.getPlayer().getName());
|
FightUI.addSubtitle("UI_PLAYER_DEATH", fightPlayer.getTeam().getPrefix(), fightPlayer.getPlayer().getName());
|
||||||
Fight.playSound(SWSound.ENTITY_WITHER_DEATH.getSound(), 100.0F, 1.0F);
|
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);
|
onPlayerEnd(event.getPlayer(), FightPlayer::setOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPlayerEnd(Player player, Consumer<FightPlayer> withLivingPlayer) {
|
private void onPlayerEnd(Entity player, Consumer<FightPlayer> withLivingPlayer) {
|
||||||
FightPlayer fightPlayer = Fight.getFightPlayer(player);
|
if(!(player instanceof LivingEntity))
|
||||||
|
return;
|
||||||
|
|
||||||
|
FightPlayer fightPlayer = Fight.getFightPlayer((LivingEntity) player);
|
||||||
if(fightPlayer == null || !fightPlayer.isLiving())
|
if(fightPlayer == null || !fightPlayer.isLiving())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -20,10 +20,14 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
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.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
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
|
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
|
).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);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,10 @@ import de.steamwar.fightsystem.states.FightState;
|
|||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
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.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -281,12 +284,13 @@ public class Recording implements Listener {
|
|||||||
if(!fp.isLiving())
|
if(!fp.isLiving())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Player player = fp.getPlayer();
|
fp.withPlayer(player -> {
|
||||||
BountifulWrapper.impl.recordHandItems(player);
|
BountifulWrapper.impl.recordHandItems(player);
|
||||||
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getHelmet()), "HEAD");
|
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().getChestplate()), "CHEST");
|
||||||
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getLeggings()), "LEGS");
|
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getLeggings()), "LEGS");
|
||||||
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getBoots()), "FEET");
|
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getBoots()), "FEET");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
@ -148,7 +149,7 @@ public interface Recorder {
|
|||||||
* 0x08: Message following
|
* 0x08: Message following
|
||||||
* */
|
* */
|
||||||
|
|
||||||
default void playerJoins(Player p){
|
default void playerJoins(LivingEntity p){
|
||||||
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
||||||
|
|
||||||
write(0x00, p.getEntityId(), user.getId());
|
write(0x00, p.getEntityId(), user.getId());
|
||||||
|
@ -30,6 +30,7 @@ import de.steamwar.techhider.ProtocolUtils;
|
|||||||
import de.steamwar.techhider.TechHider;
|
import de.steamwar.techhider.TechHider;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -58,13 +59,13 @@ public class TechHiderWrapper extends StateDependent {
|
|||||||
techHider.disable();
|
techHider.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProtocolUtils.ChunkPos> prepareChunkReload(Player p, boolean hide) {
|
public List<ProtocolUtils.ChunkPos> prepareChunkReload(LivingEntity p, boolean hide) {
|
||||||
if(!ENABLED)
|
if(!ENABLED || !(p instanceof Player))
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
||||||
List<ProtocolUtils.ChunkPos> chunksToReload = new ArrayList<>();
|
List<ProtocolUtils.ChunkPos> chunksToReload = new ArrayList<>();
|
||||||
Config.ArenaRegion.forEachChunk((x, z) -> {
|
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));
|
chunksToReload.add(new ProtocolUtils.ChunkPos(x, z));
|
||||||
});
|
});
|
||||||
return chunksToReload;
|
return chunksToReload;
|
||||||
|
@ -24,7 +24,8 @@ import de.steamwar.fightsystem.countdown.Countdown;
|
|||||||
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.states.StateDependentCountdown;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -53,8 +54,11 @@ public abstract class Wincondition {
|
|||||||
FightSystem.setSpectateState(team, windescription, subtitle, params);
|
FightSystem.setSpectateState(team, windescription, subtitle, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected FightTeam isTarget(Player player){
|
protected FightTeam isTarget(Entity player){
|
||||||
return Fight.getPlayerTeam(player);
|
if(!(player instanceof LivingEntity))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return Fight.getPlayerTeam((LivingEntity) player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<PrintableWincondition> getPrintableWinconditions(){
|
public static List<PrintableWincondition> getPrintableWinconditions(){
|
||||||
|
@ -24,10 +24,10 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
|||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
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.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
public class WinconditionAllDead extends Wincondition implements Listener {
|
public class WinconditionAllDead extends Wincondition implements Listener {
|
||||||
@ -38,8 +38,8 @@ public class WinconditionAllDead extends Wincondition implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerDeath(PlayerDeathEvent event) {
|
public void handlePlayerDeath(EntityDeathEvent event) {
|
||||||
handleDeath(event.getEntity().getPlayer());
|
handleDeath(event.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -47,7 +47,7 @@ public class WinconditionAllDead extends Wincondition implements Listener {
|
|||||||
handleDeath(event.getPlayer());
|
handleDeath(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDeath(Player player){
|
private void handleDeath(Entity player){
|
||||||
FightTeam team = isTarget(player);
|
FightTeam team = isTarget(player);
|
||||||
if(team == null)
|
if(team == null)
|
||||||
return;
|
return;
|
||||||
|
@ -23,10 +23,11 @@ import de.steamwar.fightsystem.fight.Fight;
|
|||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
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.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
public class WinconditionCaptainDead extends Wincondition implements Listener {
|
public class WinconditionCaptainDead extends Wincondition implements Listener {
|
||||||
@ -37,8 +38,8 @@ public class WinconditionCaptainDead extends Wincondition implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerDeath(PlayerDeathEvent event) {
|
public void handlePlayerDeath(EntityDeathEvent event) {
|
||||||
handleDeath(event.getEntity().getPlayer());
|
handleDeath(event.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -46,12 +47,12 @@ public class WinconditionCaptainDead extends Wincondition implements Listener {
|
|||||||
handleDeath(event.getPlayer());
|
handleDeath(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDeath(Player player){
|
private void handleDeath(Entity player){
|
||||||
FightTeam team = isTarget(player);
|
FightTeam team = isTarget(player);
|
||||||
if(team == null)
|
if(team == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(team.isPlayerLeader(player)) {
|
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().getPlayer().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren