mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-22 09:08:03 +01:00
Added team invite command.
This commit is contained in:
parent
008a4e6b72
commit
2c2cd774d3
@ -289,7 +289,9 @@ expel:
|
||||
invite:
|
||||
errorCantJoinIsland: "You couldn't join the island, maybe it's full."
|
||||
errorCoolDown: "You can invite that player again in [time] minutes"
|
||||
errorNoOneInvitedYou: "No one invited you"
|
||||
errorThatPlayerIsAlreadyInATeam: "That player is already in a team."
|
||||
errorYouAreAlreadyOnATeam: "You are already on a team!"
|
||||
errorYouCannotInviteYourself: "You can not invite yourself!"
|
||||
errorYouMustHaveIslandToInvite: "You must have an island in order to invite people to it!"
|
||||
errorYourIslandIsFull: "Your island is full, you can't invite anyone else."
|
||||
|
@ -1,11 +1,14 @@
|
||||
package us.tastybento.bskyblock.commands;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -16,6 +19,7 @@ import com.google.common.collect.HashBiMap;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.api.commands.AbstractCommand;
|
||||
import us.tastybento.bskyblock.api.events.team.PlayerAcceptInviteEvent;
|
||||
import us.tastybento.bskyblock.config.Settings;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
import us.tastybento.bskyblock.schematics.Schematic;
|
||||
@ -29,13 +33,15 @@ import us.tastybento.bskyblock.util.VaultHelper;
|
||||
* @author Poslovitch
|
||||
*/
|
||||
public class IslandCommand extends AbstractCommand {
|
||||
protected static final boolean DEBUG = true;
|
||||
private BSkyBlock plugin;
|
||||
/**
|
||||
* Invite list - invited player name string (key), inviter name string
|
||||
* (value)
|
||||
*/
|
||||
private final BiMap<UUID, UUID> inviteList = HashBiMap.create();
|
||||
|
||||
// The time a player has to wait until they can reset their island again
|
||||
private HashMap<UUID, Long> resetWaitTime = new HashMap<UUID, Long>();
|
||||
|
||||
public IslandCommand(BSkyBlock plugin) {
|
||||
super(plugin, Settings.ISLANDCOMMAND, true);
|
||||
@ -294,11 +300,14 @@ public class IslandCommand extends AbstractCommand {
|
||||
if (plugin.getIslands().hasIsland(player.getUniqueId())) {
|
||||
// Get the player's old island
|
||||
Island oldIsland = plugin.getIslands().getIsland(player.getUniqueId());
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: old island is at " + oldIsland.getCenter().getBlockX() + "," + oldIsland.getCenter().getBlockZ());
|
||||
// Remove them from this island (it still exists and will be deleted later)
|
||||
plugin.getIslands().removePlayer(player.getUniqueId());
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: old island's owner is " + oldIsland.getOwner());
|
||||
// Create new island and then delete the old one
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: making new island ");
|
||||
Schematic schematic = plugin.getSchematics().getSchematic("default");
|
||||
plugin.getIslands().newIsland(player, schematic, oldIsland);
|
||||
@ -499,6 +508,7 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: executing team command");
|
||||
if (inTeam) {
|
||||
if (teamLeaderUUID.equals(playerUUID)) {
|
||||
@ -550,6 +560,7 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public String[] usage(CommandSender sender){
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: executing team help");
|
||||
|
||||
return new String[] {null, plugin.getLocale(sender).get("help.island.team")};
|
||||
@ -732,18 +743,18 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
// Invite label with no name, i.e., /island invite - tells the player who has invited them so far
|
||||
if (inviteList.inverse().containsKey(playerUUID)) {
|
||||
Player invitee = plugin.getServer().getPlayer(inviteList.inverse().get(playerUUID));
|
||||
if (invitee != null) {
|
||||
inviteList.inverse().remove(playerUUID);
|
||||
Util.sendMessage(invitee, ChatColor.RED + plugin.getLocale(invitee.getUniqueId()).get("invite.nameHasUninvitedYou").replace("[name]", player.getName()));
|
||||
Util.sendMessage(player, ChatColor.GREEN + plugin.getLocale(playerUUID).get("general.success"));
|
||||
}
|
||||
} else {
|
||||
Util.sendMessage(player, ChatColor.RED + plugin.getLocale(sender).get("island.help.Invite"));
|
||||
// Invite label with no name, i.e., /island invite - tells the player who has invited them so far
|
||||
if (inviteList.inverse().containsKey(playerUUID)) {
|
||||
Player invitee = plugin.getServer().getPlayer(inviteList.inverse().get(playerUUID));
|
||||
if (invitee != null) {
|
||||
inviteList.inverse().remove(playerUUID);
|
||||
Util.sendMessage(invitee, ChatColor.RED + plugin.getLocale(invitee.getUniqueId()).get("invite.nameHasUninvitedYou").replace("[name]", player.getName()));
|
||||
Util.sendMessage(player, ChatColor.GREEN + plugin.getLocale(playerUUID).get("general.success"));
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
Util.sendMessage(player, ChatColor.RED + plugin.getLocale(sender).get("island.help.Invite"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -763,7 +774,12 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
|
||||
if (isPlayer) {
|
||||
if (VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team.create")) {
|
||||
return new CanUseResp(true);
|
||||
}
|
||||
return new CanUseResp(ChatColor.RED + plugin.getLocale(player).get("general.errors.no-permission"));
|
||||
}
|
||||
return new CanUseResp(false);
|
||||
}
|
||||
|
||||
@ -790,7 +806,12 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
|
||||
if (isPlayer) {
|
||||
if (VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team.create")) {
|
||||
return new CanUseResp(true);
|
||||
}
|
||||
return new CanUseResp(ChatColor.RED + plugin.getLocale(player).get("general.errors.no-permission"));
|
||||
}
|
||||
return new CanUseResp(false);
|
||||
}
|
||||
|
||||
@ -817,14 +838,70 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
|
||||
if (isPlayer) {
|
||||
if (VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team.create")) {
|
||||
return new CanUseResp(true);
|
||||
}
|
||||
return new CanUseResp(ChatColor.RED + plugin.getLocale(player).get("general.errors.no-permission"));
|
||||
}
|
||||
return new CanUseResp(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!isPlayer) {
|
||||
|
||||
}
|
||||
// Check if player has been invited
|
||||
if (!inviteList.containsKey(playerUUID)) {
|
||||
Util.sendMessage(player, ChatColor.RED + plugin.getLocale(player).get("invite.errorNoOneInvitedYou"));
|
||||
return;
|
||||
}
|
||||
// Check if player is already in a team
|
||||
if (plugin.getPlayers().inTeam(playerUUID)) {
|
||||
Util.sendMessage(player, ChatColor.RED + plugin.getLocale(player).get("invite.errorYouAreAlreadyOnATeam"));
|
||||
return;
|
||||
}
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
// If the invitee has an island of their own
|
||||
if (plugin.getPlayers().hasIsland(playerUUID)) {
|
||||
plugin.getLogger().info(player.getName() + "'s island will be deleted because they joined a party.");
|
||||
plugin.getIslands().deletePlayerIsland(playerUUID, true);
|
||||
plugin.getLogger().info("Island deleted.");
|
||||
}
|
||||
// Set the team leader
|
||||
teamLeaderUUID = inviteList.get(playerUUID);
|
||||
// TODO implement this
|
||||
plugin.getPlayers().resetPlayer(player);
|
||||
// Add the player to the team
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: adding " + playerUUID + " to team " + teamLeaderUUID);
|
||||
plugin.getIslands().setJoinTeam(playerUUID, inviteList.get(playerUUID));
|
||||
setResetWaitTime(player);
|
||||
if (Settings.teamJoinDeathReset) {
|
||||
plugin.getPlayers().setDeaths(player.getUniqueId(), 0);
|
||||
}
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: team leader's home is " + plugin.getPlayers().getHomeLocation(teamLeaderUUID));
|
||||
// Set the player's home
|
||||
plugin.getPlayers().setHomeLocation(playerUUID, plugin.getPlayers().getHomeLocation(teamLeaderUUID));
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: teleporting player to new island");
|
||||
plugin.getIslands().homeTeleport(player);
|
||||
|
||||
// Fire event so add-ons can run commands, etc.
|
||||
plugin.getServer().getPluginManager().callEvent(new PlayerAcceptInviteEvent(player));
|
||||
Util.sendMessage(player, ChatColor.GREEN + plugin.getLocale(player.getUniqueId()).get("invite.youHaveJoinedAnIsland"));
|
||||
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: Removing player from invite list");
|
||||
if (plugin.getServer().getPlayer(inviteList.get(playerUUID)) != null) {
|
||||
Util.sendMessage(plugin.getServer().getPlayer(inviteList.get(playerUUID)),
|
||||
ChatColor.GREEN + plugin.getLocale(player.getUniqueId()).get("invite.hasJoinedYourIsland").replace("[name]", player.getName()));
|
||||
}
|
||||
// Remove the invite
|
||||
inviteList.remove(player.getUniqueId());
|
||||
plugin.getIslands().save(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -844,7 +921,12 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
|
||||
if (isPlayer) {
|
||||
if (VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team.create")) {
|
||||
return new CanUseResp(true);
|
||||
}
|
||||
return new CanUseResp(ChatColor.RED + plugin.getLocale(player).get("general.errors.no-permission"));
|
||||
}
|
||||
return new CanUseResp(false);
|
||||
}
|
||||
|
||||
@ -871,7 +953,12 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
|
||||
if (isPlayer) {
|
||||
if (VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team.create")) {
|
||||
return new CanUseResp(true);
|
||||
}
|
||||
return new CanUseResp(ChatColor.RED + plugin.getLocale(player).get("general.errors.no-permission"));
|
||||
}
|
||||
return new CanUseResp(false);
|
||||
}
|
||||
|
||||
@ -1344,6 +1431,16 @@ public class IslandCommand extends AbstractCommand {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a timeout for player into the Hashmap resetWaitTime
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
private void setResetWaitTime(final Player player) {
|
||||
resetWaitTime.put(player.getUniqueId(), Long.valueOf(Calendar.getInstance().getTimeInMillis() + Settings.resetWait * 1000));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates an island for player
|
||||
* @param player
|
||||
|
@ -223,5 +223,6 @@ public class Settings {
|
||||
public static HashMap<String,Integer> limitedBlocks;
|
||||
public static boolean allowTNTPushing;
|
||||
public static boolean showInActionBar;
|
||||
public static boolean teamJoinDeathReset;
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import java.util.WeakHashMap;
|
||||
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -43,7 +44,7 @@ import us.tastybento.bskyblock.util.Util;
|
||||
*/
|
||||
public class IslandsManager {
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
private static final boolean DEBUG = true;
|
||||
private BSkyBlock plugin;
|
||||
private BSBDatabase database;
|
||||
|
||||
@ -324,7 +325,7 @@ public class IslandsManager {
|
||||
public void removePlayer(UUID playerUUID) {
|
||||
Island island = islandsByUUID.get(playerUUID);
|
||||
if (island != null) {
|
||||
if (island.getOwner().equals(playerUUID)) {
|
||||
if (island.getOwner() != null && island.getOwner().equals(playerUUID)) {
|
||||
// Clear ownership and members
|
||||
island.getMembers().clear();
|
||||
island.setOwner(null);
|
||||
@ -360,6 +361,7 @@ public class IslandsManager {
|
||||
}
|
||||
// Add player to new island
|
||||
teamIsland.addMember(playerUUID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -519,7 +521,8 @@ public class IslandsManager {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("home teleport called for #" + number);
|
||||
home = getSafeHomeLocation(player.getUniqueId(), number);
|
||||
//plugin.getLogger().info("home get safe loc = " + home);
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("home get safe loc = " + home);
|
||||
// Check if the player is a passenger in a boat
|
||||
if (player.isInsideVehicle()) {
|
||||
Entity boat = player.getVehicle();
|
||||
@ -548,6 +551,10 @@ public class IslandsManager {
|
||||
} else {
|
||||
Util.sendMessage(player, ChatColor.GREEN + "teleported to #" + number);
|
||||
}
|
||||
// Exit spectator mode if in it
|
||||
if (player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -569,7 +576,8 @@ public class IslandsManager {
|
||||
l = plugin.getPlayers().getHomeLocation(playerUUID, number);
|
||||
}
|
||||
// Check if it is safe
|
||||
//plugin.getLogger().info("DEBUG: Home location " + l);
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: Home location " + l);
|
||||
if (l != null) {
|
||||
// Homes are stored as integers and need correcting to be more central
|
||||
if (isSafeLocation(l)) {
|
||||
@ -586,26 +594,38 @@ public class IslandsManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//plugin.getLogger().info("DEBUG: Home location either isn't safe, or does not exist so try the island");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: Home location either isn't safe, or does not exist so try the island");
|
||||
// Home location either isn't safe, or does not exist so try the island
|
||||
// location
|
||||
if (plugin.getPlayers().inTeam(playerUUID)) {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG:player is in team");
|
||||
l = plugin.getIslands().getIslandLocation(playerUUID);
|
||||
if (isSafeLocation(l)) {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG:island loc is safe");
|
||||
plugin.getPlayers().setHomeLocation(playerUUID, l, number);
|
||||
return l.clone().add(new Vector(0.5D,0,0.5D));
|
||||
} else {
|
||||
// try team leader's home
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: trying leader's home");
|
||||
Location tlh = plugin.getPlayers().getHomeLocation(plugin.getIslands().getTeamLeader(playerUUID));
|
||||
if (tlh != null) {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: leader has a home");
|
||||
if (isSafeLocation(tlh)) {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: team leader's home is safe");
|
||||
plugin.getPlayers().setHomeLocation(playerUUID, tlh, number);
|
||||
return tlh.clone().add(new Vector(0.5D,0,0.5D));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: player is not in team - trying island location");
|
||||
l = plugin.getIslands().getIslandLocation(playerUUID);
|
||||
if (isSafeLocation(l)) {
|
||||
plugin.getPlayers().setHomeLocation(playerUUID, l, number);
|
||||
@ -616,24 +636,28 @@ public class IslandsManager {
|
||||
plugin.getLogger().warning(plugin.getPlayers().getName(playerUUID) + " player has no island!");
|
||||
return null;
|
||||
}
|
||||
//plugin.getLogger().info("DEBUG: If these island locations are not safe, then we need to get creative");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: If these island locations are not safe, then we need to get creative");
|
||||
// If these island locations are not safe, then we need to get creative
|
||||
// Try the default location
|
||||
//plugin.getLogger().info("DEBUG: default");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: try default location");
|
||||
Location dl = new Location(l.getWorld(), l.getX() + 0.5D, l.getY() + 5D, l.getZ() + 2.5D, 0F, 30F);
|
||||
if (isSafeLocation(dl)) {
|
||||
plugin.getPlayers().setHomeLocation(playerUUID, dl, number);
|
||||
return dl;
|
||||
}
|
||||
// Try just above the bedrock
|
||||
//plugin.getLogger().info("DEBUG: above bedrock");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: above bedrock");
|
||||
dl = new Location(l.getWorld(), l.getX() + 0.5D, l.getY() + 5D, l.getZ() + 0.5D, 0F, 30F);
|
||||
if (isSafeLocation(dl)) {
|
||||
plugin.getPlayers().setHomeLocation(playerUUID, dl, number);
|
||||
return dl;
|
||||
}
|
||||
// Try all the way up to the sky
|
||||
//plugin.getLogger().info("DEBUG: try all the way to the sky");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: try all the way to the sky");
|
||||
for (int y = l.getBlockY(); y < 255; y++) {
|
||||
final Location n = new Location(l.getWorld(), l.getX() + 0.5D, y, l.getZ() + 0.5D);
|
||||
if (isSafeLocation(n)) {
|
||||
@ -641,7 +665,8 @@ public class IslandsManager {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
//plugin.getLogger().info("DEBUG: unsuccessful");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: unsuccessful");
|
||||
// Unsuccessful
|
||||
return null;
|
||||
}
|
||||
|
@ -117,26 +117,31 @@ public class PlayersManager{
|
||||
public Players addPlayer(final UUID playerUUID) {
|
||||
if (playerUUID == null)
|
||||
return null;
|
||||
//plugin.getLogger().info("DEBUG: adding player " + playerUUID);
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: adding player " + playerUUID);
|
||||
if (!playerCache.containsKey(playerUUID)) {
|
||||
//plugin.getLogger().info("DEBUG: player not in cache");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: player not in cache");
|
||||
Players player = null;
|
||||
// If the player is in the database, load it, otherwise create a new player
|
||||
if (handler.objectExits(playerUUID.toString())) {
|
||||
//plugin.getLogger().info("DEBUG: player in database");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: player in database");
|
||||
try {
|
||||
player = handler.loadObject(playerUUID.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
//plugin.getLogger().info("DEBUG: new player");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: new player");
|
||||
player = new Players(playerUUID);
|
||||
}
|
||||
playerCache.put(playerUUID, player);
|
||||
return player;
|
||||
} else {
|
||||
//plugin.getLogger().info("DEBUG: known player");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: known player");
|
||||
return playerCache.get(playerUUID);
|
||||
}
|
||||
}
|
||||
|
@ -61,11 +61,16 @@ public class Players extends DataObject {
|
||||
* @return Location of this home or null if not available
|
||||
*/
|
||||
public Location getHomeLocation(int number) {
|
||||
if (homeLocations.containsKey(number)) {
|
||||
return homeLocations.get(number);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* Bukkit.getLogger().info("DEBUG: getting home location " + number);
|
||||
|
||||
Bukkit.getLogger().info("DEBUG: " + homeLocations.toString());
|
||||
for (Entry<Integer, Location> en : homeLocations.entrySet()) {
|
||||
Bukkit.getLogger().info("DEBUG: " + en.getKey() + " ==> " + en.getValue());
|
||||
if (number == en.getKey())
|
||||
Bukkit.getLogger().info("DEBUG: key = number");
|
||||
}*/
|
||||
return homeLocations.get(Integer.valueOf(number));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,6 +112,7 @@ public class Players extends DataObject {
|
||||
* @param homeLocations the homeLocations to set
|
||||
*/
|
||||
public void setHomeLocations(HashMap<Integer, Location> homeLocations) {
|
||||
Bukkit.getLogger().info("DEBUG: " + homeLocations.toString());
|
||||
this.homeLocations = homeLocations;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -216,6 +217,13 @@ public class SafeSpotTeleport {
|
||||
Vector velocity = entity.getVelocity();
|
||||
entity.teleport(destination);
|
||||
entity.setVelocity(velocity);
|
||||
// Exit spectator mode if in it
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player)entity;
|
||||
if (player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
}
|
||||
}});
|
||||
} else {
|
||||
// We did not find a spot
|
||||
|
Loading…
Reference in New Issue
Block a user