From 16fa9a695d787138265df2d082d439d7c81c0d73 Mon Sep 17 00:00:00 2001 From: BunSLaPatate Date: Sat, 13 Oct 2018 19:52:09 +0200 Subject: [PATCH] Soon done inshallah --- .../net/berrygames/witchrush/WitchRush.java | 22 ++- .../commands/admins/LocationsCMD.java | 160 +++++++++--------- .../witchrush/game/GameManager.java | 2 +- .../listeners/entities/DamageEvent.java | 6 +- .../listeners/entities/EntityDeath.java | 15 +- .../listeners/players/PlayerChat.java | 2 +- .../listeners/players/PlayerJoin.java | 1 + .../listeners/players/PlayerQuit.java | 1 + .../witchrush/team/TeamManager.java | 52 +++--- .../berrygames/witchrush/team/TeamsInfos.java | 16 +- .../berrygames/witchrush/team/TeamsMenu.java | 27 ++- .../witchrush/tools/ItemFactory.java | 6 + 12 files changed, 161 insertions(+), 149 deletions(-) diff --git a/WitchRush/src/main/java/net/berrygames/witchrush/WitchRush.java b/WitchRush/src/main/java/net/berrygames/witchrush/WitchRush.java index 551a93e..fcf7287 100644 --- a/WitchRush/src/main/java/net/berrygames/witchrush/WitchRush.java +++ b/WitchRush/src/main/java/net/berrygames/witchrush/WitchRush.java @@ -6,6 +6,7 @@ import net.berrygames.witchrush.listeners.ListenersManager; import net.berrygames.witchrush.team.TeamManager; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; @@ -63,6 +64,19 @@ public class WitchRush extends JavaPlugin { } } + public void setConf(String path, Object value){ + this.conf.set(path, value); + try { + this.conf.save(this.file); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public FileConfiguration getConf(){ + return conf; + } + @Override public void onDisable() { System.out.println("*-*-*-*-*-*-*-*"); @@ -72,18 +86,14 @@ public class WitchRush extends JavaPlugin { System.out.println("*-*-*-*-*-*-*-*"); super.onDisable(); - for(Player pls : Bukkit.getOnlinePlayers()){ - pls.kickPlayer(ChatColor.RED+"Le serveur redémarre"); - } + Bukkit.getOnlinePlayers().forEach(pls -> pls.kickPlayer(ChatColor.RED+"Le serveur redémarre")); + Bukkit.getWorld("world").getEntities().forEach(en -> en.remove()); } @Override public File getFile() { return file; } - public FileConfiguration getMode() { - return conf; - } public TeamManager getTeamManager() { return teamManager; diff --git a/WitchRush/src/main/java/net/berrygames/witchrush/commands/admins/LocationsCMD.java b/WitchRush/src/main/java/net/berrygames/witchrush/commands/admins/LocationsCMD.java index d5186d0..628a827 100644 --- a/WitchRush/src/main/java/net/berrygames/witchrush/commands/admins/LocationsCMD.java +++ b/WitchRush/src/main/java/net/berrygames/witchrush/commands/admins/LocationsCMD.java @@ -23,35 +23,35 @@ public class LocationsCMD implements CommandExecutor { case "bleu": switch (args[1].toLowerCase()){ case "shop": - WitchRush.get().getMode().set("teams.bleu.shop.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.bleu.shop.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.bleu.shop.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.bleu.shop.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.bleu.shop.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.bleu.shop.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.bleu.shop.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.bleu.shop.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.bleu.shop.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.bleu.shop.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; case "spawn": - WitchRush.get().getMode().set("teams.bleu.spawn.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.bleu.spawn.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.bleu.spawn.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.bleu.spawn.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.bleu.spawn.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.bleu.spawn.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.bleu.spawn.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.bleu.spawn.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.bleu.spawn.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.bleu.spawn.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; case "upgrade": - WitchRush.get().getMode().set("teams.bleu.upgrade.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.bleu.upgrade.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.bleu.upgrade.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.bleu.upgrade.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.bleu.upgrade.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.bleu.upgrade.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.bleu.upgrade.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.bleu.upgrade.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.bleu.upgrade.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.bleu.upgrade.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; case "boss": - WitchRush.get().getMode().set("teams.bleu.boss.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.bleu.boss.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.bleu.boss.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.bleu.boss.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.bleu.boss.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.bleu.boss.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.bleu.boss.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.bleu.boss.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.bleu.boss.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.bleu.boss.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; default: @@ -62,35 +62,35 @@ public class LocationsCMD implements CommandExecutor { case "vert": switch (args[1].toLowerCase()){ case "shop": - WitchRush.get().getMode().set("teams.vert.shop.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.vert.shop.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.vert.shop.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.vert.shop.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.vert.shop.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.vert.shop.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.vert.shop.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.vert.shop.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.vert.shop.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.vert.shop.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; case "spawn": - WitchRush.get().getMode().set("teams.vert.spawn.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.vert.spawn.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.vert.spawn.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.vert.spawn.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.vert.spawn.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.vert.spawn.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.vert.spawn.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.vert.spawn.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.vert.spawn.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.vert.spawn.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; case "upgrade": - WitchRush.get().getMode().set("teams.vert.upgrade.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.vert.upgrade.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.vert.upgrade.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.vert.upgrade.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.vert.upgrade.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.vert.upgrade.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.vert.upgrade.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.vert.upgrade.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.vert.upgrade.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.vert.upgrade.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; case "boss": - WitchRush.get().getMode().set("teams.vert.boss.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.vert.boss.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.vert.boss.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.vert.boss.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.vert.boss.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.vert.boss.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.vert.boss.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.vert.boss.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.vert.boss.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.vert.boss.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; default: @@ -101,35 +101,35 @@ public class LocationsCMD implements CommandExecutor { case "jaune": switch (args[1].toLowerCase()){ case "shop": - WitchRush.get().getMode().set("teams.jaune.shop.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.jaune.shop.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.jaune.shop.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.jaune.shop.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.jaune.shop.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.jaune.shop.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.jaune.shop.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.jaune.shop.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.jaune.shop.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.jaune.shop.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; case "spawn": - WitchRush.get().getMode().set("teams.jaune.spawn.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.jaune.spawn.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.jaune.spawn.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.jaune.spawn.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.jaune.spawn.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.jaune.spawn.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.jaune.spawn.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.jaune.spawn.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.jaune.spawn.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.jaune.spawn.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; case "upgrade": - WitchRush.get().getMode().set("teams.jaune.upgrade.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.jaune.upgrade.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.jaune.upgrade.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.jaune.upgrade.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.jaune.upgrade.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.jaune.upgrade.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.jaune.upgrade.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.jaune.upgrade.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.jaune.upgrade.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.jaune.upgrade.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; case "boss": - WitchRush.get().getMode().set("teams.jaune.boss.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.jaune.boss.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.jaune.boss.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.jaune.boss.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.jaune.boss.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.jaune.boss.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.jaune.boss.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.jaune.boss.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.jaune.boss.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.jaune.boss.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; default: @@ -140,35 +140,35 @@ public class LocationsCMD implements CommandExecutor { case "rouge": switch (args[1].toLowerCase()){ case "shop": - WitchRush.get().getMode().set("teams.rouge.shop.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.rouge.shop.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.rouge.shop.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.rouge.shop.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.rouge.shop.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.rouge.shop.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.rouge.shop.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.rouge.shop.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.rouge.shop.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.rouge.shop.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; case "spawn": - WitchRush.get().getMode().set("teams.rouge.spawn.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.rouge.spawn.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.rouge.spawn.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.rouge.spawn.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.rouge.spawn.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.rouge.spawn.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.rouge.spawn.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.rouge.spawn.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.rouge.spawn.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.rouge.spawn.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; case "upgrade": - WitchRush.get().getMode().set("teams.rouge.upgrade.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.rouge.upgrade.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.rouge.upgrade.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.rouge.upgrade.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.rouge.upgrade.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.rouge.upgrade.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.rouge.upgrade.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.rouge.upgrade.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.rouge.upgrade.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.rouge.upgrade.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; case "boss": - WitchRush.get().getMode().set("teams.rouge.boss.x", player.getLocation().getX()); - WitchRush.get().getMode().set("teams.rouge.boss.y", player.getLocation().getY()); - WitchRush.get().getMode().set("teams.rouge.boss.z", player.getLocation().getZ()); - WitchRush.get().getMode().set("teams.rouge.boss.yaw", player.getLocation().getYaw()); - WitchRush.get().getMode().set("teams.rouge.boss.pitch", player.getLocation().getPitch()); + WitchRush.get().setConf("teams.rouge.boss.x", player.getLocation().getX()); + WitchRush.get().setConf("teams.rouge.boss.y", player.getLocation().getY()); + WitchRush.get().setConf("teams.rouge.boss.z", player.getLocation().getZ()); + WitchRush.get().setConf("teams.rouge.boss.yaw", player.getLocation().getYaw()); + WitchRush.get().setConf("teams.rouge.boss.pitch", player.getLocation().getPitch()); player.sendMessage("Location ajoutée !"); break; default: diff --git a/WitchRush/src/main/java/net/berrygames/witchrush/game/GameManager.java b/WitchRush/src/main/java/net/berrygames/witchrush/game/GameManager.java index 7e59277..02b368a 100644 --- a/WitchRush/src/main/java/net/berrygames/witchrush/game/GameManager.java +++ b/WitchRush/src/main/java/net/berrygames/witchrush/game/GameManager.java @@ -47,7 +47,7 @@ public class GameManager { } new HealthRunnable().runTaskTimer(WitchRush.get(), 0L, 20L); - }, 10 * 20); + }, 3 * 20 * 60); } } diff --git a/WitchRush/src/main/java/net/berrygames/witchrush/listeners/entities/DamageEvent.java b/WitchRush/src/main/java/net/berrygames/witchrush/listeners/entities/DamageEvent.java index b5c8d0d..a4b2b16 100644 --- a/WitchRush/src/main/java/net/berrygames/witchrush/listeners/entities/DamageEvent.java +++ b/WitchRush/src/main/java/net/berrygames/witchrush/listeners/entities/DamageEvent.java @@ -4,6 +4,8 @@ import net.berrygames.witchrush.WitchRush; import net.berrygames.witchrush.game.GameState; import net.berrygames.witchrush.team.TeamsInfos; import net.berrygames.witchrush.team.TeamManager; +import org.bukkit.Bukkit; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.entity.Witch; import org.bukkit.event.EventHandler; @@ -31,7 +33,7 @@ public class DamageEvent implements Listener { player.sendMessage("§cVous ne pouvez pas tuer votre boss !"); return; } - /*for(TeamsInfos infos : TeamsInfos.values()){ + for(TeamsInfos infos : TeamsInfos.values()){ if(teamManager.getTeamBoss(infos).getWitch().equals(witch)){ Bukkit.getOnlinePlayers().forEach(pls -> { if(teamManager.getPlayerTeam(pls).equals(infos)){ @@ -40,7 +42,7 @@ public class DamageEvent implements Listener { } }); } - }*/ + } break; case VILLAGER: if(e.getDamager() instanceof Player) e.setCancelled(true); diff --git a/WitchRush/src/main/java/net/berrygames/witchrush/listeners/entities/EntityDeath.java b/WitchRush/src/main/java/net/berrygames/witchrush/listeners/entities/EntityDeath.java index 1e68448..4194a9a 100644 --- a/WitchRush/src/main/java/net/berrygames/witchrush/listeners/entities/EntityDeath.java +++ b/WitchRush/src/main/java/net/berrygames/witchrush/listeners/entities/EntityDeath.java @@ -34,19 +34,16 @@ public class EntityDeath implements Listener { teamInfos = teamInfosList; } } - System.out.println(witch.getCustomName()); - System.out.println(witch.getName()); - System.out.println(teamManager.getTeamBoss(teamInfos).getWitch().getCustomName()); - System.out.println(teamManager.getTeamBoss(teamInfos).getWitch().getName()); if(teamManager.getTeamBoss(teamInfos).getWitch().equals(witch)){ - Bukkit.broadcastMessage(WitchRush.prefix()+" Le boss des"+teamInfos.getChatColor()+teamInfos.getTeamName()+"s §dest mort"); - TeamsInfos finalTeamInfos = teamInfos; + Bukkit.broadcastMessage(WitchRush.prefix()+" Le boss des "+teamInfos.getChatColor()+teamInfos.getTeamName().toUpperCase()+"s §dest mort"); + final TeamsInfos finalTeamInfos = teamInfos; Bukkit.getOnlinePlayers().forEach(pls -> { pls.playSound(pls.getLocation(), Sound.ENTITY_WITHER_DEATH, 1.0f, 1.0f); if(teamManager.isPlayerInTeam(pls, finalTeamInfos)){ - pls.sendMessage("Votre boss est mort !"); - pls.sendMessage("Ne mourrez pas"); - pls.sendTitle("§cAttention","Votre boss est mort !"); + pls.sendMessage("§4Votre boss est mort !"); + pls.sendMessage("§4Ne mourrez pas"); + pls.sendTitle("§cAttention","§c§oVotre boss est mort !"); + teamManager.getBossEntityMap().remove(finalTeamInfos); } }); } diff --git a/WitchRush/src/main/java/net/berrygames/witchrush/listeners/players/PlayerChat.java b/WitchRush/src/main/java/net/berrygames/witchrush/listeners/players/PlayerChat.java index 4c7d7c5..59a2f37 100644 --- a/WitchRush/src/main/java/net/berrygames/witchrush/listeners/players/PlayerChat.java +++ b/WitchRush/src/main/java/net/berrygames/witchrush/listeners/players/PlayerChat.java @@ -39,7 +39,7 @@ public class PlayerChat implements Listener { Bukkit.getOnlinePlayers().forEach(playerOnline -> { final TeamsInfos teamInfos = WitchRush.get().getTeamManager().getPlayerTeam(player); if(WitchRush.get().getTeamManager().getPlayerTeam(playerOnline).equals(teamInfos)){ - playerOnline.sendMessage("§7["+teamInfos.getChatColor()+teamInfos.getTeamName()+"§7] " + playerOnline.sendMessage("§7["+teamInfos.getChatColor()+teamInfos.getIDName()+"§7] " +WitchRush.get().getTeamManager().getPlayerTeam(playerOnline).getChatColor() +player.getDisplayName()+" §7» §f"+message.replace("!","§r")); } diff --git a/WitchRush/src/main/java/net/berrygames/witchrush/listeners/players/PlayerJoin.java b/WitchRush/src/main/java/net/berrygames/witchrush/listeners/players/PlayerJoin.java index f4bc698..d79f896 100644 --- a/WitchRush/src/main/java/net/berrygames/witchrush/listeners/players/PlayerJoin.java +++ b/WitchRush/src/main/java/net/berrygames/witchrush/listeners/players/PlayerJoin.java @@ -52,6 +52,7 @@ public class PlayerJoin implements Listener { player.sendMessage("§7Seuls les autres spectateurs voient vos messages !"); player.sendMessage(" "); e.setJoinMessage(null); + witchPlayer.setSpectator(true); player.setGameMode(GameMode.SPECTATOR); player.setLevel(0); player.setHealth(20); diff --git a/WitchRush/src/main/java/net/berrygames/witchrush/listeners/players/PlayerQuit.java b/WitchRush/src/main/java/net/berrygames/witchrush/listeners/players/PlayerQuit.java index c8790cb..1a66f0d 100644 --- a/WitchRush/src/main/java/net/berrygames/witchrush/listeners/players/PlayerQuit.java +++ b/WitchRush/src/main/java/net/berrygames/witchrush/listeners/players/PlayerQuit.java @@ -25,6 +25,7 @@ public class PlayerQuit implements Listener { e.setQuitMessage(null); break; case GAME: + if(witchPlayer.isSpectator()) return; e.setQuitMessage( WitchRush.prefix()+"§e"+player.getName()+ " §da quitté la partie §7(§d"+ diff --git a/WitchRush/src/main/java/net/berrygames/witchrush/team/TeamManager.java b/WitchRush/src/main/java/net/berrygames/witchrush/team/TeamManager.java index e4095ff..eb9a32b 100644 --- a/WitchRush/src/main/java/net/berrygames/witchrush/team/TeamManager.java +++ b/WitchRush/src/main/java/net/berrygames/witchrush/team/TeamManager.java @@ -55,46 +55,40 @@ public class TeamManager { } public boolean isInLife(final TeamsInfos teamInfos) { - if(getBossEntityMap().containsKey(teamInfos)){ - return true; - } - return false; + return getBossEntityMap().containsKey(teamInfos); } public Location getBossLocation(final TeamsInfos teamInfos) { return new Location(Bukkit.getWorld("world"), - WitchRush.get().getMode().getDouble("teams."+teamInfos.getTeamName()+".boss.x"), - WitchRush.get().getMode().getDouble("teams."+teamInfos.getTeamName()+".boss.y"), - WitchRush.get().getMode().getDouble("teams."+teamInfos.getTeamName()+".boss.z"), - WitchRush.get().getMode().getLong("teams."+teamInfos.getTeamName()+".boss.yaw"), - WitchRush.get().getMode().getLong("teams."+teamInfos.getTeamName()+".boss.pitch")); + WitchRush.get().getConf().getDouble("teams."+teamInfos.getTeamName()+".boss.x"), + WitchRush.get().getConf().getDouble("teams."+teamInfos.getTeamName()+".boss.y"), + WitchRush.get().getConf().getDouble("teams."+teamInfos.getTeamName()+".boss.z"), + WitchRush.get().getConf().getLong("teams."+teamInfos.getTeamName()+".boss.yaw"), + WitchRush.get().getConf().getLong("teams."+teamInfos.getTeamName()+".boss.pitch")); } - public Location getShopLocation(final TeamsInfos teamInfos) { return new Location(Bukkit.getWorld("world"), - WitchRush.get().getMode().getDouble("teams."+teamInfos.getTeamName()+".shop.x"), - WitchRush.get().getMode().getDouble("teams."+teamInfos.getTeamName()+".shop.y"), - WitchRush.get().getMode().getDouble("teams."+teamInfos.getTeamName()+".shop.z"), - WitchRush.get().getMode().getLong("teams."+teamInfos.getTeamName()+".shop.yaw"), - WitchRush.get().getMode().getLong("teams."+teamInfos.getTeamName()+".shop.pitch")); + WitchRush.get().getConf().getDouble("teams."+teamInfos.getTeamName()+".shop.x"), + WitchRush.get().getConf().getDouble("teams."+teamInfos.getTeamName()+".shop.y"), + WitchRush.get().getConf().getDouble("teams."+teamInfos.getTeamName()+".shop.z"), + WitchRush.get().getConf().getLong("teams."+teamInfos.getTeamName()+".shop.yaw"), + WitchRush.get().getConf().getLong("teams."+teamInfos.getTeamName()+".shop.pitch")); } - public Location getUpgradeLocation(final TeamsInfos teamInfos) { return new Location(Bukkit.getWorld("world"), - WitchRush.get().getMode().getDouble("teams."+teamInfos.getTeamName()+".upgrade.x"), - WitchRush.get().getMode().getDouble("teams."+teamInfos.getTeamName()+".upgrade.y"), - WitchRush.get().getMode().getDouble("teams."+teamInfos.getTeamName()+".upgrade.z"), - WitchRush.get().getMode().getLong("teams."+teamInfos.getTeamName()+".upgrade.yaw"), - WitchRush.get().getMode().getLong("teams."+teamInfos.getTeamName()+".upgrade.pitch")); + WitchRush.get().getConf().getDouble("teams."+teamInfos.getTeamName()+".upgrade.x"), + WitchRush.get().getConf().getDouble("teams."+teamInfos.getTeamName()+".upgrade.y"), + WitchRush.get().getConf().getDouble("teams."+teamInfos.getTeamName()+".upgrade.z"), + WitchRush.get().getConf().getLong("teams."+teamInfos.getTeamName()+".upgrade.yaw"), + WitchRush.get().getConf().getLong("teams."+teamInfos.getTeamName()+".upgrade.pitch")); } - public Location getTeamLocation(final TeamsInfos teamInfos) { return new Location(Bukkit.getWorld("world"), - WitchRush.get().getMode().getDouble("teams."+teamInfos.getTeamName()+".spawn.x"), - WitchRush.get().getMode().getDouble("teams."+teamInfos.getTeamName()+".spawn.y"), - WitchRush.get().getMode().getDouble("teams."+teamInfos.getTeamName()+".spawn.z"), - WitchRush.get().getMode().getLong("teams."+teamInfos.getTeamName()+".spawn.yaw"), - WitchRush.get().getMode().getLong("teams."+teamInfos.getTeamName()+".spawn.pitch")); + WitchRush.get().getConf().getDouble("teams."+teamInfos.getTeamName()+".spawn.x"), + WitchRush.get().getConf().getDouble("teams."+teamInfos.getTeamName()+".spawn.y"), + WitchRush.get().getConf().getDouble("teams."+teamInfos.getTeamName()+".spawn.z"), + WitchRush.get().getConf().getLong("teams."+teamInfos.getTeamName()+".spawn.yaw"), + WitchRush.get().getConf().getLong("teams."+teamInfos.getTeamName()+".spawn.pitch")); } public boolean isPlayerInTeam(final Player player, final TeamsInfos teamInfos) { @@ -103,9 +97,7 @@ public class TeamManager { public boolean playerHaveTeam(final Player player) { for (final TeamsInfos teamInfos : TeamsInfos.values()) { - if (this.playerTeamList.get(teamInfos) != null && this.playerTeamList.get(teamInfos).contains(player)) { - return true; - } + return isPlayerInTeam(player, teamInfos); } return false; } diff --git a/WitchRush/src/main/java/net/berrygames/witchrush/team/TeamsInfos.java b/WitchRush/src/main/java/net/berrygames/witchrush/team/TeamsInfos.java index e84e53c..16ebe6e 100644 --- a/WitchRush/src/main/java/net/berrygames/witchrush/team/TeamsInfos.java +++ b/WitchRush/src/main/java/net/berrygames/witchrush/team/TeamsInfos.java @@ -5,10 +5,10 @@ import org.bukkit.Color; public enum TeamsInfos { - VERT(0,"Vert", "vert", "§a", (short)13, Color.GREEN), - BLEU(1,"Bleu", "bleu", "§b", (short)11, Color.BLUE), - JAUNE(2,"Jaune", "jaune", "§e", (short)4, Color.YELLOW), - ROUGE(3,"Rouge", "rouge", "§c", (short)14, Color.RED), + VERT(0,"Vert", "vert", "§a", (short)13, Color.GREEN, 23), + BLEU(1,"Bleu", "bleu", "§b", (short)11, Color.BLUE, 19), + JAUNE(2,"Jaune", "jaune", "§e", (short)4, Color.YELLOW, 21), + ROUGE(3,"Rouge", "rouge", "§c", (short)14, Color.RED, 25), ; private int id; @@ -17,14 +17,16 @@ public enum TeamsInfos { private String chatColor; private short dataClay; private Color color; + private int slotGUI; - TeamsInfos(int id, String IDName, String teamName, String chatColor, short dataClay, Color color) { + TeamsInfos(int id, String IDName, String teamName, String chatColor, short dataClay, Color color, int slotGUI) { this.id = id; this.IDName = IDName; this.teamName = teamName; this.chatColor = chatColor; this.dataClay = dataClay; this.color = color; + this.slotGUI = slotGUI; } public String getIDName() { @@ -51,6 +53,10 @@ public enum TeamsInfos { return id; } + public int getSlotGUI() { + return slotGUI; + } + public static TeamsInfos getTeamInfosByIDName(final String ID) { for (final TeamsInfos teamInfos : values()) { if (teamInfos.getIDName().equalsIgnoreCase(ID)) { diff --git a/WitchRush/src/main/java/net/berrygames/witchrush/team/TeamsMenu.java b/WitchRush/src/main/java/net/berrygames/witchrush/team/TeamsMenu.java index 53ab449..a515261 100644 --- a/WitchRush/src/main/java/net/berrygames/witchrush/team/TeamsMenu.java +++ b/WitchRush/src/main/java/net/berrygames/witchrush/team/TeamsMenu.java @@ -15,33 +15,30 @@ public class TeamsMenu { public TeamsMenu(Player player) { this.player = player; - inventory = Bukkit.createInventory(null, 4 * 9, WitchRush.prefix()+"Teams"); + inventory = Bukkit.createInventory(null, 5 * 9, WitchRush.prefix()+"Teams"); for(int i = 0; i < 9; i++){ inventory.setItem(i, new ItemFactory(Material.STAINED_GLASS_PANE).withName("").withColor(DyeColor.PINK).done()); } - for(int i = 45; i < 54; i++){ + for(int i = 36; i < 45; i++){ inventory.setItem(i, new ItemFactory(Material.STAINED_GLASS_PANE).withName("").withColor(DyeColor.PINK).done()); } inventory.setItem(9, new ItemFactory(Material.STAINED_GLASS_PANE).withName("").withColor(DyeColor.PINK).done()); inventory.setItem(17, new ItemFactory(Material.STAINED_GLASS_PANE).withName("").withColor(DyeColor.PINK).done()); - inventory.setItem(36, new ItemFactory(Material.STAINED_GLASS_PANE).withName("").withColor(DyeColor.PINK).done()); - inventory.setItem(44, new ItemFactory(Material.STAINED_GLASS_PANE).withName("").withColor(DyeColor.PINK).done()); + inventory.setItem(27, new ItemFactory(Material.STAINED_GLASS_PANE).withName("").withColor(DyeColor.PINK).done()); + inventory.setItem(35, new ItemFactory(Material.STAINED_GLASS_PANE).withName("").withColor(DyeColor.PINK).done()); - inventory.setItem(40, new ItemFactory(Material.DOUBLE_PLANT).withName("§dTeam Random").done()); + inventory.setItem(31, new ItemFactory(Material.DOUBLE_PLANT).withName("§dTeam Random").done()); - for(int i = 0; i < TeamsInfos.values().length; i++){ - for(int slot = 10; slot < 17; slot++){ - inventory.setItem(slot, new ItemFactory(Material.WOOL).withName(TeamsInfos.getTeamInfosByID(i).getTeamName()).done()); - } - for(int slot = 19; slot < 26; slot++){ - inventory.setItem(slot, new ItemFactory(Material.WOOL).withName(TeamsInfos.getTeamInfosByID(i).getTeamName()).done()); - } - inventory.setItem(30, new ItemFactory(Material.WOOL).withName(TeamsInfos.getTeamInfosByID(i).getTeamName()).done()); - inventory.setItem(32, new ItemFactory(Material.WOOL).withName(TeamsInfos.getTeamInfosByID(i).getTeamName()).done()); + for(TeamsInfos infos : TeamsInfos.values()){ + inventory.setItem(infos.getSlotGUI(), new ItemFactory(Material.WOOL) + .withName(infos.getChatColor()+infos.getTeamName()) + .withColor(infos.getColor()) + .done()); } - inventory.setItem(49, new ItemFactory(Material.BARRIER).withName("§cFermer").done()); + + inventory.setItem(40, new ItemFactory(Material.BARRIER).withName("§cFermer").done()); player.openInventory(inventory); } } diff --git a/WitchRush/src/main/java/net/berrygames/witchrush/tools/ItemFactory.java b/WitchRush/src/main/java/net/berrygames/witchrush/tools/ItemFactory.java index 7906f98..3d0bc7a 100644 --- a/WitchRush/src/main/java/net/berrygames/witchrush/tools/ItemFactory.java +++ b/WitchRush/src/main/java/net/berrygames/witchrush/tools/ItemFactory.java @@ -1,5 +1,6 @@ package net.berrygames.witchrush.tools; +import org.bukkit.Color; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -48,6 +49,11 @@ public class ItemFactory { return this; } + public ItemFactory withColor(final Color color) { + this.item.setDurability((short) DyeColor.getByColor(color).getWoolData()); + return this; + } + public ItemFactory withOwner(final String owner) { if (this.item.getType().equals((Object)Material.SKULL_ITEM)) { this.item.setDurability((short)3);