Basically. When 2 players duel they get the parameters added to their name (player1, player2) but we have multiple players dueling in the same arena and they cant see each other or anything but the duels can clash if they come into each other. For example player1 is dueling player2 but then another player1 and player2 join which is completely 2 other random people and if that other player1 hit the other player1 it would allow it, same for player2 and player2+player1. The duels can clash basically. Also the potions clash so when you are dueling you can see the other player1+player2's potions and enderpearls if your in the same arena. Does anyone have a fix for this? Im like super tired right now and really confused with it. I've done java but rarely bukkit. I will list all the classes that you will need below. Listeners.java CLASS below Code: package me.HTM; import com.google.common.collect.Multimap; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Random; import java.util.Set; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.Chest; import org.bukkit.block.Sign; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.entity.ThrownPotion; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PotionSplashEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffect; import org.kitteh.tag.AsyncPlayerReceiveNameTagEvent; @SuppressWarnings("unused") public class Listeners implements Listener { Core plugin; public Listeners(Core plugin) { this.plugin = plugin; } @EventHandler public void onNameTag(AsyncPlayerReceiveNameTagEvent event) { if (event.getNamedPlayer().getName().equals("Oblation")) { event.setTag(ChatColor.AQUA + "" + ChatColor.BOLD + "Oblation"); } } @EventHandler public void onSignCreate(SignChangeEvent e) { Player p = e.getPlayer(); Sign sign = (Sign)e.getBlock().getState(); if ((Lists.creatingSign.containsKey(p.getName())) && (((Integer)Lists.creatingSign.get(p.getName())).intValue() == 1)) { Chat.sendMessage(p, "Now type " + Chat.white + "\"" + Chat.gold + "Load" + Chat.white + "\"" + Chat.gold + " or " + Chat.white + "\"" + Chat.gold + "Save" + Chat.white + "\"" + Chat.gold + " to create either a load or save sign."); Lists.creatingSignState.put(p.getName(), sign); Lists.creatingSign.put(p.getName(), Integer.valueOf(2)); } } @EventHandler public void onBlockBreak(BlockBreakEvent e) { Player p = e.getPlayer(); if (e.getBlock().getType() == Material.CHEST) { InfiniteChest infiniteChest = new InfiniteChest((Chest)e.getBlock().getState()); if ((infiniteChest.exists()) && (!e.isCancelled()) && (p.hasPermission("potpvp.removechest"))) { infiniteChest.remove(); Chat.sendMessage(p, "Infinite chest removed."); } } if ((e.getBlock().getType() == Material.WALL_SIGN) || (e.getBlock().getType() == Material.SIGN_POST)) { Sign sign = (Sign)e.getBlock().getState(); KitSign kitSign = KitSign.getSign(sign); if ((kitSign.exists()) && (!e.isCancelled()) && (p.hasPermission("potpvp.removesign"))) { kitSign.remove(); Chat.sendMessage(p, "Kit sign removed."); } } } @EventHandler public void onEntitySpawn(ProjectileLaunchEvent e) { if ((e.getEntity().getShooter() instanceof Player)) { Projectile entity = e.getEntity(); Player p = (Player)e.getEntity().getShooter(); if (((entity instanceof ThrownPotion)) && (DuelMatch.isInDuel(p))) { for (Player all : Bukkit.getOnlinePlayers()) { if ((!all.equals(DuelMatch.getPartner(p))) && (!all.equals(p))) { Core.entityHider.hideEntity(all, entity); Core.hiddenEntities.put(all.getName(), Integer.valueOf(e.getEntity().getEntityId())); } } } } } @EventHandler public void onCommand(PlayerCommandPreprocessEvent event) { Player player = event.getPlayer(); if (event.getMessage().split(" ")[0].contains(":")) { // stops colon event.setCancelled(true); } else { if (player.isOp()) { event.setCancelled(false); } } } @EventHandler public void onPotionSpash(PotionSplashEvent e) { if ((e.getPotion().getShooter() instanceof Player)) { Player p = (Player)e.getPotion().getShooter(); for (LivingEntity entity : e.getAffectedEntities()) { if ((entity instanceof Player)) { Player player = (Player)entity; if ((!player.getName().equals(p.getName())) && (DuelMatch.isInDuel(p)) && (!player.getName().equals(DuelMatch.getPartner(p).getName()))) { e.setIntensity(player, 0.0D); { } } } } } } @EventHandler public void onJoin(PlayerJoinEvent e) { Player p = e.getPlayer(); for (String all : Duel.getPlayersInDuel()) { Player player = Bukkit.getPlayer(all); if (player != null) { player.hidePlayer(p); p.hidePlayer(player); } } } @EventHandler public void onQuit(PlayerQuitEvent e) { Player p = e.getPlayer(); Player d = e.getPlayer(); Core.hiddenEntities.removeAll(p.getName()); if (Lists.matchup.contains(p.getName())) { Lists.matchup.remove(p.getName()); Lists.inDuel.remove(p.getName()); Lists.inDuel.remove(d.getName()); } if (DuelMatch.isInDuel(p)) { p.getInventory().clear(); p.getInventory().setArmorContents(null); DuelMatch.showPlayers(p, DuelMatch.getPartner(p)); DuelMatch.getPartner(p).setHealth(20.0D); DuelMatch.getPartner(p).teleport(Bukkit.getWorld("Spawn").getSpawnLocation()); DuelMatch.removeFromDuel(p); DuelMatch.removeFromDuel(d); DuelMatch.showPlayers(d, p); } } @EventHandler public void onPlayerKick(PlayerKickEvent e) { Player p = e.getPlayer(); Player d = e.getPlayer(); Core.hiddenEntities.removeAll(p.getName()); if (Lists.matchup.contains(p.getName())) { Lists.matchup.remove(p.getName()); Lists.inDuel.remove(p.getName()); Lists.inDuel.remove(d.getName()); } if (DuelMatch.isInDuel(p)) { p.getInventory().clear(); p.getInventory().setArmorContents(null); DuelMatch.showPlayers(p, DuelMatch.getPartner(p)); DuelMatch.getPartner(p).setHealth(20.0D); DuelMatch.getPartner(p).teleport(Bukkit.getWorld("Spawn").getSpawnLocation()); DuelMatch.removeFromDuel(p); DuelMatch.removeFromDuel(d); DuelMatch.showPlayers(d, p); } } @EventHandler public void onProjectiveHit(ProjectileHitEvent e) { int id = e.getEntity().getEntityId(); while (Core.hiddenEntities.values().remove(Integer.valueOf(id))) {} } Random random = new Random(); @EventHandler public void onFoodChange(FoodLevelChangeEvent e) { Player p = (Player)e.getEntity(); if ((e.getFoodLevel() < p.getFoodLevel()) && (this.random.nextInt(100) <= 70)) { e.setCancelled(true); } } @EventHandler public void onDeath(PlayerDeathEvent e) { Player p = e.getEntity().getKiller(); Player d = e.getEntity(); if (DuelMatch.isInDuel(p)) { e.getDrops().clear(); if (DuelMatch.getPartner(p) != null) { DuelMatch.showPlayers(p, DuelMatch.getPartner(p)); DuelMatch.getPartner(p).teleport(Bukkit.getWorld("Spawn").getSpawnLocation()); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "heal " + p.getName()); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "clearinventory " + p.getName()); DuelMatch.getPartner(d).teleport(Bukkit.getWorld("Spawn").getSpawnLocation()); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "heal " + d.getName()); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "clearinventory " + d.getName()); // p.teleport(Bukkit.getWorld("world").getSpawnLocation()); // d.teleport(Bukkit.getWorld("world").getSpawnLocation()); Bukkit.broadcastMessage(ChatColor.RED + p.getName() + ChatColor.GRAY + " has beaten " + ChatColor.RED + d.getName() + ChatColor.GRAY + " in a duel!"); for (PotionEffect potionEffect : DuelMatch.getPartner(p).getActivePotionEffects()) { DuelMatch.getPartner(p).removePotionEffect(potionEffect.getType()); } DuelMatch.removeFromDuel(d); DuelMatch.removeFromDuel(DuelMatch.getPartner(d)); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "heal " + p.getName()); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "heal " + d.getName()); e.setDeathMessage(null); } } } @EventHandler public void onChat(AsyncPlayerChatEvent e) { Player p = e.getPlayer(); String msg = e.getMessage().trim(); if (Lists.creatingSign.containsKey(p.getName())) { if (((Integer)Lists.creatingSign.get(p.getName())).intValue() == 2) { if ((msg.equalsIgnoreCase("load")) || (msg.equalsIgnoreCase("save"))) { Chat.sendMessage(p, "Now type a sign ID to create the " + msg.toLowerCase() + " sign."); Lists.creatingSignData.put(p.getName(), msg.toLowerCase()); Lists.creatingSign.put(p.getName(), Integer.valueOf(3)); } else { Chat.sendMessage(p, "Error: Message, " + Chat.white + "\"" + Chat.gold + msg + Chat.white + "\"" + Chat.gold + " is not allowed."); } } else if (((Integer)Lists.creatingSign.get(p.getName())).intValue() == 3) { try { int id = Integer.parseInt(msg); String type = (String)Lists.creatingSignData.get(p.getName()); Chat.sendMessage(p, "Success! " + StringUtils.capitalize(type) + " sign with ID " + id + " created."); KitSign.createKitSign((Sign)Lists.creatingSignState.get(p.getName()), id, KitSign.KitSignType.valueOf(type.toUpperCase())); Lists.creatingSign.remove(p.getName()); Lists.creatingSignData.remove(p.getName()); Lists.creatingSignState.remove(p.getName()); } catch (Exception ex) { Chat.sendMessage(p, "Error: " + Chat.white + "\"" + Chat.gold + msg + Chat.white + "\"" + Chat.gold + " is not a number."); } } e.setCancelled(true); } } @EventHandler public void onInteract(PlayerInteractEvent e) { Player p = e.getPlayer(); if (((e.getAction() == Action.RIGHT_CLICK_AIR) || (e.getAction() == Action.RIGHT_CLICK_BLOCK)) && (e.getItem() != null) && (e.getItem().getType() == Material.ENDER_PEARL)) { if (!Lists.enderpearlCooldown.containsKey(p.getName())) { Lists.enderpearlCooldown.put(p.getName(), Long.valueOf(System.currentTimeMillis())); } else { long timeSincePearl = 15L - (System.currentTimeMillis() - ((Long)Lists.enderpearlCooldown.get(p.getName())).longValue()) / 1000L; if (timeSincePearl > 0L) { Chat.sendMessage(p, "You cannot use an enderpearl for " + Chat.gold + timeSincePearl + Chat.white + (timeSincePearl != 1L ? " seconds." : " second.")); e.setCancelled(true); p.updateInventory(); } else { Lists.enderpearlCooldown.put(p.getName(), Long.valueOf(System.currentTimeMillis())); } } } if (e.getAction() == Action.LEFT_CLICK_BLOCK) { ItemStack wand = new ItemStack(Material.GOLD_AXE, 1); ItemMeta wandMeta = wand.getItemMeta(); wandMeta.setDisplayName(ChatColor.BLUE + "Spawn selector"); wand.setItemMeta(wandMeta); if ((p.getItemInHand() != null) && (p.getItemInHand().equals(wand))) { if (!Lists.creatingArena.containsKey(p.getName())) { Chat.sendMessage(p, "First location set. Now left click the second spawn point."); Lists.creatingArena.put(p.getName(), e.getClickedBlock().getLocation().add(0.0D, 2.0D, 0.0D)); } else { Chat.sendMessage(p, "Arena " + Chat.white + (String)Lists.creatingArenaData.get(p.getName()) + Chat.gold + " created."); Location firstLoc = (Location)Lists.creatingArena.get(p.getName()); Location secondLoc = e.getClickedBlock().getLocation().add(0.0D, 2.0D, 0.0D); String firstLocKey = firstLoc.getBlockX() + "," + firstLoc.getBlockY() + "," + firstLoc.getBlockZ(); String secondLocKey = secondLoc.getBlockX() + "," + secondLoc.getBlockY() + "," + secondLoc.getBlockZ(); Core.getArenaConfiguration().set((String)Lists.creatingArenaData.get(p.getName()) + ".first", firstLocKey); Core.getArenaConfiguration().set((String)Lists.creatingArenaData.get(p.getName()) + ".second", secondLocKey); Core.getArenaConfiguration().set((String)Lists.creatingArenaData.get(p.getName()) + ".world", p.getWorld().getName()); Core.arenaData.saveConfig(); Lists.creatingArena.remove(p.getName()); Lists.creatingArenaData.remove(p.getName()); p.getInventory().remove(wand); } e.setCancelled(true); } if ((e.getClickedBlock() != null) && (e.getClickedBlock().getType() == Material.CHEST) && (Lists.creatingChest.containsKey(p.getName()))) { if (Lists.creatingChest.get(p.getName()) == null) { Chat.sendMessage(p, "Chest 1 selected. Now left click the chest to copy items from."); Lists.creatingChest.put(p.getName(), (Chest)e.getClickedBlock().getState()); } else { InfiniteChest infiniteChest = new InfiniteChest((Chest)Lists.creatingChest.get(p.getName())); infiniteChest.createChest((Chest)e.getClickedBlock().getState()); Chat.sendMessage(p, "Success! Chest created."); Lists.creatingChest.remove(p.getName()); } e.setCancelled(true); } } if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { if ((e.getClickedBlock() != null) && (e.getClickedBlock().getType() == Material.CHEST)) { InfiniteChest infiniteChest = new InfiniteChest((Chest)e.getClickedBlock().getState()); if (infiniteChest.exists()) { e.setCancelled(true); Inventory inventory = Bukkit.createInventory(null, 27, infiniteChest.getMaster().getInventory().getTitle()); inventory.setContents(infiniteChest.getMaster().getInventory().getContents()); p.openInventory(inventory); p.playSound(p.getLocation(), Sound.CHEST_OPEN, 1.0F, 1.0F); } } if ((e.getClickedBlock() != null) && ((e.getClickedBlock().getType() == Material.WALL_SIGN) || (e.getClickedBlock().getType() == Material.SIGN_POST))) { Sign sign = (Sign)e.getClickedBlock().getState(); KitSign kitSign = KitSign.getSign(sign); if (kitSign.exists()) { int id = kitSign.getSignId(); if (kitSign.getKitSignType() == KitSign.KitSignType.LOAD) { Kit.loadInventory(p, kitSign.getSignId()); } else { Kit.saveInventory(p, kitSign.getSignId()); } } } } } } DuelMatch.java CLASS below Code: package me.HTM; import java.util.AbstractMap; import java.util.List; import java.util.Random; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector; public class DuelMatch { public static Random random = new Random(); public static void hidePlayers(final Player player1, final Player player2) { for(Player all : Bukkit.getOnlinePlayers()) { all.hidePlayer(player1); all.hidePlayer(player2); player1.hidePlayer(all); player2.hidePlayer(all); } new BukkitRunnable() { @Override public void run() { player1.showPlayer(player2); player2.showPlayer(player1); } }.runTaskLater(Core.getPlugin(), 20); } public static void showPlayers(Player player1, Player player2) { for(Player all : Bukkit.getOnlinePlayers()) { player1.showPlayer(all); player2.showPlayer(all); all.showPlayer(player1); all.showPlayer(player2); } } public static void removeFromDuel(Player p) { for(int i = 0 ; i < Lists.inDuel.size() ; i++) { if(Lists.inDuel.get(i).getKey().equals(p.getName()) || Lists.inDuel.get(i).getValue().equals(p.getName())) { Lists.inDuel.remove(i); } } } public static boolean isInDuel(Player p) { for(AbstractMap.SimpleEntry<String, String> entry : Lists.inDuel) { if(entry.getValue().equals(p.getName()) || entry.getKey().equals(p.getName())) { return true; } } return false; } public static Player getPartner(Player p) { for(AbstractMap.SimpleEntry<String, String> entry : Lists.inDuel) { if(entry.getKey().equals(p.getName())) { return Bukkit.getPlayer(entry.getValue()); } else if(entry.getValue().equals(p.getName())) { return Bukkit.getPlayer(entry.getKey()); } } return null; } public static void doDuel(Player player1, Player player2) { boolean randBoolean = random.nextBoolean(); List<Location> arenas = Arena.getRandomArena(); if(randBoolean) { player1.teleport(arenas.get(0)); player2.teleport(arenas.get(1)); } else { player1.teleport(arenas.get(1)); player2.teleport(arenas.get(0)); } Bukkit.dispatchCommand(player1, "pvpkit duel"); Bukkit.dispatchCommand(player2, "pvpkit duel"); Lists.inDuel.add(new AbstractMap.SimpleEntry<String, String>(player1.getName(), player2.getName())); hidePlayers(player1, player2); lookAtPlayer(player1, player2); lookAtPlayer(player2, player1); } public static void lookAtPlayer(Player source, Player target) { Vector direction = getVector(target).subtract(getVector(source)).normalize(); double x = direction.getX(); double y = direction.getY(); double z = direction.getZ(); Location changed = target.getLocation().clone(); changed.setYaw(180 - toDegree(Math.atan2(x, z))); changed.setPitch(90 - toDegree(Math.acos(y))); target.teleport(changed); } private static float toDegree(double angle) { return (float) Math.toDegrees(angle); } private static Vector getVector(Player player) { return player.getEyeLocation().toVector(); } } Duel.java CLASS below Code: package me.HTM; import java.util.AbstractMap; import java.util.AbstractMap.SimpleEntry; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import org.bukkit.entity.Player; @SuppressWarnings("unused") public class Duel { private Player p; private List<AbstractMap.SimpleEntry<String, Long>> challengers; @SuppressWarnings({ "unchecked", "rawtypes" }) private static HashMap<String, Duel> challenged = new HashMap(); @SuppressWarnings({ "unchecked", "rawtypes" }) public Duel(Player p) { this.p = p; this.challengers = new ArrayList(); challenged.put(p.getName(), this); } @SuppressWarnings("unchecked") public static List<String> getPlayersInDuel() { @SuppressWarnings("rawtypes") List<String> inDuel = new ArrayList(); for (AbstractMap.SimpleEntry<String, String> entry : Lists.inDuel) { inDuel.add((String)entry.getKey()); inDuel.add((String)entry.getValue()); } return inDuel; } @SuppressWarnings({ "unchecked", "rawtypes" }) public void addChallenger(Player challenger) { this.challengers.add(new AbstractMap.SimpleEntry(challenger.getName(), Long.valueOf(System.currentTimeMillis()))); } @SuppressWarnings("rawtypes") public void removeChallenger(Player challenger) { for (int i = 0; i < this.challengers.size(); i++) { if (((String)((AbstractMap.SimpleEntry)this.challengers.get(i)).getKey()).equals(challenger.getName())) { this.challengers.remove(i); } } } public boolean challengeExpired(Player challenger) { for (AbstractMap.SimpleEntry<String, Long> entry : this.challengers) { if ((((String)entry.getKey()).equals(challenger.getName())) && ((System.currentTimeMillis() - ((Long)entry.getValue()).longValue()) / 1000L >= 30L)) { return true; } } return false; } @SuppressWarnings("unchecked") public List<String> getChallengers() { @SuppressWarnings("rawtypes") List<String> toReturn = new ArrayList(); for (AbstractMap.SimpleEntry<String, Long> entry : this.challengers) { toReturn.add((String)entry.getKey()); } return toReturn; } public void removeDuel() { this.challengers.clear(); challenged.remove(this.p.getName()); } public static boolean hasDuel(Player p) { return challenged.containsKey(p.getName()); } public static Duel getDuel(Player p) { return (Duel)challenged.get(p.getName()); } } If anyone could give me a fix for this since I don't want to make a whole new one, would appreciate it. Also (VERY TIRED) and I focus on a lot of coursework at school so I'm having a hard time with this and it just adds to my stress. Please do not reply if your going to have comments that are not of use.