here you go fixed and looks much better
Code:
package server.model.minigames;
import server.event.Event;
import server.event.EventContainer;
import server.event.EventManager;
import server.model.players.Player;
import server.model.players.PlayerHandler;
import server.util.Misc;
import server.model.players.Client;
public class TriviaBot {
public static void startup() {
EventManager.getSingleton().addEvent(new Event() {
@Override
public void execute(EventContainer e) {
if (getPlayerCount() > 0) {
askQuestion();
}
}
}, 900000);
}
public static void attemptAnswer(Player p, String attempt) {
if (!currentQuestion.equals("") && attempt.replaceAll("_", " ").equalsIgnoreCase(currentAnswer)) {
currentQuestion = "";
p.pkPoints++;
sendServerMessage("<shad=255>Well done! " + p.playerName
+ " has quessed the question correctly and earned 1 Trivia Point!");
}
}
public static boolean acceptingQuestion() {
return !currentQuestion.equals("");
}
public static void askQuestion() {
final int random = Misc.random(TRIVIA_DATA.length - 1);
currentQuestion = TRIVIA_DATA[random][0];
currentAnswer = TRIVIA_DATA[random][1];
sendServerMessage(currentQuestion);
}
private static int getPlayerCount() {
int players = 0;
for (Player p : PlayerHandler.players) {
if (p != null)
players++;
}
return players;
}
private static void sendServerMessage(String message) {
for (Player p : PlayerHandler.players) {
if (p != null) {
((Client) p).sendMessage(message);
}
}
}
private static final String[][] TRIVIA_DATA = {
{"<shad=255>[Trivia] What is the highest combat level in the game?", "126"},
{"<shad=255>[Trivia] What is the highest leveled NPC in the game?", "Corporal Beast"},
{"<shad=255>[Trivia] Who created the server originally?", "InsidiaX"},
{"<shad=255>[Trivia] Which NPC sells magic gear", "Zaff"},
{"<shad=255>[Trivia] What is the highest rank in the game?", "Owner"},
};
private static String currentQuestion;
private static String currentAnswer;
}
Originally Posted by
Jrage
New errors, Im stuck and so tired, gonna post them, head to bed, wake up, try to fix, if I cant I'll look here. lol
Code:
src\server\model\players\packets\Commands.java:14: error: cannot find symbol
import server.model.players.TriviaBot;
^
symbol: class TriviaBot
location: package server.model.players
src\server\Server.java:20: error: cannot find symbol
import server.model.players.TriviaBot;
^
symbol: class TriviaBot
location: package server.model.players
src\server\model\players\packets\Commands.java:143: error: cannot find symbol
if(TriviaBot.acceptingQuestion()){
^
symbol: variable TriviaBot
location: class Commands
src\server\model\players\packets\Commands.java:144: error: cannot find symbol
TriviaBot.attemptAnswer(c, triviaAnswer);
^
symbol: variable TriviaBot
location: class Commands
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors
Press any key to continue . . .
the import you need is:
Code:
import server.model.minigames.TriviaBot;
just replace it