mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Merge pull request #1042 from manuelgu/feature/tpondeath
Add teleport on death feature
This commit is contained in:
commit
6ea1383027
@ -96,6 +96,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
@ -461,6 +462,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}, 20);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void playerRespawn(PlayerRespawnEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
EventUtil.manager.doDeathTask(pp);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void playerMove(PlayerMoveEvent event) {
|
||||
org.bukkit.Location from = event.getFrom();
|
||||
|
@ -53,7 +53,6 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||
import com.plotsquared.listener.WESubscriber;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -2030,6 +2029,7 @@ public class PS {
|
||||
|
||||
// Teleportation
|
||||
options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN);
|
||||
options.put("teleport.on_death", Settings.TELEPORT_ON_DEATH);
|
||||
options.put("teleport.delay", Settings.TELEPORT_DELAY);
|
||||
|
||||
// WorldEdit
|
||||
@ -2140,6 +2140,7 @@ public class PS {
|
||||
// Teleportation
|
||||
Settings.TELEPORT_DELAY = this.config.getInt("teleport.delay");
|
||||
Settings.TELEPORT_ON_LOGIN = this.config.getBoolean("teleport.on_login");
|
||||
Settings.TELEPORT_ON_DEATH = this.config.getBoolean("teleport.on_death");
|
||||
|
||||
// WorldEdit
|
||||
Settings.QUEUE_COMMANDS = this.config.getBoolean("worldedit.queue-commands");
|
||||
|
@ -82,6 +82,10 @@ public class Settings {
|
||||
* Teleport to path on login
|
||||
*/
|
||||
public static boolean TELEPORT_ON_LOGIN = false;
|
||||
/**
|
||||
* Teleport to path on death
|
||||
*/
|
||||
public static boolean TELEPORT_ON_DEATH = false;
|
||||
/**
|
||||
* Display titles
|
||||
*/
|
||||
|
@ -15,7 +15,6 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Rating;
|
||||
import com.plotsquared.listener.PlayerBlockEventType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
@ -78,6 +77,19 @@ public abstract class EventUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public void doDeathTask(final PlotPlayer pp) {
|
||||
final Plot plot = pp.getCurrentPlot();
|
||||
if (Settings.TELEPORT_ON_DEATH && plot != null) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plot.teleportPlayer(pp);
|
||||
}
|
||||
});
|
||||
MainUtil.sendMessage(pp, C.TELEPORTED_TO_ROAD);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkPlayerBlockEvent(PlotPlayer pp, PlayerBlockEventType type, Location loc, LazyBlock block, boolean notifyPerms) {
|
||||
PlotArea area = PS.get().getPlotAreaAbs(loc);
|
||||
Plot plot;
|
||||
|
Loading…
Reference in New Issue
Block a user