mirror of
https://github.com/ArthurDanjou/WitchRush.git
synced 2026-01-14 12:14:39 +01:00
Kits added
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package net.berrygames.witchrush;
|
||||
|
||||
import net.berrygames.witchrush.game.GameState;
|
||||
import net.berrygames.witchrush.kits.Kits;
|
||||
import net.berrygames.witchrush.team.TeamManager;
|
||||
import net.berrygames.witchrush.tools.ItemFactory;
|
||||
import org.bukkit.Color;
|
||||
@@ -37,13 +38,14 @@ public class WitchPlayer {
|
||||
|
||||
public void giveStuff(){
|
||||
player.getInventory().clear();
|
||||
final ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
|
||||
final Color color = manager.getPlayerTeam(player).getColor();
|
||||
player.getInventory().setHelmet(getHelmetColor(Material.LEATHER_HELMET, color));
|
||||
player.getInventory().setChestplate(getHelmetColor(Material.LEATHER_CHESTPLATE, color));
|
||||
player.getInventory().setLeggings(getHelmetColor(Material.LEATHER_LEGGINGS, color));
|
||||
player.getInventory().setBoots(getHelmetColor(Material.LEATHER_BOOTS, color));
|
||||
player.getInventory().setItem(0, sword);
|
||||
for(ItemStack items : Kits.getGoblinIKit()){
|
||||
player.getInventory().addItem(items);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendLobby(){
|
||||
|
||||
@@ -38,7 +38,6 @@ public class GameManager {
|
||||
new PNJSpawner("§6§lSHOP", infos, new TeamManager().getShopLocation(infos));
|
||||
new PNJSpawner("§b§LUPGRADE", infos, new TeamManager().getUpgradeLocation(infos));
|
||||
}
|
||||
new PVPTask().runTaskTimer(WitchRush.get(), 0, 20);
|
||||
Bukkit.getScheduler().runTaskLater(WitchRush.get(), ()->{
|
||||
Bukkit.broadcastMessage(WitchRush.prefix()+"Les §6Witchs §dsont apparues, §d§nBonne chance à vous !");
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class WinManager {
|
||||
}
|
||||
if (teamLeft == 1) {
|
||||
for (final TeamsInfos teamInfos : TeamsInfos.values()) {
|
||||
if (!teamManager.getPlayerTeamList(teamInfos).isEmpty()) {
|
||||
if (!teamManager.getPlayersTeamList(teamInfos).isEmpty()) {
|
||||
GameState.setStatus(GameState.END);
|
||||
Bukkit.broadcastMessage(WitchRush.prefix()+"Victoire de l'équipe "+teamInfos.getChatColor()+teamInfos.getTeamName());
|
||||
this.endGame();
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package net.berrygames.witchrush.kits;
|
||||
|
||||
import net.berrygames.witchrush.tools.ItemFactory;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public enum Kits {
|
||||
|
||||
ElfI("§eElf I", getElfIKit()),
|
||||
ElfII("§eElf II", getElfIIKit()),
|
||||
ElfIII("§eElf III", getElfIIIKit()),
|
||||
|
||||
GoblinI("§aGoblin I", getGoblinIKit()),
|
||||
GoblinII("§aGoblin I", getGoblinIIKit()),
|
||||
GoblinIII("§aGoblin I", getGoblinIIIKit()),
|
||||
;
|
||||
|
||||
private String kitName;
|
||||
private ArrayList<ItemStack> items;
|
||||
|
||||
Kits(String kitName, ArrayList<ItemStack> items) {
|
||||
this.kitName = kitName;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getItems() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
public static ArrayList<ItemStack> getElfIKit(){
|
||||
ArrayList<ItemStack> list = new ArrayList<>();
|
||||
|
||||
list.add(new ItemFactory(Material.WOOD_SWORD).withName("§bSword Level I").done());
|
||||
list.add(new ItemFactory(Material.SANDSTONE, 64).done());
|
||||
|
||||
return list;
|
||||
}
|
||||
public static ArrayList<ItemStack> getElfIIKit(){
|
||||
ArrayList<ItemStack> list = new ArrayList<>();
|
||||
|
||||
list.add(new ItemFactory(Material.STONE_SWORD).withName("§bSword Level II").done());
|
||||
list.add(new ItemFactory(Material.SANDSTONE, 64).done());
|
||||
|
||||
return list;
|
||||
}
|
||||
public static ArrayList<ItemStack> getElfIIIKit(){
|
||||
ArrayList<ItemStack> list = new ArrayList<>();
|
||||
|
||||
list.add(new ItemFactory(Material.IRON_SWORD).withName("§bSword Level III").done());
|
||||
list.add(new ItemFactory(Material.SANDSTONE, 64).done());
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static ArrayList<ItemStack> getGoblinIKit(){
|
||||
ArrayList<ItemStack> list = new ArrayList<>();
|
||||
|
||||
list.add(new ItemFactory(Material.BOW).withName("§bArc Level I").done());
|
||||
list.add(new ItemFactory(Material.ARROW, 64).done());
|
||||
list.add(new ItemFactory(Material.SANDSTONE, 64).done());
|
||||
|
||||
return list;
|
||||
}
|
||||
public static ArrayList<ItemStack> getGoblinIIKit(){
|
||||
ArrayList<ItemStack> list = new ArrayList<>();
|
||||
|
||||
list.add(new ItemFactory(Material.BOW).withName("§bArc Level II").withEnchant(Enchantment.ARROW_DAMAGE, 1).done());
|
||||
list.add(new ItemFactory(Material.ARROW, 64).done());
|
||||
list.add(new ItemFactory(Material.SANDSTONE, 64).done());
|
||||
|
||||
return list;
|
||||
}
|
||||
public static ArrayList<ItemStack> getGoblinIIIKit(){
|
||||
ArrayList<ItemStack> list = new ArrayList<>();
|
||||
|
||||
list.add(new ItemFactory(Material.BOW).withName("§bArc Level III").withEnchant(Enchantment.ARROW_DAMAGE, 2).done());
|
||||
list.add(new ItemFactory(Material.ARROW, 64).done());
|
||||
list.add(new ItemFactory(Material.SANDSTONE, 64).done());
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import net.berrygames.witchrush.WitchRush;
|
||||
import net.berrygames.witchrush.game.GameState;
|
||||
import net.berrygames.witchrush.team.TeamsInfos;
|
||||
import net.berrygames.witchrush.team.TeamManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -19,29 +20,36 @@ public class InventoryClick implements Listener {
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
ItemStack item = e.getCurrentItem();
|
||||
Inventory inv = e.getClickedInventory();
|
||||
TeamManager teamManager = WitchRush.get().getTeamManager();
|
||||
final TeamManager teamManager = WitchRush.get().getTeamManager();
|
||||
if(!GameState.getStatus().equals(GameState.LOBBY)) return;
|
||||
if(inv.getTitle().equals(WitchRush.prefix()+"Teams")){
|
||||
e.setCancelled(true);
|
||||
switch (item.getType()){
|
||||
case WOOL:
|
||||
final TeamsInfos teamInfos = TeamsInfos.getTeamInfosByShortData(e.getCurrentItem().getDurability());
|
||||
if (teamManager.isPlayerInTeam(player, teamInfos)) {
|
||||
if(teamManager.isPlayerInTeam(player, teamInfos)) {
|
||||
player.sendMessage("§dVous êtes déjà dans cette team !");
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1.0f, 1.0f);
|
||||
player.closeInventory();
|
||||
return;
|
||||
}
|
||||
if (teamManager.teamIsFull(teamInfos)) {
|
||||
if(teamManager.teamIsFull(teamInfos)) {
|
||||
player.sendMessage("§dL'équipe est pleine !");
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1.0f, 1.0f);
|
||||
player.closeInventory();
|
||||
return;
|
||||
}
|
||||
teamManager.removePlayerAllTeam(player);
|
||||
if(Bukkit.getOnlinePlayers().size() <= 4 && teamManager.getPlayersTeamList(teamInfos).size() == 1){
|
||||
player.sendMessage("§dCela risquerais de déséquilibrer les équipes !");
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1.0f, 1.0f);
|
||||
player.closeInventory();
|
||||
return;
|
||||
}
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_YES, 1.0f, 1.0f);
|
||||
teamManager.addPlayerTeam(player, teamInfos);
|
||||
TeamsInfos infos1 = teamManager.getPlayerTeam(player);
|
||||
player.sendMessage("§dVous avez rejoint la team "+infos1.getChatColor()+infos1.getTeamName());
|
||||
player.sendMessage("§dVous avez rejoint la team "+
|
||||
teamManager.getPlayerTeam(player).getChatColor()+
|
||||
teamManager.getPlayerTeam(player).getTeamName());
|
||||
player.closeInventory();
|
||||
break;
|
||||
case BARRIER:
|
||||
@@ -50,7 +58,7 @@ public class InventoryClick implements Listener {
|
||||
case DOUBLE_PLANT:
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_YES, 1.0f, 1.0f);
|
||||
teamManager.removePlayerAllTeam(player);
|
||||
player.sendMessage("&dVous serez dans une équipe au debut de la partie !");
|
||||
player.sendMessage("§dVous serez dans une équipe au debut de la partie !");
|
||||
player.closeInventory();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class PlayerChat implements Listener {
|
||||
Bukkit.getOnlinePlayers().forEach(playerOnline -> {
|
||||
final TeamsInfos teamInfos = WitchRush.get().getTeamManager().getPlayerTeam(player);
|
||||
if(WitchRush.get().getTeamManager().getPlayerTeam(playerOnline).equals(teamInfos)){
|
||||
playerOnline.sendMessage("§7["+teamInfos.getChatColor()+teamInfos.getIDName()+"§7] "
|
||||
playerOnline.sendMessage("§7["+teamInfos.getChatColor()+teamInfos.getTeamName()+"§7] "
|
||||
+WitchRush.get().getTeamManager().getPlayerTeam(playerOnline).getChatColor()
|
||||
+player.getDisplayName()+" §7» §f"+message.replace("!","§r"));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.berrygames.witchrush.listeners.players;
|
||||
import net.berrygames.witchrush.WitchPlayer;
|
||||
import net.berrygames.witchrush.WitchRush;
|
||||
import net.berrygames.witchrush.game.GameState;
|
||||
import net.berrygames.witchrush.kits.Kits;
|
||||
import net.berrygames.witchrush.team.TeamsInfos;
|
||||
import net.berrygames.witchrush.team.TeamManager;
|
||||
import net.berrygames.witchrush.tools.DeadPlayer;
|
||||
@@ -79,22 +80,8 @@ public class PlayerDeath implements Listener {
|
||||
|
||||
private void checkDrop(PlayerDeathEvent e){
|
||||
for(final ItemStack itemStack : e.getDrops()){
|
||||
switch (itemStack.getType()){
|
||||
case LEATHER_BOOTS:
|
||||
itemStack.setType(Material.AIR);
|
||||
break;
|
||||
case LEATHER_LEGGINGS:
|
||||
itemStack.setType(Material.AIR);
|
||||
break;
|
||||
case LEATHER_CHESTPLATE:
|
||||
itemStack.setType(Material.AIR);
|
||||
break;
|
||||
case LEATHER_HELMET:
|
||||
itemStack.setType(Material.AIR);
|
||||
break;
|
||||
case DIAMOND_SWORD:
|
||||
itemStack.setType(Material.AIR);
|
||||
break;
|
||||
for(Kits kits : Kits.values()){
|
||||
if(itemStack.getType().equals(kits.getItems())) itemStack.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,16 +22,15 @@ public class PlayerQuit implements Listener {
|
||||
|
||||
switch (GameState.getStatus()){
|
||||
case LOBBY:
|
||||
e.setQuitMessage(null);
|
||||
break;
|
||||
case GAME:
|
||||
if(witchPlayer.isSpectator()) return;
|
||||
e.setQuitMessage(
|
||||
WitchRush.prefix()+"§e"+player.getName()+
|
||||
" §da quitté la partie §7(§d"+
|
||||
WitchPlayer.getwitchMap().size()+
|
||||
"§8/§d16§7)");
|
||||
break;
|
||||
case GAME:
|
||||
e.setQuitMessage(null);
|
||||
break;
|
||||
case END:
|
||||
e.setQuitMessage(null);
|
||||
break;
|
||||
|
||||
@@ -19,43 +19,38 @@ public class TeamManager {
|
||||
}
|
||||
|
||||
public void addPlayerTeam(final Player player, final TeamsInfos teamInfos) {
|
||||
if (this.playerTeamList.get(teamInfos) == null) {
|
||||
if(this.playerTeamList.get(teamInfos) == null) {
|
||||
this.playerTeamList.put(teamInfos, new ArrayList<>());
|
||||
}
|
||||
if (!this.teamIsFull(teamInfos)) {
|
||||
this.removePlayerAllTeam(player);
|
||||
this.playerTeamList.get(teamInfos).add(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayerAllTeam(final Player player){
|
||||
for (final TeamsInfos teamInfos : TeamsInfos.values()) {
|
||||
for(final TeamsInfos teamInfos : TeamsInfos.values()) {
|
||||
if (this.playerTeamList.get(teamInfos) != null && this.playerTeamList.get(teamInfos).contains(player)) {
|
||||
this.playerTeamList.get(teamInfos).remove(player);
|
||||
removePlayerTeam(player, teamInfos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayerTeam(final Player player, final TeamsInfos teamInfos) {
|
||||
if (this.playerTeamList.get(teamInfos) != null && this.playerTeamList.get(teamInfos).contains(player)) {
|
||||
if(this.playerTeamList.get(teamInfos) != null && this.playerTeamList.get(teamInfos).contains(player)) {
|
||||
this.playerTeamList.get(teamInfos).remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayerInRandomTeam(final Player player) {
|
||||
if(playerHaveTeam(player)) return;
|
||||
TreeMap<TeamsInfos, List<Player>> teamMap = new TreeMap<>();
|
||||
for(TeamsInfos infos : TeamsInfos.values()){
|
||||
for(Player pls: Bukkit.getOnlinePlayers()){
|
||||
if(!isPlayerInTeam(pls , infos)) teamMap.put(infos, getPlayerTeamList(infos));
|
||||
teamMap.put(infos, getPlayersTeamList(infos));
|
||||
}
|
||||
}
|
||||
if(!playerHaveTeam(player)){
|
||||
addPlayerTeam(player, teamMap.firstKey());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInLife(final TeamsInfos teamInfos) {
|
||||
return getBossEntityMap().containsKey(teamInfos);
|
||||
return getBossEntityMap().containsValue(teamInfos);
|
||||
}
|
||||
|
||||
public Location getBossLocation(final TeamsInfos teamInfos) {
|
||||
@@ -122,7 +117,7 @@ public class TeamManager {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public List<Player> getPlayerTeamList(final TeamsInfos teamInfos) {
|
||||
public List<Player> getPlayersTeamList(final TeamsInfos teamInfos) {
|
||||
if (this.playerTeamList.get(teamInfos) != null) {
|
||||
return this.playerTeamList.get(teamInfos);
|
||||
}
|
||||
@@ -134,7 +129,7 @@ public class TeamManager {
|
||||
}
|
||||
|
||||
public WitchBoss getTeamBoss(final TeamsInfos teamInfos) {
|
||||
return this.bossEntityMap.get(teamInfos);
|
||||
return this.getBossEntityMap().get(teamInfos);
|
||||
}
|
||||
|
||||
public Map<TeamsInfos, WitchBoss> getBossEntityMap() {
|
||||
|
||||
@@ -1,38 +1,34 @@
|
||||
package net.berrygames.witchrush.team;
|
||||
|
||||
import net.berrygames.witchrush.tools.PNJSpawner;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
|
||||
public enum TeamsInfos {
|
||||
|
||||
VERT(0,"Vert", "vert", "§a", (short)13, Color.GREEN, 23),
|
||||
BLEU(1,"Bleu", "bleu", "§b", (short)11, Color.BLUE, 19),
|
||||
JAUNE(2,"Jaune", "jaune", "§e", (short)4, Color.YELLOW, 21),
|
||||
ROUGE(3,"Rouge", "rouge", "§c", (short)14, Color.RED, 25),
|
||||
VERT(0,"Vert", "§a", DyeColor.LIME, (short)5, Color.GREEN, 23),
|
||||
BLEU(1,"Bleu", "§b", DyeColor.LIGHT_BLUE, (short)3, Color.BLUE, 19),
|
||||
JAUNE(2,"Jaune", "§e", DyeColor.YELLOW, (short)4, Color.YELLOW, 21),
|
||||
ROUGE(3,"Rouge", "§c", DyeColor.RED, (short)14, Color.RED, 25),
|
||||
;
|
||||
|
||||
private int id;
|
||||
private String IDName;
|
||||
private String teamName;
|
||||
private String chatColor;
|
||||
private short dataClay;
|
||||
private Color color;
|
||||
private DyeColor dyeColor;
|
||||
private int slotGUI;
|
||||
|
||||
TeamsInfos(int id, String IDName, String teamName, String chatColor, short dataClay, Color color, int slotGUI) {
|
||||
TeamsInfos(int id, String teamName, String chatColor, DyeColor dyeColor, short dataClay, Color color, int slotGUI) {
|
||||
this.id = id;
|
||||
this.IDName = IDName;
|
||||
this.teamName = teamName;
|
||||
this.chatColor = chatColor;
|
||||
this.dyeColor = dyeColor;
|
||||
this.dataClay = dataClay;
|
||||
this.color = color;
|
||||
this.slotGUI = slotGUI;
|
||||
}
|
||||
|
||||
public String getIDName() {
|
||||
return IDName;
|
||||
}
|
||||
|
||||
public String getTeamName() {
|
||||
return teamName;
|
||||
}
|
||||
@@ -41,6 +37,10 @@ public enum TeamsInfos {
|
||||
return chatColor;
|
||||
}
|
||||
|
||||
public DyeColor getDyeColor() {
|
||||
return dyeColor;
|
||||
}
|
||||
|
||||
public short getDataClay() {
|
||||
return dataClay;
|
||||
}
|
||||
@@ -57,9 +57,9 @@ public enum TeamsInfos {
|
||||
return slotGUI;
|
||||
}
|
||||
|
||||
public static TeamsInfos getTeamInfosByIDName(final String ID) {
|
||||
public static TeamsInfos getTeamInfosByName(final String name) {
|
||||
for (final TeamsInfos teamInfos : values()) {
|
||||
if (teamInfos.getIDName().equalsIgnoreCase(ID)) {
|
||||
if (teamInfos.getTeamName().toLowerCase().equalsIgnoreCase(name.toLowerCase())) {
|
||||
return teamInfos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TeamsMenu {
|
||||
for(TeamsInfos infos : TeamsInfos.values()){
|
||||
inventory.setItem(infos.getSlotGUI(), new ItemFactory(Material.WOOL)
|
||||
.withName(infos.getChatColor()+infos.getTeamName())
|
||||
.withColor(infos.getColor())
|
||||
.withColor(infos.getDyeColor())
|
||||
.done());
|
||||
}
|
||||
|
||||
|
||||
@@ -49,11 +49,6 @@ public class ItemFactory {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemFactory withColor(final Color color) {
|
||||
this.item.setDurability((short) DyeColor.getByColor(color).getWoolData());
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemFactory withOwner(final String owner) {
|
||||
if (this.item.getType().equals((Object)Material.SKULL_ITEM)) {
|
||||
this.item.setDurability((short)3);
|
||||
|
||||
@@ -22,7 +22,7 @@ public class WitchBoss {
|
||||
this.manager = WitchRush.get().getTeamManager();
|
||||
manager.getBossEntityMap().put(teamInfos, this);
|
||||
this.witch = (Witch) Bukkit.getWorld("world").spawnEntity(location, EntityType.WITCH);
|
||||
this.life = 500;
|
||||
this.life = WitchRush.get().getConfig().getInt("game.bossLife");
|
||||
this.witch.setMaxHealth(this.life);
|
||||
this.witch.setHealth(this.life);
|
||||
this.witch.setCustomNameVisible(false);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#test
|
||||
|
||||
teams:
|
||||
|
||||
bleu:
|
||||
x:
|
||||
y:
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
game:
|
||||
mode: "4x4"
|
||||
bossLife: 500
|
||||
Reference in New Issue
Block a user