本文整理匯總了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());
}
}
}