本文整理汇总了Java中org.bukkit.event.player.PlayerTeleportEvent.setTo方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerTeleportEvent.setTo方法的具体用法?Java PlayerTeleportEvent.setTo怎么用?Java PlayerTeleportEvent.setTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerTeleportEvent
的用法示例。
在下文中一共展示了PlayerTeleportEvent.setTo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPearlClip
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPearlClip(PlayerTeleportEvent event) {
if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
Location to = event.getTo();
if (blockedPearlTypes.contains(to.getBlock().getType())) {
Player player = event.getPlayer();
player.sendMessage(ChatColor.YELLOW + "You have been detected trying to pearl glitch, your pearl has been refunded and cooldown wiped.");
plugin.getTimerManager().getEnderPearlTimer().refund(player);
event.setCancelled(true);
return;
}
to.setX(to.getBlockX() + 0.5);
to.setZ(to.getBlockZ() + 0.5);
event.setTo(to);
}
}
示例2: onPearlClip
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPearlClip(PlayerTeleportEvent event) {
if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
Location to = event.getTo();
if (blockedPearlTypes.contains(to.getBlock().getType())) {
Player player = event.getPlayer();
player.sendMessage(ChatColor.RED + "You cannot pearl there.");
removeCooldown(player);
event.setCancelled(true);
return;
}
to.setX(to.getBlockX() + 0.5D);
to.setZ(to.getBlockZ() + 0.5D);
event.setTo(to);
}
}
示例3: on
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler (priority = EventPriority.MONITOR)
public void on(PlayerTeleportEvent event) {
if (!config.isPatchesForceAllowTeleportation()) {
return;
}
Storage storage = Storage.get(event.getPlayer());
Object value = storage.get("teleportedTo");
if (value == null) {
return;
}
storage.remove("teleportedTo");
event.setTo((Location) value);
event.setCancelled(false);
}
示例4: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(final PlayerTeleportEvent event)
{
final IUser user = ess.getUserMap().getUser(event.getPlayer());
if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
{
return;
}
try
{
event.setTo(getJail(user.getData().getJail()));
}
catch (Exception ex)
{
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()), ex);
}
else
{
LOGGER.log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()));
}
}
user.sendMessage(_("§4You do the crime, you do the time."));
}
示例5: onTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled=true, priority=EventPriority.NORMAL)
public void onTeleport(PlayerTeleportEvent event) {
if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
Location to = event.getTo();
if (this.blockedTypes.contains(to.getBlock().getType())) {
event.setCancelled(true);
return;
}
to.setX(to.getBlockX() + 0.5D);
to.setZ(to.getBlockZ() + 0.5D);
event.setTo(to);
}
}
示例6: onTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler
public void onTeleport(PlayerTeleportEvent event) {
final Player player = event.getPlayer();
HeightMapMCAGenerator gen = getGenerator(player);
if (gen != null) {
Location from = event.getFrom();
Location to = event.getTo();
if (to.getWorld().equals(from.getWorld()) && to.distanceSquared(from) < 8) {
event.setTo(player.getLocation());
event.setCancelled(true);
player.setVelocity(player.getVelocity());
}
}
}
示例7: onTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onTeleport(final PlayerTeleportEvent e) {
//
// plugin.getLogger().info("DEBUG: Teleport called");
Player player = e.getPlayer();
if (SafeBoat.ignoreList.contains(player.getUniqueId())) {
return;
}
// If the player is not teleporting due to boat exit, return
if (!exitedBoat.containsKey(player.getUniqueId())) {
return;
}
// Entity boat = exitedBoat.get(player.getUniqueId());
// Reset the flag
exitedBoat.remove(player.getUniqueId());
// Okay, so a player is getting out of a boat in the the right world.
// Now...
//plugin.getLogger().info("DEBUG: Player just exited a boat");
// Find a safe place for the player to land
int radius = 0;
while (radius++ < 2) {
for (int x = player.getLocation().getBlockX() - radius; x < player.getLocation().getBlockX() + radius; x++) {
for (int z = player.getLocation().getBlockZ() - radius; z < player.getLocation().getBlockZ() + radius; z++) {
for (int y = player.getLocation().getBlockY(); y < player.getLocation().getBlockY() + 2; y++) {
// The safe location to tp to is actually +0.5 to x and
// z.
final Location loc = new Location(player.getWorld(), (double) (x + 0.5), (double) y, (double) (z + 0.5));
// plugin.getLogger().info("XYZ is " + x + " " + y + " "
// + z);
// Make sure the location is safe
if (GridManager.isSafeLocation(loc)) {
// plugin.getLogger().info("Safe!");
e.setTo(loc);
return;
}
}
}
}
}
}
示例8: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
if (testObserver(event.getPlayer())) {
if (event.getTo().getY() <= -64) {
TeamModule teamModule = Teams.getTeamById("observers").get();
ModuleCollection<SpawnModule> modules = new ModuleCollection<>();
for (SpawnModule spawnModule : match.getModules().getModules(SpawnModule.class)) {
if (spawnModule.getTeam() == teamModule) modules.add(spawnModule);
}
event.setTo(modules.getRandom().getLocation());
}
}
}