本文整理匯總了Java中org.bukkit.event.player.PlayerTeleportEvent.getPlayer方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerTeleportEvent.getPlayer方法的具體用法?Java PlayerTeleportEvent.getPlayer怎麽用?Java PlayerTeleportEvent.getPlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.player.PlayerTeleportEvent
的用法示例。
在下文中一共展示了PlayerTeleportEvent.getPlayer方法的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: 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);
}
示例4: 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);
}
}
示例5: 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));
}
示例6: 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);
}
}
示例7: 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);
}
}
示例8: onPlayerSwitch
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerSwitch(final PlayerTeleportEvent e) {
if(RandomCoords.getPlugin().config.getStringList("OnJoinWorlds") == null ) { return; }
if(e.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL || e.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL) {
return;
}
final List<String> list = RandomCoords.getPlugin().config.getStringList("OnJoinWorlds");
if(list.isEmpty()) { return; }
if(e.getTo().getWorld() == e.getFrom().getWorld()) { return; }
if(list.contains(e.getTo().getWorld().getName())) {
if(e.getTo().getWorld().getPlayers().contains(e.getPlayer())) { return; }
final Player p = e.getPlayer();
//coordinates.finalCoordinates(p, 574272099, 574272099, e.getTo().getWorld(), CoordType.JOINWORLD, 0);
coordinatesManager.randomlyTeleportPlayer(p, e.getTo().getWorld(), coordinatesManager.key, coordinatesManager.key, CoordType.JOINWORLD, 0);
}
}
示例9: playerTeleportEvent
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler
public void playerTeleportEvent(PlayerTeleportEvent event)
{
Player player = event.getPlayer();
PlayerGUIPage playerGUIContainer = PlayerData.getPlayerData(player).getPlayerGUIPage();
if(playerGUIContainer != null)
{
if(event.getCause() != PlayerTeleportEvent.TeleportCause.UNKNOWN)
{
playerGUIContainer.destroy();
PlayerData.getPlayerData(player).setPlayerGUIPage(null);
PlayerData.getPlayerData(player).setPlayerPreviousGUIPage(null);
}
}
}
示例10: onTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler
public void onTeleport(final PlayerTeleportEvent e) {
final Player p = e.getPlayer();
if (e.getCause().equals(TeleportCause.SPECTATE)
&& !(p.hasPermission("essentials.tp"))){
e.setCancelled(true);
p.sendMessage(ChatColor.RED + "You do not have permission to /tp");
}
if (!e.getFrom().getWorld().equals(e.getTo().getWorld())) {
MultiverseCore mv = (MultiverseCore) Bukkit.getServer()
.getPluginManager().getPlugin("Multiverse-Core");
MVWorldManager wm = mv.getMVWorldManager();
MultiverseWorld toWorld = wm.getMVWorld(e.getTo().getWorld()
.getName());
MultiverseWorld fromWorld = wm.getMVWorld(e.getFrom().getWorld()
.getName());
if (toWorld != fromWorld
&& !p.getGameMode().equals(toWorld.getGameMode())) {
p.setGameMode(toWorld.getGameMode());
}
}
}
示例11: onTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onTeleport(final PlayerTeleportEvent event) {
final PlayerStat stat = PlayerStat.TELEPORTS;
// Get player
final Player player = event.getPlayer();
// Do general check
if (!plugin.doGeneralCheck(player, stat))
return;
// Update value to new stat.
plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat,
StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", 1, "world",
event.getFrom().getWorld().getName(), "destWorld", event.getTo().getWorld().getName(), "cause", event.getCause().toString()));
}
示例12: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerTeleportEvent event) {
final Player p = event.getPlayer();
final IPet pi = EchoPet.getManager().getPet(p);
Iterator<IPet> i = EchoPet.getManager().getPets().iterator();
while (i.hasNext()) {
IPet pet = i.next();
if (pet.getEntityPet() instanceof IEntityPacketPet && ((IEntityPacketPet) pet.getEntityPet()).hasInititiated()) {
if (GeometryUtil.getNearbyEntities(event.getTo(), 50).contains(pet)) {
((IEntityPacketPet) pet.getEntityPet()).updatePosition();
}
}
}
if (pi != null) {
if (!WorldUtil.allowPets(event.getTo())) {
Lang.sendTo(p, Lang.PETS_DISABLED_HERE.toString().replace("%world%", WordUtils.capitalizeFully(event.getTo().getWorld().getName())));
EchoPet.getManager().saveFileData("autosave", pi);
EchoPet.getSqlManager().saveToDatabase(pi, false);
EchoPet.getManager().removePet(pi, false);
}
}
}
示例13: on
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void on(PlayerTeleportEvent event) {
if (!isCurrentlyFrozen(event.getPlayer().getUniqueId())) return;
Player player = event.getPlayer();
switch (event.getCause()) {
case PLUGIN:
// skip if it was to the same location as currently set, stops
// resetting particles/metadata on border knockback
if (event.getTo().equals(getFreezeLocation(player).get())) return;
case COMMAND:
case UNKNOWN:
// set new location and reset particles
setFreezeLocation(player, event.getTo());
startParticleSpawning(player, event.getTo());
potionApplier.addPotions(player);
}
}
示例14: onPlayerChangedWorld
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerChangedWorld(PlayerTeleportEvent event){
World from = event.getFrom().getWorld();
World to = event.getTo().getWorld();
if(!from.getUID().equals(to.getUID())){
Player player = event.getPlayer();
if(player.hasPermission("spigotplus.multiworld.leave." + from.getName())){
if(player.hasPermission("spigotplus.multiworld.enter." + to.getName())){
// We don't set the event to be "uncanceled" to avoid interfering with
// the work of other plugins, as we don't care what happens to the event
// provided that by our books it is allowed.
return;
} else {
player.sendMessage(ChatColor.RED + "You are not permitted to enter this world.");
}
} else {
player.sendMessage(ChatColor.RED + "You are not permitted to leave this world.");
}
//event.setTo(event.getFrom());
event.setCancelled(true);
}
}
示例15: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent e){
if (e.isCancelled()) {
return;
}
final Player p = e.getPlayer();
Location lfrom = e.getFrom();
Location lto = e.getTo();
if (e.getCause().equals(PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT)){
final Region rfrom = RedProtect.get().rm.getTopRegion(lfrom);
final Region rto = RedProtect.get().rm.getTopRegion(lto);
if (rfrom != null && !rfrom.canTeleport(p)){
RPLang.sendMessage(p, "playerlistener.region.cantuse");
e.setCancelled(true);
}
if (rto != null && !rto.canTeleport(p)){
RPLang.sendMessage(p, "playerlistener.region.cantuse");
e.setCancelled(true);
}
}
}