本文整理汇总了Java中org.bukkit.event.player.PlayerTeleportEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerTeleportEvent类的具体用法?Java PlayerTeleportEvent怎么用?Java PlayerTeleportEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlayerTeleportEvent类属于org.bukkit.event.player包,在下文中一共展示了PlayerTeleportEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent e) { // ����Ҵ��ͺ���¾�����
final Game bw = io.github.bedwarsrel.BedwarsRel.Main.getInstance()
.getGameManager().getGameOfPlayer(e.getPlayer());
if (bw == null) {
return;
}
if (!Config.isGameEnabledXP(bw.getName())) {
return;
}
final Player p = e.getPlayer();
Bukkit.getScheduler().runTaskLater(Main.plugin, new Runnable() {
@Override
public void run() {
XPManager.updateXPBar(bw.getName(), p);
}
}, 5);
}
示例2: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent e) { // ����Ҵ��ͺ���¾�����
final Game bw = io.github.yannici.bedwars.Main.getInstance()
.getGameManager().getGameOfPlayer(e.getPlayer());
if (bw == null) {
return;
}
if (!Config.isGameEnabledXP(bw.getName())) {
return;
}
final Player p = e.getPlayer();
Bukkit.getScheduler().runTaskLater(Main.plugin, new Runnable() {
@Override
public void run() {
XPManager.updateXPBar(bw.getName(), p);
}
}, 5);
}
示例3: spawnPlayer
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
public void spawnPlayer(PlayerContext playerContext, MatchTeam matchTeam, boolean teleport) {
Players.reset(playerContext.getPlayer(), true);
if (matchTeam.isSpectator()) {
spectatorModule.applySpectatorKit(playerContext);
if (teleport) {
playerContext.getPlayer().teleport(getTeamSpawn(matchTeam).getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
}
} else {
matchTeam.getKits().forEach(kit -> kit.apply(playerContext.getPlayer(), matchTeam));
playerContext.getPlayer().updateInventory();
if (teleport) {
playerContext.getPlayer().teleport(getTeamSpawn(matchTeam).getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
playerContext.getPlayer().setGameMode(GameMode.SURVIVAL);
}
}
}
示例4: run
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
@Override
public void run(WCUser user, String label, String[] args) {
WCUser target = user;
if (args.length != 0) {
target = WCServer.getUser(plugin.getServer().getPlayer(args[0]));
if (!target.isOnline()) {
userNotOnline(user);
return;
}
}
for (Player p : plugin.getServer().getOnlinePlayers()) {
p.teleport(target.getPlayer().getLocation(), PlayerTeleportEvent.TeleportCause.COMMAND);
}
user.sendMessagePrefix("&6Todos los jugadores han sido teletransportados");
}
示例5: run
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
@Override
public void run(WCUser user, String label, String[] args) {
if (args.length != 3) {
user.sendMessage("&eUsa: /" + label + " <x> <y> <z>");
return;
}
Double x, y, z;
try {
x = Double.parseDouble(args[0]);
y = Double.parseDouble(args[1]);
z = Double.parseDouble(args[2]);
} catch (NumberFormatException e) {
user.sendMessage("&eUsa: /" + label + " <x> <y> <z> (Deben ser números de coordenadas)");
return;
}
Location loc = new Location(user.getPlayer().getWorld(), x, y, z);
user.getPlayer().teleport(loc, PlayerTeleportEvent.TeleportCause.COMMAND);
user.sendMessage("&6Teleportando a &e" + x + "&6, &e" + y + "&6, &e" + z);
}
示例6: run
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
@Override
public void run(WCUser user, String label, String[] args) {
if (args.length == 0) {
user.sendMessage("");
return;
}
WCUser target = WCServer.getUser(plugin.getServer().getPlayer(args[0]));
if (!target.isOnline()) {
userNotOnline(user);
return;
}
target.getPlayer().teleport(user.getPlayer().getLocation(), PlayerTeleportEvent.TeleportCause.COMMAND);
user.sendMessage("");
}
示例7: resetPosition
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
/**
* Modify the to location of the given event to prevent the movement and
* move the player so they are standing on the center of the block at the
* from location.
*/
private static void resetPosition(final PlayerMoveEvent event) {
Location newLoc;
double yValue = event.getFrom().getY();
if(yValue <= 0 || event instanceof PlayerTeleportEvent) {
newLoc = event.getFrom();
} else {
newLoc = BlockUtils.center(event.getFrom()).subtract(new Vector(0, 0.5, 0));
if(newLoc.getBlock() != null) {
switch(newLoc.getBlock().getType()) {
case STEP:
case WOOD_STEP:
newLoc.add(new Vector(0, 0.5, 0));
break;
default: break;
}
}
}
newLoc.setPitch(event.getTo().getPitch());
newLoc.setYaw(event.getTo().getYaw());
event.setCancelled(false);
event.setTo(newLoc);
}
示例8: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) {
final Player player = event.getPlayer();
final int visibleDistance = server.getViewDistance() * 16;
// Fix the visibility issue one tick later
server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
// Refresh nearby clients
String version;
version = Bukkit.getServer().getClass().getPackage().getName();
if (version.contains("v1_11")) {
TeleportFix_1_11.updateEntities(getPlayersWithin(player, visibleDistance));
} else if (version.contains("v1_12")) {
TeleportFix_1_12.updateEntities(getPlayersWithin(player, visibleDistance));
}
//System.out.println("Applying fix ... " + visibleDistance);
}
}, TELEPORT_FIX_DELAY);
}
示例9: onTeleportEvent
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
@EventHandler
public void onTeleportEvent(PlayerTeleportEvent e) {
final Player player = e.getPlayer();
if (teleportBetweenWorlds(e.getTo().getWorld(), e.getFrom().getWorld()) && teleportToLobby(e.getTo().getWorld())) {
SkyWarsReloaded.get().getServer().getScheduler().scheduleSyncDelayedTask(SkyWarsReloaded.get(), new Runnable() {
public void run() {
if (player != null) {
givePlayerItems(player);
}
}
}, 8);
} else if (teleportBetweenWorlds(e.getTo().getWorld(), e.getFrom().getWorld()) && !teleportToLobby(e.getTo().getWorld())) {
SkyWarsReloaded.get().getServer().getScheduler().scheduleSyncDelayedTask(SkyWarsReloaded.get(), new Runnable() {
public void run() {
if (player != null) {
removePlayerItems(player);
}
}
}, 8);
}
}
示例10: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
@EventHandler
public void teleport(PlayerTeleportEvent e){
if(e.getPlayer().hasMetadata("NPC"))return;
if(!rs.worldExists(e.getTo().getWorld().getName())){
if(rs.getPlayerData(e.getPlayer())==null)return;
rs.deletePlayer(e.getPlayer());
return;
}
if(rs.getPlayerData(e.getPlayer())!=null)return;
Player p=e.getPlayer();
File data=new File(rs.getDataFolder()+File.separator+"PlayerDatas"+File.separator+p.getUniqueId().toString()+".yml");
if(!data.exists()){//�������ļ��Ƿ����,������������ʼ��һ���ļ�
try {data.createNewFile();} catch (IOException e1) {}
PlayerData pd=new PlayerData(p.getUniqueId(),p.getWorld().getName(), rs.getSleepMax(), rs.getThirstMax(), 0, 37, 0, rs.getPhysical_strength());
pd.savaData();
}
rs.addPlayerData(p, Utils.getPlayerData(p));
}
示例11: onPlayerPortal
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerPortal(PlayerPortalEvent event) {
if (event.getCause() != PlayerTeleportEvent.TeleportCause.END_PORTAL) {
return;
}
if (event.getTo() != null) {
World toWorld = event.getTo().getWorld();
if (toWorld != null && toWorld.getEnvironment() == World.Environment.THE_END) {
event.useTravelAgent(false);
event.setTo(toWorld.getSpawnLocation());
return;
}
}
World fromWorld = event.getFrom().getWorld();
if (fromWorld != null && fromWorld.getEnvironment() == World.Environment.THE_END) {
event.useTravelAgent(false);
event.setTo(endExit);
}
}
示例12: 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);
}
}
示例13: onPlayerDamage
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerDamage(EntityDamageEvent event) {
if (event.getCause() == EntityDamageEvent.DamageCause.VOID) {
Entity entity = event.getEntity();
if (entity instanceof Player) {
// Allow players to die by VOID in the END
if (entity.getWorld().getEnvironment() == World.Environment.THE_END) {
return;
}
Location destination = BukkitUtils.getHighestLocation(entity.getLocation());
if (destination == null)
return;
if (entity.teleport(destination, PlayerTeleportEvent.TeleportCause.PLUGIN)) {
event.setCancelled(true);
((Player) entity).sendMessage(ChatColor.YELLOW + "You were saved from the void.");
}
}
}
}
示例14: teleport
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
/**
* Teleports a {@link Player} to a {@link Location} with a delay.
*
* @param player
* the {@link Player} to teleport
* @param location
* the {@link Location} to teleport to
* @param millis
* the time in milliseconds until teleport
* @param warmupMessage
* the message to send whilst waiting
* @param cause
* the cause for teleporting
* @return true if {@link Player} was successfully teleported
*/
public boolean teleport(Player player, Location location, long millis, String warmupMessage, PlayerTeleportEvent.TeleportCause cause) {
cancelTeleport(player, null); // cancels any previous teleport for the player.
boolean result;
if (millis <= 0) { // if there is no delay, just instantly teleport.
result = player.teleport(location, cause);
clearCooldown(player.getUniqueId());
} else {
UUID uuid = player.getUniqueId();
player.sendMessage(warmupMessage);
destinationMap.put(uuid, location.clone());
setCooldown(player, uuid, millis, true, null);
result = true;
}
return result;
}
示例15: run
import org.bukkit.event.player.PlayerTeleportEvent; //导入依赖的package包/类
@Override
public void run(PAUser user, String label, String[] args) {
PAUser target = user;
if (args.length != 0) {
target = PAServer.getUser(plugin.getServer().getPlayer(args[0]));
if (!target.isOnline()) {
userNotOnline(user);
return;
}
}
for (Player p : plugin.getServer().getOnlinePlayers()) {
p.teleport(target.getPlayer().getLocation(), PlayerTeleportEvent.TeleportCause.COMMAND);
}
user.sendMessage(PAData.CORE.getPrefix() + "&6Todos los jugadores han sido teletransportados");
}