Originally Posted by
Pietz
Read what I just said in my last reply... I don't know where to add it
Code:
import java.util.ArrayList;
import java.util.List;
import server.event.Event;
import server.event.EventContainer;
import server.event.EventManager;
/**
* Player VS Player Point gaining
* @author <RogueX>
*
*/
public class PlayerKilling {
/**
* Time in minutes to wait before you may gain another PK Point from the same Client
*/
private static final short TIME_TOWAIT = 10;
/**
* Holds our Client and Attacker objects
*/
private static List<PlayerKill> playerKills = new ArrayList<PlayerKill>();
/**
* Runs multiple checks to see if the Attacker is valid for a Player Vs Player Point
* @param c Client who died
* @param a Client the attacker
*/
public static void addKill(Client c, Client a) {
for (PlayerKill pk : playerKills) {
if (pk.playerName.equalsIgnoreCase(c.playerName)
&& pk.attackerName.equalsIgnoreCase(a.playerName)
|| pk.ipAddress.equalsIgnoreCase(c.connectedFrom)
&& pk.attackerIP.equalsIgnoreCase(a.connectedFrom)) {
a.sendMessage("PK Point not given. You may not kill the same person within " + TIME_TOWAIT + " minutes.");
return;
}
}
final PlayerKill tempPK = new PlayerKill(c.playerName, c.connectedFrom, a.playerName, a.connectedFrom);
playerKills.add(tempPK);
a.pkPoints += 1;
a.sendMessage("You have gained 1 PK Point. You now have " + a.pkPoints + " PK Points.");
EventManager.getSingleton().addEvent(new Event() {
public void execute(EventContainer ec) {
playerKills.remove(tempPK);
ec.stop();
}
}, TIME_TOWAIT * 1000);
return;
}
}
/**
* Object to hold the client and attackers information
*/
class PlayerKill {
String playerName;
String ipAddress;
String attackerName;
String attackerIP;
public PlayerKill(String a, String b, String c, String d) {
this.playerName = a;
this.ipAddress = b;
this.attackerName = c;
this.attackerIP = d;
}
}
Code:
PlayerKilling.addKill(c, o);
Where would I put both of these? And btw thank you for getting that for me but I just don't know where to put this