Move Player To World Not Working ?!

Discussion in 'Plugin Development' started by projectwoosh, Jun 23, 2016.

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


    Hello guys,
    I am a Bukkit plugin maker beginner,
    and I have a server and I wanna create just a simple plugin to move players.
    (In future more things)
    And I don't know what I am doing wrong!?

    This is my error:

    [22:10:02 INFO]: UMADSON issued server command: /skyblock
    [22:10:02 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'skyblock' in plugin ServerPlugin v0.1
      at org.bukkit.command.PluginCommand.execute( ~[minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at org.bukkit.command.SimpleCommandMap.dispatch( ~[minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at org.bukkit.craftbukkit.v1_10_R1.CraftServer.dispatchCommand( ~[minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at net.minecraft.server.v1_10_R1.PlayerConnection.handleCommand( [minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at net.minecraft.server.v1_10_R1.PlayerConnection.a( [minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at net.minecraft.server.v1_10_R1.PacketPlayInChat.a(SourceFile:37) [minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at net.minecraft.server.v1_10_R1.PacketPlayInChat.a(SourceFile:9) [minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at net.minecraft.server.v1_10_R1.PlayerConnectionUtils$ [minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at java.util.concurrent.Executors$ Source) [?:1.8.0_92]
      at Source) [?:1.8.0_92]
      at net.minecraft.server.v1_10_R1.SystemUtils.a(SourceFile:45) [minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at net.minecraft.server.v1_10_R1.MinecraftServer.D( [minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at net.minecraft.server.v1_10_R1.DedicatedServer.D( [minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at net.minecraft.server.v1_10_R1.MinecraftServer.C( [minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at [minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at Source) [?:1.8.0_92]
    Caused by: java.lang.NullPointerException
      at org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer.teleport( ~[minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity.teleport( ~[minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      at net.woosh.hub.main.Main.onCommand( ~[?:?]
      at org.bukkit.command.PluginCommand.execute( ~[minecraft_server.1.9.jar:git-Bukkit-10c10b3]
      ... 15 more
    And this is My Main File:
    package net.woosh.hub.main;
    import java.util.logging.Logger;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import net.milkbowl.vault.economy.Economy;
    public class Main extends JavaPlugin implements Listener {
       public static final String Prefix = ChatColor.DARK_GRAY+ "[" + ChatColor.DARK_PURPLE + ChatColor.BOLD + "Woosh" + ChatColor.RESET + ChatColor.DARK_GRAY + "] " + ChatColor.DARK_PURPLE;
      public static Economy econ = null;
       public void onEnable(){    
         Bukkit.getServer().getPluginManager().registerEvents(this, this);
       public void onDisable(){
       public void onPlayerJoin(PlayerJoinEvent e){
         Player user = e.getPlayer();
         String message = Prefix + "Welcome, " + ChatColor.GOLD + user.getName() + ChatColor.DARK_PURPLE + "!";
      public int onlinePlayers() {
      int a = 0;
      for (Player player : getServer().getOnlinePlayers()) {
      return a;
      Logger log = Logger.getLogger("minecraft");
      public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
         if(!(sender instanceof Player)){
           sender.sendMessage(Prefix + "You aren't a player!");
           return false;
      if(cmd.getName().equalsIgnoreCase("skyblock") && args.length == 0){
      Player player = (Player) sender;
      World p = Bukkit.getWorld("skyblock");
      player.teleport(new Location(p, -232, 51, -8.5));
      player.sendMessage(Prefix + "You're now in the Skyblock!");
      return true;
      }else if(args.length == 1){
         Player player = (Player) sender;
         String vip = args[1];
         for (Player all : Bukkit.getOnlinePlayers()) {
      if (all.hasPermission("woosh.perm")){
      World p = Bukkit.getWorld("skyblock");
      player.teleport(new Location(p, -232, 51, -8.5));
      player.sendMessage(Prefix + "You're now in the Skyblock!");
      player.sendMessage(ChatColor.RED + "You don't have permissions to use this command!");
           player.sendMessage(Prefix + "Unknow argument!");
      }else if(args.length > 1){
         Player player = (Player) sender;
         player.sendMessage(Prefix + "Too much arguments!");
      return false;
    And here is my plugin.yml file:
    name: ServerPlugin
    main: net.woosh.hub.main.Main
    version: 0.1
    author: UMADSON
    prefix: Woosh
      description: Goto VIP Skyblock!
      usage: /<command>
    I hope that you know!
    Sorry for bad English ;)
    Sorry for long question!
    Last edited by a moderator: Jun 23, 2016
  2. Offline

    timtower Administrator Administrator Moderator

    • Please don't use static, you don't need it.
    • You never set the value of econ
    • To get the amount of online players use getServer().getOnlinePlayers().size()
    • Don't use that logger, use getLogger instead.
    • Check if the world is null before you use it.
Thread Status:
Not open for further replies.

Share This Page