--- miscJava/bukkit-minecraft-plugins/HoerupUtils/src/dk/thoerup/bukkit/hoeruputils/HomeCommand.java 2011/10/20 17:06:20 1614 +++ miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/HomeCommand.java 2012/01/27 12:21:27 1684 @@ -11,6 +11,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.bukkit.configuration.Configuration; import org.bukkit.configuration.file.YamlConfiguration; public class HomeCommand implements CommandExecutor { @@ -33,6 +34,10 @@ System.out.println("[HoerupUtils] exception loading config file: " + e.getMessage() ); } } + + Configuration getConfig() { + return config; + } @Override @@ -41,7 +46,7 @@ if (!(sender instanceof Player)) { return false; } - Player p = (Player) sender; + final Player p = (Player) sender; String name = p.getName(); @@ -56,10 +61,21 @@ double z = config.getDouble( name + ".z", 0.0); World world = p.getServer().getWorld(worldName); + int blockX = (int) Math.floor(x); + int blockZ = (int) Math.floor(z); + world.loadChunk(blockX, blockZ); + + final Location loc = new Location( world, x, y, z, (float)yaw, (float)pitch); + + Runnable r = new Runnable() { + public void run() { + p.teleport(loc); + } + }; + int tickCount = 2; // 2 ticks = 100ms - Location loc = new Location( world, x, y, z, (float)yaw, (float)pitch); + p.getServer().getScheduler().scheduleSyncDelayedTask(plugin, r, tickCount); - p.teleport(loc); } else { p.sendMessage(ChatColor.YELLOW + "You haven't set a home yet!"); }