Solved Plugin not working?

Discussion in 'Spigot Plugin Development' started by ZevoGaems, Jun 4, 2017.

  1. I am working on a launchpad plugin so whenever you step on a slimeblock it launches you. I don't know what I did wrong but its not working. I am including the code and everything up (not including imports)

    Code (Text):
    public class main extends JavaPlugin implements Listener {
        public void onEnable() {
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
        }

        @EventHandler
        public void LogOnGMC(final PlayerJoinEvent e) {
            Player playerisgmed = e.getPlayer();
            if(playerisgmed.getGameMode() == GameMode.CREATIVE) {
            playerisgmed.setGameMode(GameMode.SURVIVAL);
            playerisgmed.sendMessage(ChatColor.BLUE + "Gamemode Changed to Survival (Loged out with CREATIVE MODE)");
            }
            }
       
        @EventHandler
        public void onPlayerMoveEvent(PlayerMoveEvent event) {
            Player player = event.getPlayer();
            Location loc = player.getPlayer().getLocation();
            loc.setY(loc.getY() -2);
            int block = loc.getWorld().getBlockTypeIdAt(loc);
            if(block == 165) {
                player.setVelocity(player.getLocation().getDirection().multiply(5));
            }
        }
     
  2. Errors? Does the code even run at all?
     
  3. Nope it doesn't work at all. When you step on a slime block nothing happens and there is one deprecated at getBlockTypeIdAt(loc)
     
  4. Is this your first post?
    Firstly, don't tell us your plugin doesn't work. Say something more: what is not working? Have tou tried anything else?
    Secondly, make a title that is a little bit more descriptive.
    Thirdly, post errors or logs and test if the code runs.
    Fourthly, you can use java syntax using [code=java][/code] tags. Better then just using the tags without =java

    And learn to google and debug:
     
  5. is there an error/ does the plugin load?
     
  6. You really should be using:
    Code (Text):
    if(loc.getBlock().getType == Material.SLIME_BLOCK) { }
    ^Might have some syntax errors.

    Using item id's is deprecated and should not be used anymore.
     
  7. The plugin loads and all of the other commands I have in it work but not the slime thing
     
  8. I changed it and that didn't work either
     
  9. Add this line of code:
    Code (Text):
    event.getPlayer().sendMessage(loc.getBlock().getType);
    Check if it even says slime block at all. I think it needs to be -1 instead of -2
     
  10. Ok I found the error. It was -2 when it should have been -1 :p
     
  11. Wow at the same exact time xD
     
    • Funny Funny x 1
  12. Now, mark your thingy as solved and give me that shiny winner reaction :D
     
    • Winner Winner x 1
  13. I said that a long time ago if you read my message carefully xD
     
  14. I didn't see it. I also did use google and the guy said it was from a head height so do -2, but he was wrong
     
  15. Good you used google. Many people go and ask something here whilst there are many fixes and solutions on the internet.
     
    • Agree Agree x 1