You have two "public class PlayerKilling {".
Remove the top public class PlayerKilling {
|
Basically I've been searching all over to find a good playerkilling system that if you kiill someone it gives you pk points. However my server isn't recognising o.lastKilled because it has never been added. I've added a code to my playerkilling.java and client.java and for some reason I receive this annoying error... The code made by Core
This is the code for playerkilling.java
This is the error I receive.Code:package server.model.players; public class PlayerKilling { private Client c; /** * Constructor class */ public PlayerKilling(Client Client) { this.c = Client; } /** * @author Core * Handles adding and removing hosts to the players array list. */ public class PlayerKilling { /** * Adds the host of the killed player. *@param client Player that saves the host. *@param host Host address of the killed player. *@return True if the host is added to the players array. */ public static boolean addHostToList(Client client, String host) { if(client != null) { return client.lastKilledPlayers.add(host); } return false; } /** * Checks if the host is already on the players array. * @param client Player that is adding the killed players host. * @param host Host address of the killed player. * @return True if the host is on the players array. */ public static boolean hostOnList(Client client, String host) { if(client != null) { if(client.lastKilledPlayers.lastIndexOf(host) >= KILL_WAIT_MAX) { removeHostFromList(client, host); return false; } return client.lastKilledPlayers.contains(host); } return false; } /** * Removes the host from the players array. * @param client Player that is removing the host. * @param host Host that is being removed. * @return True if host is successfully removed. */ public static boolean removeHostFromList(Client client, String host) { if(client != null) { return client.lastKilledPlayers.remove(host); } return false; } /* * Amount of kills you have to wait before the host is deleted. */ public static final int KILL_WAIT_MAX = 3; } /** * How many people you have to kill before getting points again * for killing the same person. */ public final int NEEDED_KILLS = 10; /** * First the method checks if the array list contains the person * and if it doesn't then add there name but if it does then * return the method false. */ public boolean addPlayer(String i) { if(!c.killedPlayers.contains(i)) { c.killedPlayers.add(i); return true; } return false; } /** * Checking if the array list contains the player and if * the person has killed 20 or more people since that person. */ public void checkForPlayer(String i) { if(c.killedPlayers.contains(i) && c.killedPlayers.indexOf(i) >= NEEDED_KILLS) { c.killedPlayers.remove(i); } } }
I don't quite get what it means by static declaration error...Code:src\server\model\players\PlayerKilling.java:19: server.model.players.PlayerKilli ng is already defined in server.model.players public class PlayerKilling { ^ src\server\model\players\PlayerKilling.java:28: inner classes cannot have static declarations public static boolean addHostToList(Client client, String host) { ^ src\server\model\players\PlayerKilling.java:42: inner classes cannot have static declarations public static boolean hostOnList(Client client, String host) { ^ src\server\model\players\PlayerKilling.java:60: inner classes cannot have static declarations public static boolean removeHostFromList(Client client, String host) { ^ 4 errors Press any key to continue . . .
Can someone please help me?
Uhm If I do that it gives me 10 errors?
Bumped..Code:src\server\model\players\PlayerKilling.java:4: class, interface, or enum expecte d private Client c; ^ src\server\model\players\PlayerKilling.java:10: class, interface, or enum expect ed public PlayerKilling(Client Client) { ^ src\server\model\players\PlayerKilling.java:12: class, interface, or enum expect ed } ^ src\server\model\players\PlayerKilling.java:79: class, interface, or enum expect ed public final int NEEDED_KILLS = 10; ^ src\server\model\players\PlayerKilling.java:87: class, interface, or enum expect ed public boolean addPlayer(String i) { ^ src\server\model\players\PlayerKilling.java:90: class, interface, or enum expect ed return true; ^ src\server\model\players\PlayerKilling.java:91: class, interface, or enum expect ed } ^ src\server\model\players\PlayerKilling.java:93: class, interface, or enum expect ed } ^ src\server\model\players\PlayerKilling.java:100: class, interface, or enum expec ted public void checkForPlayer(String i) { ^ src\server\model\players\PlayerKilling.java:103: class, interface, or enum expec ted } ^ 10 errors Press any key to continue . . .
Last edited by Austin_; 02-25-2012 at 04:55 PM.
Code:package server.model.players; /** * @author Core * Handles adding and removing hosts to the players array list. */ public class PlayerKilling { private Client c; /** * Constructor class */ public PlayerKilling(Client Client) { this.c = Client; } /** * Adds the host of the killed player. *@param client Player that saves the host. *@param host Host address of the killed player. *@return True if the host is added to the players array. */ public static boolean addHostToList(Client client, String host) { if(client != null) { return client.lastKilledPlayers.add(host); } return false; } /** * Checks if the host is already on the players array. * @param client Player that is adding the killed players host. * @param host Host address of the killed player. * @return True if the host is on the players array. */ public static boolean hostOnList(Client client, String host) { if(client != null) { if(client.lastKilledPlayers.lastIndexOf(host) >= KILL_WAIT_MAX) { removeHostFromList(client, host); return false; } return client.lastKilledPlayers.contains(host); } return false; } /** * Removes the host from the players array. * @param client Player that is removing the host. * @param host Host that is being removed. * @return True if host is successfully removed. */ public static boolean removeHostFromList(Client client, String host) { if(client != null) { return client.lastKilledPlayers.remove(host); } return false; } /* * Amount of kills you have to wait before the host is deleted. */ public static final int KILL_WAIT_MAX = 3; /** * How many people you have to kill before getting points again * for killing the same person. */ public final int NEEDED_KILLS = 10; /** * First the method checks if the array list contains the person * and if it doesn't then add there name but if it does then * return the method false. */ public boolean addPlayer(String i) { if(!c.killedPlayers.contains(i)) { c.killedPlayers.add(i); return true; } return false; } /** * Checking if the array list contains the player and if * the person has killed 20 or more people since that person. */ public void checkForPlayer(String i) { if(c.killedPlayers.contains(i) && c.killedPlayers.indexOf(i) >= NEEDED_KILLS) { c.killedPlayers.remove(i); } } }
Should I add that code in?
Replace yours with that
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |