What wrong?

Discussion in 'Plugin Development' started by GRANTSWIM4, Dec 29, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    GRANTSWIM4

    hello im am useing http://forums.bukkit.org/threads/library-lightweight-email-send-emails-from-plugins.101927/ but it will not work what am im doing wrong?


    Here the code

    Code:java
    1.  
    Code:java
    1.  
    2. package me.GRANTSWIM4.EHTracker;
    3.  
    4. import org.bukkit.plugin.java.JavaPlugin;
    5.  
    6. public final class Main extends JavaPlugin{
    7.  
    8. public void onEnable(){
    9. getLogger().info("Sending Test email");
    10. Email email = new Email();
    11. email.sendEmail(Providers.GMAIL, "E mail it going to",
    12. "Sending Email", "password", "Hi! This is a test subject!", "Hi! How are you today?");
    13.  
    14.  
    15. }
    16.  
    17. public void onDisable(){
    18. getLogger().info("Disableing goodbye");
    19. }
    20.  
    21. }
    22. [FONT=Consolas][/FONT]


    The LIB code

    Code:java
    1.  
    Code:java
    1.  
    2. package me.GRANTSWIM4.EHTracker;
    3.  
    4. import java.io.DataInputStream;
    5. import java.io.DataOutputStream;
    6. import java.io.IOException;
    7. import java.net.Socket;
    8.  
    9. public class Email {
    10.  
    11. @SuppressWarnings("deprecation")
    12. public void sendEmail(Providers provider, String to, String from,
    13. String password, String content, String subject, int port) {
    14.  
    15. String HOST = provider.getHost();
    16.  
    17. String PASSWORD = Base64Coder
    18. .encodeString(password);
    19. String USER = Base64Coder
    20. .encodeString(from);;
    21.  
    22. try {
    23. Socket socket = new Socket(HOST, port);
    24.  
    25. .getOutputStream());
    26. .getInputStream());
    27.  
    28. dos.writeBytes("HELO\r\n");
    29. dos.writeBytes("AUTH LOGIN");
    30. dos.writeBytes("\r\n");
    31. dos.writeBytes(USER);
    32. dos.writeBytes("\r\n");
    33. dos.writeBytes(PASSWORD);
    34. dos.writeBytes("\r\n");
    35. dos.writeBytes("MAIL FROM:<" + from + ">\r\n");
    36. dos.writeBytes("\r\n");
    37. dos.writeBytes("RCPT TO: <" + to + ">\r\n");
    38. dos.writeBytes("DATA\r\n");
    39. dos.writeBytes("Subject: "+subject+"\r\n");
    40. dos.writeBytes(content);
    41. dos.writeBytes("\r\n.\r\n");
    42. dos.writeBytes("QUIT\r\n");
    43.  
    44. dos.flush();
    45.  
    46. String responseline;
    47. while ((responseline = is.readLine()) != null) {
    48. System.out.println(responseline);
    49. }
    50.  
    51. is.close();
    52. dos.close();
    53. socket.close();
    54. } catch (IOException ex) {
    55. System.err.println(ex);
    56. }
    57.  
    58. }
    59.  
    60. public void sendEmail(Providers provider, String to, String from,
    61. String password, String content, String subject) {
    62.  
    63. sendEmail(provider, to, from, password, content, subject, 25); // Use default
    64. // port
    65.  
    66. }
    67.  
    68. }
    69.  
    70. class Base64Coder {
    71.  
    72. private static final char[] map1 = new char[64];
    73. static {
    74. int i = 0;
    75. for (char c = 'A'; c <= 'Z'; c++)
    76. map1[i++] = c;
    77. for (char c = 'a'; c <= 'z'; c++)
    78. map1[i++] = c;
    79. for (char c = '0'; c <= '9'; c++)
    80. map1[i++] = c;
    81. map1[i++] = '+';
    82. map1[i++] = '/';
    83. }
    84.  
    85. private static final byte[] map2 = new byte[128];
    86. static {
    87. for (int i = 0; i < map2.length; i++)
    88. map2[I] = [/I]-1;
    89. for (int i = 0; i < 64; i++)
    90. map2[map1] = (byte) i;
    91. }
    92.  
    93. public static String encodeString(String s) {
    94. return new String(encode(s.getBytes()));
    95. }
    96.  
    97. public static char[] encode(byte[] in) {
    98. return encode(in, 0, in.length);
    99. }
    100.  
    101. public static char[] encode(byte[] in, int iLen) {
    102. return encode(in, 0, iLen);
    103. }
    104.  
    105. public static char[] encode(byte[] in, int iOff, int iLen) {
    106. int oDataLen = (iLen * 4 + 2) / 3;
    107. int oLen = ((iLen + 2) / 3) * 4;
    108. char[] out = new char[oLen];
    109. int ip = iOff;
    110. int iEnd = iOff + iLen;
    111. int op = 0;
    112. while (ip < iEnd) {
    113. int i0 = in[ip++] & 0xff;
    114. int i1 = ip < iEnd ? in[ip++] & 0xff : 0;
    115. int i2 = ip < iEnd ? in[ip++] & 0xff : 0;
    116. int o0 = i0 >>> 2;
    117. int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
    118. int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
    119. int o3 = i2 & 0x3F;
    120. out[op++] = map1[o0];
    121. out[op++] = map1[o1];
    122. out[op] = op < oDataLen ? map1[o2] : '=';
    123. op++;
    124. out[op] = op < oDataLen ? map1[o3] : '=';
    125. op++;
    126. }
    127. return out;
    128. }
    129.  
    130. private Base64Coder() {}
    131.  
    132. }[FONT=Consolas][/FONT]



    Code:
    2012-12-29 17:53:15 [SEVERE] Error occurred while enabling EH Tracker v1.0 (Is it up to date?)
    java.lang.Error: Unresolved compilation problem:
     
        at me.GRANTSWIM4.EHTracker.Base64Coder.encodeString(Email.java:94)
        at me.GRANTSWIM4.EHTracker.Email.sendEmail(Email.java:17)
        at me.GRANTSWIM4.EHTracker.Email.sendEmail(Email.java:64)
        at me.GRANTSWIM4.EHTracker.Main.onEnable(Main.java:10)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
        at org.bukkit.craftbukkit.v1_4_6.CraftServer.loadPlugin(CraftServer.java:278)
        at org.bukkit.craftbukkit.v1_4_6.CraftServer.enablePlugins(CraftServer.java:260)
        at net.minecraft.server.v1_4_6.MinecraftServer.j(MinecraftServer.java:321)
        at net.minecraft.server.v1_4_6.MinecraftServer.e(MinecraftServer.java:300)
        at net.minecraft.server.v1_4_6.MinecraftServer.a(MinecraftServer.java:259)
        at net.minecraft.server.v1_4_6.DedicatedServer.init(DedicatedServer.java:149)
        at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:399)
        at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849)
     
  2. it would be a lot easier debugging if we see the error you're getting, because we then can see what has gone wrong and where
     
  3. Offline

    GRANTSWIM4

    Durp i forgot adding right now

    Added

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  4. Offline

    fireblast709

    GRANTSWIM4 now please build the plugin without compilation errors ;3
     
  5. Offline

    GRANTSWIM4

    Tell me how to fix it then I will not :3 fireblast709
     
  6. Offline

    fireblast709

    Your IDE should be able to help you a lot with those ;3. Just fix the red wriggly lines, and if you don't know how to fix a specific problem, post it here (including the line, additional snippets, and what your IDE is complaining about)
     
  7. Offline

    GRANTSWIM4

    Well fireblast709 I got no errors in eclips
     
  8. Offline

    fireblast709

    Well the stacktrace is telling me the opposite ;3
     
  9. Offline

    GRANTSWIM4

    Fond it How do i fix it?
     
  10. Offline

    fireblast709

    Sure, just post it on here
     
  11. Offline

    GRANTSWIM4

    Im on a pc how do i take a phto
     
  12. Offline

    Sagacious_Zed Bukkit Docs

    You take photos with cameras. Have you tried using the print screen key to capture a screen shot into the clipboard?
     
  13. Offline

    GRANTSWIM4

    What the key? on windows 7
     
  14. Offline

    ImDeJay

  15. Offline

    GRANTSWIM4

  16. Offline

    ImDeJay

    after you do print screen, it saves to your 'clipboard'

    best way to do it now is to go into MSPAINT and type "ctrl+v" to paste it, then save it wherever you want it
     
  17. Offline

    GRANTSWIM4

    can i use gimp
     
  18. Offline

    ImDeJay

    no idea what that is, but any type of photo editor will work just fine.
     
  19. Offline

    GRANTSWIM4

    I like how this went off topic lol im going to take a pic of eclips now

    Um how do i show what line number its on and in code how do i put java on help ImDeJay

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  20. Offline

    ImDeJay

  21. Offline

    GRANTSWIM4

  22. Offline

    ImDeJay

    use
    Code:
    [syntax=java]CODE HERE[/syntax]
     
  23. Offline

    GRANTSWIM4

    Here the phto i under line what wrong its in the LIB and fireblast709
    [​IMG]

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  24. Offline

    ImDeJay

    wait 12 hours before bumping a thread.

    but your error lies in a failure to copy/paste.
    the above picture tells me this:

    1. You dont know much about Java.
    2. Your expecting someone else to code your plugin for you.

    the and should not be there. that was put there by the forums [ syntax] command.

    Remove the and .

    ps. if your going to copy/paste code atleast know what it does so you can fix problems like this instead of just copy/pasting an entire project together then calling it your own.
     
  25. Offline

    fireblast709

    Why do you have 2 static blocks?
     
  26. Offline

    GRANTSWIM4

    I know a lot about java at last how to code a program so stop dising me

    Ok i got it how do i mark it solve?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  27. Offline

    fireblast709

    GRANTSWIM4 there should be an option 'edit thread' somewhere
     
Thread Status:
Not open for further replies.

Share This Page