Sign Change event not working

Discussion in 'Plugin Development' started by ChromeHD__, Jul 9, 2014.

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

    ChromeHD__

    Code:java
    1.  
    2. @EventHandler(priority=EventPriority.HIGHEST)
    3. public void LobbySign(SignChangeEvent sign){
    4.  
    5. if (sign.getLine(0).equalsIgnoreCase("[Join-MOD]")){
    6.  
    7. sign.setLine(0, "&b[Join-MOD1]");
    8. if(Gamestate == 1){
    9. sign.setLine(1, "&4In-game" );
    10. }else if (Gamestate == 0){
    11. sign.setLine(1, "&2Waiting" );
    12. }
    13.  
    14. sign.setLine(3, PlayerCount + "/" + Maxslots);
    15.  
    16. }



    There is my code there is no errors but i put that on the sign in game nothing happens

    Also in my main class my plugin is not creating a folder and config and here is the code for that
    Code:java
    1.  
    2. if(!MOD.exists()){
    3. MOD.mkdir();
    4. }else{
    5. System.out.println("Folder has already been been made.");
    6. }
    7. if(!Config.exists()){
    8. System.out.println("Config file has not been made.");
    9. try{
    10. Config.createNewFile();
    11. }catch(Exception e){
    12.  
    13. }
    14. }else{
    15. System.out.println("Config file has been made.");
    16. }
    17.  
     
  2. Offline

    MCMastery

  3. Offline

    tommycake50

    Please show us the whole method and any set variables associated with it for the creating DataFolder and file, it would help us narrow down the problem.
     
  4. Offline

    ChromeHD__

    Here is the main code for the main .java
    Code:java
    1. package com.mod.chrome;
    2.  
    3. import java.io.ByteArrayOutputStream;
    4. import java.io.DataOutputStream;
    5. import java.io.File;
    6. import java.io.IOException;
    7. import java.util.ArrayList;
    8. import java.util.List;
    9.  
    10. import org.bukkit.ChatColor;
    11. import org.bukkit.command.Command;
    12. import org.bukkit.command.CommandSender;
    13. import org.bukkit.configuration.file.FileConfiguration;
    14. import org.bukkit.entity.Player;
    15. import org.bukkit.event.Listener;
    16. import org.bukkit.plugin.java.JavaPlugin;
    17.  
    18. public class Main extends JavaPlugin {
    19. ///////////variables////////////////////////////////////////////////////////////
    20.  
    21. public String title = "[Mine of Duty]";
    22. List<String> blue = new ArrayList<String>();
    23. List<String> red = new ArrayList<String>();
    24. public boolean IL,St;
    25.  
    26. ///////////////////////////////////////////////////////////////////////////////
    27.  
    28. //On Disable
    29.  
    30. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    31. public void onEnabled(){
    32. File MOD = new File(getDataFolder() + "");
    33. File Config = new File(getDataFolder(), "Config.yml");
    34. FileConfiguration Radiation;
    35. Listener Sign = new Sign();
    36. getServer().getPluginManager().registerEvents(Sign, this);
    37. getLogger().info(title + " has been enabled!.");
    38.  
    39. if(!MOD.exists()){
    40. MOD.mkdir();
    41. }else{
    42. System.out.println("Folder has already been been made.");
    43. }
    44. if(!Config.exists()){
    45. System.out.println("Config file has not been made.");
    46. try{
    47. Config.createNewFile();
    48. }catch(Exception e){
    49.  
    50. }
    51. }else{
    52. System.out.println("Config file has been made.");
    53. }
    54.  
    55. }
    56. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    57.  
    58. //On Disable
    59.  
    60. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    61. public void onDisable(){
    62.  
    63. getLogger().info("has been disabled!.");
    64.  
    65. }
    66. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    67.  
    68. /////////////////////////////////////////////////////////////////////////////////////////////////////////
    69.  
    70. public void modsend(Player player, String server){
    71.  
    72.  
    73. try{
    74. this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
    75. out.writeUTF("Connect");
    76. out.writeUTF(server);
    77. }catch(Exception e){
    78. e.printStackTrace();
    79. }
    80. player.sendPluginMessage(this, "BungeeCord", byt.toByteArray());
    81. }
    82. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
    83.  
    84. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    85. Player user = (Player)sender;
    86. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    87. if(cmd.getName().equalsIgnoreCase("mod")){
    88. if(args.length == 0){
    89. user.sendMessage(ChatColor.AQUA + title + ChatColor.GOLD + ": " + ChatColor.GREEN +"List of available commands are below.");
    90. user.sendMessage(ChatColor.AQUA + title + ChatColor.GOLD + ": " + ChatColor.GREEN + "/Mod start - Forces the current lobby to start.");
    91. user.sendMessage(ChatColor.AQUA + title + ChatColor.GOLD + ": " + ChatColor.GREEN + "/Mod stop - Stops the current game/lobby to close.");
    92. user.sendMessage(ChatColor.AQUA + title + ChatColor.GOLD + ": " + ChatColor.GREEN + "/Mod team - Allows you to switch to the opposite team |Staff/VIP Only|");
    93. user.sendMessage(ChatColor.AQUA + title + ChatColor.GOLD + ": " + ChatColor.GREEN + "/Mod xp - Displays the amount of XP needed to level up.");
    94. user.sendMessage(ChatColor.AQUA + title + ChatColor.GOLD + ": " + ChatColor.GREEN + "/Mod leave - Leaves the game and returns you to the Hub server.");
    95. return true;
    96. }
    97. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    98. if(args[0].equalsIgnoreCase("Join")){
    99.  
    100. try {
    101. this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
    102. modsend(user, "mod");
    103. } catch (Exception e) {
    104.  
    105. }
    106. }
    107. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    108. if(args[0].equalsIgnoreCase("leave")){
    109. try {
    110. this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
    111. modsend(user, "Hub");
    112. } catch (Exception e) {
    113.  
    114. }
    115. }
    116. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    117. }
    118.  
    119. return false;
    120. }
    121. }
    122.  


    Code:java
    1.  
    2. package com.mod.chrome;
    3.  
    4. import org.bukkit.event.EventHandler;
    5. import org.bukkit.event.EventPriority;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.block.SignChangeEvent;
    8.  
    9. public class Sign implements Listener{
    10.  
    11. public int PlayerCount;
    12. public int Maxslots;
    13. public String map;
    14. public int Gamestate;
    15.  
    16.  
    17.  
    18.  
    19. @EventHandler(priority=EventPriority.HIGHEST)
    20. public void LobbySign(SignChangeEvent sign){
    21.  
    22. if (sign.getLine(0).equalsIgnoreCase("[Join-MOD]")){
    23.  
    24. sign.setLine(0, "&b[Join-MOD1]");
    25. if(Gamestate == 1){
    26. sign.setLine(1, "&4In-game" );
    27. }else if (Gamestate == 0){
    28. sign.setLine(1, "&2Waiting" );
    29. }
    30.  
    31. sign.setLine(3, PlayerCount + "/" + Maxslots);
    32.  
    33. }
    34.  
    35. }
    36.  
    37. }
    38.  


    for the sign.java i havent set variables = to anything because i cant get the config file set up
     
  5. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    We do not support servers with authentication disabled.
     
Thread Status:
Not open for further replies.

Share This Page