Version 1.1.0
Ajouté: - Rôle Montreur d'Ours - Rôle Vampire - Rôle Chasseur de Vampire Corrections: - Quelques corrections de bugs - Ajouts de messages afin d'éviter les erreurs dans certaines commandes
This commit is contained in:
parent
cc75c0746f
commit
5d41f506e5
35 changed files with 721 additions and 71 deletions
2
pom.xml
2
pom.xml
|
@ -2,7 +2,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>fr.leomelki</groupId>
|
||||
<artifactId>LoupGarou</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.1.0</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
|
|
@ -56,6 +56,7 @@ import fr.leomelki.loupgarou.roles.RAssassin;
|
|||
import fr.leomelki.loupgarou.roles.RBouffon;
|
||||
import fr.leomelki.loupgarou.roles.RChaperonRouge;
|
||||
import fr.leomelki.loupgarou.roles.RChasseur;
|
||||
import fr.leomelki.loupgarou.roles.RChasseurDeVampire;
|
||||
import fr.leomelki.loupgarou.roles.RChienLoup;
|
||||
import fr.leomelki.loupgarou.roles.RCorbeau;
|
||||
import fr.leomelki.loupgarou.roles.RCupidon;
|
||||
|
@ -69,15 +70,18 @@ import fr.leomelki.loupgarou.roles.RLoupGarou;
|
|||
import fr.leomelki.loupgarou.roles.RLoupGarouBlanc;
|
||||
import fr.leomelki.loupgarou.roles.RLoupGarouNoir;
|
||||
import fr.leomelki.loupgarou.roles.RMedium;
|
||||
import fr.leomelki.loupgarou.roles.RMontreurDOurs;
|
||||
import fr.leomelki.loupgarou.roles.RPetiteFille;
|
||||
import fr.leomelki.loupgarou.roles.RPirate;
|
||||
import fr.leomelki.loupgarou.roles.RPretre;
|
||||
import fr.leomelki.loupgarou.roles.RPyromane;
|
||||
import fr.leomelki.loupgarou.roles.RSorciere;
|
||||
import fr.leomelki.loupgarou.roles.RSurvivant;
|
||||
import fr.leomelki.loupgarou.roles.RVampire;
|
||||
import fr.leomelki.loupgarou.roles.RVillageois;
|
||||
import fr.leomelki.loupgarou.roles.RVoyante;
|
||||
import fr.leomelki.loupgarou.roles.Role;
|
||||
import fr.leomelki.loupgarou.utils.VariousUtils;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
@ -100,7 +104,6 @@ public class MainLg extends JavaPlugin{
|
|||
saveConfig();
|
||||
}
|
||||
loadConfig();
|
||||
Bukkit.getConsoleSender().sendMessage("/");
|
||||
Bukkit.getPluginManager().registerEvents(new JoinListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new CancelListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new VoteListener(), this);
|
||||
|
@ -225,9 +228,23 @@ public class MainLg extends JavaPlugin{
|
|||
sender.sendMessage(prefix+"§aLa position a bien été ajoutée !");
|
||||
return true;
|
||||
}else if(args[0].equalsIgnoreCase("end")) {
|
||||
LGPlayer.thePlayer(Bukkit.getPlayer(args[1])).getGame().cancelWait();
|
||||
LGPlayer.thePlayer(Bukkit.getPlayer(args[1])).getGame().endGame(LGWinType.EQUAL);
|
||||
LGPlayer.thePlayer(Bukkit.getPlayer(args[1])).getGame().broadcastMessage("§cLa partie a été arrêtée de force !");
|
||||
if(args.length != 2) {
|
||||
sender.sendMessage("§4Utilisation : §c/lg end <pseudo>");
|
||||
return true;
|
||||
}
|
||||
Player selected = Bukkit.getPlayer(args[1]);
|
||||
if(selected == null) {
|
||||
sender.sendMessage("§4Erreur : §cLe joueur §4"+args[1]+"§c n'est pas connecté.");
|
||||
return true;
|
||||
}
|
||||
LGGame game = LGPlayer.thePlayer(selected).getGame();
|
||||
if(game == null) {
|
||||
sender.sendMessage("§4Erreur : §cLe joueur §4"+selected.getName()+"§c n'est pas dans une partie.");
|
||||
return true;
|
||||
}
|
||||
game.cancelWait();
|
||||
game.endGame(LGWinType.EQUAL);
|
||||
game.broadcastMessage("§cLa partie a été arrêtée de force !");
|
||||
return true;
|
||||
}else if(args[0].equalsIgnoreCase("start")) {
|
||||
if(args.length < 2) {
|
||||
|
@ -240,6 +257,10 @@ public class MainLg extends JavaPlugin{
|
|||
return true;
|
||||
}
|
||||
LGPlayer lgp = LGPlayer.thePlayer(player);
|
||||
if(lgp.getGame() == null) {
|
||||
sender.sendMessage("§4Erreur : §cLe joueur §4"+lgp.getName()+"§c n'est pas dans une partie.");
|
||||
return true;
|
||||
}
|
||||
if(MainLg.getInstance().getConfig().getList("spawns").size() < lgp.getGame().getMaxPlayers()) {
|
||||
sender.sendMessage("§4Erreur : §cIl n'y a pas assez de points de spawn !");
|
||||
sender.sendMessage("§8§oPour les définir, merci de faire §7/lg addSpawn");
|
||||
|
@ -413,6 +434,9 @@ public class MainLg extends JavaPlugin{
|
|||
roles.put("Pretre", RPretre.class.getConstructor(LGGame.class));
|
||||
roles.put("Faucheur", RFaucheur.class.getConstructor(LGGame.class));
|
||||
roles.put("EnfantSauvage", REnfantSauvage.class.getConstructor(LGGame.class));
|
||||
roles.put("MontreurDOurs", RMontreurDOurs.class.getConstructor(LGGame.class));
|
||||
roles.put("Vampire", RVampire.class.getConstructor(LGGame.class));
|
||||
roles.put("ChasseurDeVampire", RChasseurDeVampire.class.getConstructor(LGGame.class));
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -30,6 +30,7 @@ import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
|
||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerChat;
|
||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerEntityDestroy;
|
||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerExperience;
|
||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerPlayerInfo;
|
||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardObjective;
|
||||
|
@ -190,7 +191,6 @@ public class LGGame implements Listener{
|
|||
deaths.put(event.getReason(), player);
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean tryToJoin(LGPlayer lgp) {
|
||||
if(ended)return false;
|
||||
if(!started && inGame.size() < maxPlayers) {//Si la partie n'a pas démarrée et qu'il reste de la place
|
||||
|
@ -199,9 +199,32 @@ public class LGGame implements Listener{
|
|||
if(lgp.isMuted())
|
||||
lgp.resetMuted();
|
||||
|
||||
lgp.getPlayer().getInventory().clear();
|
||||
lgp.getPlayer().updateInventory();
|
||||
lgp.getPlayer().closeInventory();
|
||||
Player player = lgp.getPlayer();
|
||||
|
||||
// Clear votes
|
||||
|
||||
WrapperPlayServerEntityDestroy destroy = new WrapperPlayServerEntityDestroy();
|
||||
destroy.setEntityIds(new int[] {Integer.MIN_VALUE+player.getEntityId()});
|
||||
int[] ids = new int[getInGame().size()+1];
|
||||
for(int i = 0;i<getInGame().size();i++) {
|
||||
Player l = getInGame().get(i).getPlayer();
|
||||
if(l == null)
|
||||
continue;
|
||||
ids[i] = Integer.MIN_VALUE+l.getEntityId();
|
||||
destroy.sendPacket(l);
|
||||
}
|
||||
|
||||
ids[ids.length-1] = -player.getEntityId();// Clear voting
|
||||
|
||||
destroy = new WrapperPlayServerEntityDestroy();
|
||||
destroy.setEntityIds(ids);
|
||||
destroy.sendPacket(player);
|
||||
|
||||
// End clear votes/voting
|
||||
|
||||
player.getInventory().clear();
|
||||
player.updateInventory();
|
||||
player.closeInventory();
|
||||
|
||||
lgp.joinChat(dayChat);
|
||||
|
||||
|
@ -213,22 +236,22 @@ public class LGGame implements Listener{
|
|||
for(LGPlayer other : getInGame()) {
|
||||
other.updatePrefix();
|
||||
if(lgp != other) {
|
||||
lgp.getPlayer().hidePlayer(other.getPlayer());
|
||||
lgp.getPlayer().showPlayer(other.getPlayer());
|
||||
player.hidePlayer(other.getPlayer());
|
||||
player.showPlayer(other.getPlayer());
|
||||
|
||||
other.getPlayer().hidePlayer(lgp.getPlayer());
|
||||
other.getPlayer().showPlayer(lgp.getPlayer());
|
||||
other.getPlayer().hidePlayer(player);
|
||||
other.getPlayer().showPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
lgp.getPlayer().setGameMode(GameMode.ADVENTURE);
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
broadcastMessage("§7Le joueur §8"+lgp.getName()+"§7 a rejoint la partie §9(§8"+inGame.size()+"§7/§8"+maxPlayers+"§9)");
|
||||
|
||||
//Reset scoreboard
|
||||
WrapperPlayServerScoreboardObjective obj = new WrapperPlayServerScoreboardObjective();
|
||||
obj.setName("lg_scoreboard");
|
||||
obj.setMode(1);
|
||||
obj.sendPacket(lgp.getPlayer());
|
||||
obj.sendPacket(player);
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new LGGameJoinEvent(this, lgp));
|
||||
//AutoStart
|
||||
|
@ -522,7 +545,7 @@ public class LGGame implements Listener{
|
|||
if(vote != null)
|
||||
vote.remove(killed);
|
||||
|
||||
broadcastMessage(String.format(reason.getMessage(), killed.getName())+", il était "+killed.getRole().getName()+(killed.getCache().getBoolean("infected") ? " §c§l(Infecté)" : "")+"§4.");
|
||||
broadcastMessage(String.format(reason.getMessage(), killed.getName())+", il était "+killed.getRole().getName()+(killed.getCache().getBoolean("infected") ? " §c§l(Infecté)" : "")+(killed.getCache().getBoolean("vampire") ? " §5§l(Vampire)" : "")+"§4.");
|
||||
|
||||
//Lightning effect
|
||||
killed.getPlayer().getWorld().strikeLightningEffect(killed.getPlayer().getLocation());
|
||||
|
@ -579,6 +602,12 @@ public class LGGame implements Listener{
|
|||
if(event.isCancelled())
|
||||
return;
|
||||
|
||||
for(LGPlayer lgp : getInGame())//Avoid bugs
|
||||
if(lgp.getPlayer() != null)
|
||||
lgp.getPlayer().closeInventory();
|
||||
|
||||
cancelWait();//Also avoid bugs
|
||||
|
||||
ended = true;
|
||||
//We unregister every role listener because they are unused after the game's end !
|
||||
for(Role role : getRoles())
|
||||
|
@ -847,7 +876,7 @@ public class LGGame implements Listener{
|
|||
return checkEndGame(true);
|
||||
}
|
||||
public boolean checkEndGame(boolean doEndGame) {
|
||||
int goodGuy = 0, badGuy = 0, solo = 0;
|
||||
int goodGuy = 0, badGuy = 0, solo = 0, vampires = 0;
|
||||
for(LGPlayer lgp : getAlive())
|
||||
if(lgp.getRoleWinType() == RoleWinType.LOUP_GAROU)
|
||||
badGuy++;
|
||||
|
@ -855,14 +884,19 @@ public class LGGame implements Listener{
|
|||
goodGuy++;
|
||||
else if(lgp.getRoleWinType() == RoleWinType.SEUL)
|
||||
solo++;
|
||||
else if(lgp.getRoleWinType() == RoleWinType.VAMPIRE)
|
||||
vampires++;
|
||||
LGEndCheckEvent event = new LGEndCheckEvent(this, goodGuy == 0 || badGuy == 0 ? (goodGuy+badGuy == 0 ? LGWinType.EQUAL : (goodGuy > 0 ? LGWinType.VILLAGEOIS : LGWinType.LOUPGAROU)) : LGWinType.NONE);
|
||||
|
||||
if((badGuy+goodGuy > 0 && solo > 0) || solo > 1)
|
||||
if((badGuy+goodGuy > 0 && solo > 0) || solo > 1 || (badGuy+goodGuy > 0 && vampires > 0) || (solo > 0 && vampires > 0))
|
||||
event.setWinType(LGWinType.NONE);
|
||||
|
||||
if(badGuy+goodGuy == 0 && solo == 1)
|
||||
if(badGuy+goodGuy == 0 && solo == 1 && vampires == 0)
|
||||
event.setWinType(LGWinType.SOLO);
|
||||
|
||||
if(badGuy+goodGuy == 0 && solo == 0 && vampires > 0)
|
||||
event.setWinType(LGWinType.VAMPIRE);
|
||||
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if(doEndGame && event.getWinType() != LGWinType.NONE)
|
||||
endGame(event.getWinType());
|
||||
|
|
|
@ -282,10 +282,14 @@ public class LGPlayer {
|
|||
}
|
||||
|
||||
public RoleType getRoleType() {
|
||||
return this.getCache().getBoolean("infected") ? RoleType.LOUP_GAROU : getRole().getType(this);
|
||||
return this.getCache().getBoolean("vampire") ? RoleType.VAMPIRE : this.getCache().getBoolean("infected") ? RoleType.LOUP_GAROU : getRole().getType(this);
|
||||
}
|
||||
public RoleWinType getRoleWinType() {
|
||||
return this.getCache().getBoolean("infected") ? RoleWinType.LOUP_GAROU : getRole().getWinType(this);
|
||||
return this.getCache().getBoolean("vampire") ? RoleWinType.VAMPIRE : this.getCache().getBoolean("infected") ? RoleWinType.LOUP_GAROU : getRole().getWinType(this);
|
||||
}
|
||||
|
||||
public boolean isRoleActive() {
|
||||
return !this.getCache().getBoolean("vampire");
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
|
|
@ -52,7 +52,7 @@ public class LGVote {
|
|||
@Getter private final HashMap<LGPlayer, List<LGPlayer>> votes = new HashMap<LGPlayer, List<LGPlayer>>();
|
||||
private int votesSize = 0;
|
||||
private LGPlayer mayor;
|
||||
private ArrayList<LGPlayer> latestTop = new ArrayList<LGPlayer>();
|
||||
private ArrayList<LGPlayer> latestTop = new ArrayList<LGPlayer>(), blacklisted = new ArrayList<LGPlayer>();
|
||||
private final boolean positiveVote, randomIfEqual;
|
||||
@Getter private boolean mayorVote;
|
||||
private boolean ended;
|
||||
|
@ -73,6 +73,15 @@ public class LGVote {
|
|||
for(LGPlayer player : participants)
|
||||
player.choose(getChooseCallback(player));
|
||||
}
|
||||
public void start(List<LGPlayer> participants, List<LGPlayer> viewers, Runnable callback, ArrayList<LGPlayer> blacklisted) {
|
||||
this.callback = callback;
|
||||
this.participants = participants;
|
||||
this.viewers = viewers;
|
||||
game.wait(timeout, this::end, generator);
|
||||
for(LGPlayer player : participants)
|
||||
player.choose(getChooseCallback(player));
|
||||
this.blacklisted = blacklisted;
|
||||
}
|
||||
public void start(List<LGPlayer> participants, List<LGPlayer> viewers, Runnable callback, LGPlayer mayor) {
|
||||
this.callback = callback;
|
||||
this.participants = participants;
|
||||
|
@ -215,6 +224,10 @@ public class LGVote {
|
|||
};
|
||||
}
|
||||
public void vote(LGPlayer voter, LGPlayer voted) {
|
||||
if(blacklisted.contains(voted)) {
|
||||
voter.sendMessage("§cVous ne pouvez pas votre pour §7§l"+voted.getName()+"§c.");
|
||||
return;
|
||||
}
|
||||
if(voted == voter.getCache().get("vote"))
|
||||
voted = null;
|
||||
|
||||
|
@ -223,7 +236,7 @@ public class LGVote {
|
|||
if(voter.getCache().has("vote"))
|
||||
votesSize--;
|
||||
|
||||
if(votesSize == participants.size() && timeout > littleTimeout) {
|
||||
if(votesSize == participants.size() && game.getWaitTicks() > littleTimeout*20) {
|
||||
votesSize = 999;
|
||||
game.wait(littleTimeout, initialTimeout, this::end, generator);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ public enum LGWinType {
|
|||
SOLO("§6§l§oUn joueur solitaire a gagné la partie!"),//bug si ça s'affiche
|
||||
ASSASSIN("§6§l§oLa partie a été gagnée par l'§1§lAssassin§6§l§o !"),
|
||||
PYROMANE("§6§l§oLa partie a été gagnée par le §6§lPyromane§6§l§o !"),
|
||||
VAMPIRE("§6§l§oLa partie a été gagnée par les §5§lVampires§6§l§o !"),
|
||||
NONE("§4Erreur: §cpersonne n'a gagné la partie.");
|
||||
|
||||
@Getter private final String message;
|
||||
|
|
|
@ -26,6 +26,7 @@ public class LGPlayerKilledEvent extends LGEvent implements Cancellable{
|
|||
GM_LOUP_GAROU("§7§l%s§4 est mort pendant la nuit"),
|
||||
LOUP_BLANC(LOUP_GAROU.getMessage()),
|
||||
SORCIERE(LOUP_GAROU.getMessage()),
|
||||
CHASSEUR_DE_VAMPIRE("§7§l%s§4 s'est fait purifier"),
|
||||
VOTE("§7§l%s§4 a été victime du vote"),
|
||||
CHASSEUR("§7§l%s§4 est mort sur le coup"),
|
||||
DICTATOR("§7§l%s§4 a été désigné"),
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package fr.leomelki.loupgarou.events;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
import fr.leomelki.loupgarou.classes.LGGame;
|
||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class LGVampiredEvent extends LGEvent{
|
||||
public LGVampiredEvent(LGGame game, LGPlayer player) {
|
||||
super(game);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Getter @Setter private boolean immuned, protect;
|
||||
@Getter @Setter private LGPlayer player;
|
||||
}
|
|
@ -47,7 +47,7 @@ public class JoinListener implements Listener{
|
|||
}
|
||||
p.setFoodLevel(6);
|
||||
if(e.getJoinMessage() == null || !e.getJoinMessage().equals("joinall"))
|
||||
p.getPlayer().setResourcePack("http://leomelki.fr/mcgames/ressourcepacks/v29/loup_garou.zip");
|
||||
p.getPlayer().setResourcePack("http://leomelki.fr/mcgames/ressourcepacks/v32/loup_garou.zip");
|
||||
else {
|
||||
LGPlayer lgp = LGPlayer.thePlayer(e.getPlayer());
|
||||
lgp.showView();
|
||||
|
|
|
@ -62,7 +62,7 @@ public class RAnge extends Role{
|
|||
night = getGame().getNight();
|
||||
vote = true;
|
||||
for(LGPlayer lgp : getPlayers())
|
||||
if(!lgp.isDead())
|
||||
if(!lgp.isDead() && lgp.isRoleActive())
|
||||
lgp.sendMessage("§9§oFais en sorte que les autres votent contre toi !");
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ public class RAnge extends Role{
|
|||
getGame().getRoles().add(villageois = new RVillageois(getGame()));
|
||||
|
||||
for(LGPlayer lgp : getPlayers()) {
|
||||
if(lgp.isRoleActive())
|
||||
lgp.sendMessage("§4§oTu as échoué, tu deviens §a§l§oVillageois§4§o...");
|
||||
lgp.setRole(villageois);
|
||||
villageois.join(lgp);
|
||||
|
@ -97,7 +98,7 @@ public class RAnge extends Role{
|
|||
@EventHandler
|
||||
public void onDeath(LGPlayerGotKilledEvent e) {
|
||||
if(e.getGame() == getGame())
|
||||
if(e.getReason() == Reason.VOTE && e.getKilled().getRole() == this && getGame().getNight() == night)
|
||||
if(e.getReason() == Reason.VOTE && e.getKilled().getRole() == this && getGame().getNight() == night && e.getKilled().isRoleActive())
|
||||
winners.add(e.getKilled());
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,10 @@ import fr.leomelki.loupgarou.events.LGEndCheckEvent;
|
|||
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
||||
import fr.leomelki.loupgarou.events.LGNightEndEvent;
|
||||
import fr.leomelki.loupgarou.events.LGNightPlayerPreKilledEvent;
|
||||
import fr.leomelki.loupgarou.events.LGPyromaneGasoilEvent;
|
||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||
import fr.leomelki.loupgarou.events.LGPyromaneGasoilEvent;
|
||||
import fr.leomelki.loupgarou.events.LGRoleTurnEndEvent;
|
||||
import fr.leomelki.loupgarou.events.LGVampiredEvent;
|
||||
|
||||
public class RAssassin extends Role{
|
||||
public RAssassin(LGGame game) {
|
||||
|
@ -77,7 +78,7 @@ public class RAssassin extends Role{
|
|||
|
||||
@EventHandler
|
||||
public void onKill(LGNightPlayerPreKilledEvent e) {
|
||||
if(e.getKilled().getRole() == this && e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.GM_LOUP_GAROU) {//Les assassins ne peuvent pas mourir la nuit !
|
||||
if(e.getKilled().getRole() == this && e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.GM_LOUP_GAROU && e.getKilled().isRoleActive()) {//Les assassins ne peuvent pas mourir la nuit !
|
||||
e.setReason(Reason.DONT_DIE);
|
||||
e.getKilled().getCache().set("assassin_protected", true);
|
||||
}
|
||||
|
@ -105,9 +106,14 @@ public class RAssassin extends Role{
|
|||
|
||||
@EventHandler
|
||||
public void onPyroGasoil(LGPyromaneGasoilEvent e) {
|
||||
if(e.getPlayer().getRole() == this)
|
||||
if(e.getPlayer().getRole() == this && e.getPlayer().isRoleActive())
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@EventHandler
|
||||
public void onVampired(LGVampiredEvent e) {
|
||||
if(e.getPlayer().getRole() == this && e.getPlayer().isRoleActive())
|
||||
e.setImmuned(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDayStart(LGNightEndEvent e) {
|
||||
|
@ -121,10 +127,15 @@ public class RAssassin extends Role{
|
|||
@EventHandler
|
||||
public void onEndgameCheck(LGEndCheckEvent e) {
|
||||
if(e.getGame() == getGame() && e.getWinType() == LGWinType.SOLO) {
|
||||
if(getPlayers().size() > 0)
|
||||
if(getPlayers().size() > 0) {
|
||||
if(getPlayers().size() > 1)
|
||||
for(LGPlayer lgp : getPlayers())
|
||||
if(!lgp.isRoleActive())
|
||||
return;
|
||||
e.setWinType(LGWinType.ASSASSIN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onEndGame(LGGameEndEvent e) {
|
||||
|
|
|
@ -121,7 +121,7 @@ public class RBouffon extends Role{
|
|||
|
||||
@EventHandler
|
||||
public void onPlayerKill(LGPlayerKilledEvent e) {
|
||||
if(e.getKilled().getRole() == this && e.getReason() == Reason.VOTE) {
|
||||
if(e.getKilled().getRole() == this && e.getReason() == Reason.VOTE && e.getKilled().isRoleActive()) {
|
||||
needToPlay.add(e.getKilled());
|
||||
getGame().broadcastMessage("§9§oQuelle erreur, le "+getName()+"§9§o aura droit à sa vengeance...");
|
||||
e.getKilled().sendMessage("§6Tu as rempli ta mission, l'heure de la vengeance a sonné.");
|
||||
|
|
|
@ -53,7 +53,7 @@ public class RChaperonRouge extends Role{
|
|||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onKill(LGNightPlayerPreKilledEvent e) {
|
||||
if(e.getKilled().getRole() == this && e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.GM_LOUP_GAROU) {
|
||||
if(e.getKilled().getRole() == this && e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.GM_LOUP_GAROU && e.getKilled().isRoleActive()) {
|
||||
for(Role role : getGame().getRoles())
|
||||
if(role instanceof RChasseur)
|
||||
if(role.getPlayers().size() > 0){
|
||||
|
@ -68,14 +68,14 @@ public class RChaperonRouge extends Role{
|
|||
if(e.getGame() == getGame()) {
|
||||
if(e.getPreviousRole() instanceof RLoupGarou) {
|
||||
for(LGPlayer lgp : getGame().getAlive())
|
||||
if(lgp.getCache().getBoolean("chaperon_kill")) {
|
||||
if(lgp.getCache().getBoolean("chaperon_kill") && lgp.isRoleActive()) {
|
||||
for(LGPlayer l : getGame().getInGame())
|
||||
if(l.getRoleType() == RoleType.LOUP_GAROU)
|
||||
l.sendMessage("§cVotre cible est immunisée.");
|
||||
}
|
||||
}else if(e.getPreviousRole() instanceof RGrandMechantLoup) {
|
||||
for(LGPlayer lgp : getGame().getAlive())
|
||||
if(lgp.getCache().getBoolean("chaperon_kill")) {
|
||||
if(lgp.getCache().getBoolean("chaperon_kill") && lgp.isRoleActive()) {
|
||||
for(LGPlayer l : e.getPreviousRole().getPlayers())
|
||||
l.sendMessage("§cVotre cible est immunisée.");
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public class RChasseur extends Role{
|
|||
|
||||
@EventHandler
|
||||
public void onPlayerKill(LGPlayerKilledEvent e) {
|
||||
if(e.getKilled().getRole() == this && e.getReason() != Reason.DISCONNECTED)
|
||||
if(e.getKilled().getRole() == this && e.getReason() != Reason.DISCONNECTED && e.getKilled().isRoleActive())
|
||||
needToPlay.add(e.getKilled());
|
||||
}
|
||||
@EventHandler
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
package fr.leomelki.loupgarou.roles;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import fr.leomelki.loupgarou.classes.LGGame;
|
||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||
import fr.leomelki.loupgarou.classes.LGPlayer.LGChooseCallback;
|
||||
import fr.leomelki.loupgarou.classes.LGWinType;
|
||||
import fr.leomelki.loupgarou.events.LGEndCheckEvent;
|
||||
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
||||
import fr.leomelki.loupgarou.events.LGNightEndEvent;
|
||||
import fr.leomelki.loupgarou.events.LGNightPlayerPreKilledEvent;
|
||||
import fr.leomelki.loupgarou.events.LGPyromaneGasoilEvent;
|
||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||
import fr.leomelki.loupgarou.events.LGRoleTurnEndEvent;
|
||||
|
||||
public class RChasseurDeVampire extends Role{
|
||||
public RChasseurDeVampire(LGGame game) {
|
||||
super(game);
|
||||
}
|
||||
@Override
|
||||
public RoleType getType() {
|
||||
return RoleType.VILLAGER;
|
||||
}
|
||||
@Override
|
||||
public RoleWinType getWinType() {
|
||||
return RoleWinType.VILLAGE;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return "§a§lChasseur de Vampires";
|
||||
}
|
||||
@Override
|
||||
public String getFriendlyName() {
|
||||
return "du "+getName();
|
||||
}
|
||||
@Override
|
||||
public String getShortDescription() {
|
||||
return "Tu gagnes avec le §a§lVillage";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux traquer un joueur pour découvrir s'il s'agit d'un Vampire. Si c'est le cas, tu le tueras dans son sommeil. Si les §5§lVampires§f te prennent pour cible, tu seras immunisé contre leur attaque, et tu tueras le plus jeune d'entre eux.";
|
||||
}
|
||||
@Override
|
||||
public String getTask() {
|
||||
return "Choisis un joueur à pister.";
|
||||
}
|
||||
@Override
|
||||
public String getBroadcastedTask() {
|
||||
return "Le "+getName()+"§9 traque ses proies...";
|
||||
}
|
||||
@Override
|
||||
public int getTimeout() {
|
||||
return 15;
|
||||
}
|
||||
@Override
|
||||
public boolean hasPlayersLeft() {
|
||||
for(LGPlayer lgp : getGame().getAlive())
|
||||
if(lgp.getRoleType() == RoleType.VAMPIRE)
|
||||
return super.hasPlayersLeft();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||
player.showView();
|
||||
|
||||
player.choose(new LGChooseCallback() {
|
||||
@Override
|
||||
public void callback(LGPlayer choosen) {
|
||||
if(choosen != null && choosen != player) {
|
||||
// player.sendMessage("§6Tu as choisi de rendre visite à §7§l"+choosen.getName()+"§6.");
|
||||
if(choosen.getCache().getBoolean("vampire") || choosen.getRole() instanceof RVampire) {
|
||||
getGame().kill(choosen, Reason.CHASSEUR_DE_VAMPIRE);
|
||||
player.sendMessage("§7§l"+choosen.getName()+"§6 est un §5§lVampire§6, à l'attaque.");
|
||||
player.sendActionBarMessage("§e§l"+choosen.getName()+"§6 va mourir");
|
||||
} else {
|
||||
player.sendMessage("§7§l"+choosen.getName()+"§6 n'est pas un §5§lVampire§6...");
|
||||
player.sendActionBarMessage("§e§l"+choosen.getName()+"§6 n'est pas un §5§lVampire");
|
||||
}
|
||||
|
||||
player.stopChoosing();
|
||||
player.hideView();
|
||||
callback.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onNightTurnTimeout(LGPlayer player) {
|
||||
player.stopChoosing();
|
||||
player.hideView();
|
||||
//player.sendTitle("§cVous n'avez regardé aucun rôle", "§4Vous avez mis trop de temps à vous décider...", 80);
|
||||
//player.sendMessage("§cVous n'avez pas utilisé votre pouvoir cette nuit.");
|
||||
}
|
||||
}
|
|
@ -188,7 +188,7 @@ public class RDictateur extends Role{
|
|||
}
|
||||
public void onTurn(Cancellable e) {
|
||||
for(LGPlayer lgp : getPlayers())
|
||||
if(lgp.getCache().getBoolean("just_coup_d_etat"))
|
||||
if(lgp.getCache().getBoolean("just_coup_d_etat") && lgp.isRoleActive())
|
||||
e.setCancelled(true);
|
||||
|
||||
if(!e.isCancelled())
|
||||
|
|
|
@ -100,7 +100,7 @@ public class REnfantSauvage extends Role{
|
|||
if(e.getGame() == getGame())
|
||||
if(e.getKilled().getCache().has("enfant_svg_d")) {
|
||||
LGPlayer enfant = e.getKilled().getCache().remove("enfant_svg_d");
|
||||
if(!enfant.isDead() && enfant.getCache().remove("enfant_svg") == e.getKilled()) {
|
||||
if(!enfant.isDead() && enfant.getCache().remove("enfant_svg") == e.getKilled() && enfant.isRoleActive()) {
|
||||
enfant.sendMessage("§7§l"+e.getKilled().getName()+"§6 est mort, tu deviens un §c§lLoup-Garou§6.");
|
||||
REnfantSauvageLG lgEnfantSvg = null;
|
||||
for(Role role : getGame().getRoles())
|
||||
|
|
|
@ -58,7 +58,7 @@ public class RFaucheur extends Role{
|
|||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onKill(LGPlayerKilledEvent e) {
|
||||
if (e.getKilled().getRole() == this) {
|
||||
if (e.getKilled().getRole() == this && e.getKilled().isRoleActive()) {
|
||||
LGPlayer killed = e.getKilled();
|
||||
if(killed.getCache().getBoolean("faucheur_did"))//A déjà fait son coup de faucheur !
|
||||
return;
|
||||
|
|
|
@ -11,6 +11,7 @@ import fr.leomelki.loupgarou.classes.LGPlayer.LGChooseCallback;
|
|||
import fr.leomelki.loupgarou.events.LGNightPlayerPreKilledEvent;
|
||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||
import fr.leomelki.loupgarou.events.LGPreDayStartEvent;
|
||||
import fr.leomelki.loupgarou.events.LGVampiredEvent;
|
||||
|
||||
public class RGarde extends Role{
|
||||
public RGarde(LGGame game) {
|
||||
|
@ -105,6 +106,11 @@ public class RGarde extends Role{
|
|||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onVampired(LGVampiredEvent e) {
|
||||
if(e.getGame() == getGame() && e.getPlayer().getCache().getBoolean("garde_protected"))
|
||||
e.setProtect(true);
|
||||
}
|
||||
@EventHandler
|
||||
public void onDayStart(LGPreDayStartEvent e) {
|
||||
if(e.getGame() == getGame())
|
||||
for(LGPlayer lgp : getGame().getInGame())
|
||||
|
|
|
@ -80,7 +80,7 @@ public class RMedium extends Role{
|
|||
if(e.getGame() == getGame())
|
||||
if(e.getPreviousRole() instanceof RLoupGarou)
|
||||
for(LGPlayer lgp : getPlayers())
|
||||
if(lgp.getChat() != getGame().getSpectatorChat()) {
|
||||
if(lgp.getChat() != getGame().getSpectatorChat() && lgp.isRoleActive()) {
|
||||
lgp.sendMessage("§6§oTu peux de nouveau parler aux morts...");
|
||||
joinChat(lgp);
|
||||
}
|
||||
|
@ -90,6 +90,7 @@ public class RMedium extends Role{
|
|||
public void onDay(LGPreDayStartEvent e) {
|
||||
if(e.getGame() == getGame())
|
||||
for(LGPlayer lgp : getPlayers())
|
||||
if(lgp.isRoleActive())
|
||||
lgp.leaveChat();
|
||||
}
|
||||
}
|
||||
|
|
107
src/main/java/fr/leomelki/loupgarou/roles/RMontreurDOurs.java
Normal file
107
src/main/java/fr/leomelki/loupgarou/roles/RMontreurDOurs.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
package fr.leomelki.loupgarou.roles;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import fr.leomelki.loupgarou.MainLg;
|
||||
import fr.leomelki.loupgarou.classes.LGGame;
|
||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||
import fr.leomelki.loupgarou.events.LGDayStartEvent;
|
||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent;
|
||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||
|
||||
public class RMontreurDOurs extends Role{
|
||||
public RMontreurDOurs(LGGame game) {
|
||||
super(game);
|
||||
}
|
||||
@Override
|
||||
public RoleType getType() {
|
||||
return RoleType.VILLAGER;
|
||||
}
|
||||
@Override
|
||||
public RoleWinType getWinType() {
|
||||
return RoleWinType.VILLAGE;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return "§a§lMontreur d'Ours";
|
||||
}
|
||||
@Override
|
||||
public String getFriendlyName() {
|
||||
return "du "+getName();
|
||||
}
|
||||
@Override
|
||||
public String getShortDescription() {
|
||||
return "Tu gagnes avec le §a§lVillage";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Tu gagnes avec le §a§lVillage§f. Chaque matin, ton Ours va renifler tes voisins et grognera si l'un d'eux est hostile aux Villageois.";
|
||||
}
|
||||
@Override
|
||||
public String getTask() {
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public String getBroadcastedTask() {
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public int getTimeout() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static Random random = new Random();
|
||||
private int lastNight = -1;
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onDay(LGDayStartEvent e) {
|
||||
if (e.getGame() == getGame() && getPlayers().size() > 0) {
|
||||
if(lastNight == getGame().getNight())
|
||||
return;
|
||||
lastNight = getGame().getNight();
|
||||
List<?> original = MainLg.getInstance().getConfig().getList("spawns");
|
||||
for(LGPlayer target : getPlayers()) {
|
||||
if(!target.isRoleActive())
|
||||
continue;
|
||||
int size = original.size();
|
||||
int killedPlace = target.getPlace();
|
||||
|
||||
for (int i = killedPlace + 1;; i++) {
|
||||
if (i == size)
|
||||
i = 0;
|
||||
LGPlayer lgp = getGame().getPlacements().get(i);
|
||||
if (lgp != null && !lgp.isDead()) {
|
||||
if(lgp.getRoleWinType() == RoleWinType.VILLAGE || lgp.getRoleWinType() == RoleWinType.NONE)
|
||||
break;
|
||||
else{
|
||||
getGame().broadcastMessage("§6La bête du "+getName()+"§6 grogne...");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (lgp == target)// Fait un tour complet
|
||||
break;
|
||||
}
|
||||
for (int i = killedPlace - 1;; i--) {
|
||||
if (i == -1)
|
||||
i = size - 1;
|
||||
LGPlayer lgp = getGame().getPlacements().get(i);
|
||||
if (lgp != null && !lgp.isDead()) {
|
||||
if(lgp.getRoleWinType() == RoleWinType.VILLAGE || lgp.getRoleWinType() == RoleWinType.NONE)
|
||||
break;
|
||||
else{
|
||||
getGame().broadcastMessage("§6La bête du "+getName()+"§6 grogne...");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (lgp == target)// Fait un tour complet
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -60,7 +60,7 @@ public class RPetiteFille extends Role{
|
|||
if(role instanceof RLoupGarou) {
|
||||
RLoupGarou lgRole = (RLoupGarou)role;
|
||||
for(LGPlayer player : getPlayers())
|
||||
if(!player.getCache().getBoolean("infected"))
|
||||
if(!player.getCache().getBoolean("infected") && player.isRoleActive())
|
||||
player.joinChat(lgRole.getChat(), (sender, message)->{
|
||||
return "§c"+customNames.get(lgRole.getPlayers().indexOf(sender))+" §6» §f"+message;
|
||||
}, true);
|
||||
|
@ -68,7 +68,7 @@ public class RPetiteFille extends Role{
|
|||
}
|
||||
if(e.getPreviousRole() instanceof RLoupGarou)
|
||||
for(LGPlayer player : getPlayers())
|
||||
if(!player.getCache().getBoolean("infected"))
|
||||
if(!player.getCache().getBoolean("infected") && player.isRoleActive())
|
||||
player.leaveChat();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ public class RPirate extends Role{
|
|||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerKilled(LGPlayerKilledEvent e) {
|
||||
if(e.getGame() == getGame() && e.getReason() == Reason.VOTE)
|
||||
if(e.getKilled().getCache().has("pirate_otage")) {
|
||||
if(e.getKilled().getCache().has("pirate_otage") && e.getKilled().isRoleActive()) {
|
||||
LGPlayer otage = e.getKilled().getCache().remove("pirate_otage");
|
||||
if(!otage.isDead() && otage.getCache().get("pirate_otage_d") == e.getKilled()) {
|
||||
getGame().broadcastMessage("§7§l"+e.getKilled().getName()+"§6 est "+getName()+"§6, c'est son otage qui va mourir.");
|
||||
|
|
|
@ -108,13 +108,12 @@ public class RPretre extends Role{
|
|||
|
||||
public void openInventory(Player player) {
|
||||
inMenu = true;
|
||||
Inventory inventory = Bukkit.createInventory(null, 9, "§7Veux-tu réssuciter quelqu'un ?");
|
||||
Inventory inventory = Bukkit.createInventory(null, 9, "§7Veux-tu réssusciter quelqu'un ?");
|
||||
inventory.setContents(items.clone());
|
||||
player.closeInventory();
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
WrappedDataWatcherObject invisible = new WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class));
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||
player.showView();
|
||||
|
@ -183,7 +182,7 @@ public class RPretre extends Role{
|
|||
WrapperPlayServerHeldItemSlot held = new WrapperPlayServerHeldItemSlot();
|
||||
held.setSlot(0);
|
||||
held.sendPacket(player);
|
||||
lgp.sendMessage("§6Choisissez qui réssuciter.");
|
||||
lgp.sendMessage("§6Choisissez qui réssusciter.");
|
||||
lgp.canSelectDead = true;
|
||||
lgp.choose(new LGChooseCallback() {
|
||||
|
||||
|
@ -202,12 +201,12 @@ public class RPretre extends Role{
|
|||
lgp.stopChoosing();
|
||||
lgp.canSelectDead = false;
|
||||
lgp.sendMessage("§6Tu as ramené §7§l"+choosen.getName()+"§6 à la vie.");
|
||||
lgp.sendActionBarMessage("§7§l"+choosen.getName()+"§6 sera réssucité");
|
||||
lgp.sendActionBarMessage("§7§l"+choosen.getName()+"§6 sera réssuscité");
|
||||
|
||||
|
||||
ressucited.add(choosen);
|
||||
getPlayers().remove(lgp);//Pour éviter qu'il puisse sauver plusieurs personnes.
|
||||
choosen.sendMessage("§6Tu vas être réssucité en tant que §a§lVillageois§6.");
|
||||
choosen.sendMessage("§6Tu vas être réssuscité en tant que §a§lVillageois§6.");
|
||||
hidePlayers(lgp);
|
||||
lgp.hideView();
|
||||
callback.run();
|
||||
|
@ -250,7 +249,7 @@ public class RPretre extends Role{
|
|||
villagers = (RVillageois)role;
|
||||
if(villagers == null)
|
||||
getGame().getRoles().add(villagers = new RVillageois(getGame()));
|
||||
villagers.join(lgp, false);//Le joueur réssucité rejoint les villageois.
|
||||
villagers.join(lgp, false);//Le joueur réssuscité rejoint les villageois.
|
||||
lgp.setRole(villagers);
|
||||
lgp.getPlayer().removePotionEffect(PotionEffectType.INVISIBILITY);
|
||||
lgp.getPlayer().getInventory().setHelmet(null);
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package fr.leomelki.loupgarou.roles;
|
||||
|
||||
import fr.leomelki.loupgarou.classes.LGGame;
|
||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||
import fr.leomelki.loupgarou.classes.LGPlayer.LGChooseCallback;
|
||||
|
||||
public class RPronostiqueur extends Role{
|
||||
public RPronostiqueur(LGGame game) {
|
||||
super(game);
|
||||
}
|
||||
@Override
|
||||
public RoleType getType() {
|
||||
return RoleType.VILLAGER;
|
||||
}
|
||||
@Override
|
||||
public RoleWinType getWinType() {
|
||||
return RoleWinType.VILLAGE;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return "§a§lPronostiqueur";
|
||||
}
|
||||
@Override
|
||||
public String getFriendlyName() {
|
||||
return "du "+getName();
|
||||
}
|
||||
@Override
|
||||
public String getShortDescription() {
|
||||
return "Tu gagnes avec le §a§lVillage";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux espionner un joueur et découvrir s'il est gentil ou non. Cependant, dans certaines parties, vos pronostiques ne sont pas exacts...";
|
||||
}
|
||||
@Override
|
||||
public String getTask() {
|
||||
return "Choisis un joueur sur lequel pronostiquer.";
|
||||
}
|
||||
@Override
|
||||
public String getBroadcastedTask() {
|
||||
return "Le "+getName()+"§9 s'apprête à pronostiquer...";
|
||||
}
|
||||
@Override
|
||||
public int getTimeout() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightTurn(LGPlayer player, Runnable callback) {
|
||||
player.showView();
|
||||
|
||||
player.choose(new LGChooseCallback() {
|
||||
@Override
|
||||
public void callback(LGPlayer choosen) {
|
||||
if(choosen != null && choosen != player) {
|
||||
//player.sendTitle("§6Vous avez regardé un rôle", "§e§l"+choosen.getName()+"§6§l est §e§l"+choosen.getRole().getName(), 5*20);
|
||||
String gentilMechant = choosen.getRoleWinType() == RoleWinType.VILLAGE || choosen.getRoleWinType() == RoleWinType.NONE ? "§a§lgentil" : "§c§lméchant";
|
||||
player.sendActionBarMessage("§e§l"+choosen.getName()+"§6 est "+gentilMechant);
|
||||
player.sendMessage("§6Votre instinct vous dit que §7§l"+choosen.getName()+"§6 est "+gentilMechant+"§6.");
|
||||
player.stopChoosing();
|
||||
player.hideView();
|
||||
callback.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
protected void onNightTurnTimeout(LGPlayer player) {
|
||||
player.stopChoosing();
|
||||
player.hideView();
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
|||
import fr.leomelki.loupgarou.events.LGNightPlayerPreKilledEvent;
|
||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||
import fr.leomelki.loupgarou.events.LGPreDayStartEvent;
|
||||
import fr.leomelki.loupgarou.events.LGVampiredEvent;
|
||||
import fr.leomelki.loupgarou.utils.VariableCache;
|
||||
|
||||
public class RSurvivant extends Role{
|
||||
|
@ -146,14 +147,20 @@ public class RSurvivant extends Role{
|
|||
|
||||
@EventHandler
|
||||
public void onPlayerKill(LGNightPlayerPreKilledEvent e) {
|
||||
if(e.getGame() == getGame() && (e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.LOUP_BLANC || e.getReason() == Reason.GM_LOUP_GAROU || e.getReason() == Reason.ASSASSIN) && e.getKilled().getCache().getBoolean("survivant_protected")) {
|
||||
if(e.getGame() == getGame() && (e.getReason() == Reason.LOUP_GAROU || e.getReason() == Reason.LOUP_BLANC || e.getReason() == Reason.GM_LOUP_GAROU || e.getReason() == Reason.ASSASSIN) && e.getKilled().getCache().getBoolean("survivant_protected") && e.getKilled().isRoleActive()) {
|
||||
e.setReason(Reason.DONT_DIE);
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onVampired(LGVampiredEvent e) {
|
||||
if(e.getGame() == getGame() && e.getPlayer().getCache().getBoolean("survivant_protected"))
|
||||
e.setProtect(true);
|
||||
}
|
||||
@EventHandler
|
||||
public void onDayStart(LGPreDayStartEvent e) {
|
||||
if(e.getGame() == getGame())
|
||||
for(LGPlayer lgp : getGame().getInGame())
|
||||
if(lgp.isRoleActive())
|
||||
lgp.getCache().remove("survivant_protected");
|
||||
}
|
||||
|
||||
|
|
229
src/main/java/fr/leomelki/loupgarou/roles/RVampire.java
Normal file
229
src/main/java/fr/leomelki/loupgarou/roles/RVampire.java
Normal file
|
@ -0,0 +1,229 @@
|
|||
package fr.leomelki.loupgarou.roles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import fr.leomelki.com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
|
||||
import fr.leomelki.loupgarou.classes.LGCustomItems;
|
||||
import fr.leomelki.loupgarou.classes.LGCustomSkin;
|
||||
import fr.leomelki.loupgarou.classes.LGGame;
|
||||
import fr.leomelki.loupgarou.classes.LGPlayer;
|
||||
import fr.leomelki.loupgarou.classes.LGVote;
|
||||
import fr.leomelki.loupgarou.classes.LGWinType;
|
||||
import fr.leomelki.loupgarou.classes.LGCustomItems.LGCustomItemsConstraints;
|
||||
import fr.leomelki.loupgarou.classes.chat.LGChat;
|
||||
import fr.leomelki.loupgarou.events.LGCustomItemChangeEvent;
|
||||
import fr.leomelki.loupgarou.events.LGDayEndEvent;
|
||||
import fr.leomelki.loupgarou.events.LGGameEndEvent;
|
||||
import fr.leomelki.loupgarou.events.LGNightEndEvent;
|
||||
import fr.leomelki.loupgarou.events.LGNightStart;
|
||||
import fr.leomelki.loupgarou.events.LGPlayerKilledEvent.Reason;
|
||||
import fr.leomelki.loupgarou.events.LGSkinLoadEvent;
|
||||
import fr.leomelki.loupgarou.events.LGUpdatePrefixEvent;
|
||||
import fr.leomelki.loupgarou.events.LGVampiredEvent;
|
||||
import lombok.Getter;
|
||||
|
||||
public class RVampire extends Role{
|
||||
|
||||
public RVampire(LGGame game) {
|
||||
super(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "§5§lVampire";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFriendlyName() {
|
||||
return "des §5§lVampires";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortDescription() {
|
||||
return "Tu gagnes avec les §5§lVampires";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Tu gagnes avec les §5§lVampires§f. Chaque nuit, tu te réunis avec tes compères pour décider d'une victime à transformer en §5§lVampire§f... Lorsqu'une transformation a lieu, tous les §5§lVampires§f doivent se reposer la nuit suivante. Un joueur transformé perd tous les pouvoirs liés à son ancien rôle, et gagne avec les §5§lVampires§f.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTask() {
|
||||
return "Votez pour une cible à mordre.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBroadcastedTask() {
|
||||
return "Les §5§lVampires§9 choisissent leur cible.";
|
||||
}
|
||||
@Override
|
||||
public RoleType getType() {
|
||||
return RoleType.VAMPIRE;
|
||||
}
|
||||
@Override
|
||||
public RoleWinType getWinType() {
|
||||
return RoleWinType.VAMPIRE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTimeout() {
|
||||
return 30;
|
||||
}
|
||||
@Override
|
||||
public boolean hasPlayersLeft() {
|
||||
return nextCanInfect < getGame().getNight() && super.hasPlayersLeft();
|
||||
}
|
||||
|
||||
@Getter private LGChat chat = new LGChat((sender, message) -> {
|
||||
return "§5"+sender.getName()+" §6» §f"+message;
|
||||
});
|
||||
int nextCanInfect = 0;
|
||||
LGVote vote;
|
||||
@Override
|
||||
public void join(LGPlayer player, boolean sendMessage) {
|
||||
super.join(player, sendMessage);
|
||||
for(LGPlayer p : getPlayers())
|
||||
p.updatePrefix();
|
||||
}
|
||||
|
||||
public void onNightTurn(Runnable callback) {
|
||||
vote = new LGVote(getTimeout(), getTimeout()/3, getGame(), false, false, (player, secondsLeft)-> {
|
||||
return !getPlayers().contains(player) ? "§6C'est au tour "+getFriendlyName()+" §6(§e"+secondsLeft+" s§6)" : player.getCache().has("vote") ? "§l§9Vous votez pour §c§l"+player.getCache().<LGPlayer>get("vote").getName() : "§6Il vous reste §e"+secondsLeft+" seconde"+(secondsLeft > 1 ? "s" : "")+"§6 pour voter";
|
||||
});
|
||||
for(LGPlayer lgp : getGame().getAlive())
|
||||
if(lgp.getRoleType() == RoleType.VAMPIRE)
|
||||
lgp.showView();
|
||||
for(LGPlayer player : getPlayers()) {
|
||||
player.sendMessage("§6"+getTask());
|
||||
// player.sendTitle("§6C'est à vous de jouer", "§a"+getTask(), 100);
|
||||
player.joinChat(chat);
|
||||
}
|
||||
vote.start(getPlayers(), getPlayers(), ()->{
|
||||
onNightTurnEnd();
|
||||
callback.run();
|
||||
}, getPlayers());
|
||||
}
|
||||
private void onNightTurnEnd() {
|
||||
for(LGPlayer lgp : getGame().getAlive())
|
||||
if(lgp.getRoleType() == RoleType.VAMPIRE)
|
||||
lgp.hideView();
|
||||
for(LGPlayer player : getPlayers())
|
||||
player.leaveChat();
|
||||
|
||||
LGPlayer choosen = vote.getChoosen();
|
||||
if(choosen == null) {
|
||||
if(vote.getVotes().size() > 0) {
|
||||
int max = 0;
|
||||
boolean equal = false;
|
||||
for(Entry<LGPlayer, List<LGPlayer>> entry : vote.getVotes().entrySet())
|
||||
if(entry.getValue().size() > max) {
|
||||
equal = false;
|
||||
max = entry.getValue().size();
|
||||
choosen = entry.getKey();
|
||||
}else if(entry.getValue().size() == max)
|
||||
equal = true;
|
||||
if(equal) {
|
||||
choosen = null;
|
||||
ArrayList<LGPlayer> choosable = new ArrayList<LGPlayer>();
|
||||
for(Entry<LGPlayer, List<LGPlayer>> entry : vote.getVotes().entrySet())
|
||||
if(entry.getValue().size() == max && entry.getKey().getRoleType() != RoleType.VAMPIRE)
|
||||
choosable.add(entry.getKey());
|
||||
if(choosable.size() > 0)
|
||||
choosen = choosable.get(getGame().getRandom().nextInt(choosable.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(choosen != null) {
|
||||
if(choosen.getRoleType() == RoleType.LOUP_GAROU || choosen.getRoleType() == RoleType.VAMPIRE) {
|
||||
for(LGPlayer player : getPlayers())
|
||||
player.sendMessage("§cVotre cible est immunisée.");
|
||||
return;
|
||||
}else if(choosen.getRole() instanceof RChasseurDeVampire) {
|
||||
for(LGPlayer player : getPlayers())
|
||||
player.sendMessage("§cVotre cible est immunisée.");
|
||||
getGame().kill(getPlayers().get(getPlayers().size()-1), Reason.CHASSEUR_DE_VAMPIRE);
|
||||
return;
|
||||
}
|
||||
|
||||
LGVampiredEvent event = new LGVampiredEvent(getGame(), choosen);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if(event.isImmuned()) {
|
||||
for(LGPlayer player : getPlayers())
|
||||
player.sendMessage("§cVotre cible est immunisée.");
|
||||
return;
|
||||
}else if(event.isProtect()) {
|
||||
for(LGPlayer player : getPlayers())
|
||||
player.sendMessage("§cVotre cible est protégée.");
|
||||
return;
|
||||
}
|
||||
for(LGPlayer player : getPlayers())
|
||||
player.sendMessage("§7§l"+choosen.getName()+" s'est transformé en §5§lVampire§6.");
|
||||
choosen.sendMessage("§6Tu as été infecté par les §5§lVampires §6pendant la nuit. Tu as perdu tes pouvoirs.");
|
||||
choosen.sendMessage("§6§oTu gagnes désormais avec les §5§l§oVampires§6§o.");
|
||||
choosen.getCache().set("vampire", true);
|
||||
choosen.getCache().set("just_vampire", true);
|
||||
nextCanInfect = getGame().getNight()+1;
|
||||
join(choosen, false);
|
||||
LGCustomItems.updateItem(choosen);
|
||||
}else
|
||||
for(LGPlayer player : getPlayers())
|
||||
player.sendMessage("§6Personne n'a été infecté.");
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onDayStart(LGNightEndEvent e) {
|
||||
if(e.getGame() == getGame())
|
||||
for(LGPlayer player : getGame().getAlive()) {
|
||||
if(player.getCache().getBoolean("just_vampire")) {
|
||||
player.getCache().remove("just_vampire");
|
||||
for(LGPlayer lgp : getGame().getInGame()) {
|
||||
if(lgp.getRoleType() == RoleType.VAMPIRE)
|
||||
lgp.sendMessage("§7§l"+player.getName()+"§6 s'est transformé en §5§lVampire§6...");
|
||||
else
|
||||
lgp.sendMessage("§6Quelqu'un s'est transformé en §5§lVampire§6...");
|
||||
}
|
||||
|
||||
if(getGame().checkEndGame())
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* @EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onSkinChange(LGSkinLoadEvent e) {
|
||||
if(e.getGame() == getGame())
|
||||
if(getPlayers().contains(e.getPlayer()) && getPlayers().contains(e.getTo()) && showSkins) {
|
||||
e.getProfile().getProperties().removeAll("textures");
|
||||
e.getProfile().getProperties().put("textures", LGCustomSkin.WEREWOLF.getProperty());
|
||||
}
|
||||
}*/
|
||||
@EventHandler
|
||||
public void onGameEnd(LGGameEndEvent e) {
|
||||
if(e.getGame() == getGame() && e.getWinType() == LGWinType.VAMPIRE)
|
||||
for(LGPlayer lgp : getGame().getInGame())
|
||||
if(lgp.getRoleWinType() == RoleWinType.VAMPIRE)//Changed to wintype
|
||||
e.getWinners().add(lgp);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onUpdatePrefix (LGUpdatePrefixEvent e) {
|
||||
if(e.getGame() == getGame())
|
||||
if(getPlayers().contains(e.getTo()) && getPlayers().contains(e.getPlayer()))
|
||||
e.setPrefix(e.getPrefix()+"§5");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCustomItemChange(LGCustomItemChangeEvent e) {
|
||||
if(e.getGame() == getGame())
|
||||
if(e.getPlayer().getCache().getBoolean("vampire"))
|
||||
e.getConstraints().add(LGCustomItemsConstraints.VAMPIRE_INFECTE.getName());
|
||||
}
|
||||
|
||||
}
|
|
@ -28,6 +28,7 @@ public class RVoyante extends Role{
|
|||
public String getShortDescription() {
|
||||
return "Tu gagnes avec le §a§lVillage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Tu gagnes avec le §a§lVillage§f. Chaque nuit, tu peux espionner un joueur et découvrir sa véritable identité...";
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package fr.leomelki.loupgarou.roles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import fr.leomelki.loupgarou.MainLg;
|
||||
import fr.leomelki.loupgarou.classes.LGCustomItems;
|
||||
|
@ -59,6 +61,7 @@ public abstract class Role implements Listener{
|
|||
return;
|
||||
}
|
||||
LGPlayer player = players.remove(0);
|
||||
if(player.isRoleActive()) {
|
||||
getGame().wait(getTimeout(), ()->{
|
||||
try {
|
||||
Role.this.onNightTurnTimeout(player);
|
||||
|
@ -73,6 +76,19 @@ public abstract class Role implements Listener{
|
|||
player.sendMessage("§6"+getTask());
|
||||
// player.sendTitle("§6C'est à vous de jouer", "§a"+getTask(), 100);
|
||||
onNightTurn(player, this);
|
||||
} else {
|
||||
getGame().wait(getTimeout(), ()->{}, (currentPlayer, secondsLeft)->{
|
||||
return currentPlayer == player ? "§c§lTu ne peux pas jouer" : "§6C'est au tour "+getFriendlyName()+" §6(§e"+secondsLeft+" s§6)";
|
||||
});
|
||||
Runnable run = this;
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
run.run();
|
||||
}
|
||||
}.runTaskLater(MainLg.getInstance(), 20*(ThreadLocalRandom.current().nextInt(getTimeout()/3*2-4)+4));
|
||||
}
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ public enum RoleSort {
|
|||
LoupGarouBlanc,
|
||||
Assassin,
|
||||
Pyromane,
|
||||
ChasseurDeVampire,
|
||||
Vampire,
|
||||
Pirate,
|
||||
Bouffon,
|
||||
Sorciere,
|
||||
|
|
|
@ -3,5 +3,6 @@ package fr.leomelki.loupgarou.roles;
|
|||
public enum RoleType {
|
||||
VILLAGER,
|
||||
LOUP_GAROU,
|
||||
VAMPIRE,
|
||||
NEUTRAL;
|
||||
}
|
||||
|
|
|
@ -4,5 +4,6 @@ public enum RoleWinType {
|
|||
SEUL,
|
||||
VILLAGE,
|
||||
LOUP_GAROU,
|
||||
VAMPIRE,
|
||||
NONE;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: LoupGarou
|
||||
version: 1.0.1
|
||||
version: 1.1.0
|
||||
description: Permet de jouer au jeu du loup garou
|
||||
main: fr.leomelki.loupgarou.MainLg
|
||||
depend: [ProtocolLib]
|
||||
|
|
Loading…
Reference in a new issue