Plugin %10 remaining

This commit is contained in:
BunSLaPatate
2018-09-22 13:36:53 +02:00
parent f3ccaef86c
commit b21c91c09a
4 changed files with 64 additions and 34 deletions

View File

@@ -17,6 +17,9 @@ public class WinManager {
if (teamManager.getTeamPlayerCount(teamInfos) >= 1) { if (teamManager.getTeamPlayerCount(teamInfos) >= 1) {
++teamLeft; ++teamLeft;
} }
if(teamManager.getPlayerTeamList(teamInfos).size() == 0){
teamManager.getTeamBoss(teamInfos).getWitch().remove();
}
} }
if (teamLeft == 1) { if (teamLeft == 1) {
for (final TeamInfos teamInfos : TeamInfos.values()) { for (final TeamInfos teamInfos : TeamInfos.values()) {

View File

@@ -45,6 +45,7 @@ public class DeathEvent implements Listener {
switch (WitchRush.get().getState()){ switch (WitchRush.get().getState()){
case PVP: case PVP:
if(!teamManager.isInLife(teamManager.getPlayerTeam(player))){ if(!teamManager.isInLife(teamManager.getPlayerTeam(player))){
checkDrop(e);
TeamInfos team = WitchRush.get().getTeamManager().getPlayerTeam(player); TeamInfos team = WitchRush.get().getTeamManager().getPlayerTeam(player);
e.setDeathMessage(WitchRush.prefix()+team.getChatColor()+player.getName()+"§c est éliminé"); e.setDeathMessage(WitchRush.prefix()+team.getChatColor()+player.getName()+"§c est éliminé");
witchPlayer.setDeath(witchPlayer.getDeath()+1); witchPlayer.setDeath(witchPlayer.getDeath()+1);
@@ -59,14 +60,15 @@ public class DeathEvent implements Listener {
player.sendMessage(" "); player.sendMessage(" ");
TeamsTagsManager.setNameTag(player, player.getName(), "§8(Spec)§7 "); TeamsTagsManager.setNameTag(player, player.getName(), "§8(Spec)§7 ");
} else {
teamvictim = WitchRush.get().getTeamManager().getPlayerTeam(player);
teamKiller = WitchRush.get().getTeamManager().getPlayerTeam(killer);
e.setDeathMessage(WitchRush.prefix()+teamvictim.getChatColor()+player.getName()+"§d a été tué par "+teamKiller.getChatColor()+ killer.getName());
checkDrop(e);
new DeadPlayer(player);
witchKiller.setKills(witchKiller.getKills()+1);
witchPlayer.setDeath(witchPlayer.getDeath()+1);
} }
teamvictim = WitchRush.get().getTeamManager().getPlayerTeam(player);
teamKiller = WitchRush.get().getTeamManager().getPlayerTeam(killer);
e.setDeathMessage(WitchRush.prefix()+teamvictim.getChatColor()+player.getName()+"§d a été tué par "+teamKiller.getChatColor()+ killer.getName());
new DeadPlayer(player);
witchKiller.setKills(witchKiller.getKills()+1);
witchPlayer.setDeath(witchPlayer.getDeath()+1);
break; break;
case NOWITCH: case NOWITCH:
teamvictim = WitchRush.get().getTeamManager().getPlayerTeam(player); teamvictim = WitchRush.get().getTeamManager().getPlayerTeam(player);
@@ -81,6 +83,7 @@ public class DeathEvent implements Listener {
} else { } else {
TeamInfos team = WitchRush.get().getTeamManager().getPlayerTeam(player); TeamInfos team = WitchRush.get().getTeamManager().getPlayerTeam(player);
e.setDeathMessage(WitchRush.prefix()+team.getChatColor()+player.getName()+"§d est mort"); e.setDeathMessage(WitchRush.prefix()+team.getChatColor()+player.getName()+"§d est mort");
checkDrop(e);
new DeadPlayer(player); new DeadPlayer(player);
player.setHealth(20); player.setHealth(20);
witchPlayer.setDeath(witchPlayer.getDeath()+1); witchPlayer.setDeath(witchPlayer.getDeath()+1);
@@ -91,30 +94,55 @@ public class DeathEvent implements Listener {
@EventHandler @EventHandler
public void onEntityDeath(final EntityDeathEvent e) { public void onEntityDeath(final EntityDeathEvent e) {
if (e.getEntity() instanceof Witch) { if (e.getEntity() instanceof Witch) {
final Witch witch = (Witch)e.getEntity(); if(WitchRush.get().getState().equals(GameState.PVP)){
final TeamManager teamManager = WitchRush.get().getTeamManager(); final Witch witch = (Witch)e.getEntity();
for (final ItemStack itemStack : e.getDrops()) { final TeamManager teamManager = WitchRush.get().getTeamManager();
itemStack.setType(Material.AIR); for (final ItemStack itemStack : e.getDrops()) {
} itemStack.setType(Material.AIR);
TeamInfos teamInfos = null;
for (final TeamInfos teamInfosList : TeamInfos.values()) {
if (teamManager.getTeamBoss(teamInfosList).getWitch().equals(witch)) {
teamInfos = teamInfosList;
} }
} TeamInfos teamInfos = null;
Bukkit.broadcastMessage(WitchRush.prefix()+"L'équipe "+teamInfos.getChatColor()+teamInfos.getTeamName()+" §dest morte !"); for (final TeamInfos teamInfosList : TeamInfos.values()) {
if (e.getEntity().getKiller() instanceof Player) { if (teamManager.getTeamBoss(teamInfosList).getWitch().equals(witch)) {
Bukkit.getPluginManager().callEvent(new BossDeathEvent(teamInfos, e.getEntity().getKiller())); teamInfos = teamInfosList;
teamManager.getBossEntityMap().remove(teamInfos); }
new HealthRunnable().arMap.remove(teamInfos); }
} Bukkit.broadcastMessage(WitchRush.prefix()+"L'équipe "+teamInfos.getChatColor()+teamInfos.getTeamName()+" §dest morte !");
for (final Player playerOnline : Bukkit.getOnlinePlayers()) { if (e.getEntity().getKiller() instanceof Player) {
playerOnline.playSound(playerOnline.getLocation(), Sound.ENTITY_WITHER_DEATH, 1.0f, 1.0f); Bukkit.getPluginManager().callEvent(new BossDeathEvent(teamInfos, e.getEntity().getKiller()));
if (teamManager.isPlayerInTeam(playerOnline, teamInfos)) { teamManager.getBossEntityMap().remove(teamInfos);
playerOnline.sendMessage(WitchRush.prefix()+"Votre Boss est mort! Ne mourrez pas !"); new HealthRunnable().arMap.remove(teamInfos);
playerOnline.sendTitle("§cAttention","Votre boss est mort !"); }
for (final Player playerOnline : Bukkit.getOnlinePlayers()) {
playerOnline.playSound(playerOnline.getLocation(), Sound.ENTITY_WITHER_DEATH, 1.0f, 1.0f);
if (teamManager.isPlayerInTeam(playerOnline, teamInfos)) {
playerOnline.sendMessage(WitchRush.prefix()+"Votre Boss est mort! Ne mourrez pas !");
playerOnline.sendTitle("§cAttention","Votre boss est mort !");
}
} }
} }
} }
} }
private void checkDrop(PlayerDeathEvent e){
for(int i = 0; i<e.getDrops().size(); i++){
ItemStack stack = e.getDrops().get(i);
switch (stack.getType()){
case LEATHER_BOOTS:
e.getDrops().get(i).setType(Material.AIR);
break;
case LEATHER_LEGGINGS:
e.getDrops().get(i).setType(Material.AIR);
break;
case LEATHER_CHESTPLATE:
e.getDrops().get(i).setType(Material.AIR);
break;
case LEATHER_HELMET:
e.getDrops().get(i).setType(Material.AIR);
break;
case DIAMOND_SWORD:
e.getDrops().get(i).setType(Material.AIR);
break;
}
}
}
} }

View File

@@ -43,13 +43,13 @@ public class TeamManager {
} }
public void addPlayerInRandomTeam(final Player player) { public void addPlayerInRandomTeam(final Player player) {
TreeMap<TeamInfos, Player> teams = new TreeMap<>(); TreeMap<TeamInfos, List<Player>> teamMap = new TreeMap<>();
for(TeamInfos infos : TeamInfos.values()){ for(TeamInfos infos : TeamInfos.values()){
for(Player pls: Bukkit.getOnlinePlayers()){ for(Player pls: Bukkit.getOnlinePlayers()){
if(!isPlayerInTeam(pls , infos)) teams.put(infos, pls); if(!isPlayerInTeam(pls , infos)) teamMap.put(infos, getPlayerTeamList(infos));
} }
} }
if(!playerHaveTeam(player)) addPlayerTeam(player, teams.firstKey()); if(!playerHaveTeam(player)) addPlayerTeam(player, teamMap.lastKey());
} }
public void checkNoTeamPlayers() { public void checkNoTeamPlayers() {
@@ -117,7 +117,7 @@ public class TeamManager {
if (this.playerTeamList.get(teamInfos) != null) { if (this.playerTeamList.get(teamInfos) != null) {
return this.playerTeamList.get(teamInfos); return this.playerTeamList.get(teamInfos);
} }
return new ArrayList<Player>(); return new ArrayList<>();
} }
public Integer getPlayerTeamLimit() { public Integer getPlayerTeamLimit() {

View File

@@ -21,8 +21,7 @@ public class DeadPlayer {
this.witchPlayer.setSpectator(true); this.witchPlayer.setSpectator(true);
player.setHealth(20); player.setHealth(20);
player.setGameMode(GameMode.SPECTATOR); player.setGameMode(GameMode.SPECTATOR);
player.teleport(Locations.SPAWN_SPECTATORS.getLocation()); player.sendTitle("§cVous êtes mort", " ");
player.sendTitle("§cVous êtes mort", null);
task = Bukkit.getScheduler().runTaskTimer(WitchRush.get(), new Runnable() { task = Bukkit.getScheduler().runTaskTimer(WitchRush.get(), new Runnable() {
@Override @Override
public void run() { public void run() {