When a server is shut off while a player is in Herobrine's Graveyard, that player will be stuck in Herobrine's Graveyard the next time they log in. From now on, whenever this happens, the player will be teleported to the spawn point of the server's default world.
This commit is contained in:
parent
d3d047b5b1
commit
1dc2cb3d39
@ -2,6 +2,7 @@ package net.theprogrammersworld.herobrine;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -24,6 +25,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -277,10 +279,22 @@ public class Herobrine extends JavaPlugin implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
// When a player joins the server, check if they are an OP. If they are,
|
||||
// and a newer version of Herobrine is available, display a message to
|
||||
// them stating so.
|
||||
// When a player joins the server, perform several checks.
|
||||
Player joinedPlayer = event.getPlayer();
|
||||
|
||||
// It is possible for a player to become stuck in Herobrine's Graveyard. If the player that
|
||||
// has just logged in is stuck in Herobrine's Graveyard, teleport them to the server's default
|
||||
// spawn point and let them know what happened.
|
||||
if(joinedPlayer.getWorld().getName().equals(configdb.HerobrineWorldName)) {
|
||||
List<World> worldList = Bukkit.getServer().getWorlds();
|
||||
joinedPlayer.teleport(worldList.get(0).getSpawnLocation());
|
||||
joinedPlayer.sendMessage(ChatColor.RED + "It looks like you got stuck in Herobrine's " +
|
||||
"Graveyard. This usually happens when the server has been shut off after you have been " +
|
||||
"teleported to it. To fix this, we have teleported you to this server's default spawn point.");
|
||||
}
|
||||
|
||||
// If the player that has just joined is an OP and a newer version of Herobrine is available,
|
||||
// display a message to them stating so.
|
||||
if(configdb.newVersionFound && joinedPlayer.isOp()) {
|
||||
joinedPlayer.sendMessage(ChatColor.RED + "A new version of Herobrine is available. To " +
|
||||
"get it, go to www.theprogrammersworld.net/Herobrine and click \"Download\".");
|
||||
|
Reference in New Issue
Block a user