Solved I think i coded my /sethub and /hub wrong, can you help me?

Discussion in 'Plugin Development' started by NordisKFail, Apr 29, 2015.

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

    NordisKFail

    Hey, i just fixed my code after my other post, but then i encountered a problem... /sethub and /hub that i made doesen't work, i am sure that was the way to do it when i do /sethub it works completely fine until i do /hub i get teleported to a completely different place, and hiiigh up in the air, i can't see the problem and i am not sure what to do, that's where you come in! You need to help me figure out what's wrong with this code!

    Code:
            if (cmd.getName().equalsIgnoreCase("hub")) {
                player.teleport(player.getWorld().getSpawnLocation());
                player.sendMessage(ChatColor.AQUA + "Teleporterer...");
                return true;
            }
           
            if (cmd.getName().equalsIgnoreCase("sethub")) {
                player.getWorld().setSpawnLocation(player.getLocation().getBlockX(), player.getLocation().getBlockZ(), player.getLocation().getBlockY());
                Bukkit.broadcastMessage("Det har kommet en ny hub, for å komme dit bruk /hub");
                return true;
    If you want the whole code of the plugin here you go:

    Code:
    package me.NordisKFail;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class PluginMain extends JavaPlugin implements JavaListener {
    
        public void onEnable() {
            getLogger().info(ChatColor.AQUA + "Ser ut som om pluginen funker! :) GoliHub (SmartHub) av NordisKFail");
       
            getServer().getPluginManager().registerEvents(new EventFile (this), this);
           
        }
    
        public void onDisable() {
            getLogger().info(ChatColor.AQUA + "VIKTIG: Pluginen stenger naa! Var ikke det meningen? Kontakt meg [email protected]");
        }
       
        public boolean onCommand (CommandSender sender, Command cmd, String label, String[] args) {
            Player player = (Player) sender;
           
            if(cmd.getName().equalsIgnoreCase("test")) {
                player.sendMessage(ChatColor.GRAY + "[" + ChatColor.BLUE + "GoliCraft" + ChatColor.GRAY + "] " +  ChatColor.AQUA + "Ser ut som om det er null problem i denne pluginen! ;)");
                return true;
               
            }
           
            if(cmd.getName().equalsIgnoreCase("bugs")) {
                player.sendMessage(ChatColor.GRAY + "[" + ChatColor.BLUE + "GoliCraft" + ChatColor.GRAY + "] " +  ChatColor.AQUA + "Noen ganger kommer det bugs! Da er det lurt at du kontakter NordisKFail snarest mulig!");
                return true;
            }
           
            if(cmd.getName().equalsIgnoreCase("kontaktoss")) {
                player.sendMessage(ChatColor.GRAY + "[" + ChatColor.BLUE + "GoliCraft" + ChatColor.GRAY + "] " + ChatColor.AQUA + "Webside: http://hkonaulv.wix.com/golicraft E-post: [email protected]");
                return true;
            }
           
            if (cmd.getName().equalsIgnoreCase("hub")) {
                player.teleport(player.getWorld().getSpawnLocation());
                player.sendMessage(ChatColor.AQUA + "Teleporterer...");
                return true;
            }
           
            if (cmd.getName().equalsIgnoreCase("sethub")) {
                player.getWorld().setSpawnLocation(player.getLocation().getBlockX(), player.getLocation().getBlockZ(), player.getLocation().getBlockY());
                Bukkit.broadcastMessage("Det har kommet en ny hub, for å komme dit bruk /hub");
                return true;
            }
           
            return false;
           
        }
       
    }
    
    Please ignore stuff that doesen't have to do with the things i have done wrong with /hub and /sethub, and don't go out of topic in this forum post. :)
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    NordisKFail

    Ok, i'll try.

    EDIT: It worked, thanks @timtower.
     
    Last edited: Apr 29, 2015
Thread Status:
Not open for further replies.

Share This Page