From ee69cdc34eee3a29c6c1e8a4dbd142aa44fe96e5 Mon Sep 17 00:00:00 2001 From: flifloo Date: Mon, 7 Sep 2020 22:23:32 +0200 Subject: [PATCH] Code cleanup --- .gitignore | 7 + README.md | 4 +- pom.xml | 138 +++++++++--------- .../WrapperPlayServerSpawnEntity.java | 2 +- .../java/fr/leomelki/loupgarou/MainLg.java | 4 +- .../loupgarou/classes/LGCustomItems.java | 2 +- .../fr/leomelki/loupgarou/classes/LGGame.java | 21 ++- .../leomelki/loupgarou/classes/LGPlayer.java | 8 +- .../fr/leomelki/loupgarou/classes/LGVote.java | 4 +- .../loupgarou/classes/chat/LGChat.java | 6 +- .../events/LGPlayerGotKilledEvent.java | 2 +- .../loupgarou/events/LGPlayerKilledEvent.java | 2 +- .../loupgarou/listeners/JoinListener.java | 18 +-- .../fr/leomelki/loupgarou/roles/RCupidon.java | 2 +- .../leomelki/loupgarou/roles/RDictateur.java | 4 +- .../loupgarou/roles/REnfantSauvage.java | 2 +- .../leomelki/loupgarou/roles/RFaucheur.java | 2 +- .../fr/leomelki/loupgarou/roles/RGarde.java | 2 +- .../leomelki/loupgarou/roles/RLoupGarou.java | 2 +- .../loupgarou/roles/RLoupGarouBlanc.java | 2 +- .../loupgarou/roles/RMontreurDOurs.java | 2 +- .../leomelki/loupgarou/roles/RPyromane.java | 12 +- .../leomelki/loupgarou/roles/RSorciere.java | 4 +- .../fr/leomelki/loupgarou/roles/RVampire.java | 2 +- .../fr/leomelki/loupgarou/roles/Role.java | 2 +- .../fr/leomelki/loupgarou/roles/RoleSort.java | 2 +- .../fr/leomelki/loupgarou/roles/RoleType.java | 2 +- .../leomelki/loupgarou/roles/RoleWinType.java | 2 +- .../scoreboard/CustomScoreboardEntry.java | 2 +- .../loupgarou/utils/MultipleValueMap.java | 4 +- .../loupgarou/utils/VariableCache.java | 4 +- .../loupgarou/utils/VariousUtils.java | 2 +- src/main/{java => resources}/plugin.yml | 2 +- 33 files changed, 145 insertions(+), 131 deletions(-) rename src/main/{java => resources}/plugin.yml (97%) diff --git a/.gitignore b/.gitignore index dd5a7bc..d8537e0 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,10 @@ hs_err_pid* # Minecraft data /minecraft_data + +# IntelliJ files +.idea/ +*.iml + +# Maven files +/target/ diff --git a/README.md b/README.md index d5e3909..e9e14db 100644 --- a/README.md +++ b/README.md @@ -41,9 +41,9 @@ Un serveur est mis à votre disposition pour vous permettre de jouer au LoupGaro - [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997/) ### Installation classique -**Minecraft 1.15.1 est requis.** +**Minecraft 1.15.2 est requis.** Pour installer le plug-in, merci de suivre les étapes suivantes: - - Téléchargez Spigot 1.15.1 et lancez une fois le serveur + - Téléchargez Spigot 1.15.2 et lancez une fois le serveur - Dans le dossier `plugins`, insérez [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997/) et [LoupGarou.jar](https://github.com/leomelki/LoupGarou/releases) - Redémarrez votre serveur puis donnez vous les permissions administrateur (/op dans la console) - Allez sur la map et ajoutez les points de spawn sur chaque dalle `/lg addSpawn` diff --git a/pom.xml b/pom.xml index 5e2b762..b9b854f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,91 +1,97 @@ - - 4.0.0 - fr.leomelki - LoupGarou - 1.1.0 - - UTF-8 - UTF-8 - - - LoupGarou - src - - - maven-compiler-plugin - 3.8.0 - - 1.8 - 1.8 - - - - maven-assembly-plugin - - ${project.java.version} - ${project.java.version} - ${project.build.sourceEncoding} - - jar-with-dependencies - - - - - org.apache.maven.plugins - maven-resources-plugin - 3.0.2 - - ${project.build.sourceEncoding} - - - - - - src/main/java - - plugin.yml - - - - - + + 4.0.0 + fr.leomelki + LoupGarou + 1.0.1 + + + UTF-8 + UTF-8 + + + + LoupGarou + src/main/java + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.2.0 + + + ${project.build.sourceEncoding} + + + jar-with-dependencies + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.0.2 + + ${project.build.sourceEncoding} + + + + + + spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + dmulloy2-repo http://repo.dmulloy2.net/nexus/repository/public/ - - - + + - bungeecord-repo - https://oss.sonatype.org/content/repositories/snapshots + bungeecord-repo + https://oss.sonatype.org/content/repositories/snapshots + org.spigotmc spigot - 1.15.1-R0.1-SNAPSHOT + 1.15.2-R0.1-SNAPSHOT provided + org.json json 20180813 - + + com.comphenix.protocol ProtocolLib 4.4.0 - - - org.projectlombok - lombok - 1.18.10 - provided - + + + + org.projectlombok + lombok + 1.18.10 + - + \ No newline at end of file diff --git a/src/main/java/fr/leomelki/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntity.java b/src/main/java/fr/leomelki/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntity.java index 414b2a7..2c3872b 100644 --- a/src/main/java/fr/leomelki/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntity.java +++ b/src/main/java/fr/leomelki/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntity.java @@ -70,7 +70,7 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket { /** * The singleton instance. Can also be retrieved from the parent class. */ - private static ObjectTypes INSTANCE = new ObjectTypes(); + private static final ObjectTypes INSTANCE = new ObjectTypes(); /** * Retrieve an instance of the object types enum. diff --git a/src/main/java/fr/leomelki/loupgarou/MainLg.java b/src/main/java/fr/leomelki/loupgarou/MainLg.java index 784819e..389fdd9 100644 --- a/src/main/java/fr/leomelki/loupgarou/MainLg.java +++ b/src/main/java/fr/leomelki/loupgarou/MainLg.java @@ -87,8 +87,8 @@ import lombok.Setter; public class MainLg extends JavaPlugin{ private static MainLg instance; - @Getter private HashMap> roles = new HashMap>(); - @Getter private static String prefix = ""/*"§7[§9Loup-Garou§7] "*/; + @Getter private final HashMap> roles = new HashMap>(); + @Getter private static final String prefix = ""/*"§7[§9Loup-Garou§7] "*/; @Getter @Setter private LGGame currentGame;//Because for now, only one game will be playable on one server (flemme) diff --git a/src/main/java/fr/leomelki/loupgarou/classes/LGCustomItems.java b/src/main/java/fr/leomelki/loupgarou/classes/LGCustomItems.java index 1a12a47..85c532c 100644 --- a/src/main/java/fr/leomelki/loupgarou/classes/LGCustomItems.java +++ b/src/main/java/fr/leomelki/loupgarou/classes/LGCustomItems.java @@ -68,7 +68,7 @@ public class LGCustomItems { } @RequiredArgsConstructor - public static enum LGCustomItemsConstraints{ + public enum LGCustomItemsConstraints{ INFECTED("infecte"), MAYOR("maire"), VAMPIRE_INFECTE("vampire-infecte"), diff --git a/src/main/java/fr/leomelki/loupgarou/classes/LGGame.java b/src/main/java/fr/leomelki/loupgarou/classes/LGGame.java index 99b353c..aa958e5 100644 --- a/src/main/java/fr/leomelki/loupgarou/classes/LGGame.java +++ b/src/main/java/fr/leomelki/loupgarou/classes/LGGame.java @@ -70,13 +70,13 @@ import lombok.Getter; import lombok.Setter; public class LGGame implements Listener{ - private static boolean autoStart = false; + private static final boolean autoStart = false; @Getter private final SecureRandom random = new SecureRandom(); @Getter private final int maxPlayers; - @Getter private ArrayList inGame = new ArrayList(); - @Getter private ArrayList roles = new ArrayList(); + @Getter private final ArrayList inGame = new ArrayList(); + @Getter private final ArrayList roles = new ArrayList(); @Getter private boolean started; @Getter private int night = 0; @@ -84,12 +84,12 @@ public class LGGame implements Listener{ @Getter @Setter private int waitTicks; @Getter private boolean day; @Getter public long time = 0; - @Getter private HashMap placements = new HashMap(); + @Getter private final HashMap placements = new HashMap(); - @Getter private LGChat spectatorChat = new LGChat((sender, message) -> { + @Getter private final LGChat spectatorChat = new LGChat((sender, message) -> { return "§7"+sender.getName()+" §6» §f"+message; }); - @Getter private LGChat dayChat = new LGChat((sender, message) -> { + @Getter private final LGChat dayChat = new LGChat((sender, message) -> { return "§e"+sender.getName()+" §6» §f"+message; }); @@ -100,7 +100,7 @@ public class LGGame implements Listener{ } @Getter - private MultipleValueMap deaths = new MultipleValueMap(); + private final MultipleValueMap deaths = new MultipleValueMap(); public void sendActionBarMessage(String msg) { WrapperPlayServerChat chat = new WrapperPlayServerChat(); @@ -173,8 +173,8 @@ public class LGGame implements Listener{ }.runTaskTimer(MainLg.getInstance(), 0, 1); } - public static interface TextGenerator{ - public String generate(LGPlayer player, int secondsLeft); + public interface TextGenerator{ + String generate(LGPlayer player, int secondsLeft); } public void cancelWait() { if(waitTask != null) { @@ -551,8 +551,7 @@ public class LGGame implements Listener{ killed.getPlayer().getWorld().strikeLightningEffect(killed.getPlayer().getLocation()); for(Role role : getRoles()) - if(role.getPlayers().contains(killed)) - role.getPlayers().remove(killed); + role.getPlayers().remove(killed); killed.setDead(true); diff --git a/src/main/java/fr/leomelki/loupgarou/classes/LGPlayer.java b/src/main/java/fr/leomelki/loupgarou/classes/LGPlayer.java index fc6a80f..9cf5bf8 100644 --- a/src/main/java/fr/leomelki/loupgarou/classes/LGPlayer.java +++ b/src/main/java/fr/leomelki/loupgarou/classes/LGPlayer.java @@ -42,7 +42,7 @@ import net.minecraft.server.v1_15_R1.PacketPlayOutRespawn; import net.minecraft.server.v1_15_R1.WorldType; public class LGPlayer { - private static HashMap cachedPlayers = new HashMap(); + private static final HashMap cachedPlayers = new HashMap(); public static LGPlayer thePlayer(Player player) { LGPlayer lgp = cachedPlayers.get(player); if(lgp == null) { @@ -60,7 +60,7 @@ public class LGPlayer { @Setter @Getter private Role role; private LGChooseCallback chooseCallback; private List blacklistedChoice = new ArrayList<>(0); - @Getter private VariableCache cache = new VariableCache(); + @Getter private final VariableCache cache = new VariableCache(); @Getter @Setter private LGGame game; @Getter @Setter private String latestObjective; @Getter private CustomScoreboard scoreboard; @@ -148,8 +148,8 @@ public class LGPlayer { this.chooseCallback = null; } - public static interface LGChooseCallback{ - public void callback(LGPlayer choosen); + public interface LGChooseCallback{ + void callback(LGPlayer choosen); } public void showView() { diff --git a/src/main/java/fr/leomelki/loupgarou/classes/LGVote.java b/src/main/java/fr/leomelki/loupgarou/classes/LGVote.java index c354c4a..5497cb7 100644 --- a/src/main/java/fr/leomelki/loupgarou/classes/LGVote.java +++ b/src/main/java/fr/leomelki/loupgarou/classes/LGVote.java @@ -44,7 +44,9 @@ import net.minecraft.server.v1_15_R1.PacketPlayOutEntityMetadata; public class LGVote { @Getter LGPlayer choosen; - private int timeout, initialTimeout, littleTimeout; + private int timeout; + private final int initialTimeout; + private final int littleTimeout; private Runnable callback; private final LGGame game; @Getter private List participants, viewers; diff --git a/src/main/java/fr/leomelki/loupgarou/classes/chat/LGChat.java b/src/main/java/fr/leomelki/loupgarou/classes/chat/LGChat.java index f4bc234..93d2c65 100644 --- a/src/main/java/fr/leomelki/loupgarou/classes/chat/LGChat.java +++ b/src/main/java/fr/leomelki/loupgarou/classes/chat/LGChat.java @@ -12,9 +12,9 @@ public class LGChat { @Getter private final HashMap viewers = new HashMap(); @Getter private final LGChatCallback defaultCallback; - public static interface LGChatCallback{ - public String receive(LGPlayer sender, String message); - public default String send(LGPlayer sender, String message) {return null;}; + public interface LGChatCallback{ + String receive(LGPlayer sender, String message); + default String send(LGPlayer sender, String message) {return null;} } public void sendMessage(LGPlayer sender, String message) { diff --git a/src/main/java/fr/leomelki/loupgarou/events/LGPlayerGotKilledEvent.java b/src/main/java/fr/leomelki/loupgarou/events/LGPlayerGotKilledEvent.java index a9cd955..ce0e987 100644 --- a/src/main/java/fr/leomelki/loupgarou/events/LGPlayerGotKilledEvent.java +++ b/src/main/java/fr/leomelki/loupgarou/events/LGPlayerGotKilledEvent.java @@ -15,6 +15,6 @@ public class LGPlayerGotKilledEvent extends LGEvent { @Getter private final boolean endGame; @Getter private final LGPlayer killed; - @Getter private Reason reason; + @Getter private final Reason reason; } diff --git a/src/main/java/fr/leomelki/loupgarou/events/LGPlayerKilledEvent.java b/src/main/java/fr/leomelki/loupgarou/events/LGPlayerKilledEvent.java index 419edd4..3e1002f 100644 --- a/src/main/java/fr/leomelki/loupgarou/events/LGPlayerKilledEvent.java +++ b/src/main/java/fr/leomelki/loupgarou/events/LGPlayerKilledEvent.java @@ -21,7 +21,7 @@ public class LGPlayerKilledEvent extends LGEvent implements Cancellable{ @Getter @Setter private Reason reason; @RequiredArgsConstructor - public static enum Reason{ + public enum Reason{ LOUP_GAROU("§7§l%s§4 est mort pendant la nuit"), GM_LOUP_GAROU("§7§l%s§4 est mort pendant la nuit"), LOUP_BLANC(LOUP_GAROU.getMessage()), diff --git a/src/main/java/fr/leomelki/loupgarou/listeners/JoinListener.java b/src/main/java/fr/leomelki/loupgarou/listeners/JoinListener.java index 5d5f25f..e1e22a9 100644 --- a/src/main/java/fr/leomelki/loupgarou/listeners/JoinListener.java +++ b/src/main/java/fr/leomelki/loupgarou/listeners/JoinListener.java @@ -25,30 +25,30 @@ public class JoinListener implements Listener{ @EventHandler public void onJoin(PlayerJoinEvent e) { Player p = e.getPlayer(); - + WrapperPlayServerScoreboardTeam myTeam = new WrapperPlayServerScoreboardTeam(); myTeam.setName(p.getName()); myTeam.setPrefix(WrappedChatComponent.fromText("")); myTeam.setPlayers(Arrays.asList(p.getName())); myTeam.setMode(0); boolean noSpec = p.getGameMode() != GameMode.SPECTATOR; - for(Player player : Bukkit.getOnlinePlayers()) - if(player != p) { - if(player.getGameMode() != GameMode.SPECTATOR) + for (Player player : Bukkit.getOnlinePlayers()) + if (player != p) { + if (player.getGameMode() != GameMode.SPECTATOR) player.hidePlayer(p); WrapperPlayServerScoreboardTeam team = new WrapperPlayServerScoreboardTeam(); team.setName(player.getName()); team.setPrefix(WrappedChatComponent.fromText("")); team.setPlayers(Arrays.asList(player.getName())); team.setMode(0); - + team.sendPacket(p); myTeam.sendPacket(player); } p.setFoodLevel(6); - if(e.getJoinMessage() == null || !e.getJoinMessage().equals("joinall")) + if (e.getJoinMessage() == null || !e.getJoinMessage().equals("joinall")) { p.getPlayer().setResourcePack("http://leomelki.fr/mcgames/ressourcepacks/v32/loup_garou.zip"); - else { + } else { LGPlayer lgp = LGPlayer.thePlayer(e.getPlayer()); lgp.showView(); lgp.join(MainLg.getInstance().getCurrentGame()); @@ -62,12 +62,12 @@ public class JoinListener implements Listener{ } @EventHandler public void onResoucePack(PlayerResourcePackStatusEvent e) { - if(e.getStatus() == Status.SUCCESSFULLY_LOADED) { + if (e.getStatus() == Status.SUCCESSFULLY_LOADED) { Player p = e.getPlayer(); LGPlayer lgp = LGPlayer.thePlayer(p); lgp.showView(); lgp.join(MainLg.getInstance().getCurrentGame()); - }else if(e.getStatus() == Status.DECLINED || e.getStatus() == Status.FAILED_DOWNLOAD) + } else if(e.getStatus() == Status.DECLINED || e.getStatus() == Status.FAILED_DOWNLOAD) e.getPlayer().kickPlayer(MainLg.getPrefix()+"§cIl vous faut le resourcepack pour jouer ! ("+e.getStatus()+")"); } @EventHandler diff --git a/src/main/java/fr/leomelki/loupgarou/roles/RCupidon.java b/src/main/java/fr/leomelki/loupgarou/roles/RCupidon.java index 320b800..8c92f47 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/RCupidon.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/RCupidon.java @@ -223,7 +223,7 @@ public class RCupidon extends Role{ if(!e.getWinners().contains(lgp)) e.getWinners().add(lgp); } else { - LGPlayer player2 = lgp.getCache().get("inlove"); + LGPlayer player2 = lgp.getCache().get("inlove"); boolean winEnCouple = (lgp.getRoleType() == RoleType.LOUP_GAROU) != (player2.getRoleType() == RoleType.LOUP_GAROU) || lgp.getRoleWinType() == RoleWinType.SEUL || player2.getRoleWinType() == RoleWinType.SEUL; if(winEnCouple) { System.out.println(lgp.getName()+" ne peut pas gagner car il était en couple !"); diff --git a/src/main/java/fr/leomelki/loupgarou/roles/RDictateur.java b/src/main/java/fr/leomelki/loupgarou/roles/RDictateur.java index fa770d1..0c5db74 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/RDictateur.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/RDictateur.java @@ -29,8 +29,8 @@ import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason; import fr.leomelki.loupgarou.events.LGVoteEvent; public class RDictateur extends Role{ - static private ItemStack[] items = new ItemStack[9]; - static private Inventory inventory; + static private final ItemStack[] items = new ItemStack[9]; + static private final Inventory inventory; static { items[3] = new ItemStack(Material.IRON_NUGGET); ItemMeta meta = items[3].getItemMeta(); diff --git a/src/main/java/fr/leomelki/loupgarou/roles/REnfantSauvage.java b/src/main/java/fr/leomelki/loupgarou/roles/REnfantSauvage.java index 0f4fbb9..4dab69c 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/REnfantSauvage.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/REnfantSauvage.java @@ -80,7 +80,7 @@ public class REnfantSauvage extends Role{ } }, player); } - private static Random random = new Random(); + private static final Random random = new Random(); @Override protected void onNightTurnTimeout(LGPlayer player) { player.stopChoosing(); diff --git a/src/main/java/fr/leomelki/loupgarou/roles/RFaucheur.java b/src/main/java/fr/leomelki/loupgarou/roles/RFaucheur.java index 5af5f32..768fa12 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/RFaucheur.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/RFaucheur.java @@ -54,7 +54,7 @@ public class RFaucheur extends Role{ return -1; } - private static Random random = new Random(); + private static final Random random = new Random(); @EventHandler(priority = EventPriority.LOWEST) public void onKill(LGPlayerKilledEvent e) { diff --git a/src/main/java/fr/leomelki/loupgarou/roles/RGarde.java b/src/main/java/fr/leomelki/loupgarou/roles/RGarde.java index 67cd752..8869355 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/RGarde.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/RGarde.java @@ -96,7 +96,7 @@ public class RGarde extends Role{ //player.sendMessage("§cVous n'avez protégé personne cette nuit."); } - private static List reasonsProtected = Arrays.asList(Reason.LOUP_GAROU, Reason.LOUP_BLANC, Reason.GM_LOUP_GAROU, Reason.ASSASSIN); + private static final List reasonsProtected = Arrays.asList(Reason.LOUP_GAROU, Reason.LOUP_BLANC, Reason.GM_LOUP_GAROU, Reason.ASSASSIN); @EventHandler public void onPlayerKill(LGNightPlayerPreKilledEvent e) { diff --git a/src/main/java/fr/leomelki/loupgarou/roles/RLoupGarou.java b/src/main/java/fr/leomelki/loupgarou/roles/RLoupGarou.java index 42df8b2..7ae8cec 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/RLoupGarou.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/RLoupGarou.java @@ -71,7 +71,7 @@ public class RLoupGarou extends Role{ return 30; } - @Getter private LGChat chat = new LGChat((sender, message) -> { + @Getter private final LGChat chat = new LGChat((sender, message) -> { return "§c"+sender.getName()+" §6» §f"+message; }); diff --git a/src/main/java/fr/leomelki/loupgarou/roles/RLoupGarouBlanc.java b/src/main/java/fr/leomelki/loupgarou/roles/RLoupGarouBlanc.java index 4c61464..56516cb 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/RLoupGarouBlanc.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/RLoupGarouBlanc.java @@ -19,7 +19,7 @@ import fr.leomelki.loupgarou.events.LGGameEndEvent; import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason; public class RLoupGarouBlanc extends Role{ - private static ItemStack skip; + private static final ItemStack skip; static { skip = new ItemStack(Material.IRON_NUGGET); ItemMeta meta = skip.getItemMeta(); diff --git a/src/main/java/fr/leomelki/loupgarou/roles/RMontreurDOurs.java b/src/main/java/fr/leomelki/loupgarou/roles/RMontreurDOurs.java index e27ddb0..3d1a811 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/RMontreurDOurs.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/RMontreurDOurs.java @@ -55,7 +55,7 @@ public class RMontreurDOurs extends Role{ return -1; } - private static Random random = new Random(); + private static final Random random = new Random(); private int lastNight = -1; @EventHandler(priority = EventPriority.LOWEST) diff --git a/src/main/java/fr/leomelki/loupgarou/roles/RPyromane.java b/src/main/java/fr/leomelki/loupgarou/roles/RPyromane.java index 0b5b7e3..31412ef 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/RPyromane.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/RPyromane.java @@ -130,7 +130,7 @@ public class RPyromane extends Role{ @Override protected void onNightTurnTimeout(LGPlayer player) { if(first != null) { - List liste = player.getCache().>get("pyromane_essence"); + List liste = player.getCache().get("pyromane_essence"); LGPyromaneGasoilEvent event = new LGPyromaneGasoilEvent(getGame(), first); Bukkit.getPluginManager().callEvent(event); if(event.isCancelled()) @@ -172,7 +172,7 @@ public class RPyromane extends Role{ e.setCancelled(true); closeInventory(player); if(lgp.getCache().>get("pyromane_essence").size() != 0) { - List liste = lgp.getCache().>get("pyromane_essence"); + List liste = lgp.getCache().get("pyromane_essence"); for(LGPlayer scndPlayer : liste) { if(!scndPlayer.isDead() && scndPlayer.getPlayer() != null) { getGame().kill(scndPlayer, Reason.PYROMANE); @@ -203,7 +203,7 @@ public class RPyromane extends Role{ lgp.sendMessage("§cTu as déjà versé du gasoil sur §7§l"+choosen.getName()+"§6."); return; } - List liste = lgp.getCache().>get("pyromane_essence"); + List liste = lgp.getCache().get("pyromane_essence"); if(liste.contains(choosen)) { lgp.sendMessage("§7§l"+choosen.getName()+"§c est déjà recouvert de gasoil."); return; @@ -266,9 +266,9 @@ public class RPyromane extends Role{ if(e.getGame() == getGame()) for(LGPlayer lgp : getPlayers()) if(lgp.getCache().has("pyromane_essence")) { - List liste = lgp.getCache().>get("pyromane_essence"); - if(liste.contains(e.getKilled()))//Au cas où le mec soit rez - liste.remove(e.getKilled()); + List liste = lgp.getCache().get("pyromane_essence"); + //Au cas où le mec soit rez + liste.remove(e.getKilled()); } } @EventHandler diff --git a/src/main/java/fr/leomelki/loupgarou/roles/RSorciere.java b/src/main/java/fr/leomelki/loupgarou/roles/RSorciere.java index 3bd827f..dfa7c00 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/RSorciere.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/RSorciere.java @@ -24,8 +24,8 @@ import fr.leomelki.loupgarou.classes.LGPlayer; import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason; public class RSorciere extends Role{ - private static ItemStack[] items = new ItemStack[4]; - private static ItemStack cancel; + private static final ItemStack[] items = new ItemStack[4]; + private static final ItemStack cancel; static { items[0] = new ItemStack(Material.PURPLE_DYE, 1); ItemMeta meta = items[0].getItemMeta(); diff --git a/src/main/java/fr/leomelki/loupgarou/roles/RVampire.java b/src/main/java/fr/leomelki/loupgarou/roles/RVampire.java index ef3cb2a..ca2fe28 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/RVampire.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/RVampire.java @@ -82,7 +82,7 @@ public class RVampire extends Role{ return nextCanInfect < getGame().getNight() && super.hasPlayersLeft(); } - @Getter private LGChat chat = new LGChat((sender, message) -> { + @Getter private final LGChat chat = new LGChat((sender, message) -> { return "§5"+sender.getName()+" §6» §f"+message; }); int nextCanInfect = 0; diff --git a/src/main/java/fr/leomelki/loupgarou/roles/Role.java b/src/main/java/fr/leomelki/loupgarou/roles/Role.java index 5bb2435..52906f3 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/Role.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/Role.java @@ -17,7 +17,7 @@ import lombok.Setter; public abstract class Role implements Listener{ @Getter @Setter private int waitedPlayers; - @Getter private ArrayList players = new ArrayList(); + @Getter private final ArrayList players = new ArrayList(); @Getter private final LGGame game; public Role(LGGame game) { diff --git a/src/main/java/fr/leomelki/loupgarou/roles/RoleSort.java b/src/main/java/fr/leomelki/loupgarou/roles/RoleSort.java index 9326f96..f90f856 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/RoleSort.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/RoleSort.java @@ -21,5 +21,5 @@ public enum RoleSort { Pirate, Bouffon, Sorciere, - Corbeau; + Corbeau } diff --git a/src/main/java/fr/leomelki/loupgarou/roles/RoleType.java b/src/main/java/fr/leomelki/loupgarou/roles/RoleType.java index c5f2b11..2d0dbed 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/RoleType.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/RoleType.java @@ -4,5 +4,5 @@ public enum RoleType { VILLAGER, LOUP_GAROU, VAMPIRE, - NEUTRAL; + NEUTRAL } diff --git a/src/main/java/fr/leomelki/loupgarou/roles/RoleWinType.java b/src/main/java/fr/leomelki/loupgarou/roles/RoleWinType.java index dc63a27..d740d1a 100644 --- a/src/main/java/fr/leomelki/loupgarou/roles/RoleWinType.java +++ b/src/main/java/fr/leomelki/loupgarou/roles/RoleWinType.java @@ -5,5 +5,5 @@ public enum RoleWinType { VILLAGE, LOUP_GAROU, VAMPIRE, - NONE; + NONE } diff --git a/src/main/java/fr/leomelki/loupgarou/scoreboard/CustomScoreboardEntry.java b/src/main/java/fr/leomelki/loupgarou/scoreboard/CustomScoreboardEntry.java index d403a85..847821d 100644 --- a/src/main/java/fr/leomelki/loupgarou/scoreboard/CustomScoreboardEntry.java +++ b/src/main/java/fr/leomelki/loupgarou/scoreboard/CustomScoreboardEntry.java @@ -12,7 +12,7 @@ import lombok.Getter; import lombok.Setter; public class CustomScoreboardEntry { - private static WrappedChatComponent nullComponent = WrappedChatComponent.fromText(""); + private static final WrappedChatComponent nullComponent = WrappedChatComponent.fromText(""); //setter car flemme de modifier le systeme pour le rendre plus logique @Getter @Setter private int score; diff --git a/src/main/java/fr/leomelki/loupgarou/utils/MultipleValueMap.java b/src/main/java/fr/leomelki/loupgarou/utils/MultipleValueMap.java index fc221a5..1c75c9b 100644 --- a/src/main/java/fr/leomelki/loupgarou/utils/MultipleValueMap.java +++ b/src/main/java/fr/leomelki/loupgarou/utils/MultipleValueMap.java @@ -10,7 +10,7 @@ import lombok.Getter; import lombok.Setter; public class MultipleValueMap { - private HashMap> map = new HashMap<>(); + private final HashMap> map = new HashMap<>(); public void put(K key, V value) { List list = map.get(key); if(list == null) @@ -56,7 +56,7 @@ public class MultipleValueMap { @AllArgsConstructor public static class MultipleValueKeyEntry implements Entry{ @Getter - private K key; + private final K key; @Getter private V value; @Override diff --git a/src/main/java/fr/leomelki/loupgarou/utils/VariableCache.java b/src/main/java/fr/leomelki/loupgarou/utils/VariableCache.java index 040690c..8986e82 100644 --- a/src/main/java/fr/leomelki/loupgarou/utils/VariableCache.java +++ b/src/main/java/fr/leomelki/loupgarou/utils/VariableCache.java @@ -3,10 +3,10 @@ package fr.leomelki.loupgarou.utils; import java.util.HashMap; public class VariableCache { - private HashMap cache = new HashMap(); + private final HashMap cache = new HashMap(); public boolean getBoolean(String key) { Object object = get(key); - return object == null ? false : (boolean)object; + return object != null && (boolean) object; } public void set(String key, Object value) { if(cache.containsKey(key)) diff --git a/src/main/java/fr/leomelki/loupgarou/utils/VariousUtils.java b/src/main/java/fr/leomelki/loupgarou/utils/VariousUtils.java index f25c4ed..5b173e3 100644 --- a/src/main/java/fr/leomelki/loupgarou/utils/VariousUtils.java +++ b/src/main/java/fr/leomelki/loupgarou/utils/VariousUtils.java @@ -40,7 +40,7 @@ public class VariousUtils { e.printStackTrace(); } } - private static char[] hex = "0123456789abcdef".toCharArray(); + private static final char[] hex = "0123456789abcdef".toCharArray(); public static char toHex(int i) { return hex[i]; } diff --git a/src/main/java/plugin.yml b/src/main/resources/plugin.yml similarity index 97% rename from src/main/java/plugin.yml rename to src/main/resources/plugin.yml index c9edd9e..b2d42de 100644 --- a/src/main/java/plugin.yml +++ b/src/main/resources/plugin.yml @@ -5,4 +5,4 @@ main: fr.leomelki.loupgarou.MainLg depend: [ProtocolLib] api-version: 1.13 commands: - lg: \ No newline at end of file + ww: \ No newline at end of file