[Help] Signs

Discussion in 'Plugin Development' started by JollyGiant16, Feb 10, 2013.

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

    JollyGiant16

    Hello,

    I'm trying to make a kit-pvp done by signs, I also have an issue I'm trying to link this class with my other main class.

    [SIGN]

    [BCKits]
    Regular

    Code:
    package me.anonymous350.Kits;
     
    import java.util.HashMap;
    import java.util.logging.Logger;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.event.block.SignChangeEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class SignListener extends JavaPlugin implements Listener {
        public final Logger logger = Logger.getLogger("Minecraft");
        public static SignListener plugin;
        public final HashMap<Location, String> signs = new HashMap<Location, String>();
        private String prefix;
       
        @Override
        public void onEnable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " Has Been Enabled!");
            {
              this.prefix = (ChatColor.WHITE + "[" + ChatColor.AQUA + "KitPvp" + ChatColor.WHITE + "] ");
                getLogger().info("has been enabled");
            }
        }
       
        @Override
        public void onDisable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + " Has Been Disabled!");
       
        }
       
        @EventHandler
        public void onSignChange(SignChangeEvent event) {
        if(event.getPlayer().isOp()) {
          if(event.getLine(0).equalsIgnoreCase("[BCKit]"))
              if(event.getLine(1).equalsIgnoreCase("Regular"))
                signs.put(event.getBlock().getLocation(), event.getPlayer().getName());
                event.getPlayer().sendMessage(this.prefix + " Kit Sign created."); }
               
            }
       
        @EventHandler
        public void onBlockBreak(BlockBreakEvent event) {
            if (signs.containsKey(event.getBlock().getLocation())
                    && !signs.containsValue(event.getPlayer().getName())) {
                event.setCancelled(true);
            } else {
                signs.remove(event.getBlock().getLocation());
            }
        }
       
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event) {
            Player player = event.getPlayer();
            player.performCommand("kit regular");
           
           
            if(signs.containsKey(event.getClickedBlock().getLocation())) {
               
            }
        }
     
  2. Offline

    ZeusAllMighty11

    Why not just check if the sign has text?
     
  3. Offline

    JollyGiant16

    Would you mind throwing in a example of that? - In code?
     
  4. Offline

    ZeusAllMighty11

    JollyGiant16

    if(block is an instanceof sign){
    Sign sign = block.getState();
    if(sign.getLine(0) equals ignore case "[BCkit]" ) {
    if line 1 is blah, do stuff
    }
    }
     
  5. Offline

    Butkicker12

  6. Offline

    JollyGiant16

    Thank you

    Bump! Any suggestions why it's not working?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
    Butkicker12 likes this.
  7. Offline

    chasechocolate

    Just do that.
     
Thread Status:
Not open for further replies.

Share This Page