Code cleanup

This commit is contained in:
Ethanell 2020-09-07 22:23:32 +02:00
parent 94bc0a32e8
commit ee69cdc34e
33 changed files with 145 additions and 131 deletions

7
.gitignore vendored
View file

@ -23,3 +23,10 @@ hs_err_pid*
# Minecraft data # Minecraft data
/minecraft_data /minecraft_data
# IntelliJ files
.idea/
*.iml
# Maven files
/target/

View file

@ -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/) - [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997/)
### Installation classique ### 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: 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) - 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 <votre_pseudo> dans la console) - Redémarrez votre serveur puis donnez vous les permissions administrateur (/op <votre_pseudo> dans la console)
- Allez sur la map et ajoutez les points de spawn sur chaque dalle `/lg addSpawn` - Allez sur la map et ajoutez les points de spawn sur chaque dalle `/lg addSpawn`

136
pom.xml
View file

@ -1,91 +1,97 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<modelVersion>4.0.0</modelVersion> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>fr.leomelki</groupId> <modelVersion>4.0.0</modelVersion>
<artifactId>LoupGarou</artifactId> <groupId>fr.leomelki</groupId>
<version>1.1.0</version> <artifactId>LoupGarou</artifactId>
<properties> <version>1.0.1</version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <properties>
</properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<build> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<finalName>LoupGarou</finalName> </properties>
<sourceDirectory>src</sourceDirectory>
<plugins> <build>
<plugin> <finalName>LoupGarou</finalName>
<artifactId>maven-compiler-plugin</artifactId> <sourceDirectory>src/main/java</sourceDirectory>
<version>3.8.0</version>
<configuration> <plugins>
<source>1.8</source> <plugin>
<target>1.8</target> <groupId>org.apache.maven.plugins</groupId>
</configuration> <artifactId>maven-compiler-plugin</artifactId>
</plugin> <version>3.8.1</version>
<plugin>
<artifactId>maven-assembly-plugin</artifactId> <configuration>
<configuration> <source>1.8</source>
<source>${project.java.version}</source> <target>1.8</target>
<target>${project.java.version}</target> </configuration>
<encoding>${project.build.sourceEncoding}</encoding> </plugin>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef> <plugin>
</descriptorRefs> <groupId>org.apache.maven.plugins</groupId>
</configuration> <artifactId>maven-assembly-plugin</artifactId>
</plugin> <version>3.2.0</version>
<plugin>
<groupId>org.apache.maven.plugins</groupId> <configuration>
<artifactId>maven-resources-plugin</artifactId> <encoding>${project.build.sourceEncoding}</encoding>
<version>3.0.2</version>
<configuration> <descriptorRefs>
<encoding>${project.build.sourceEncoding}</encoding> <descriptorRef>jar-with-dependencies</descriptorRef>
</configuration> </descriptorRefs>
</plugin> </configuration>
</plugins> </plugin>
<resources>
<resource> <plugin>
<directory>src/main/java</directory> <groupId>org.apache.maven.plugins</groupId>
<includes> <artifactId>maven-resources-plugin</artifactId>
<include>plugin.yml</include> <version>3.0.2</version>
</includes> <configuration>
</resource> <encoding>${project.build.sourceEncoding}</encoding>
</resources> </configuration>
</build> </plugin>
<repositories> </plugins>
</build>
<repositories>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<repository> <repository>
<id>dmulloy2-repo</id> <id>dmulloy2-repo</id>
<url>http://repo.dmulloy2.net/nexus/repository/public/</url> <url>http://repo.dmulloy2.net/nexus/repository/public/</url>
</repository> </repository>
<!--Bungeecord Repo-->
<!--Only include if using the Spigot API dependency-->
<repository> <repository>
<id>bungeecord-repo</id> <id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url> <url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository> </repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.15.1-R0.1-SNAPSHOT</version> <version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.json</groupId> <groupId>org.json</groupId>
<artifactId>json</artifactId> <artifactId>json</artifactId>
<version>20180813</version> <version>20180813</version>
</dependency> </dependency>
<dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId> <groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId> <artifactId>ProtocolLib</artifactId>
<version>4.4.0</version> <version>4.4.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId> <dependency>
<artifactId>lombok</artifactId> <groupId>org.projectlombok</groupId>
<version>1.18.10</version> <artifactId>lombok</artifactId>
<scope>provided</scope> <version>1.18.10</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View file

@ -70,7 +70,7 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket {
/** /**
* The singleton instance. Can also be retrieved from the parent class. * 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. * Retrieve an instance of the object types enum.

View file

@ -87,8 +87,8 @@ import lombok.Setter;
public class MainLg extends JavaPlugin{ public class MainLg extends JavaPlugin{
private static MainLg instance; private static MainLg instance;
@Getter private HashMap<String, Constructor<? extends Role>> roles = new HashMap<String, Constructor<? extends Role>>(); @Getter private final HashMap<String, Constructor<? extends Role>> roles = new HashMap<String, Constructor<? extends Role>>();
@Getter private static String prefix = ""/*"§7[§9Loup-Garou§7] "*/; @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) @Getter @Setter private LGGame currentGame;//Because for now, only one game will be playable on one server (flemme)

View file

@ -68,7 +68,7 @@ public class LGCustomItems {
} }
@RequiredArgsConstructor @RequiredArgsConstructor
public static enum LGCustomItemsConstraints{ public enum LGCustomItemsConstraints{
INFECTED("infecte"), INFECTED("infecte"),
MAYOR("maire"), MAYOR("maire"),
VAMPIRE_INFECTE("vampire-infecte"), VAMPIRE_INFECTE("vampire-infecte"),

View file

@ -70,13 +70,13 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
public class LGGame implements Listener{ 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 SecureRandom random = new SecureRandom();
@Getter private final int maxPlayers; @Getter private final int maxPlayers;
@Getter private ArrayList<LGPlayer> inGame = new ArrayList<LGPlayer>(); @Getter private final ArrayList<LGPlayer> inGame = new ArrayList<LGPlayer>();
@Getter private ArrayList<Role> roles = new ArrayList<Role>(); @Getter private final ArrayList<Role> roles = new ArrayList<Role>();
@Getter private boolean started; @Getter private boolean started;
@Getter private int night = 0; @Getter private int night = 0;
@ -84,12 +84,12 @@ public class LGGame implements Listener{
@Getter @Setter private int waitTicks; @Getter @Setter private int waitTicks;
@Getter private boolean day; @Getter private boolean day;
@Getter public long time = 0; @Getter public long time = 0;
@Getter private HashMap<Integer, LGPlayer> placements = new HashMap<Integer, LGPlayer>(); @Getter private final HashMap<Integer, LGPlayer> placements = new HashMap<Integer, LGPlayer>();
@Getter private LGChat spectatorChat = new LGChat((sender, message) -> { @Getter private final LGChat spectatorChat = new LGChat((sender, message) -> {
return "§7"+sender.getName()+" §6» §f"+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; return "§e"+sender.getName()+" §6» §f"+message;
}); });
@ -100,7 +100,7 @@ public class LGGame implements Listener{
} }
@Getter @Getter
private MultipleValueMap<LGPlayerKilledEvent.Reason, LGPlayer> deaths = new MultipleValueMap<LGPlayerKilledEvent.Reason, LGPlayer>(); private final MultipleValueMap<LGPlayerKilledEvent.Reason, LGPlayer> deaths = new MultipleValueMap<LGPlayerKilledEvent.Reason, LGPlayer>();
public void sendActionBarMessage(String msg) { public void sendActionBarMessage(String msg) {
WrapperPlayServerChat chat = new WrapperPlayServerChat(); WrapperPlayServerChat chat = new WrapperPlayServerChat();
@ -173,8 +173,8 @@ public class LGGame implements Listener{
}.runTaskTimer(MainLg.getInstance(), 0, 1); }.runTaskTimer(MainLg.getInstance(), 0, 1);
} }
public static interface TextGenerator{ public interface TextGenerator{
public String generate(LGPlayer player, int secondsLeft); String generate(LGPlayer player, int secondsLeft);
} }
public void cancelWait() { public void cancelWait() {
if(waitTask != null) { if(waitTask != null) {
@ -551,8 +551,7 @@ public class LGGame implements Listener{
killed.getPlayer().getWorld().strikeLightningEffect(killed.getPlayer().getLocation()); killed.getPlayer().getWorld().strikeLightningEffect(killed.getPlayer().getLocation());
for(Role role : getRoles()) for(Role role : getRoles())
if(role.getPlayers().contains(killed)) role.getPlayers().remove(killed);
role.getPlayers().remove(killed);
killed.setDead(true); killed.setDead(true);

View file

@ -42,7 +42,7 @@ import net.minecraft.server.v1_15_R1.PacketPlayOutRespawn;
import net.minecraft.server.v1_15_R1.WorldType; import net.minecraft.server.v1_15_R1.WorldType;
public class LGPlayer { public class LGPlayer {
private static HashMap<Player, LGPlayer> cachedPlayers = new HashMap<Player, LGPlayer>(); private static final HashMap<Player, LGPlayer> cachedPlayers = new HashMap<Player, LGPlayer>();
public static LGPlayer thePlayer(Player player) { public static LGPlayer thePlayer(Player player) {
LGPlayer lgp = cachedPlayers.get(player); LGPlayer lgp = cachedPlayers.get(player);
if(lgp == null) { if(lgp == null) {
@ -60,7 +60,7 @@ public class LGPlayer {
@Setter @Getter private Role role; @Setter @Getter private Role role;
private LGChooseCallback chooseCallback; private LGChooseCallback chooseCallback;
private List<LGPlayer> blacklistedChoice = new ArrayList<>(0); private List<LGPlayer> 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 LGGame game;
@Getter @Setter private String latestObjective; @Getter @Setter private String latestObjective;
@Getter private CustomScoreboard scoreboard; @Getter private CustomScoreboard scoreboard;
@ -148,8 +148,8 @@ public class LGPlayer {
this.chooseCallback = null; this.chooseCallback = null;
} }
public static interface LGChooseCallback{ public interface LGChooseCallback{
public void callback(LGPlayer choosen); void callback(LGPlayer choosen);
} }
public void showView() { public void showView() {

View file

@ -44,7 +44,9 @@ import net.minecraft.server.v1_15_R1.PacketPlayOutEntityMetadata;
public class LGVote { public class LGVote {
@Getter LGPlayer choosen; @Getter LGPlayer choosen;
private int timeout, initialTimeout, littleTimeout; private int timeout;
private final int initialTimeout;
private final int littleTimeout;
private Runnable callback; private Runnable callback;
private final LGGame game; private final LGGame game;
@Getter private List<LGPlayer> participants, viewers; @Getter private List<LGPlayer> participants, viewers;

View file

@ -12,9 +12,9 @@ public class LGChat {
@Getter private final HashMap<LGPlayer, LGChatCallback> viewers = new HashMap<LGPlayer, LGChatCallback>(); @Getter private final HashMap<LGPlayer, LGChatCallback> viewers = new HashMap<LGPlayer, LGChatCallback>();
@Getter private final LGChatCallback defaultCallback; @Getter private final LGChatCallback defaultCallback;
public static interface LGChatCallback{ public interface LGChatCallback{
public String receive(LGPlayer sender, String message); String receive(LGPlayer sender, String message);
public default String send(LGPlayer sender, String message) {return null;}; default String send(LGPlayer sender, String message) {return null;}
} }
public void sendMessage(LGPlayer sender, String message) { public void sendMessage(LGPlayer sender, String message) {

View file

@ -15,6 +15,6 @@ public class LGPlayerGotKilledEvent extends LGEvent {
@Getter private final boolean endGame; @Getter private final boolean endGame;
@Getter private final LGPlayer killed; @Getter private final LGPlayer killed;
@Getter private Reason reason; @Getter private final Reason reason;
} }

View file

@ -21,7 +21,7 @@ public class LGPlayerKilledEvent extends LGEvent implements Cancellable{
@Getter @Setter private Reason reason; @Getter @Setter private Reason reason;
@RequiredArgsConstructor @RequiredArgsConstructor
public static enum Reason{ public enum Reason{
LOUP_GAROU("§7§l%s§4 est mort pendant la nuit"), LOUP_GAROU("§7§l%s§4 est mort pendant la nuit"),
GM_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()), LOUP_BLANC(LOUP_GAROU.getMessage()),

View file

@ -32,9 +32,9 @@ public class JoinListener implements Listener{
myTeam.setPlayers(Arrays.asList(p.getName())); myTeam.setPlayers(Arrays.asList(p.getName()));
myTeam.setMode(0); myTeam.setMode(0);
boolean noSpec = p.getGameMode() != GameMode.SPECTATOR; boolean noSpec = p.getGameMode() != GameMode.SPECTATOR;
for(Player player : Bukkit.getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
if(player != p) { if (player != p) {
if(player.getGameMode() != GameMode.SPECTATOR) if (player.getGameMode() != GameMode.SPECTATOR)
player.hidePlayer(p); player.hidePlayer(p);
WrapperPlayServerScoreboardTeam team = new WrapperPlayServerScoreboardTeam(); WrapperPlayServerScoreboardTeam team = new WrapperPlayServerScoreboardTeam();
team.setName(player.getName()); team.setName(player.getName());
@ -46,9 +46,9 @@ public class JoinListener implements Listener{
myTeam.sendPacket(player); myTeam.sendPacket(player);
} }
p.setFoodLevel(6); 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"); p.getPlayer().setResourcePack("http://leomelki.fr/mcgames/ressourcepacks/v32/loup_garou.zip");
else { } else {
LGPlayer lgp = LGPlayer.thePlayer(e.getPlayer()); LGPlayer lgp = LGPlayer.thePlayer(e.getPlayer());
lgp.showView(); lgp.showView();
lgp.join(MainLg.getInstance().getCurrentGame()); lgp.join(MainLg.getInstance().getCurrentGame());
@ -62,12 +62,12 @@ public class JoinListener implements Listener{
} }
@EventHandler @EventHandler
public void onResoucePack(PlayerResourcePackStatusEvent e) { public void onResoucePack(PlayerResourcePackStatusEvent e) {
if(e.getStatus() == Status.SUCCESSFULLY_LOADED) { if (e.getStatus() == Status.SUCCESSFULLY_LOADED) {
Player p = e.getPlayer(); Player p = e.getPlayer();
LGPlayer lgp = LGPlayer.thePlayer(p); LGPlayer lgp = LGPlayer.thePlayer(p);
lgp.showView(); lgp.showView();
lgp.join(MainLg.getInstance().getCurrentGame()); 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()+")"); e.getPlayer().kickPlayer(MainLg.getPrefix()+"§cIl vous faut le resourcepack pour jouer ! ("+e.getStatus()+")");
} }
@EventHandler @EventHandler

View file

@ -223,7 +223,7 @@ public class RCupidon extends Role{
if(!e.getWinners().contains(lgp)) if(!e.getWinners().contains(lgp))
e.getWinners().add(lgp); e.getWinners().add(lgp);
} else { } else {
LGPlayer player2 = lgp.getCache().<LGPlayer>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; boolean winEnCouple = (lgp.getRoleType() == RoleType.LOUP_GAROU) != (player2.getRoleType() == RoleType.LOUP_GAROU) || lgp.getRoleWinType() == RoleWinType.SEUL || player2.getRoleWinType() == RoleWinType.SEUL;
if(winEnCouple) { if(winEnCouple) {
System.out.println(lgp.getName()+" ne peut pas gagner car il était en couple !"); System.out.println(lgp.getName()+" ne peut pas gagner car il était en couple !");

View file

@ -29,8 +29,8 @@ import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
import fr.leomelki.loupgarou.events.LGVoteEvent; import fr.leomelki.loupgarou.events.LGVoteEvent;
public class RDictateur extends Role{ public class RDictateur extends Role{
static private ItemStack[] items = new ItemStack[9]; static private final ItemStack[] items = new ItemStack[9];
static private Inventory inventory; static private final Inventory inventory;
static { static {
items[3] = new ItemStack(Material.IRON_NUGGET); items[3] = new ItemStack(Material.IRON_NUGGET);
ItemMeta meta = items[3].getItemMeta(); ItemMeta meta = items[3].getItemMeta();

View file

@ -80,7 +80,7 @@ public class REnfantSauvage extends Role{
} }
}, player); }, player);
} }
private static Random random = new Random(); private static final Random random = new Random();
@Override @Override
protected void onNightTurnTimeout(LGPlayer player) { protected void onNightTurnTimeout(LGPlayer player) {
player.stopChoosing(); player.stopChoosing();

View file

@ -54,7 +54,7 @@ public class RFaucheur extends Role{
return -1; return -1;
} }
private static Random random = new Random(); private static final Random random = new Random();
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onKill(LGPlayerKilledEvent e) { public void onKill(LGPlayerKilledEvent e) {

View file

@ -96,7 +96,7 @@ public class RGarde extends Role{
//player.sendMessage("§cVous n'avez protégé personne cette nuit."); //player.sendMessage("§cVous n'avez protégé personne cette nuit.");
} }
private static List<Reason> reasonsProtected = Arrays.asList(Reason.LOUP_GAROU, Reason.LOUP_BLANC, Reason.GM_LOUP_GAROU, Reason.ASSASSIN); private static final List<Reason> reasonsProtected = Arrays.asList(Reason.LOUP_GAROU, Reason.LOUP_BLANC, Reason.GM_LOUP_GAROU, Reason.ASSASSIN);
@EventHandler @EventHandler
public void onPlayerKill(LGNightPlayerPreKilledEvent e) { public void onPlayerKill(LGNightPlayerPreKilledEvent e) {

View file

@ -71,7 +71,7 @@ public class RLoupGarou extends Role{
return 30; 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; return "§c"+sender.getName()+" §6» §f"+message;
}); });

View file

@ -19,7 +19,7 @@ import fr.leomelki.loupgarou.events.LGGameEndEvent;
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason; import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
public class RLoupGarouBlanc extends Role{ public class RLoupGarouBlanc extends Role{
private static ItemStack skip; private static final ItemStack skip;
static { static {
skip = new ItemStack(Material.IRON_NUGGET); skip = new ItemStack(Material.IRON_NUGGET);
ItemMeta meta = skip.getItemMeta(); ItemMeta meta = skip.getItemMeta();

View file

@ -55,7 +55,7 @@ public class RMontreurDOurs extends Role{
return -1; return -1;
} }
private static Random random = new Random(); private static final Random random = new Random();
private int lastNight = -1; private int lastNight = -1;
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)

View file

@ -130,7 +130,7 @@ public class RPyromane extends Role{
@Override @Override
protected void onNightTurnTimeout(LGPlayer player) { protected void onNightTurnTimeout(LGPlayer player) {
if(first != null) { if(first != null) {
List<LGPlayer> liste = player.getCache().<List<LGPlayer>>get("pyromane_essence"); List<LGPlayer> liste = player.getCache().get("pyromane_essence");
LGPyromaneGasoilEvent event = new LGPyromaneGasoilEvent(getGame(), first); LGPyromaneGasoilEvent event = new LGPyromaneGasoilEvent(getGame(), first);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if(event.isCancelled()) if(event.isCancelled())
@ -172,7 +172,7 @@ public class RPyromane extends Role{
e.setCancelled(true); e.setCancelled(true);
closeInventory(player); closeInventory(player);
if(lgp.getCache().<List<LGPlayer>>get("pyromane_essence").size() != 0) { if(lgp.getCache().<List<LGPlayer>>get("pyromane_essence").size() != 0) {
List<LGPlayer> liste = lgp.getCache().<List<LGPlayer>>get("pyromane_essence"); List<LGPlayer> liste = lgp.getCache().get("pyromane_essence");
for(LGPlayer scndPlayer : liste) { for(LGPlayer scndPlayer : liste) {
if(!scndPlayer.isDead() && scndPlayer.getPlayer() != null) { if(!scndPlayer.isDead() && scndPlayer.getPlayer() != null) {
getGame().kill(scndPlayer, Reason.PYROMANE); 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."); lgp.sendMessage("§cTu as déjà versé du gasoil sur §7§l"+choosen.getName()+"§6.");
return; return;
} }
List<LGPlayer> liste = lgp.getCache().<List<LGPlayer>>get("pyromane_essence"); List<LGPlayer> liste = lgp.getCache().get("pyromane_essence");
if(liste.contains(choosen)) { if(liste.contains(choosen)) {
lgp.sendMessage("§7§l"+choosen.getName()+"§c est déjà recouvert de gasoil."); lgp.sendMessage("§7§l"+choosen.getName()+"§c est déjà recouvert de gasoil.");
return; return;
@ -266,9 +266,9 @@ public class RPyromane extends Role{
if(e.getGame() == getGame()) if(e.getGame() == getGame())
for(LGPlayer lgp : getPlayers()) for(LGPlayer lgp : getPlayers())
if(lgp.getCache().has("pyromane_essence")) { if(lgp.getCache().has("pyromane_essence")) {
List<LGPlayer> liste = lgp.getCache().<List<LGPlayer>>get("pyromane_essence"); List<LGPlayer> liste = lgp.getCache().get("pyromane_essence");
if(liste.contains(e.getKilled()))//Au cas le mec soit rez //Au cas le mec soit rez
liste.remove(e.getKilled()); liste.remove(e.getKilled());
} }
} }
@EventHandler @EventHandler

View file

@ -24,8 +24,8 @@ import fr.leomelki.loupgarou.classes.LGPlayer;
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason; import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
public class RSorciere extends Role{ public class RSorciere extends Role{
private static ItemStack[] items = new ItemStack[4]; private static final ItemStack[] items = new ItemStack[4];
private static ItemStack cancel; private static final ItemStack cancel;
static { static {
items[0] = new ItemStack(Material.PURPLE_DYE, 1); items[0] = new ItemStack(Material.PURPLE_DYE, 1);
ItemMeta meta = items[0].getItemMeta(); ItemMeta meta = items[0].getItemMeta();

View file

@ -82,7 +82,7 @@ public class RVampire extends Role{
return nextCanInfect < getGame().getNight() && super.hasPlayersLeft(); 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; return "§5"+sender.getName()+" §6» §f"+message;
}); });
int nextCanInfect = 0; int nextCanInfect = 0;

View file

@ -17,7 +17,7 @@ import lombok.Setter;
public abstract class Role implements Listener{ public abstract class Role implements Listener{
@Getter @Setter private int waitedPlayers; @Getter @Setter private int waitedPlayers;
@Getter private ArrayList<LGPlayer> players = new ArrayList<LGPlayer>(); @Getter private final ArrayList<LGPlayer> players = new ArrayList<LGPlayer>();
@Getter private final LGGame game; @Getter private final LGGame game;
public Role(LGGame game) { public Role(LGGame game) {

View file

@ -21,5 +21,5 @@ public enum RoleSort {
Pirate, Pirate,
Bouffon, Bouffon,
Sorciere, Sorciere,
Corbeau; Corbeau
} }

View file

@ -4,5 +4,5 @@ public enum RoleType {
VILLAGER, VILLAGER,
LOUP_GAROU, LOUP_GAROU,
VAMPIRE, VAMPIRE,
NEUTRAL; NEUTRAL
} }

View file

@ -5,5 +5,5 @@ public enum RoleWinType {
VILLAGE, VILLAGE,
LOUP_GAROU, LOUP_GAROU,
VAMPIRE, VAMPIRE,
NONE; NONE
} }

View file

@ -12,7 +12,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
public class CustomScoreboardEntry { 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 //setter car flemme de modifier le systeme pour le rendre plus logique
@Getter @Setter private int score; @Getter @Setter private int score;

View file

@ -10,7 +10,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
public class MultipleValueMap<K, V> { public class MultipleValueMap<K, V> {
private HashMap<K, List<V>> map = new HashMap<>(); private final HashMap<K, List<V>> map = new HashMap<>();
public void put(K key, V value) { public void put(K key, V value) {
List<V> list = map.get(key); List<V> list = map.get(key);
if(list == null) if(list == null)
@ -56,7 +56,7 @@ public class MultipleValueMap<K, V> {
@AllArgsConstructor @AllArgsConstructor
public static class MultipleValueKeyEntry<K, V> implements Entry<K, V>{ public static class MultipleValueKeyEntry<K, V> implements Entry<K, V>{
@Getter @Getter
private K key; private final K key;
@Getter @Getter
private V value; private V value;
@Override @Override

View file

@ -3,10 +3,10 @@ package fr.leomelki.loupgarou.utils;
import java.util.HashMap; import java.util.HashMap;
public class VariableCache { public class VariableCache {
private HashMap<String, Object> cache = new HashMap<String, Object>(); private final HashMap<String, Object> cache = new HashMap<String, Object>();
public boolean getBoolean(String key) { public boolean getBoolean(String key) {
Object object = get(key); Object object = get(key);
return object == null ? false : (boolean)object; return object != null && (boolean) object;
} }
public void set(String key, Object value) { public void set(String key, Object value) {
if(cache.containsKey(key)) if(cache.containsKey(key))

View file

@ -40,7 +40,7 @@ public class VariousUtils {
e.printStackTrace(); e.printStackTrace();
} }
} }
private static char[] hex = "0123456789abcdef".toCharArray(); private static final char[] hex = "0123456789abcdef".toCharArray();
public static char toHex(int i) { public static char toHex(int i) {
return hex[i]; return hex[i];
} }

View file

@ -5,4 +5,4 @@ main: fr.leomelki.loupgarou.MainLg
depend: [ProtocolLib] depend: [ProtocolLib]
api-version: 1.13 api-version: 1.13
commands: commands:
lg: ww: