[WIP][General]SignCountdown Plugin

Discussion in 'Plugin Development' started by redraskal, Mar 19, 2014.

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

    redraskal

    Hello everybody!
    I was working on a plugin called SignCountdown and it allows people to make countdowns on signs. So far it is working, but for some reason when I test it, it has an error on the plugindescriptionfile which I guess would be the plugin.yml, and I can't figure out what it is. It might be the actual code that somehow changes it or something, but ill paste the yml and the main class (the only class) in here if that helps :).

    plugin.yml:
    Code:
    name: SignCountdown
    version: 1.0
    description: Made by redraskal.
    load: POSTWORLD
    authors: []
    website: http://play-miniworldmc.sytes.net/bukkit
    main: me.redraskaldoesgaming.signcountdown.SignCountdown
    database: false
    depend: []
    softdepend: []
    author: redraskal
    SignCountdown.java:
    Code:java
    1. package me.redraskaldoesgaming.signcountdown;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Location;
    8. import org.bukkit.Material;
    9. import org.bukkit.Server;
    10. import org.bukkit.World;
    11. import org.bukkit.block.Block;
    12. import org.bukkit.block.Sign;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.event.EventHandler;
    15. import org.bukkit.event.Listener;
    16. import org.bukkit.event.block.SignChangeEvent;
    17. import org.bukkit.event.player.PlayerInteractEvent;
    18. import org.bukkit.plugin.java.JavaPlugin;
    19.  
    20. public class SignCountdown extends JavaPlugin implements Listener {
    21. Server server = getServer();
    22. Logger logger = getLogger();
    23. public Logger log = Bukkit.getLogger();
    24. String prefix = color(getConfig().getString("prefix").replace("%space%", " "));
    25. String enabled = ChatColor.GREEN + "Is now enabled!";
    26. String configmade = ChatColor.GREEN + "Config detected! Default config copy job is now cancelled!";
    27. public String color(String msg)
    28. {
    29. String coloredMsg = "";
    30. for(int i = 0; i < msg.length(); i++)
    31. {
    32. if(msg.charAt(i) == '&')
    33. coloredMsg += 'ยง';
    34. else
    35. coloredMsg += msg.charAt(i);
    36. }
    37. return coloredMsg;
    38. }
    39.  
    40. public void onEnable() {
    41. server.getPluginManager().registerEvents(this, this);
    42. if(!getConfig().contains("made")) {
    43. getConfig().options().copyDefaults(true);
    44. } else {
    45. log.info(prefix + configmade);
    46. }
    47. log.info(prefix + enabled);
    48. }
    49. @EventHandler
    50. public void onSignCreate(SignChangeEvent sign) {
    51. Player player = sign.getPlayer();
    52. World world = player.getWorld();
    53. if(sign.getLine(0).equalsIgnoreCase("[Countdown]") && sign.getLine(2).endsWith("m")) {
    54. sign.setLine(0, prefix);
    55. if(sign.getLine(1).contains("%")) {
    56. sign.getLine(1).replace("%tournament%", "Tournament starts in...");
    57. sign.getLine(1).replace("%game%", "Game starts in...");
    58. } else {
    59. sign.setLine(0, ChatColor.RED + "[Countdown]");
    60. sign.setLine(1, ChatColor.RED + "<Type>");
    61. player.sendMessage(color(prefix + ChatColor.YELLOW + "Warning: There is not the right format on the second line!"));
    62. }
    63. sign.setLine(2, "00:" + sign.getLine(1).replace("m", "") + ":00");
    64. Block targetBlock = player.getTargetBlock(null, 15);
    65. if (targetBlock.getType() == Material.WALL_SIGN || targetBlock.getType() == Material.SIGN){
    66.  
    67. int x = targetBlock.getX();
    68. int y = targetBlock.getY();
    69. int z = targetBlock.getZ();
    70.  
    71.  
    72. Sign targetsign = (Sign) world.getBlockAt(x, y, z);
    73. if(sign.getLine(0).equalsIgnoreCase("[Countdown]") && sign.getLine(1).contains("%")) {
    74. getConfig().set("countdownsign", targetsign);
    75. }
    76. } else {
    77. }
    78. log.warning(color(prefix + ChatColor.YELLOW + "Warning: Sign Made By " + ChatColor.WHITE + player + ChatColor.YELLOW + " is not a countdown sign!"));
    79. }
    80. }
    81. }


    If anyone can help, please post in the comments any changes and please tell me what the changes were :).

    Thanks,
    redraskal
     
  2. Try using this as a plugin.yml
    Code:
    name: SignCountdown
    version: 1.0
    description: Made by redraskal.
    website: http://play-miniworldmc.sytes.net/bukkit
    main: me.redraskaldoesgaming.signcountdown.SignCountdown
    author: redraskal
    It seemed like you had a lot of entries that didn't really do anything.
     
  3. Offline

    redraskal

    ill try that, thanks :)
     
  4. Offline

    sfxworks

    It would be cool if these signs could emit a redstone signal when they hit 0
     
  5. Offline

    TnT

    Moved to the correct forum.
     
  6. Offline

    redraskal

    I may be able to figure that out
     
    sfxworks likes this.
Thread Status:
Not open for further replies.

Share This Page