Move Everyone On The Server

Discussion in 'Bukkit Help' started by jcan89, Jul 26, 2012.

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

    jcan89

    I want to make everyone registered on my server start in one specific location the next time they login, despite where they were last time they logged off. The purpose is to start players at the new spawn location. How can I do this?

    Is there a command that comes with Essentials or anything? Can I get a plugin to handle this?
    This is very important I need to know an answer soon!
    Thanks guys. :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  2. Offline

    jcan89

    Can someone please help me?
     
  3. Offline

    MrMee3

    i just signed up to bukkit to try and help you

    i thought that you could do this in the API but tested it and it don't work unfortunately :-(
    Code:
              Location setLoc = new Location(plugin.getServer().getWorld("world"),-100,64,100);
                for(OfflinePlayer Player : plugin.getServer().getOfflinePlayers()){
                    Player.getPlayer().teleport(setLoc);
                }
    what you could do is get all the offline players and store them and when they join the server next tp them to the location

    or even simpler you could just get every player to be tp'd to the location every time they join the server no matter what
     
  4. Offline

    jcan89

    Thanks for the responce...but wouldnt that make it so everytime someone logs on they start back at the spawn?
     
  5. Offline

    MrMee3

    yeah but if the plugin stored every one in a list and as soon as they joined the server they would get tp'd there and then removed from the list and will not be tp'd again

    i made it and it works:
    Code:
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
            if(!sender.isOp())return true;
            if (!(sender instanceof Player))return true;
           
            Player Sender = (Player)sender;
           
            Location setLoc = Sender.getLocation();
           
            List<String> playerList = new ArrayList<String>();
           
            for(OfflinePlayer Player : getServer().getOfflinePlayers()){
                if(Player.isOnline()){
                    Player.getPlayer().teleport(setLoc);
                } else {
                    playerList.add(Player.getName());
                }
            }
           
            getConfig().set("PlayersToTP", playerList);
            getConfig().set("TPworld", setLoc.getWorld().getName());
            getConfig().set("TPx", setLoc.getX());
            getConfig().set("TPy", setLoc.getY());
            getConfig().set("TPz", setLoc.getZ());
           
            saveConfig();
           
            return true;
        }
     
        @EventHandler(priority = EventPriority.NORMAL)
        public void onPlayerJoin(PlayerJoinEvent event) {
            if(getConfig().contains("PlayersToTP")){
                String TPworld = getConfig().getString("TPworld");
                Double TPx = getConfig().getDouble("TPx");
                Double TPy = getConfig().getDouble("TPy");
                Double TPz = getConfig().getDouble("TPz");
                Location TPloc = new Location(getServer().getWorld(TPworld),TPx,TPy,TPz);
                List<String> playerList = (List<String>) getConfig().getList("PlayersToTP");
                if (playerList.contains(event.getPlayer().getName())){
                    event.getPlayer().teleport(TPloc);
                    playerList.remove(event.getPlayer().getName());
                    getConfig().set("PlayersToTP", playerList);
                    saveConfig();
                }
            }
        }
    if you need me to i can make the plugin jar for you :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  6. Offline

    jcan89

    sure thing! i haven't delved into plugin creation yet :D
    any tips on where to get started?
     
Thread Status:
Not open for further replies.

Share This Page