Thread: {PI} - Compiling Error - Really stuck!

Results 1 to 3 of 3
  1. #1 {PI} - Compiling Error - Really stuck! 
    Registered Member
    Join Date
    Jan 2012
    Posts
    3
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    I followed a tutorial and have also tried to find others for a basic report abuse system.. however, out of all the comments, I seem to be the only one with this error! What am I missing?

    Code:
    src\server\model\players\ReportHandler.java:129: error: illegal start of express
    ion
     public static boolean hasSpoke(String s) {
     ^
    src\server\model\players\ReportHandler.java:129: error: illegal start of express
    ion
     public static boolean hasSpoke(String s) {
            ^
    src\server\model\players\ReportHandler.java:129: error: ';' expected
     public static boolean hasSpoke(String s) {
                  ^
    src\server\model\players\ReportHandler.java:129: error: ')' expected
     public static boolean hasSpoke(String s) {
                                          ^
    src\server\model\players\ReportHandler.java:129: error: illegal start of express
    ion
     public static boolean hasSpoke(String s) {
                                            ^
    src\server\model\players\ReportHandler.java:129: error: ';' expected
     public static boolean hasSpoke(String s) {
                                             ^
    src\server\model\players\ReportHandler.java:139: error: illegal start of express
    ion
    public static String getMonth(String s) {
    ^
    src\server\model\players\ReportHandler.java:139: error: illegal start of express
    ion
    public static String getMonth(String s) {
           ^
    src\server\model\players\ReportHandler.java:139: error: ';' expected
    public static String getMonth(String s) {
                        ^
    src\server\model\players\ReportHandler.java:139: error: ')' expected
    public static String getMonth(String s) {
                                        ^
    src\server\model\players\ReportHandler.java:139: error: illegal start of express
    ion
    public static String getMonth(String s) {
                                          ^
    src\server\model\players\ReportHandler.java:139: error: ';' expected
    public static String getMonth(String s) {
                                           ^
    12 errors
    Press any key to continue . . .
    Oh, and here's the ReportHandler class.

    Code:
    package server.model.players;
    
    import java.io.BufferedWriter;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    
    import server.model.players.Client;
    import server.util.Misc;
    
    
    public class ReportHandler {
    
    public static String[] savedNames = new String[500];
    public static String[] savedSpeach = new String[500];
    public static String[] savedTimes = new String[500];
    
    public static final String[] reportNames = { "Offensive language",
    "Item scamming", "Password scamming", "Bug abuse",
    "Staff impersonation", "Other", "Macroing", "Duping",
    "Encouraging others to break the rules", "Yell abuse",
    "Advertising", "Possible duped items" };
    
    public static void addText(String name, byte[] data, int dataLength) {
    for (int i = 499; i > 0; i--) {
    savedNames[i] = savedNames[i - 1];
    savedSpeach[i] = savedSpeach[i - 1];
    savedTimes[i] = savedTimes[i - 1];
    }
    
    savedNames[0] = name;
    savedSpeach[0] = Misc.textUnpack(data, dataLength);
    String minute = new SimpleDateFormat("mm").format(new Date());
    String second = new SimpleDateFormat("ss").format(new Date());
    String hour = new SimpleDateFormat("hh").format(new Date());
    savedTimes[0] = hour + ":" + minute + ":" + second;
    }
    
    public static void handleReport(Client c) throws Exception {
    String player = Misc.longToReportPlayerName(c.inStream.readQWord2());
    player = player.replaceAll("_", " ");
    byte rule = (byte) c.inStream.readUnsignedByte();
    if (c.lastReported.equalsIgnoreCase(player)
    && (System.currentTimeMillis() - c.lastReport) < 60000) {
    c.sendMessage("You can only report a player once every 60 seconds.");
    return;
    }
    if (c.playerName.equalsIgnoreCase(player)) {
    c.sendMessage("You cannot report yourself!");
    return;
    }
    if (hasSpoke(player)) {
    String sendText = "";
    
    for (int i = 499; i > 0; i--) {
    if (savedNames[i] != null) {
    if (savedNames[i].equalsIgnoreCase(c.playerName)
    || savedNames[i].equalsIgnoreCase(player)) {
    sendText += " -[" + savedTimes[i] + ": "
    + savedNames[i] + "]: " + savedSpeach[i]
    + "\r\n";
    }
    }
    }
    
    sendText = sendText.replaceAll("'", " ");
    String month = getMonth(new SimpleDateFormat("MM")
    .format(new Date()));
    String day = new SimpleDateFormat("dd").format(new Date());
    // Statement statement = Server.conn.createStatement();
    writeReport(player + " was reported by " + c.playerName + ", "
    + reportNames[rule] + ", " + month + ", " + day + "",
    sendText + ".", reportNames[rule]);
    c.sendMessage("Thank you, your report has been received and will be reviewed.");
    c.lastReported = player;
    c.lastReport = System.currentTimeMillis();
    return;
    } else {
    c.sendMessage("You can only report someone who has spoken in the last 60 seconds.");
    return;
    }
    }
    
    public static void writeReport(String data, String text, String file) {
    BufferedWriter bw = null;
    
    try {
    bw = new BufferedWriter(new FileWriter("./data/reports/" + file
    + ".txt", true));
    bw.write(data);
    bw.newLine();
    bw.write(text);
    bw.newLine();
    bw.newLine();
    bw.flush();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    } finally {
    if (bw != null)
    try {
    bw.close();
    } catch (IOException ioe2) {
    System.out.println("Error writing system log.");
    ioe2.printStackTrace();
    }
    }
    
    }
    
    public static void writeLog(String text, String file, String dir) {
    // used for bans/mutes/chatlogs etc. -bakatool
    BufferedWriter bw = null;
    try {
    bw = new BufferedWriter(new FileWriter(dir + file + ".txt", true));
    bw.write(text);
    bw.newLine();
    bw.flush();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    } finally {
    if (bw != null)
    try {
    bw.close();
    } catch (IOException ioe2) {
    System.out.println("Error writing system log.");
    ioe2.printStackTrace();
    
     public static boolean hasSpoke(String s) {         
     for (int i = 0; i < 500; i++) {             
     if (savedNames[i] != null) {                 
     if (savedNames[i].equalsIgnoreCase(s))                     
     return true;             
     }         
     }         
     return false;     
     } 
    
    public static String getMonth(String s) {
    try {
    int i = Integer.parseInt(s);
    String[] months = { "", "January", "February", "March", "April",
    "May", "June", "July", "August", "September", "October",
    "November", "December" };
    return months[i];
    } catch (Exception e) {
    e.printStackTrace();
    }
    return "Unknown";
    }
    }
    
    }
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jan 2012
    Posts
    3
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Anyone? Need this so I can carry on working on it!
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Feb 2010
    Posts
    3,253
    Thanks given
    1,145
    Thanks received
    909
    Rep Power
    2081
    Code:
    public static void writeLog(String text, String file, String dir) {
    // used for bans/mutes/chatlogs etc. -bakatool
    BufferedWriter bw = null;
    try {
    bw = new BufferedWriter(new FileWriter(dir + file + ".txt", true));
    bw.write(text);
    bw.newLine();
    bw.flush();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    } finally {
    if (bw != null)
    try {
    bw.close();
    } catch (IOException ioe2) {
    System.out.println("Error writing system log.");
    ioe2.printStackTrace();
    There's no closing brace.

    This should work:
    Code:
    public static void writeLog(String text, String file, String dir) {
    // used for bans/mutes/chatlogs etc. -bakatool
    BufferedWriter bw = null;
    try {
    bw = new BufferedWriter(new FileWriter(dir + file + ".txt", true));
    bw.write(text);
    bw.newLine();
    bw.flush();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    } finally {
    if (bw != null)
    try {
    bw.close();
    } catch (IOException ioe2) {
    System.out.println("Error writing system log.");
    ioe2.printStackTrace();
    }
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Small error help please im stuck haha (rep++)
    By garrydowling2011 in forum Help
    Replies: 0
    Last Post: 12-08-2011, 03:48 PM
  2. Compiling Error
    By ipkerzi in forum Help
    Replies: 2
    Last Post: 06-11-2011, 01:53 AM
  3. SERVER STUCK ON STARTUP --- error inside
    By lewis0001 in forum Help
    Replies: 21
    Last Post: 05-20-2011, 08:59 PM
  4. compiling error
    By 99matt99 in forum Help
    Replies: 0
    Last Post: 10-17-2010, 08:03 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •