Adding ability to save /back location from teleport events outside essentilals

New config setting to turn this on "register-back-in-listener"
Test #1200
CB#1560 / B#1055
This commit is contained in:
ementalo 2011-12-06 22:56:38 +00:00
parent ff13279e6c
commit b9077d91a5
9 changed files with 43 additions and 4 deletions

View File

@ -56,13 +56,12 @@ import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.error.YAMLException;
public class Essentials extends JavaPlugin implements IEssentials
{
public static final int BUKKIT_VERSION = 1538;
public static final int BUKKIT_VERSION = 1560;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);

View File

@ -20,6 +20,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.ItemStack;
@ -225,12 +227,19 @@ public class EssentialsPlayerListener extends PlayerListener
@Override
public void onPlayerTeleport(PlayerTeleportEvent event)
{
{
if (event.isCancelled())
{
return;
}
final User user = ess.getUser(event.getPlayer());
final User user = ess.getUser(event.getPlayer());
//There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports.
if(event.getCause() == TeleportCause.PLUGIN && ess.getSettings().registerBackInListener())
{
user.setLastLocation();
}
if (ess.getSettings().changeDisplayName())
{
user.setDisplayNick();

View File

@ -144,4 +144,6 @@ public interface ISettings extends IConf
boolean getRepairEnchanted();
boolean getIsWorldTeleportPermissions();
boolean registerBackInListener();
}

View File

@ -12,6 +12,7 @@ import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.map.MapView;
@ -803,4 +804,16 @@ public class OfflinePlayer implements Player
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean teleport(Location lctn, TeleportCause tc)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean teleport(Entity entity, TeleportCause tc)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -566,4 +566,10 @@ public class Settings implements ISettings
{
return config.getBoolean("world-teleport-permissions", false);
}
@Override
public boolean registerBackInListener()
{
return config.getBoolean("register-back-in-listener", false);
}
}

View File

@ -239,6 +239,10 @@ oversized-stacksize: 64
# essentials.repair.enchanted
repair-enchanted: true
#Do you want essentials to keep track of previous location for /back in the teleport listener?
#If you set this to true any plugin that uses teleport will have the previous location registered.
register-back-in-listener: false
############################################################
# +------------------------------------------------------+ #
# | EssentialsHome | #

View File

@ -593,4 +593,10 @@ public class FakeServer implements Server
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public OfflinePlayer[] getOfflinePlayers()
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

Binary file not shown.

Binary file not shown.