41 |
if (!(sender instanceof Player)) { |
if (!(sender instanceof Player)) { |
42 |
return false; |
return false; |
43 |
} |
} |
44 |
Player p = (Player) sender; |
final Player p = (Player) sender; |
45 |
|
|
46 |
String name = p.getName(); |
String name = p.getName(); |
47 |
|
|
56 |
double z = config.getDouble( name + ".z", 0.0); |
double z = config.getDouble( name + ".z", 0.0); |
57 |
|
|
58 |
World world = p.getServer().getWorld(worldName); |
World world = p.getServer().getWorld(worldName); |
59 |
|
int blockX = (int) Math.floor(x); |
60 |
|
int blockZ = (int) Math.floor(z); |
61 |
|
world.loadChunk(blockX, blockZ); |
62 |
|
|
63 |
|
final Location loc = new Location( world, x, y, z, (float)yaw, (float)pitch); |
64 |
|
|
65 |
|
Runnable r = new Runnable() { |
66 |
|
public void run() { |
67 |
|
p.teleport(loc); |
68 |
|
} |
69 |
|
}; |
70 |
|
int tickCount = 2; // 2 ticks = 100ms |
71 |
|
|
72 |
Location loc = new Location( world, x, y, z, (float)yaw, (float)pitch); |
p.getServer().getScheduler().scheduleSyncDelayedTask(plugin, r, tickCount); |
73 |
|
|
|
p.teleport(loc); |
|
74 |
} else { |
} else { |
75 |
p.sendMessage(ChatColor.YELLOW + "You haven't set a home yet!"); |
p.sendMessage(ChatColor.YELLOW + "You haven't set a home yet!"); |
76 |
} |
} |