Hi all, I've been coding a 1v1 system, but I'm stuck on one part. I'm trying to figure out how to get which player is fighting which. Here is my code. Code:java package me.Etched.Main; import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.Location;import org.bukkit.Material;import org.bukkit.World;import org.bukkit.entity.Entity;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.PlayerInteractEntityEvent;import org.bukkit.event.player.PlayerMoveEvent; public class Request implements Listener{ public static Map<Player, Player> request = new HashMap<Player, Player>();public static List<List<Player>> fighting = new ArrayList<List<Player>>();public static List<Player> pregame = new ArrayList<Player>(); public Main plugin;public Request(Main ins){this.plugin = ins;} World w = Bukkit.getWorld(plugin.getConfig().getString("arena1.world"));int x = Integer.parseInt(plugin.getConfig().getString("arena1.x"));int y = Integer.parseInt(plugin.getConfig().getString("arena1.y"));int z = Integer.parseInt(plugin.getConfig().getString("arena1.z"));float yaw = Float.parseFloat(plugin.getConfig().getString("arena1.yaw"));float pitch = Float.parseFloat(plugin.getConfig().getString("arena1.pitch"));Location arena1 = new Location(w, x, y, z, yaw, pitch); World w1 = Bukkit.getWorld(plugin.getConfig().getString("arena2.world"));int x1 = Integer.parseInt(plugin.getConfig().getString("arena2.x"));int y1 = Integer.parseInt(plugin.getConfig().getString("arena2.y"));int z1 = Integer.parseInt(plugin.getConfig().getString("arena2.z"));float yaw1 = Float.parseFloat(plugin.getConfig().getString("arena2.yaw"));float pitch1 = Float.parseFloat(plugin.getConfig().getString("arena2.pitch"));Location arena2 = new Location(w1, x1, y1, z1, yaw1, pitch1); @EventHandlerpublic void onAccept(PlayerInteractEntityEvent e){final Player p = e.getPlayer();final Player victim = (Player) e.getRightClicked();if(p.getItemInHand().getType() == Material.SIGN && p.getItemInHand().getItemMeta().getDisplayName().contains("Request 1v1")){if(victim instanceof Player){if(request.containsKey(p.getName())){p.sendMessage(ChatColor.RED + "Request with " + request.get(p).getName() + " cancelled. Now requesting to 1v1 with " + victim.getName());request.put(p, victim);victim.sendMessage(ChatColor.GOLD + p.getName() + " just send you a request to 1v1. Right click him to accept.");}else{p.sendMessage(ChatColor.GOLD + "Requesting to 1v1 with " + victim.getName());request.put(p, victim);victim.sendMessage(ChatColor.GOLD + p.getName() + " just send you a request to 1v1. Right click him to accept.");}if(request.get(victim).equals(p)){p.sendMessage("Accepted the duel... Teleporting");victim.sendMessage("Your request was accepted... Teleporting");request.remove(p);request.remove(victim);p.teleport(arena1);victim.teleport(arena2);pregame.add(p);pregame.add(victim);for(Player other : Bukkit.getServer().getOnlinePlayers()){if(!other.equals(p)){p.hidePlayer(other);}} Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){public void run(){pregame.remove(p);pregame.remove(victim);ArrayList<Player> players = new ArrayList<Player>();players.add(p);players.add(victim);fighting.add(players);}}, 20*5);}}}} @EventHandlerpublic void onMove(PlayerMoveEvent e){Player p = e.getPlayer();if(pregame.contains(p)){e.setCancelled(true);}} @EventHandlerpublic void onDeath(PlayerDeathEvent e){Player p = e.getEntity();for(List<Player> fight : fighting){if(fight.contains(p)){p.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "You lost the 1v1!");Player winner =}else{return;}}}} Sorry about the weird unfinished thing in the death event, that's where I'm trying to get the other player. Sorry if the List seems dodgy, its me trying to figure out a way (and I couldn't be bothered to remove it for this )
Etched Why are you parsing every value you are getting from the config, why not save the actual number to the .yml file using Code: <ConfigurationFile>.set(Key, Value(As an Int not a String) );
I don't know jthort Actually don't worry, I figured it out. I'll use a constructor and a custom 1v1 class Thanks EDIT by Moderator: merged posts, please use the edit button instead of double posting.