forked from lokka30/PhantomWorlds
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transfer setspawn command. Handle spawn TP internally to prevent spig…
…ot from rounding to integers.
- Loading branch information
1 parent
f89809e
commit 72840fc
Showing
5 changed files
with
136 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
import me.lokka30.phantomworlds.PhantomWorlds; | ||
import org.bukkit.GameMode; | ||
import org.bukkit.Location; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerChangedWorldEvent; | ||
|
@@ -41,6 +42,19 @@ public PlayerChangeWorldListener(PhantomWorlds plugin) { | |
|
||
@EventHandler | ||
public void onChangeWorld(PlayerChangedWorldEvent event) { | ||
|
||
//Check if this world has a PhantomWorlds managed spawn. If so, teleport the player there. | ||
final String spawnPath = "worlds-to-load." + event.getPlayer().getWorld().getName() + ".spawn"; | ||
if(PhantomWorlds.instance().data.getConfig().contains(spawnPath)) { | ||
final double x = PhantomWorlds.instance().data.getConfig().getDouble(spawnPath + ".x", event.getPlayer().getWorld().getSpawnLocation().getX()); | ||
final double y = PhantomWorlds.instance().data.getConfig().getDouble(spawnPath + ".y", event.getPlayer().getWorld().getSpawnLocation().getY()); | ||
final double z = PhantomWorlds.instance().data.getConfig().getDouble(spawnPath + ".z", event.getPlayer().getWorld().getSpawnLocation().getZ()); | ||
final float yaw = (float)PhantomWorlds.instance().data.getConfig().getDouble(spawnPath + ".yaw", event.getPlayer().getWorld().getSpawnLocation().getYaw()); | ||
final float pitch = (float)PhantomWorlds.instance().data.getConfig().getDouble(spawnPath + ".pitch", event.getPlayer().getWorld().getSpawnLocation().getPitch()); | ||
|
||
event.getPlayer().teleport(new Location(event.getPlayer().getWorld(), x, y, z, yaw, pitch)); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
creatorfromhell
Author
Member
|
||
} | ||
|
||
final String cfgPath = "worlds-to-load." + event.getPlayer().getWorld().getName(); | ||
if(PhantomWorlds.instance().data.getConfig().contains(cfgPath + ".gameMode")) { | ||
final GameMode mode = GameMode.valueOf(PhantomWorlds.instance().data.getConfig().getString(cfgPath + ".gameMode")); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
just thought of something whilst checking the implementation - would this also teleport players to spawn each time they change world via a portal or something? or if they are teleporting to a player in a different world, for example?