maps : observerEntityMap.rowMap().values()) {
+ maps.remove(entityID);
+ }
+ }
+
+ /**
+ * Invoked when a player logs out.
+ * @param player - the player that jused logged out.
+ */
+ protected void removePlayer(Player player) {
+ // Cleanup
+ observerEntityMap.rowMap().remove(player.getEntityId());
+ }
+
+ /**
+ * Construct the Bukkit event listener.
+ * @return Our listener.
+ */
+ private Listener constructBukkit() {
+ return new Listener() {
+ @EventHandler
+ public void onEntityDeath(EntityDeathEvent e) {
+ removeEntity(e.getEntity(), true);
+ }
+
+ @EventHandler
+ public void onChunkUnload(ChunkUnloadEvent e) {
+ for (Entity entity : e.getChunk().getEntities()) {
+ removeEntity(entity, false);
+ }
+ }
+
+ @EventHandler
+ public void onPlayerQuit(PlayerQuitEvent e) {
+ removePlayer(e.getPlayer());
+ }
+ };
+ }
+
+ /**
+ * Construct the packet listener that will be used to intercept every entity-related packet.
+ * @param plugin - the parent plugin.
+ * @return The packet listener.
+ */
+ private PacketAdapter constructProtocol(Plugin plugin) {
+ return new PacketAdapter(plugin, ENTITY_PACKETS) {
+ @Override
+ public void onPacketSending(PacketEvent event) {
+ int entityID = event.getPacket().getIntegers().read(0);
+
+ // See if this packet should be cancelled
+ if (!isVisible(event.getPlayer(), entityID)) {
+ event.setCancelled(true);
+ }
+ }
+ };
+ }
+
+ /**
+ * Toggle the visibility status of an entity for a player.
+ *
+ * If the entity is visible, it will be hidden. If it is hidden, it will become visible.
+ * @param observer - the player observer.
+ * @param entity - the entity to toggle.
+ * @return TRUE if the entity was visible before, FALSE otherwise.
+ */
+ public final boolean toggleEntity(Player observer, Entity entity) {
+ if (isVisible(observer, entity.getEntityId())) {
+ return hideEntity(observer, entity);
+ } else {
+ return !showEntity(observer, entity);
+ }
+ }
+
+ /**
+ * Allow the observer to see an entity that was previously hidden.
+ * @param observer - the observer.
+ * @param entity - the entity to show.
+ * @return TRUE if the entity was hidden before, FALSE otherwise.
+ */
+ public final boolean showEntity(Player observer, Entity entity) {
+ validate(observer, entity);
+ boolean hiddenBefore = !setVisibility(observer, entity.getEntityId(), true);
+
+ // Resend packets
+ if (manager != null && hiddenBefore) {
+ manager.updateEntity(entity, Arrays.asList(observer));
+ }
+ return hiddenBefore;
+ }
+
+ /**
+ * Prevent the observer from seeing a given entity.
+ * @param observer - the player observer.
+ * @param entity - the entity to hide.
+ * @return TRUE if the entity was previously visible, FALSE otherwise.
+ */
+ public final boolean hideEntity(Player observer, Entity entity) {
+ validate(observer, entity);
+ boolean visibleBefore = setVisibility(observer, entity.getEntityId(), false);
+
+ if (visibleBefore) {
+ PacketContainer destroyEntity = new PacketContainer(ENTITY_DESTROY);
+ destroyEntity.getIntegerArrays().write(0, new int[] { entity.getEntityId() });
+
+ // Make the entity disappear
+ try {
+ manager.sendServerPacket(observer, destroyEntity);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException("Cannot send server packet.", e);
+ }
+ }
+ return visibleBefore;
+ }
+
+ /**
+ * Determine if the given entity has been hidden from an observer.
+ *
+ * Note that the entity may very well be occluded or out of range from the perspective
+ * of the observer. This method simply checks if an entity has been completely hidden
+ * for that observer.
+ * @param observer - the observer.
+ * @param entity - the entity that may be hidden.
+ * @return TRUE if the player may see the entity, FALSE if the entity has been hidden.
+ */
+ public final boolean canSee(Player observer, Entity entity) {
+ validate(observer, entity);
+
+ return isVisible(observer, entity.getEntityId());
+ }
+
+ // For valdiating the input parameters
+ private void validate(Player observer, Entity entity) {
+ Preconditions.checkNotNull(observer, "observer cannot be NULL.");
+ Preconditions.checkNotNull(entity, "entity cannot be NULL.");
+ }
+
+ /**
+ * Retrieve the current visibility policy.
+ * @return The current visibility policy.
+ */
+ public Policy getPolicy() {
+ return policy;
+ }
+
+ public void close() {
+ if (manager != null) {
+ HandlerList.unregisterAll(bukkitListener);
+ manager.removePacketListener(protocolListener);
+ manager = null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/me/iran/iranpvp/IranPvP.java b/src/me/iran/iranpvp/IranPvP.java
new file mode 100644
index 0000000..dd61bcd
--- /dev/null
+++ b/src/me/iran/iranpvp/IranPvP.java
@@ -0,0 +1,335 @@
+package me.iran.iranpvp;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.cmd.arena.ArenaCommands;
+import me.iran.iranpvp.cmd.pvp.EloCommands;
+import me.iran.iranpvp.cmd.pvp.PvPCommands;
+import me.iran.iranpvp.cmd.pvp.specevent.SpectatorEvents;
+import me.iran.iranpvp.cmd.team.TeamCommands;
+import me.iran.iranpvp.duel.DuelManager;
+import me.iran.iranpvp.duel.team.TeamDuelManager;
+import me.iran.iranpvp.events.duel.ClickDuelInventoryEvent;
+import me.iran.iranpvp.events.duel.DeathInventory;
+import me.iran.iranpvp.events.duel.PlayerBreakBlockEvent;
+import me.iran.iranpvp.events.duel.PlayerDeathWhileInPvP;
+import me.iran.iranpvp.events.duel.PlayerDisconnectWhileInPvP;
+import me.iran.iranpvp.events.duel.ProtocolEvents;
+import me.iran.iranpvp.events.duel.RespawnEvent;
+import me.iran.iranpvp.events.duel.TeamClickInventoryEvent;
+import me.iran.iranpvp.events.inhanditems.AddItemsOnJoin;
+import me.iran.iranpvp.events.inhanditems.DropItemsInHandEvent;
+import me.iran.iranpvp.events.inhanditems.InteractWithItemsInHand;
+import me.iran.iranpvp.events.teamfight.DisconnectWhileInTeam;
+import me.iran.iranpvp.events.teamfight.KothDeathEvent;
+import me.iran.iranpvp.events.teamfight.TeamDamageTeam;
+import me.iran.iranpvp.events.teamfight.TeamFightEvent;
+import me.iran.iranpvp.ffa.FFACommand;
+import me.iran.iranpvp.ffa.FFAEvent;
+import me.iran.iranpvp.ffa.FFARunnable;
+import me.iran.iranpvp.kit.KitEvents;
+import me.iran.iranpvp.kit.KitManager;
+import me.iran.iranpvp.kit.bard.Bard;
+import me.iran.iranpvp.kit.bard.BardEvent;
+import me.iran.iranpvp.runnable.Run;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamChat;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.type.GameTypeCommands;
+import me.iran.iranpvp.type.GameTypeManager;
+import me.iran.iranpvp.type.RankedEvent;
+import me.iran.iranpvp.utils.EnderpearlCooldown;
+import me.iran.iranpvp.utils.Queue;
+import me.iran.iranpvp.utils.TeleportSpawn;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Listener;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import com.comphenix.example.EntityHider;
+import com.comphenix.example.EntityHider.Policy;
+
+public class IranPvP extends JavaPlugin implements Listener {
+
+ File file = null;
+
+ public static Plugin plugin;
+
+ private Run run = new Run(this);
+
+ private TeleportSpawn spawn = new TeleportSpawn();
+ private KitManager km = new KitManager();
+ private Bard bard = new Bard();
+ private FFARunnable ffaRun = new FFARunnable(this);
+
+ private Queue queue = new Queue();
+
+ private RankedEvent rank = new RankedEvent(this);
+
+ private static ArrayList toggle = new ArrayList();
+
+ @SuppressWarnings("deprecation")
+ public void onEnable() {
+
+ IranPvP.plugin = this;
+
+ ArenaManager.getManager().loadArena();
+ GameTypeManager.getManager().loadGameTypes();
+
+ file = new File(this.getDataFolder(), "gametype.yml");
+
+ if(!file.exists()) {
+ file = new File(this.getDataFolder(), "gametype.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration gConfig = YamlConfiguration.loadConfiguration(file);
+
+ gConfig.createSection("gametype");
+
+ try {
+ gConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ file = new File(this.getDataFolder(), "arena.yml");
+
+ if(!file.exists()) {
+
+ System.out.println("[IranPvP] Could not find any Arenas, Creating new file");
+
+ file = new File(this.getDataFolder(), "arena.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration arenaConfig = YamlConfiguration.loadConfiguration(file);
+
+ arenaConfig.createSection("arena");
+
+ try {
+ arenaConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ getConfig().options().copyDefaults(true);
+ saveConfig();
+
+ Bukkit.getPluginManager().registerEvents(this, this);
+ Bukkit.getPluginManager().registerEvents(new ClickDuelInventoryEvent(this), this);
+ Bukkit.getPluginManager().registerEvents(new InteractWithItemsInHand(this), this);
+ Bukkit.getPluginManager().registerEvents(new DropItemsInHandEvent(this), this);
+ Bukkit.getPluginManager().registerEvents(new PlayerDeathWhileInPvP(this), this);
+ Bukkit.getPluginManager().registerEvents(new PlayerDisconnectWhileInPvP(this), this);
+ Bukkit.getPluginManager().registerEvents(new AddItemsOnJoin(this), this);
+ Bukkit.getPluginManager().registerEvents(new TeamClickInventoryEvent(this), this);
+ Bukkit.getPluginManager().registerEvents(new TeamFightEvent(this), this);
+ Bukkit.getPluginManager().registerEvents(new EnderpearlCooldown(this), this);
+ Bukkit.getPluginManager().registerEvents(new TeamDamageTeam(this), this);
+ Bukkit.getPluginManager().registerEvents(new PlayerBreakBlockEvent(this), this);
+ Bukkit.getPluginManager().registerEvents(new RespawnEvent(this), this);
+ Bukkit.getPluginManager().registerEvents(new DisconnectWhileInTeam(this), this);
+ Bukkit.getPluginManager().registerEvents(new BardEvent(this), this);
+ Bukkit.getPluginManager().registerEvents(new KitEvents(this), this);
+ Bukkit.getPluginManager().registerEvents(new DeathInventory(this), this);
+ Bukkit.getPluginManager().registerEvents(new SpectatorEvents(this), this);
+ Bukkit.getPluginManager().registerEvents(new FFAEvent(this), this);
+ Bukkit.getPluginManager().registerEvents(new RankedEvent(this), this);
+ Bukkit.getPluginManager().registerEvents(new TeamChat(this), this);
+ Bukkit.getPluginManager().registerEvents(new GameTypeCommands(this), this);
+ Bukkit.getPluginManager().registerEvents(new KothDeathEvent(this), this);
+ //Bukkit.getPluginManager().registerEvents(new ProtocolEvents(this), this);
+
+ getCommand("ffa").setExecutor(new FFACommand(this));
+ getCommand("leave").setExecutor(new FFACommand(this));
+ getCommand("join").setExecutor(new FFACommand(this));
+
+ getCommand("elo").setExecutor(new EloCommands(this));
+
+ getCommand("duel").setExecutor(new PvPCommands(this));
+ getCommand("ping").setExecutor(new PvPCommands(this));
+ getCommand("accept").setExecutor(new PvPCommands(this));
+ getCommand("spectate").setExecutor(new PvPCommands(this));
+ getCommand("deny").setExecutor(new PvPCommands(this));
+ getCommand("arena").setExecutor(new ArenaCommands(this));
+ getCommand("team").setExecutor(new TeamCommands(this));
+ getCommand("gametype").setExecutor(new GameTypeCommands(this));
+ getCommand("iranpvpitems").setExecutor(new ItemsCommand(this));
+
+ run.runTaskTimer(this, 0L, 20L);
+ ffaRun.runTaskTimer(this, 0L, 20L);
+ bard.runTaskTimer(this, 0L, 10L);
+
+ if(Bukkit.getOnlinePlayers().length > 0) {
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ rank.createFiles(p);
+ }
+ }
+
+ }
+
+ @Override
+ @SuppressWarnings("deprecation")
+ public void onDisable() {
+ if(Bukkit.getOnlinePlayers().length > 0) {
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ rank.saveElo(p);
+ }
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
+
+ if(!(sender instanceof Player)) {
+ return true;
+ }
+
+ Player player = (Player) sender;
+
+ if(cmd.getName().equalsIgnoreCase("setpracticespawn")) {
+
+ if(!player.hasPermission("iranpvp.setloc")) { return true; }
+
+ if(!this.getConfig().contains("spawn")) {
+ this.getConfig().createSection("spawn.x");
+ this.getConfig().createSection("spawn.y");
+ this.getConfig().createSection("spawn.z");
+ this.getConfig().createSection("spawn.pitch");
+ this.getConfig().createSection("spawn.yaw");
+ this.getConfig().createSection("spawn.world");
+
+ this.getConfig().set("spawn.x", player.getLocation().getBlockX());
+ this.getConfig().set("spawn.y", player.getLocation().getBlockY());
+ this.getConfig().set("spawn.z", player.getLocation().getBlockZ());
+ this.getConfig().set("spawn.pitch", player.getLocation().getPitch());
+ this.getConfig().set("spawn.yaw", player.getLocation().getYaw());
+ this.getConfig().set("spawn.world", player.getLocation().getWorld().getName());
+ this.saveConfig();
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("SET_SPAWN")));
+ } else {
+ this.getConfig().set("spawn.x", player.getLocation().getBlockX());
+ this.getConfig().set("spawn.y", player.getLocation().getBlockY());
+ this.getConfig().set("spawn.z", player.getLocation().getBlockZ());
+ this.getConfig().set("spawn.pitch", player.getLocation().getPitch());
+ this.getConfig().set("spawn.yaw", player.getLocation().getYaw());
+ this.getConfig().set("spawn.world", player.getLocation().getWorld().getName());
+ this.saveConfig();
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("SET_SPAWN")));
+ }
+ }
+
+ if(cmd.getName().equalsIgnoreCase("seteditor")) {
+
+ if(!player.hasPermission("iranpvp.setloc")) {
+
+ return true;
+
+ }
+
+ if(!this.getConfig().contains("kit")) {
+ this.getConfig().createSection("kit.x");
+ this.getConfig().createSection("kit.y");
+ this.getConfig().createSection("kit.z");
+ this.getConfig().createSection("kit.pitch");
+ this.getConfig().createSection("kit.yaw");
+ this.getConfig().createSection("kit.world");
+
+ this.getConfig().set("kit.x", player.getLocation().getBlockX());
+ this.getConfig().set("kit.y", player.getLocation().getBlockY());
+ this.getConfig().set("kit.z", player.getLocation().getBlockZ());
+ this.getConfig().set("kit.pitch", player.getLocation().getPitch());
+ this.getConfig().set("kit.yaw", player.getLocation().getYaw());
+ this.getConfig().set("kit.world", player.getLocation().getWorld().getName());
+ this.saveConfig();
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("SET_EDITOR_SPAWN")));
+ } else {
+ this.getConfig().set("kit.x", player.getLocation().getBlockX());
+ this.getConfig().set("kit.y", player.getLocation().getBlockY());
+ this.getConfig().set("kit.z", player.getLocation().getBlockZ());
+ this.getConfig().set("kit.pitch", player.getLocation().getPitch());
+ this.getConfig().set("kit.yaw", player.getLocation().getYaw());
+ this.getConfig().set("kit.world", player.getLocation().getWorld().getName());
+ this.saveConfig();
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("SET_EDITOR_SPAWN")));
+ }
+ }
+
+ if(cmd.getName().equalsIgnoreCase("items")) {
+ if(TeamManager.getManager().isInTeam(player)) {
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+ if(TeamDuelManager.getManager().isInDuel(team)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("IN_DUEL_ERROR")));
+ return true;
+ }
+ }
+
+ if(DuelManager.getManager().isInDuel(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("IN_DUEL_ERROR")));
+ return true;
+ }
+
+ if(queue.isInUnranked(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("IN_QUEUE_ERROR")));
+ return true;
+ }
+
+ if(queue.isInRanked(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("IN_QUEUE_ERROR")));
+ return true;
+ }
+
+ if(FFACommand.fighters.contains(player.getName())) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("IN_FFA_ERROR")));
+ return true;
+ }
+
+ if (ArenaManager.getManager().isSpectator(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("IN_SPECTATOR_ERROR")));
+ return true;
+ }
+
+ spawn.teleportSpawn(player);
+ }
+
+ if(cmd.getName().equalsIgnoreCase("view")) {
+
+ if(args.length < 1) {
+ player.sendMessage(ChatColor.RED + "/view player");
+ }
+
+ Player target = Bukkit.getPlayer(args[0]);
+
+ if(target == null) {
+ player.sendMessage(ChatColor.RED + "Couldn't find player");
+ return true;
+ }
+
+ if(DeathInventory.getTimer().containsKey(target.getName())) {
+ player.openInventory(DeathInventory.deadInv(target));
+ }
+
+ }
+
+ return true;
+ }
+
+
+ public ArrayList getToggle() {
+ return toggle;
+ }
+
+}
diff --git a/src/me/iran/iranpvp/ItemsCommand.java b/src/me/iran/iranpvp/ItemsCommand.java
new file mode 100644
index 0000000..5dac12a
--- /dev/null
+++ b/src/me/iran/iranpvp/ItemsCommand.java
@@ -0,0 +1,67 @@
+package me.iran.iranpvp;
+
+import me.iran.iranpvp.duel.DuelManager;
+import me.iran.iranpvp.duel.team.TeamDuelManager;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.utils.TeleportSpawn;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+public class ItemsCommand implements CommandExecutor {
+
+ IranPvP plugin;
+
+ public ItemsCommand(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ TeleportSpawn spawn = new TeleportSpawn();
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
+
+ if(!(sender instanceof Player)) {
+ if(cmd.getName().equalsIgnoreCase("iranpvpitems")) {
+
+ if(args.length < 1) {
+ sender.sendMessage(ChatColor.RED + "/items ");
+ return true;
+ }
+
+ Player player = Bukkit.getPlayer(args[0]);
+
+ if(player == null) {
+ return true;
+ }
+
+ if (TeamManager.getManager().isInTeam(player)) {
+ Team team = TeamManager.getManager()
+ .getTeamByPlayer(player);
+ if (TeamDuelManager.getManager().isInDuel(team)) {
+ player.sendMessage(ChatColor.RED + "Can't do this while in a duel");
+ return true;
+ }
+ }
+
+ if (DuelManager.getManager().isInDuel(player)) {
+ player.sendMessage(ChatColor.RED + "Can't do this while in a duel");
+ return true;
+ }
+
+ spawn.teleportSpawn(player);
+ }
+
+
+
+ }
+
+ return true;
+ }
+
+}
diff --git a/src/me/iran/iranpvp/arena/Arena.java b/src/me/iran/iranpvp/arena/Arena.java
new file mode 100644
index 0000000..230b12a
--- /dev/null
+++ b/src/me/iran/iranpvp/arena/Arena.java
@@ -0,0 +1,338 @@
+package me.iran.iranpvp.arena;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.bukkit.Location;
+
+public class Arena {
+
+ Location loc1;
+ Location loc2;
+
+ int x1;
+ int y1;
+ int z1;
+
+ int x2;
+ int y2;
+ int z2;
+
+ float pitch1;
+ float yaw1;
+
+ float pitch2;
+ float yaw2;
+
+ int loc1x;
+ int loc1y;
+ int loc1z;
+
+ int loc2x;
+ int loc2y;
+ int loc2z;
+
+ private String name;
+ private String creator;
+
+ private List fighters;
+ private int timer;
+ private int time;
+ private ArrayList cappers;
+ private boolean active;
+ private boolean teamArena;
+
+ private ArrayList spec;
+
+ private String world;
+
+ public Arena (Location loc1, Location loc2, int timer, String name, String world) {
+ this.loc1 = loc1;
+ this.loc2 = loc2;
+ this.timer = timer;
+ this.time = timer;
+ this.name = name;
+ this.world = world;
+ active = false;
+ teamArena = true;
+ spec = new ArrayList();
+ fighters = new ArrayList();
+ cappers = new ArrayList();
+ this.creator = "Anonymous";
+ }
+
+ public void setCreator(String creator) {
+ this.creator = creator;
+ }
+
+ public String getCreator() {
+ return creator;
+ }
+
+ public ArrayList getSpec() {
+ return spec;
+ }
+
+ public void setSpec(ArrayList spec) {
+ this.spec = spec;
+ }
+
+ public void addSpec(String spec) {
+ this.spec.add(spec);
+ }
+
+ public void removeSpec(String spec){
+ this.spec.remove(spec);
+ }
+
+ public boolean isSpec(String player) {
+ if(spec.contains(player)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ //Team 1
+
+ public void setXTeam1(int x) {
+ this.x1 = x;
+ }
+
+ public void setYTeam1(int y) {
+ this.y1 = y;
+ }
+
+ public void setZTeam1(int z) {
+ this.z1 = z;
+ }
+
+ public void setPitchTeam1(float pitch) {
+ this.pitch1 = pitch;
+ }
+
+ public void setYawTeam1(float yaw) {
+ this.yaw1 = yaw;
+ }
+
+ public float getPitchTeam1() {
+ return this.pitch1;
+ }
+
+ public float getYawTeam1() {
+ return this.yaw1;
+ }
+
+ public int getXTeam1() {
+ return x1;
+ }
+
+ public int getYTeam1() {
+ return y1;
+ }
+
+ public int getZTeam1() {
+ return z1;
+ }
+
+ //Team 2
+
+ public void setXTeam2(int x) {
+ this.x2 = x;
+ }
+
+ public void setYTeam2(int y) {
+ this.y2 = y;
+ }
+
+ public void setZTeam2(int z) {
+ this.z2 = z;
+ }
+
+ public void setPitchTeam2(float pitch) {
+ this.pitch2 = pitch;
+ }
+
+ public void setYawTeam2(float yaw) {
+ this.yaw2 = yaw;
+ }
+
+ public float getPitchTeam2() {
+ return this.pitch2;
+ }
+
+ public float getYawTeam2() {
+ return this.yaw2;
+ }
+
+ public int getXTeam2() {
+ return x2;
+ }
+
+ public int getYTeam2() {
+ return y2;
+ }
+
+ public int getZTeam2() {
+ return z2;
+ }
+
+ //KOTH
+
+ public void setLoc1(Location loc1) {
+ this.loc1 = loc1;
+ }
+
+ public void setLoc2(Location loc2) {
+ this.loc2 = loc2;
+ }
+
+ public Location getLoc1() {
+ return this.loc1;
+ }
+
+ public Location getLoc2() {
+ return this.loc2;
+ }
+
+ public void setLoc1X(int x) {
+ this.loc1x = x;
+ }
+
+ public void setLoc1Y(int y) {
+ this.loc1y = y;
+ }
+
+ public void setLoc1Z(int z) {
+ this.loc1z = z;
+ }
+
+ public void setLoc2X(int x) {
+ this.loc2x = x;
+ }
+
+ public void setLoc2Y(int y) {
+ this.loc2y = y;
+ }
+
+ public void setLoc2Z(int z) {
+ this.loc2z = z;
+ }
+
+ //KOTH min
+ public int getMaxX() {
+ return Math.max(loc1.getBlockX(), loc2.getBlockX());
+ }
+
+ public int getMaxZ() {
+ return Math.max(loc1.getBlockZ(), loc2.getBlockZ());
+ }
+
+ public int getMaxY() {
+ return Math.max(loc1.getBlockY(), loc2.getBlockY());
+ }
+
+ public int getMinX() {
+ return Math.min(loc1.getBlockX(), loc2.getBlockX());
+ }
+
+ public int getMinZ() {
+ return Math.min(loc1.getBlockZ(), loc2.getBlockZ());
+ }
+
+ public int getMinY() {
+ return Math.min(loc1.getBlockY(), loc2.getBlockY());
+ }
+
+ //Name
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ //Timer
+
+ public int getTimer() {
+ return timer;
+ }
+
+ public void setTimer(int timer) {
+ this.timer = timer;
+ }
+
+ public void setArenaTimer(int time) {
+ this.time = time;
+ }
+
+ public int getArenaTimer() {
+ return this.time;
+ }
+
+ //Fighters
+ public List getFighters() {
+ return fighters;
+ }
+
+ public void setFightersList(List fighters) {
+ this.fighters = fighters;
+ }
+
+ public void addFighter(String name) {
+ fighters.add(name);
+ }
+
+ public void removeFighter(String name) {
+ fighters.remove(name);
+ }
+
+ //Cappers
+ public ArrayList getCappers() {
+ return cappers;
+ }
+
+ public void setCapperList(ArrayList cappers) {
+ this.cappers = cappers;
+ }
+
+ public void setCapper(String capper) {
+ cappers.add(0, capper);
+ }
+
+ public String getCapper() {
+ return cappers.get(0);
+ }
+
+ //Active
+
+ public boolean isActive() {
+ return active;
+ }
+
+ public void setActive() {
+ active = true;
+ }
+
+ public void setInactive() {
+ active = false;
+ }
+
+ public String getWorld() {
+ return world;
+ }
+
+ public void setWorld(String world) {
+ this.world = world;
+ }
+
+ public boolean isTeamArena() {
+ return teamArena;
+ }
+
+ public void setTeamArena(boolean teamArena) {
+ this.teamArena = teamArena;
+ }
+}
diff --git a/src/me/iran/iranpvp/arena/ArenaManager.java b/src/me/iran/iranpvp/arena/ArenaManager.java
new file mode 100644
index 0000000..986caa5
--- /dev/null
+++ b/src/me/iran/iranpvp/arena/ArenaManager.java
@@ -0,0 +1,796 @@
+package me.iran.iranpvp.arena;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.runnable.Run;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.utils.TeleportSpawn;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.GameMode;
+import org.bukkit.Location;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
+
+public class ArenaManager {
+
+ File file = null;
+
+ public static ArrayList arenas = new ArrayList();
+ public static ArrayList available = new ArrayList();
+ public static ArrayList pAvailable = new ArrayList();
+
+ private static ArenaManager am;
+
+ private ArenaManager() {}
+
+ public static ArenaManager getManager() {
+ if (am == null)
+ am = new ArenaManager();
+
+ return am;
+ }
+
+ TeleportSpawn spawn = new TeleportSpawn();
+
+ public void loadArena() {
+
+ file = new File(IranPvP.plugin.getDataFolder(), "arena.yml");
+
+ if(!file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder(), "arena.yml");
+
+ System.out.println("[IranPvP] Could not find any Arenas, Creating new file");
+
+ file = new File(IranPvP.plugin.getDataFolder(), "arena.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration arenaConfig = YamlConfiguration.loadConfiguration(file);
+
+ arenaConfig.createSection("arena");
+
+ try {
+ arenaConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("[IranPvP] Created arena file, now you can create arenas");
+ } else {
+
+ file = new File(IranPvP.plugin.getDataFolder(), "arena.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration arenaConfig = YamlConfiguration.loadConfiguration(file);
+
+ for(String a : arenaConfig.getConfigurationSection("arena").getKeys(false)) {
+ int teamx1 = arenaConfig.getInt("arena." + a + ".team1.x");
+ int teamy1 = arenaConfig.getInt("arena." + a + ".team1.y");
+ int teamz1 = arenaConfig.getInt("arena." + a + ".team1.z");
+ float team1pitch = (float) arenaConfig.getDouble("arena." + a + ".team1.pitch");
+ float team1yaw = (float) arenaConfig.getDouble("arena." + a + ".team1.yaw");
+
+ int teamx2 = arenaConfig.getInt("arena." + a + ".team2.x");
+ int teamy2 = arenaConfig.getInt("arena." + a + ".team2.y");
+ int teamz2 = arenaConfig.getInt("arena." + a + ".team2.z");
+ float teampitch2 = (float) arenaConfig.getDouble("arena." + a + ".team2.pitch");
+ float teamyaw2 = (float) arenaConfig.getDouble("arena." + a + ".team2.yaw");
+
+ int timer = arenaConfig.getInt("arena." + a + ".timer");
+ int time = arenaConfig.getInt("arena." + a + ".time");
+
+ int loc1x = arenaConfig.getInt("arena." + a + ".loc1.x");
+ int loc1y = arenaConfig.getInt("arena." + a + ".loc1.y");
+ int loc1z = arenaConfig.getInt("arena." + a + ".loc1.z");
+
+ int loc2x = arenaConfig.getInt("arena." + a + ".loc2.x");
+ int loc2y = arenaConfig.getInt("arena." + a + ".loc2.y");
+ int loc2z = arenaConfig.getInt("arena." + a + ".loc2.z");
+
+ String world = arenaConfig.getString("arena." + a + ".world");
+
+ String name = arenaConfig.getString("arena." + a + ".name");
+
+ String creator = arenaConfig.getString("arena." + a + ".creator");
+
+ /////NEW///////
+ boolean teamArena = arenaConfig.getBoolean("arena." + a + ".teamarena");
+
+ /////NEW///////
+
+
+ Location loc1 = new Location(Bukkit.getWorld(world), loc1x, loc1y, loc1z);
+ Location loc2 = new Location(Bukkit.getWorld(world), loc2x, loc2y, loc2z);
+
+ Location team1 = new Location(Bukkit.getWorld(world), teamx1, teamy1, teamz1);
+ Location team2 = new Location(Bukkit.getWorld(world), teamx2, teamy2, teamz2);
+
+ team1.setPitch(team1pitch);
+ team1.setYaw(team1yaw);
+
+ team2.setPitch(teampitch2);
+ team2.setYaw(teamyaw2);
+
+ Arena arena = new Arena(loc1, loc2, timer, name, world);
+ arena.setName(name);
+ arena.setLoc1(loc1);
+ arena.setLoc2(loc2);
+
+ arena.setXTeam1(teamx1);
+ arena.setYTeam1(teamy1);
+ arena.setZTeam1(teamz1);
+ arena.setPitchTeam1(team1pitch);
+ arena.setYawTeam1(team1yaw);
+
+ arena.setXTeam2(teamx2);
+ arena.setYTeam2(teamy2);
+ arena.setZTeam2(teamz2);
+ arena.setPitchTeam2(teampitch2);
+ arena.setYawTeam2(teamyaw2);
+ arena.setTeamArena(teamArena);
+
+ arena.setCreator(creator);
+
+ arena.setWorld(world);
+ arena.setArenaTimer(time);;
+ arena.setTimer(arena.getArenaTimer());
+
+ arenas.add(arena);
+
+
+ }
+
+
+ }
+
+ for(Arena a : arenas) {
+ if(a.isTeamArena() == true) {
+ available.add(a);
+ } else if(a.isTeamArena() == false) {
+ pAvailable.add(a);
+ }
+ }
+
+ System.out.println("Team Fight Arenas: " + available.size());
+ System.out.println("1v1 Arenas: " + pAvailable.size());
+ }
+
+ public void saveArena() {
+ file = new File(IranPvP.plugin.getDataFolder(), "arena.yml");
+
+
+ if(!file.exists()) {
+
+ file = new File(IranPvP.plugin.getDataFolder(), "arena.yml");
+
+ System.out.println("[IranPvP] Could not find any Arenas, Creating new file");
+
+ file = new File(IranPvP.plugin.getDataFolder(), "arena.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration arenaConfig = YamlConfiguration.loadConfiguration(file);
+
+ arenaConfig.createSection("arena");
+
+ try {
+ arenaConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("[IranPvP] Created arena file, now you can create arenas");
+ } else {
+
+ file = new File(IranPvP.plugin.getDataFolder(), "arena.yml");
+
+ new YamlConfiguration();
+ YamlConfiguration arenaConfig = YamlConfiguration.loadConfiguration(file);
+
+ for(int i = 0; i < arenas.size(); i++) {
+
+ String a = arenas.get(i).getName();
+
+ Arena arena = getArenaByName(a);
+
+ arenaConfig.set("arena." + a + ".name", a);
+ arenaConfig.set("arena." + a + ".creator", arena.getCreator());
+
+ arenaConfig.set("arena." + a + ".team1.x", arena.getXTeam1());
+ arenaConfig.set("arena." + a + ".team1.y", arena.getYTeam1());
+ arenaConfig.set("arena." + a + ".team1.z", arena.getZTeam1());
+ arenaConfig.set("arena." + a + ".team1.pitch", arena.getPitchTeam1());
+ arenaConfig.set("arena." + a + ".team1.yaw", arena.getYawTeam1());
+
+ arenaConfig.set("arena." + a + ".team2.x", arena.getXTeam2());
+ arenaConfig.set("arena." + a + ".team2.y", arena.getYTeam2());
+ arenaConfig.set("arena." + a + ".team2.z", arena.getZTeam2());
+ arenaConfig.set("arena." + a + ".team2.pitch", arena.getPitchTeam2());
+ arenaConfig.set("arena." + a + ".team2.yaw", arena.getYawTeam2());
+
+ arenaConfig.set("arena." + a + ".xmin", arena.getMinX());
+ arenaConfig.set("arena." + a + ".ymin", arena.getMinY());
+ arenaConfig.set("arena." + a + ".zmin", arena.getMinZ());
+
+ arenaConfig.set("arena." + a + ".xmax", arena.getMaxX());
+ arenaConfig.set("arena." + a + ".ymax", arena.getMaxY());
+ arenaConfig.set("arena." + a + ".zmax", arena.getMaxZ());
+
+ arenaConfig.set("arena." + a + ".loc1.x", arena.getLoc1().getBlockX());
+ arenaConfig.set("arena." + a + ".loc1.y", arena.getLoc1().getBlockY());
+ arenaConfig.set("arena." + a + ".loc1.z", arena.getLoc1().getBlockZ());
+
+ arenaConfig.set("arena." + a + ".loc2.x", arena.getLoc2().getBlockX());
+ arenaConfig.set("arena." + a + ".loc2.y", arena.getLoc2().getBlockY());
+ arenaConfig.set("arena." + a + ".loc2.z", arena.getLoc2().getBlockZ());
+
+ arenaConfig.set("arena." + a + ".world", arena.getWorld());
+ arenaConfig.set("arena." + a + ".active", false);
+ arenaConfig.set("arena." + a + ".teamarena", arena.isTeamArena());
+ arenaConfig.set("arena." + a + ".timer", arena.getArenaTimer());
+ arenaConfig.set("arena." + a + ".time", arena.getArenaTimer());
+ arenaConfig.set("arena." + a + ".world", arena.getWorld());
+
+ }
+
+ try {
+ arenaConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ public void deleteArena(String name, Player player) {
+
+ file = new File(IranPvP.plugin.getDataFolder(), "arena.yml");
+
+ if(file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder(), "arena.yml");
+
+ new YamlConfiguration();
+ YamlConfiguration arenaConfig = YamlConfiguration.loadConfiguration(file);
+
+ Arena arena = getArenaByName(name);
+
+ if(!arenas.contains(arena)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_REMOVE_FAIL").replace("%arena%", arena.getName())));
+ return;
+ }
+
+ if(arena.isActive()) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_REMOVE_FAIL").replace("%arena%", arena.getName())));
+ return;
+ }
+ arenaConfig.set("arena." + name, null);
+
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_REMOVE_SUCCESS").replace("%arena%", arena.getName())));
+
+ arenas.remove(arena);
+ available.remove(arena);
+
+
+
+ try {
+ arenaConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void createArena(Location loc1, Location loc2, int timer, String name, Player player) {
+
+ if(arenas.contains(getArenaByName(name))) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_CREATE_FAIL").replace("%arena%", name)));
+
+ return;
+ }
+
+ Arena arena = new Arena (loc1, loc2, timer, name, player.getLocation().getWorld().getName());
+
+ arenas.add(arena);
+ available.add(arena);
+
+ file = new File(IranPvP.plugin.getDataFolder(), "arena.yml");
+
+ if(!file.exists()) {
+ System.out.println("[IranPvP] Could not find any Arenas, Creating new file");
+
+ file = new File(IranPvP.plugin.getDataFolder(), "arena.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration arenaConfig = YamlConfiguration.loadConfiguration(file);
+
+ arenaConfig.createSection("arena." + name + ".name");
+ arenaConfig.createSection("arena." + name + ".creator");
+
+ arenaConfig.createSection("arena." + name + ".team1.x");
+ arenaConfig.createSection("arena." + name + ".team1.y");
+ arenaConfig.createSection("arena." + name + ".team1.z");
+ arenaConfig.createSection("arena." + name + ".team1.pitch");
+ arenaConfig.createSection("arena." + name + ".team1.yaw");
+
+ arenaConfig.createSection("arena." + name + ".team2.x");
+ arenaConfig.createSection("arena." + name + ".team2.y");
+ arenaConfig.createSection("arena." + name + ".team2.z");
+ arenaConfig.createSection("arena." + name + ".team2.pitch");
+ arenaConfig.createSection("arena." + name + ".team2.yaw");
+
+ arenaConfig.createSection("arena." + name + ".xmin");
+ arenaConfig.createSection("arena." + name + ".ymin");
+ arenaConfig.createSection("arena." + name + ".zmin");
+
+ arenaConfig.createSection("arena." + name + ".xmax");
+ arenaConfig.createSection("arena." + name + ".ymax");
+ arenaConfig.createSection("arena." + name + ".zmax");
+
+ arenaConfig.createSection("arena." + name + ".timer");
+ arenaConfig.createSection("arena." + name + ".time");
+
+ arenaConfig.createSection("arena." + name + ".world");
+ arenaConfig.createSection("arena." + name + ".active");
+
+ arenaConfig.createSection("arena." + name + ".loc1.x");
+ arenaConfig.createSection("arena." + name + ".loc1.y");
+ arenaConfig.createSection("arena." + name + ".loc1.z");
+
+ arenaConfig.createSection("arena." + name + ".loc2.x");
+ arenaConfig.createSection("arena." + name + ".loc2.y");
+ arenaConfig.createSection("arena." + name + ".loc2.z");
+ arenaConfig.createSection("arena." + name + ".teamarena");
+
+ arenaConfig.set("arena." + name + ".name", name);
+ arenaConfig.set("arena." + name + ".creator", arena.getCreator());
+
+ arenaConfig.set("arena." + name + ".team1.x", arena.getXTeam1());
+ arenaConfig.set("arena." + name + ".team1.y", arena.getYTeam1());
+ arenaConfig.set("arena." + name + ".team1.z", arena.getZTeam1());
+ arenaConfig.set("arena." + name + ".team1.pitch", arena.getPitchTeam1());
+ arenaConfig.set("arena." + name + ".team1.yaw", arena.getYawTeam1());
+
+ arenaConfig.set("arena." + name + ".team2.x", arena.getXTeam2());
+ arenaConfig.set("arena." + name + ".team2.y", arena.getYTeam2());
+ arenaConfig.set("arena." + name + ".team2.z", arena.getZTeam2());
+ arenaConfig.set("arena." + name + ".team2.pitch", arena.getPitchTeam2());
+ arenaConfig.set("arena." + name + ".team2.yaw", arena.getYawTeam2());
+
+ arenaConfig.set("arena." + name + ".xmin", arena.getMinX());
+ arenaConfig.set("arena." + name + ".ymin", arena.getMinY());
+ arenaConfig.set("arena." + name + ".zmin", arena.getMinZ());
+
+ arenaConfig.set("arena." + name + ".xmax", arena.getMaxX());
+ arenaConfig.set("arena." + name + ".ymax", arena.getMaxY());
+ arenaConfig.set("arena." + name + ".zmax", arena.getMaxZ());
+
+ arenaConfig.set("arena." + name + ".timer", timer);
+ arenaConfig.set("arena." + name + ".time", timer);
+
+ arenaConfig.set("arena." + name + ".loc1.x", arena.getLoc1().getBlockX());
+ arenaConfig.set("arena." + name + ".loc1.y", arena.getLoc1().getBlockY());
+ arenaConfig.set("arena." + name + ".loc1.z", arena.getLoc1().getBlockZ());
+
+ arenaConfig.set("arena." + name + ".loc2.x", arena.getLoc2().getBlockX());
+ arenaConfig.set("arena." + name + ".loc2.y", arena.getLoc2().getBlockY());
+ arenaConfig.set("arena." + name + ".loc2.z", arena.getLoc2().getBlockZ());
+
+ arenaConfig.set("arena." + name + ".world", arena.getWorld());
+ arenaConfig.set("arena." + name + ".active", false);
+ arenaConfig.set("arena." + name + ".teamarena", true);
+
+ try {
+ arenaConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_CREATE_SUCCESS").replace("%arena%", arena.getName())));
+
+
+ } else {
+
+ file = new File(IranPvP.plugin.getDataFolder(), "arena.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration arenaConfig = YamlConfiguration.loadConfiguration(file);
+
+ arenaConfig.createSection("arena." + name + ".name");
+ arenaConfig.createSection("arena." + name + ".creator");
+
+ arenaConfig.createSection("arena." + name + ".team1.x");
+ arenaConfig.createSection("arena." + name + ".team1.y");
+ arenaConfig.createSection("arena." + name + ".team1.z");
+ arenaConfig.createSection("arena." + name + ".team1.pitch");
+ arenaConfig.createSection("arena." + name + ".team1.yaw");
+
+ arenaConfig.createSection("arena." + name + ".team2.x");
+ arenaConfig.createSection("arena." + name + ".team2.y");
+ arenaConfig.createSection("arena." + name + ".team2.z");
+ arenaConfig.createSection("arena." + name + ".team2.pitch");
+ arenaConfig.createSection("arena." + name + ".team2.yaw");
+
+ arenaConfig.createSection("arena." + name + ".xmin");
+ arenaConfig.createSection("arena." + name + ".ymin");
+ arenaConfig.createSection("arena." + name + ".zmin");
+
+ arenaConfig.createSection("arena." + name + ".xmax");
+ arenaConfig.createSection("arena." + name + ".ymax");
+ arenaConfig.createSection("arena." + name + ".zmax");
+
+ arenaConfig.createSection("arena." + name + ".timer");
+ arenaConfig.createSection("arena." + name + ".time");
+
+ arenaConfig.createSection("arena." + name + ".loc1.x");
+ arenaConfig.createSection("arena." + name + ".loc1.y");
+ arenaConfig.createSection("arena." + name + ".loc1.z");
+
+ arenaConfig.createSection("arena." + name + ".loc2.x");
+ arenaConfig.createSection("arena." + name + ".loc2.y");
+ arenaConfig.createSection("arena." + name + ".loc2.z");
+
+ arenaConfig.createSection("arena." + name + ".world");
+ arenaConfig.createSection("arena." + name + ".active");
+ arenaConfig.createSection("arena." + name + ".teamarena");
+
+ arenaConfig.set("arena." + name + ".name", name);
+ arenaConfig.set("arena." + name + ".creator", arena.getCreator());
+
+ arenaConfig.set("arena." + name + ".team1.x", arena.getXTeam1());
+ arenaConfig.set("arena." + name + ".team1.y", arena.getYTeam1());
+ arenaConfig.set("arena." + name + ".team1.z", arena.getZTeam1());
+ arenaConfig.set("arena." + name + ".team1.pitch", arena.getPitchTeam1());
+ arenaConfig.set("arena." + name + ".team1.yaw", arena.getYawTeam1());
+
+ arenaConfig.set("arena." + name + ".team2.x", arena.getXTeam2());
+ arenaConfig.set("arena." + name + ".team2.y", arena.getYTeam2());
+ arenaConfig.set("arena." + name + ".team2.z", arena.getZTeam2());
+ arenaConfig.set("arena." + name + ".team2.pitch", arena.getPitchTeam2());
+ arenaConfig.set("arena." + name + ".team2.yaw", arena.getYawTeam2());
+
+ arenaConfig.set("arena." + name + ".xmin", arena.getMinX());
+ arenaConfig.set("arena." + name + ".ymin", arena.getMinY());
+ arenaConfig.set("arena." + name + ".zmin", arena.getMinZ());
+
+ arenaConfig.set("arena." + name + ".xmax", arena.getMaxX());
+ arenaConfig.set("arena." + name + ".ymax", arena.getMaxY());
+ arenaConfig.set("arena." + name + ".zmax", arena.getMaxZ());
+
+ arenaConfig.set("arena." + name + ".timer", timer);
+ arenaConfig.set("arena." + name + ".time", timer);
+
+ arenaConfig.set("arena." + name + ".loc1.x", arena.getLoc1().getBlockX());
+ arenaConfig.set("arena." + name + ".loc1.y", arena.getLoc1().getBlockY());
+ arenaConfig.set("arena." + name + ".loc1.z", arena.getLoc1().getBlockZ());
+
+ arenaConfig.set("arena." + name + ".loc2.x", arena.getLoc2().getBlockX());
+ arenaConfig.set("arena." + name + ".loc2.y", arena.getLoc2().getBlockY());
+ arenaConfig.set("arena." + name + ".loc2.z", arena.getLoc2().getBlockZ());
+
+ arenaConfig.set("arena." + name + ".world", arena.getWorld());
+ arenaConfig.set("arena." + name + ".active", false);
+ arenaConfig.set("arena." + name + ".teamarena", true);
+ try {
+ arenaConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_CREATE_SUCCESS").replace("%arena%", arena.getName())));
+
+ }
+
+ }
+
+
+
+ public Arena getArenaByName(String name) {
+ for(Arena arena : arenas) {
+ if(arena.getName().equalsIgnoreCase(name)) {
+ return arena;
+ }
+ }
+
+ return null;
+ }
+
+ public Arena getArenaByPlayer(Player player) {
+ for(Arena arena : arenas) {
+ if(arena.getFighters().contains(player.getName())) {
+ return arena;
+ }
+ }
+
+ return null;
+ }
+
+ //team fights
+ @SuppressWarnings("deprecation")
+ public void teleportTeams(Team team1, Team team2) {
+ Arena arena = available.get(0);
+
+ if(arena == null) {
+ return;
+ }
+
+ available.remove(arena);
+ arena.setInactive();
+
+ int x1 = arena.getXTeam1();
+ int y1 = arena.getYTeam1();
+ int z1 = arena.getZTeam1();
+
+ int x2 = arena.getXTeam2();
+ int y2 = arena.getYTeam2();
+ int z2 = arena.getZTeam2();
+
+ float pitch1 = arena.getPitchTeam1();
+ float yaw1 = arena.getYawTeam1();
+
+ float pitch2 = arena.getPitchTeam2();
+ float yaw2 = arena.getYawTeam2();
+
+ Location loc1 = new Location(Bukkit.getWorld(arena.getWorld()), x1, y1, z1);
+ loc1.setPitch(pitch1);
+ loc1.setYaw(yaw1);
+
+ Location loc2 = new Location(Bukkit.getWorld(arena.getWorld()), x2, y2, z2);
+ loc2.setPitch(pitch2);
+ loc2.setYaw(yaw2);
+
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team1.getTeamMembers().contains(p.getName())) {
+ p.teleport(loc1);
+ arena.getFighters().add(p.getName());
+ }
+ }
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team2.getTeamMembers().contains(p.getName())) {
+ p.teleport(loc2);
+ arena.getFighters().add(p.getName());
+ }
+ }
+
+ }
+
+ @SuppressWarnings("deprecation")
+ public void teleportKothTeams(Team team1, Team team2) {
+ Arena arena = available.get(0);
+
+ if(arena == null) {
+ return;
+ }
+
+ available.remove(arena);
+ arena.setActive();
+
+ int x1 = arena.getXTeam1();
+ int y1 = arena.getYTeam1();
+ int z1 = arena.getZTeam1();
+
+ int x2 = arena.getXTeam2();
+ int y2 = arena.getYTeam2();
+ int z2 = arena.getZTeam2();
+
+ float pitch1 = arena.getPitchTeam1();
+ float yaw1 = arena.getYawTeam1();
+
+ float pitch2 = arena.getPitchTeam2();
+ float yaw2 = arena.getYawTeam2();
+
+ Location loc1 = new Location(Bukkit.getWorld(arena.getWorld()), x1, y1, z1);
+ loc1.setPitch(pitch1);
+ loc1.setYaw(yaw1);
+
+ Location loc2 = new Location(Bukkit.getWorld(arena.getWorld()), x2, y2, z2);
+ loc2.setPitch(pitch2);
+ loc2.setYaw(yaw2);
+
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team1.getTeamMembers().contains(p.getName())) {
+ p.teleport(loc1);
+ arena.getFighters().add(p.getName());
+ }
+ }
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team2.getTeamMembers().contains(p.getName())) {
+ p.teleport(loc2);
+ arena.getFighters().add(p.getName());
+ }
+ }
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getFighters().contains(p.getName())) {
+ p.sendMessage(ChatColor.GOLD + "Arena: " + ChatColor.YELLOW + arena.getName());
+ p.sendMessage(ChatColor.GOLD + "Timer: " + ChatColor.YELLOW + Run.toMMSS(arena.getArenaTimer()));
+ p.sendMessage(ChatColor.GOLD + "Active: " + ChatColor.YELLOW + arena.isActive());
+ }
+ }
+
+ }
+
+ //1v1's
+ public void teleportPlayers(Player player1, Player player2) {
+ Arena arena = pAvailable.get(0);
+
+ if(arena == null) {
+ return;
+ }
+
+ pAvailable.remove(arena);
+ arena.setInactive();
+
+ arena.addFighter(player1.getName());
+ arena.addFighter(player2.getName());
+
+ int x1 = arena.getXTeam1();
+ int y1 = arena.getYTeam1();
+ int z1 = arena.getZTeam1();
+
+ int x2 = arena.getXTeam2();
+ int y2 = arena.getYTeam2();
+ int z2 = arena.getZTeam2();
+
+ float pitch1 = arena.getPitchTeam1();
+ float yaw1 = arena.getYawTeam1();
+
+ float pitch2 = arena.getPitchTeam2();
+ float yaw2 = arena.getYawTeam2();
+
+ Location loc1 = new Location(Bukkit.getWorld(arena.getWorld()), x1, y1, z1);
+ loc1.setPitch(pitch1);
+ loc1.setYaw(yaw1);
+
+ Location loc2 = new Location(Bukkit.getWorld(arena.getWorld()), x2, y2, z2);
+ loc2.setPitch(pitch2);
+ loc2.setYaw(yaw2);
+
+
+ player1.teleport(loc1);
+ player2.teleport(loc2);
+
+ player1.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_TELEPORT").replace("%creator%", arena.getCreator()).replace("%arena%", arena.getName())));
+
+ player2.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_TELEPORT").replace("%creator%", arena.getCreator()).replace("%arena%", arena.getName())));
+ }
+
+ //remove teams
+ public void removeTeams(Player player) {
+ final Arena arena = getArenaByPlayer(player);
+
+ if(!arenas.contains(arena)) {
+ return;
+ }
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+
+ if(arena.getSpec().contains(p.getName())) {
+ spawn.teleportSpawn(p);
+ p.setGameMode(GameMode.SURVIVAL);
+ p.setAllowFlight(false);
+ arena.getSpec().remove(p.getName());
+ }
+ }
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+
+ if(arena.getFighters().contains(p.getName())) {
+
+ p.getInventory().clear();
+ p.getInventory().setArmorContents(null);
+
+ }
+ }
+
+ arena.setTimer(arena.getArenaTimer());
+ arena.setInactive();
+ arena.getCappers().clear();
+
+ Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(IranPvP.plugin, new Runnable() {
+
+ @Override
+ public void run() {
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+
+ if(arena.getFighters().contains(p.getName())) {
+ spawn.teleportSpawn(p);
+ }
+ }
+
+ available.add(arena);
+
+ arena.getFighters().clear();
+ arena.getSpec().clear();
+ }
+
+ }, 60);
+
+ }
+
+ //remove 1v1's
+ public void removePlayer(Player player) {
+ Arena arena = getArenaByPlayer(player);
+
+ if(!arenas.contains(arena)) {
+ return;
+ }
+
+ pAvailable.add(arena);
+
+ arena.setInactive();
+ arena.setTimer(arena.getArenaTimer());
+ arena.getFighters().clear();
+ arena.getCappers().clear();
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getSpec().contains(p.getName())) {
+ spawn.teleportSpawn(p);
+ p.setAllowFlight(false);
+ p.setGameMode(GameMode.SURVIVAL);
+ arena.getSpec().remove(p.getName());
+ player.showPlayer(p);
+
+ }
+ }
+
+ arena.getSpec().clear();
+ }
+
+ public boolean insideCube(Player player, Location loc) {
+ Arena arena = getArenaByPlayer(player);
+
+ if(!arenas.contains(arena)) {
+ return false;
+ }
+
+ if((loc.getBlockX() >= arena.getMinX()) && (loc.getBlockX() <= arena.getMaxX())) {
+ if((loc.getBlockZ() >= arena.getMinZ()) && (loc.getBlockZ() <= arena.getMaxZ())) {
+ if((loc.getBlockY() >= arena.getMinY()) && (loc.getBlockY() <= arena.getMaxY())) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public boolean isSpectator(Player player) {
+ for(Arena arena : arenas) {
+ if(arena.getSpec().contains(player.getName())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public Arena getArenaBySpectator(Player player) {
+ for(Arena arena : arenas) {
+ if(arena.getSpec().contains(player.getName())) {
+ return arena;
+ }
+ }
+ return null;
+ }
+
+ public ArrayList getAllArena() {
+ return arenas;
+ }
+
+ public ArrayList getAllAvailable() {
+ return available;
+ }
+}
\ No newline at end of file
diff --git a/src/me/iran/iranpvp/cmd/arena/ArenaCommands.java b/src/me/iran/iranpvp/cmd/arena/ArenaCommands.java
new file mode 100644
index 0000000..9abe5f8
--- /dev/null
+++ b/src/me/iran/iranpvp/cmd/arena/ArenaCommands.java
@@ -0,0 +1,295 @@
+package me.iran.iranpvp.cmd.arena;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.Arena;
+import me.iran.iranpvp.arena.ArenaManager;
+
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+public class ArenaCommands implements CommandExecutor {
+
+ IranPvP plugin;
+
+ public ArenaCommands(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
+
+ if(!(sender instanceof Player)) {
+ sender.sendMessage(ChatColor.RED + "Player command only");;
+ return true;
+ }
+
+ Player player = (Player) sender;
+
+ if(cmd.getName().equalsIgnoreCase("arena")) {
+ if(!player.hasPermission("kothpractice.staff")) {
+ player.sendMessage(ChatColor.RED + "Not Enough Permissions.");
+ return true;
+ }
+
+ if(args.length < 1) {
+ player.sendMessage(ChatColor.RED + "/arena create ");
+ player.sendMessage(ChatColor.RED + "/arena setteam1 ");
+ player.sendMessage(ChatColor.RED + "/arena setteam2 ");
+ player.sendMessage(ChatColor.RED + "/arena setloc1 ");
+ player.sendMessage(ChatColor.RED + "/arena setloc2 ");
+ player.sendMessage(ChatColor.RED + "/arena setteamarena true|false");
+ player.sendMessage(ChatColor.RED + "/arena settime ");
+ return true;
+ }
+
+ if(args[0].equalsIgnoreCase("create")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/arena create ");
+ return true;
+ }
+
+ ArenaManager.getManager().createArena(player.getLocation(), player.getLocation(), 0, args[1], player);
+
+ }
+
+ if(args[0].equalsIgnoreCase("setcreator")) {
+ if(args.length < 3) {
+ player.sendMessage(ChatColor.RED + "/arena setcreator ");
+ return true;
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByName(args[1]);
+
+ if(ArenaManager.getManager().getAllArena().contains(arena)) {
+
+ arena.setCreator(args[2]);
+ player.sendMessage(ChatColor.GREEN + "Set the arena creator for arena " + arena.getName() + " to " + arena.getCreator());
+ }
+
+ }
+
+ if(args[0].equalsIgnoreCase("av")) {
+ player.sendMessage("" + ArenaManager.getManager().getAllAvailable().size());
+ }
+
+ if(args[0].equalsIgnoreCase("setteam1")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/arena setteam1 ");
+ return true;
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByName(args[1]);
+
+ if(arena == null) {
+ player.sendMessage(ChatColor.RED + "Could not find that arena");
+ return true;
+ }
+
+
+ int x = player.getLocation().getBlockX();
+ int y = player.getLocation().getBlockY();
+ int z = player.getLocation().getBlockZ();
+
+ float pitch = player.getLocation().getPitch();
+ float yaw = player.getLocation().getYaw();
+
+ arena.setXTeam1(x);
+ arena.setYTeam1(y);
+ arena.setZTeam1(z);
+ arena.setPitchTeam1(pitch);
+ arena.setYawTeam1(yaw);
+
+ ArenaManager.getManager().saveArena();
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_SET_TEAM1").replace("%arena%", arena.getName())));
+
+ }
+
+ if(args[0].equalsIgnoreCase("setteam2")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/arena setteam2 ");
+ return true;
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByName(args[1]);
+
+ if(arena == null) {
+ player.sendMessage(ChatColor.RED + "Could not find that arena");
+ return true;
+ }
+
+
+ int x = player.getLocation().getBlockX();
+ int y = player.getLocation().getBlockY();
+ int z = player.getLocation().getBlockZ();
+
+ float pitch = player.getLocation().getPitch();
+ float yaw = player.getLocation().getYaw();
+
+ arena.setXTeam2(x);
+ arena.setYTeam2(y);
+ arena.setZTeam2(z);
+ arena.setPitchTeam2(pitch);
+ arena.setYawTeam2(yaw);
+
+ ArenaManager.getManager().saveArena();
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_SET_TEAM2").replace("%arena%", arena.getName())));
+ }
+
+ if(args[0].equalsIgnoreCase("setloc1")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/arena setloc1 ");
+ return true;
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByName(args[1]);
+
+ if(arena == null) {
+ player.sendMessage(ChatColor.RED + "Could not find that arena");
+ return true;
+ }
+
+ int x = player.getLocation().getBlockX();
+ int y = player.getLocation().getBlockY();
+ int z = player.getLocation().getBlockZ();
+
+ arena.setLoc1(player.getLocation());
+ arena.setLoc1X(x);
+ arena.setLoc1Y(y);
+ arena.setLoc1Z(z);
+
+ ArenaManager.getManager().saveArena();
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_SET_LOC1").replace("%arena%", arena.getName())));
+ }
+
+
+ if(args[0].equalsIgnoreCase("setloc2")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/arena setloc2 ");
+ return true;
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByName(args[1]);
+
+ if(arena == null) {
+ player.sendMessage(ChatColor.RED + "Could not find that arena");
+ return true;
+ }
+
+ int x = player.getLocation().getBlockX();
+ int y = player.getLocation().getBlockY();
+ int z = player.getLocation().getBlockZ();
+
+ arena.setLoc2(player.getLocation());
+ arena.setLoc2X(x);
+ arena.setLoc2Y(y);
+ arena.setLoc2Z(z);
+
+ ArenaManager.getManager().saveArena();
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_SET_LOC2").replace("%arena%", arena.getName())));
+ }
+
+ if(args[0].equalsIgnoreCase("settime")) {
+ if(args.length < 3) {
+ player.sendMessage(ChatColor.RED + "/arena settimer ");
+ return true;
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByName(args[1]);
+
+ if(arena == null) {
+ player.sendMessage(ChatColor.RED + "Could not find that arena");
+ return true;
+ }
+
+ int time = Integer.parseInt(args[2]);
+
+ arena.setArenaTimer(time);
+ ArenaManager.getManager().saveArena();
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_SET_TIME").replace("%time%", args[2]).replace("%arena%", arena.getName())));
+ }
+
+ if(args[0].equalsIgnoreCase("setteamarena")) {
+ if(args.length < 3) {
+ player.sendMessage(ChatColor.RED + "/arena setteamarena true|false");
+ return true;
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByName(args[1]);
+
+ if(arena == null) {
+ player.sendMessage(ChatColor.RED + "Could not find that arena");
+ return true;
+ }
+
+ String bool = args[2];
+
+ if(bool.equalsIgnoreCase("true")) {
+ arena.setTeamArena(true);
+ ArenaManager.getManager().saveArena();
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_SET_TEAM_TRUE").replace("%arena%", arena.getName())));
+ } else if(bool.equalsIgnoreCase("false")) {
+ arena.setTeamArena(false);
+ ArenaManager.getManager().saveArena();
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ARENA_SET_TEAM_FALSE").replace("%arena%", arena.getName())));
+ } else {
+ player.sendMessage(ChatColor.RED + "/arena setteamarena true|false");
+ }
+
+ }
+
+ if(args[0].equalsIgnoreCase("info")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/arena info ");
+ return true;
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByName(args[1]);
+
+ if(!ArenaManager.getManager().getAllArena().contains(arena)) {
+ player.sendMessage(ChatColor.RED + "That arena doesn't exist");
+ return true;
+ }
+
+ player.sendMessage(ChatColor.GOLD + "Arena Name: " + ChatColor.RED + arena.getName());
+ player.sendMessage("================================");
+ player.sendMessage(ChatColor.YELLOW + "Arena Team1 X: " + ChatColor.RED + arena.getXTeam1());
+ player.sendMessage(ChatColor.YELLOW + "Arena Team1 Y: " + ChatColor.RED + arena.getYTeam1());
+ player.sendMessage(ChatColor.YELLOW + "Arena Team1 Z: " + ChatColor.RED + arena.getZTeam1());
+ player.sendMessage("================================");
+ player.sendMessage(ChatColor.YELLOW + "Arena Team2 X: " + ChatColor.RED + arena.getXTeam2());
+ player.sendMessage(ChatColor.YELLOW + "Arena Team2 Y: " + ChatColor.RED + arena.getYTeam2());
+ player.sendMessage(ChatColor.YELLOW + "Arena Team2 Z: " + ChatColor.RED + arena.getZTeam2());
+ player.sendMessage("================================");
+ player.sendMessage(ChatColor.YELLOW + "Arena Max X: " + ChatColor.RED + arena.getMaxX());
+ player.sendMessage(ChatColor.YELLOW + "Arena Max Y: " + ChatColor.RED + arena.getMaxY());
+ player.sendMessage(ChatColor.YELLOW + "Arena Max Z: " + ChatColor.RED + arena.getMaxZ());
+ player.sendMessage("================================");
+ player.sendMessage(ChatColor.YELLOW + "Arena Min X: " + ChatColor.RED + arena.getMinX());
+ player.sendMessage(ChatColor.YELLOW + "Arena Min Y: " + ChatColor.RED + arena.getMinY());
+ player.sendMessage(ChatColor.YELLOW + "Arena Min Z: " + ChatColor.RED + arena.getMinZ());
+ player.sendMessage("================================");
+ player.sendMessage(ChatColor.YELLOW + "Arena Time: " + ChatColor.RED + arena.getArenaTimer());
+ player.sendMessage(ChatColor.YELLOW + "Arena World: " + ChatColor.RED + arena.getWorld());
+ }
+
+ if(args[0].equalsIgnoreCase("delete")) {
+
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/arena delete ");
+ return true;
+ }
+
+ ArenaManager.getManager().deleteArena(args[1], player);
+ }
+
+ }
+
+
+ return true;
+ }
+
+
+
+}
diff --git a/src/me/iran/iranpvp/cmd/pvp/EloCommands.java b/src/me/iran/iranpvp/cmd/pvp/EloCommands.java
new file mode 100644
index 0000000..f9787d0
--- /dev/null
+++ b/src/me/iran/iranpvp/cmd/pvp/EloCommands.java
@@ -0,0 +1,72 @@
+package me.iran.iranpvp.cmd.pvp;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.type.GameType;
+import me.iran.iranpvp.type.GameTypeManager;
+import me.iran.iranpvp.type.RankedEvent;
+import me.iran.iranpvp.type.RankedManager;
+import net.md_5.bungee.api.ChatColor;
+
+import org.bukkit.Bukkit;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+public class EloCommands implements CommandExecutor {
+
+ IranPvP plugin;
+
+ public EloCommands (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ RankedEvent rank = new RankedEvent(plugin);
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
+
+ if(!(sender instanceof Player)) {
+ return true;
+ }
+
+ Player player = (Player) sender;
+
+ if(cmd.getName().equalsIgnoreCase("elo")) {
+
+ if(args.length < 1) {
+
+ player.sendMessage(ChatColor.BLUE.toString() + ChatColor.BOLD + player.getName() + "'s Elo");
+
+ for(GameType game : GameTypeManager.getManager().getAllGameTypes()) {
+
+ player.sendMessage(ChatColor.GREEN + game.getName() + ": " + ChatColor.GRAY + RankedManager.getManager().getRank(player, game).getElo());
+
+ }
+ return true;
+ }
+
+ Player target = Bukkit.getPlayer(args[0]);
+
+ if(target == null) {
+ return true;
+ }
+
+ if(target.isOnline()) {
+
+ player.sendMessage(ChatColor.BLUE.toString() + ChatColor.BOLD + target.getName() + "'s Elo");
+
+ for(GameType game : GameTypeManager.getManager().getAllGameTypes()) {
+
+ player.sendMessage(ChatColor.GREEN + game.getName() + ": " + ChatColor.GRAY + RankedManager.getManager().getRank(target, game).getElo());
+
+ }
+ } else {
+
+ }
+ }
+
+ return true;
+ }
+
+}
diff --git a/src/me/iran/iranpvp/cmd/pvp/PvPCommands.java b/src/me/iran/iranpvp/cmd/pvp/PvPCommands.java
new file mode 100644
index 0000000..f2855dd
--- /dev/null
+++ b/src/me/iran/iranpvp/cmd/pvp/PvPCommands.java
@@ -0,0 +1,429 @@
+package me.iran.iranpvp.cmd.pvp;
+
+import java.util.HashMap;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.Arena;
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.duel.Duel;
+import me.iran.iranpvp.duel.DuelManager;
+import me.iran.iranpvp.duel.InvitePlayer;
+import me.iran.iranpvp.duel.InvitePlayerManager;
+import me.iran.iranpvp.duel.team.TeamDuelManager;
+import me.iran.iranpvp.runnable.Run;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.type.Ranked;
+import me.iran.iranpvp.type.RankedManager;
+import me.iran.iranpvp.utils.CustomInventory;
+import me.iran.iranpvp.utils.OnJoinItems;
+import me.iran.iranpvp.utils.Queue;
+import me.iran.iranpvp.utils.ScoreboardUtils;
+import net.minecraft.server.v1_7_R4.EntityPlayer;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.GameMode;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+public class PvPCommands implements CommandExecutor {
+
+ IranPvP plugin;
+
+ public PvPCommands(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ public static HashMap invite = new HashMap();
+
+ CustomInventory duelInv = new CustomInventory();
+ Queue queue = new Queue();
+
+ Run run = new Run(plugin);
+
+ OnJoinItems items = new OnJoinItems();
+
+ ScoreboardUtils sb = new ScoreboardUtils();
+
+ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
+
+ if(!(sender instanceof Player)) {
+ return true;
+ }
+
+ Player player = (Player) sender;
+
+ if(cmd.getName().equalsIgnoreCase("duel")) {
+ if(args.length < 1) {
+ player.sendMessage(ChatColor.RED + "/duel ");
+ return true;
+ }
+
+ Player target = Bukkit.getPlayer(args[0]);
+
+ if(target == null) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TARGET_NULL").replace("%target%", args[0])));
+
+ return true;
+ }
+
+ if(target == player) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TARGET_IS_PLAYER").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(InvitePlayerManager.getManager().hasInvited(player, target)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ALREADY_DUELED_TARGET").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(DuelManager.getManager().isInDuel(target)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TARGET_BUSY").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(DuelManager.getManager().isInDuel(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("PLAYER_IN_DUEL")));
+ return true;
+ }
+
+ if(queue.isInUnranked(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_QUEUE_ERROR")));
+ return true;
+ }
+
+ if(queue.isInUnranked(target)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TARGET_IN_QUEUE").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(queue.isInRanked(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_QUEUE_ERROR")));
+ return true;
+ }
+
+ if(queue.isInRanked(target)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TARGET_IN_QUEUE").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(TeamManager.getManager().isInTeam(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_TEAM_ERROR")));
+ return true;
+ }
+
+ if(TeamManager.getManager().isInTeam(target)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TARGET_IN_TEAM").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(ArenaManager.getManager().isSpectator(target)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_SPECTATOR_TARGET").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(ArenaManager.getManager().isSpectator(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_SPECTATOR_ERROR").replace("%target%", args[0])));
+ return true;
+ }
+
+ invite.put(player.getName(), target.getName());
+ player.openInventory(duelInv.gameTypes(player));
+
+ }
+
+ if(cmd.getName().equalsIgnoreCase("accept")) {
+ if(args.length < 1) {
+ player.sendMessage(ChatColor.RED + "/accept ");
+ return true;
+ }
+
+ Player target = Bukkit.getPlayer(args[0]);
+
+ if(target == null) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TARGET_NULL").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(target == player) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TARGET_IS_PLAYER").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(DuelManager.getManager().isInDuel(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_DUEL_ERROR")));
+ return true;
+ }
+
+ if(DuelManager.getManager().isInDuel(target)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TARGET_BUSY").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(queue.isInUnranked(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_QUEUE_ERROR").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(queue.isInUnranked(target)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TARGET_IN_QUEUE").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(queue.isInRanked(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_QUEUE_ERROR").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(queue.isInRanked(target)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TARGET_IN_QUEUE").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(TeamManager.getManager().isInTeam(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_TEAM_ERROR")));
+ return true;
+ }
+
+ if(TeamManager.getManager().isInTeam(target)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TARGET_IN_TEAM").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(ArenaManager.getManager().isSpectator(target)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_SPECTATOR_TARGET").replace("%target%", args[0])));
+ return true;
+ }
+
+ if(ArenaManager.getManager().isSpectator(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_SPECTATOR_ERROR")));
+ return true;
+ }
+
+ if(InvitePlayerManager.getManager().hasInvited(target, player)) {
+
+ InvitePlayer invite = InvitePlayerManager.getManager().getPlayerInvites(target, player);
+
+ DuelManager.getManager().createDuel(target, player, invite.getGameType());
+ InvitePlayerManager.getManager().clearInvites(target);
+ InvitePlayerManager.getManager().clearInvites(player);
+ } else {
+ player.sendMessage(ChatColor.RED + "That person has not dueled you");
+ }
+ }
+
+ if(cmd.getName().equalsIgnoreCase("deny")) {
+ if(args.length < 1) {
+ player.sendMessage(ChatColor.RED + "/deny ");
+ return true;
+ }
+
+ Player target = Bukkit.getPlayer(args[0]);
+
+ if(target == null) {
+ player.sendMessage(ChatColor.RED + "Could not find that player");
+ return true;
+ }
+
+ if(target == player) {
+ player.sendMessage(ChatColor.RED + "Can't do that");
+ return true;
+ }
+
+ if(invite.containsKey(target.getName())) {
+ if(InvitePlayerManager.getManager().hasInvited(target, player)) {
+ invite.remove(target.getName());
+ InvitePlayerManager.getManager().deleteInvites(target, player);
+ player.sendMessage(ChatColor.RED.toString() + "Denied Duel from " + ChatColor.BOLD + target.getName());
+ }
+ } else {
+ player.sendMessage(ChatColor.RED + "That person has not Dueled you");
+ }
+ }
+
+ if(cmd.getName().equalsIgnoreCase("ping")) {
+
+ if(args.length < 1) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("PING").replace("%ping%", "" + getPing(player))));
+ return true;
+ }
+
+ Player target = Bukkit.getPlayer(args[0]);
+
+ if(target == null) {
+ player.sendMessage(ChatColor.RED + "Couldn't find player");
+ return true;
+ }
+
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("PING_TARGET").replace("%target%", target.getName()).replace("%ping%", "" + getPing(target))));
+
+ }
+
+ if(cmd.getName().equalsIgnoreCase("spectate")) {
+ if(args.length < 1) {
+ player.sendMessage(ChatColor.RED + "/spectate ");
+ return true;
+ }
+
+ Player target = Bukkit.getPlayer(args[0]);
+
+ if(target == null) {
+ player.sendMessage(ChatColor.RED + "Could not find that player");
+ return true;
+ }
+
+ if(target == player) {
+ player.sendMessage(ChatColor.RED + "Can't do that");
+ return true;
+ }
+
+ if(TeamManager.getManager().isInTeam(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_TEAM_ERROR")));
+ return true;
+ }
+
+ if(DuelManager.getManager().isInDuel(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_DUEL_ERROR")));
+ return true;
+ }
+
+ if(queue.isInUnranked(player)) {
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("IN_QUEUE_ERROR")));
+ return true;
+ }
+
+ if(TeamManager.getManager().isInTeam(target)) {
+ Team team = TeamManager.getManager().getTeamByPlayer(target);
+ if(ArenaManager.getManager().isSpectator(player)) {
+ player.sendMessage(ChatColor.RED + "Already in spectator mode");
+ return true;
+ }
+
+ if(!TeamDuelManager.getManager().isInDuel(team)) {
+ player.sendMessage(ChatColor.RED + "That team is not in a duel right now!");
+ return true;
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(target);
+
+ if(arena.isActive()) {
+ arena.addSpec(player.getName());
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SPECTATE_TEAM_MESSAGE").replace("%team%", team.getTeamName())));
+
+ player.setGameMode(GameMode.CREATIVE);
+
+ for (Player p : Bukkit.getOnlinePlayers()) {
+ if (arena.getFighters().contains(p.getName())) {
+ p.hidePlayer(player);
+ player.showPlayer(p);
+ }
+ }
+
+ player.setScoreboard(sb.specTeamBoard(player, target));
+
+ items.spectatorMode(player);
+
+ player.teleport(target.getLocation());
+ player.setAllowFlight(true);
+
+ } else {
+ arena.addSpec(player.getName());
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SPECTATE_TEAM_MESSAGE").replace("%team%", team.getTeamName())));
+
+ player.setGameMode(GameMode.CREATIVE);
+
+ for (Player p : Bukkit.getOnlinePlayers()) {
+ if (arena.getFighters().contains(p.getName())) {
+ p.hidePlayer(player);
+ player.showPlayer(p);
+ }
+ }
+
+ player.setScoreboard(sb.specTeamBoard(player, target));
+
+ items.spectatorMode(player);
+ player.teleport(target.getLocation());
+ player.setAllowFlight(true);
+ }
+
+
+ } else if(DuelManager.getManager().isInDuel(target)) {
+
+ if(ArenaManager.getManager().isSpectator(player)) {
+ player.sendMessage(ChatColor.RED + "Already in spectator mode");
+ return true;
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(target);
+
+ Duel duel = DuelManager.getManager().getDuelByPlayer(target);
+
+ if(!duel.isRanked()) {
+ arena.addSpec(player.getName());
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SPECTATE_PLAYER_MESSAGE").replace("%player2%", duel.getPlayer2().getName()).replace("%player1%", duel.getPlayer1().getName())));
+
+ player.teleport(target.getLocation());
+ items.spectatorMode(player);
+
+ player.setGameMode(GameMode.CREATIVE);
+
+ player.setScoreboard(sb.specDuelBoard(player, target));
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getFighters().contains(p.getName())) {
+ p.hidePlayer(player);
+ player.showPlayer(p);
+ }
+ }
+
+ items.spectatorMode(player);
+ player.teleport(target.getLocation());
+ player.setAllowFlight(true);
+
+ } else {
+
+ Ranked elo1 = RankedManager.getManager().getRank(duel.getPlayer1(), duel.getGameType());
+ Ranked elo2 = RankedManager.getManager().getRank(duel.getPlayer2(), duel.getGameType());
+
+ arena.addSpec(player.getName());
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SPECTATE_PLAYER_MESSAGE_RANKED").replace("%player1elo%", "" + elo1.getElo()).replace("%player2elo%", "" + elo2.getElo()).replace("%player2%", duel.getPlayer2().getName()).replace("%player1%", duel.getPlayer1().getName())));
+
+ player.teleport(target.getLocation());
+ items.spectatorMode(player);
+
+ player.setScoreboard(sb.specDuelBoard(player, target));
+
+ player.setGameMode(GameMode.CREATIVE);
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getFighters().contains(p.getName())) {
+ p.hidePlayer(player);
+ player.showPlayer(p);
+ }
+ }
+
+ items.spectatorMode(player);
+ player.teleport(target.getLocation());
+ player.setAllowFlight(true);
+ }
+
+ } else {
+ player.sendMessage(ChatColor.RED + "That person is not in a Duel");
+ }
+
+ }
+
+ return true;
+ }
+
+ public int getPing(Player p) {
+ CraftPlayer cp = (CraftPlayer) p;
+ EntityPlayer ep = cp.getHandle();
+ return ep.ping;
+ }
+
+}
diff --git a/src/me/iran/iranpvp/cmd/pvp/specevent/SpectatorEvents.java b/src/me/iran/iranpvp/cmd/pvp/specevent/SpectatorEvents.java
new file mode 100644
index 0000000..ee1dbce
--- /dev/null
+++ b/src/me/iran/iranpvp/cmd/pvp/specevent/SpectatorEvents.java
@@ -0,0 +1,89 @@
+package me.iran.iranpvp.cmd.pvp.specevent;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.Arena;
+import me.iran.iranpvp.arena.ArenaManager;
+
+import org.bukkit.GameMode;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.player.PlayerChangedWorldEvent;
+import org.bukkit.event.player.PlayerDropItemEvent;
+import org.bukkit.event.player.PlayerPickupItemEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+
+public class SpectatorEvents implements Listener {
+
+ IranPvP plugin;
+
+ public SpectatorEvents(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void onPickUp(PlayerPickupItemEvent event) {
+ Player player = event.getPlayer();
+
+ if(ArenaManager.getManager().isSpectator(player)) {
+ event.setCancelled(true);
+ }
+
+ }
+
+ @EventHandler
+ public void onClick(InventoryClickEvent event) {
+
+ if(event.getWhoClicked() instanceof Player) {
+ Player player = (Player) event.getWhoClicked();
+
+ if(ArenaManager.getManager().isSpectator(player)) {
+ event.setCancelled(true);
+ }
+
+ }
+ }
+
+ @EventHandler
+ public void onDrop(PlayerDropItemEvent event) {
+
+ Player player = event.getPlayer();
+
+ if(ArenaManager.getManager().isSpectator(player)) {
+ event.setCancelled(true);
+ }
+
+ }
+
+ @EventHandler
+ public void worldChange(PlayerChangedWorldEvent event) {
+
+ Player player = event.getPlayer();
+
+ if(ArenaManager.getManager().isSpectator(player)) {
+ player.setGameMode(GameMode.CREATIVE);
+ player.setAllowFlight(true);
+ player.setHealth(20.0);
+ player.setFoodLevel(20);
+ }
+
+ }
+
+ @EventHandler
+ public void onQuit(PlayerQuitEvent event) {
+
+ Player player = event.getPlayer();
+
+ if(ArenaManager.getManager().isSpectator(player)) {
+ Arena arena = ArenaManager.getManager().getArenaBySpectator(player);
+ arena.removeSpec(player.getName());
+
+ player.setGameMode(GameMode.SURVIVAL);
+ player.setAllowFlight(false);
+ player.setHealth(20.0);
+ player.setFoodLevel(20);
+ }
+ }
+
+}
diff --git a/src/me/iran/iranpvp/cmd/team/TeamCommands.java b/src/me/iran/iranpvp/cmd/team/TeamCommands.java
new file mode 100644
index 0000000..f8531a5
--- /dev/null
+++ b/src/me/iran/iranpvp/cmd/team/TeamCommands.java
@@ -0,0 +1,364 @@
+package me.iran.iranpvp.cmd.team;
+
+import java.util.HashMap;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.duel.team.TeamDuelManager;
+import me.iran.iranpvp.duel.team.TeamInviteManager;
+import me.iran.iranpvp.runnable.Run;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.type.GameType;
+import me.iran.iranpvp.utils.BungeeChat;
+import me.iran.iranpvp.utils.CustomInventory;
+import me.iran.iranpvp.utils.OnJoinItems;
+import me.iran.iranpvp.utils.Queue;
+import me.iran.iranpvp.utils.TeleportSpawn;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+public class TeamCommands implements CommandExecutor {
+
+ IranPvP plugin;
+
+ public static HashMap invite = new HashMap();
+
+ public TeamCommands(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ Run run = new Run(plugin);
+ Queue queue = new Queue();
+ OnJoinItems items = new OnJoinItems();
+ BungeeChat click = new BungeeChat();
+ CustomInventory inv = new CustomInventory();
+ TeleportSpawn spawn = new TeleportSpawn();
+
+ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
+
+ if(!(sender instanceof Player)) {
+ sender.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " Player Command Only!");
+ return true;
+ }
+
+ Player player = (Player) sender;
+
+ if(cmd.getName().equalsIgnoreCase("team")) {
+
+ if(args.length < 1) {
+ player.sendMessage(ChatColor.AQUA.toString() + ChatColor.STRIKETHROUGH + "----------------");
+
+ player.sendMessage(ChatColor.YELLOW + "Team Leader Commands");
+ player.sendMessage("");
+ player.sendMessage(ChatColor.GRAY + "/team create");
+ player.sendMessage(ChatColor.GRAY + "/team disband");
+ player.sendMessage(ChatColor.GRAY + "/team kick ");
+ player.sendMessage(ChatColor.GRAY + "/team leave");
+ player.sendMessage(ChatColor.GRAY + "/team duel ");
+ player.sendMessage(ChatColor.GRAY + "/team accept ");
+ player.sendMessage(ChatColor.GRAY + "/team invite ");
+ player.sendMessage(ChatColor.GRAY + "/team bard ");
+ player.sendMessage(ChatColor.AQUA.toString() + ChatColor.STRIKETHROUGH + "----------------");
+
+ player.sendMessage("");
+ player.sendMessage(ChatColor.YELLOW + "Team Commands");
+ player.sendMessage(ChatColor.GRAY + "/team join ");
+ player.sendMessage(ChatColor.GRAY + "/team leave");
+ return true;
+ }
+
+ if(args[0].equalsIgnoreCase("create") || args[0].equalsIgnoreCase("c")) {
+
+ if(queue.isInUnranked(player)) {
+ player.sendMessage(ChatColor.RED + "Can't create a team while in a Queue");
+ return true;
+ }
+
+ TeamManager.getManager().createTeam(player.getName(), player);
+ }
+
+ if(args[0].equalsIgnoreCase("invite")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + " /team invite ");
+ return true;
+ }
+
+ Player target = Bukkit.getPlayer(args[1]);
+
+ if(target == null) {
+ player.sendMessage(ChatColor.RED + " Invalid player");
+ return true;
+ }
+
+ if(target == player) {
+ player.sendMessage(ChatColor.RED + " You can't invite yourself");
+ return true;
+ }
+
+ TeamManager.getManager().inviteToTeam(player, target);
+ }
+
+ if(args[0].equalsIgnoreCase("join") || args[0].equalsIgnoreCase("j")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " /team help for more info!");
+ return true;
+ }
+
+ TeamManager.getManager().joinTeam(player, args[1]);
+ }
+
+ if(args[0].equalsIgnoreCase("leave")) {
+
+ if(TeamManager.getManager().isInTeam(player)) {
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ if(TeamDuelManager.getManager().isInDuel(team)) {
+ player.sendMessage(ChatColor.RED + "Can't leave a team while in a duel");
+ return true;
+ } else {
+ TeamManager.getManager().leaveTeam(player);
+ spawn.teleportSpawn(player);
+ }
+ }
+ }
+
+ if(args[0].equalsIgnoreCase("disband")) {
+ if(TeamManager.getManager().isInTeam(player)) {
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+ TeamManager.getManager().disbandTeam(player);
+ }
+ }
+
+ if(args[0].equalsIgnoreCase("kick") || args[0].equalsIgnoreCase("k")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + " /team kick ");
+ return true;
+ }
+
+ Player target = Bukkit.getPlayer(args[1]);
+ if(target == null) {
+ player.sendMessage(ChatColor.RED + " Invalid player");
+ return true;
+ }
+
+ TeamManager.getManager().kickFromTeam(player, target);
+ }
+
+ if(args[0].equalsIgnoreCase("leader") || args[0].equalsIgnoreCase("l")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + " /team leader ");
+ return true;
+ }
+
+ Player target = Bukkit.getPlayer(args[1]);
+ if(target == null) {
+ player.sendMessage(ChatColor.RED + " Invalid player");
+ return true;
+ }
+
+ TeamManager.getManager().makeLeader(player, target);
+ TeamManager.getManager().getTeamByPlayer(target).setTeamName(target.getName());
+ }
+
+ if(args[0].equalsIgnoreCase("bard") || args[0].equalsIgnoreCase("b")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/team bard ");
+ return true;
+ }
+
+ Player target = Bukkit.getPlayer(args[1]);
+ if(target == null) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " Invalid player");
+ return true;
+ }
+
+ TeamManager.getManager().setTeamBard(player, target);
+ }
+
+
+ if(args[0].equalsIgnoreCase("duel") || args[0].equalsIgnoreCase("d")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " /team duel ");
+ return true;
+ }
+ if(!TeamManager.getManager().isInTeam(player)) {
+ player.sendMessage(ChatColor.RED + "You must be in a team to do this command");
+ return true;
+ }
+ Team team1 = TeamManager.getManager().getTeamByPlayer(player);
+
+ if(!team1.getTeamLeader().equals(player.getName())) {
+ player.sendMessage(ChatColor.RED + "Only leaders can do this command");
+ return true;
+ }
+
+ if(TeamDuelManager.getManager().isInDuel(team1)) {
+ player.sendMessage(ChatColor.RED + "Can't duel someone while in a match already");
+ return true;
+ }
+
+ Team team2 = TeamManager.getManager().getTeamByName(args[1]);
+
+ if(!TeamManager.getManager().getAllTeams().contains(team2)) {
+ player.sendMessage(ChatColor.RED + "Couldn't find that team");
+ return true;
+ }
+
+
+ if(TeamDuelManager.getManager().isInDuel(team2)) {
+ player.sendMessage(ChatColor.RED + "That team is busy");
+ return true;
+ }
+
+ if(team1 == team2) {
+ player.sendMessage(ChatColor.RED + "Can't duel yourself");
+ return true;
+ }
+
+ if(TeamInviteManager.getManager().hasInvited(team1, team2)) {
+ player.sendMessage(ChatColor.RED + "You have already dueled that Team");
+ return true;
+ }
+
+ invite.put(team1, team2);
+
+ player.openInventory(inv.gameTypesTeam(player));
+
+ }
+
+
+
+ if(args[0].equalsIgnoreCase("accept") || args[0].equalsIgnoreCase("a")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " /team accept ");
+ return true;
+ }
+ if(!TeamManager.getManager().isInTeam(player)) {
+ player.sendMessage(ChatColor.RED + "You must be in a team to do this command");
+ return true;
+ }
+
+ Team team1 = TeamManager.getManager().getTeamByName(args[1]);
+
+ if(!TeamManager.getManager().getAllTeams().contains(team1)) {
+ player.sendMessage(ChatColor.RED + "Couldn't find that team");
+ return true;
+ }
+
+ Team team2 = TeamManager.getManager().getTeamByPlayer(player);
+
+ if(!team2.getTeamLeader().equals(player.getName())) {
+ player.sendMessage(ChatColor.RED + "Only leaders can do this command");
+ return true;
+ }
+
+ if(TeamDuelManager.getManager().isInDuel(team2)) {
+ player.sendMessage(ChatColor.RED + "Can't duel someone while in a match");
+ return true;
+ }
+
+
+ if(TeamInviteManager.getManager().hasInvited(team1, team2)) {
+ GameType game = TeamInviteManager.getManager().getTeamInvite(team1, team2).getGameType();
+ String type = TeamInviteManager.getManager().getTeamInvite(team1, team2).getType();
+
+ if(type.equalsIgnoreCase("team")) {
+ TeamDuelManager.getManager().createDuel(team1, team2, game);
+ }
+
+ if(type.equalsIgnoreCase("koth")) {
+ TeamDuelManager.getManager().createKothDuel(team1, team2, game);
+ }
+
+ TeamInviteManager.getManager().clearInvites(team1);
+ TeamInviteManager.getManager().clearInvites(team2);
+ } else {
+ player.sendMessage(ChatColor.RED + "That team has not dueled you!");
+ }
+
+ }
+
+ if(args[0].equalsIgnoreCase("info") || args[0].equalsIgnoreCase("i")) {
+ if(args.length < 2) {
+
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ if(!TeamManager.getManager().getAllTeams().contains(team)) {
+ player.sendMessage(ChatColor.RED + "Must be in a Team");
+ return true;
+ }
+
+ player.sendMessage(ChatColor.AQUA.toString() + "------" + ChatColor.BOLD + team.getTeamName() + ChatColor.AQUA + "------");
+ player.sendMessage("");
+ for(String p : team.getTeamMembers()) {
+ player.sendMessage(ChatColor.GREEN + p);
+ }
+ player.sendMessage("");
+ return true;
+ }
+
+ Player target = Bukkit.getPlayer(args[1]);
+
+ if(target == null) {
+
+ Team team = TeamManager.getManager().getTeamByName(args[1]);
+
+ if(!TeamManager.getManager().getAllTeams().contains(team)) {
+ player.sendMessage(ChatColor.RED + "Couldn't find that team");
+ return true;
+ }
+
+ player.sendMessage(ChatColor.AQUA + "Team Name: " + ChatColor.GREEN + team.getTeamName());
+
+ for(String p : team.getTeamMembers()) {
+ player.sendMessage(ChatColor.GREEN + p);
+ }
+
+ } else {
+ Team team = TeamManager.getManager().getTeamByPlayer(target);
+
+ if(!TeamManager.getManager().getAllTeams().contains(team)) {
+ player.sendMessage(ChatColor.RED + "Couldn't find that team");
+ return true;
+ }
+
+ player.sendMessage(ChatColor.AQUA + "Team Name: " + ChatColor.GREEN + team.getTeamName());
+
+ for(String p : team.getTeamMembers()) {
+ player.sendMessage(ChatColor.GREEN + p);
+ }
+ }
+ }
+
+ if(args[0].equalsIgnoreCase("end")) {
+
+ if(!player.hasPermission("iranpvp.staff")) {
+ return true;
+ }
+
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/team end (ends the duel)");
+ return true;
+ }
+
+ Player target = Bukkit.getPlayer(args[1]);
+
+ if(target == null) {
+ player.sendMessage(ChatColor.RED + "Could not find that player");
+ return true;
+ }
+
+ TeamDuelManager.getManager().endDuel(target);
+ player.sendMessage(ChatColor.RED + "Forced the Duel to Stop");
+ }
+
+ }
+
+ return true;
+ }
+}
diff --git a/src/me/iran/iranpvp/duel/Duel.java b/src/me/iran/iranpvp/duel/Duel.java
new file mode 100644
index 0000000..621d3b2
--- /dev/null
+++ b/src/me/iran/iranpvp/duel/Duel.java
@@ -0,0 +1,98 @@
+package me.iran.iranpvp.duel;
+
+import java.util.ArrayList;
+
+import me.iran.iranpvp.type.GameType;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+
+public class Duel {
+
+ private Player player1;
+ private Player player2;
+ private Player winner;
+ private GameType game;
+ private boolean ranked;
+ private ArrayList blocks;
+
+ private boolean kothStatus;
+
+ private int timer = 0;
+
+ public Duel(Player player1, Player player2, GameType game) {
+ this.player1 = player1;
+ this.player2 = player2;
+ this.game = game;
+ winner = null;
+ kothStatus = false;
+ ranked = false;
+
+ blocks = new ArrayList();
+ }
+
+ public void setRanked(boolean ranked) {
+ this.ranked = ranked;
+ }
+
+ public ArrayList getBlocks() {
+ return blocks;
+ }
+
+ public boolean isRanked() {
+ if(ranked) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public int getTimer() {
+ return timer;
+ }
+
+ public void setTimer(int timer) {
+ this.timer = timer;
+ }
+
+ public Player getPlayer1() {
+ return player1;
+ }
+
+ public Player getPlayer2() {
+ return player2;
+ }
+
+ public GameType getGameType() {
+ return this.game;
+ }
+
+ public boolean getKothStatus() {
+ return this.kothStatus;
+ }
+
+ public void setPlayer1(Player player1) {
+ this.player1 = player1;
+ }
+
+ public void setKothStatus(boolean kothStatus) {
+ this.kothStatus = kothStatus;
+ }
+
+ public void setPlayer2(Player player2) {
+ this.player2 = player2;
+ }
+
+ public void setWinner(Player winner) {
+ this.winner = winner;
+ }
+
+ public Player getWinner() {
+ return this.winner;
+ }
+
+ public void setGameType(GameType game) {
+ this.game = game;
+ }
+
+}
diff --git a/src/me/iran/iranpvp/duel/DuelManager.java b/src/me/iran/iranpvp/duel/DuelManager.java
new file mode 100644
index 0000000..5e13098
--- /dev/null
+++ b/src/me/iran/iranpvp/duel/DuelManager.java
@@ -0,0 +1,524 @@
+package me.iran.iranpvp.duel;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.Arena;
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.events.duel.DeathInventory;
+import me.iran.iranpvp.kit.KitManager;
+import me.iran.iranpvp.type.GameType;
+import me.iran.iranpvp.type.Ranked;
+import me.iran.iranpvp.type.RankedManager;
+import me.iran.iranpvp.utils.BungeeChat;
+import me.iran.iranpvp.utils.EnderpearlCooldown;
+import me.iran.iranpvp.utils.OnJoinItems;
+import me.iran.iranpvp.utils.ScoreboardUtils;
+import me.iran.iranpvp.utils.TeleportSpawn;
+import net.md_5.bungee.api.ChatColor;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+import org.bukkit.potion.PotionEffect;
+
+public class DuelManager {
+
+ IranPvP plugin;
+
+ TeleportSpawn spawn = new TeleportSpawn();
+
+ OnJoinItems item = new OnJoinItems();
+
+ KitManager km = new KitManager();
+
+ BungeeChat chat = new BungeeChat();
+
+ ScoreboardUtils sb = new ScoreboardUtils();
+
+ private static HashMap games = new HashMap<>();
+
+ private static ArrayList duels = new ArrayList<>();
+
+ private static DuelManager dm;
+
+ private DuelManager() {}
+
+
+ public static DuelManager getManager() {
+ if (dm == null)
+ dm = new DuelManager();
+
+ return dm;
+ }
+
+ public ArrayList getAllDuels() {
+ return duels;
+ }
+
+ @SuppressWarnings("deprecation")
+ public void createDuel(Player player1, Player player2, GameType game) {
+
+ if (player1 == null || player2 == null) {
+ return;
+ }
+
+ Duel duel = new Duel(player1, player2, game);
+
+ duel.setKothStatus(false);
+
+ duels.add(duel);
+
+ ArenaManager.getManager().teleportPlayers(player1, player2);
+
+ player1.setHealth(20.0);
+ player1.setFoodLevel(20);
+
+ player2.setHealth(20.0);
+ player2.setFoodLevel(20);
+
+ player1.getInventory().clear();
+ player1.getInventory().setArmorContents(null);
+
+ player2.getInventory().clear();
+ player2.getInventory().setArmorContents(null);
+
+ km.getKits(player1, game);
+ km.getKits(player2, game);
+
+/* for(Player p : Bukkit.getOnlinePlayers()) {
+ IranPvP.getHider().hideEntity(player1, p);
+ IranPvP.getHider().hideEntity(player2, p);
+ }
+
+ IranPvP.getHider().showEntity(player1, player2);
+ IranPvP.getHider().showEntity(player2, player1);*/
+
+ player1.showPlayer(player2);
+ player2.showPlayer(player1);
+
+ player1.setScoreboard(sb.duelBoard(player1));
+ player2.setScoreboard(sb.duelBoard(player2));
+
+ games.put(player1.getName(), IranPvP.plugin.getConfig().getInt("MATCH_TIMER"));
+ games.put(player2.getName(), IranPvP.plugin.getConfig().getInt("MATCH_TIMER"));
+ }
+
+ @SuppressWarnings("deprecation")
+ public void createRankedDuel(Player player1, Player player2, GameType game) {
+
+ if (player1 == null || player2 == null) {
+ return;
+ }
+
+ Duel duel = new Duel(player1, player2, game);
+
+ duel.setKothStatus(false);
+
+ duel.setRanked(true);
+
+ duels.add(duel);
+
+ ArenaManager.getManager().teleportPlayers(player1, player2);
+
+ player1.setHealth(20.0);
+ player1.setFoodLevel(20);
+
+ player2.setHealth(20.0);
+ player2.setFoodLevel(20);
+
+ player1.getInventory().clear();
+ player1.getInventory().setArmorContents(null);
+
+ player2.getInventory().clear();
+ player2.getInventory().setArmorContents(null);
+
+ km.getKits(player1, game);
+ km.getKits(player2, game);
+
+ player1.showPlayer(player2);
+ player2.showPlayer(player1);
+
+ player1.setScoreboard(sb.duelBoard(player1));
+ player2.setScoreboard(sb.duelBoard(player2));
+
+ games.put(player1.getName(), IranPvP.plugin.getConfig().getInt("MATCH_TIMER"));
+ games.put(player2.getName(), IranPvP.plugin.getConfig().getInt("MATCH_TIMER"));
+
+ }
+
+ public void endDuel(Player player) {
+ Duel duel = getDuelByPlayer(player);
+
+ if(duel == null) {
+ System.out.println("duel is null");
+ return;
+ }
+
+ Player player1 = duel.getPlayer1();
+ Player player2 = duel.getPlayer2();
+
+ if(player1 != null || player2 != null) {
+ duel.setWinner(player);
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+
+ if(arena.getSpec().contains(p.getName())) {
+ player1.showPlayer(p);
+ player2.showPlayer(p);
+ }
+ }
+
+ if(duel.getWinner() == player1) {
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(player1.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(player1.getName());
+ }
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(player2.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(player2.getName());
+ }
+
+ chat.viewInv(player1, player2);
+
+ DeathInventory.getTimer().put(player1.getName(), 30);
+ DeathInventory.getInv().put(player1.getName(), player.getInventory().getContents());
+ DeathInventory.getArmor().put(player1.getName(), player.getInventory().getArmorContents());
+ DeathInventory.getPots().put(player1.getName(), new ArrayList());
+ DeathInventory.getHealth().put(player.getName(), ((CraftPlayer) player).getHealth());
+
+ for(Iterator it = player1.getActivePotionEffects().iterator(); it.hasNext();) {
+
+ PotionEffect potion = it.next();
+ String info = ChatColor.GOLD + potion.getType().getName() + ": " + potion.getDuration();
+
+ DeathInventory.getPots().get(player1.getName()).add(info);
+ }
+
+ player1.setHealth(20.0);
+ player1.setFoodLevel(20);
+
+ for(PotionEffect effect : player1.getActivePotionEffects()) {
+ player1.removePotionEffect(effect.getType());
+ }
+
+ for(PotionEffect effect : player2.getActivePotionEffects()) {
+ player2.removePotionEffect(effect.getType());
+ }
+
+ spawn.teleportSpawn(player1);
+
+ } else if(duel.getWinner() == player2) {
+
+ DeathInventory.getTimer().put(player2.getName(), 30);
+ DeathInventory.getInv().put(player2.getName(), player.getInventory().getContents());
+ DeathInventory.getArmor().put(player2.getName(), player.getInventory().getArmorContents());
+ DeathInventory.getPots().put(player2.getName(), new ArrayList());
+ DeathInventory.getHealth().put(player.getName(), ((CraftPlayer) player).getHealth());
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(player1.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(player1.getName());
+ }
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(player2.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(player2.getName());
+ }
+
+ for(Iterator it = player2.getActivePotionEffects().iterator(); it.hasNext();) {
+
+ PotionEffect potion = it.next();
+ String info = ChatColor.GOLD + potion.getType().getName() + ": " + potion.getDuration();
+
+ DeathInventory.getPots().get(player2.getName()).add(info);
+ }
+
+ chat.viewInv(player2, player1);
+
+ player2.setHealth(20.0);
+ player2.setFoodLevel(20);
+
+ for(PotionEffect effect : player1.getActivePotionEffects()) {
+ player1.removePotionEffect(effect.getType());
+ }
+
+ for(PotionEffect effect : player2.getActivePotionEffects()) {
+ player2.removePotionEffect(effect.getType());
+ }
+
+ spawn.teleportSpawn(player2);
+ }
+
+
+ if(duel.getWinner() == player1) {
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getSpec().contains(p.getName())) {
+ chat.viewInvSpec(player1, player2, p);
+ }
+ }
+
+ } else if(duel.getWinner() == player2) {
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getSpec().contains(p.getName())) {
+ chat.viewInvSpec(player2, player1, p);
+ }
+ }
+
+ }
+
+ player1.setFireTicks(0);
+ player2.setFireTicks(0);
+
+ ArenaManager.getManager().removePlayer(player);
+
+ for(Location loc : duel.getBlocks()) {
+
+ loc.getBlock().setType(Material.AIR);
+ }
+
+ duels.remove(duel);
+ }
+
+ public void endRankedDuel(Player player) {
+ Duel duel = getDuelByPlayer(player);
+
+ if(duel == null) {
+ System.out.println("duel is null");
+ return;
+ }
+
+ Player player1 = duel.getPlayer1();
+ Player player2 = duel.getPlayer2();
+
+ if(player1 != null || player2 != null) {
+ duel.setWinner(player);
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+
+ if(arena.getSpec().contains(p.getName())) {
+ player1.showPlayer(p);
+ player2.showPlayer(p);
+ }
+ }
+
+ ArenaManager.getManager().removePlayer(player);
+
+ if(duel.getWinner() == player1) {
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(player1.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(player1.getName());
+ }
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(player2.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(player2.getName());
+ }
+
+ chat.viewInv(player1, player2);
+
+ DeathInventory.getTimer().put(player1.getName(), 30);
+ DeathInventory.getInv().put(player1.getName(), player.getInventory().getContents());
+ DeathInventory.getArmor().put(player1.getName(), player.getInventory().getArmorContents());
+ DeathInventory.getPots().put(player1.getName(), new ArrayList());
+ DeathInventory.getHealth().put(player.getName(), ((CraftPlayer) player).getHealth());
+
+ for(Iterator it = player1.getActivePotionEffects().iterator(); it.hasNext();) {
+
+ PotionEffect potion = it.next();
+ String info = ChatColor.GOLD + potion.getType().getName() + ": " + potion.getDuration();
+
+ DeathInventory.getPots().get(player1.getName()).add(info);
+ }
+
+ player1.setHealth(20.0);
+ player1.setFoodLevel(20);
+
+ for(PotionEffect effect : player1.getActivePotionEffects()) {
+ player1.removePotionEffect(effect.getType());
+ }
+
+ for(PotionEffect effect : player2.getActivePotionEffects()) {
+ player2.removePotionEffect(effect.getType());
+ }
+
+ GameType game = duel.getGameType();
+
+ Ranked rank1 = RankedManager.getManager().getRank(player1, game);
+
+ Ranked rank2 = RankedManager.getManager().getRank(player2, game);
+
+
+ double calc = 1.0 / (1.0 + Math.pow(10.0, (rank2.getElo() - rank1.getElo()) / 400.0));
+ int elo = (int) Math.round(5 * (3 - calc));
+
+ rank1.setElo(rank1.getElo() + elo);
+
+ rank2.setElo(rank2.getElo() - elo);
+
+ player1.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.LINE")));
+ player1.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.MESSAGE_1").replace("%gametype%", duel.getGameType().getName()).replace("%winner%", player1.getName()).replace("%elo%", "" + elo).replace("%newelo%", "" + (rank1.getElo()))));
+ player1.sendMessage("");
+ player1.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.MESSAGE_2").replace("%gametype%", duel.getGameType().getName()).replace("%loser%", player2.getName()).replace("%elo%", "" + elo).replace("%newelo%", "" + (rank2.getElo()))));
+ player1.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.LINE")));
+
+
+ player2.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.LINE")));
+ player2.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.MESSAGE_1").replace("%gametype%", duel.getGameType().getName()).replace("%winner%", player1.getName()).replace("%elo%", "" + elo).replace("%newelo%", "" + (rank1.getElo()))));
+ player2.sendMessage("");
+ player2.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.MESSAGE_2").replace("%gametype%", duel.getGameType().getName()).replace("%loser%", player2.getName()).replace("%elo%", "" + elo).replace("%newelo%", "" + (rank2.getElo()))));
+ player2.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.LINE")));
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getSpec().contains(p.getName())) {
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.LINE")));
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.MESSAGE_1").replace("%gametype%", duel.getGameType().getName()).replace("%winner%", player2.getName()).replace("%elo%", "" + elo).replace("%newelo%", "" + (rank2.getElo()))));
+ p.sendMessage("");
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.MESSAGE_2").replace("%gametype%", duel.getGameType().getName()).replace("%loser%", player1.getName()).replace("%elo%", "" + elo).replace("%newelo%", "" + (rank1.getElo()))));
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.LINE")));
+
+ }
+ }
+
+ spawn.teleportSpawn(player1);
+
+ } else if(duel.getWinner() == player2) {
+
+ DeathInventory.getTimer().put(player2.getName(), 30);
+ DeathInventory.getInv().put(player2.getName(), player.getInventory().getContents());
+ DeathInventory.getArmor().put(player2.getName(), player.getInventory().getArmorContents());
+ DeathInventory.getPots().put(player2.getName(), new ArrayList());
+ DeathInventory.getHealth().put(player.getName(), ((CraftPlayer) player).getHealth());
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(player1.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(player1.getName());
+ }
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(player2.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(player2.getName());
+ }
+
+ for(Iterator it = player2.getActivePotionEffects().iterator(); it.hasNext();) {
+
+ PotionEffect potion = it.next();
+ String info = ChatColor.GOLD + potion.getType().getName() + ": " + potion.getDuration();
+
+ DeathInventory.getPots().get(player2.getName()).add(info);
+ }
+
+ chat.viewInv(player2, player1);
+
+ player2.setHealth(20.0);
+ player2.setFoodLevel(20);
+
+ for(PotionEffect effect : player1.getActivePotionEffects()) {
+ player1.removePotionEffect(effect.getType());
+ }
+
+ for(PotionEffect effect : player2.getActivePotionEffects()) {
+ player2.removePotionEffect(effect.getType());
+ }
+
+ GameType game = duel.getGameType();
+
+ Ranked rank1 = RankedManager.getManager().getRank(player1, game);
+
+ Ranked rank2 = RankedManager.getManager().getRank(player2, game);
+
+ double calc = 1.0 / (1.0 + Math.pow(10.0, (rank1.getElo() - rank2.getElo()) / 400.0));
+ int elo = (int) Math.round(5 * (3 - calc));
+
+ rank1.setElo(rank1.getElo() - elo);
+
+ rank2.setElo(rank2.getElo() + elo);
+
+ player1.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.LINE")));
+ player1.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.MESSAGE_1").replace("%gametype%", duel.getGameType().getName()).replace("%winner%", player2.getName()).replace("%elo%", "" + elo).replace("%newelo%", "" + (rank2.getElo()))));
+ player1.sendMessage("");
+ player1.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.MESSAGE_2").replace("%gametype%", duel.getGameType().getName()).replace("%loser%", player1.getName()).replace("%elo%", "" + elo).replace("%newelo%", "" + (rank1.getElo()))));
+ player1.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.LINE")));
+
+
+ player2.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.LINE")));
+ player2.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.MESSAGE_1").replace("%gametype%", duel.getGameType().getName()).replace("%winner%", player2.getName()).replace("%elo%", "" + elo).replace("%newelo%", "" + (rank2.getElo()))));
+ player2.sendMessage("");
+ player2.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.MESSAGE_2").replace("%gametype%", duel.getGameType().getName()).replace("%loser%", player1.getName()).replace("%elo%", "" + elo).replace("%newelo%", "" + (rank1.getElo()))));
+ player2.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.LINE")));
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getSpec().contains(p.getName())) {
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.LINE")));
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.MESSAGE_1").replace("%gametype%", duel.getGameType().getName()).replace("%winner%", player2.getName()).replace("%elo%", "" + elo).replace("%newelo%", "" + (rank2.getElo()))));
+ p.sendMessage("");
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.MESSAGE_2").replace("%gametype%", duel.getGameType().getName()).replace("%loser%", player1.getName()).replace("%elo%", "" + elo).replace("%newelo%", "" + (rank1.getElo()))));
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MESSAGE.LINE")));
+
+ }
+ }
+
+ spawn.teleportSpawn(player2);
+ }
+
+ if(duel.getWinner() == player1) {
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getSpec().contains(p.getName())) {
+ chat.viewInvSpec(player1, player2, p);
+
+ }
+ }
+
+ } else if(duel.getWinner() == player2) {
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getSpec().contains(p.getName())) {
+ chat.viewInvSpec(player2, player1, p);
+ }
+ }
+
+ }
+
+ player1.setFireTicks(0);
+ player2.setFireTicks(0);
+
+ for(Location loc : duel.getBlocks()) {
+
+ loc.getBlock().setType(Material.AIR);
+ }
+
+ duels.remove(duel);
+ }
+
+ public Duel getDuelByPlayer(Player player) {
+ for(Duel duel : duels) {
+ if(duel.getPlayer1() == player || duel.getPlayer2() == player) {
+ return duel;
+ }
+ }
+
+ return null;
+ }
+
+ public boolean isInDuel(Player player) {
+ for(Duel duel : duels) {
+ if(duel.getPlayer1().equals(player) || duel.getPlayer2().equals(player)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public HashMap getGames() {
+ return games;
+ }
+
+}
diff --git a/src/me/iran/iranpvp/duel/InvitePlayer.java b/src/me/iran/iranpvp/duel/InvitePlayer.java
new file mode 100644
index 0000000..937fa35
--- /dev/null
+++ b/src/me/iran/iranpvp/duel/InvitePlayer.java
@@ -0,0 +1,42 @@
+package me.iran.iranpvp.duel;
+
+import me.iran.iranpvp.type.GameType;
+
+public class InvitePlayer {
+
+ String player1;
+ String player2;
+
+ GameType game;
+
+ public InvitePlayer(String player1, String player2, GameType game) {
+ this.player1= player1;
+ this.player2 = player2;
+ this.game = game;
+ }
+
+ public void setPlayer1(String player1) {
+ this.player1= player1;
+ }
+
+ public void setPlayer2(String player2) {
+ this.player2 = player2;
+ }
+
+ public void setGameType(GameType game) {
+ this.game = game;
+ }
+
+ public String getPlayer1() {
+ return this.player1;
+ }
+
+ public String getPlayer2() {
+ return this.player2;
+ }
+
+ public GameType getGameType() {
+ return this.game;
+ }
+
+}
diff --git a/src/me/iran/iranpvp/duel/InvitePlayerManager.java b/src/me/iran/iranpvp/duel/InvitePlayerManager.java
new file mode 100644
index 0000000..b841c0d
--- /dev/null
+++ b/src/me/iran/iranpvp/duel/InvitePlayerManager.java
@@ -0,0 +1,104 @@
+package me.iran.iranpvp.duel;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import me.iran.iranpvp.type.GameType;
+import me.iran.iranpvp.utils.BungeeChat;
+
+import org.bukkit.entity.Player;
+
+public class InvitePlayerManager {
+
+ private static ArrayList invites = new ArrayList<>();
+
+ BungeeChat chat = new BungeeChat();
+
+ private static InvitePlayerManager im;
+
+ private InvitePlayerManager() {}
+
+ public static InvitePlayerManager getManager() {
+ if (im == null)
+ im = new InvitePlayerManager();
+
+ return im;
+ }
+
+ public void createInvite(Player player1, Player player2, GameType game) {
+ InvitePlayer invite = new InvitePlayer(player1.getName(), player2.getName(), game);
+
+ if(hasInvited(player1, player2)) {
+ return;
+ }
+
+ invites.add(invite);
+
+ chat.acceptPlayer(player1, player2, game.getName());
+ }
+
+
+ public void deleteInvites(Player player1, Player player2) {
+
+ Iterator iter = invites.iterator();
+
+ while(iter.hasNext()) {
+ InvitePlayer invite = (InvitePlayer) iter.next();
+
+ if(invite.getPlayer1().equals(player1.getName()) || invite.getPlayer2().equals(player2.getName())) {
+ invite.setGameType(null);
+ invite.setPlayer1(null);
+ invite.setPlayer2(null);
+ invites.remove(invite);
+ }
+
+ }
+
+ }
+
+ public InvitePlayer getPlayerInvites(Player player1, Player player2) {
+ for(InvitePlayer invite : invites) {
+ if(invite.getPlayer1().equals(player1.getName()) && invite.getPlayer2().equals(player2.getName())) {
+ return invite;
+ }
+ }
+
+ return null;
+ }
+
+ public boolean hasInvited(Player player1, Player player2) {
+
+ InvitePlayer invite = getPlayerInvites(player1, player2);
+
+ if(!invites.contains(invite)) {
+ return false;
+ }
+
+ if(invite.getPlayer1().equals(player1.getName()) && invite.getPlayer2().equals(player2.getName())) {
+ return true;
+ }
+
+ return false;
+
+ }
+
+ public void clearInvites(Player player) {
+
+ for(int i = 0; i < invites.size(); i++) {
+ InvitePlayer invite = invites.get(i);
+
+ if(invite.getPlayer1().equals(player.getName()) || invite.getPlayer2().equals(player.getName())) {
+ invite.setGameType(null);
+ invite.setPlayer1(null);
+ invite.setPlayer2(null);
+
+ invites.remove(invite);
+ }
+ }
+
+ }
+
+ public ArrayList getAllInvites() {
+ return invites;
+ }
+}
diff --git a/src/me/iran/iranpvp/duel/team/TeamDuel.java b/src/me/iran/iranpvp/duel/team/TeamDuel.java
new file mode 100644
index 0000000..0c53c58
--- /dev/null
+++ b/src/me/iran/iranpvp/duel/team/TeamDuel.java
@@ -0,0 +1,63 @@
+package me.iran.iranpvp.duel.team;
+
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.type.GameType;
+
+public class TeamDuel {
+
+ Team Team1;
+ Team Team2;
+ Team winner;
+ GameType game;
+
+ boolean kothStatus;
+
+ public TeamDuel(Team Team1, Team Team2, GameType game) {
+ this.Team1 = Team1;
+ this.Team2 = Team2;
+ this.game = game;
+ winner = null;
+ kothStatus = false;
+ }
+
+ public Team getTeam1() {
+ return Team1;
+ }
+
+ public Team getTeam2() {
+ return Team2;
+ }
+
+ public GameType getGameType() {
+ return this.game;
+ }
+
+ public boolean getKothStatus() {
+ return this.kothStatus;
+ }
+
+ public void setTeam1(Team Team1) {
+ this.Team1 = Team1;
+ }
+
+ public void setKothStatus(boolean kothStatus) {
+ this.kothStatus = kothStatus;
+ }
+
+ public void setTeam2(Team Team2) {
+ this.Team2 = Team2;
+ }
+
+ public void setWinner(Team winner) {
+ this.winner = winner;
+ }
+
+ public Team getWinner() {
+ return this.winner;
+ }
+
+ public void setGameType(GameType game) {
+ this.game = game;
+ }
+
+}
diff --git a/src/me/iran/iranpvp/duel/team/TeamDuelManager.java b/src/me/iran/iranpvp/duel/team/TeamDuelManager.java
new file mode 100644
index 0000000..99762fc
--- /dev/null
+++ b/src/me/iran/iranpvp/duel/team/TeamDuelManager.java
@@ -0,0 +1,512 @@
+package me.iran.iranpvp.duel.team;
+
+import java.util.ArrayList;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.Arena;
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.events.teamfight.KothDeathEvent;
+import me.iran.iranpvp.kit.KitManager;
+import me.iran.iranpvp.runnable.Run;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.type.GameType;
+import me.iran.iranpvp.utils.EnderpearlCooldown;
+import me.iran.iranpvp.utils.OnJoinItems;
+import me.iran.iranpvp.utils.ScoreboardUtils;
+import me.iran.iranpvp.utils.TeleportSpawn;
+import net.md_5.bungee.api.ChatColor;
+
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.scoreboard.DisplaySlot;
+
+public class TeamDuelManager {
+
+ IranPvP plugin;
+
+ ScoreboardUtils sb = new ScoreboardUtils();
+
+ private static ArrayList duels = new ArrayList<>();
+
+ private static TeamDuelManager tdm;
+ private TeamDuelManager() {}
+
+
+ public static TeamDuelManager getManager() {
+ if (tdm == null)
+ tdm = new TeamDuelManager();
+
+ return tdm;
+ }
+
+ public ArrayList getAllDuels() {
+ return duels;
+ }
+
+
+ Run run = new Run(plugin);
+ OnJoinItems items = new OnJoinItems();
+ TeleportSpawn spawn = new TeleportSpawn();
+ KitManager km = new KitManager();
+
+ @SuppressWarnings("deprecation")
+ public void createKothDuel(Team team1, Team team2, GameType game) {
+
+ if (team1 == null || team2 == null) {
+ return;
+ }
+
+ TeamDuel duel = new TeamDuel(team1, team2, game);
+
+ duel.setKothStatus(true);
+
+ duels.add(duel);
+
+ ArenaManager.getManager().teleportKothTeams(team1, team2);
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team1.getTeamMembers().contains(p.getName())) {
+ p.getInventory().clear();
+ p.getInventory().setArmorContents(null);
+
+ p.setScoreboard(sb.setKOTHBoard(p));
+
+ p.setHealth(20.0);
+ p.setFoodLevel(20);
+
+ km.getKits(p, game);
+
+ KothDeathEvent.getLives().put(p.getName(), IranPvP.plugin.getConfig().getInt("KOTH.LIVES"));
+
+ for(Player pl : Bukkit.getOnlinePlayers()) {
+ if(team2.getTeamMembers().contains(pl.getName())) {
+ p.showPlayer(pl);
+ pl.showPlayer(pl);
+ }
+ }
+
+ }
+
+ if(team2.getTeamMembers().contains(p.getName())) {
+
+ p.getInventory().clear();
+ p.getInventory().setArmorContents(null);
+
+ p.setScoreboard(sb.setKOTHBoard(p));
+
+ p.setHealth(20.0);
+ p.setFoodLevel(20);
+
+ KothDeathEvent.getLives().put(p.getName(), IranPvP.plugin.getConfig().getInt("KOTH.LIVES"));
+
+ km.getKits(p, game);
+
+ for(Player pl : Bukkit.getOnlinePlayers()) {
+ if(team1.getTeamMembers().contains(pl.getName())) {
+ p.showPlayer(pl);
+ pl.showPlayer(pl);
+ }
+ }
+
+ }
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ public void createDuel(Team team1, Team team2, GameType game) {
+
+ if (team1 == null || team2 == null) {
+ return;
+ }
+
+ TeamDuel duel = new TeamDuel(team1, team2, game);
+
+ duel.setKothStatus(false);
+
+ duels.add(duel);
+
+ ArenaManager.getManager().teleportTeams(team1, team2);
+
+ TeamFightManager.getManager().createTeamFight(team1, team2);
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team1.getTeamMembers().contains(p.getName())) {
+ p.getInventory().clear();
+ p.getInventory().setArmorContents(null);
+
+ p.setHealth(20.0);
+ p.setFoodLevel(20);
+
+ p.setScoreboard(sb.setBoard(p));
+
+ km.getKits(p, game);
+
+ for(Player pl : Bukkit.getOnlinePlayers()) {
+ if(team2.getTeamMembers().contains(pl.getName())) {
+ p.showPlayer(pl);
+ pl.showPlayer(pl);
+ }
+ }
+ }
+
+ if(team2.getTeamMembers().contains(p.getName())) {
+ p.getInventory().clear();
+ p.getInventory().setArmorContents(null);
+
+ p.setHealth(20.0);
+ p.setFoodLevel(20);
+
+ p.setScoreboard(sb.setBoard(p));
+
+ km.getKits(p, game);
+
+ for(Player pl : Bukkit.getOnlinePlayers()) {
+ if(team1.getTeamMembers().contains(pl.getName())) {
+ p.showPlayer(pl);
+ pl.showPlayer(pl);
+ }
+ }
+ }
+ }
+ }
+
+ public void endDuel(Player player) {
+ TeamDuel duel = getDuelByPlayer(player);
+
+ if (duel == null) {
+ System.out.println("duel is null");
+ return;
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getSpec().contains(p.getName())) {
+ for(String pl : duel.getTeam1().getTeamMembers()) {
+ Player team1Players = Bukkit.getPlayer(pl);
+ team1Players.showPlayer(p);
+ }
+
+ for(String pl : duel.getTeam2().getTeamMembers()) {
+ Player team2Players = Bukkit.getPlayer(pl);
+ team2Players.showPlayer(p);
+ }
+ }
+ }
+
+ if(!ArenaManager.getManager().getAllArena().contains(arena)) {
+ return;
+ }
+
+ Team team1 = duel.getTeam1();
+ Team team2 = duel.getTeam2();
+
+ if (team1 != null || team2 != null) {
+
+ if (team1.getTeamMembers().contains(player.getName())) {
+
+ duel.setWinner(team1);
+
+ for (Player p : Bukkit.getOnlinePlayers()) {
+
+ if (team1.getTeamMembers().contains(p.getName())) {
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(p.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(p.getName());
+ }
+
+ p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ p.sendMessage("");
+ p.sendMessage(ChatColor.GREEN + "You have won against Team " + ChatColor.RED + team2.getTeamName());
+ p.sendMessage("");
+
+ p.setFireTicks(0);
+
+ p.setAllowFlight(false);
+
+ for(PotionEffect effect : p.getActivePotionEffects()) {
+ p.removePotionEffect(effect.getType());
+ }
+
+ p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ }
+
+ if (team2.getTeamMembers().contains(p.getName())) {
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(p.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(p.getName());
+ }
+
+ p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ p.sendMessage("");
+ p.sendMessage(ChatColor.RED + "Team " + ChatColor.GOLD + team1.getTeamName() + ChatColor.RED + " has defeated you!");
+ p.sendMessage("");
+
+ p.setFireTicks(0);
+
+ p.setAllowFlight(false);
+
+ for(PotionEffect effect : p.getActivePotionEffects()) {
+ p.removePotionEffect(effect.getType());
+ }
+
+ p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ }
+
+ }
+
+ } else if (team2.getTeamMembers().contains(player.getName())) {
+
+ duel.setWinner(team2);
+
+ for (Player p : Bukkit.getOnlinePlayers()) {
+
+ if (team2.getTeamMembers().contains(p.getName())) {
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(p.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(p.getName());
+ }
+
+ p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ p.sendMessage("");
+ p.sendMessage(ChatColor.GREEN + "You have won against Team " + ChatColor.RED + team1.getTeamName());
+ p.sendMessage("");
+
+ p.setFireTicks(0);
+
+ p.setAllowFlight(false);
+
+ for(PotionEffect effect : p.getActivePotionEffects()) {
+ p.removePotionEffect(effect.getType());
+ }
+
+
+ }
+
+ if (team1.getTeamMembers().contains(p.getName())) {
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(p.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(p.getName());
+ }
+
+ p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ p.sendMessage("");
+ p.sendMessage(ChatColor.RED + "Team " + ChatColor.GOLD + team2.getTeamName() + ChatColor.RED + " has defeated you!");
+ p.sendMessage("");
+
+ p.setFireTicks(0);
+
+ p.setAllowFlight(false);
+
+ for(PotionEffect effect : p.getActivePotionEffects()) {
+ p.removePotionEffect(effect.getType());
+ }
+
+ }
+
+
+ }
+ }
+
+ ArenaManager.getManager().removeTeams(player);
+
+ duels.remove(duel);
+
+ }
+
+ }
+
+ public void forceEnd(Player player) {
+ TeamDuel duel = getDuelByPlayer(player);
+
+ if (duel == null) {
+ System.out.println("duel is null");
+ return;
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getSpec().contains(p.getName())) {
+ for(String pl : duel.getTeam1().getTeamMembers()) {
+ Player team1Players = Bukkit.getPlayer(pl);
+ team1Players.showPlayer(p);
+ }
+
+ for(String pl : duel.getTeam2().getTeamMembers()) {
+ Player team2Players = Bukkit.getPlayer(pl);
+ team2Players.showPlayer(p);
+ }
+ }
+ }
+
+ if(!ArenaManager.getManager().getAllArena().contains(arena)) {
+ return;
+ }
+
+ Team team1 = duel.getTeam1();
+ Team team2 = duel.getTeam2();
+
+ if (team1 != null || team2 != null) {
+
+ if (team1.getTeamMembers().contains(player.getName())) {
+
+ duel.setWinner(team1);
+
+ for (Player p : Bukkit.getOnlinePlayers()) {
+
+ if (team1.getTeamMembers().contains(p.getName())) {
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(p.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(p.getName());
+ }
+
+ p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ p.sendMessage("");
+ p.sendMessage(ChatColor.GREEN + "You have won against Team " + ChatColor.RED + team2.getTeamName());
+ p.sendMessage("");
+
+ p.setFireTicks(0);
+
+ p.setAllowFlight(false);
+
+ for(PotionEffect effect : p.getActivePotionEffects()) {
+ p.removePotionEffect(effect.getType());
+ }
+
+ p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ }
+
+ if (team2.getTeamMembers().contains(p.getName())) {
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(p.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(p.getName());
+ }
+
+ p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ p.sendMessage("");
+ p.sendMessage(ChatColor.RED + "Team " + ChatColor.GOLD + team1.getTeamName() + ChatColor.RED + " has defeated you!");
+ p.sendMessage("");
+
+ p.setFireTicks(0);
+
+ p.setAllowFlight(false);
+
+ for(PotionEffect effect : p.getActivePotionEffects()) {
+ p.removePotionEffect(effect.getType());
+ }
+
+ p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ }
+
+ }
+
+ } else if (team2.getTeamMembers().contains(player.getName())) {
+
+ duel.setWinner(team2);
+
+ for (Player p : Bukkit.getOnlinePlayers()) {
+
+ if (team2.getTeamMembers().contains(p.getName())) {
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(p.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(p.getName());
+ }
+
+ p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ p.sendMessage("");
+ p.sendMessage(ChatColor.GREEN + "You have won against Team " + ChatColor.RED + team1.getTeamName());
+ p.sendMessage("");
+
+ p.setFireTicks(0);
+
+ p.setAllowFlight(false);
+
+ for(PotionEffect effect : p.getActivePotionEffects()) {
+ p.removePotionEffect(effect.getType());
+ }
+
+
+ }
+
+ if (team1.getTeamMembers().contains(p.getName())) {
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(p.getName())) {
+ EnderpearlCooldown.getEnderpearl().remove(p.getName());
+ }
+
+ p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ p.sendMessage("");
+ p.sendMessage(ChatColor.RED + "Team " + ChatColor.GOLD + team2.getTeamName() + ChatColor.RED + " has defeated you!");
+ p.sendMessage("");
+
+ p.setFireTicks(0);
+
+ p.setAllowFlight(false);
+
+ for(PotionEffect effect : p.getActivePotionEffects()) {
+ p.removePotionEffect(effect.getType());
+ }
+
+
+ }
+
+
+ }
+ }
+
+ ArenaManager.getManager().removeTeams(player);
+
+ duels.remove(duel);
+
+ }
+
+ }
+
+ public TeamDuel getDuelByTeam(Team team) {
+ for(TeamDuel duel : duels) {
+ if(duel.getTeam1() == team || duel.getTeam2() == team) {
+ return duel;
+ }
+ }
+
+ return null;
+ }
+
+ public TeamDuel getDuelByPlayer(Player player) {
+
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ for(TeamDuel duel : duels) {
+ if(duel.getTeam1() == team || duel.getTeam2() == team) {
+ return duel;
+ }
+ }
+
+ return null;
+ }
+
+ public boolean isInDuel(Team team) {
+
+ for(TeamDuel duel : duels) {
+ if(duel.getTeam1() == team || duel.getTeam2() == team) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/me/iran/iranpvp/duel/team/TeamFight.java b/src/me/iran/iranpvp/duel/team/TeamFight.java
new file mode 100644
index 0000000..b0030b0
--- /dev/null
+++ b/src/me/iran/iranpvp/duel/team/TeamFight.java
@@ -0,0 +1,70 @@
+package me.iran.iranpvp.duel.team;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import me.iran.iranpvp.teams.Team;
+
+public class TeamFight {
+
+ Team team1;
+ Team team2;
+
+ List aliveTeam1;
+ List aliveTeam2;
+
+ public TeamFight(Team team1, Team team2) {
+ aliveTeam1 = new ArrayList<>();
+ aliveTeam2 = new ArrayList<>();
+
+ this.team1 = team1;
+ this.team2 = team2;
+ }
+
+ public Team getTeam1() {
+ return this.team1;
+ }
+
+ public Team getTeam2() {
+ return this.team2;
+ }
+
+ public void setTeam1(Team team1) {
+ this.team1 = team1;
+ }
+
+ public void setTeam2(Team team2) {
+ this.team2 = team2;
+ }
+
+ public void removePlayerTeam1(String name) {
+ aliveTeam1.remove(name);
+ }
+
+ public void removePlayerTeam2(String name) {
+ aliveTeam2.remove(name);
+ }
+
+ public void setAliveTeam1(List list) {
+ this.aliveTeam1 = list;
+ }
+
+ public void setAliveTeam2(List list) {
+ this.aliveTeam2 = list;
+ }
+
+ public List getAliveTeam1() {
+ return this.aliveTeam1;
+ }
+
+ public List getAliveTeam2() {
+ return this.aliveTeam2;
+ }
+
+ public boolean isAlive(String name) {
+ if(aliveTeam1.contains(name) || aliveTeam2.contains(name)) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/me/iran/iranpvp/duel/team/TeamFightManager.java b/src/me/iran/iranpvp/duel/team/TeamFightManager.java
new file mode 100644
index 0000000..f4179c4
--- /dev/null
+++ b/src/me/iran/iranpvp/duel/team/TeamFightManager.java
@@ -0,0 +1,92 @@
+package me.iran.iranpvp.duel.team;
+
+import java.util.ArrayList;
+
+import me.iran.iranpvp.teams.Team;
+
+import org.bukkit.entity.Player;
+
+public class TeamFightManager {
+
+ public static ArrayList fights = new ArrayList<>();
+
+
+ private static TeamFightManager fm;
+
+ private TeamFightManager() {}
+
+ public static TeamFightManager getManager() {
+ if (fm == null)
+ fm = new TeamFightManager();
+
+ return fm;
+ }
+
+ public void createTeamFight(Team team1, Team team2) {
+ TeamFight fight = new TeamFight(team1, team2);
+
+ for(String p : team1.getTeamMembers()) {
+ fight.getAliveTeam1().add(p);
+ }
+
+ for(String p : team2.getTeamMembers()) {
+ fight.getAliveTeam2().add(p);
+ }
+
+ fights.add(fight);
+ }
+
+ public void deleteTeamFight(Player player) {
+ TeamFight fight = getFightByPlayer(player);
+
+ if(fights.contains(fight)) {
+ fights.remove(fight);
+ }
+ }
+
+ public boolean inTeamFight(Team team) {
+ for(TeamFight fight : fights) {
+ if(fight.getTeam1() == team || fight.getTeam2() == team) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public Team getPlayerTeam(Player player) {
+ for(TeamFight fight : fights) {
+ if(fight.getTeam1().getTeamMembers().contains(player.getName())) {
+ return fight.getTeam1();
+
+ } else if (fight.getTeam2().getTeamMembers().contains(player.getName())) {
+ return fight.getTeam2();
+ }
+ }
+
+ return null;
+ }
+
+ public TeamFight getFightByPlayer(Player player) {
+ for(TeamFight fight : fights) {
+ if(fight.getTeam1().getTeamMembers().contains(player.getName()) || fight.getTeam2().getTeamMembers().contains(player.getName())) {
+ return fight;
+ }
+ }
+
+ return null;
+ }
+
+ public TeamFight getFightByTeam(Team team) {
+ for(TeamFight fight : fights) {
+ if(fight.getTeam1() == team || fight.getTeam2() == team) {
+ return fight;
+ }
+ }
+ return null;
+ }
+
+ public ArrayList getAllTeamFights() {
+ return fights;
+ }
+}
diff --git a/src/me/iran/iranpvp/duel/team/TeamInvite.java b/src/me/iran/iranpvp/duel/team/TeamInvite.java
new file mode 100644
index 0000000..b57c961
--- /dev/null
+++ b/src/me/iran/iranpvp/duel/team/TeamInvite.java
@@ -0,0 +1,51 @@
+package me.iran.iranpvp.duel.team;
+
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.type.GameType;
+
+public class TeamInvite {
+
+ private Team team1;
+ private Team team2;
+ private String type;
+ private GameType gametype;
+
+ public TeamInvite(Team team1, Team team2, GameType gametype, String type) {
+ this.team1 = team1;
+ this.team2 = team2;
+ this.type = type;
+ this.gametype = gametype;
+ }
+
+ public void setTeam1(Team team1) {
+ this.team1 = team1;
+ }
+
+ public void setTeam2(Team team2) {
+ this.team2 = team2;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setGameType(GameType gametype) {
+ this.gametype = gametype;
+ }
+
+ public Team getTeam1() {
+ return this.team1;
+ }
+
+ public Team getTeam2() {
+ return this.team2;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public GameType getGameType() {
+ return this.gametype;
+ }
+}
diff --git a/src/me/iran/iranpvp/duel/team/TeamInviteManager.java b/src/me/iran/iranpvp/duel/team/TeamInviteManager.java
new file mode 100644
index 0000000..7fbdbdb
--- /dev/null
+++ b/src/me/iran/iranpvp/duel/team/TeamInviteManager.java
@@ -0,0 +1,76 @@
+package me.iran.iranpvp.duel.team;
+
+import java.util.ArrayList;
+
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.type.GameType;
+
+public class TeamInviteManager {
+
+ public static ArrayList invites = new ArrayList<>();
+
+ private static TeamInviteManager ti;
+
+ private TeamInviteManager() {}
+
+ public static TeamInviteManager getManager() {
+ if (ti == null)
+ ti = new TeamInviteManager();
+
+ return ti;
+ }
+
+ public void createInvite(Team team1, Team team2, GameType gametype, String type) {
+
+ if(invites.contains(getTeamInvite(team1, team2))) {
+ return;
+ }
+
+ TeamInvite invite = new TeamInvite(team1, team2, gametype, type);
+
+ invites.add(invite);
+
+ }
+
+ public TeamInvite getTeamInvite(Team team1, Team team2) {
+ for(TeamInvite invite : invites) {
+ if(invite.getTeam1().equals(team1) && invite.getTeam2().equals(team2)) {
+ return invite;
+ }
+ }
+ return null;
+ }
+
+ public boolean hasInvited(Team team1, Team team2) {
+
+ TeamInvite invite = getTeamInvite(team1, team2);
+
+ if(!invites.contains(invite)) {
+ return false;
+ }
+
+ if(invite.getTeam1().equals(team1) && invite.getTeam2().equals(team2)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public void clearInvites(Team team) {
+
+ for(int i = 0; i < invites.size(); i++) {
+ TeamInvite invite = invites.get(i);
+
+ if(invite.getTeam1().equals(team) || invite.getTeam2().equals(team)) {
+ invite.setGameType(null);
+ invite.setTeam1(null);
+ invite.setTeam2(null);
+ invite.setType(null);
+
+ invites.remove(invite);
+ }
+ }
+
+ }
+
+}
diff --git a/src/me/iran/iranpvp/events/duel/ClickDuelInventoryEvent.java b/src/me/iran/iranpvp/events/duel/ClickDuelInventoryEvent.java
new file mode 100644
index 0000000..0d2bb14
--- /dev/null
+++ b/src/me/iran/iranpvp/events/duel/ClickDuelInventoryEvent.java
@@ -0,0 +1,161 @@
+package me.iran.iranpvp.events.duel;
+
+import java.util.HashMap;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.cmd.pvp.PvPCommands;
+import me.iran.iranpvp.duel.InvitePlayerManager;
+import me.iran.iranpvp.ffa.FFACommand;
+import me.iran.iranpvp.kit.KitEvents;
+import me.iran.iranpvp.type.GameType;
+import me.iran.iranpvp.type.GameTypeManager;
+import me.iran.iranpvp.utils.BungeeChat;
+import me.iran.iranpvp.utils.CustomInventory;
+import me.iran.iranpvp.utils.OnJoinItems;
+import me.iran.iranpvp.utils.ScoreboardUtils;
+import me.iran.iranpvp.utils.TeleportSpawn;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+
+public class ClickDuelInventoryEvent implements Listener {
+
+ IranPvP plugin;
+
+ public ClickDuelInventoryEvent (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ OnJoinItems items = new OnJoinItems();
+ CustomInventory inv = new CustomInventory();
+ BungeeChat chat = new BungeeChat();
+ TeleportSpawn spawn = new TeleportSpawn();
+
+ ScoreboardUtils sb = new ScoreboardUtils();
+
+ public static HashMap duelGameType = new HashMap<>();
+
+
+ @EventHandler
+ public void onClickEvent(InventoryClickEvent event) {
+ Player player = (Player) event.getWhoClicked();
+
+ if(event.getClickedInventory() == null) {
+ return;
+ }
+
+ if(event.getClickedInventory().getTitle() == null) {
+ return;
+ }
+
+
+ if(event.getCurrentItem() == null) {
+ return;
+ }
+
+ if(event.getInventory().getTitle().equals("Fight")) {
+ event.setCancelled(true);
+ }
+
+ if(!event.getCurrentItem().hasItemMeta()) {
+ return;
+ }
+
+ if(event.getCurrentItem().getItemMeta().getDisplayName() == null) {
+ return;
+ }
+
+ if(event.getClickedInventory().getTitle().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("DUEL_INVENTORY")))) {
+ if(PvPCommands.invite.containsKey(player.getName())) {
+
+ Player target = Bukkit.getPlayer(PvPCommands.invite.get(player.getName()));
+
+ String game = ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName());
+
+ InvitePlayerManager.getManager().createInvite(player, target, GameTypeManager.getManager().getGameTypeByName(game));
+
+ GameType gameType = GameTypeManager.getManager().getGameTypeByName(game);
+
+ duelGameType.put(player.getName(), gameType);
+ duelGameType.put(target.getName(), gameType);
+
+ player.closeInventory();
+ event.setCancelled(true);
+
+ player.sendMessage(ChatColor.GREEN + "Your duel has been sent");
+ }
+ }
+
+ if(event.getClickedInventory().getTitle().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("RANKED_INVENTORY")))) {
+ String game = ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName());
+
+ GameTypeManager.getManager().joinRanked(player, game);
+
+ items.rankedQueue(player);
+
+ sb.add(player, player.getScoreboard(), ChatColor.BLUE, "ranked", game, "Ranked: ");
+
+ player.closeInventory();
+ event.setCancelled(true);
+ }
+
+ if(event.getClickedInventory().getTitle().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("UNRANKED_INVENTORY")))) {
+ String game = ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName());
+
+ GameTypeManager.getManager().joinUnranked(player, game);
+
+ items.unrankedQueue(player);
+
+ sb.add(player, player.getScoreboard(), ChatColor.BLUE, "unranked", game, "Unranked: ");
+
+ player.closeInventory();
+ event.setCancelled(true);
+ }
+
+ if(event.getClickedInventory().getTitle().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("KIT_EDITOR_INVENTORY")))) {
+ String game = ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName());
+
+ KitEvents.getEditing().put(player.getName(), GameTypeManager.getManager().getGameTypeByName(game));
+ player.closeInventory();
+
+ spawn.teleportKit(player);
+
+ player.sendMessage(ChatColor.DARK_RED.toString() + ChatColor.BOLD + "*");
+ player.sendMessage(ChatColor.RED.toString() + ChatColor.BOLD + "Make sure you have a Diamond Kit if you are the Bard, Only the kits you create will be given to you");
+ player.sendMessage(ChatColor.DARK_RED.toString() + ChatColor.BOLD + "*");
+
+ event.setCancelled(true);
+ }
+
+ if(event.getClickedInventory().getTitle().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("FFA_INVENTORY")))) {
+ String game = ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName());
+
+ FFACommand.enabled = true;
+ FFACommand.gameType = game;
+
+ Bukkit.broadcastMessage(ChatColor.GOLD + "FFA Event Started! " + ChatColor.RED.toString() + ChatColor.BOLD + "/join" + ChatColor.GOLD + " (60 Seconds)");
+
+ player.closeInventory();
+
+ event.setCancelled(true);
+ }
+
+ if(event.getClickedInventory().getTitle().equals(ChatColor.AQUA + "All Teams")) {
+ event.setCancelled(true);
+ }
+ }
+
+ /**
+ * Cant use the following colors
+ * WHITE, BLACK, AQUA, RESET, LIGHT_PURPLE
+ *
+ * Cant use the following team names
+ * online, top, bottom, queue, white
+ */
+
+
+}
diff --git a/src/me/iran/iranpvp/events/duel/DeathInventory.java b/src/me/iran/iranpvp/events/duel/DeathInventory.java
new file mode 100644
index 0000000..ea28a7c
--- /dev/null
+++ b/src/me/iran/iranpvp/events/duel/DeathInventory.java
@@ -0,0 +1,129 @@
+package me.iran.iranpvp.events.duel;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.utils.TeleportSpawn;
+import net.md_5.bungee.api.ChatColor;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.PlayerDeathEvent;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.potion.PotionEffect;
+
+public class DeathInventory implements Listener {
+
+ IranPvP plugin;
+
+ public DeathInventory (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ TeleportSpawn spawn = new TeleportSpawn();
+
+ static HashMap inv = new HashMap();
+ static HashMap armor = new HashMap();
+ static HashMap> pots = new HashMap>();
+ static HashMap viewTimer = new HashMap();
+ static HashMap playerHealth = new HashMap();
+
+ public static Inventory deadInv(Player player) {
+ Inventory inventory = Bukkit.createInventory(player, 54, "Fight");
+
+ ItemStack[] playerItems = inv.get(player.getName());
+ ItemStack[] playerArmor = armor.get(player.getName());
+
+ ItemStack potion = new ItemStack(Material.BREWING_STAND_ITEM);
+ ItemMeta potionMeta = potion.getItemMeta();
+
+ ItemStack health = new ItemStack(Material.SPECKLED_MELON);
+ ItemMeta healthMeta = health.getItemMeta();
+
+ int potCount = 0;
+ ItemStack hp = new ItemStack(Material.POTION, 1, (short) 16421);
+
+
+ for(int i = 0; i < playerItems.length; i++) {
+ ItemStack items = playerItems[i];
+ inventory.setItem(i, items);
+
+ }
+
+ for(int i = 0; i < playerArmor.length; i++) {
+ ItemStack items = playerArmor[i];
+ inventory.setItem(i + 45, items);
+ }
+
+ potionMeta.setDisplayName(ChatColor.AQUA + "Active Potions");
+ potionMeta.setLore(pots.get(player.getName()));
+ potion.setItemMeta(potionMeta);
+
+ healthMeta.setDisplayName("" + ChatColor.RED + Math.round(playerHealth.get(player.getName())));
+ health.setItemMeta(healthMeta);
+
+ inventory.setItem(52, health);
+ inventory.setItem(53, potion);
+
+ System.out.println(potCount);
+
+ return inventory;
+ }
+
+ public static HashMap getTimer() {
+ return viewTimer;
+ }
+
+ public static HashMap getInv() {
+ return inv;
+ }
+
+ public static HashMap getArmor() {
+ return armor;
+ }
+
+ public static HashMap> getPots() {
+ return pots;
+ }
+
+ public static HashMap getHealth() {
+ return playerHealth;
+ }
+
+ @EventHandler
+ public void onDeath(PlayerDeathEvent event) {
+
+ if(event.getEntity().getKiller() instanceof Player) {
+
+ Player player = (Player) event.getEntity();
+
+ viewTimer.put(player.getName(), 30);
+
+ inv.put(player.getName(), player.getInventory().getContents());
+
+ armor.put(player.getName(), player.getInventory().getArmorContents());
+
+ pots.put(player.getName(), new ArrayList());
+
+ playerHealth.put(player.getName(), ((CraftPlayer) player).getHealth());
+
+ for(Iterator it = player.getActivePotionEffects().iterator(); it.hasNext();) {
+
+ PotionEffect potion = it.next();
+ String info = ChatColor.GOLD + potion.getType().getName() + ": " + potion.getDuration();
+
+ pots.get(player.getName()).add(info);
+ }
+ }
+ }
+
+}
diff --git a/src/me/iran/iranpvp/events/duel/PlayerBreakBlockEvent.java b/src/me/iran/iranpvp/events/duel/PlayerBreakBlockEvent.java
new file mode 100644
index 0000000..be88953
--- /dev/null
+++ b/src/me/iran/iranpvp/events/duel/PlayerBreakBlockEvent.java
@@ -0,0 +1,67 @@
+package me.iran.iranpvp.events.duel;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.duel.Duel;
+import me.iran.iranpvp.duel.DuelManager;
+
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.BlockBreakEvent;
+import org.bukkit.event.block.BlockPlaceEvent;
+import org.bukkit.event.player.PlayerDropItemEvent;
+
+public class PlayerBreakBlockEvent implements Listener {
+
+ IranPvP plugin;
+
+ public PlayerBreakBlockEvent(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void onBreak(BlockBreakEvent event) {
+ Player player = event.getPlayer();
+
+
+ Duel duel = DuelManager.getManager().getDuelByPlayer(player);
+
+ if(duel == null) {
+ event.setCancelled(true);
+ return;
+ }
+
+ if(!duel.getBlocks().contains(event.getBlock().getLocation())) {
+
+ if(!player.isOp()) {
+ event.setCancelled(true);
+ }
+
+ }
+
+ }
+
+ @EventHandler
+ public void onPlace(BlockPlaceEvent event) {
+ Player player = event.getPlayer();
+
+ Duel duel = DuelManager.getManager().getDuelByPlayer(player);
+
+ if(duel != null) {
+ duel.getBlocks().add(event.getBlock().getLocation());
+ } else if(duel == null && !player.isOp()) {
+ event.setCancelled(true);
+ }
+
+ }
+
+ @EventHandler
+ public void onDrop(PlayerDropItemEvent event) {
+
+ if(event.getItemDrop().getItemStack().getType() == Material.GLASS_BOTTLE) {
+ event.getItemDrop().remove();
+ }
+ }
+
+}
diff --git a/src/me/iran/iranpvp/events/duel/PlayerDeathWhileInPvP.java b/src/me/iran/iranpvp/events/duel/PlayerDeathWhileInPvP.java
new file mode 100644
index 0000000..5a4c23b
--- /dev/null
+++ b/src/me/iran/iranpvp/events/duel/PlayerDeathWhileInPvP.java
@@ -0,0 +1,112 @@
+package me.iran.iranpvp.events.duel;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.duel.Duel;
+import me.iran.iranpvp.duel.DuelManager;
+import me.iran.iranpvp.duel.team.TeamDuelManager;
+import me.iran.iranpvp.ffa.FFACommand;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.PlayerDeathEvent;
+import org.bukkit.event.player.PlayerTeleportEvent;
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
+
+public class PlayerDeathWhileInPvP implements Listener {
+
+ IranPvP plugin;
+
+ public PlayerDeathWhileInPvP (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void onDeath(PlayerDeathEvent event) {
+ Player player = event.getEntity();
+
+ event.setDeathMessage(null);
+
+ if (event.getEntity().getKiller() instanceof Player) {
+
+ final Player killer = event.getEntity().getKiller();
+
+ if (!TeamManager.getManager().isInTeam(player) && !TeamManager.getManager().isInTeam(killer)) {
+
+ if (DuelManager.getManager().isInDuel(player) && DuelManager.getManager().isInDuel(killer)) {
+
+ Duel duel = DuelManager.getManager().getDuelByPlayer(player);
+
+ if(duel.isRanked()) {
+
+ DuelManager.getManager().endRankedDuel(killer);
+
+ } else {
+
+ DuelManager.getManager().endDuel(killer);
+
+ }
+ }
+ }
+
+ } else if(!(event.getEntity().getKiller() instanceof Player)) {
+
+ if (!TeamManager.getManager().isInTeam(player)) {
+
+ if (DuelManager.getManager().isInDuel(player)) {
+
+ Duel duel = DuelManager.getManager().getDuelByPlayer(player);
+
+ final Player player1 = duel.getPlayer1();
+ final Player player2 = duel.getPlayer2();
+
+ if(duel.isRanked()) {
+
+ if(player.equals(player1)) {
+ DuelManager.getManager().endRankedDuel(player2);
+ } else if(player.equals(player2)) {
+ DuelManager.getManager().endRankedDuel(player1);
+ }
+
+ } else {
+
+ if(player.equals(player1)) {
+
+ DuelManager.getManager().endDuel(player2);
+
+ } else if(player.equals(player2)) {
+
+ DuelManager.getManager().endDuel(player1);
+
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ @EventHandler
+ public void onTp(PlayerTeleportEvent event) {
+
+ Player player = event.getPlayer();
+
+ if(event.getCause() == TeleportCause.ENDER_PEARL) {
+ if(TeamManager.getManager().isInTeam(player)) {
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ if(!TeamDuelManager.getManager().isInDuel(team)) {
+ event.setCancelled(true);
+ }
+ } else {
+
+ if(!DuelManager.getManager().isInDuel(player) && !FFACommand.fighters.contains(player.getName())) {
+ event.setCancelled(true);
+ }
+
+ }
+ }
+ }
+}
diff --git a/src/me/iran/iranpvp/events/duel/PlayerDisconnectWhileInPvP.java b/src/me/iran/iranpvp/events/duel/PlayerDisconnectWhileInPvP.java
new file mode 100644
index 0000000..8dd7775
--- /dev/null
+++ b/src/me/iran/iranpvp/events/duel/PlayerDisconnectWhileInPvP.java
@@ -0,0 +1,94 @@
+package me.iran.iranpvp.events.duel;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.Arena;
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.duel.Duel;
+import me.iran.iranpvp.duel.DuelManager;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.utils.Queue;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerQuitEvent;
+
+public class PlayerDisconnectWhileInPvP implements Listener {
+
+ IranPvP plugin;
+
+ public PlayerDisconnectWhileInPvP (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ Queue queue = new Queue();
+
+ @EventHandler
+ public void onQuit(PlayerQuitEvent event) {
+ Player player = event.getPlayer();
+
+ player.setAllowFlight(false);
+
+ if(queue.isInUnranked(player)) {
+ queue.leaveUnranked(player);
+ }
+
+ if(queue.isInRanked(player)) {
+ queue.leaveRanked(player);
+ }
+
+ if(DeathInventory.getTimer().containsKey(player.getName())) {
+ DeathInventory.getTimer().remove(player.getName());
+ }
+
+ if(DeathInventory.getArmor().containsKey(player.getName())) {
+ DeathInventory.getArmor().remove(player.getName());
+ }
+
+ if(DeathInventory.getInv().containsKey(player.getName())) {
+ DeathInventory.getInv().remove(player.getName());
+ }
+
+ if(DeathInventory.getPots().containsKey(player.getName())) {
+ DeathInventory.getPots().remove(player.getName());
+ }
+
+ if(ArenaManager.getManager().isSpectator(player)) {
+ Arena arena = ArenaManager.getManager().getArenaBySpectator(player);
+
+ arena.removeSpec(player.getName());
+ }
+
+ if(!TeamManager.getManager().isInTeam(player)) {
+ if(DuelManager.getManager().isInDuel(player)) {
+ final Duel duel = DuelManager.getManager().getDuelByPlayer(player);
+
+ if(duel.isRanked()) {
+
+ if (duel.getPlayer1().equals(player)) {
+
+ DuelManager.getManager().endRankedDuel(duel.getPlayer2());
+
+ } else if (duel.getPlayer2().equals(player)) {
+
+ DuelManager.getManager().endRankedDuel(duel.getPlayer1());
+
+ }
+ } else {
+
+ if (duel.getPlayer1().equals(player)) {
+
+ DuelManager.getManager().endDuel(duel.getPlayer2());
+
+ } else if (duel.getPlayer2().equals(player)) {
+
+ DuelManager.getManager().endDuel(duel.getPlayer1());
+
+ }
+ }
+
+ }
+ }
+ }
+
+}
diff --git a/src/me/iran/iranpvp/events/duel/ProtocolEvents.java b/src/me/iran/iranpvp/events/duel/ProtocolEvents.java
new file mode 100644
index 0000000..f886781
--- /dev/null
+++ b/src/me/iran/iranpvp/events/duel/ProtocolEvents.java
@@ -0,0 +1,57 @@
+package me.iran.iranpvp.events.duel;
+
+import me.iran.iranpvp.IranPvP;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.ProjectileLaunchEvent;
+
+import com.comphenix.protocol.PacketType;
+import com.comphenix.protocol.ProtocolLibrary;
+import com.comphenix.protocol.events.PacketAdapter;
+import com.comphenix.protocol.events.PacketEvent;
+
+public class ProtocolEvents implements Listener {
+
+/*
+ * TODO
+ * 1) hide all entities (done)
+ * 2) hide all dropped entities, and cancel pickup for invisible
+ * 3) play effects of potions where they land
+ * 4) play sound effects for players
+
+
+ IranPvP plugin;
+
+ public ProtocolEvents (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ @SuppressWarnings("deprecation")
+ @EventHandler
+ public void onLaunch(ProjectileLaunchEvent event) {
+
+ final Player player = (Player) event.getEntity().getShooter();
+
+ ProtocolLibrary.getProtocolManager().addPacketListener(
+ new PacketAdapter(IranPvP.plugin, PacketType.Play.Server.WORLD_EVENT) {
+ public void onPacketSending(PacketEvent e) {
+ if (e.getPacket().getType() == PacketType.Play.Server.WORLD_EVENT) {
+
+ //Person that the packet is recieving
+ Player p = e.getPlayer();
+
+ if(!IranPvP.getHider().canSee(player, p)) {
+ e.setCancelled(true);
+ }
+ }
+ }
+ });
+
+
+
+
+ }*/
+
+}
diff --git a/src/me/iran/iranpvp/events/duel/RespawnEvent.java b/src/me/iran/iranpvp/events/duel/RespawnEvent.java
new file mode 100644
index 0000000..4259fd0
--- /dev/null
+++ b/src/me/iran/iranpvp/events/duel/RespawnEvent.java
@@ -0,0 +1,37 @@
+package me.iran.iranpvp.events.duel;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.utils.TeleportSpawn;
+
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerRespawnEvent;
+
+public class RespawnEvent implements Listener {
+
+ IranPvP plugin;
+
+ public RespawnEvent (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ TeleportSpawn spawn = new TeleportSpawn();
+
+ @EventHandler
+ public void onRespawn(PlayerRespawnEvent event) {
+ final Player player = event.getPlayer();
+
+ Bukkit.getScheduler().scheduleSyncDelayedTask(IranPvP.plugin, new Runnable() {
+
+ public void run() {
+ spawn.teleportSpawn(player);
+
+ }
+
+ }, 5);
+
+ }
+
+}
diff --git a/src/me/iran/iranpvp/events/duel/TeamClickInventoryEvent.java b/src/me/iran/iranpvp/events/duel/TeamClickInventoryEvent.java
new file mode 100644
index 0000000..9e53090
--- /dev/null
+++ b/src/me/iran/iranpvp/events/duel/TeamClickInventoryEvent.java
@@ -0,0 +1,127 @@
+package me.iran.iranpvp.events.duel;
+
+import java.util.HashMap;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.cmd.team.TeamCommands;
+import me.iran.iranpvp.duel.DuelManager;
+import me.iran.iranpvp.duel.team.TeamInviteManager;
+import me.iran.iranpvp.kit.KitEvents;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.type.GameType;
+import me.iran.iranpvp.type.GameTypeManager;
+import me.iran.iranpvp.utils.BungeeChat;
+import me.iran.iranpvp.utils.CustomInventory;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+
+public class TeamClickInventoryEvent implements Listener {
+
+ IranPvP plugin;
+
+ public TeamClickInventoryEvent (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ public static HashMap teamGameType = new HashMap<>();
+
+ CustomInventory inv = new CustomInventory();
+ BungeeChat chat = new BungeeChat();
+
+ @EventHandler
+ public void onClick(InventoryClickEvent event) {
+ Player player = (Player) event.getWhoClicked();
+
+ if(event.getClickedInventory() == null) {
+ return;
+ }
+
+ if(event.getClickedInventory().getTitle() == null) {
+ return;
+ }
+
+ if(event.getCurrentItem() == null) {
+ return;
+ }
+
+ if(!event.getCurrentItem().hasItemMeta()) {
+ return;
+ }
+
+ if(event.getCurrentItem().getItemMeta().getDisplayName() == null) {
+ return;
+ }
+
+ if(!DuelManager.getManager().isInDuel(player) && !KitEvents.getEditing().containsKey(player.getName()) && !KitEvents.getNaming().containsKey(player.getName())) {
+
+ event.setCancelled(true);
+ }
+
+ if (event.getClickedInventory().getTitle().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TEAM_DUEL_INVENTORY")))) {
+
+ String game = ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName());
+
+ GameType gameType = GameTypeManager.getManager().getGameTypeByName(game);
+
+ teamGameType.put(TeamManager.getManager().getTeamByPlayer(player), gameType);
+
+ player.closeInventory();
+ event.setCancelled(true);
+ player.openInventory(inv.modes(player));
+
+ }
+
+ if (event.getClickedInventory().getTitle().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("GAME_MODES_INVENTORY")))) {
+
+
+ if (ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName()).equals("Team")) {
+
+ Team team1 = TeamManager.getManager().getTeamByPlayer(player);
+
+ Team team2 = TeamCommands.invite.get(team1);
+
+ GameType game = teamGameType.get(team1);
+
+ TeamInviteManager.getManager().createInvite(team1, team2, game, "team");
+
+ Player player1 = Bukkit.getPlayer(team1.getTeamLeader());
+ Player player2 = Bukkit.getPlayer(team2.getTeamLeader());
+
+ chat.acceptTeamDuel(player1, player2, game.getName());
+
+ player.sendMessage(ChatColor.GREEN + "Team Duel Sent");
+
+ event.setCancelled(true);
+
+ player.closeInventory();
+
+ } else if (ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName()).equals("KOTH")) {
+
+ Team team1 = TeamManager.getManager().getTeamByPlayer(player);
+
+ Team team2 = TeamCommands.invite.get(team1);
+
+ GameType game = teamGameType.get(team1);
+
+ TeamInviteManager.getManager().createInvite(team1, team2, game, "koth");
+
+ Player player1 = Bukkit.getPlayer(team1.getTeamLeader());
+ Player player2 = Bukkit.getPlayer(team2.getTeamLeader());
+
+ chat.acceptKothDuel(player1, player2, game.getName());
+
+ player.sendMessage(ChatColor.GREEN + "KOTH Duel Sent");
+
+ event.setCancelled(true);
+
+ player.closeInventory();
+ }
+ }
+ }
+}
diff --git a/src/me/iran/iranpvp/events/inhanditems/AddItemsOnJoin.java b/src/me/iran/iranpvp/events/inhanditems/AddItemsOnJoin.java
new file mode 100644
index 0000000..59c8185
--- /dev/null
+++ b/src/me/iran/iranpvp/events/inhanditems/AddItemsOnJoin.java
@@ -0,0 +1,37 @@
+package me.iran.iranpvp.events.inhanditems;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.utils.OnJoinItems;
+import me.iran.iranpvp.utils.TeleportSpawn;
+
+import org.bukkit.GameMode;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerJoinEvent;
+
+public class AddItemsOnJoin implements Listener {
+
+ IranPvP plugin;
+
+ public AddItemsOnJoin (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ OnJoinItems items = new OnJoinItems();
+
+ TeleportSpawn spawn = new TeleportSpawn();
+
+ @EventHandler
+ public void onPracticeJoin(PlayerJoinEvent event) {
+ Player player = event.getPlayer();
+
+ player.setGameMode(GameMode.SURVIVAL);
+
+ player.setAllowFlight(false);
+
+ spawn.teleportSpawn(player);
+
+ }
+
+}
diff --git a/src/me/iran/iranpvp/events/inhanditems/DropItemsInHandEvent.java b/src/me/iran/iranpvp/events/inhanditems/DropItemsInHandEvent.java
new file mode 100644
index 0000000..f5e054d
--- /dev/null
+++ b/src/me/iran/iranpvp/events/inhanditems/DropItemsInHandEvent.java
@@ -0,0 +1,75 @@
+package me.iran.iranpvp.events.inhanditems;
+
+import me.iran.iranpvp.IranPvP;
+
+import org.bukkit.ChatColor;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerDropItemEvent;
+
+public class DropItemsInHandEvent implements Listener{
+
+ IranPvP plugin;
+
+ public DropItemsInHandEvent (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void dropItem(PlayerDropItemEvent event) {
+ if(event.getItemDrop().getItemStack().hasItemMeta()) {
+
+ if(event.getItemDrop() == null) {
+ return;
+ }
+
+ if(event.getItemDrop().getItemStack() == null) {
+ return;
+ }
+
+ if(event.getItemDrop().getItemStack().getItemMeta() == null) {
+ return;
+ }
+
+ if(event.getItemDrop().getItemStack().getItemMeta().getDisplayName() == null) {
+ return;
+ }
+
+ /* KIT_EDITOR: '&4Kit Editor'x
+ RANKED_SWORD: '&a&lRanked Queue'x
+ UNRANKED_SWORD: '&b&lUnranked Queue'x
+ CREATE_TEAM: '&6&lCreate Team'x
+ TEAM_INFO: '&a&lTeam Info'x
+ DISBAND_TEAM: '&c&lDisband Team'x
+ ALL_TEAMS: '&e&lView Current Teams'x
+ LEAVE_TEAM: '&c&lLeave Team'x
+ PING: '&aPing: &l%ping%'*/
+
+ if(event.getItemDrop().getItemStack().getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("CREATE_TEAM")))) {
+ event.setCancelled(true);
+ } else if(event.getItemDrop().getItemStack().getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TEAM_INFO")))) {
+ event.setCancelled(true);
+ } else if(event.getItemDrop().getItemStack().getItemMeta().getDisplayName().contains(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("LEAVE_TEAM")))) {
+ event.setCancelled(true);
+ } else if (event.getItemDrop().getItemStack().getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ALL_TEAMS")))) {
+ event.setCancelled(true);
+ } else if (event.getItemDrop().getItemStack().getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("DISBAND_TEAM")))) {
+ event.setCancelled(true);
+ } else if (event.getItemDrop().getItemStack().getItemMeta().getDisplayName().equals(ChatColor.RED.toString() + ChatColor.BOLD + "Leave Unranked queue")) {
+ event.setCancelled(true);
+ } else if (event.getItemDrop().getItemStack().getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("KIT_EDITOR")))) {
+ event.setCancelled(true);
+ } else if (event.getItemDrop().getItemStack().getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("UNRANKED_SWORD")))) {
+ event.setCancelled(true);
+ } else if (event.getItemDrop().getItemStack().getItemMeta().getDisplayName().equals(ChatColor.RED + "Leave Spectator")) {
+ event.setCancelled(true);
+ } else if (event.getItemDrop().getItemStack().getItemMeta().getDisplayName().equals(ChatColor.RED.toString() + ChatColor.BOLD + "Leave Ranked queue")) {
+ event.setCancelled(true);
+ } else if (event.getItemDrop().getItemStack().getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("RANKED_SWORD")))) {
+ event.setCancelled(true);
+ }
+
+ }
+ }
+
+}
diff --git a/src/me/iran/iranpvp/events/inhanditems/InteractWithItemsInHand.java b/src/me/iran/iranpvp/events/inhanditems/InteractWithItemsInHand.java
new file mode 100644
index 0000000..f909548
--- /dev/null
+++ b/src/me/iran/iranpvp/events/inhanditems/InteractWithItemsInHand.java
@@ -0,0 +1,221 @@
+package me.iran.iranpvp.events.inhanditems;
+
+import java.util.HashMap;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.Arena;
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.runnable.Run;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.utils.CustomInventory;
+import me.iran.iranpvp.utils.OnJoinItems;
+import me.iran.iranpvp.utils.Queue;
+import me.iran.iranpvp.utils.ScoreboardUtils;
+import me.iran.iranpvp.utils.TeleportSpawn;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.GameMode;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.player.PlayerInteractEvent;
+
+public class InteractWithItemsInHand implements Listener {
+
+ IranPvP plugin;
+
+ public InteractWithItemsInHand(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ HashMap timer = new HashMap<>();
+
+ Queue queue = new Queue();
+ OnJoinItems items = new OnJoinItems();
+ CustomInventory inv = new CustomInventory();
+ TeleportSpawn spawn = new TeleportSpawn();
+
+ ScoreboardUtils sb = new ScoreboardUtils();
+
+ Run run = new Run(plugin);
+
+ @EventHandler
+ public void onRightClick(PlayerInteractEvent event) {
+ Player player = event.getPlayer();
+
+ if (event.getAction() == null) {
+ return;
+ }
+
+ if (player.getItemInHand() == null) {
+ return;
+ }
+
+ if (!player.getItemInHand().hasItemMeta()) {
+ return;
+ }
+
+ if (player.getItemInHand().getItemMeta().getDisplayName() == null) {
+ return;
+ }
+
+ if (event.getAction() == Action.RIGHT_CLICK_AIR
+ || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
+
+ if (timer.containsKey(player.getName())
+ && timer.get(player.getName()) > System.currentTimeMillis()
+ && !player.isOp()) {
+ player.sendMessage(ChatColor.RED + "Stop spamming items");
+ event.setCancelled(true);
+ return;
+ } else {
+
+
+ timer.put(player.getName(),
+ System.currentTimeMillis() + 2 * 1000);
+
+ if (event.getAction() == Action.RIGHT_CLICK_AIR
+ || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
+
+ if (player
+ .getItemInHand()
+ .getItemMeta()
+ .getDisplayName()
+ .equals(ChatColor.RED.toString() + ChatColor.BOLD
+ + "Leave Unranked queue")) {
+
+ sb.remove(player, player.getScoreboard(), "unranked", ChatColor.BLUE);
+
+ queue.leaveUnranked(player);
+ items.onJoin(player);
+ return;
+ }
+
+ if (player
+ .getItemInHand()
+ .getItemMeta()
+ .getDisplayName()
+ .equals(ChatColor.RED.toString() + ChatColor.BOLD
+ + "Leave Ranked queue")) {
+
+ sb.remove(player, player.getScoreboard(), "ranked", ChatColor.BLUE);
+
+ queue.leaveRanked(player);
+ items.onJoin(player);
+ return;
+ }
+
+ if (player.getItemInHand().getItemMeta().getDisplayName()
+ .equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("UNRANKED_SWORD")))) {
+ player.openInventory(inv.queue(player));
+ return;
+ }
+
+ if (player.getItemInHand().getItemMeta().getDisplayName()
+ .equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("RANKED_SWORD")))) {
+ player.openInventory(inv.ranked(player));
+ return;
+ }
+
+ if (player.getItemInHand().getItemMeta().getDisplayName()
+ .equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("CREATE_TEAM")))) {
+ if (!TeamManager.getManager().isInTeam(player)) {
+ if (queue.isInUnranked(player)) {
+ player.sendMessage(ChatColor.RED
+ + "Can't create a team while in a Queue");
+ return;
+ }
+ TeamManager.getManager().createTeam(
+ player.getName(), player);
+ }
+ } else if (player.getItemInHand().getItemMeta()
+ .getDisplayName()
+ .equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TEAM_INFO")))) {
+ if (TeamManager.getManager().isInTeam(player)) {
+
+ Team team = TeamManager.getManager()
+ .getTeamByPlayer(player);
+
+ player.sendMessage(ChatColor.AQUA.toString()
+ + "------" + ChatColor.BOLD
+ + team.getTeamName() + ChatColor.AQUA
+ + "------");
+ player.sendMessage("");
+ for (String p : team.getTeamMembers()) {
+ player.sendMessage(ChatColor.GREEN + p);
+ }
+ player.sendMessage("");
+ }
+ } else if (player.getItemInHand().getItemMeta()
+ .getDisplayName()
+ .equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("LEAVE_TEAM")))) {
+ if (TeamManager.getManager().isInTeam(player)) {
+ TeamManager.getManager().leaveTeam(player);
+ spawn.teleportSpawn(player);
+ }
+ } else if (player.getItemInHand().getItemMeta()
+ .getDisplayName()
+ .equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ALL_TEAMS")))) {
+ if (TeamManager.getManager().isInTeam(player)) {
+ player.openInventory(run.allTeamsInv(player));
+ }
+ } else if (player.getItemInHand().getItemMeta()
+ .getDisplayName()
+ .equals(ChatColor.RED + "Make Leader")) {
+ if (TeamManager.getManager().isInTeam(player)) {
+ Team team = TeamManager.getManager()
+ .getTeamByPlayer(player);
+
+ if (team.getTeamLeader().equals(player.getName())) {
+ TeamManager.getManager().disbandTeam(player);
+ }
+
+ }
+ } else if (player.getItemInHand().getItemMeta()
+ .getDisplayName()
+ .equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("KIT_EDITOR")))) {
+ if (TeamManager.getManager().isInTeam(player)) {
+ player.sendMessage(ChatColor.RED
+ + "Can't do this while in a in Team");
+ } else {
+ player.openInventory(inv.kitEditorInv(player));
+ }
+
+ } else if (player.getItemInHand().getItemMeta()
+ .getDisplayName()
+ .equals(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("DISBAND_TEAM")))) {
+ if (TeamManager.getManager().isInTeam(player)) {
+ Team team = TeamManager.getManager()
+ .getTeamByPlayer(player);
+
+ if (team.getTeamLeader().equals(player.getName())) {
+ TeamManager.getManager().disbandTeam(player);
+ }
+ }
+ } else if (player.getItemInHand().getItemMeta()
+ .getDisplayName()
+ .equals(ChatColor.RED + "Leave Spectator")) {
+ if (ArenaManager.getManager().isSpectator(player)) {
+ Arena arena = ArenaManager.getManager()
+ .getArenaBySpectator(player);
+ arena.getSpec().remove(player.getName());
+ for (Player p : Bukkit.getOnlinePlayers()) {
+ p.showPlayer(player);
+ }
+
+ player.setGameMode(GameMode.SURVIVAL);
+ player.setAllowFlight(false);
+ player.setHealth(20.0);
+ player.setFoodLevel(20);
+ spawn.teleportSpawn(player);
+ }
+
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/me/iran/iranpvp/events/teamfight/DisconnectWhileInTeam.java b/src/me/iran/iranpvp/events/teamfight/DisconnectWhileInTeam.java
new file mode 100644
index 0000000..f6e9aea
--- /dev/null
+++ b/src/me/iran/iranpvp/events/teamfight/DisconnectWhileInTeam.java
@@ -0,0 +1,114 @@
+package me.iran.iranpvp.events.teamfight;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.Arena;
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.duel.team.TeamDuelManager;
+import me.iran.iranpvp.duel.team.TeamFight;
+import me.iran.iranpvp.duel.team.TeamFightManager;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.utils.OnJoinItems;
+
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerQuitEvent;
+
+public class DisconnectWhileInTeam implements Listener {
+
+ IranPvP plugin;
+
+ public DisconnectWhileInTeam (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ OnJoinItems items = new OnJoinItems();
+
+ @EventHandler
+ public void onQuit(PlayerQuitEvent event) {
+ Player player = event.getPlayer();
+
+ if(TeamManager.getManager().isInTeam(player)) {
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ if(TeamDuelManager.getManager().isInDuel(team)) {
+ if(team.getTeamMembers().size() > 1) {
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+
+ Player newLeader = Bukkit.getPlayer(team.getTeamMembers().get(1));
+
+/* TeamManager.getManager().makeLeaderInFight(player, newLeader);
+ team.removeMember(player.getName());*/
+
+ TeamManager.getManager().makeLeaderInFight(player, newLeader);
+ team.removeMember(player.getName());
+ arena.getFighters().remove(player.getName());
+
+ if(arena.isActive() && arena.getCappers().contains(player.getName())) {
+ arena.getCappers().remove(player.getName());
+ arena.setTimer(arena.getArenaTimer());
+
+ } else if(!arena.isActive()) {
+
+ if(TeamDuelManager.getManager().isInDuel(team)) {
+
+ TeamFight fight = TeamFightManager.getManager().getFightByPlayer(player);
+
+ if(fight.getTeam1() == team) {
+
+ fight.getAliveTeam1().remove(player.getName());
+
+ if(fight.getAliveTeam1().size() < 1) {
+ TeamDuelManager.getManager().endDuel(Bukkit.getPlayer(fight.getTeam2().getTeamLeader()));
+ }
+
+ } else if(fight.getTeam2() == team) {
+
+ fight.getAliveTeam2().remove(player.getName());
+
+ if(fight.getAliveTeam2().size() < 1) {
+ TeamDuelManager.getManager().endDuel(Bukkit.getPlayer(fight.getTeam1().getTeamLeader()));
+ }
+
+ }
+ }
+ }
+
+
+ } else if(team.getTeamMembers().size() < 2) {
+ Team team1 = TeamDuelManager.getManager().getDuelByPlayer(player).getTeam1();
+ Team team2 = TeamDuelManager.getManager().getDuelByPlayer(player).getTeam2();
+
+ if(team1 == team) {
+ TeamDuelManager.getManager().endDuel(Bukkit.getPlayer(team2.getTeamLeader()));
+ TeamManager.getManager().disbandTeam(player);
+ } else if(team2 == team) {
+ TeamDuelManager.getManager().endDuel(Bukkit.getPlayer(team1.getTeamLeader()));
+ TeamManager.getManager().disbandTeam(player);
+ }
+ }
+ } else if(!TeamDuelManager.getManager().isInDuel(team)) {
+ if(team.getTeamMembers().size() > 1) {
+
+ Player newLeader = Bukkit.getPlayer(team.getTeamMembers().get(1));
+
+ TeamManager.getManager().makeLeader(player, newLeader);
+ team.removeMember(player.getName());
+
+ items.teamLeaderItems(newLeader);
+
+ } else if(team.getTeamMembers().size() < 2) {
+
+ TeamManager.getManager().disbandTeam(player);
+ }
+ }
+
+ }
+
+
+ }
+
+}
diff --git a/src/me/iran/iranpvp/events/teamfight/KothDeathEvent.java b/src/me/iran/iranpvp/events/teamfight/KothDeathEvent.java
new file mode 100644
index 0000000..d58b944
--- /dev/null
+++ b/src/me/iran/iranpvp/events/teamfight/KothDeathEvent.java
@@ -0,0 +1,133 @@
+package me.iran.iranpvp.events.teamfight;
+
+import java.util.HashMap;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.Arena;
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.duel.team.TeamDuel;
+import me.iran.iranpvp.duel.team.TeamDuelManager;
+import me.iran.iranpvp.kit.KitManager;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.utils.ScoreboardUtils;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.PlayerDeathEvent;
+
+public class KothDeathEvent implements Listener {
+
+ IranPvP plugin;
+
+ public static HashMap lives = new HashMap<>();
+ public static HashMap cooldown = new HashMap<>();
+
+ public static ScoreboardUtils sb = new ScoreboardUtils();
+ public static KitManager km = new KitManager();
+
+ public KothDeathEvent(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void onDeath(PlayerDeathEvent event) {
+
+ Player player = event.getEntity();
+
+ System.out.println("1");
+
+ if(TeamManager.getManager().isInTeam(player)) {
+ System.out.println("2");
+
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ if(TeamDuelManager.getManager().isInDuel(team) && ArenaManager.getManager().getArenaByPlayer(player).isActive()) {
+ System.out.println("3");
+ cooldown.put(player.getName(), IranPvP.plugin.getConfig().getInt("KOTH.COOLDOWN"));
+ System.out.println(cooldown.get(player.getName()));
+ }
+ }
+
+ }
+
+ public static HashMap getLives() {
+ return lives;
+ }
+
+ public static HashMap getCooldown() {
+ return lives;
+ }
+
+ public static void removeSpectator(Player player) {
+
+ if(TeamManager.getManager().isInTeam(player)) {
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ if(TeamDuelManager.getManager().isInDuel(team) && ArenaManager.getManager().getArenaByPlayer(player).isActive()) {
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+
+ if(!ArenaManager.getManager().getAllArena().contains(arena)) {
+ return;
+ }
+
+ TeamDuel duel = TeamDuelManager.getManager().getDuelByPlayer(player);
+
+ if(!TeamDuelManager.getManager().getAllDuels().contains(duel)) {
+ return;
+ }
+
+
+ if(duel.getTeam1().getTeamMembers().contains(player.getName())) {
+
+ int x1 = arena.getXTeam1();
+ int y1 = arena.getYTeam1();
+ int z1 = arena.getZTeam1();
+
+ float pitch1 = arena.getPitchTeam1();
+ float yaw1 = arena.getYawTeam1();
+
+ Location location = new Location(Bukkit.getWorld(arena.getWorld()), x1, y1, z1);
+
+ location.setPitch(pitch1);
+ location.setYaw(yaw1);
+
+ player.setAllowFlight(false);
+ player.teleport(location);
+
+ km.getKits(player, duel.getGameType());
+
+ sb.setKOTHBoard(player);
+
+ } else if(duel.getTeam2().getTeamMembers().contains(player.getName())) {
+
+ int x2 = arena.getXTeam2();
+ int y2 = arena.getYTeam2();
+ int z2 = arena.getZTeam2();
+
+ float pitch2 = arena.getPitchTeam2();
+ float yaw2 = arena.getYawTeam2();
+
+ Location location = new Location(Bukkit.getWorld(arena.getWorld()), x2, y2, z2);
+
+ location.setPitch(pitch2);
+ location.setYaw(yaw2);
+
+ player.setAllowFlight(false);
+ player.teleport(location);
+
+ sb.setKOTHBoard(player);
+
+ km.getKits(player, duel.getGameType());
+ }
+
+ }
+ }
+
+ }
+
+}
diff --git a/src/me/iran/iranpvp/events/teamfight/TeamDamageTeam.java b/src/me/iran/iranpvp/events/teamfight/TeamDamageTeam.java
new file mode 100644
index 0000000..822e530
--- /dev/null
+++ b/src/me/iran/iranpvp/events/teamfight/TeamDamageTeam.java
@@ -0,0 +1,41 @@
+package me.iran.iranpvp.events.teamfight;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
+
+public class TeamDamageTeam implements Listener {
+ IranPvP plugin;
+
+ public TeamDamageTeam(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void onAttack(EntityDamageByEntityEvent event) {
+
+ if(event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
+ Player hit = (Player) event.getEntity();
+ Player damager = (Player) event.getDamager();
+
+ if(ArenaManager.getManager().isSpectator(damager)) {
+ event.setCancelled(true);
+ }
+
+ Team hitTeam = TeamManager.getManager().getTeamByPlayer(hit);
+ Team damTeam = TeamManager.getManager().getTeamByPlayer(damager);
+
+ if(TeamManager.getManager().getAllTeams().contains(hitTeam) && TeamManager.getManager().getAllTeams().contains(damTeam)) {
+ if(hitTeam.getTeamName().equalsIgnoreCase(damTeam.getTeamName())) {
+ event.setCancelled(true);
+ }
+ }
+ }
+ }
+}
diff --git a/src/me/iran/iranpvp/events/teamfight/TeamFightEvent.java b/src/me/iran/iranpvp/events/teamfight/TeamFightEvent.java
new file mode 100644
index 0000000..85e15c1
--- /dev/null
+++ b/src/me/iran/iranpvp/events/teamfight/TeamFightEvent.java
@@ -0,0 +1,219 @@
+package me.iran.iranpvp.events.teamfight;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.Arena;
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.duel.team.TeamDuelManager;
+import me.iran.iranpvp.duel.team.TeamFight;
+import me.iran.iranpvp.duel.team.TeamFightManager;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.utils.TeleportSpawn;
+import net.md_5.bungee.api.ChatColor;
+
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.PlayerDeathEvent;
+
+public class TeamFightEvent implements Listener {
+
+ IranPvP plugin;
+
+ public TeamFightEvent (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ TeleportSpawn spawn = new TeleportSpawn();
+
+ @SuppressWarnings("deprecation")
+ @EventHandler
+ public void onDeath(PlayerDeathEvent event) {
+ Player player = (Player) event.getEntity();
+
+ event.getDrops().clear();
+
+ if(event.getEntity().getKiller() instanceof Player) {
+ final Player killer = (Player) event.getEntity().getKiller();
+
+ //Player is in a team
+ if(TeamManager.getManager().isInTeam(player)) {
+
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ //Team is in Duel
+ if(TeamDuelManager.getManager().isInDuel(team)) {
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getFighters().contains(p.getName())) {
+ p.sendMessage(ChatColor.RED + killer.getName() + ChatColor.GOLD + " has killed " + ChatColor.RED + player.getName());
+ }
+ }
+
+ //Arena is not active
+ if(!arena.isActive()) {
+
+ TeamFight fight = TeamFightManager.getManager().getFightByPlayer(player);
+
+ if(!TeamFightManager.getManager().getAllTeamFights().contains(fight)) {
+ return;
+ }
+
+ if(fight.isAlive(player.getName())) {
+
+
+ if(fight.getTeam1().getTeamMembers().contains(player.getName())) {
+
+ fight.getAliveTeam1().remove(player.getName());
+
+
+ if(fight.getAliveTeam1().size() <= 0) {
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getFighters().contains(p.getName())) {
+ p.sendMessage(ChatColor.DARK_AQUA + fight.getTeam2().getTeamName() + ChatColor.GREEN + " has won the Team Fight");
+ }
+ }
+
+
+ TeamDuelManager.getManager().endDuel(killer);
+
+ TeamFightManager.getManager().deleteTeamFight(killer);
+
+
+ }
+ }
+
+ if(fight.getTeam2().getTeamMembers().contains(player.getName())) {
+
+ fight.getAliveTeam2().remove(player.getName());
+
+
+ if(fight.getAliveTeam2().size() <= 0) {
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getFighters().contains(p.getName())) {
+ p.sendMessage(ChatColor.DARK_AQUA + fight.getTeam1().getTeamName() + ChatColor.GREEN + " has won the Team Fight");
+ }
+ }
+
+ TeamDuelManager.getManager().endDuel(killer);
+
+ TeamFightManager.getManager().deleteTeamFight(killer);
+
+
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+ } else if(!(event.getEntity().getKiller() instanceof Player)) {
+
+ if(TeamManager.getManager().isInTeam(player)) {
+
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ //Team is in Duel
+ if(TeamDuelManager.getManager().isInDuel(team)) {
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getFighters().contains(p.getName())) {
+ p.sendMessage(ChatColor.RED + player.getName() + ChatColor.GOLD + " died");
+ }
+ }
+
+ //Arena is not active
+ if(!arena.isActive()) {
+
+ final TeamFight fight = TeamFightManager.getManager().getFightByPlayer(player);
+
+ if(!TeamFightManager.getManager().getAllTeamFights().contains(fight)) {
+ return;
+ }
+
+ if(fight.isAlive(player.getName())) {
+
+
+ if(fight.getTeam1().getTeamMembers().contains(player.getName())) {
+
+ fight.getAliveTeam1().remove(player.getName());
+
+
+ if(fight.getAliveTeam1().size() <= 0) {
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getFighters().contains(p.getName())) {
+ p.sendMessage(ChatColor.DARK_AQUA + fight.getTeam2().getTeamName() + ChatColor.GREEN + " has won the Team Fight");
+ }
+ }
+
+ Bukkit.getScheduler().scheduleAsyncDelayedTask(IranPvP.plugin, new Runnable() {
+
+ @Override
+ public void run() {
+
+ TeamDuelManager.getManager().endDuel(Bukkit.getPlayer(fight.getTeam2().getTeamLeader()));
+
+ TeamFightManager.getManager().deleteTeamFight(Bukkit.getPlayer(fight.getTeam2().getTeamLeader()));
+ }
+
+ }, 100);
+
+
+
+ }
+ }
+
+ if(fight.getTeam2().getTeamMembers().contains(player.getName())) {
+
+ fight.getAliveTeam2().remove(player.getName());
+
+
+ if(fight.getAliveTeam2().size() <= 0) {
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getFighters().contains(p.getName())) {
+ p.sendMessage(ChatColor.DARK_AQUA + fight.getTeam1().getTeamName() + ChatColor.GREEN + " has won the Team Fight");
+ }
+ }
+
+ Bukkit.getScheduler().scheduleAsyncDelayedTask(IranPvP.plugin, new Runnable() {
+
+ @Override
+ public void run() {
+ TeamDuelManager.getManager().endDuel(Bukkit.getPlayer(fight.getTeam1().getTeamLeader()));
+ TeamFightManager.getManager().deleteTeamFight(Bukkit.getPlayer(fight.getTeam1().getTeamLeader()));
+ }
+
+ }, 100);
+
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/me/iran/iranpvp/ffa/FFACommand.java b/src/me/iran/iranpvp/ffa/FFACommand.java
new file mode 100644
index 0000000..f02de3e
--- /dev/null
+++ b/src/me/iran/iranpvp/ffa/FFACommand.java
@@ -0,0 +1,246 @@
+package me.iran.iranpvp.ffa;
+
+import java.util.ArrayList;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.duel.DuelManager;
+import me.iran.iranpvp.kit.KitEvents;
+import me.iran.iranpvp.kit.KitManager;
+import me.iran.iranpvp.runnable.Run;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.type.GameTypeManager;
+import me.iran.iranpvp.utils.CustomInventory;
+import me.iran.iranpvp.utils.OnJoinItems;
+import me.iran.iranpvp.utils.ScoreboardUtils;
+import me.iran.iranpvp.utils.TeleportSpawn;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.scoreboard.DisplaySlot;
+
+public class FFACommand implements CommandExecutor {
+
+ IranPvP plugin;
+
+ public FFACommand(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ public static boolean enabled = false;
+ private static int timer = 60;
+ public static String gameType = "";
+ //Set gametype
+
+ public static ArrayList fighters = new ArrayList();
+
+ TeleportSpawn spawn = new TeleportSpawn();
+
+ OnJoinItems items = new OnJoinItems();
+
+ KitManager km = new KitManager();
+
+ CustomInventory inv = new CustomInventory();
+
+ Run run = new Run(plugin);
+
+ ScoreboardUtils sb = new ScoreboardUtils();
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String label,
+ String[] args) {
+
+ if (!(sender instanceof Player)) {
+ return true;
+ }
+
+ Player player = (Player) sender;
+
+ if (cmd.getName().equalsIgnoreCase("ffa")) {
+ if (!player.hasPermission("rifthq.ffa")) {
+ return true;
+ }
+ if(args.length < 1) {
+ player.sendMessage(ChatColor.RED + "/ffa start | stop | set");
+ return true;
+ }
+
+ if (args[0].equalsIgnoreCase("start")) {
+ if (enabled) {
+ player.sendMessage(ChatColor.RED
+ + "A FFA seems to be running!");
+ return true;
+ }
+
+ player.openInventory(inv.ffa(player));
+
+ }
+
+ if (args[0].equalsIgnoreCase("stop")) {
+ if (!enabled) {
+ player.sendMessage(ChatColor.RED
+ + "FFA is not running at the moment");
+ return true;
+ }
+
+ enabled = false;
+ timer = 60;
+ gameType = "";
+ Bukkit.broadcastMessage(ChatColor.RED + "FFA Event Stopped by "
+ + player.getDisplayName());
+ }
+
+ if (args[0].equalsIgnoreCase("set")) {
+
+ if (!IranPvP.plugin.getConfig().contains("ffa.arena")) {
+
+ IranPvP.plugin.getConfig().createSection("ffa.arena.x");
+ IranPvP.plugin.getConfig().createSection("ffa.arena.y");
+ IranPvP.plugin.getConfig().createSection("ffa.arena.z");
+ IranPvP.plugin.getConfig().createSection("ffa.arena.pitch");
+ IranPvP.plugin.getConfig().createSection("ffa.arena.yaw");
+ IranPvP.plugin.getConfig().createSection("ffa.arena.world");
+
+ IranPvP.plugin.getConfig().set("ffa.arena.x", player.getLocation().getBlockX());
+ IranPvP.plugin.getConfig().set("ffa.arena.y", player.getLocation().getBlockY());
+ IranPvP.plugin.getConfig().set("ffa.arena.z", player.getLocation().getBlockZ());
+ IranPvP.plugin.getConfig().set("ffa.arena.pitch", player.getLocation().getPitch());
+ IranPvP.plugin.getConfig().set("ffa.arena.yaw", player.getLocation().getYaw());
+ IranPvP.plugin.getConfig().set("ffa.arena.world", player.getLocation().getWorld().getName());
+
+ IranPvP.plugin.saveConfig();
+ player.sendMessage(ChatColor.GREEN + "Set FFA arena location");
+
+ } else {
+ IranPvP.plugin.getConfig().set("ffa.arena.x", player.getLocation().getBlockX());
+ IranPvP.plugin.getConfig().set("ffa.arena.y", player.getLocation().getBlockY());
+ IranPvP.plugin.getConfig().set("ffa.arena.z", player.getLocation().getBlockZ());
+ IranPvP.plugin.getConfig().set("ffa.arena.pitch", player.getLocation().getPitch());
+ IranPvP.plugin.getConfig().set("ffa.arena.yaw", player.getLocation().getYaw());
+ IranPvP.plugin.getConfig().set("ffa.arena.world", player.getLocation().getWorld().getName());
+
+ IranPvP.plugin.saveConfig();
+ player.sendMessage(ChatColor.GREEN + "Set FFA arena location");
+ }
+
+ }
+ }
+
+ if (cmd.getName().equalsIgnoreCase("join")) {
+
+ if(TeamManager.getManager().isInTeam(player)) {
+ player.sendMessage(ChatColor.RED + "Can't do this while in a team");
+ return true;
+ }
+
+ if(DuelManager.getManager().isInDuel(player)) {
+ player.sendMessage(ChatColor.RED + "Can't do this while in a duel");
+ return true;
+ }
+
+ if(ArenaManager.getManager().isSpectator(player)) {
+ player.sendMessage(ChatColor.RED + "Can't do this while in spectator mode");
+ return true;
+ }
+
+ if(fighters.contains(player.getName())) {
+ player.sendMessage(ChatColor.RED + "Already in this FFA");
+ return true;
+ }
+
+ if(fighters.size() >= 80) {
+ player.sendMessage(ChatColor.RED + "This FFA is already full");
+ return true;
+ }
+
+ if(enabled == false) {
+ player.sendMessage(ChatColor.RED + "This FFA is not active");
+ return true;
+ }
+
+ if(getTimer() <= 0) {
+ player.sendMessage(ChatColor.RED + "This FFA is in progress");
+ return true;
+ }
+
+ if(KitEvents.getEditing().containsKey(player.getName())) {
+ player.sendMessage(ChatColor.RED + "Can't join FFA while in editing mode");
+ return true;
+ }
+
+ fighters.add(player.getName());
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+
+ if(fighters.contains(p.getName())) {
+ player.showPlayer(p);
+ p.showPlayer(player);
+ }
+
+ }
+
+ ffaTeleport(player);
+
+ items.clearInv(player);
+
+ km.getKits(player, GameTypeManager.getManager().getGameTypeByName(gameType));
+
+ player.setScoreboard(sb.ffaBoard(player));
+
+ Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.GOLD + " has joined FFA (" + fighters.size() + "/80)");
+
+ }
+
+ if(cmd.getName().equalsIgnoreCase("leave")) {
+ if(!fighters.contains(player.getName())) {
+ player.sendMessage(ChatColor.RED + "Already in this FFA");
+ return true;
+ }
+
+ if(getTimer() <= 0) {
+ player.sendMessage(ChatColor.RED + "Can't leave mid game");
+ return true;
+ }
+
+ fighters.remove(player.getName());
+
+ player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ spawn.teleportSpawn(player);
+
+ Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.RED + " has left FFA (" + fighters.size() + "/80)");
+ }
+
+ return true;
+ }
+
+ public static int getTimer() {
+ return timer;
+ }
+
+ public static void setTimer(int timer) {
+ FFACommand.timer = timer;
+ }
+
+ public void ffaTeleport(Player player) {
+ int x = IranPvP.plugin.getConfig().getInt("ffa.arena.x");
+ int y = IranPvP.plugin.getConfig().getInt("ffa.arena.y");
+ int z = IranPvP.plugin.getConfig().getInt("ffa.arena.z");
+ float pitch = (float) IranPvP.plugin.getConfig().getDouble("ffa.arena.pitch");
+ float yaw = (float) IranPvP.plugin.getConfig().getDouble("ffa.arena.yaw");
+ String world = IranPvP.plugin.getConfig().getString("ffa.arena.world");
+
+ Location loc = new Location(Bukkit.getWorld(world), x, y, z);
+ loc.setPitch(pitch);
+ loc.setYaw(yaw);
+
+ player.teleport(loc);
+
+ }
+
+}
diff --git a/src/me/iran/iranpvp/ffa/FFAEvent.java b/src/me/iran/iranpvp/ffa/FFAEvent.java
new file mode 100644
index 0000000..794184b
--- /dev/null
+++ b/src/me/iran/iranpvp/ffa/FFAEvent.java
@@ -0,0 +1,214 @@
+package me.iran.iranpvp.ffa;
+
+import java.util.HashMap;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.utils.TeleportSpawn;
+import net.md_5.bungee.api.ChatColor;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Color;
+import org.bukkit.FireworkEffect;
+import org.bukkit.FireworkEffect.Type;
+import org.bukkit.entity.Firework;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.Projectile;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
+import org.bukkit.event.entity.PlayerDeathEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.inventory.meta.FireworkMeta;
+import org.bukkit.scoreboard.DisplaySlot;
+
+public class FFAEvent implements Listener {
+
+ IranPvP plugin;
+
+ public FFAEvent (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ TeleportSpawn spawn = new TeleportSpawn();
+
+ private static HashMap firework = new HashMap<>();
+
+ @EventHandler
+ public void onDeath(PlayerDeathEvent event) {
+
+ if(event.getEntity() instanceof Player && event.getEntity().getKiller() instanceof Player) {
+ Player player = event.getEntity();
+
+ if(FFACommand.fighters.contains(player.getName())) {
+
+ FFACommand.fighters.remove(player.getName());
+
+ Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.RED + " has been eliminated from the FFA Event! (" + FFACommand.fighters.size() + ")");
+
+ if(event.getEntity().getKiller() instanceof Player) {
+
+ Player killer = event.getEntity().getKiller();
+
+ if(FFACommand.fighters.size() < 2) {
+ Bukkit.broadcastMessage(ChatColor.AQUA.toString() + ChatColor.BOLD + killer.getName() + " HAS WON THE FFA EVENT!!!");
+ for(String p : FFACommand.fighters) {
+ Player pl = Bukkit.getPlayer(p);
+
+ pl.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ spawn.teleportSpawn(pl);
+
+ }
+
+ firework.put(killer.getName(), 20);
+ FFACommand.enabled = false;
+ FFACommand.setTimer(60);
+ FFACommand.gameType = "";
+ FFACommand.fighters.clear();
+ }
+ } else {
+ if(FFACommand.fighters.size() < 2) {
+ Bukkit.broadcastMessage(ChatColor.AQUA.toString() + ChatColor.BOLD + FFACommand.fighters.get(0) + " HAS WON THE FFA EVENT!!!");
+
+ for(String p : FFACommand.fighters) {
+ Player pl = Bukkit.getPlayer(p);
+
+ pl.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ spawn.teleportSpawn(pl);
+
+ }
+
+ firework.put(FFACommand.fighters.get(0), 20);
+
+ FFACommand.enabled = false;
+ FFACommand.setTimer(60);
+ FFACommand.gameType = "";
+ FFACommand.fighters.clear();
+ }
+ }
+ }
+ } else if(event.getEntity() instanceof Player && !(event.getEntity().getKiller() instanceof Player)) {
+
+ Player player = (Player) event.getEntity();
+
+ if(FFACommand.fighters.contains(player.getName())) {
+
+ FFACommand.fighters.remove(player.getName());
+
+ player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.RED + " has been eliminated from the FFA Event! (" + FFACommand.fighters.size() + ")");
+
+ if(FFACommand.fighters.size() < 2) {
+
+ Bukkit.broadcastMessage(ChatColor.AQUA.toString() + ChatColor.BOLD + FFACommand.fighters.get(0) + " HAS WON THE FFA EVENT!!!");
+
+ Player killer = Bukkit.getPlayer(FFACommand.fighters.get(0));
+
+ killer.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ spawn.teleportSpawn(killer);
+
+ firework.put(killer.getName(), 20);
+ FFACommand.enabled = false;
+ FFACommand.setTimer(60);
+ FFACommand.gameType = "";
+ FFACommand.fighters.clear();
+ }
+
+ }
+ }
+
+ }
+
+ @EventHandler
+ public void onDamager(EntityDamageByEntityEvent event) {
+
+ if(event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
+
+ Player damager = (Player) event.getDamager();
+
+ Player hit = (Player) event.getEntity();
+
+ if(FFACommand.enabled) {
+ if(FFACommand.fighters.contains(damager.getName()) && FFACommand.fighters.contains(hit.getName())) {
+ if(FFACommand.getTimer() > 0) {
+ damager.sendMessage(ChatColor.RED + "You can't damage anyone for another " + FFACommand.getTimer() + " seconds");
+ event.setCancelled(true);
+ }
+ }
+ }
+
+ }
+
+ if(event.getDamager() instanceof Projectile && event.getEntity() instanceof Player) {
+
+ Player hit = (Player) event.getEntity();
+
+ if(FFACommand.enabled) {
+ if(FFACommand.fighters.contains(hit.getName())) {
+ if(FFACommand.getTimer() > 0) {
+ event.setCancelled(true);
+ }
+ }
+ }
+ }
+
+ }
+
+ @EventHandler
+ public void onLeave(PlayerQuitEvent event) {
+ Player player = event.getPlayer();
+
+ if(FFACommand.fighters.contains(player.getName())) {
+ if(FFACommand.enabled) {
+
+ FFACommand.fighters.remove(player.getName());
+ Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.RED + " has left FFA (" + FFACommand.fighters.size() + "/80) [Disconnected]");
+
+ //if (FFACommand.getTimer() == 0) {
+ if (FFACommand.fighters.size() < 2) {
+ Bukkit.broadcastMessage(ChatColor.AQUA.toString()
+ + ChatColor.BOLD + FFACommand.fighters.get(0)
+ + " HAS WON THE FFA EVENT!!!");
+ for (String p : FFACommand.fighters) {
+ Player pl = Bukkit.getPlayer(p);
+
+ pl.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ spawn.teleportSpawn(pl);
+
+ }
+ firework.put(FFACommand.fighters.get(0), 20);
+ FFACommand.enabled = false;
+ FFACommand.setTimer(60);
+ FFACommand.gameType = "";
+ FFACommand.fighters.clear();
+ }
+ //}
+
+ }
+ }
+ }
+
+
+ public static HashMap getFirework() {
+ return firework;
+ }
+
+ public static void spawnFirework(Player player) {
+ Firework f = (Firework) player.getWorld().spawn(player.getLocation(), Firework.class);
+
+ FireworkMeta fm = f.getFireworkMeta();
+ fm.addEffect(FireworkEffect.builder()
+ .flicker(false)
+ .trail(true)
+ .with(Type.CREEPER)
+ .withColor(Color.GREEN)
+ .withFade(Color.BLUE)
+ .build());
+ fm.setPower(3);
+ f.setFireworkMeta(fm);
+ }
+}
diff --git a/src/me/iran/iranpvp/ffa/FFARunnable.java b/src/me/iran/iranpvp/ffa/FFARunnable.java
new file mode 100644
index 0000000..44e47b4
--- /dev/null
+++ b/src/me/iran/iranpvp/ffa/FFARunnable.java
@@ -0,0 +1,81 @@
+package me.iran.iranpvp.ffa;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.kit.KitManager;
+import me.iran.iranpvp.type.GameTypeManager;
+import me.iran.iranpvp.utils.TeleportSpawn;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.scheduler.BukkitRunnable;
+
+public class FFARunnable extends BukkitRunnable {
+
+ IranPvP plugin;
+
+ public FFARunnable(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ private KitManager km = new KitManager();
+ private TeleportSpawn spawn = new TeleportSpawn();
+
+
+ @Override
+ public void run() {
+ if(FFACommand.enabled) {
+ FFACommand.setTimer(FFACommand.getTimer() - 1);
+
+ if(FFACommand.getTimer() == 40) {
+ Bukkit.broadcastMessage(ChatColor.GOLD + "FFA Event Started! " + ChatColor.RED.toString() + ChatColor.BOLD + "/join" + ChatColor.GOLD + " (40 Seconds)");
+ } else if(FFACommand.getTimer() == 20) {
+ Bukkit.broadcastMessage(ChatColor.GOLD + "FFA Event Started! " + ChatColor.RED.toString() + ChatColor.BOLD + "/join" + ChatColor.GOLD + " (20 Seconds)");
+ } else if(FFACommand.getTimer() == 10) {
+ Bukkit.broadcastMessage(ChatColor.GOLD + "FFA Event Started! " + ChatColor.RED.toString() + ChatColor.BOLD + "/join" + ChatColor.GOLD + " (10 Seconds)");
+ } else if(FFACommand.getTimer() == 5) {
+ Bukkit.broadcastMessage(ChatColor.GOLD + "FFA Event Started! " + ChatColor.RED.toString() + ChatColor.BOLD + "/join" + ChatColor.GOLD + " (5 Seconds)");
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(FFACommand.fighters.contains(p.getName())) {
+ km.getKits(p, GameTypeManager.getManager().getGameTypeByName(FFACommand.gameType));
+ }
+ }
+
+ } else if(FFACommand.getTimer() == 4) {
+ Bukkit.broadcastMessage(ChatColor.GOLD + "FFA Event Started! " + ChatColor.RED.toString() + ChatColor.BOLD + "/join" + ChatColor.GOLD + " (4 Seconds)");
+ } else if(FFACommand.getTimer() == 3) {
+ Bukkit.broadcastMessage(ChatColor.GOLD + "FFA Event Started! " + ChatColor.RED.toString() + ChatColor.BOLD + "/join" + ChatColor.GOLD + " (3 Seconds)");
+ } else if(FFACommand.getTimer() == 2) {
+ Bukkit.broadcastMessage(ChatColor.GOLD + "FFA Event Started! " + ChatColor.RED.toString() + ChatColor.BOLD + "/join" + ChatColor.GOLD + " (2 Seconds)");
+ } else if(FFACommand.getTimer() == 1) {
+ Bukkit.broadcastMessage(ChatColor.GOLD + "FFA Event Started! " + ChatColor.RED.toString() + ChatColor.BOLD + "/join" + ChatColor.GOLD + " (1 Seconds)");
+ } else if(FFACommand.getTimer() == 0) {
+
+ if(FFACommand.fighters.size() < 2) {
+ for(String p : FFACommand.fighters) {
+ Player pl = Bukkit.getPlayer(p);
+
+ spawn.teleportSpawn(pl);
+
+ }
+
+ FFACommand.enabled = false;
+ FFACommand.setTimer(60);
+ FFACommand.fighters.clear();
+
+ Bukkit.broadcastMessage(ChatColor.RED.toString() + ChatColor.BOLD + "Not enough players, FFA event Stopped");
+
+ } else {
+
+ FFACommand.setTimer(0);
+
+ Bukkit.broadcastMessage(ChatColor.GREEN.toString() + ChatColor.BOLD + "FFA Event Started!");
+
+ }
+
+ }
+ }
+ }
+
+}
diff --git a/src/me/iran/iranpvp/kit/KitEvents.java b/src/me/iran/iranpvp/kit/KitEvents.java
new file mode 100644
index 0000000..a34e4b0
--- /dev/null
+++ b/src/me/iran/iranpvp/kit/KitEvents.java
@@ -0,0 +1,279 @@
+package me.iran.iranpvp.kit;
+
+import java.util.HashMap;
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.duel.Duel;
+import me.iran.iranpvp.duel.DuelManager;
+import me.iran.iranpvp.duel.team.TeamDuel;
+import me.iran.iranpvp.duel.team.TeamDuelManager;
+import me.iran.iranpvp.ffa.FFACommand;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.type.GameType;
+import me.iran.iranpvp.type.GameTypeManager;
+import me.iran.iranpvp.utils.CustomInventory;
+import me.iran.iranpvp.utils.TeleportSpawn;
+
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.block.Block;
+import org.bukkit.block.Sign;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.player.AsyncPlayerChatEvent;
+import org.bukkit.event.player.PlayerDropItemEvent;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+
+public class KitEvents implements Listener {
+
+ IranPvP plugin;
+
+ public KitEvents (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ KitManager km = new KitManager();
+ TeleportSpawn spawn = new TeleportSpawn();
+ CustomInventory inv = new CustomInventory();
+
+ private static HashMap editing = new HashMap<>();
+ private static HashMap naming = new HashMap<>();
+
+ @EventHandler
+ public void onDrop(PlayerDropItemEvent event) {
+ if(event.getItemDrop().getItemStack().getType() == Material.ENCHANTED_BOOK) {
+ event.setCancelled(true);
+ }
+
+ if(event.getItemDrop().getItemStack().getType() == Material.DIAMOND_SWORD) {
+ event.setCancelled(true);
+ }
+ }
+
+ @EventHandler
+ public void onChat(AsyncPlayerChatEvent event) {
+ Player player = event.getPlayer();
+
+ if(editing.containsKey(player.getName()) && naming.containsKey(player.getName())) {
+ GameType game = naming.get(player.getName());
+
+ km.createKit(player, game, event.getMessage().replace(" ", "_").toLowerCase());
+
+ player.playSound(player.getLocation(), Sound.ANVIL_USE, 10.0f, 10.0f);
+
+ naming.remove(player.getName());
+ event.setCancelled(true);
+ }
+ }
+
+ @EventHandler
+ public void onClick(PlayerInteractEvent event) {
+ Player player = event.getPlayer();
+
+ if(event.getClickedBlock() == null) {
+ return;
+ }
+
+ if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
+ Block b = event.getClickedBlock();
+ if ((b.getType() == Material.SIGN_POST) || (b.getType() == Material.WALL_SIGN)) {
+ Sign s = (Sign) b.getState();
+ if (s.getLine(0).equalsIgnoreCase("[Right Click]"))
+ if(editing.containsKey(player.getName()) && !naming.containsKey(player.getName())) {
+ editing.remove(player.getName());
+ spawn.teleportSpawn(player);
+
+ } else if(editing.containsKey(player.getName()) && naming.containsKey(player.getName())) {
+ player.sendMessage(ChatColor.RED + "Enter a kit name!");
+ player.playSound(player.getLocation(), Sound.ANVIL_BREAK, 10.0f, 10.0f);
+ }
+
+ }
+ }
+
+ if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
+
+ if(editing.containsKey(player.getName())) {
+ Block block = event.getClickedBlock();
+ if (block.getType() == Material.CHEST) {
+
+ GameType game = editing.get(player.getName());
+
+ event.setCancelled(true);
+ player.openInventory(km.openChest(player, game));
+ player.playSound(player.getLocation(), Sound.CHEST_OPEN, 10.0f, 10.0f);
+ }
+ }
+
+ }
+
+ if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
+
+ if(editing.containsKey(player.getName())) {
+ Block block = event.getClickedBlock();
+ if (block.getType() == Material.ANVIL) {
+
+ player.openInventory(inv.saveKitInventory(player));
+
+ event.setCancelled(true);
+
+ }
+ }
+
+ }
+ }
+
+ @EventHandler
+ public void loadKits(PlayerInteractEvent event) {
+
+ Player player = event.getPlayer();
+
+ if (event.getAction() == null) {
+ return;
+ }
+
+ if (player.getItemInHand() == null) {
+ return;
+ }
+
+ if (!player.getItemInHand().hasItemMeta()) {
+ return;
+ }
+
+ if (player.getItemInHand().getItemMeta().getDisplayName() == null) {
+ return;
+ }
+
+ if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
+
+ if(player.getItemInHand().getType() == Material.ENCHANTED_BOOK) {
+ if(DuelManager.getManager().isInDuel(player)) {
+ Duel duel = DuelManager.getManager().getDuelByPlayer(player);
+ String name = player.getItemInHand().getItemMeta().getDisplayName();
+
+ km.loadKit(player, duel.getGameType(), name);
+ } else if(TeamManager.getManager().isInTeam(player)) {
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ if(TeamDuelManager.getManager().isInDuel(team)) {
+
+ TeamDuel duel = TeamDuelManager.getManager().getDuelByTeam(team);
+
+ String name = player.getItemInHand().getItemMeta().getDisplayName();
+ km.loadKit(player, duel.getGameType(), name);
+ }
+ } else if(FFACommand.fighters.contains(player.getName())) {
+ String name = player.getItemInHand().getItemMeta().getDisplayName();
+ km.loadKit(player, GameTypeManager.getManager().getGameTypeByName(FFACommand.gameType), name);
+ }
+
+ }
+ }
+ }
+
+ @EventHandler
+ public void onClickEvent(InventoryClickEvent event) {
+ Player player = (Player) event.getWhoClicked();
+
+ if(event.getClickedInventory() == null) {
+ return;
+ }
+
+ if(event.getClickedInventory().getTitle() == null) {
+ return;
+ }
+
+ if(event.getCurrentItem() == null) {
+ return;
+ }
+
+ if(!event.getCurrentItem().hasItemMeta()) {
+ return;
+ }
+
+ if(event.getCurrentItem().getItemMeta().getDisplayName() == null) {
+ return;
+ }
+
+ if(event.getClickedInventory().getTitle().contains(ChatColor.GOLD + "Fighter")) {
+ event.setCancelled(true);
+ }
+
+ if(event.getClickedInventory().getTitle().equals(ChatColor.DARK_RED.toString() + ChatColor.BOLD + "Kit Options")) {
+ if(editing.containsKey(player.getName())) {
+
+ String option = ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName());
+
+ GameType game = editing.get(player.getName());
+
+ if(option.equalsIgnoreCase("cancel")) {
+
+ event.setCancelled(true);
+
+ player.closeInventory();
+
+ } else if(option.equalsIgnoreCase("save")) {
+
+ naming.put(player.getName(), game);
+
+ player.sendMessage(ChatColor.GREEN + "Type a name for your kit in chat");
+
+ player.playSound(player.getLocation(), Sound.NOTE_BASS_GUITAR, 10.0f, 10.0f);
+
+ event.setCancelled(true);
+
+ player.closeInventory();
+ } else if(option.equalsIgnoreCase("delete")) {
+
+ event.setCancelled(true);
+ player.closeInventory();
+ player.openInventory(inv.deleteKit(player, game));
+ }
+
+ }
+ }
+
+ if(event.getClickedInventory().getTitle().equals(ChatColor.DARK_RED.toString() + ChatColor.BOLD + "Delete Kit")) {
+ if(editing.containsKey(player.getName())) {
+
+ String name = ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName());
+
+ GameType game = editing.get(player.getName());
+
+ km.deleteKit(player, game, name);
+ event.setCancelled(true);
+ player.closeInventory();
+ player.openInventory(inv.deleteKit(player, game));
+ player.sendMessage(ChatColor.RED + "Deleted kit " + ChatColor.YELLOW + name);
+ }
+ }
+
+ }
+
+ @EventHandler
+ public void onQuit(PlayerQuitEvent event) {
+ Player player = event.getPlayer();
+
+ if(editing.containsKey(player.getName())) {
+ editing.remove(player.getName());
+ }
+
+ if(naming.containsKey(player.getName())) {
+ naming.remove(player.getName());
+ }
+
+ }
+
+ public static HashMap getEditing() {
+ return editing;
+ }
+
+ public static HashMap getNaming() {
+ return naming;
+ }
+}
\ No newline at end of file
diff --git a/src/me/iran/iranpvp/kit/KitManager.java b/src/me/iran/iranpvp/kit/KitManager.java
new file mode 100644
index 0000000..5264233
--- /dev/null
+++ b/src/me/iran/iranpvp/kit/KitManager.java
@@ -0,0 +1,440 @@
+package me.iran.iranpvp.kit;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.type.GameType;
+import net.md_5.bungee.api.ChatColor;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+public class KitManager {
+
+ File file = null;
+
+ public void deleteKit(Player player, GameType gameType, String name) {
+ file = new File(IranPvP.plugin.getDataFolder() + "/kits/" + player.getUniqueId().toString(), gameType.getName() + "_" + player.getUniqueId().toString() + ".yml");
+
+ if(file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder() + "/kits/" + player.getUniqueId().toString(), gameType.getName() + "_" + player.getUniqueId().toString() + ".yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration kConfig = YamlConfiguration.loadConfiguration(file);
+
+ kConfig.set(gameType.getName() + "." + name, null);
+ kConfig.set(gameType.getName() + ".size", kConfig.getInt(gameType.getName() + ".size") - 1);
+
+ try {
+ kConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+
+ if(kConfig.getInt(gameType.getName() + ".size") <= 0) {
+ file = new File(IranPvP.plugin.getDataFolder() + "/kits/" + player.getUniqueId().toString(), gameType.getName() + "_" + player.getUniqueId().toString() + ".yml");
+ file.delete();
+ }
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ }
+ }
+
+ public void createKit(Player player, GameType gameType, String name) {
+ file = new File(IranPvP.plugin.getDataFolder() + "/kits/" + player.getUniqueId().toString(), gameType.getName() + "_" + player.getUniqueId().toString() + ".yml");
+
+ if(!file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder() + "/kits/" + player.getUniqueId().toString(), gameType.getName() + "_" + player.getUniqueId().toString() + ".yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration kConfig = YamlConfiguration.loadConfiguration(file);
+
+ //Debuff > name > items
+
+
+ kConfig.createSection(gameType.getName() + "." + name + ".inv");
+ kConfig.createSection(gameType.getName() + "." + name + ".armor");
+ kConfig.createSection(gameType.getName() + ".size");
+ kConfig.createSection(gameType.getName() + "." + name + ".name");
+
+ kConfig.set(gameType.getName() + "." + name + ".inv", player.getInventory().getContents());
+ kConfig.set(gameType.getName() + "." + name + ".armor", player.getInventory().getArmorContents());
+ kConfig.set(gameType.getName() + ".size", 1);
+ kConfig.set(gameType.getName() + "." + name + ".name", name);
+
+ if(name.equalsIgnoreCase("name") || name.equalsIgnoreCase("size") || name.equalsIgnoreCase("inv") || name.equalsIgnoreCase("armor")) {
+ player.sendMessage(ChatColor.RED + "Sorry you can't name your kit the following names: name, size, inv, armor");
+ return;
+ }
+
+ try {
+ kConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ player.sendMessage(ChatColor.GREEN + "Kit " + ChatColor.YELLOW + name + ChatColor.GREEN +" Created for GameType: " + ChatColor.GOLD + gameType.getName());
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ } else {
+
+ file = new File(IranPvP.plugin.getDataFolder() + "/kits/" + player.getUniqueId().toString(), gameType.getName() + "_" + player.getUniqueId().toString() + ".yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration kConfig = YamlConfiguration.loadConfiguration(file);
+
+ if(kConfig.getInt(gameType.getName() + ".size") == 4) {
+ player.sendMessage(ChatColor.RED + "Reached the Maximum amount of kits you can create");
+ return;
+ }
+
+ if(kConfig.contains(gameType.getName() + "." + name)) {
+ player.sendMessage(ChatColor.RED + "You already have a kit with that name");
+ return;
+ }
+
+ if(name.equalsIgnoreCase("name") || name.equalsIgnoreCase("size") || name.equalsIgnoreCase("inv") || name.equalsIgnoreCase("armor")) {
+ player.sendMessage(ChatColor.RED + "Sorry you can't name your kit the following names: name, size, inv, armor");
+ return;
+ }
+
+ kConfig.set(gameType.getName() + "." + name + ".inv", player.getInventory().getContents());
+ kConfig.set(gameType.getName() + "." + name + ".armor", player.getInventory().getArmorContents());
+ kConfig.set(gameType.getName() + ".size", kConfig.getInt(gameType.getName() + ".size") + 1);
+ kConfig.set(gameType.getName() + "." + name + ".name", name);
+
+ try {
+ kConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ player.sendMessage(ChatColor.GREEN + "Kit " + ChatColor.YELLOW + name + ChatColor.GREEN +" Created for GameType: " + ChatColor.GOLD + gameType.getName());
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+ }
+ }
+
+ public void getKits(Player player, GameType gameType) {
+
+ file = new File(IranPvP.plugin.getDataFolder() + "/kits/" + player.getUniqueId().toString(), gameType.getName() + "_" + player.getUniqueId().toString() + ".yml");
+
+ if(file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder() + "/kits/" + player.getUniqueId().toString(), gameType.getName() + "_" + player.getUniqueId().toString() + ".yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration kConfig = YamlConfiguration.loadConfiguration(file);
+
+ List kits = new ArrayList<>();
+
+ ItemStack book = new ItemStack(Material.ENCHANTED_BOOK);
+ ItemMeta bookMeta = book.getItemMeta();
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ for(String name : kConfig.getConfigurationSection(gameType.getName()).getKeys(false)) {
+
+ kits.add(name.toLowerCase());
+
+ if(kits.contains("name")) {
+ kits.remove("name");
+ }
+
+ if(kits.contains("inv")) {
+ kits.remove("inv");
+ }
+
+ if(kits.contains("armor")) {
+ kits.remove("armor");
+ }
+
+ if(kits.contains("size")) {
+ kits.remove("size");
+ }
+
+ if(TeamManager.getManager().isInTeam(player)) {
+
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ if(team.getBard().contains(player.getName())) {
+
+ List bard = new ArrayList();
+
+ for(int i = 0; i < kits.size(); i++) {
+
+ if(kits.get(i).contains("bard")) {
+ bard.add(kits.get(i));
+ }
+ }
+
+ if(bard.size() <= 0) {
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ if(kits.size() <= 0) {
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ player.getInventory().setContents(gameType.getInv());
+ player.getInventory().setArmorContents(gameType.getArmor());
+
+ } else {
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ for(int i = 0; i < kits.size(); i++) {
+
+ bookMeta.setDisplayName(kits.get(i));
+ book.setItemMeta(bookMeta);
+ player.getInventory().setItem(i, book);
+
+ }
+ }
+
+ } else {
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ for(int i = 0; i < bard.size(); i++) {
+
+ bookMeta.setDisplayName(bard.get(i));
+ book.setItemMeta(bookMeta);
+ player.getInventory().setItem(i, book);
+
+ }
+ }
+
+
+ } else {
+
+ for(int i = 0; i < kits.size(); i++) {
+
+ if(kits.get(i).contains("bard")) {
+ kits.remove(kits.get(i));
+ }
+
+ }
+
+ if(kits.size() <= 0) {
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ player.getInventory().setContents(gameType.getInv());
+ player.getInventory().setArmorContents(gameType.getArmor());
+
+ } else {
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ for(int i = 0; i < kits.size(); i++) {
+ bookMeta.setDisplayName(kits.get(i));
+ book.setItemMeta(bookMeta);
+ player.getInventory().setItem(i, book);
+
+ }
+ }
+ }
+
+ } else {
+
+ if(kits.size() <= 0) {
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ player.getInventory().setContents(gameType.getInv());
+ player.getInventory().setArmorContents(gameType.getArmor());
+
+ } else {
+
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ for(int i = 0; i < kits.size(); i++) {
+
+ if(kits.get(i).contains("bard")) {
+ kits.remove(kits.get(i));
+ } else {
+ bookMeta.setDisplayName(kits.get(i));
+ book.setItemMeta(bookMeta);
+ player.getInventory().setItem(i, book);
+ }
+ }
+ }
+ }
+ }
+ } else {
+
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ player.getInventory().setContents(gameType.getInv());
+ player.getInventory().setArmorContents(gameType.getArmor());
+ }
+ }
+
+ public void setChest(Player player, GameType gameType, Inventory inv) {
+ file = new File(IranPvP.plugin.getDataFolder(), gameType.getName() + "_chest.yml");
+
+ if(!file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder(), gameType.getName() + "_chest.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration kConfig = YamlConfiguration.loadConfiguration(file);
+
+ kConfig.createSection(gameType.getName() + ".inv");
+
+
+ kConfig.set(gameType.getName() + ".inv", inv.getContents());
+
+ try {
+ kConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ } else {
+ file = new File(IranPvP.plugin.getDataFolder(), gameType.getName() + "_chest.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration kConfig = YamlConfiguration.loadConfiguration(file);
+
+ kConfig.set(gameType.getName() + ".inv", inv.getContents());
+
+ try {
+ kConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ player.updateInventory();
+
+ }
+
+ public void loadKit(Player player, GameType gameType, String name) {
+
+ file = new File(IranPvP.plugin.getDataFolder() + "/kits/" + player.getUniqueId().toString(), gameType.getName() + "_" + player.getUniqueId().toString() + ".yml");
+
+ if(file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder() + "/kits/" + player.getUniqueId().toString(), gameType.getName() + "_" + player.getUniqueId().toString() + ".yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration kConfig = YamlConfiguration.loadConfiguration(file);
+
+ ItemStack[] inv = player.getInventory().getContents();
+ ItemStack[] armor = player.getInventory().getArmorContents();
+
+ if(!kConfig.contains(gameType.getName() + "." + name)) {
+ player.sendMessage(ChatColor.RED + "You don't own that kit");
+ return;
+ }
+
+ List> items = kConfig.getList(gameType.getName() + "." + name + ".inv");
+ List> armorItems = kConfig.getList(gameType.getName() + "." + name + ".armor");
+
+ for(int i = 0; i < items.size(); i++) {
+ inv[i] = (ItemStack) items.get(i);
+ }
+ for(int i = 0; i < armorItems.size(); i++) {
+ armor[i] = (ItemStack) armorItems.get(i);
+ }
+
+ player.getInventory().clear();
+ player.getInventory().setContents(inv);
+ player.getInventory().setArmorContents(armor);
+ player.updateInventory();
+ player.sendMessage(ChatColor.GREEN + "Loaded your Kit!");
+
+ } else {
+ player.getInventory().setContents(gameType.getInv());
+ player.getInventory().setArmorContents(gameType.getArmor());
+ }
+ }
+
+ public Inventory openChest(Player player, GameType gameType) {
+
+ Inventory inv = Bukkit.createInventory(null, 54, gameType.getName());
+
+ file = new File(IranPvP.plugin.getDataFolder(), gameType.getName() + "_chest.yml");
+
+ if(file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder(), gameType.getName() + "_chest.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration kitConfig = YamlConfiguration.loadConfiguration(file);
+
+ if (gameType.getEdit()) {
+
+ List> items = kitConfig.getList(gameType.getName() + ".inv");
+
+ for (int i = 0; i < items.size(); i++) {
+ ItemStack item = (ItemStack) items.get(i);
+ inv.setItem(i, item);
+ }
+ }
+ }
+
+ return inv;
+ }
+
+ public Inventory openEditorChest(Player player, GameType gameType) {
+
+ Inventory inv = Bukkit.createInventory(null, 54, ChatColor.BLUE + "Edit Chest");
+
+ file = new File(IranPvP.plugin.getDataFolder(), gameType.getName() + "_chest.yml");
+
+ if(file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder(), gameType.getName() + "_chest.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration kitConfig = YamlConfiguration.loadConfiguration(file);
+
+ if (gameType.getEdit()) {
+
+ List> items = kitConfig.getList(gameType.getName() + ".inv");
+
+ for (int i = 0; i < items.size(); i++) {
+ ItemStack item = (ItemStack) items.get(i);
+ inv.setItem(i, item);
+ }
+ }
+ }
+
+ return inv;
+ }
+}
\ No newline at end of file
diff --git a/src/me/iran/iranpvp/kit/bard/Bard.java b/src/me/iran/iranpvp/kit/bard/Bard.java
new file mode 100644
index 0000000..48d6964
--- /dev/null
+++ b/src/me/iran/iranpvp/kit/bard/Bard.java
@@ -0,0 +1,191 @@
+package me.iran.iranpvp.kit.bard;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.utils.ScoreboardUtils;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionEffectType;
+import org.bukkit.scheduler.BukkitRunnable;
+
+public class Bard extends BukkitRunnable {
+
+ ScoreboardUtils sb = new ScoreboardUtils();
+
+ public void bard(Player player) {
+
+ ItemStack helmet = player.getInventory().getHelmet();
+ ItemStack chest = player.getInventory().getChestplate();
+ ItemStack leggings = player.getInventory().getLeggings();
+ ItemStack boots = player.getInventory().getBoots();
+
+ if(TeamManager.getManager().isInTeam(player)) {
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+
+ if(helmet != null && chest != null && leggings != null && boots != null) {
+ if (helmet.getType() == Material.GOLD_HELMET && chest.getType() == Material.GOLD_CHESTPLATE && leggings.getType() == Material.GOLD_LEGGINGS && boots.getType() == Material.GOLD_BOOTS) {
+ if(team.getBard().contains(player.getName()) && BardManager.getManager().isBard(player)) {
+
+ sb.add(player, player.getScoreboard(), ChatColor.DARK_RED, "energy", ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.ENERGY")));
+
+ player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100000000, 1));
+ player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 100000000, 1));
+ player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 100000000, 0));
+ player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100000000, 0));
+
+ } else if(!team.getBard().equals(player.getName())) {
+
+ sb.remove(player, player.getScoreboard(), "energy", ChatColor.DARK_RED);
+
+ player.removePotionEffect(PotionEffectType.SPEED);
+ player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
+ player.removePotionEffect(PotionEffectType.NIGHT_VISION);
+ player.removePotionEffect(PotionEffectType.REGENERATION);
+ }
+
+ }
+ } else {
+ if(team.getBard().contains(player.getName())) {
+
+ BardManager.getManager().getBardByName(player).setEnergy(25);
+
+ sb.remove(player, player.getScoreboard(), "energy", ChatColor.DARK_RED);
+
+ player.removePotionEffect(PotionEffectType.SPEED);
+ player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
+ player.removePotionEffect(PotionEffectType.NIGHT_VISION);
+ player.removePotionEffect(PotionEffectType.REGENERATION);
+ }
+ }
+
+ }
+
+ }
+
+ public void passiveEffects(Player player) {
+
+ if (player.getItemInHand() == null) {
+ return;
+ }
+
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ if (!TeamManager.getManager().getAllTeams().contains(team)) {
+ return;
+ }
+
+ if (BardManager.getManager().isBard(player)) {
+
+ // SPEED
+ if (player.getItemInHand().getType() == Material.SUGAR) {
+
+ PotionEffect effect = new PotionEffect(PotionEffectType.SPEED, 100, 1);
+
+
+ for(Entity p : player.getNearbyEntities(24, 24, 24)) {
+ if(p instanceof Player) {
+ Player near = (Player) p;
+ if(team.getTeamMembers().contains(near.getName())) {
+ near.addPotionEffect(effect);
+ }
+ }
+ }
+ }
+
+ if (player.getItemInHand().getType() == Material.BLAZE_POWDER) {
+
+ PotionEffect effect = new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 100, 0);
+
+ for(Entity p : player.getNearbyEntities(24, 24, 24)) {
+ if(p instanceof Player) {
+ Player near = (Player) p;
+ if(team.getTeamMembers().contains(near.getName())) {
+ near.addPotionEffect(effect);
+ }
+ }
+ }
+
+ }
+
+ if (player.getItemInHand().getType() == Material.GHAST_TEAR) {
+
+ PotionEffect effect = new PotionEffect(PotionEffectType.REGENERATION, 100, 0);
+
+ for(Entity p : player.getNearbyEntities(24, 24, 24)) {
+ if(p instanceof Player) {
+ Player near = (Player) p;
+ if(team.getTeamMembers().contains(near.getName())) {
+ near.addPotionEffect(effect);
+ }
+ }
+ }
+
+ }
+
+ if (player.getItemInHand().getType() == Material.FEATHER) {
+
+ PotionEffect effect = new PotionEffect(PotionEffectType.JUMP, 100, 1);
+
+ for(Entity p : player.getNearbyEntities(24, 24, 24)) {
+ if(p instanceof Player) {
+ Player near = (Player) p;
+ if(team.getTeamMembers().contains(near.getName())) {
+ near.addPotionEffect(effect);
+ }
+ }
+ }
+
+ }
+
+ if (player.getItemInHand().getType() == Material.IRON_INGOT) {
+
+ PotionEffect effect = new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 100, 0);
+
+ for(Entity p : player.getNearbyEntities(24, 24, 24)) {
+ if(p instanceof Player) {
+ Player near = (Player) p;
+ if(team.getTeamMembers().contains(near.getName())) {
+ near.addPotionEffect(effect);
+ }
+ }
+ }
+
+ }
+
+ if (player.getItemInHand().getType() == Material.MAGMA_CREAM) {
+
+ PotionEffect effect = new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 100, 0);
+
+ for(Entity p : player.getNearbyEntities(24, 24, 24)) {
+ if(p instanceof Player) {
+ Player near = (Player) p;
+ if(team.getTeamMembers().contains(near.getName())) {
+ near.addPotionEffect(effect);
+ }
+ }
+ }
+
+ }
+
+ }
+
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void run() {
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ passiveEffects(p);
+ }
+
+ }
+}
diff --git a/src/me/iran/iranpvp/kit/bard/BardClass.java b/src/me/iran/iranpvp/kit/bard/BardClass.java
new file mode 100644
index 0000000..fcf8bcc
--- /dev/null
+++ b/src/me/iran/iranpvp/kit/bard/BardClass.java
@@ -0,0 +1,33 @@
+package me.iran.iranpvp.kit.bard;
+
+public class BardClass {
+
+ private int energy;
+ private String player;
+ private final int MAX_ENERGY = 200;
+
+ public BardClass(String player) {
+ energy = 0;
+ this.player = player;
+ }
+
+ public void setPlayer(String player) {
+ this.player = player;
+ }
+
+ public void setEnergy(int energy) {
+ this.energy = energy;
+ }
+
+ public String getPlayer() {
+ return player;
+ }
+
+ public int getEnerg() {
+ return energy;
+ }
+
+ public int getMax() {
+ return MAX_ENERGY;
+ }
+}
diff --git a/src/me/iran/iranpvp/kit/bard/BardEvent.java b/src/me/iran/iranpvp/kit/bard/BardEvent.java
new file mode 100644
index 0000000..b037b56
--- /dev/null
+++ b/src/me/iran/iranpvp/kit/bard/BardEvent.java
@@ -0,0 +1,416 @@
+package me.iran.iranpvp.kit.bard;
+
+import java.util.HashMap;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.duel.team.TeamDuelManager;
+import me.iran.iranpvp.teams.Team;
+import me.iran.iranpvp.teams.TeamManager;
+
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionEffectType;
+
+public class BardEvent implements Listener {
+
+ IranPvP plugin;
+
+ public BardEvent (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ public static HashMap kitCooldown = new HashMap();
+
+ @EventHandler
+ public void onRightClick(PlayerInteractEvent event) {
+ if(event.getAction() == null) {
+ return;
+ }
+
+ Player player = event.getPlayer();
+
+ if(BardManager.getManager().isBard(player)) {
+
+ BardClass bard = BardManager.getManager().getBardByName(player);
+
+ if(TeamManager.getManager().getTeamByPlayer(player) != null && TeamDuelManager.getManager().isInDuel(TeamManager.getManager().getTeamByPlayer(player))) {
+
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
+
+ if(player.getInventory().getItemInHand() == null) {
+ return;
+ }
+
+ /*
+ * Jump Boost
+ */
+
+ if(player.getItemInHand().getType() == Material.FEATHER) {
+
+ if(kitCooldown.containsKey(player.getName()) && kitCooldown.get(player.getName()) > System.currentTimeMillis()) {
+
+ long timer = kitCooldown.get(player.getName()) - System.currentTimeMillis();
+ player.sendMessage(ChatColor.RED.toString() + "Can't used Bard Effects for another " + ChatColor.BOLD + timer/1000 + "'s");
+
+ } else {
+
+ int power = IranPvP.plugin.getConfig().getInt("BARD.JUMP_BOOST.POWER");
+ int duration = IranPvP.plugin.getConfig().getInt("BARD.JUMP_BOOST.DURATION");
+ int cooldown = IranPvP.plugin.getConfig().getInt("BARD.JUMP_BOOST.COOLDOWN");
+ int amp = IranPvP.plugin.getConfig().getInt("BARD.JUMP_BOOST.AMPLIFIER");
+
+ String msg = ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("BARD.MESSAGE").replace("%effect%", "Jump Boost").replace("%bard%", player.getName()));
+
+ if(power < bard.getEnerg()) {
+
+ bard.setEnergy(bard.getEnerg() - power);
+
+ kitCooldown.put(player.getName(), System.currentTimeMillis() + (cooldown * 1000));
+
+ player.sendMessage(msg);
+ player.removePotionEffect(PotionEffectType.JUMP);
+ player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 20 * duration, amp));
+
+ for (Entity p : player.getNearbyEntities(24,
+ 24, 24)) {
+ if (p instanceof Player) {
+
+ Player near = (Player) p;
+
+ if (team.getTeamMembers().contains(near.getName())) {
+ near.removePotionEffect(PotionEffectType.JUMP);
+ near.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 200, 3));
+ near.sendMessage(msg);
+
+ }
+ }
+ }
+
+ if(player.getItemInHand().getAmount() > 1) {
+ player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
+ } else {
+ player.setItemInHand(null);
+ }
+
+ } else {
+ player.sendMessage(ChatColor.RED + "Not enough power");
+ }
+
+ }
+
+ }
+
+
+ /*
+ * Strength
+ */
+
+ if(player.getItemInHand().getType() == Material.BLAZE_POWDER) {
+
+ if(kitCooldown.containsKey(player.getName()) && kitCooldown.get(player.getName()) > System.currentTimeMillis()) {
+
+ long timer = kitCooldown.get(player.getName()) - System.currentTimeMillis();
+ player.sendMessage(ChatColor.RED.toString() + "Can't used Bard Effects for another " + ChatColor.BOLD + timer/1000 + "'s");
+
+ } else {
+
+ int power = IranPvP.plugin.getConfig().getInt("BARD.STRENGTH.POWER");
+ int duration = IranPvP.plugin.getConfig().getInt("BARD.STRENGTH.DURATION");
+ int cooldown = IranPvP.plugin.getConfig().getInt("BARD.STRENGTH.COOLDOWN");
+ int amp = IranPvP.plugin.getConfig().getInt("BARD.STRENGTH.AMPLIFIER");
+
+ String msg = ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("BARD.MESSAGE").replace("%effect%", "Strength").replace("%bard%", player.getName()));
+
+ if(power < bard.getEnerg()) {
+
+ bard.setEnergy(bard.getEnerg() - power);
+
+ kitCooldown.put(player.getName(), System.currentTimeMillis() + (cooldown * 1000));
+
+ player.sendMessage(msg);
+ player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE);
+ player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 20 * duration, amp));
+
+ for (Entity p : player.getNearbyEntities(24,
+ 24, 24)) {
+ if (p instanceof Player) {
+
+ Player near = (Player) p;
+
+ if (team.getTeamMembers().contains(near.getName())) {
+ near.removePotionEffect(PotionEffectType.INCREASE_DAMAGE);
+ near.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 20 * duration, amp));
+ near.sendMessage(msg);
+
+ }
+ }
+ }
+
+ if(player.getItemInHand().getAmount() > 1) {
+ player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
+ } else {
+ player.setItemInHand(null);
+ }
+
+ } else {
+ player.sendMessage(ChatColor.RED + "Not enough power");
+ }
+
+ }
+
+ }
+
+ /*
+ * Speed
+ */
+
+ if(player.getItemInHand().getType() == Material.SUGAR) {
+
+ if(kitCooldown.containsKey(player.getName()) && kitCooldown.get(player.getName()) > System.currentTimeMillis()) {
+
+ long timer = kitCooldown.get(player.getName()) - System.currentTimeMillis();
+ player.sendMessage(ChatColor.RED.toString() + "Can't used Bard Effects for another " + ChatColor.BOLD + timer/1000 + "'s");
+
+ } else {
+
+ int power = IranPvP.plugin.getConfig().getInt("BARD.SPEED.POWER");
+ int duration = IranPvP.plugin.getConfig().getInt("BARD.SPEED.DURATION");
+ int cooldown = IranPvP.plugin.getConfig().getInt("BARD.SPEED.COOLDOWN");
+ int amp = IranPvP.plugin.getConfig().getInt("BARD.SPEED.AMPLIFIER");
+
+ String msg = ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("BARD.MESSAGE").replace("%effect%", "Speed").replace("%bard%", player.getName()));
+
+ if(power < bard.getEnerg()) {
+
+ bard.setEnergy(bard.getEnerg() - power);
+
+ kitCooldown.put(player.getName(), System.currentTimeMillis() + (cooldown * 1000));
+
+ player.sendMessage(msg);
+ player.removePotionEffect(PotionEffectType.SPEED);
+ player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20 * duration, amp));
+
+ for (Entity p : player.getNearbyEntities(24,
+ 24, 24)) {
+ if (p instanceof Player) {
+
+ Player near = (Player) p;
+
+ if (team.getTeamMembers().contains(near.getName())) {
+ near.removePotionEffect(PotionEffectType.SPEED);
+ near.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20 * duration, amp));
+ near.sendMessage(msg);
+
+ }
+ }
+ }
+
+ if(player.getItemInHand().getAmount() > 1) {
+ player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
+ } else {
+ player.setItemInHand(null);
+ }
+
+ } else {
+ player.sendMessage(ChatColor.RED + "Not enough power");
+ }
+
+ }
+
+ }
+
+ /*
+ * Regeneration
+ */
+
+ if(player.getItemInHand().getType() == Material.GHAST_TEAR) {
+
+ if(kitCooldown.containsKey(player.getName()) && kitCooldown.get(player.getName()) > System.currentTimeMillis()) {
+
+ long timer = kitCooldown.get(player.getName()) - System.currentTimeMillis();
+ player.sendMessage(ChatColor.RED.toString() + "Can't used Bard Effects for another " + ChatColor.BOLD + timer/1000 + "'s");
+
+ } else {
+
+ int power = IranPvP.plugin.getConfig().getInt("BARD.REGENERATION.POWER");
+ int duration = IranPvP.plugin.getConfig().getInt("BARD.REGENERATION.DURATION");
+ int cooldown = IranPvP.plugin.getConfig().getInt("BARD.REGENERATION.COOLDOWN");
+ int amp = IranPvP.plugin.getConfig().getInt("BARD.REGENERATION.AMPLIFIER");
+
+ String msg = ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("BARD.MESSAGE").replace("%effect%", "Regeneration").replace("%bard%", player.getName()));
+
+ if(power < bard.getEnerg()) {
+
+ bard.setEnergy(bard.getEnerg() - power);
+
+ kitCooldown.put(player.getName(), System.currentTimeMillis() + (cooldown * 1000));
+
+ player.sendMessage(msg);
+ player.removePotionEffect(PotionEffectType.REGENERATION);
+ player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * duration, amp));
+
+ for (Entity p : player.getNearbyEntities(24,
+ 24, 24)) {
+ if (p instanceof Player) {
+
+ Player near = (Player) p;
+
+ if (team.getTeamMembers().contains(near.getName())) {
+ near.removePotionEffect(PotionEffectType.REGENERATION);
+ near.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * duration, amp));
+ near.sendMessage(msg);
+
+ }
+ }
+ }
+
+ if(player.getItemInHand().getAmount() > 1) {
+ player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
+ } else {
+ player.setItemInHand(null);
+ }
+
+ } else {
+ player.sendMessage(ChatColor.RED + "Not enough power");
+ }
+
+ }
+
+ }
+
+ /*
+ * Fire Resistance
+ */
+
+ if(player.getItemInHand().getType() == Material.MAGMA_CREAM) {
+
+ if(kitCooldown.containsKey(player.getName()) && kitCooldown.get(player.getName()) > System.currentTimeMillis()) {
+
+ long timer = kitCooldown.get(player.getName()) - System.currentTimeMillis();
+ player.sendMessage(ChatColor.RED.toString() + "Can't used Bard Effects for another " + ChatColor.BOLD + timer/1000 + "'s");
+
+ } else {
+
+ int power = IranPvP.plugin.getConfig().getInt("BARD.FIRE_RESISTANCE.POWER");
+ int duration = IranPvP.plugin.getConfig().getInt("BARD.FIRE_RESISTANCE.DURATION");
+ int cooldown = IranPvP.plugin.getConfig().getInt("BARD.FIRE_RESISTANCE.COOLDOWN");
+ int amp = IranPvP.plugin.getConfig().getInt("BARD.FIRE_RESISTANCE.AMPLIFIER");
+
+ String msg = ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("BARD.MESSAGE").replace("%effect%", "Fire Resistance").replace("%bard%", player.getName()));
+
+ if(power < bard.getEnerg()) {
+
+ bard.setEnergy(bard.getEnerg() - power);
+
+ kitCooldown.put(player.getName(), System.currentTimeMillis() + (cooldown * 1000));
+
+ player.sendMessage(msg);
+ player.removePotionEffect(PotionEffectType.FIRE_RESISTANCE);
+ player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 20 * duration, amp));
+
+ for (Entity p : player.getNearbyEntities(24,
+ 24, 24)) {
+ if (p instanceof Player) {
+
+ Player near = (Player) p;
+
+ if (team.getTeamMembers().contains(near.getName())) {
+ near.removePotionEffect(PotionEffectType.FIRE_RESISTANCE);
+ near.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 20 * duration, amp));
+ near.sendMessage(msg);
+
+ }
+ }
+ }
+
+ if(player.getItemInHand().getAmount() > 1) {
+ player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
+ } else {
+ player.setItemInHand(null);
+ }
+
+ } else {
+ player.sendMessage(ChatColor.RED + "Not enough power");
+ }
+
+ }
+
+ }
+
+
+ /*
+ * Resistance
+ */
+
+ if(player.getItemInHand().getType() == Material.IRON_INGOT) {
+
+ if(kitCooldown.containsKey(player.getName()) && kitCooldown.get(player.getName()) > System.currentTimeMillis()) {
+
+ long timer = kitCooldown.get(player.getName()) - System.currentTimeMillis();
+ player.sendMessage(ChatColor.RED.toString() + "Can't used Bard Effects for another " + ChatColor.BOLD + timer/1000 + "'s");
+
+ } else {
+
+ int power = IranPvP.plugin.getConfig().getInt("BARD.RESISTANCE.POWER");
+ int duration = IranPvP.plugin.getConfig().getInt("BARD.RESISTANCE.DURATION");
+ int cooldown = IranPvP.plugin.getConfig().getInt("BARD.RESISTANCE.COOLDOWN");
+ int amp = IranPvP.plugin.getConfig().getInt("BARD.RESISTANCE.AMPLIFIER");
+
+ String msg = ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("BARD.MESSAGE").replace("%effect%", "Resistance").replace("%bard%", player.getName()));
+
+ if(power < bard.getEnerg()) {
+
+ bard.setEnergy(bard.getEnerg() - power);
+
+ kitCooldown.put(player.getName(), System.currentTimeMillis() + (cooldown * 1000));
+
+ player.sendMessage(msg);
+ player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
+ player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * duration, amp));
+
+ for (Entity p : player.getNearbyEntities(24,
+ 24, 24)) {
+ if (p instanceof Player) {
+
+ Player near = (Player) p;
+
+ if (team.getTeamMembers().contains(near.getName())) {
+ near.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
+ near.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * duration, amp));
+ near.sendMessage(msg);
+
+ }
+ }
+ }
+
+ if(player.getItemInHand().getAmount() > 1) {
+ player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
+ } else {
+ player.setItemInHand(null);
+ }
+
+ } else {
+ player.sendMessage(ChatColor.RED + "Not enough power");
+ }
+
+ }
+
+ }
+
+
+ }
+
+ }
+
+ }
+ }
+}
diff --git a/src/me/iran/iranpvp/kit/bard/BardManager.java b/src/me/iran/iranpvp/kit/bard/BardManager.java
new file mode 100644
index 0000000..55c3f86
--- /dev/null
+++ b/src/me/iran/iranpvp/kit/bard/BardManager.java
@@ -0,0 +1,73 @@
+package me.iran.iranpvp.kit.bard;
+
+import java.util.ArrayList;
+
+import me.iran.iranpvp.type.GameTypeManager;
+
+import org.bukkit.entity.Player;
+
+public class BardManager {
+
+ private static ArrayList bards = new ArrayList<>();
+
+ private static BardManager bm;
+
+ private BardManager() {}
+
+ public static BardManager getManager() {
+ if (bm == null)
+ bm = new BardManager();
+
+ return bm;
+ }
+
+ public void createBard(Player player) {
+
+ if(isBard(player)) {
+ return;
+ }
+
+ BardClass bard = new BardClass(player.getName());
+
+ bards.add(bard);
+
+ bard.setEnergy(50);
+
+ }
+
+ public boolean isBard(Player player) {
+
+ for(BardClass bard : bards) {
+ if(bard.getPlayer().equalsIgnoreCase(player.getName())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public BardClass getBardByName(Player player) {
+
+ for(BardClass bard : bards) {
+ if(bard.getPlayer().equalsIgnoreCase(player.getName())) {
+ return bard;
+ }
+ }
+
+ return null;
+ }
+
+ public void removeBard(Player player) {
+
+ if(isBard(player)) {
+ bards.remove(getBardByName(player));
+
+ }
+
+ }
+
+ public ArrayList getAllBards() {
+ return bards;
+ }
+
+}
diff --git a/src/me/iran/iranpvp/runnable/Run.java b/src/me/iran/iranpvp/runnable/Run.java
new file mode 100644
index 0000000..ca363f5
--- /dev/null
+++ b/src/me/iran/iranpvp/runnable/Run.java
@@ -0,0 +1,524 @@
+package me.iran.iranpvp.runnable;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.Arena;
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.duel.Duel;
+import me.iran.iranpvp.duel.DuelManager;
+import me.iran.iranpvp.duel.team.TeamDuel;
+import me.iran.iranpvp.duel.team.TeamDuelManager;
+import me.iran.iranpvp.duel.team.TeamFight;
+import me.iran.iranpvp.duel.team.TeamFightManager;
+import me.iran.iranpvp.events.duel.DeathInventory;
+import me.iran.iranpvp.events.teamfight.KothDeathEvent;
+import me.iran.iranpvp.ffa.FFACommand;
+import me.iran.iranpvp.ffa.FFAEvent;
+import me.iran.iranpvp.kit.bard.Bard;
+import me.iran.iranpvp.kit.bard.BardClass;
+import me.iran.iranpvp.kit.bard.BardManager;
+import me.iran.iranpvp.teams.TeamManager;
+import me.iran.iranpvp.type.GameType;
+import me.iran.iranpvp.type.GameTypeManager;
+import me.iran.iranpvp.utils.EnderpearlCooldown;
+import me.iran.iranpvp.utils.Queue;
+import me.iran.iranpvp.utils.ScoreboardUtils;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.scheduler.BukkitRunnable;
+import org.bukkit.scoreboard.DisplaySlot;
+import org.bukkit.scoreboard.Scoreboard;
+import org.bukkit.scoreboard.Team;
+
+public class Run extends BukkitRunnable {
+
+ IranPvP plugin;
+
+ public Run(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ private Queue queue = new Queue();
+
+ private Bard bard = new Bard();
+
+ private ScoreboardUtils sb = new ScoreboardUtils();
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void run() {
+ queue.unrankedMatch();
+ queue.rankedMatch();
+
+ kothTimer();
+
+ for(Duel duel : DuelManager.getManager().getAllDuels()) {
+ duel.setTimer(duel.getTimer() + 1);
+ }
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+
+ if(KothDeathEvent.cooldown.containsKey(p.getName())) {
+
+ KothDeathEvent.cooldown.put(p.getName(), KothDeathEvent.cooldown.get(p.getName()) - 1);
+
+ if(KothDeathEvent.cooldown.get(p.getName()) <= 0) {
+
+ KothDeathEvent.cooldown.remove(p.getName());
+
+ if(KothDeathEvent.lives.containsKey(p.getName()) && KothDeathEvent.lives.get(p.getName()) > 0) {
+
+ KothDeathEvent.lives.put(p.getName(), KothDeathEvent.lives.get(p.getName()) - 1);
+
+ p.sendMessage(ChatColor.RED + "You have " + KothDeathEvent.lives.get(p.getName()) + " live(s) left");
+
+ KothDeathEvent.removeSpectator(p);
+
+ } else {
+ p.sendMessage(ChatColor.RED + "You have run out of lives");
+ }
+
+ }
+ }
+
+
+ if(DuelManager.getManager().getGames().containsKey(p.getName())) {
+
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("MATCH_WAIT_MESSAGE").replace("%timer%", "" + DuelManager.getManager().getGames().get(p.getName()))));
+
+ DuelManager.getManager().getGames().put(p.getName() , DuelManager.getManager().getGames().get(p.getName()) - 1);
+
+ if(DuelManager.getManager().getGames().get(p.getName()) <= 0) {
+ DuelManager.getManager().getGames().remove(p.getName());
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("MATCH_START_MESSAGE")));
+ }
+ }
+
+
+ kothLogic(p);
+
+ if(FFAEvent.getFirework().containsKey(p.getName())) {
+ FFAEvent.getFirework().put(p.getName(), FFAEvent.getFirework().get(p.getName()) - 1);
+ FFAEvent.spawnFirework(p);
+
+ if(FFAEvent.getFirework().get(p.getName()) == 0) {
+ FFAEvent.getFirework().remove(p.getName());
+ }
+ }
+
+ if(DeathInventory.getTimer().containsKey(p.getName()) && DeathInventory.getTimer().get(p.getName()) > 0) {
+ DeathInventory.getTimer().put(p.getName(), DeathInventory.getTimer().get(p.getName()) - 1);
+
+ if(DeathInventory.getTimer().get(p.getName()) <= 0) {
+ DeathInventory.getTimer().remove(p.getName());
+ DeathInventory.getArmor().remove(p.getName());
+ DeathInventory.getInv().remove(p.getName());
+ DeathInventory.getPots().remove(p.getName());
+ }
+ }
+
+ bard.bard(p);
+
+ if(p.getScoreboard().getTeam("koth") != null) {
+
+ p.getScoreboard().getTeam("koth").setSuffix(setSuffix(p));
+ p.getScoreboard().getTeam("capper").setSuffix(setCapperSuffix(p));
+
+ if(p.getScoreboard().getTeam("energy") != null) {
+ p.getScoreboard().getTeam("energy").setSuffix(ChatColor.WHITE.toString() + BardManager.getManager().getBardByName(p).getEnerg());
+
+ }
+
+ } else if(p.getScoreboard().getTeam("alive") != null) {
+
+ p.getScoreboard().getTeam("alive").setSuffix(setAliveSuffix(p));
+
+ if(p.getScoreboard().getTeam("energy") != null) {
+ p.getScoreboard().getTeam("energy").setSuffix(ChatColor.WHITE.toString() + BardManager.getManager().getBardByName(p).getEnerg());
+
+ }
+
+ } else if(p.getScoreboard().getTeam("ffa") != null) {
+
+ p.getScoreboard().getTeam("ffa").setSuffix(ffaSuffix(p));
+
+ for(Player pl : Bukkit.getOnlinePlayers()) {
+
+ if(FFACommand.fighters.contains(pl.getName())) {
+ p.getScoreboard().getTeam("fighters").addPlayer(pl);
+ }
+ }
+
+ if(p.getScoreboard().getTeam("timer") != null) {
+ p.getScoreboard().getTeam("timer").setSuffix("" + FFACommand.getTimer());
+
+ if(FFACommand.getTimer() <= 0) {
+ sb.remove(p, p.getScoreboard(), "timer", ChatColor.GREEN);
+ }
+
+ }
+
+ } else if(p.getScoreboard().getTeam("online") != null && p.getScoreboard().getTeam("queue") != null) {
+ p.getScoreboard().getTeam("online").setSuffix(lobbyOnline(p));
+ p.getScoreboard().getTeam("queue").setSuffix(lobbyQueue(p));
+ } else if(p.getScoreboard().getTeam("timer") != null) {
+ p.getScoreboard().getTeam("timer").setSuffix(duelTimer(p));
+ } else if(p.getScoreboard().getTeam("spectimer") != null) {
+ p.getScoreboard().getTeam("spectimer").setSuffix(specDuelTimer(p));
+ } else if(p.getScoreboard().getTeam("speckoth") != null) {
+ p.getScoreboard().getTeam("speckoth").setSuffix(specKothTimer(p));
+ }
+
+ if(EnderpearlCooldown.getEnderpearl().containsKey(p.getName())) {
+
+ EnderpearlCooldown.getEnderpearl().put(p.getName(), EnderpearlCooldown.getEnderpearl().get(p.getName()) - 1);
+
+ updatePearl(p, p.getScoreboard(), "pearl", EnderpearlCooldown.getEnderpearl().get(p.getName()));
+
+ if(EnderpearlCooldown.getEnderpearl().get(p.getName()) <= 0) {
+ EnderpearlCooldown.getEnderpearl().remove(p.getName());
+ sb.remove(p, p.getScoreboard(), "pearl", ChatColor.LIGHT_PURPLE);
+ }
+ }
+
+ }
+
+ if(BardManager.getManager().getAllBards().size() > 0) {
+
+ for(BardClass bard : BardManager.getManager().getAllBards()) {
+
+ if(bard.getEnerg() < bard.getMax()) {
+ bard.setEnergy(bard.getEnerg() + 1);
+ }
+ }
+ }
+
+ }
+
+ private String specKothTimer(Player player) {
+
+ String suffix = "";
+
+ if(player.getScoreboard().getObjective(DisplaySlot.SIDEBAR) != null) {
+
+ Arena arena = ArenaManager.getManager().getArenaBySpectator(player);
+
+ if(arena != null) {
+
+ TeamDuel duel = TeamDuelManager.getManager().getDuelByPlayer(Bukkit.getPlayer(arena.getFighters().get(0)));
+
+ if(duel != null && arena.isActive()) {
+ suffix = ": " + ChatColor.WHITE + toMMSS(arena.getTimer());
+ }
+
+ }
+
+ }
+
+ return suffix;
+ }
+
+ private String duelTimer(Player player) {
+
+ String suffix = "";
+
+ if(player.getScoreboard().getObjective(DisplaySlot.SIDEBAR) != null) {
+
+ Duel duel = DuelManager.getManager().getDuelByPlayer(player);
+
+ if(duel != null) {
+ suffix = ChatColor.WHITE + toMMSS(duel.getTimer());
+ }
+ }
+
+
+ return suffix;
+ }
+
+
+ private String specDuelTimer(Player player) {
+
+ String suffix = "";
+
+ if(player.getScoreboard().getObjective(DisplaySlot.SIDEBAR) != null) {
+
+ Arena arena = ArenaManager.getManager().getArenaBySpectator(player);
+
+ if(arena != null) {
+
+ Duel duel = DuelManager.getManager().getDuelByPlayer(Bukkit.getPlayer(arena.getFighters().get(0)));
+
+ if(duel != null) {
+ suffix = ChatColor.WHITE + toMMSS(duel.getTimer());
+ }
+
+ }
+
+ }
+
+
+ return suffix;
+ }
+
+
+ public void updatePearl(Player player, Scoreboard board, String name, int suffix) {
+
+ if(board.getObjective(DisplaySlot.SIDEBAR) != null) {
+
+ Team team = board.getTeam(name);
+
+ if(team != null) {
+ team.setSuffix(ChatColor.GREEN.toString() + suffix);
+ }
+ }
+ }
+
+ public Inventory allTeamsInv(Player player) {
+
+ final Inventory teams = Bukkit.createInventory(player, 54, ChatColor.AQUA + "All Teams");
+
+ new BukkitRunnable() {
+ public void run() {
+ ItemStack skull = new ItemStack(Material.DIAMOND);
+ ItemMeta skullMeta = skull.getItemMeta();
+ if (TeamManager.getManager().getAllTeams().size() <= 54) {
+ teams.clear();
+ for (int i = 0; i < TeamManager.getManager().getAllTeams().size(); i++) {
+ skullMeta.setDisplayName(ChatColor.LIGHT_PURPLE + TeamManager.getManager().getAllTeams().get(i).getTeamName() + ChatColor.AQUA + " (" + TeamManager.getManager().getAllTeams().get(i).getTeamMembers().size() + ")");
+ skullMeta.setLore(TeamManager.getManager().getAllTeams().get(i).getTeamMembers());
+ skull.setItemMeta(skullMeta);
+ teams.setItem(i, skull);
+ }
+ }
+
+ }
+ }.runTaskTimer(IranPvP.plugin, 0L, 20L);
+
+ return teams;
+ }
+
+ //Arena timer
+ @SuppressWarnings("deprecation")
+ public void kothTimer() {
+ if(ArenaManager.getManager().getAllArena().size() > 0) {
+ for(Arena arena : ArenaManager.getManager().getAllArena()) {
+ if(arena.isActive()) {
+ if(arena.getCappers().size() > 0) {
+ arena.setTimer(arena.getTimer() - 1);
+ Player player = Bukkit.getPlayer(arena.getCapper());
+
+ if(player == null) {
+ arena.setTimer(arena.getArenaTimer());
+ arena.getCappers().clear();
+ return;
+ }
+
+ Arena pArena = ArenaManager.getManager().getArenaByPlayer(player);
+
+
+ if(arena.getTimer() <= 5) {
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getFighters().contains(p.getName())) {
+ p.sendMessage(ChatColor.GOLD + "[" + ChatColor.GRAY + pArena.getName() + ChatColor.GOLD + "]" + ChatColor.YELLOW + " is at " + ChatColor.RED + pArena.getTimer() + ChatColor.YELLOW + " Seconds");
+ }
+ }
+
+ if(arena.getTimer() <= 0) {
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(arena.getFighters().contains(p.getName())) {
+ p.sendMessage(ChatColor.GOLD + "[" + ChatColor.GRAY + pArena.getName() + ChatColor.GOLD + "]" + ChatColor.YELLOW + " has been Captured!");
+ }
+ }
+ TeamDuelManager.getManager().endDuel(player);
+ }
+
+ }
+
+ } else {
+ arena.setTimer(arena.getArenaTimer());
+ }
+ }
+ }
+ }
+ }
+
+ //Anti Flicker
+ public String setSuffix(Player player) {
+ String suffix = "";
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+
+ if (!ArenaManager.getManager().getAllArena().contains(arena)) {
+ return "null prefix";
+ }
+
+ suffix = ChatColor.GREEN + toMMSS((long) arena.getTimer());
+ return suffix;
+ }
+
+ //Capper Board
+ public String setCapperSuffix(Player player) {
+ String suffix = "";
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+
+ if (!ArenaManager.getManager().getAllArena().contains(arena)) {
+ return "null prefix";
+ }
+
+ me.iran.iranpvp.teams.Team team = TeamManager.getManager()
+ .getTeamByPlayer(player);
+
+ if (!TeamManager.getManager().getAllTeams().contains(team)) {
+ return "null suffix";
+ }
+
+ if (arena.getCappers().size() > 0) {
+ if (team.getTeamMembers().contains(arena.getCapper())) {
+ suffix = arena.getCapper();
+ } else {
+ suffix = "Other Team";
+ }
+ } else {
+ suffix = "None";
+ }
+
+ return suffix;
+ }
+
+ public void kothLogic(Player player) {
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+
+ if(!ArenaManager.getManager().getAllArena().contains(arena)) {
+ return;
+ }
+
+ me.iran.iranpvp.teams.Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ if(!TeamManager.getManager().getAllTeams().contains(team)) {
+ return;
+ }
+
+ if(arena.isActive()) {
+
+ if(arena.getCappers().size() < 1) {
+ arena.setTimer(arena.getArenaTimer());
+ }
+
+ if(ArenaManager.getManager().insideCube(player, player.getLocation())) {
+ if(!arena.getCappers().contains(player.getName())) {
+ arena.getCappers().add(player.getName());
+
+ }
+
+ } else if(!ArenaManager.getManager().insideCube(player, player.getLocation())) {
+ if(arena.getCappers().contains(player.getName())) {
+
+ if(arena.getCapper().equals(player.getName())) {
+ arena.setTimer(arena.getArenaTimer());
+ }
+
+ arena.getCappers().remove(player.getName());
+
+ }
+
+ }
+
+ }
+ }
+
+ public String setAliveSuffix(Player player) {
+ String suffix = "";
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+
+ if (!ArenaManager.getManager().getAllArena().contains(arena)) {
+ return "null prefix";
+ }
+
+ me.iran.iranpvp.teams.Team team = TeamManager.getManager()
+ .getTeamByPlayer(player);
+
+ if (!TeamManager.getManager().getAllTeams().contains(team)) {
+ return "null suffix";
+ }
+
+ if(TeamDuelManager.getManager().isInDuel(team)) {
+ TeamFight duel = TeamFightManager.getManager().getFightByTeam(team);
+
+ if(duel.getTeam1() == team) {
+ suffix = "" + duel.getAliveTeam2().size();
+ } else if(duel.getTeam2() == team) {
+ suffix = "" + duel.getAliveTeam1().size();
+ }
+
+ } else {
+ suffix = "none";
+ }
+
+ return suffix;
+ }
+
+ public String ffaSuffix(Player player) {
+ String suffix = "";
+
+ if(!FFACommand.fighters.contains(player.getName())) {
+ return "null prefix";
+ }
+
+ suffix = "" + FFACommand.fighters.size();
+
+ return suffix;
+ }
+
+ public String lobbyOnline(Player player) {
+ String suffix = "";
+
+ if(player.getScoreboard().getObjective(DisplaySlot.SIDEBAR) != null) {
+
+ suffix = ChatColor.WHITE.toString() + Bukkit.getServer().getOnlinePlayers().length;
+
+ }
+
+ return suffix;
+ }
+
+
+ public String lobbyQueue(Player player) {
+ int counter = 0;
+
+ if(player.getScoreboard().getObjective(DisplaySlot.SIDEBAR) != null) {
+
+ for(GameType game : GameTypeManager.getManager().getAllGameTypes()) {
+ counter = counter + game.getRanked().size();
+ counter = counter + game.getUnranked().size();
+ }
+ }
+
+ return "" + counter;
+ }
+
+ //timer fixer
+ public static String toMMSS(long dura){
+ int minute = (int)(dura / 60.0D);
+ long second = dura - (minute * 60);
+ String formatted = "";
+ {
+ if(minute < 10){
+ formatted += "";
+ }
+ formatted += minute;
+ formatted += ":";
+ if(second < 10){
+ formatted += "0";
+ }
+ formatted += second;
+ }
+ return formatted;
+ }
+}
diff --git a/src/me/iran/iranpvp/teams/Team.java b/src/me/iran/iranpvp/teams/Team.java
new file mode 100644
index 0000000..6e60c81
--- /dev/null
+++ b/src/me/iran/iranpvp/teams/Team.java
@@ -0,0 +1,76 @@
+package me.iran.iranpvp.teams;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Team {
+ private String name;
+ private String leader;
+ private ArrayList bard;
+ private List members;
+ private List invites;
+
+ public Team(String name, String leader) {
+ this.name = name;
+ this.leader = leader;
+
+ bard = new ArrayList();
+
+ members = new ArrayList();
+ invites = new ArrayList();
+
+ members.add(leader);
+ }
+
+ public String getTeamName() {
+ return name;
+ }
+
+ public ArrayList getBard() {
+ return bard;
+ }
+
+ public String getTeamLeader() {
+ return leader;
+ }
+
+ public List getTeamMembers() {
+ return members;
+ }
+
+ public List getInvites() {
+ return invites;
+ }
+
+ public void setTeamLeader(String leader) {
+ this.leader = leader;
+ }
+
+ public void setTeamName(String name) {
+ this.name = name;
+ }
+
+ public void addBard(String bard) {
+ this.bard.add(bard);
+ }
+
+ public void setMemebers(List members) {
+ this.members = members;
+ }
+
+ public void setInvites(List invites) {
+ this.invites = invites;
+ }
+
+ public void addMember(String uuid) {
+ this.members.add(uuid);
+ }
+
+ public void addInvite(String uuid) {
+ this.invites.add(uuid);
+ }
+
+ public void removeMember(String uuid) {
+ this.members.remove(uuid);
+ }
+}
diff --git a/src/me/iran/iranpvp/teams/TeamChat.java b/src/me/iran/iranpvp/teams/TeamChat.java
new file mode 100644
index 0000000..a41cde1
--- /dev/null
+++ b/src/me/iran/iranpvp/teams/TeamChat.java
@@ -0,0 +1,43 @@
+package me.iran.iranpvp.teams;
+
+import me.iran.iranpvp.IranPvP;
+import net.md_5.bungee.api.ChatColor;
+
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.AsyncPlayerChatEvent;
+
+public class TeamChat implements Listener {
+
+ IranPvP plugin;
+
+ public TeamChat (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ @SuppressWarnings("deprecation")
+ @EventHandler
+ public void onChat(AsyncPlayerChatEvent event) {
+ Player player = event.getPlayer();
+
+ if(TeamManager.getManager().isInTeam(player)) {
+ Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ String msg = event.getMessage();
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+
+ if(team.getTeamMembers().contains(p.getName())) {
+
+ if(msg.startsWith("!")) {
+ event.setCancelled(true);
+ p.sendMessage(ChatColor.BLUE.toString() + ChatColor.BOLD + "TEAM " + player.getName() + " " + ChatColor.GREEN + msg.replace("!", ""));
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/me/iran/iranpvp/teams/TeamManager.java b/src/me/iran/iranpvp/teams/TeamManager.java
new file mode 100644
index 0000000..b1e735d
--- /dev/null
+++ b/src/me/iran/iranpvp/teams/TeamManager.java
@@ -0,0 +1,495 @@
+package me.iran.iranpvp.teams;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import me.iran.iranpvp.duel.DuelManager;
+import me.iran.iranpvp.duel.team.TeamDuelManager;
+import me.iran.iranpvp.duel.team.TeamInviteManager;
+import me.iran.iranpvp.ffa.FFACommand;
+import me.iran.iranpvp.kit.bard.BardClass;
+import me.iran.iranpvp.kit.bard.BardManager;
+import me.iran.iranpvp.utils.BungeeChat;
+import me.iran.iranpvp.utils.OnJoinItems;
+import me.iran.iranpvp.utils.Queue;
+import me.iran.iranpvp.utils.TeleportSpawn;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+
+public class TeamManager {
+ static ArrayList teams= new ArrayList();
+
+ private OnJoinItems items = new OnJoinItems();
+ private BungeeChat click = new BungeeChat();
+ private TeleportSpawn spawn = new TeleportSpawn();
+ private Queue queue = new Queue();
+
+ private static TeamManager tm;
+ private TeamManager() {}
+
+ public static TeamManager getManager() {
+ if (tm == null)
+ tm = new TeamManager();
+
+ return tm;
+ }
+
+ public void createTeam(String name, Player leader) {
+
+ if(isInTeam(leader)) {
+ leader.sendMessage("You are already in a team");
+ return;
+ }
+
+ if(teams.contains(getTeamByName(name))) {
+ leader.sendMessage(ChatColor.RED + "That team already exists");
+ return;
+ }
+
+ Team team = new Team(name, leader.getName());
+
+ leader.sendMessage(ChatColor.BLUE + "You have created a Team!");
+ teams.add(team);
+ items.teamLeaderItems(leader);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void joinTeam(Player player, String name) {
+ Team team = getTeamByName(name); //Joining Team
+ Team playerTeam = getTeamByPlayer(player); //Current team
+
+ //is other team valid
+ if(!teams.contains(team)) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " That Team doesn't exist!");
+ return;
+ }
+
+ if(playerTeam == team) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You can't join your own Team");
+ return;
+ }
+
+ //Does the player have a team
+ if(teams.contains(playerTeam)) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You must leave your Current Team to join another!");
+ return;
+ }
+ //Is he invited
+ if(!team.getInvites().contains(player.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You have not been invited to join this Team");
+ return;
+ }
+
+ if(team.getTeamMembers().size() >= 30) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " That Team has reached its Maximum number of Players!");
+ return;
+ }
+
+ if(DuelManager.getManager().isInDuel(player)) {
+ player.sendMessage(ChatColor.RED + "Can't join a team while in a fight");
+ return;
+ }
+
+ if(FFACommand.fighters.contains(player.getName())) {
+ player.sendMessage(ChatColor.RED + "Can't join a team while in a FFA");
+ return;
+ }
+
+ if(queue.isInRanked(player)) {
+ player.sendMessage(ChatColor.RED + "Can't join a team while in Ranked queue");
+ return;
+ }
+
+ if(queue.isInUnranked(player)) {
+ player.sendMessage(ChatColor.RED + "Can't join a team while in Unranked queue");
+ return;
+ }
+
+ team.getInvites().remove(player.getName());
+ team.getTeamMembers().add(player.getName());
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team.getTeamMembers().contains(p.getName())) {
+ p.sendMessage(ChatColor.GREEN + player.getName() + " has joined the Team");
+ }
+ }
+ items.teamItems(player);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void inviteToTeam(Player player, Player target) {
+ Team team = getTeamByPlayer(player);
+
+ if(!teams.contains(team)) {
+ player.sendMessage(ChatColor.RED + "You are not in a Team");
+ return;
+ }
+
+ if(!team.getTeamLeader().equals(player.getName())) {
+ player.sendMessage(ChatColor.RED + "Only leaders can do that Command");
+ return;
+ }
+
+ if(team.getTeamMembers().contains(target.getName())) {
+ player.sendMessage(ChatColor.RED + "That person is already in your Team");
+ return;
+ }
+
+ if(team.getInvites().contains(target.getName())) {
+ player.sendMessage(ChatColor.RED + "That person has already been invited to your Team");
+ return;
+ }
+
+ if(TeamDuelManager.getManager().isInDuel(team)) {
+ player.sendMessage(ChatColor.RED + "Can't do that while in a duel");
+ return;
+ }
+
+ if(queue.isInRanked(player)) {
+ player.sendMessage(ChatColor.RED + "That person is buy at the moment");
+ return;
+ }
+
+ if(queue.isInUnranked(player)) {
+ player.sendMessage(ChatColor.RED + "That person is buy at the moment");
+ return;
+ }
+
+ team.addInvite(target.getName());
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team.getTeamMembers().contains(p.getName())) {
+ p.sendMessage(ChatColor.YELLOW + player.getName() + " has invited " + target.getName() + " to join the Team!");
+ }
+ }
+ click.joinTeam(player, target);
+
+ }
+
+ @SuppressWarnings("deprecation")
+ public void unInvite(Player player, Player target) {
+
+ Team team = getTeamByPlayer(player);
+
+ if(!teams.contains(team)) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You are not in a Team");
+ return;
+ }
+
+ if(!team.getTeamLeader().equals(player.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " Only Team Leaders can do this command");
+ return;
+ }
+
+ if(team.getTeamMembers().contains(target.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " That person is already in your Team");
+ return;
+ }
+
+ if(!team.getInvites().contains(target.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " That person has not been invited to your Team");
+ return;
+ }
+
+ team.getInvites().remove(target.getName());
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team.getTeamMembers().contains(p.getName())) {
+ p.sendMessage(ChatColor.YELLOW + player.getName() + " has revoked access for " + target.getName() + " to join the Team!");
+ }
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ public void setTeamBard(Player player, Player target) {
+ Team team = getTeamByPlayer(player);
+
+
+ if(!teams.contains(team)) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You are not in a Team");
+ return;
+ }
+
+ if(!team.getTeamLeader().equals(player.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " Only Team Leaders can do this command");
+ return;
+ }
+
+ if(!team.getTeamMembers().contains(target.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " That person is not in your Team");
+ return;
+ }
+
+ if(team.getBard().size() != 3 && team.getBard().size() < 4) {
+
+
+ if(!team.getBard().contains(target.getName())) {
+ team.getBard().add(target.getName());
+
+ BardManager.getManager().createBard(player);
+
+ BardClass bard = BardManager.getManager().getBardByName(player);
+
+ System.out.println(bard.getEnerg());
+ System.out.println(bard.getPlayer());
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team.getTeamMembers().contains(p.getName())) {
+ p.sendMessage(ChatColor.YELLOW + target.getName() + " has been made a Team Bard");
+ }
+ }
+
+ } else {
+ team.getBard().remove(target.getName());
+
+ BardManager.getManager().removeBard(player);
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team.getTeamMembers().contains(p.getName())) {
+ p.sendMessage(ChatColor.RED + target.getName() + " is not longer Bard");
+ }
+ }
+ }
+
+ } else {
+ player.sendMessage(ChatColor.RED + "Can't make anymore people bard");
+ }
+
+ }
+
+ @SuppressWarnings("deprecation")
+ public void kickFromTeam(Player player, Player target) {
+ Team team = getTeamByPlayer(player);
+
+ if(!teams.contains(team)) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You are not in a Team");
+ return;
+ }
+
+ if(!team.getTeamLeader().equals(player.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " Only Team Leaders can do this command");
+ return;
+ }
+
+ if(!team.getTeamMembers().contains(target.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " That person is not in your Team");
+ return;
+ }
+
+ if(team.getTeamLeader().equals(target.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You can't kick your Leader from the Team");
+ return;
+ }
+
+ if(team.getBard().contains(target.getName())) {
+ team.getBard().remove(target.getName());
+ }
+
+ team.getTeamMembers().remove(target.getName());
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team.getTeamMembers().contains(p.getName())) {
+ p.sendMessage(ChatColor.RED + player.getName() + " has kicked " + target.getName() + " from the Team!");
+ }
+ }
+ target.sendMessage(ChatColor.RED + "You have been Kicked to from the team " + team.getTeamName());
+ items.onJoin(target);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void makeLeader(Player player, Player target) {
+ Team team = getTeamByPlayer(player);
+
+ if(!teams.contains(team)) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You are not in a Team");
+ return;
+ }
+
+ if(!team.getTeamLeader().equals(player.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You are not the Team Leader");
+ return;
+ }
+
+ if(!team.getTeamMembers().contains(target.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " That person is not in your Team");
+ return;
+ }
+
+ team.setTeamLeader(target.getName());
+ team.setTeamName(target.getName());
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team.getTeamMembers().contains(p.getName())) {
+ p.sendMessage(ChatColor.LIGHT_PURPLE.toString() + ChatColor.UNDERLINE + player.getName() + " has made " + target.getName() + " the new Team Leader!");
+ }
+ }
+
+ TeamInviteManager.getManager().clearInvites(team);
+
+ items.teamItems(player);
+ items.teamLeaderItems(target);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void makeLeaderInFight(Player player, Player target) {
+ Team team = getTeamByPlayer(player);
+
+ if(!teams.contains(team)) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You are not in a Team");
+ return;
+ }
+
+ if(!team.getTeamLeader().equals(player.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You are not the Team Leader");
+ return;
+ }
+
+ if(!team.getTeamMembers().contains(target.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " That person is not in your Team");
+ return;
+ }
+
+ TeamInviteManager.getManager().clearInvites(team);
+ team.setTeamLeader(target.getName());
+ team.setTeamName(target.getName());
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team.getTeamMembers().contains(p.getName())) {
+ p.sendMessage(ChatColor.LIGHT_PURPLE.toString() + ChatColor.UNDERLINE + player.getName() + " has made " + target.getName() + " the new Team Leader!");
+ }
+ }
+ }
+
+ public Team getTeamByName(String name) {
+ for(Team team : teams) {
+ if(team.getTeamName().equalsIgnoreCase(name)) {
+ return team;
+ }
+ }
+ return null;
+ }
+
+
+ public Team getTeamByPlayer(Player player) {
+ for(Team team : teams) {
+ if(team.getTeamMembers().contains(player.getName())) {
+ return team;
+ }
+ }
+ return null;
+ }
+
+ public boolean isInTeam(Player player) {
+ for(Team team : teams) {
+ if(team.getTeamMembers().contains(player.getName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @SuppressWarnings("deprecation")
+ public void leaveTeam(Player player) {
+ Team team = getTeamByPlayer(player);
+
+ if(!teams.contains(team)) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You are not in a team");
+ return;
+ }
+
+ if(team.getTeamMembers().size() == 1) {
+/* TeamInviteManager.getManager().clearInvites(team);
+ team.getTeamMembers().clear();
+ teams.remove(team);
+ items.onJoin(player);
+ player.sendMessage(ChatColor.RED + "You have disbaned your team");*/
+
+ disbandTeam(player);
+ return;
+ }
+
+ if(team.getTeamLeader().equals(player.getName())) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You must make someone the leader before leaving or /team disband");
+ return;
+ }
+
+ if(TeamDuelManager.getManager().isInDuel(team)) {
+ player.sendMessage(ChatColor.RED + "Can't leave a team while in a duel");
+ return;
+ }
+
+ if(team.getTeamMembers().contains(player.getName())) {
+ team.getTeamMembers().remove(player.getName());
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team.getTeamMembers().contains(p.getName())) {
+ p.sendMessage(ChatColor.RED + player.getName() + " Has left the Team!");
+ }
+ }
+
+ player.sendMessage(ChatColor.RED + "You have left the Team");
+ items.onJoin(player);
+ return;
+ }
+
+ if(team.getBard().contains(player.getName())) {
+ team.getBard().remove(player.getName());
+
+ BardManager.getManager().removeBard(player);
+ }
+
+ if(team.getTeamMembers().contains(player.getName())) {
+ team.getTeamMembers().remove(player.getName());
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team.getTeamMembers().contains(p.getName())) {
+ p.sendMessage(ChatColor.RED + player.getName() + " Has left the Team!");
+ }
+ }
+ player.sendMessage(ChatColor.RED + "You have left the Team");
+ items.onJoin(player);
+ return;
+ }
+
+ }
+
+ public void disbandTeam(Player player) {
+ Team team = getTeamByPlayer(player);
+
+ if(!teams.contains(team)) {
+ player.sendMessage(ChatColor.GOLD + "[Teams]" + ChatColor.RED + " You are not in a team");
+ return;
+ }
+
+ if(TeamDuelManager.getManager().isInDuel(team)) {
+ player.sendMessage(ChatColor.RED + "Can't disband your team while in a duel");
+ return;
+ }
+
+ if(team.getTeamLeader().equals(player.getName())) {
+
+ for(String p : team.getTeamMembers()) {
+ Player pl = Bukkit.getPlayer(p);
+ spawn.teleportSpawn(pl);
+ items.onJoin(pl);
+
+ if(team.getBard().contains(p)) {
+ BardManager.getManager().removeBard(pl);
+ }
+ }
+
+ TeamInviteManager.getManager().clearInvites(team);
+
+ team.getBard().clear();
+ team.getTeamMembers().clear();
+ teams.remove(team);
+ player.sendMessage(ChatColor.RED + "You have disbanded your team");
+ }
+
+ items.onJoin(player);
+ }
+
+ public List getAllTeams() {
+ return TeamManager.teams;
+ }
+
+
+}
diff --git a/src/me/iran/iranpvp/type/GameType.java b/src/me/iran/iranpvp/type/GameType.java
new file mode 100644
index 0000000..49ade0b
--- /dev/null
+++ b/src/me/iran/iranpvp/type/GameType.java
@@ -0,0 +1,84 @@
+package me.iran.iranpvp.type;
+
+import java.util.ArrayList;
+
+import org.bukkit.inventory.ItemStack;
+
+public class GameType {
+
+ private String name;
+ private ItemStack[] inv;
+ private ItemStack[] armor;
+ private ItemStack display;
+ private ArrayList unranked;
+ private ArrayList ranked;
+ private boolean edit;
+
+ public GameType(String name, ItemStack[] inv, ItemStack[] armor, ItemStack display, boolean edit) {
+ this.name = name;
+ this.edit = edit;
+ this.inv = inv;
+ this.armor = armor;
+ this.display = display;
+
+ unranked = new ArrayList();
+ ranked = new ArrayList();
+
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setEdit(boolean edit) {
+ this.edit = edit;
+ }
+
+ public boolean getEdit() {
+ return this.edit;
+ }
+
+ public void addUnranked(String name) {
+ unranked.add(name);
+ }
+
+ public void removeUnranked(String name) {
+ unranked.remove(name);
+ }
+
+ public void setInv(ItemStack[] inv) {
+ this.inv = inv;
+ }
+
+ public void setArmor(ItemStack[] armor) {
+ this.armor = armor;
+ }
+
+ public void setDisplay(ItemStack display) {
+ this.display = display;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public ItemStack[] getInv() {
+ return this.inv;
+ }
+
+ public ItemStack[] getArmor() {
+ return this.armor;
+ }
+
+ public ItemStack getDisplay() {
+ return this.display;
+ }
+
+ public ArrayList getUnranked() {
+ return this.unranked;
+ }
+
+ public ArrayList getRanked() {
+ return this.ranked;
+ }
+}
diff --git a/src/me/iran/iranpvp/type/GameTypeCommands.java b/src/me/iran/iranpvp/type/GameTypeCommands.java
new file mode 100644
index 0000000..3be681d
--- /dev/null
+++ b/src/me/iran/iranpvp/type/GameTypeCommands.java
@@ -0,0 +1,174 @@
+package me.iran.iranpvp.type;
+
+import java.util.HashMap;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.kit.KitManager;
+import net.md_5.bungee.api.ChatColor;
+
+import org.bukkit.Bukkit;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryCloseEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.inventory.Inventory;
+
+public class GameTypeCommands implements CommandExecutor, Listener {
+
+ IranPvP plugin;
+
+ public GameTypeCommands(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ KitManager km = new KitManager();
+
+ private static HashMap edit = new HashMap();
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
+
+ if(!(sender instanceof Player)) {
+ return true;
+ }
+
+ Player player = (Player) sender;
+
+ if(cmd.getName().equalsIgnoreCase("gametype")) {
+
+ if(!player.hasPermission("iranpvp.gametype")) {
+ return true;
+ }
+
+ if(args.length < 1) {
+ player.sendMessage(ChatColor.RED + "/gametype create ");
+ player.sendMessage(ChatColor.RED + "/gametype setdisplay ");
+ player.sendMessage(ChatColor.RED + "/gametype delete ");
+ player.sendMessage(ChatColor.RED + "/gametype setkit ");
+ player.sendMessage(ChatColor.RED + "/gametype setedit ");
+ player.sendMessage(ChatColor.RED + "/gametype editable true|false");
+ return true;
+ }
+
+ if(args[0].equalsIgnoreCase("create")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/gametype create ");
+ return true;
+ }
+
+ GameTypeManager.getManager().createGameType(args[1], player);
+
+
+ }
+
+
+ if(args[0].equalsIgnoreCase("delete")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/gametype delete ");
+ return true;
+ }
+
+ GameTypeManager.getManager().deleteGameType(args[1]);
+
+ player.sendMessage(ChatColor.RED + "GameType " + ChatColor.GOLD + args[1] + ChatColor.RED + " Deleted Successfully");
+ }
+
+ if(args[0].equalsIgnoreCase("setdisplay")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/gametype setdisplay ");
+ return true;
+ }
+
+ GameTypeManager.getManager().setItemDisplay(player, args[1]);
+
+ player.sendMessage(ChatColor.GREEN + "Set Display Item for GameType " + ChatColor.GOLD + args[1]);
+ }
+
+ if(args[0].equalsIgnoreCase("setkit")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/gametype setkit ");
+ return true;
+ }
+
+ GameTypeManager.getManager().setDefaultArmor(player, args[1]);
+
+ GameTypeManager.getManager().setDefaultInv(player, args[1]);
+
+ player.sendMessage(ChatColor.GREEN + "Set Default kit for GameType " + ChatColor.GOLD + args[1]);
+
+ }
+
+ if(args[0].equalsIgnoreCase("setedit")) {
+ if(args.length < 2) {
+ player.sendMessage(ChatColor.RED + "/gametype setedit ");
+ return true;
+ }
+
+ if(GameTypeManager.getManager().getGameTypeByName(args[1]) != null) {
+
+ edit.put(player.getName(), GameTypeManager.getManager().getGameTypeByName(args[1]));
+
+ player.openInventory(km.openEditorChest(player, GameTypeManager.getManager().getGameTypeByName(args[1])));
+
+ /* Inventory inv = Bukkit.createInventory(player, 54, ChatColor.BLUE + "Edit Chest");
+
+ player.openInventory(inv);*/
+ }
+
+ }
+
+ if(args[0].equalsIgnoreCase("editable")) {
+ if(args.length < 3) {
+ player.sendMessage(ChatColor.RED + "/gametype editable true|false");
+ return true;
+ }
+
+ if(args[2].contains("true")) {
+ GameTypeManager.getManager().setEdit(player, true, args[1]);
+ } else if(args[2].contains("false")) {
+ GameTypeManager.getManager().setEdit(player, false, args[1]);
+ }
+
+
+ }
+ }
+
+ return true;
+ }
+
+ @EventHandler
+ public void onClose(InventoryCloseEvent event) {
+
+ if(event.getInventory() != null && event.getInventory().getTitle().equals(ChatColor.BLUE + "Edit Chest")) {
+
+ if(event.getPlayer() instanceof Player) {
+
+ Player player = (Player) event.getPlayer();
+
+ if(edit.containsKey(player.getName())) {
+
+ km.setChest(player, edit.get(player.getName()), event.getInventory());
+
+ edit.remove(player.getName());
+ player.sendMessage(ChatColor.GREEN + "Chest setup!");
+ }
+ }
+ }
+
+ }
+
+ @EventHandler
+ public void onQuit(PlayerQuitEvent event) {
+
+ Player player = event.getPlayer();
+
+ if(edit.containsKey(player.getName())) {
+ edit.remove(player.getName());
+ }
+ }
+
+}
diff --git a/src/me/iran/iranpvp/type/GameTypeManager.java b/src/me/iran/iranpvp/type/GameTypeManager.java
new file mode 100644
index 0000000..5b7e2b7
--- /dev/null
+++ b/src/me/iran/iranpvp/type/GameTypeManager.java
@@ -0,0 +1,423 @@
+package me.iran.iranpvp.type;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import me.iran.iranpvp.IranPvP;
+
+import org.bukkit.ChatColor;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+public class GameTypeManager {
+
+ private static ArrayList gameType = new ArrayList<>();
+
+ File file = null;
+
+ //Pick GameType
+ //Player put in Queue for specific gametype
+ //Queue picks 2 random people with the same gametype and they fight
+
+
+ //GameType inv and armor are defaults set by admin
+
+ private static GameTypeManager gm;
+
+ private GameTypeManager() {}
+
+ public static GameTypeManager getManager() {
+ if (gm == null)
+ gm = new GameTypeManager();
+
+ return gm;
+ }
+
+ public void loadGameTypes() {
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ if(file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration gConfig = YamlConfiguration.loadConfiguration(file);
+
+ for(String s : gConfig.getConfigurationSection("gametype").getKeys(false)) {
+ String name = gConfig.getString("gametype." + s + ".name");
+
+ List> items = gConfig.getList("gametype." + s + ".inv");
+ List> armor = gConfig.getList("gametype." + s + ".armor");
+
+ ItemStack[] arrayItem = items.toArray(new ItemStack[items.size()]);
+ ItemStack[] arrayArmor = armor.toArray(new ItemStack[armor.size()]);
+
+ ItemStack display = (ItemStack) gConfig.get("gametype." + s + ".display");
+
+ boolean edit = gConfig.getBoolean("gametype." + s + ".edit");
+
+ GameType game = new GameType(name, arrayItem, arrayArmor, display, edit);
+
+ gameType.add(game);
+
+ }
+ }
+ }
+
+ public void saveGameType() {
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ if(file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration gConfig = YamlConfiguration.loadConfiguration(file);
+
+ ArrayList invList = new ArrayList();
+ ArrayList armorList = new ArrayList();
+
+ for(int i = 0; i < gameType.size(); i++) {
+ String name = gameType.get(i).getName();
+
+ GameType game = getGameTypeByName(name);
+
+ ItemStack[] inv = game.getInv();
+ ItemStack[] armor = game.getArmor();
+
+ for(int j = 0; j < inv.length; j++) {
+ ItemStack item = inv[j];
+ if(item != null) {
+ invList.add(item);
+ }
+ }
+
+ for(int k = 0; k < armor.length; k++) {
+ ItemStack arm = armor[k];
+ if(arm != null) {
+ armorList.add(arm);
+ }
+ }
+
+ gConfig.set("gametype." + name + ".name", name);
+ gConfig.set("gametype." + name + ".inv", invList);
+ gConfig.set("gametype." + name + ".armor", armorList);
+ gConfig.set("gametype." + name + ".display", game.getDisplay());
+ gConfig.set("gametype." + name + ".edit", game.getEdit());
+
+ try {
+ gConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public void deleteGameType(String name) {
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ if (file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration gConfig = YamlConfiguration
+ .loadConfiguration(file);
+
+ gConfig.set("gametype." + name, null);
+
+ try {
+ gConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void createGameType(String name, Player player) {
+
+ if(gameType.contains(getGameTypeByName(name))) {
+ player.sendMessage(ChatColor.RED + "That gametype already exists");
+ return;
+ }
+
+ GameType game = new GameType(name, player.getInventory().getContents(), player.getInventory().getArmorContents(), player.getItemInHand(), true);
+
+ gameType.add(game);
+
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ if(file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration gConfig = YamlConfiguration.loadConfiguration(file);
+
+ gConfig.createSection("gametype." + name + ".name");
+ gConfig.createSection("gametype." + name + ".inv");
+ gConfig.createSection("gametype." + name + ".armor");
+ gConfig.createSection("gametype." + name + ".display");
+ gConfig.createSection("gametype." + name + ".edit");
+
+ ArrayList invList = new ArrayList();
+ ArrayList armorList = new ArrayList();
+
+ ItemStack[] inv = game.getInv();
+ ItemStack[] armor = game.getArmor();
+
+ for(int i = 0; i < inv.length; i++) {
+ ItemStack item = inv[i];
+ if(item != null) {
+ invList.add(item);
+ }
+ }
+ for(int i = 0; i < armor.length; i++) {
+ ItemStack arm = armor[i];
+ if(arm != null) {
+ armorList.add(arm);
+ }
+ }
+
+ gConfig.set("gametype." + name + ".name", name);
+ gConfig.set("gametype." + name + ".inv", invList);
+ gConfig.set("gametype." + name + ".armor", armorList);
+ gConfig.set("gametype." + name + ".display", game.getDisplay());
+ gConfig.set("gametype." + name + ".edit", game.getEdit());
+
+ try {
+ gConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ player.sendMessage(ChatColor.GREEN + "GameType " + ChatColor.GOLD + name + ChatColor.GREEN + " Created Successfully");
+ }
+ }
+
+ public void setItemDisplay(Player player, String name) {
+ GameType game = getGameTypeByName(name);
+
+ if(!getAllGameTypes().contains(game)) {
+ System.out.println("game was null");
+ return;
+ }
+
+ game.setDisplay(player.getItemInHand());
+
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ if (file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration gConfig = YamlConfiguration.loadConfiguration(file);
+
+ gConfig.set("gametype." + name + ".display", game.getDisplay());
+
+ try {
+ gConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } else {
+ System.out.println("Couldn't Find this GameType in the File.");
+ }
+ }
+
+ public void setDefaultInv(Player player, String name) {
+ GameType game = getGameTypeByName(name);
+
+ if(!getAllGameTypes().contains(game)) {
+ System.out.println("game was null");
+ return;
+ }
+
+ game.setInv(player.getInventory().getContents());
+
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ if (file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration gConfig = YamlConfiguration.loadConfiguration(file);
+
+ ArrayList invList = new ArrayList();
+
+ ItemStack[] inv = game.getInv();
+
+ for (int j = 0; j < inv.length; j++) {
+ ItemStack item = inv[j];
+ if (item != null) {
+ invList.add(item);
+ }
+ }
+
+ gConfig.set("gametype." + name + ".inv", invList);
+
+ try {
+ gConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } else {
+ System.out.println("Couldn't Find this GameType in the File.");
+ }
+ }
+
+ public void setDefaultArmor(Player player, String name) {
+ GameType game = getGameTypeByName(name);
+
+ if(!getAllGameTypes().contains(game)) {
+ System.out.println("game was null");
+ return;
+ }
+
+ game.setArmor(player.getInventory().getArmorContents());
+
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ if (file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration gConfig = YamlConfiguration.loadConfiguration(file);
+
+ ArrayList armorList = new ArrayList();
+
+ ItemStack[] armor = game.getArmor();
+
+ for (int j = 0; j < armor.length; j++) {
+ ItemStack item = armor[j];
+ if (item != null) {
+ armorList.add(item);
+ }
+ }
+
+ gConfig.set("gametype." + name + ".armor", armorList);
+
+ try {
+ gConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } else {
+ System.out.println("Couldn't Find this GameType in the File.");
+ }
+ }
+
+ public void setEdit(Player player, boolean edit, String name) {
+ GameType game = getGameTypeByName(name);
+
+ if(!getAllGameTypes().contains(game)) {
+ System.out.println("game was null");
+ return;
+ }
+
+ game.setEdit(edit);
+
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ if (file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder(), "gametype.yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration gConfig = YamlConfiguration.loadConfiguration(file);
+
+
+ gConfig.set("gametype." + name + ".edit", game.getEdit());
+
+ try {
+ gConfig.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ player.sendMessage(ChatColor.GREEN + game.getName() + " was set to " + edit);
+ } else {
+ System.out.println("Couldn't Find this GameType in the File.");
+ }
+ }
+
+ public void joinUnranked(Player player, String name) {
+ GameType game = getGameTypeByName(name);
+
+ if(!getAllGameTypes().contains(game)) {
+ System.out.println("game was null");
+ return;
+ }
+
+ game.addUnranked(player.getName());
+ }
+
+ public void leaveUnranked(Player player, String name) {
+ GameType game = getGameTypeByName(name);
+
+ if(!getAllGameTypes().contains(game)) {
+ System.out.println("game was null");
+ return;
+ }
+
+ game.removeUnranked(player.getName());
+ }
+
+ public void joinRanked(Player player, String name) {
+ GameType game = getGameTypeByName(name);
+
+ if(!getAllGameTypes().contains(game)) {
+ System.out.println("game was null");
+ return;
+ }
+
+ game.getRanked().add(player.getName());
+ }
+
+ public void leaveRanked(Player player, String name) {
+ GameType game = getGameTypeByName(name);
+
+ if(!getAllGameTypes().contains(game)) {
+ System.out.println("game was null");
+ return;
+ }
+
+ game.getRanked().remove(player.getName());
+ }
+
+ public boolean inUnrankedQueue(Player player, String name) {
+ GameType game = getGameTypeByName(name);
+
+ if(!getAllGameTypes().contains(game)) {
+ System.out.println("game was null");
+ return false;
+ }
+
+ if(game.getUnranked().contains(player.getName())) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public GameType getGameTypeByName(String name) {
+ for(GameType game : gameType) {
+ if(game.getName().equalsIgnoreCase(name)) {
+ return game;
+ }
+ }
+
+ return null;
+ }
+
+ public ArrayList getAllGameTypes() {
+ return gameType;
+ }
+}
diff --git a/src/me/iran/iranpvp/type/Ranked.java b/src/me/iran/iranpvp/type/Ranked.java
new file mode 100644
index 0000000..2657dfb
--- /dev/null
+++ b/src/me/iran/iranpvp/type/Ranked.java
@@ -0,0 +1,40 @@
+package me.iran.iranpvp.type;
+
+import org.bukkit.entity.Player;
+
+public class Ranked {
+
+ int elo;
+ Player player;
+ GameType gametype;
+
+ public Ranked(int elo, Player player, GameType gametype) {
+ this.elo = elo;
+ this.player = player;
+ this.gametype = gametype;
+ }
+
+ public int getElo() {
+ return this.elo;
+ }
+
+ public void setElo(int elo) {
+ this.elo = elo;
+ }
+
+ public Player getPlayer() {
+ return this.player;
+ }
+
+ public void setPlayer(Player player) {
+ this.player = player;
+ }
+
+ public void setGameType(GameType game) {
+ this.gametype = game;
+ }
+
+ public GameType getGameType() {
+ return this.gametype;
+ }
+}
diff --git a/src/me/iran/iranpvp/type/RankedEvent.java b/src/me/iran/iranpvp/type/RankedEvent.java
new file mode 100644
index 0000000..a84be7c
--- /dev/null
+++ b/src/me/iran/iranpvp/type/RankedEvent.java
@@ -0,0 +1,184 @@
+package me.iran.iranpvp.type;
+
+import java.io.File;
+import java.io.IOException;
+
+import me.iran.iranpvp.IranPvP;
+import net.md_5.bungee.api.ChatColor;
+
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+
+public class RankedEvent implements Listener {
+
+ IranPvP plugin;
+
+ File file = null;
+
+ public RankedEvent(IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void onJoin(PlayerJoinEvent event) {
+ Player player = event.getPlayer();
+
+ createFiles(player);
+ }
+
+ @EventHandler
+ public void onQuit(PlayerQuitEvent event) {
+ Player player = event.getPlayer();
+ saveElo(player);
+ }
+
+ public void saveElo(Player player) {
+ file = new File(IranPvP.plugin.getDataFolder() + "/ranked/" + player.getUniqueId().toString(), player.getUniqueId().toString() + ".yml");
+
+ if(!file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder() + "/ranked/" + player.getUniqueId().toString(), player.getUniqueId().toString() + ".yml");
+
+ YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
+
+
+
+ for(int i = 0; i < GameTypeManager.getManager().getAllGameTypes().size(); i++) {
+
+ GameType game = GameTypeManager.getManager().getAllGameTypes().get(i);
+
+ config.createSection(player.getUniqueId().toString() + "." + game.getName());
+ config.set(player.getUniqueId().toString() + "." + game.getName(), 1000);
+ }
+
+ try {
+ config.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } else {
+
+ file = new File(IranPvP.plugin.getDataFolder() + "/ranked/" + player.getUniqueId().toString(), player.getUniqueId().toString() + ".yml");
+
+ YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
+
+ for(int i = 0; i < GameTypeManager.getManager().getAllGameTypes().size(); i++) {
+
+ GameType game = GameTypeManager.getManager().getAllGameTypes().get(i);
+
+ if(!config.contains(player.getUniqueId().toString() + "." + game.getName())) {
+ config.createSection(player.getUniqueId().toString() + "." + game.getName());
+ config.set(player.getUniqueId().toString() + "." + game.getName(), 1000);
+ } else {
+
+ int elo = RankedManager.getManager().getRank(player, game).getElo();
+
+ config.set(player.getUniqueId().toString() + "." + game.getName(), elo);
+
+ RankedManager.getManager().deleteRanked(player, game);
+ }
+
+ }
+
+ try {
+ config.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void createFiles(Player player) {
+ file = new File(IranPvP.plugin.getDataFolder() + "/ranked/" + player.getUniqueId().toString(), player.getUniqueId().toString() + ".yml");
+
+ if(!file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder() + "/ranked/" + player.getUniqueId().toString(), player.getUniqueId().toString() + ".yml");
+
+ YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
+
+ for(int i = 0; i < GameTypeManager.getManager().getAllGameTypes().size(); i++) {
+
+ GameType game = GameTypeManager.getManager().getAllGameTypes().get(i);
+
+ config.createSection(player.getUniqueId().toString() + "." + game.getName());
+ config.set(player.getUniqueId().toString() + "." + game.getName(), 1000);
+
+ int elo = config.getInt(player.getUniqueId().toString() + "." + game.getName());
+
+ RankedManager.getManager().getAllRanked().add(new Ranked(elo, player, game));
+ }
+
+ try {
+ config.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } else {
+
+ file = new File(IranPvP.plugin.getDataFolder() + "/ranked/" + player.getUniqueId().toString(), player.getUniqueId().toString() + ".yml");
+
+ YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
+
+ for(int i = 0; i < GameTypeManager.getManager().getAllGameTypes().size(); i++) {
+
+ GameType game = GameTypeManager.getManager().getAllGameTypes().get(i);
+
+ if(!config.contains(player.getUniqueId().toString() + "." + game.getName())) {
+ config.createSection(player.getUniqueId().toString() + "." + game.getName());
+ config.set(player.getUniqueId().toString() + "." + game.getName(), 1000);
+ }
+
+ int elo = config.getInt(player.getUniqueId().toString() + "." + game.getName());
+
+ RankedManager.getManager().getAllRanked().add(new Ranked(elo, player, game));
+ }
+
+ try {
+ config.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ }
+
+/* public void getOfflineElo(Player player, Player target) {
+
+ file = new File(IranPvP.plugin.getDataFolder() + "/ranked/" + target.getUniqueId().toString(), target.getUniqueId().toString() + ".yml");
+
+ if(file.exists()) {
+
+ YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
+
+ player.sendMessage(ChatColor.BLUE.toString() + ChatColor.BOLD + target.getName() + "'s Elo");
+
+ for(int i = 0; i < GameTypeManager.getManager().getAllGameTypes().size(); i++) {
+
+ GameType game = GameTypeManager.getManager().getAllGameTypes().get(i);
+
+ if(!config.contains(target.getUniqueId().toString() + "." + game.getName())) {
+ config.createSection(target.getUniqueId().toString() + "." + game.getName());
+ config.set(target.getUniqueId().toString() + "." + game.getName(), 1000);
+ }
+
+ player.sendMessage(ChatColor.GREEN + game.getName() + ": " + ChatColor.GRAY + config.getInt(player.getUniqueId().toString() + "." + game.getName()));
+
+ }
+
+ try {
+ config.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ } else {
+ player.sendMessage(ChatColor.RED + "Couldn't find that users file");
+ }
+
+ }*/
+
+}
diff --git a/src/me/iran/iranpvp/type/RankedManager.java b/src/me/iran/iranpvp/type/RankedManager.java
new file mode 100644
index 0000000..87cbcbb
--- /dev/null
+++ b/src/me/iran/iranpvp/type/RankedManager.java
@@ -0,0 +1,57 @@
+package me.iran.iranpvp.type;
+
+import java.util.ArrayList;
+
+import org.bukkit.entity.Player;
+
+public class RankedManager {
+
+ public ArrayList allRanked = new ArrayList<>();
+
+ private static RankedManager rm;
+
+ private RankedManager() {}
+
+ public static RankedManager getManager() {
+ if (rm == null)
+ rm = new RankedManager();
+
+ return rm;
+ }
+
+ public void createRanked(int elo, Player player, GameType game) {
+ Ranked rank = new Ranked(elo, player, game);
+
+ allRanked.add(rank);
+ }
+
+ public Ranked getRank(Player player, GameType game) {
+ for(int i = 0; i < allRanked.size(); i++) {
+ Player rp = allRanked.get(i).getPlayer();
+ GameType rg = allRanked.get(i).getGameType();
+
+ if(player.getUniqueId().toString().equalsIgnoreCase(rp.getUniqueId().toString()) && game.getName().equalsIgnoreCase(rg.getName())) {
+ return allRanked.get(i);
+ }
+
+ }
+
+ return null;
+ }
+
+ public void deleteRanked(Player player, GameType game) {
+ Ranked rank = getRank(player, game);
+
+ if(!allRanked.contains(rank)) {
+ return;
+ }
+
+ allRanked.remove(rank);
+
+ }
+
+ public ArrayList getAllRanked() {
+ return allRanked;
+ }
+
+}
diff --git a/src/me/iran/iranpvp/utils/BungeeChat.java b/src/me/iran/iranpvp/utils/BungeeChat.java
new file mode 100644
index 0000000..845425e
--- /dev/null
+++ b/src/me/iran/iranpvp/utils/BungeeChat.java
@@ -0,0 +1,106 @@
+package me.iran.iranpvp.utils;
+
+import me.iran.iranpvp.IranPvP;
+import net.md_5.bungee.api.ChatColor;
+import net.md_5.bungee.api.chat.ClickEvent;
+import net.md_5.bungee.api.chat.ComponentBuilder;
+import net.md_5.bungee.api.chat.HoverEvent;
+import net.md_5.bungee.api.chat.TextComponent;
+
+import org.bukkit.entity.Player;
+
+public class BungeeChat {
+
+ public void joinTeam(Player player, Player target) {
+ TextComponent click = new TextComponent(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TEAM_INVITE_MESSAGE.CLICK")));
+ TextComponent message = new TextComponent(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TEAM_INVITE_MESSAGE.MESSAGE").replace("%team%", player.getName())));
+ TextComponent blank = new TextComponent(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TEAM_INVITE_MESSAGE.LINE")));
+ click.setClickEvent( new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team join " + player.getName()));
+ click.setHoverEvent( new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.GREEN + "Join Team " + player.getName()).create()));
+
+ target.spigot().sendMessage(blank);
+ target.spigot().sendMessage( message);
+ target.spigot().sendMessage(click);
+ target.spigot().sendMessage(blank);
+ }
+
+ public void acceptTeamDuel(Player player, Player target, String type) {
+ TextComponent click = new TextComponent(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TEAM_RECIEVE_INVITE.CLICK")));
+ TextComponent message = new TextComponent(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TEAM_RECIEVE_INVITE.MESSAGE").replace("%team%", player.getName()).replace("%gametype%", type)));
+
+ TextComponent blank = new TextComponent(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TEAM_RECIEVE_INVITE.LINE")));
+
+ click.setClickEvent( new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team accept " + player.getName()));
+
+ click.setHoverEvent( new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.GREEN + "Accept Team Fight").create()));
+
+ target.spigot().sendMessage(blank);
+ target.spigot().sendMessage( message);
+ target.spigot().sendMessage(click);
+ target.spigot().sendMessage(blank);
+ }
+
+ public void acceptKothDuel(Player player, Player target, String type) {
+ TextComponent click = new TextComponent(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("KOTH_RECIEVE_INVITE.CLICK")));
+ TextComponent message = new TextComponent(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("KOTH_RECIEVE_INVITE.MESSAGE").replace("%team%", player.getName()).replace("%gametype%", type)));
+
+ TextComponent blank = new TextComponent(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("KOTH_RECIEVE_INVITE.LINE")));
+
+ click.setClickEvent( new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team accept " + player.getName()));
+
+ click.setHoverEvent( new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.GREEN + "Accept KOTH Fight").create()));
+
+ target.spigot().sendMessage(blank);
+ target.spigot().sendMessage( message);
+ target.spigot().sendMessage(click);
+ target.spigot().sendMessage(blank);
+ }
+
+ public void acceptPlayer(Player player, Player target, String type) {
+ TextComponent click = new TextComponent(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("DUEL_RECIEVE_INVITE.CLICK")));
+ TextComponent message = new TextComponent(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("DUEL_RECIEVE_INVITE.MESSAGE").replace("%player%", player.getName()).replace("%gametype%", type)));
+
+ TextComponent blank = new TextComponent(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("DUEL_RECIEVE_INVITE.LINE")));
+
+ click.setClickEvent( new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/iranpvp:accept " + player.getName()));
+
+ click.setHoverEvent( new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.GREEN + "Accept Duel").create()));
+
+ target.spigot().sendMessage(blank);
+ target.spigot().sendMessage( message);
+ target.spigot().sendMessage(click);
+ target.spigot().sendMessage(blank);
+ }
+
+ public void viewInv(Player winner, Player loser) {
+ TextComponent clickWinner = new TextComponent(ChatColor.GREEN + "Winner: " + ChatColor.GOLD + winner.getName());
+ TextComponent clickLoser = new TextComponent(ChatColor.RED + "Loser: " + ChatColor.GOLD + loser.getName());
+
+ clickWinner.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/view " + winner.getName()));
+ clickLoser.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/view " + loser.getName()));
+
+ winner.sendMessage("");
+ winner.spigot().sendMessage(clickWinner);
+ winner.spigot().sendMessage(clickLoser);
+ winner.sendMessage("");
+
+ loser.sendMessage("");
+ loser.spigot().sendMessage(clickWinner);
+ loser.spigot().sendMessage(clickLoser);
+ loser.sendMessage("");
+ }
+
+ public void viewInvSpec(Player winner, Player loser, Player spec) {
+ TextComponent clickWinner = new TextComponent(ChatColor.GREEN + "Winner: " + ChatColor.GOLD + winner.getName());
+ TextComponent clickLoser = new TextComponent(ChatColor.RED + "Loser: " + ChatColor.GOLD + loser.getName());
+
+ clickWinner.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/view " + winner.getName()));
+ clickLoser.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/view " + loser.getName()));
+
+ spec.sendMessage("");
+ spec.spigot().sendMessage(clickWinner);
+ spec.spigot().sendMessage(clickLoser);
+ spec.sendMessage("");
+
+ }
+}
diff --git a/src/me/iran/iranpvp/utils/CustomInventory.java b/src/me/iran/iranpvp/utils/CustomInventory.java
new file mode 100644
index 0000000..4035127
--- /dev/null
+++ b/src/me/iran/iranpvp/utils/CustomInventory.java
@@ -0,0 +1,268 @@
+package me.iran.iranpvp.utils;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.kit.KitManager;
+import me.iran.iranpvp.type.GameType;
+import me.iran.iranpvp.type.GameTypeManager;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.scheduler.BukkitRunnable;
+
+public class CustomInventory {
+
+ KitManager km = new KitManager();
+
+ File file = null;
+
+ public Inventory gameTypes(final Player player) {
+ final Inventory gameTypes = Bukkit.createInventory(player, 18, ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("DUEL_INVENTORY")));
+ new BukkitRunnable() {
+ public void run() {
+ gameTypes.clear();
+ for (int i = 0; i < GameTypeManager.getManager().getAllGameTypes().size(); i++) {
+ GameType game = GameTypeManager.getManager().getAllGameTypes().get(i);
+
+ ItemStack display = game.getDisplay();
+ ItemMeta displayMeta = display.getItemMeta();
+ displayMeta.setDisplayName(game.getName());
+ displayMeta.setLore(Arrays.asList("", ChatColor.GRAY + "(" + ChatColor.RED.toString() + ChatColor.BOLD + "Click to Duel" + ChatColor.GRAY + ")"));
+ display.setItemMeta(displayMeta);
+
+ gameTypes.setItem(i, display);
+ }
+
+ }
+ }.runTaskTimer(IranPvP.plugin, 0L, 20L);
+
+ return gameTypes;
+ }
+
+ public Inventory kitEditorInv(Player player) {
+ Inventory gameTypes = Bukkit.createInventory(player, 18, ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("KIT_EDITOR_INVENTORY")));
+
+ List edit = new ArrayList();
+
+ for (int i = 0; i < GameTypeManager.getManager().getAllGameTypes().size(); i++) {
+
+ GameType game = GameTypeManager.getManager().getAllGameTypes().get(i);
+
+ if(game.getEdit()) {
+
+ edit.add(game);
+
+ for(int j = 0; j < edit.size(); j++) {
+
+ GameType gameEdit = edit.get(j);
+
+ ItemStack display = gameEdit.getDisplay();
+ ItemMeta displayMeta = display.getItemMeta();
+ displayMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ITEM_COLOR.KIT_EDITOR")) + gameEdit.getName());
+ display.setItemMeta(displayMeta);
+ gameTypes.setItem(j, display);
+
+ }
+ }
+
+ }
+
+ return gameTypes;
+ }
+
+ public Inventory deleteKit(Player player, GameType gameType) {
+ Inventory gameTypes = Bukkit.createInventory(player, 18, ChatColor.DARK_RED.toString() + ChatColor.BOLD + "Delete Kit");
+
+ file = new File(IranPvP.plugin.getDataFolder() + "/kits/" + player.getUniqueId().toString(), gameType.getName() + "_" + player.getUniqueId().toString() + ".yml");
+
+ if(file.exists()) {
+ file = new File(IranPvP.plugin.getDataFolder() + "/kits/" + player.getUniqueId().toString(), gameType.getName() + "_" + player.getUniqueId().toString() + ".yml");
+
+ new YamlConfiguration();
+
+ YamlConfiguration kConfig = YamlConfiguration.loadConfiguration(file);
+
+ List kits = new ArrayList<>();
+
+ ItemStack book = new ItemStack(Material.ENCHANTED_BOOK);
+ ItemMeta bookMeta = book.getItemMeta();
+
+ for(String name : kConfig.getConfigurationSection(gameType.getName()).getKeys(false)) {
+
+ kits.add(name);
+
+ if(kits.contains("name")) {
+ kits.remove("name");
+ }
+
+ if(kits.contains("inv")) {
+ kits.remove("inv");
+ }
+
+ if(kits.contains("armor")) {
+ kits.remove("armor");
+ }
+
+ if(kits.contains("size")) {
+ kits.remove("size");
+ }
+
+ for(int i = 0; i < kits.size(); i++) {
+ bookMeta.setDisplayName(kits.get(i));
+ book.setItemMeta(bookMeta);
+ gameTypes.setItem(i, book);
+ }
+ }
+
+ }
+ return gameTypes;
+ }
+
+ public Inventory saveKitInventory(Player player) {
+ Inventory save = Bukkit.createInventory(player, 27, ChatColor.DARK_RED.toString() + ChatColor.BOLD + "Kit Options");
+
+ ItemStack saveGlass = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 5);
+ ItemStack deleteGlass = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
+ ItemStack editGlass = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
+
+ ItemMeta saveMeta = saveGlass.getItemMeta();
+ ItemMeta deleteMeta = deleteGlass.getItemMeta();
+ ItemMeta editMeta = editGlass.getItemMeta();
+
+ saveMeta.setDisplayName(ChatColor.GREEN + "Save");
+ deleteMeta.setDisplayName(ChatColor.RED + "Delete");
+ editMeta.setDisplayName(ChatColor.YELLOW + "Cancel");
+
+ saveGlass.setItemMeta(saveMeta);
+ deleteGlass.setItemMeta(deleteMeta);
+ editGlass.setItemMeta(editMeta);
+
+ save.setItem(15, saveGlass);
+ save.setItem(13, deleteGlass);
+ save.setItem(11, editGlass);
+
+ return save;
+ }
+
+ public Inventory gameTypesTeam(final Player player) {
+ final Inventory gameTypes = Bukkit.createInventory(player, 18, ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TEAM_DUEL_INVENTORY")));
+ new BukkitRunnable() {
+ public void run() {
+ gameTypes.clear();
+ for (int i = 0; i < GameTypeManager.getManager().getAllGameTypes().size(); i++) {
+ GameType game = GameTypeManager.getManager().getAllGameTypes().get(i);
+
+ ItemStack display = game.getDisplay();
+ ItemMeta displayMeta = display.getItemMeta();
+ displayMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ITEM_COLOR.TEAM_DUEL")) + game.getName());
+ display.setItemMeta(displayMeta);
+
+ gameTypes.setItem(i, display);
+ }
+
+ }
+ }.runTaskTimer(IranPvP.plugin, 0L, 20L);
+
+ return gameTypes;
+ }
+
+ public Inventory modes(Player player) {
+ final Inventory gameMode = Bukkit.createInventory(player, 18, ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("GAME_MODES_INVENTORY")));
+
+ ItemStack teamFight = new ItemStack(Material.CHEST);
+ ItemStack kothFight = new ItemStack(Material.ENDER_CHEST);
+
+ ItemMeta teamMeta = teamFight.getItemMeta();
+ ItemMeta kothMeta = kothFight.getItemMeta();
+
+ teamMeta.setDisplayName(ChatColor.GREEN + "Team");
+
+ kothMeta.setDisplayName(ChatColor.AQUA + "KOTH");
+
+ teamFight.setItemMeta(teamMeta);
+ kothFight.setItemMeta(kothMeta);
+
+ gameMode.setItem(0, teamFight);
+ gameMode.setItem(1, kothFight);
+
+ return gameMode;
+ }
+
+ public Inventory queue(final Player player) {
+ final Inventory gameTypes = Bukkit.createInventory(player, 18, ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("UNRANKED_INVENTORY")));
+ new BukkitRunnable() {
+ public void run() {
+ gameTypes.clear();
+ for (int i = 0; i < GameTypeManager.getManager().getAllGameTypes().size(); i++) {
+ GameType game = GameTypeManager.getManager().getAllGameTypes().get(i);
+
+ ItemStack display = game.getDisplay();
+ ItemMeta displayMeta = display.getItemMeta();
+ displayMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ITEM_COLOR.UNRANKED")) + game.getName());
+ displayMeta.setLore(Arrays.asList("", ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ITEM_LORE.UNRANKED").replace("%size%", "" + game.getUnranked().size())), ""));
+ display.setItemMeta(displayMeta);
+
+ gameTypes.setItem(i, display);
+ }
+
+ }
+ }.runTaskTimer(IranPvP.plugin, 0L, 20L);
+
+ return gameTypes;
+ }
+
+ public Inventory ranked(final Player player) {
+ final Inventory gameTypes = Bukkit.createInventory(player, 18, ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("RANKED_INVENTORY")));
+ new BukkitRunnable() {
+ public void run() {
+ gameTypes.clear();
+ for (int i = 0; i < GameTypeManager.getManager().getAllGameTypes().size(); i++) {
+ GameType game = GameTypeManager.getManager().getAllGameTypes().get(i);
+
+ ItemStack display = game.getDisplay();
+ ItemMeta displayMeta = display.getItemMeta();
+ displayMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ITEM_COLOR.RANKED")) + game.getName());
+ displayMeta.setLore(Arrays.asList("", ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ITEM_LORE.RANKED").replace("%size%", "" + game.getRanked().size())), ""));
+ display.setItemMeta(displayMeta);
+
+ gameTypes.setItem(i, display);
+ }
+
+ }
+ }.runTaskTimer(IranPvP.plugin, 0L, 20L);
+
+ return gameTypes;
+ }
+
+ public Inventory ffa(final Player player) {
+ final Inventory gameTypes = Bukkit.createInventory(player, 18, ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("FFA_INVENTORY")));
+ new BukkitRunnable() {
+ public void run() {
+ gameTypes.clear();
+ for (int i = 0; i < GameTypeManager.getManager().getAllGameTypes().size(); i++) {
+ GameType game = GameTypeManager.getManager().getAllGameTypes().get(i);
+
+ ItemStack display = game.getDisplay();
+ ItemMeta displayMeta = display.getItemMeta();
+ displayMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ITEM_COLOR.UNRANKED")) + game.getName());
+ display.setItemMeta(displayMeta);
+
+ gameTypes.setItem(i, display);
+ }
+
+ }
+ }.runTaskTimer(IranPvP.plugin, 0L, 20L);
+
+ return gameTypes;
+ }
+}
diff --git a/src/me/iran/iranpvp/utils/EnderpearlCooldown.java b/src/me/iran/iranpvp/utils/EnderpearlCooldown.java
new file mode 100644
index 0000000..e8e23b0
--- /dev/null
+++ b/src/me/iran/iranpvp/utils/EnderpearlCooldown.java
@@ -0,0 +1,75 @@
+package me.iran.iranpvp.utils;
+
+import java.util.HashMap;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.duel.DuelManager;
+
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+
+public class EnderpearlCooldown implements Listener {
+ private static HashMap enderpearl = new HashMap();
+
+ IranPvP plugin;
+
+ ScoreboardUtils sb = new ScoreboardUtils();
+
+ public EnderpearlCooldown (IranPvP plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void onEnderpearl(PlayerInteractEvent event) {
+
+ Player player = event.getPlayer();
+
+ if(event.getAction() == null) {
+ return;
+ }
+
+
+ if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
+ if(player.getItemInHand().getType() == Material.ENDER_PEARL) {
+
+ if(DuelManager.getManager().getGames().containsKey(player.getName())) {
+ player.sendMessage(ChatColor.RED + "Can't pearl while the game hasn't started");
+ event.setCancelled(true);
+ }
+
+ if(enderpearl.containsKey(player.getName())) {
+
+ event.setCancelled(true);
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ENDERPEARL_COOLDOWN_MESSAGE").replace("%timer%", "" + enderpearl.get(player.getName()))));
+
+ } else {
+
+ sb.add(player, player.getScoreboard(), ChatColor.LIGHT_PURPLE, "pearl", ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.ENDERPEARL")));
+
+ enderpearl.put(player.getName(), 16);
+ }
+ }
+ }
+
+ }
+
+ @EventHandler
+ public void onQuit(PlayerQuitEvent event) {
+ Player player = event.getPlayer();
+
+ if(enderpearl.containsKey(player.getName())) {
+ enderpearl.remove(player.getName());
+ }
+ }
+
+ public static HashMap getEnderpearl() {
+ return enderpearl;
+ }
+
+}
diff --git a/src/me/iran/iranpvp/utils/OnJoinItems.java b/src/me/iran/iranpvp/utils/OnJoinItems.java
new file mode 100644
index 0000000..a8eccb0
--- /dev/null
+++ b/src/me/iran/iranpvp/utils/OnJoinItems.java
@@ -0,0 +1,148 @@
+package me.iran.iranpvp.utils;
+
+import me.iran.iranpvp.IranPvP;
+
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+public class OnJoinItems {
+
+ public void onJoin(Player player) {
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ ItemStack skull = new ItemStack(Material.NAME_TAG);
+ ItemStack kit = new ItemStack(Material.BOOK);
+ ItemStack sword = new ItemStack(Material.IRON_SWORD);
+ ItemStack gold = new ItemStack(Material.DIAMOND_SWORD);
+
+ ItemMeta kitMeta = kit.getItemMeta();
+ ItemMeta skullMeta = skull.getItemMeta();
+ ItemMeta swordMeta = sword.getItemMeta();
+ ItemMeta goldMeta = gold.getItemMeta();
+
+ skullMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("CREATE_TEAM")));
+ kitMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("KIT_EDITOR")));
+ swordMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("UNRANKED_SWORD")));
+ goldMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("RANKED_SWORD")));
+
+ kit.setItemMeta(kitMeta);
+ skull.setItemMeta(skullMeta);
+ sword.setItemMeta(swordMeta);
+ gold.setItemMeta(goldMeta);
+
+ player.getInventory().setItem(0, kit);
+ player.getInventory().setItem(4, skull);
+ player.getInventory().setItem(7, sword);
+ player.getInventory().setItem(8, gold);
+
+ player.updateInventory();
+ }
+
+ public void teamItems(Player player) {
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ ItemStack book = new ItemStack(Material.PAPER);
+ ItemStack fire = new ItemStack(Material.FLINT_AND_STEEL);
+ ItemStack bookshelf = new ItemStack(Material.BOOKSHELF);
+
+ ItemMeta bookMeta = book.getItemMeta();
+ ItemMeta fireMeta = fire.getItemMeta();
+ ItemMeta shelfMeta = bookshelf.getItemMeta();
+
+ bookMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TEAM_INFO")));
+ fireMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("LEAVE_TEAM")));
+ shelfMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ALL_TEAMS")));
+
+ book.setItemMeta(bookMeta);
+ fire.setItemMeta(fireMeta);
+ bookshelf.setItemMeta(shelfMeta);
+
+ player.getInventory().setItem(0, book);
+ player.getInventory().setItem(4, fire);
+ player.getInventory().setItem(8, bookshelf);
+ player.updateInventory();
+ }
+
+ public void teamLeaderItems(Player player) {
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ ItemStack book = new ItemStack(Material.PAPER);
+ ItemStack bookshelf = new ItemStack(Material.BOOKSHELF);
+ ItemStack fire = new ItemStack(Material.FLINT_AND_STEEL);
+
+ ItemMeta bookMeta = book.getItemMeta();
+ ItemMeta shelfMeta = bookshelf.getItemMeta();
+ ItemMeta fireMeta = fire.getItemMeta();
+
+
+ bookMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("TEAM_INFO")));
+ shelfMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ALL_TEAMS")));
+ fireMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("DISBAND_TEAM")));
+
+ book.setItemMeta(bookMeta);
+ bookshelf.setItemMeta(shelfMeta);
+ fire.setItemMeta(fireMeta);
+
+ player.getInventory().setItem(0, book);
+ player.getInventory().setItem(4, fire);
+ player.getInventory().setItem(8, bookshelf);
+ player.updateInventory();
+ }
+
+ public void unrankedQueue(Player player) {
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+ ItemStack red = new ItemStack(Material.REDSTONE);
+ ItemMeta redMeta = red.getItemMeta();
+
+ redMeta.setDisplayName(ChatColor.RED.toString() + ChatColor.BOLD + "Leave Unranked queue");
+ red.setItemMeta(redMeta);
+
+ player.getInventory().setItem(8, red);
+ player.updateInventory();
+ }
+
+ public void rankedQueue(Player player) {
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+ ItemStack red = new ItemStack(Material.REDSTONE);
+ ItemMeta redMeta = red.getItemMeta();
+
+ redMeta.setDisplayName(ChatColor.RED.toString() + ChatColor.BOLD + "Leave Ranked queue");
+ red.setItemMeta(redMeta);
+
+ player.getInventory().setItem(8, red);
+ player.updateInventory();
+ }
+
+ public void clearInv(Player player) {
+
+ for(int i = 0; i < player.getInventory().getContents().length; i++) {
+ player.getInventory().setItem(i, new ItemStack(Material.AIR));
+ player.updateInventory();
+ }
+
+ player.getInventory().setArmorContents(null);
+ }
+
+ public void spectatorMode(Player player) {
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+
+ ItemStack eye = new ItemStack(Material.REDSTONE_TORCH_ON);
+ ItemMeta eyeMeta = eye.getItemMeta();
+
+ eyeMeta.setDisplayName(ChatColor.RED + "Leave Spectator");
+ eye.setItemMeta(eyeMeta);
+
+ player.getInventory().setItem(0, eye);
+
+ }
+
+}
diff --git a/src/me/iran/iranpvp/utils/Queue.java b/src/me/iran/iranpvp/utils/Queue.java
new file mode 100644
index 0000000..ec12909
--- /dev/null
+++ b/src/me/iran/iranpvp/utils/Queue.java
@@ -0,0 +1,122 @@
+package me.iran.iranpvp.utils;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.duel.DuelManager;
+import me.iran.iranpvp.type.GameType;
+import me.iran.iranpvp.type.GameTypeManager;
+import me.iran.iranpvp.type.Ranked;
+import me.iran.iranpvp.type.RankedManager;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+
+public class Queue {
+
+ public void unrankedMatch() {
+ for(GameType game : GameTypeManager.getManager().getAllGameTypes()) {
+ if(game.getUnranked().size() > 1) {
+
+ if(ArenaManager.getManager().getAllAvailable().size() > 0) {
+ Player player1 = Bukkit.getPlayer(game.getUnranked().get(0));
+ Player player2 = Bukkit.getPlayer(game.getUnranked().get(1));
+
+ player1.sendMessage(ChatColor.GREEN + "Matched you up with " + ChatColor.GOLD + player2.getName() + ChatColor.GREEN + " in Queue " + ChatColor.YELLOW + game.getName());
+ player2.sendMessage(ChatColor.GREEN + "Matched you up with " + ChatColor.GOLD + player1.getName() + ChatColor.GREEN + " in Queue " + ChatColor.YELLOW + game.getName());
+
+ player1.getInventory().clear();
+ player1.getInventory().setArmorContents(null);
+
+ player2.getInventory().clear();
+ player2.getInventory().setArmorContents(null);
+
+ player1.getInventory().setContents(game.getInv());
+ player1.getInventory().setArmorContents(game.getArmor());
+
+ player2.getInventory().setContents(game.getInv());
+ player2.getInventory().setArmorContents(game.getArmor());
+
+ game.removeUnranked(player1.getName());
+ game.removeUnranked(player2.getName());
+
+ DuelManager.getManager().createDuel(player1, player2, game);
+ }
+
+ }
+ }
+ }
+
+ public void rankedMatch() {
+ for(Ranked rank : RankedManager.getManager().getAllRanked()) {
+ for(Ranked r : RankedManager.getManager().getAllRanked()) {
+
+ int min = rank.getElo() - 75;
+ int max = rank.getElo() + 75;
+
+ if(!rank.getPlayer().equals(r.getPlayer())) {
+
+ if(rank.getGameType().equals(r.getGameType())) {
+
+ if(r.getElo() >= min && r.getElo() <= max) {
+
+ if(rank.getGameType().getRanked().contains(rank.getPlayer().getName()) && rank.getGameType().getRanked().contains(r.getPlayer().getName())) {
+
+ if(ArenaManager.getManager().getAllAvailable().size() > 0) {
+ rank.getGameType().getRanked().remove(rank.getPlayer().getName());
+ r.getGameType().getRanked().remove(r.getPlayer().getName());
+
+ rank.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MATCH_FOUND").replace("%opponentelo%", "" + r.getElo()).replace("%opponent%", r.getPlayer().getName())));
+ r.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("ELO_MATCH_FOUND").replace("%opponentelo%", "" + rank.getElo()).replace("%opponent%", rank.getPlayer().getName())));
+
+ DuelManager.getManager().createRankedDuel(rank.getPlayer(), r.getPlayer(), rank.getGameType());
+ }
+
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+
+ public void leaveRanked(Player player) {
+ for(GameType game : GameTypeManager.getManager().getAllGameTypes()) {
+ if(game.getRanked().contains(player.getName())) {
+ game.getRanked().remove(player.getName());
+ player.sendMessage(ChatColor.RED + "Left Ranked queue for GameType " + ChatColor.GOLD + game.getName());
+ }
+ }
+ }
+
+ public void leaveUnranked(Player player) {
+ for(GameType game : GameTypeManager.getManager().getAllGameTypes()) {
+ if(game.getUnranked().contains(player.getName())) {
+ game.removeUnranked(player.getName());
+ player.sendMessage(ChatColor.RED + "Left Unranked queue for GameType " + ChatColor.GOLD + game.getName());
+ }
+ }
+ }
+
+ public boolean isInUnranked(Player player) {
+ for(GameType game : GameTypeManager.getManager().getAllGameTypes()) {
+ if(game.getUnranked().contains(player.getName())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ public boolean isInRanked(Player player) {
+ for(GameType game : GameTypeManager.getManager().getAllGameTypes()) {
+ if(game.getRanked().contains(player.getName())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/src/me/iran/iranpvp/utils/SQLConnection.java b/src/me/iran/iranpvp/utils/SQLConnection.java
new file mode 100644
index 0000000..137dcc6
--- /dev/null
+++ b/src/me/iran/iranpvp/utils/SQLConnection.java
@@ -0,0 +1,48 @@
+package me.iran.iranpvp.utils;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.Statement;
+
+import me.iran.iranpvp.type.GameType;
+import me.iran.iranpvp.type.GameTypeManager;
+
+public class SQLConnection {
+
+ private Connection connection;
+
+ public SQLConnection(String ip, String userName, String password, String db) {
+ try {
+
+ Class.forName("com.mysql.jdbc.Driver");
+ connection = DriverManager.getConnection("jdbc:mysql://" + ip + "/" + db + "?user=" + userName + "&password=" + password);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ public void createTable(String table) {
+
+ try{
+
+ PreparedStatement create = connection.prepareStatement("CREATE TABLE IF NOT EXISTS " + table);
+
+ Statement s = connection.createStatement();
+
+ for(int i = 0; i < GameTypeManager.getManager().getAllGameTypes().size(); i++) {
+
+ GameType game = GameTypeManager.getManager().getAllGameTypes().get(i);
+
+ s.execute("ALTER TABLE table ADD " + game.getName());
+ }
+
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+
+ }
+
+}
diff --git a/src/me/iran/iranpvp/utils/ScoreboardUtils.java b/src/me/iran/iranpvp/utils/ScoreboardUtils.java
new file mode 100644
index 0000000..aa4e797
--- /dev/null
+++ b/src/me/iran/iranpvp/utils/ScoreboardUtils.java
@@ -0,0 +1,692 @@
+package me.iran.iranpvp.utils;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.arena.Arena;
+import me.iran.iranpvp.arena.ArenaManager;
+import me.iran.iranpvp.duel.Duel;
+import me.iran.iranpvp.duel.DuelManager;
+import me.iran.iranpvp.duel.team.TeamDuel;
+import me.iran.iranpvp.duel.team.TeamDuelManager;
+import me.iran.iranpvp.duel.team.TeamFightManager;
+import me.iran.iranpvp.ffa.FFACommand;
+import me.iran.iranpvp.kit.bard.BardManager;
+import me.iran.iranpvp.teams.TeamManager;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.scoreboard.DisplaySlot;
+import org.bukkit.scoreboard.Objective;
+import org.bukkit.scoreboard.Scoreboard;
+import org.bukkit.scoreboard.Team;
+
+public class ScoreboardUtils {
+
+ public void remove(Player player, Scoreboard board, String team, ChatColor color) {
+
+ if(board.getObjective(DisplaySlot.SIDEBAR) != null) {
+
+ if(board.getTeam(team) != null) {
+ board.resetScores(color.toString());
+
+ board.getTeam(team).unregister();
+ }
+ }
+ }
+
+
+ public void add(Player player, Scoreboard board, ChatColor entry, String t, String name, String msg) {
+
+ if(board.getObjective(DisplaySlot.SIDEBAR) != null) {
+
+ if(board.getTeam(t) == null) {
+ Team team = board.registerNewTeam(t);
+
+ Objective obj = board.getObjective(DisplaySlot.SIDEBAR);
+
+ team.addEntry(entry.toString());
+ team.setPrefix(ChatColor.GREEN.toString() + ChatColor.BOLD + msg);
+ team.setSuffix(ChatColor.WHITE + name);
+
+ obj.getScore(ChatColor.BLUE.toString()).setScore(board.getEntries().size() + 1);
+ }
+ }
+ }
+
+ public void add(Player player, Scoreboard board, ChatColor entry, String t, String msg) {
+
+ if(board.getObjective(DisplaySlot.SIDEBAR) != null) {
+
+ if(board.getTeam(t) == null) {
+ Team team = board.registerNewTeam(t);
+
+ Objective obj = board.getObjective(DisplaySlot.SIDEBAR);
+
+ team.addEntry(entry.toString());
+ team.setPrefix(msg);
+ team.setSuffix(ChatColor.GREEN + "");
+
+ obj.getScore(entry.toString()).setScore(board.getEntries().size() + 1);
+ }
+ }
+ }
+
+
+
+ @SuppressWarnings("deprecation")
+ public Scoreboard setKOTHBoard(Player player) {
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+ TeamDuel duel = TeamDuelManager.getManager().getDuelByPlayer(player);
+
+
+ if(arena == null) {
+ return null;
+ }
+
+ if(duel == null) {
+ return null;
+ }
+
+ player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
+
+ if(board == null) {
+ System.out.println("Board is null");
+ return null;
+ }
+
+ Objective obj = board.registerNewObjective("koth", "dummy");
+
+ obj.setDisplaySlot(DisplaySlot.SIDEBAR);
+ obj.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.TITLE")));
+
+ Team topWrapper = board.registerNewTeam("top");
+ topWrapper.addEntry(ChatColor.WHITE.toString());
+ topWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ topWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ obj.getScore(ChatColor.WHITE.toString()).setScore(0);
+
+ Team bottomWrapper = board.registerNewTeam("bottom");
+ bottomWrapper.addEntry(ChatColor.BLACK.toString());
+ bottomWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ bottomWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ obj.getScore(ChatColor.BLACK.toString()).setScore(4);
+
+ Team arenaBoard = board.registerNewTeam("koth");
+ arenaBoard.addEntry(ChatColor.RED.toString());
+ arenaBoard.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.KOTH.ARENA").replace("%arena%", arena.getName())));
+ arenaBoard.setSuffix(toMMSS((long) arena.getTimer()));
+ obj.getScore(ChatColor.RED.toString()).setScore(2);
+ me.iran.iranpvp.teams.Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ Team opponent = board.registerNewTeam("opponent");
+ opponent.addEntry(ChatColor.RESET.toString());
+ opponent.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.KOTH.OPPONENT")));
+
+ Team capper = board.registerNewTeam("capper");
+ capper.addEntry(ChatColor.YELLOW.toString());
+ capper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.KOTH.CAPPER")));
+ capper.setSuffix(ChatColor.YELLOW + "None");
+ obj.getScore(ChatColor.YELLOW.toString()).setScore(1);
+
+ if(duel.getTeam1() == team) {
+ opponent.setSuffix(duel.getTeam2().getTeamName());
+ } else {
+ opponent.setSuffix(duel.getTeam1().getTeamName());
+ }
+
+ obj.getScore(ChatColor.RESET.toString()).setScore(3);
+
+ Team friend;
+
+ if(board.getTeam("friend") != null) {
+ friend = board.getTeam("friend");
+ } else {
+ friend = board.registerNewTeam("friend");
+ }
+
+ friend.setPrefix(ChatColor.GREEN.toString());
+
+ Team enemy;
+
+ if(board.getTeam("enemy") != null) {
+ enemy = board.getTeam("enemy");
+ } else {
+ enemy = board.registerNewTeam("enemy");
+ }
+
+ enemy.setPrefix(ChatColor.WHITE.toString());
+ enemy.setCanSeeFriendlyInvisibles(false);
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ enemy.addPlayer(p);
+ }
+ if(TeamManager.getManager().getAllTeams().contains(team)) {
+
+ for(int i = 0; i < team.getTeamMembers().size(); i++) {
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team.getTeamMembers().contains(p.getName())) {
+
+ friend.addPlayer(p);
+ friend.canSeeFriendlyInvisibles();
+
+ }
+ }
+ }
+ }
+
+ player.setScoreboard(board);
+
+ return board;
+ }
+
+ @SuppressWarnings("deprecation")
+ public Scoreboard lobbyBoard(Player player) {
+
+ Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
+
+ if(board == null) {
+ System.out.println("Board is null");
+ return null;
+ }
+
+ player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ Objective obj = board.registerNewObjective("lobby", "dummy");
+
+ obj.setDisplaySlot(DisplaySlot.SIDEBAR);
+ obj.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.TITLE")));
+
+ Team topWrapper = board.registerNewTeam("top");
+ topWrapper.addEntry(ChatColor.WHITE.toString());
+ topWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ topWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ obj.getScore(ChatColor.WHITE.toString()).setScore(1);
+
+ Team bottomWrapper = board.registerNewTeam("bottom");
+ bottomWrapper.addEntry(ChatColor.BLACK.toString());
+ bottomWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ bottomWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ obj.getScore(ChatColor.BLACK.toString()).setScore(4);
+
+ Team online = board.registerNewTeam("online");
+ online.addEntry(ChatColor.AQUA.toString());
+ online.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LOBBY.ONLINE")));
+ online.setSuffix(ChatColor.WHITE.toString() + 0);
+ obj.getScore(ChatColor.AQUA.toString()).setScore(3);
+
+ Team queue = board.registerNewTeam("queue");
+ queue.addEntry(ChatColor.RESET.toString());
+ queue.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LOBBY.QUEUE")));
+ queue.setSuffix(ChatColor.WHITE.toString() + 0);
+ obj.getScore(ChatColor.RESET.toString()).setScore(2);
+
+ Team white;
+
+ if(board.getTeam("white") != null) {
+ white = board.getTeam("white");
+ } else {
+ white = board.registerNewTeam("white");
+ }
+
+ white.setPrefix(ChatColor.WHITE.toString());
+
+ if(!white.getPlayers().contains(player)) {
+ white.addPlayer(player);
+ }
+
+ player.setScoreboard(board);
+
+ return board;
+
+ }
+
+ @SuppressWarnings("deprecation")
+ public Scoreboard setBoard(Player player) {
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(player);
+ TeamDuel duel = TeamDuelManager.getManager().getDuelByPlayer(player);
+
+
+ if(arena == null) {
+ return null;
+ }
+
+ if(duel == null) {
+ return null;
+ }
+
+ player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
+
+ if(board == null) {
+ System.out.println("Board is null");
+ return null;
+ }
+
+ Objective obj = board.registerNewObjective("koth", "dummy");
+
+ obj.setDisplaySlot(DisplaySlot.SIDEBAR);
+ obj.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.TITLE")));
+
+ Team topWrapper = board.registerNewTeam("top");
+ topWrapper.addEntry(ChatColor.WHITE.toString());
+ topWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ topWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ obj.getScore(ChatColor.WHITE.toString()).setScore(1);
+
+ Team bottomWrapper = board.registerNewTeam("bottom");
+ bottomWrapper.addEntry(ChatColor.BLACK.toString());
+ bottomWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ bottomWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ obj.getScore(ChatColor.BLACK.toString()).setScore(4);
+
+ Team arenaBoard = board.registerNewTeam("arena");
+ arenaBoard.addEntry(ChatColor.AQUA.toString());
+ arenaBoard.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.TEAM.ARENA")));
+ arenaBoard.setSuffix(arena.getName());
+ obj.getScore(ChatColor.AQUA.toString()).setScore(2);
+ me.iran.iranpvp.teams.Team team = TeamManager.getManager().getTeamByPlayer(player);
+
+ Team opponent = board.registerNewTeam("opponent");
+ opponent.addEntry(ChatColor.RESET.toString());
+ opponent.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.TEAM.OPPONENT")));
+
+ Team capper = board.registerNewTeam("alive");
+ capper.addEntry(ChatColor.YELLOW.toString());
+ capper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.TEAM.ALIVE")));
+ capper.setSuffix(ChatColor.YELLOW + "None");
+ obj.getScore(ChatColor.YELLOW.toString()).setScore(2);
+
+ if(duel.getTeam1() == team) {
+ opponent.setSuffix(duel.getTeam2().getTeamName());
+ } else {
+ opponent.setSuffix(duel.getTeam1().getTeamName());
+ }
+
+ obj.getScore(ChatColor.RESET.toString()).setScore(3);
+
+ Team friend;
+
+ if(board.getTeam("friend") != null) {
+ friend = board.getTeam("friend");
+ } else {
+ friend = board.registerNewTeam("friend");
+ }
+
+ friend.setPrefix(ChatColor.GREEN.toString());
+
+ Team enemy;
+
+ if(board.getTeam("enemy") != null) {
+ enemy = board.getTeam("enemy");
+ } else {
+ enemy = board.registerNewTeam("enemy");
+ }
+
+ enemy.setPrefix(ChatColor.WHITE.toString());
+ enemy.setCanSeeFriendlyInvisibles(false);
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ enemy.addPlayer(p);
+ }
+ if(TeamManager.getManager().getAllTeams().contains(team)) {
+
+ for(int i = 0; i < team.getTeamMembers().size(); i++) {
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(team.getTeamMembers().contains(p.getName())) {
+
+ friend.addPlayer(p);
+ friend.canSeeFriendlyInvisibles();
+
+ }
+ }
+ }
+ }
+
+ player.setScoreboard(board);
+
+ return board;
+ }
+
+ public Scoreboard ffaBoard(Player player) {
+
+ if(!FFACommand.fighters.contains(player.getName())) {
+ return null;
+ }
+
+ player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
+
+ Objective obj = board.registerNewObjective("ffa", "dummy");
+
+ obj.setDisplaySlot(DisplaySlot.SIDEBAR);
+ obj.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.TITLE")));
+
+ // 1
+ Team topWrapper = board.registerNewTeam("top");
+ topWrapper.addEntry(ChatColor.WHITE.toString());
+ topWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ topWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ obj.getScore(ChatColor.WHITE.toString()).setScore(1);
+
+ // 4
+ Team bottomWrapper = board.registerNewTeam("bottom");
+ bottomWrapper.addEntry(ChatColor.BLACK.toString());
+ bottomWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ bottomWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ obj.getScore(ChatColor.BLACK.toString()).setScore(4);
+
+ // 2
+ Team ffa = board.registerNewTeam("ffa");
+ ffa.addEntry(ChatColor.RED.toString());
+ ffa.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.FFA.ALIVE")));
+ ffa.setSuffix("" + FFACommand.fighters.size());
+ obj.getScore(ChatColor.RED.toString()).setScore(3);
+
+ Team timer = board.registerNewTeam("timer");
+ timer.addEntry(ChatColor.GREEN.toString());
+ timer.setPrefix(ChatColor.GREEN + "Starting in ");
+ timer.setSuffix("" + FFACommand.getTimer());
+ obj.getScore(ChatColor.GREEN.toString()).setScore(2);
+
+ Team fighters;
+
+ if(board.getTeam("fighters") != null) {
+ fighters = board.getTeam("fighters");
+ } else {
+ fighters = board.registerNewTeam("fighters");
+ }
+
+ fighters.setPrefix(ChatColor.RED.toString());
+
+ player.setScoreboard(board);
+
+ return board;
+ }
+
+ public Scoreboard duelBoard(Player player) {
+
+ Duel duel = DuelManager.getManager().getDuelByPlayer(player);
+
+ if(duel == null) {
+ return null;
+ }
+
+ player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
+
+ Objective obj = board.registerNewObjective("duel", "dummy");
+
+ obj.setDisplaySlot(DisplaySlot.SIDEBAR);
+ obj.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.TITLE")));
+
+ // 1
+ Team topWrapper = board.registerNewTeam("top");
+ topWrapper.addEntry(ChatColor.WHITE.toString());
+ topWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ topWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ obj.getScore(ChatColor.WHITE.toString()).setScore(1);
+
+ // 4
+ Team bottomWrapper = board.registerNewTeam("bottom");
+ bottomWrapper.addEntry(ChatColor.BLACK.toString());
+ bottomWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ bottomWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ obj.getScore(ChatColor.BLACK.toString()).setScore(4);
+
+ // 2
+ Team fight = board.registerNewTeam("fight");
+ fight.addEntry(ChatColor.RESET.toString());
+ fight.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.DUEL.OPPONENT")));
+
+ if(duel.getPlayer1().getName().equals(player.getName())) {
+ fight.setSuffix(ChatColor.stripColor(duel.getPlayer2().getName()));
+ } else if(duel.getPlayer2().getName().equals(player.getName())) {
+ fight.setSuffix(ChatColor.stripColor(duel.getPlayer1().getName()));
+ }
+
+ obj.getScore(ChatColor.RESET.toString()).setScore(3);
+
+
+ Team timer = board.registerNewTeam("timer");
+
+ timer.addEntry(ChatColor.DARK_GREEN.toString());
+ timer.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.DUEL.DURATION")));
+ timer.setSuffix(ChatColor.WHITE + toMMSS(duel.getTimer()));
+
+ obj.getScore(ChatColor.DARK_GREEN.toString()).setScore(2);
+
+ player.setScoreboard(board);
+
+ return board;
+ }
+
+ @SuppressWarnings("deprecation")
+ public Scoreboard specDuelBoard(Player player, Player target) {
+
+ Duel duel = DuelManager.getManager().getDuelByPlayer(target);
+
+ if(duel == null) {
+ System.out.println("duel is null");
+ return null;
+ }
+
+ player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
+
+ Objective obj = board.registerNewObjective("specduel", "dummy");
+
+ obj.setDisplaySlot(DisplaySlot.SIDEBAR);
+ obj.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.TITLE")));
+
+ // 1
+ Team topWrapper = board.registerNewTeam("top");
+ topWrapper.addEntry(ChatColor.WHITE.toString());
+ topWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ topWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ obj.getScore(ChatColor.WHITE.toString()).setScore(0);
+
+ Team bottomWrapper = board.registerNewTeam("bottom");
+ bottomWrapper.addEntry(ChatColor.BLACK.toString());
+ bottomWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ bottomWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ obj.getScore(ChatColor.BLACK.toString()).setScore(5);
+
+ Team player1 = board.registerNewTeam("player1");
+ player1.addEntry(ChatColor.RED.toString());
+ player1.setPrefix(ChatColor.RED.toString() + ChatColor.BOLD + "Player1: ");
+ player1.setSuffix(duel.getPlayer1().getName());
+
+ obj.getScore(ChatColor.RED.toString()).setScore(4);
+
+ Team player2 = board.registerNewTeam("player2");
+ player2.addEntry(ChatColor.GOLD.toString());
+ player2.setPrefix(ChatColor.GOLD.toString() + ChatColor.BOLD + "Player2: ");
+ player2.setSuffix(duel.getPlayer2().getName());
+
+ obj.getScore(ChatColor.GOLD.toString()).setScore(3);
+
+ Team kit = board.registerNewTeam("kit");
+ kit.addEntry(ChatColor.DARK_AQUA.toString());
+ kit.setPrefix(ChatColor.DARK_AQUA.toString() + ChatColor.BOLD + "Kit: ");
+ kit.setSuffix(duel.getGameType().getName());
+
+ obj.getScore(ChatColor.DARK_AQUA.toString()).setScore(2);
+
+ Team timer = board.registerNewTeam("spectimer");
+
+ timer.addEntry(ChatColor.DARK_GREEN.toString());
+ timer.setPrefix(ChatColor.YELLOW.toString() + ChatColor.BOLD + "Timer: ");
+ timer.setSuffix(ChatColor.WHITE + toMMSS(duel.getTimer()));
+
+ obj.getScore(ChatColor.DARK_GREEN.toString()).setScore(1);
+
+ Team p1;
+
+ if(board.getTeam("p1") != null) {
+ p1 = board.getTeam("p1");
+ } else {
+ p1 = board.registerNewTeam("p1");
+ }
+
+ p1.setPrefix(ChatColor.RED.toString());
+
+ p1.addPlayer(duel.getPlayer1());
+
+ Team p2;
+
+ if(board.getTeam("p2") != null) {
+ p2 = board.getTeam("p2");
+ } else {
+ p2 = board.registerNewTeam("p2");
+ }
+
+ p2.setPrefix(ChatColor.GOLD.toString());
+
+ p2.addPlayer(duel.getPlayer2());
+
+ player.setScoreboard(board);
+
+ return board;
+ }
+
+ @SuppressWarnings("deprecation")
+ public Scoreboard specTeamBoard(Player player, Player target) {
+
+ TeamDuel duel = TeamDuelManager.getManager().getDuelByPlayer(target);
+
+ if(duel == null) {
+ System.out.println("duel is null");
+ return null;
+ }
+
+ Arena arena = ArenaManager.getManager().getArenaByPlayer(target);
+
+ if(arena == null) {
+ System.out.println("arena is null");
+ return null;
+ }
+
+ player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
+
+ Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
+
+ Objective obj = board.registerNewObjective("specteam", "dummy");
+
+ obj.setDisplaySlot(DisplaySlot.SIDEBAR);
+ obj.setDisplayName(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.TITLE")));
+
+ // 1
+ Team topWrapper = board.registerNewTeam("top");
+ topWrapper.addEntry(ChatColor.WHITE.toString());
+ topWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ topWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_TOP")));
+ obj.getScore(ChatColor.WHITE.toString()).setScore(0);
+
+ Team bottomWrapper = board.registerNewTeam("bottom");
+ bottomWrapper.addEntry(ChatColor.BLACK.toString());
+ bottomWrapper.setPrefix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ bottomWrapper.setSuffix(ChatColor.translateAlternateColorCodes('&', IranPvP.plugin.getConfig().getString("SCOREBOARD.LINE_BOTTOM")));
+ obj.getScore(ChatColor.BLACK.toString()).setScore(5);
+
+ Team team1 = board.registerNewTeam("team1");
+ team1.addEntry(ChatColor.RED.toString());
+ team1.setPrefix(ChatColor.RED.toString() + ChatColor.BOLD + "Team1: ");
+ team1.setSuffix(duel.getTeam1().getTeamName());
+
+ obj.getScore(ChatColor.RED.toString()).setScore(4);
+
+ Team team2 = board.registerNewTeam("team2");
+ team2.addEntry(ChatColor.GOLD.toString());
+ team2.setPrefix(ChatColor.YELLOW.toString() + ChatColor.BOLD + "Team2: ");
+ team2.setSuffix(duel.getTeam2().getTeamName());
+
+ obj.getScore(ChatColor.GOLD.toString()).setScore(3);
+
+ Team kit = board.registerNewTeam("kit");
+ kit.addEntry(ChatColor.DARK_AQUA.toString());
+ kit.setPrefix(ChatColor.DARK_AQUA.toString() + ChatColor.BOLD + "Kit: ");
+ kit.setSuffix(duel.getGameType().getName());
+
+ obj.getScore(ChatColor.DARK_AQUA.toString()).setScore(2);
+
+ if(arena.isActive()) {
+ Team specKoth = board.registerNewTeam("speckoth");
+
+ specKoth.addEntry(ChatColor.DARK_GREEN.toString());
+ specKoth.setPrefix(ChatColor.YELLOW.toString() + arena.getName());
+ specKoth.setSuffix(ChatColor.WHITE + ": " + toMMSS(arena.getTimer()));
+
+ obj.getScore(ChatColor.DARK_GREEN.toString()).setScore(1);
+
+ } else {
+
+ Team specteam = board.registerNewTeam("specteam");
+
+ specteam.addEntry(ChatColor.DARK_GREEN.toString());
+ specteam.setPrefix(ChatColor.YELLOW.toString() + ChatColor.BOLD + "Arena: ");
+ specteam.setSuffix(ChatColor.YELLOW.toString() + arena.getName());
+ obj.getScore(ChatColor.DARK_GREEN.toString()).setScore(1);
+ }
+
+
+
+ Team t1;
+
+ if(board.getTeam("p1") != null) {
+ t1 = board.getTeam("p1");
+ } else {
+ t1 = board.registerNewTeam("p1");
+ }
+
+ t1.setPrefix(ChatColor.RED.toString());
+
+
+ Team t2;
+
+ if(board.getTeam("p2") != null) {
+ t2 = board.getTeam("p2");
+ } else {
+ t2 = board.registerNewTeam("p2");
+ }
+
+ t2.setPrefix(ChatColor.GOLD.toString());
+
+ for(Player p : Bukkit.getOnlinePlayers()) {
+ if(duel.getTeam1().getTeamMembers().contains(p.getName())) {
+ t1.addPlayer(p);
+ } else if(duel.getTeam2().getTeamMembers().contains(p.getName())) {
+ t2.addPlayer(p);
+ }
+ }
+
+ player.setScoreboard(board);
+
+ return board;
+ }
+
+ public static String toMMSS(long dura){
+ int minute = (int)(dura / 60.0D);
+ long second = dura - (minute * 60);
+ String formatted = "";
+ {
+ if(minute < 10){
+ formatted += "";
+ }
+ formatted += minute;
+ formatted += ":";
+ if(second < 10){
+ formatted += "0";
+ }
+ formatted += second;
+ }
+ return formatted;
+ }
+}
diff --git a/src/me/iran/iranpvp/utils/TeleportSpawn.java b/src/me/iran/iranpvp/utils/TeleportSpawn.java
new file mode 100644
index 0000000..3c0359c
--- /dev/null
+++ b/src/me/iran/iranpvp/utils/TeleportSpawn.java
@@ -0,0 +1,76 @@
+package me.iran.iranpvp.utils;
+
+import me.iran.iranpvp.IranPvP;
+import me.iran.iranpvp.runnable.Run;
+import me.iran.iranpvp.teams.TeamManager;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.potion.PotionEffect;
+
+public class TeleportSpawn {
+
+ OnJoinItems items = new OnJoinItems();
+
+ ScoreboardUtils sb = new ScoreboardUtils();
+
+ public void teleportSpawn(Player player) {
+
+ int x = IranPvP.plugin.getConfig().getInt("spawn.x");
+ int y = IranPvP.plugin.getConfig().getInt("spawn.y");
+ int z = IranPvP.plugin.getConfig().getInt("spawn.z");
+ double pitch = IranPvP.plugin.getConfig().getDouble("spawn.pitch");
+ double yaw = IranPvP.plugin.getConfig().getDouble("spawn.yaw");
+ String world = IranPvP.plugin.getConfig().getString("spawn.world");
+
+ Location loc = new Location(Bukkit.getWorld(world), x, y, z);
+ loc.setPitch((float) pitch);
+ loc.setYaw((float) yaw);
+
+ if(TeamManager.getManager().isInTeam(player)) {
+ if(TeamManager.getManager().getTeamByPlayer(player).getTeamLeader().equals(player.getName())) {
+ items.teamLeaderItems(player);
+ } else {
+ items.teamItems(player);
+ }
+ } else {
+ items.onJoin(player);
+ }
+
+ for(PotionEffect effect : player.getActivePotionEffects()) {
+ player.removePotionEffect(effect.getType());
+ }
+
+ player.setHealth(20.0);
+ player.setFoodLevel(20);
+ player.teleport(loc);
+
+ player.setScoreboard(sb.lobbyBoard(player));
+
+
+
+ }
+
+ public void teleportKit(Player player) {
+
+ int x = IranPvP.plugin.getConfig().getInt("kit.x");
+ int y = IranPvP.plugin.getConfig().getInt("kit.y");
+ int z = IranPvP.plugin.getConfig().getInt("kit.z");
+ double pitch = IranPvP.plugin.getConfig().getDouble("kit.pitch");
+ double yaw = IranPvP.plugin.getConfig().getDouble("kit.yaw");
+ String world = IranPvP.plugin.getConfig().getString("kit.world");
+
+ Location loc = new Location(Bukkit.getWorld(world), x, y, z);
+ loc.setPitch((float) pitch);
+ loc.setYaw((float) yaw);
+
+ player.teleport(loc);
+
+ items.clearInv(player);
+
+ player.setHealth(20.0);
+ player.setFoodLevel(20);
+
+ }
+}