我正在研究一个在聊天服务器内部运行的琐事机器人,我从javac得到错误,“不能用符号KailleraServerImpl服务器”。我已经阅读了所有其他帖子同样的问题,并尝试了一切,但我仍然无法摆脱这个错误。任何人都可以帮助我吗?
package org.emulinker.kaillera.model.impl;
import java.util.*;
import java.io.*;
public class Trivia implements Runnable
{
private boolean exitThread;
private boolean triviaPaused;
private KailleraServerImpl server;
private boolean newQuestion;
private String answer;
private char[] hint;
private boolean hint1;
private boolean hint2;
private boolean answered;
private int questions_count;
private String ip_streak;
private int score_streak;
private int questionTime;
private int index;
private String unscrambledword;
private int temp;
private Scanner scan;
private int s;
ArrayList<Questions> questions;
ArrayList<Integer> questions_num;
ArrayList<Scores> scores;
ArrayList<String> unscramblewords;
public boolean isAnswered() {
return this.answered;
}
public void setQuestionTime(final int questionTime) {
this.questionTime = questionTime;
}
public List<Scores> getScores() {
return this.scores;
}
public void setTriviaPaused(final boolean triviaPaused) {
this.triviaPaused = triviaPaused;
}
public Trivia(final KailleraServerImpl server) {
super();
this.exitThread = false;
this.triviaPaused = false;
this.newQuestion = true;
this.hint1 = false;
this.hint2 = false;
this.answered = false;
this.questions_count = 0;
this.ip_streak = "";
this.score_streak = 0;
this.questionTime = 10;
this.questions = new ArrayList<Questions>();
this.questions_num = new ArrayList<Integer>();
this.scores = new ArrayList<Scores>();
this.unscramblewords = new ArrayList<String>();
this.server = server;
try {
server.announce("<Unscramble> Loading GalaxyScramble Words...", false, null);
final Scanner scanner = new Scanner(new File("wordlist.txt"));
while (scanner.hasNext()) {
final String[] split = scanner.nextLine().split(" ");
for (int i = 0; i < split.length; ++i) {
this.unscramblewords.add(split[i]);
}
++this.index;
if (scanner == null) {
scanner.close();
}
}
}
catch (Exception ex) {
server.announce("<Unscramble> Error loading words!", false, null);
this.exitThread = false;
}
while (!this.exitThread) {
final Random random = new Random();
for (int j = 0; j < this.unscramblewords.size(); ++j) {
final String s = this.unscramblewords.get(j);
final char[] charArray = s.toCharArray();
for (int k = 0; k < s.length(); ++k) {
final int nextInt = random.nextInt(s.length());
final int nextInt2 = random.nextInt(s.length());
final char c = charArray[nextInt2];
charArray[nextInt2] = charArray[nextInt];
charArray[nextInt] = c;
}
this.questions.add(new Questions(new String(charArray), this.unscramblewords.get(j).toString()));
this.questions_num.add(j);
}
server.announce("<Unscramble> " + this.questions.size() + " words have been loaded!", false, null);
server.announce("<Unscramble> GalaxyUnscramble will begin in 10s!", false, null);
}
}
public void run() {
int n = 0;
final Random random = new Random();
this.temp = random.nextInt(this.questions.size() - 1);
this.questions_count = this.questions_num.get(this.temp);
this.questions_num.remove(this.temp);
try {
Thread.sleep(10000L);
}
catch (Exception ex) {}
while (!this.exitThread) {
if (!this.triviaPaused) {
if (this.newQuestion) {
if (++n % 15 == 0) {
this.saveScores(false);
this.displayHighScores(false);
}
this.newQuestion = false;
this.hint1 = true;
this.hint2 = false;
this.server.announce("<Unscramble> Unscramble this word: " + this.questions.get(this.questions_count).getQuestion(), false, null);
if (!this.answered) {
try {
Thread.sleep(10000L);
}
catch (Exception ex2) {}
}
if (!this.answered) {
this.server.announce("<Unscramble> 35 seconds left...", false, null);
try {
Thread.sleep(5000L);
}
catch (Exception ex3) {}
}
}
if (this.hint1 && !this.answered) {
this.newQuestion = false;
this.hint1 = false;
this.hint2 = true;
this.answer = this.questions.get(this.questions_count).getAnswer().toLowerCase();
this.answer = this.answer.replace(" ", " ");
this.hint = this.answer.toCharArray();
for (int i = 0; i < this.hint.length; ++i) {
if ((i + 1) % 2 == 0 && this.hint[i] != ' ') {
this.hint[i] = '_';
}
}
this.answer = String.valueOf(this.hint);
this.answer = this.answer.replace("_", " _ ");
this.server.announce("<Unscramble> Hint 1: " + this.answer, false, null);
if (!this.answered) {
try {
Thread.sleep(10000L);
}
catch (Exception ex4) {}
}
if (!this.answered) {
this.server.announce("<Unscramble> 20 seconds left...", false, null);
try {
Thread.sleep(5000L);
}
catch (Exception ex5) {}
}
}
if (this.hint2 && !this.answered) {
this.newQuestion = false;
this.hint1 = false;
this.hint2 = false;
this.answer = this.questions.get(this.questions_count).getAnswer().toLowerCase();
this.answer = this.answer.replace(" ", " ");
this.hint = this.answer.toCharArray();
for (int j = 0; j < this.hint.length; ++j) {
if ((j + 1) % 4 == 0 && this.hint[j] != ' ') {
this.hint[j] = '_';
}
}
this.answer = String.valueOf(this.hint);
this.answer = this.answer.replace("_", " _ ");
this.server.announce("<Unscramble> Hint 2: " + this.answer, false, null);
if (!this.answered) {
try {
Thread.sleep(10000L);
}
catch (Exception ex6) {}
}
if (!this.answered) {
this.server.announce("<Unscramble> 5 seconds left...", false, null);
try {
Thread.sleep(5000L);
}
catch (Exception ex7) {}
}
}
if (!this.answered) {
final Questions questions = this.questions.get(this.questions_count);
this.server.announce("<Unscramble> Time's up! The answer is: " + this.questions.get(this.questions_count).getAnswer(), false, null);
}
if (this.questions.size() == 1) {
this.questions_count = this.questions_num.get(0);
this.questions_num.clear();
n = 0;
this.server.announce("<Unscramble> ***All questions have been exhaused! Restarting list...***", false, null);
for (int k = 0; k < this.questions.size(); ++k) {
this.questions_num.add(k);
}
}
else {
this.temp = random.nextInt(this.questions.size() - 1);
this.questions_count = this.questions_num.get(this.temp);
this.questions_num.remove(this.temp);
}
try {
Thread.sleep(5000L);
}
catch (Exception ex8) {}
try {
Thread.sleep(this.questionTime);
}
catch (Exception ex9) {}
this.newQuestion = true;
this.hint1 = false;
this.hint2 = false;
this.answered = false;
}
else {
try {
Thread.sleep(1000L);
}
catch (Exception ex10) {}
}
}
}
public boolean isCorrect(String s) {
final String[] array = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
final String[] array2 = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
final String[] array3 = { "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "nineth", "tenth" };
final String[] array4 = { "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th" };
final Questions questions = this.questions.get(this.questions_count);
if (s.toLowerCase().equals(questions.getAnswer().toLowerCase())) {
return this.answered = true;
}
for (int i = 0; i < array.length; ++i) {
if (questions.getAnswer().toLowerCase().contains(array[i])) {
s = s.replace(array2[i], array[i]);
}
else if (questions.getAnswer().toLowerCase().contains(array2[i])) {
s = s.replace(array[i], array2[i]);
}
}
if (s.toLowerCase().equals(questions.getAnswer().toLowerCase())) {
return this.answered = true;
}
for (int j = 0; j < array3.length; ++j) {
if (questions.getAnswer().toLowerCase().contains(array3[j])) {
s = s.replace(array4[j], array3[j]);
}
else if (questions.getAnswer().toLowerCase().contains(array4[j])) {
s = s.replace(array3[j], array4[j]);
}
}
return s.toLowerCase().equals(questions.getAnswer().toLowerCase()) && (this.answered = true);
}
public boolean updateIP(final String s, final String ip) {
for (int i = 0; i < this.scores.size(); ++i) {
final Scores scores = this.scores.get(i);
if (scores.getIP().equals(s)) {
scores.setIP(ip);
return true;
}
}
return false;
}
public void addScore(final String s, final String s2, final String s3) {
this.answered = true;
for (int i = 0; i < this.scores.size(); ++i) {
final Scores scores = this.scores.get(i);
if (scores.getIP().equals(s2)) {
if (this.ip_streak.equals(s2)) {
++this.score_streak;
if (this.score_streak > 1) {
try {
Thread.sleep(20L);
}
catch (Exception ex) {}
this.server.announce("<Unscramble> ***" + s + " has answered " + this.score_streak + " in a row!***", false, null);
scores.setNick(s);
this.s = scores.getScore();
scores.setScore(this.s += this.score_streak);
}
else {
this.score_streak = 1;
this.ip_streak = s2;
}
try {
Thread.sleep(20L);
}
catch (Exception ex2) {}
}
else {
scores.setNick(s);
this.s = scores.getScore();
scores.setScore(++this.s);
}
final Questions questions = this.questions.get(this.questions_count);
this.server.announce("<Unscramble> Congratulations " + s + "! You have answered the question correctly with (" + s3 + ")! Your score is: " + this.s, false, null);
return;
}
}
this.scores.add(new Scores(s, s2, 1));
this.score_streak = 1;
this.ip_streak = s2;
this.server.announce("<Unscramble> Congratulations " + s + "! You have answered the question correctly with (" + s3 + ")! Your score is: 1", false, null);
}
public void displayHighScores(final boolean b) {
String nick = "";
String nick2 = "";
String nick3 = "";
int score = 0;
int score2 = 0;
int score3 = 0;
for (int i = 0; i < this.scores.size(); ++i) {
final Scores scores = this.scores.get(i);
if (scores.getScore() > score) {
final String s = nick;
final int n = score;
score = scores.getScore();
nick = scores.getNick();
score2 = n;
nick2 = s;
}
else if (scores.getScore() > score2) {
final String s2 = nick2;
final int n2 = score2;
score2 = scores.getScore();
nick2 = scores.getNick();
score3 = n2;
nick3 = s2;
}
else if (scores.getScore() > score3) {
score3 = scores.getScore();
nick3 = scores.getNick();
}
}
String s3;
if (!b) {
s3 = nick + " = " + score + ", " + nick2 + " = " + score2 + ", " + nick3 + " = " + score3;
}
else {
s3 = "The Winner is: " + nick + " with " + score + " points!";
}
this.server.announce("<Unscramble> (Top 3 Scores of " + this.scores.size() + ") " + s3, false, null);
}
public void saveScores(final boolean b) {
try {
final BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("scores_scrambler.txt", false));
for (int i = 0; i < this.scores.size(); ++i) {
final Scores scores = this.scores.get(i);
bufferedWriter.write("ip:" + scores.getIP());
bufferedWriter.newLine();
bufferedWriter.write("s:" + scores.getScore());
bufferedWriter.newLine();
bufferedWriter.write("n:" + scores.getNick());
bufferedWriter.newLine();
bufferedWriter.newLine();
}
bufferedWriter.close();
if (b) {
this.server.announce("<Unscramble> GalaxyUnscramble Scores were Saved Successfully!", false, null);
}
}
catch (Exception ex) {
this.server.announce("<Unscramble> Error Saving GalaxyUnscramble Scores!", false, null);
}
}
private class Scores
{
private String ip;
private int score;
private String nick;
public Scores(final String nick, final String ip, final int score) {
super();
this.nick = nick;
this.ip = ip;
this.score = score;
}
public void setScore(final int score) {
this.score = score;
}
public void setIP(final String ip) {
this.ip = ip;
}
public void setNick(final String nick) {
this.nick = nick;
}
public int getScore() {
return this.score;
}
public String getIP() {
return this.ip;
}
public String getNick() {
return this.nick;
}
}
private class Questions
{
String question;
String answer;
public Questions(final String question, final String answer) {
super();
this.question = question;
this.answer = answer;
}
public void setQuestion(final String question) {
this.question = question;
}
public void setAnswer(final String answer) {
this.answer = answer;
}
public String getQuestion() {
return this.question;
}
public String getAnswer() {
return this.answer;
}
}
}