-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
1 addition
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
21 changes: 1 addition & 20 deletions
21
plugin/src/main/java/fr/euphyllia/skyllia/utils/PlayerUtils.java
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 |
---|---|---|
@@ -1,44 +1,25 @@ | ||
package fr.euphyllia.skyllia.utils; | ||
|
||
import com.earth2me.essentials.Essentials; | ||
import com.earth2me.essentials.spawn.EssentialsSpawn; | ||
import fr.euphyllia.skyllia.Main; | ||
import fr.euphyllia.skyllia.api.SkylliaAPI; | ||
import fr.euphyllia.skyllia.api.event.players.PlayerTeleportSpawnEvent; | ||
import fr.euphyllia.skyllia.api.utils.scheduler.SchedulerTask; | ||
import fr.euphyllia.skyllia.api.utils.scheduler.model.SchedulerType; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.player.PlayerTeleportEvent; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class PlayerUtils { | ||
|
||
public static void teleportPlayerSpawn(Main main, Player player) { | ||
SkylliaAPI.getSchedulerTask().getScheduler(SchedulerTask.SchedulerSoft.MINECRAFT) | ||
.execute(SchedulerType.ENTITY, player, schedulerTask -> { | ||
Location spawnLocation = getSpawnLocationEssentials(player); // Todo Sera supprimer à l'avenir, je veux utiliser le point de dépendance possible ! | ||
if (spawnLocation == null) { | ||
spawnLocation = Bukkit.getWorlds().get(0).getSpawnLocation(); | ||
} | ||
PlayerTeleportSpawnEvent playerTeleportSpawnEvent = new PlayerTeleportSpawnEvent(player, spawnLocation); | ||
PlayerTeleportSpawnEvent playerTeleportSpawnEvent = new PlayerTeleportSpawnEvent(player, Bukkit.getWorlds().get(0).getSpawnLocation()); | ||
Bukkit.getPluginManager().callEvent(playerTeleportSpawnEvent); | ||
if (playerTeleportSpawnEvent.isCancelled()) { | ||
return; | ||
} | ||
player.teleportAsync(playerTeleportSpawnEvent.getFinalLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); | ||
}); | ||
} | ||
|
||
@Deprecated(forRemoval = true, since = "1.0-RC4") | ||
private static @Nullable Location getSpawnLocationEssentials(Player player) { | ||
EssentialsSpawn essentialsSpawn = (EssentialsSpawn) Bukkit.getPluginManager().getPlugin("EssentialsSpawn"); | ||
Essentials essentials = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials"); | ||
if (essentialsSpawn != null && essentialsSpawn.isEnabled() && essentials != null && essentials.isEnabled()) { | ||
return essentialsSpawn.getSpawn(essentials.getUser(player.getUniqueId()).getGroup()); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
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