Skip to content

Commit

Permalink
Refactor Utils.spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed Nov 29, 2023
1 parent b584b40 commit ad443bf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import me.lokka30.phantomworlds.PhantomWorlds;
import me.lokka30.phantomworlds.misc.Utils;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
Expand All @@ -46,7 +45,7 @@ public void onDeath(PlayerDeathEvent event) {

if(event.getEntity().getBedSpawnLocation() == null) {

event.getEntity().teleport(Utils.spawn(event.getEntity().getWorld()));
event.getEntity().teleport(Utils.parseSpawn(event.getEntity().getWorld()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import me.lokka30.phantomworlds.PhantomWorlds;
import me.lokka30.phantomworlds.misc.Utils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand Down Expand Up @@ -51,7 +50,7 @@ public void onJoin(PlayerJoinEvent event) {

//We don't manage so send the player to the spawn world
if(!event.getPlayer().hasPlayedBefore()) {
event.getPlayer().teleport(Utils.spawn(sWorld));
event.getPlayer().teleport(Utils.parseSpawn(sWorld));
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/me/lokka30/phantomworlds/misc/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public static void teleportToWorld(@NotNull CommandSender sender, @NotNull Strin
))).send(sender);
return;
}
targetPlayer.teleport(spawn(world));
targetPlayer.teleport(parseSpawn(world));

(new MultiMessage(
PhantomWorlds.instance().messages.getConfig()
Expand All @@ -321,7 +321,7 @@ public static void teleportToWorld(@NotNull CommandSender sender, @NotNull Strin
))).send(sender);
}

public static Location spawn(final World world) {
public static Location parseSpawn(final World world) {
final String cfgPath = "worlds-to-load." + world.getName() + ".spawn";
if(PhantomWorlds.instance().data.getConfig().contains(cfgPath)) {
final double x = PhantomWorlds.instance().data.getConfig().getDouble(cfgPath + ".x", world.getSpawnLocation().getX());
Expand Down

0 comments on commit ad443bf

Please sign in to comment.