[Player Teleportation] Couldn't find a suitable handler.

Discussion in 'Plugin Development' started by Matthewenderle, May 24, 2012.

Thread Status:
Not open for further replies.
  1. I'm trying to make a command where an admin will set a spawn point that will be saved as a integer or double in the command file. I am trying to focus on makeing the command that will teleport the players to this point previously set with "/bmt join" I have this so far

    PlayerManager:
    crap bell rang... where's my save as draft button.

    please look later...
     
  2. Offline

    Briggybros

    For your first command you would save the location as doubles, like so;
    Code:
                   Player player = (Player)sender;
                    Location playerLoc = player.getLocation();
                    double pX = playerLoc.getX();
                    double pY = playerLoc.getY();
                    double pZ = playerLoc.getZ();
                    getConfig().addDefault("Spawn", pX + "," + pY + "," + pZ);
    then to teleport the command would be as so;
    Code:
                    String spawnLocation = getConfig().getString("Spawn");
                    String[] spawnArray = spawnLocation.split(",");
                    double spawnX = Integer.parseInt(spawnArray[0]);
                    double spawnY = Integer.parseInt(spawnArray[1]);
                    double spawnZ = Integer.parseInt(spawnArray[2]);
                    final Location position = new Location(/*World goes here*/, spawnX, spawnY, spawnZ);
                    player.teleport(position);
     
    Matthewenderle likes this.
  3. I'll try this. When it works I'll certainty give you a Like.

    This didn't work right away but I managed to tweek it off of it. now it does... btw i was importing Location not from bukkit... :)

    Ok something is still not working...



    PlayerManager.java
    Code:
    package net.mlestudios.BuildMyThing;
     
    import java.util.Vector;
     
    import org.bukkit.World;
    import org.bukkit.command.defaults.TeleportCommand;
    import org.bukkit.entity.Player;
    import org.bukkit.event.player.PlayerChatEvent;
    import org.bukkit.event.player.PlayerTeleportEvent;
    import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
     
    import com.sun.xml.internal.bind.v2.runtime.Location;
     
    public class PlayerManager {
     
     
        public static void playerJoin(PlayerChatEvent event)
     
     
        {
            Player player = event.getPlayer();
            double spawnX = Config.xl;
            double spawnY = Config.yl;
            double spawnZ = Config.zl;
            String world = Config.world;
             
            final Location position = new Location("world", spawnX, spawnY, spawnZ);
            player.teleport(position);
        }
    Config.java
    Code:
    package net.mlestudios.BuildMyThing;
     
    import java.util.List;
     
    import org.bukkit.Location;
    import org.bukkit.configuration.Configuration;
     
    import net.mlestudios.BuildMyThing.Main;
     
    public class Config {
     
        public static String eventstart;
        public static String eventprejoin;
        public static String prefixGuess;
        public static Integer xa;
        public static Integer xb;
        public static Integer za;
        public static Integer zb;
        public static Double xl;
        public static Double yl;
        public static Double zl;
        public static String Lobby;
        public static String world;
     
     
     
        public static Boolean enable_permissions;
     
     
     
        public static List<String> Words;
     
        public static boolean PermissionsEnabled;
     
        private static Configuration config;
     
        public Config(Main plugin)
        {
            config = plugin.getConfig();
            config.options().copyDefaults(true);
            config.set("version", plugin.Version());
            plugin.saveConfig();
     
            PermissionsEnabled = config.getBoolean("Config.enable_permissions");
            Words = config.getStringList("Words");
         
            //Phrases
            eventstart = config.getString("event_start");
            eventprejoin = config.getString("event_pre_join");
            prefixGuess = config.getString("prefixGuess");
         
        }
     
    }
    
    config.yml
    Code:
    #Coded by MatthewEnderle
    #Support available on Divinedynasty.net and http://dev.bukkit.org/server-mods/icebox/tickets/
     
    Config:
        enable_permissions: true
     
    Map:
        xa: 1000000000
        xb: 1000000000
        za: 1000000000
        zb: 1000000000
        xLobby:
        yLobby:
        zLobby:
     
     
    Messages:
        no-permission: You are not allowed to guess what the sophisticated noun is!
        incorrect_guess: Nope that is not correct! Please try again!
        correct_guess: You got it right!
        event_start: has initialized a BuildMyThing Event!
        event_pre_join: If you wish to play type
        prefixGuess: Is it a
     
    Words:
    - Tree
    - Pickaxe
    - bucket
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  4. You can't use a String as a world...: final Location position = new Location("world", spawnX, spawnY, spawnZ);
    greetz blackwolf12333
     
  5. I did that... still get the same error... unless you meant without the quotes. then I still get the same.

     
  6. Offline

    Technius

    To get a world, use
    Code:java
    1. Bukkit.getServer().getWorld("World");

    Make sure the world is not null.
     
  7. Offline

    NerdsWBNerds

    In your PlayerManager.java file you are importing the wrong type of location.
    replace import com.sun.xml.internal.bind.v2.runtime.Location;
    with import org.bukkit.Location;
     
Thread Status:
Not open for further replies.

Share This Page