Solved Sign Event? (No more posting on here)

Discussion in 'Plugin Development' started by PolarCraft, Dec 11, 2013.

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

    PolarCraft

    Developerjohn I know what you mean. Anyways cowteal Please start your own thread so that it would be easier so that other people can solve it with your code not mine.
     
  2. Offline

    cowteal

    its kinda the same thing, thats why i wrote it here
     
  3. Offline

    iiHeroo



    What part?

    SignChangeEvent or PlayerInteractEvent?

    PolarCraft

    And cowteal has the right to post here, but Polar, if you're wondering where to put the performCommand, please look here, where I make an example with a KitPvP plugin, if you have more issues, look here
     
  4. Offline

    PolarCraft

    iiHeroo Already have done the performCommand. Well i am writing the command atm.
     
  5. Offline

    iiHeroo



    So is this solved?
     
  6. Offline

    PolarCraft

    iiHeroo Testing it now. So hold on.
     
  7. Offline

    cowteal


    this is what i did and its not working :(

    Code:java
    1. package me.cowteal.sign;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.block.Sign;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.block.Action;
    8. import org.bukkit.event.block.SignChangeEvent;
    9. import org.bukkit.event.player.PlayerInteractEvent;
    10.  
    11. public class Main {
    12.  
    13. @EventHandler
    14. public void onSignChange(SignChangeEvent e) {
    15. Player p = e.getPlayer();
    16. if(e.getLine(0).equalsIgnoreCase("work")) {
    17. if(p.hasPermission("kitme.admin.signmake")) {
    18. e.setLine(0, ChatColor.BLACK + "[" + ChatColor.BLUE + "Join" + ChatColor.BLACK + "]");
    19. e.setLine(1, ChatColor.BLACK + "0-0");
    20. e.setLine(2, ChatColor.BLACK + "<MAP-NAME>");
    21. }
    22. }
    23. }
    24.  
    25. @EventHandler
    26. public void SignClick(PlayerInteractEvent e) {
    27. Player p = e.getPlayer();
    28. if (e.getAction() == Action.RIGHT_CLICK_BLOCK){
    29. if (e.getClickedBlock().getState() instanceof Sign) {
    30. Sign sign = (Sign) e.getClickedBlock().getState();
    31. if(sign.getLine(1).equalsIgnoreCase("0-0")) {
    32. p.performCommand("ma join Forest");
    33. }
    34. }
    35. }
    36. }
    37. }
     
  8. Offline

    PolarCraft

    cowteal your spacing is off.

    iiHeroo Now when i right click the sign it will not fire the event.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  9. Offline

    cowteal

    what do you mean? where should i delete spaces?
     
  10. Offline

    PolarCraft

    *facepalm*
     
  11. Offline

    cowteal

    its not showing up when i do /pl
     
  12. Offline

    PolarCraft

    Do you know how to do a plugin.yml. . .
     
  13. Offline

    cowteal

    i did one here see-


    Code:
    name: SignsInAction
    main: me.cowteal.sign.Main
    version: 1
    author: cowteal
     
  14. Offline

    iiHeroo


    Then look in your console for a stacktrace, if there isn't one see if you even put it in.


    See if you registered the event, and add the permission to you also.



    If your class is called Main, where is your class called 'Sign' and does that register your events?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  15. Offline

    PolarCraft

    iiHeroo
    getServer().getPluginManager().registerEvents(new StandardEvent(), this);
    And '*' gives you all perms.
     
  16. Offline

    cowteal

    the console gets this-

    Code:
    [18:01:19 ERROR]: Could not load 'plugins/Herro.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.ClassCastException: class me.cowteal.sign.Main
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:184) ~[craftbukkit.jar:git-Bukkit-1.6.4-R2.0-11-ga4123a3-b2931jnks]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305) ~[craftbukkit.jar:git-Bukkit-1.6.4-R2.0-11-ga4123a3-b2931jnks]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-11-ga4123a3-b2931jnks]
        at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.java:255) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-11-ga4123a3-b2931jnks]
        at org.bukkit.craftbukkit.v1_7_R1.CraftServer.<init>(CraftServer.java:233) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-11-ga4123a3-b2931jnks]
        at net.minecraft.server.v1_7_R1.PlayerList.<init>(PlayerList.java:63) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-11-ga4123a3-b2931jnks]
        at net.minecraft.server.v1_7_R1.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-11-ga4123a3-b2931jnks]
        at net.minecraft.server.v1_7_R1.DedicatedServer.init(DedicatedServer.java:126) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-11-ga4123a3-b2931jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:414) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-11-ga4123a3-b2931jnks]
        at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-11-ga4123a3-b2931jnks]
    Caused by: java.lang.ClassCastException: class me.cowteal.sign.Main
        at java.lang.Class.asSubclass(Class.java:3075) ~[?:1.6.0_65]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:174) ~[craftbukkit.jar:git-Bukkit-1.6.4-R2.0-11-ga4123a3-b2931jnks]
        ... 9 more
    
    what do i do?

    i only have 1 class called "Main" and its in the package "sign"

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  17. Offline

    iiHeroo


    *facepalm*

    DO YOU EVEN KNOW JAVA? OR BUKKIT?
     
  18. Offline

    cowteal

    i know a little :p so please help me with this.

    i only have 1 class and all my other plugins worked with only 1 class.

    its called main as you can see :p

    what is wrong with the code? why is it not working? the other guy said its spacing....

    Code:java
    1. package me.cowteal.sign;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.block.Sign;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.block.Action;
    8. import org.bukkit.event.block.SignChangeEvent;
    9. import org.bukkit.event.player.PlayerInteractEvent;
    10.  
    11. public class Main {
    12.  
    13. @EventHandler
    14. public void onSignChange(SignChangeEvent e) {
    15. Player p = e.getPlayer();
    16. if(e.getLine(0).equalsIgnoreCase("work")) {
    17. if(p.hasPermission("kitme.admin.signmake")) {
    18. e.setLine(0, ChatColor.BLACK + "[" + ChatColor.BLUE + "Join" + ChatColor.BLACK + "]");
    19. e.setLine(1, ChatColor.BLACK + "0-0");
    20. e.setLine(2, ChatColor.BLACK + "<MAP-NAME>");
    21. }
    22. }
    23. }
    24.  
    25. @EventHandler
    26. public void SignClick(PlayerInteractEvent e) {
    27. Player p = e.getPlayer();
    28. if (e.getAction() == Action.RIGHT_CLICK_BLOCK){
    29. if (e.getClickedBlock().getState() instanceof Sign) {
    30. Sign sign = (Sign) e.getClickedBlock().getState();
    31. if(sign.getLine(1).equalsIgnoreCase("0-0")) {
    32. p.performCommand("ma join Forest");
    33. }
    34. }
    35. }
    36. }
    37. }
     
  19. Offline

    PolarCraft

    *FACEPALM* you must import onEnable and onDisable to even enable the plugin....
     
  20. Offline

    iiHeroo


    Don't forget the extends JavaPlugin ._.

    Please learn Java first and then Bukkit.
     
  21. Offline

    cowteal

    testing it one sec...

    IT WORKS THANKS!

    ok it works but how do i make it perform a command? this is what i did:

    Code:java
    1. @EventHandler
    2. public void onSignChange(SignChangeEvent e) {
    3. Player p = e.getPlayer();
    4. if(e.getLine(0).equalsIgnoreCase("work")) {
    5. if(p.hasPermission("kitme.admin.signmake")) {
    6. e.setLine(0, ChatColor.BLACK + "[" + ChatColor.BLUE + "Join" + ChatColor.BLACK + "]");
    7. e.setLine(1, ChatColor.BLACK + "0-0");
    8. e.setLine(2, ChatColor.BLACK + "<MAP-NAME>");
    9. }
    10. }
    11. }
    12.  
    13. @EventHandler
    14. public void SignClick(PlayerInteractEvent e) {
    15. Player p = e.getPlayer();
    16. if (e.getAction() == Action.RIGHT_CLICK_BLOCK){
    17. if (e.getClickedBlock().getState() instanceof Sign) {
    18. Sign sign = (Sign) e.getClickedBlock().getState();
    19. if(sign.getLine(1).equalsIgnoreCase("0-0")) {
    20. p.performCommand("ma join Forest");
    21. }
    22. }
    23. }
    24. }
    25. }



    the plugin works i only sent u some code

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  22. Offline

    iiHeroo


    If you don't know how to make a command then, *facepalm*
     
  23. Offline

    cowteal

    can you please just tell me how to make it work? thanks
     
  24. Offline

    PolarCraft

    iiHeroo Oh yeah sorry must extend javaplugin. Skimed over it.
     
  25. Offline

    iiHeroo


    Learn Bukkit
     
  26. Offline

    AoH_Ruthless

    cowteal
    Alright, I am sorry to sound rude, but you really are wasting other people's time with your completely ignorance of Java. You really need to learn the fundamentals of Java. There are many tutorials on youtube, many books, and you can even take classes. After you understand some of Java you should check out http://wiki.bukkit.org/Plugin_Tutorial, which is one page that helps you learn the the basics of the Bukkit API.
     
  27. Offline

    PolarCraft

  28. Offline

    AoH_Ruthless

    PolarCraft
    I didn't have a bone to pick with him about that, because frankly, that wasn't a pressing issue to me. I tend to stay away from that kind of arguing.
     
  29. Offline

    cowteal

    Sorry guys - I'm gonna learn for around 2 weeks and I will start doing things myself
     
Thread Status:
Not open for further replies.

Share This Page