import twcore.core.BotAction;
import twcore.core.EventRequester;
import twcore.core.SubspaceBot;
import twcore.core.events.PlayerEntered;
import twcore.core.EventRequester;
import twcore.core.util.Tools;
/*
- Author: LiLFrogDawg
*/
public class MyBot extends SubspaceBot {
public MyBot(BotAction botAction) {
super(botAction); EventRequester events = botAction.getEventRequester();
events.request(EventRequester.PLAYER_ENTERED); }
public void handleEvent(PlayerEntered event) { String name = event.getPlayerName(); m_botAction.sendPrivateMessage(name, "Welcome to your arena!");
}
}
private static final String TARGET_PLAYER = "Jessup";
private static final String PUBLIC_ARENA = "Public";
private static final String DESIRED_ARENA = "GoBacktoPub";
public WhereDoYouThinkYoureGoingBot(BotAction botAction) {
super(botAction);
EventRequester events = botAction.getEventRequester();
events.request(EventRequester.PLAYER_ENTERED);
}
public void handleEvent(PlayerEntered event) {
String playerName = event.getPlayerName();
String arenaName = event.getArenaName();
if (playerName.equalsIgnoreCase(TARGET_PLAYER) && !arenaName.equalsIgnoreCase(PUBLIC_ARENA)) {
// Player entered an arena other than the Public arena
m_botAction.sendPrivateMessage(playerName, "Nice try! Pub it is");
Tools.scheduleTask(new SpamTask(playerName), 5 * Tools.TimeInMillis.SECOND, 5 * Tools.TimeInMillis.SECOND);
}
}
private class SpamTask implements Runnable {
private String playerName;
public SpamTask(String playerName) {
this.playerName = playerName;
}
public void run() {
String currentArena = m_botAction.getArenaName(playerName);
if (!currentArena.equalsIgnoreCase(PUBLIC_ARENA)) {
m_botAction.sendPrivateMessage(playerName, "Nice try! Pub it is");
} else {
// Player has returned to the Public arena,
Tools.cancelTask(this);
}

Leave a comment: