每次我编译它都说这段代码有 21 个错误?我真的被困在这一点上......我已经尝试了一切。如果有人可以帮助我,那就太好了。
这是代码:
//Normal-Player End
public static void archiveLogs(Player player, String[] cmd) {
try {
if (player.getRights() < 1)
return;
String location = "";
if (player.getRights() >= 5) {
location = "data/logs/admin" + player.getUsername() + ".txt";
} else if (player.getRights() == 4) {
location = "data/logs/mod" + player.getUsername() + ".txt";
}
String afterCMD = "";
for (int i = 1; i < cmd.length; i++)
afterCMD += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
BufferedWriter writer = new BufferedWriter(new FileWriter(location,
true));
writer.write("[" + now("dd MMMMM yyyy 'at' hh:mm:ss z") + "] - ::"
+ cmd[0] + " " + afterCMD);
writer.newLine();
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static String now(String dateFormat) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
return sdf.format(cal.getTime());
}
private Commands() {
}
}
这是我的编译器所说的:
writer.flush();
^
src\com\rs\game\player\content\Commands.java:2502: error: class, interface, or e
num expected
writer.close();
^
src\com\rs\game\player\content\Commands.java:2503: error: class, interface, or e
num expected
} catch (IOException e) {
^
src\com\rs\game\player\content\Commands.java:2505: error: class, interface, or e
num expected
}
^
src\com\rs\game\player\content\Commands.java:2515: error: class, interface, or e
num expected
public static String now(String dateFormat) {
^
src\com\rs\game\player\content\Commands.java:2517: error: class, interface, or e
num expected
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
^
src\com\rs\game\player\content\Commands.java:2518: error: class, interface, or e
num expected
return sdf.format(cal.getTime());
^
src\com\rs\game\player\content\Commands.java:2519: error: class, interface, or e
num expected
}
^
Note: src\com\rs\game\player\Inventory.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
21 errors
compiling Dialogues
src\com\rs\game\player\content\Commands.java:2477: error: illegal start of type
return true;
^
src\com\rs\game\player\content\Commands.java:2477: error: ';' expected
return true;
^
src\com\rs\game\player\content\Commands.java:2483: error: class, interface, or e
num expected
public static void archiveLogs(Player player, String[] cmd) {
^
src\com\rs\game\player\content\Commands.java:2487: error: class, interface, or e
num expected
String location = "";
^
src\com\rs\game\player\content\Commands.java:2488: error: class, interface, or e
num expected
if (player.getRights() >= 5) {
^
src\com\rs\game\player\content\Commands.java:2490: error: class, interface, or e
num expected
} else if (player.getRights() == 4) {
^
src\com\rs\game\player\content\Commands.java:2492: error: class, interface, or e
num expected
}
^
src\com\rs\game\player\content\Commands.java:2494: error: class, interface, or e
num expected
for (int i = 1; i < cmd.length; i++)
^
src\com\rs\game\player\content\Commands.java:2494: error: class, interface, or e
num expected
for (int i = 1; i < cmd.length; i++)
^
src\com\rs\game\player\content\Commands.java:2494: error: class, interface, or e
num expected
for (int i = 1; i < cmd.length; i++)
^
src\com\rs\game\player\content\Commands.java:2496: error: class, interface, or e
num expected
BufferedWriter writer = new BufferedWriter(new FileWrite
r(location,
^
src\com\rs\game\player\content\Commands.java:2498: error: class, interface, or e
num expected
writer.write("[" + now("dd MMMMM yyyy 'at' hh:mm:ss z")
+ "] - ::"
^
src\com\rs\game\player\content\Commands.java:2500: error: class, interface, or e
num expected
writer.newLine();
^
src\com\rs\game\player\content\Commands.java:2501: error: class, interface, or e
num expected
writer.flush();
^
src\com\rs\game\player\content\Commands.java:2502: error: class, interface, or e
num expected
writer.close();
^
src\com\rs\game\player\content\Commands.java:2503: error: class, interface, or e
num expected
} catch (IOException e) {
^
src\com\rs\game\player\content\Commands.java:2505: error: class, interface, or e
num expected
}
^
src\com\rs\game\player\content\Commands.java:2515: error: class, interface, or e
num expected
public static String now(String dateFormat) {
^
src\com\rs\game\player\content\Commands.java:2517: error: class, interface, or e
num expected
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
^
src\com\rs\game\player\content\Commands.java:2518: error: class, interface, or e
num expected
return sdf.format(cal.getTime());
^
src\com\rs\game\player\content\Commands.java:2519: error: class, interface, or e
num expected
}
^
Note: src\com\rs\game\player\Inventory.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
21 errors
compiled Main Server Folder
src\com\rs\game\player\content\Commands.java:2477: error: illegal start of type
return true;
^
src\com\rs\game\player\content\Commands.java:2477: error: ';' expected
return true;
^
src\com\rs\game\player\content\Commands.java:2483: error: class, interface, or e
num expected
public static void archiveLogs(Player player, String[] cmd) {
^
src\com\rs\game\player\content\Commands.java:2487: error: class, interface, or e
num expected
String location = "";
^
src\com\rs\game\player\content\Commands.java:2488: error: class, interface, or e
num expected
if (player.getRights() >= 5) {
^
src\com\rs\game\player\content\Commands.java:2490: error: class, interface, or e
num expected
} else if (player.getRights() == 4) {
^
src\com\rs\game\player\content\Commands.java:2492: error: class, interface, or e
num expected
}
^
src\com\rs\game\player\content\Commands.java:2494: error: class, interface, or e
num expected
for (int i = 1; i < cmd.length; i++)
^
src\com\rs\game\player\content\Commands.java:2494: error: class, interface, or e
num expected
for (int i = 1; i < cmd.length; i++)
^
src\com\rs\game\player\content\Commands.java:2494: error: class, interface, or e
num expected
for (int i = 1; i < cmd.length; i++)
^
src\com\rs\game\player\content\Commands.java:2496: error: class, interface, or e
num expected
BufferedWriter writer = new BufferedWriter(new FileWrite
r(location,
^
src\com\rs\game\player\content\Commands.java:2498: error: class, interface, or e
num expected
writer.write("[" + now("dd MMMMM yyyy 'at' hh:mm:ss z")
+ "] - ::"
^
src\com\rs\game\player\content\Commands.java:2500: error: class, interface, or e
num expected
writer.newLine();
^
src\com\rs\game\player\content\Commands.java:2501: error: class, interface, or e
num expected
writer.flush();
^
src\com\rs\game\player\content\Commands.java:2502: error: class, interface, or e
num expected
writer.close();
^
src\com\rs\game\player\content\Commands.java:2503: error: class, interface, or e
num expected
} catch (IOException e) {
^
src\com\rs\game\player\content\Commands.java:2505: error: class, interface, or e
num expected
}
^
src\com\rs\game\player\content\Commands.java:2515: error: class, interface, or e
num expected
public static String now(String dateFormat) {
^
src\com\rs\game\player\content\Commands.java:2517: error: class, interface, or e
num expected
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
^
src\com\rs\game\player\content\Commands.java:2518: error: class, interface, or e
num expected
return sdf.format(cal.getTime());
^
src\com\rs\game\player\content\Commands.java:2519: error: class, interface, or e
num expected
}
^
21 errors
compiled Main Server Folder
src\com\rs\game\player\content\Commands.java:2477: error: illegal start of type
return true;
^
src\com\rs\game\player\content\Commands.java:2477: error: ';' expected
return true;
^
src\com\rs\game\player\content\Commands.java:2483: error: class, interface, or e
num expected
public static void archiveLogs(Player player, String[] cmd) {
^
src\com\rs\game\player\content\Commands.java:2487: error: class, interface, or e
num expected
String location = "";
^
src\com\rs\game\player\content\Commands.java:2488: error: class, interface, or e
num expected
if (player.getRights() >= 5) {
^
src\com\rs\game\player\content\Commands.java:2490: error: class, interface, or e
num expected
} else if (player.getRights() == 4) {
^
src\com\rs\game\player\content\Commands.java:2492: error: class, interface, or e
num expected
}
^
src\com\rs\game\player\content\Commands.java:2494: error: class, interface, or e
num expected
for (int i = 1; i < cmd.length; i++)
^
src\com\rs\game\player\content\Commands.java:2494: error: class, interface, or e
num expected
for (int i = 1; i < cmd.length; i++)
^
src\com\rs\game\player\content\Commands.java:2494: error: class, interface, or e
num expected
for (int i = 1; i < cmd.length; i++)
^
src\com\rs\game\player\content\Commands.java:2496: error: class, interface, or e
num expected
BufferedWriter writer = new BufferedWriter(new FileWrite
r(location,
^
src\com\rs\game\player\content\Commands.java:2498: error: class, interface, or e
num expected
writer.write("[" + now("dd MMMMM yyyy 'at' hh:mm:ss z")
+ "] - ::"
^
src\com\rs\game\player\content\Commands.java:2500: error: class, interface, or e
num expected
writer.newLine();
^
src\com\rs\game\player\content\Commands.java:2501: error: class, interface, or e
num expected
writer.flush();
^
src\com\rs\game\player\content\Commands.java:2502: error: class, interface, or e
num expected
writer.close();
^
src\com\rs\game\player\content\Commands.java:2503: error: class, interface, or e
num expected
} catch (IOException e) {
^
src\com\rs\game\player\content\Commands.java:2505: error: class, interface, or e
num expected
}
^
src\com\rs\game\player\content\Commands.java:2515: error: class, interface, or e
num expected
public static String now(String dateFormat) {
^
src\com\rs\game\player\content\Commands.java:2517: error: class, interface, or e
num expected
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
^
src\com\rs\game\player\content\Commands.java:2518: error: class, interface, or e
num expected
return sdf.format(cal.getTime());
^
src\com\rs\game\player\content\Commands.java:2519: error: class, interface, or enum expected
}
^
Note: src\com\rs\game\player\Inventory.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
21 errors
Compiled all Successfully
Press any key to continue . . .