本文整理汇总了Java中org.bukkit.event.player.PlayerPortalEvent.getPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerPortalEvent.getPlayer方法的具体用法?Java PlayerPortalEvent.getPlayer怎么用?Java PlayerPortalEvent.getPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerPortalEvent
的用法示例。
在下文中一共展示了PlayerPortalEvent.getPlayer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerPortal
import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerPortal(PlayerPortalEvent event) {
if (plugin.UseQuickPortals) return;
Player player = event.getPlayer();
if (!player.hasPermission("cuteportals.use")) {
player.sendMessage(ChatColor.DARK_RED + "You don't have permission to use portals.");
return;
}
Block block = player.getWorld().getBlockAt(player.getLocation());
String data = String.format("%s#%s#%s#%s", block.getWorld().getName(),
String.valueOf(block.getX()), String.valueOf(block.getY()), String.valueOf(block.getZ()));
if (plugin.portalData.containsKey(data)) {
String[] args = plugin.portalData.get(data).split("#");
plugin.TransferPlayer(player, args[0], args[1]);
event.setCancelled(true);
}
}
示例2: ClassChanger
import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void ClassChanger(final PlayerPortalEvent event)
{
if(Game.isGameRunning() && event.getPlayer().getGameMode() != GameMode.CREATIVE)
{
AnniPlayer p = AnniPlayer.getPlayer(event.getPlayer().getUniqueId());
if(p != null)
{
event.setCancelled(true);
if(p.getTeam() != null)
{
final Player pl = event.getPlayer();
pl.teleport(p.getTeam().getRandomSpawn());
Bukkit.getScheduler().runTaskLater(AnnihilationMain.getInstance(), new Runnable(){
@Override
public void run()
{
openKitMap(pl);
}}, 40);
}
}
}
}
示例3: onPlayerEnterPortal
import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerEnterPortal(PlayerPortalEvent e){
Player p = e.getPlayer();
Region rto = null;
Region from = null;
if (e.getTo() != null){
rto = RedProtect.get().rm.getTopRegion(e.getTo());
}
if (e.getFrom() != null){
from = RedProtect.get().rm.getTopRegion(e.getFrom());
}
if (rto != null && !rto.canExitPortal(p)){
RPLang.sendMessage(p, "playerlistener.region.cantteleport");
e.setCancelled(true);
}
if (from != null && !from.canEnterPortal(p)){
RPLang.sendMessage(p, "playerlistener.region.cantenterteleport");
e.setCancelled(true);
}
}
示例4: onPortalEvent
import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPortalEvent(PlayerPortalEvent event) {
Player player = event.getPlayer();
if (usePortals || event.getTo() == null || event.getFrom() == null ||
(!plugin.isSkyWorld(event.getTo().getWorld()) && !plugin.isSkyWorld(event.getFrom().getWorld())))
{
return; // We only care about portals going into or out of skyworld
}
if (hasPermission(player, "usb.mod.bypassprotection") || plugin.playerIsOnIsland(player) || plugin.playerIsInSpawn(player)) {
return;
}
if (event.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL ||
event.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL) {
us.talabrek.ultimateskyblock.api.IslandInfo islandInfo = plugin.getIslandInfo(player);
if (islandInfo == null || (!islandInfo.contains(event.getTo()) && !islandInfo.contains(event.getFrom()))) {
event.setCancelled(true);
player.sendMessage(tr("\u00a7eYou can not use another islands portals!"));
}
}
}
示例5: onPlayerPortal
import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerPortal(PlayerPortalEvent event) {
EntityPortalEvent e = new EntityPortalEvent(event.getPlayer(), event.getFrom(), event.getTo(), event.getPortalTravelAgent());
this.onEntityPortal(e);
event.setFrom(e.getFrom());
event.setTo(e.getTo());
event.setPortalTravelAgent(e.getPortalTravelAgent());
event.useTravelAgent(e.useTravelAgent());
}
示例6: onPlayerPortal
import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerPortal(PlayerPortalEvent e) {
final Player player = e.getPlayer();
player.setHealth(0D);
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
public void run() {
Util.showClassSelector(player, "Select Class");
}
}, 4l);
}
示例7: onPlayerPortal
import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerPortal(PlayerPortalEvent e) {
final Player player = e.getPlayer();
player.setHealth(0D);
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
Util.showClassSelector(player, "Select Class");
}
}, 4l);
}
示例8: onPortalEnter
import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPortalEnter(PlayerPortalEvent event) {
if (event.getCause() != PlayerTeleportEvent.TeleportCause.END_PORTAL) {
return;
}
Location to = event.getTo();
World toWorld = to.getWorld();
if (toWorld == null)
return; // safe-guard if the End or Nether is disabled
if (toWorld.getEnvironment() == World.Environment.THE_END) {
Player player = event.getPlayer();
// Prevent entering the end if it's closed.
if (false /* TODO:plugin.getEndManager().isOpened() */) {
message(player, ChatColor.RED + "The End is currently closed.");
event.setCancelled(true);
return;
}
// Prevent entering the end if the player is Spawn Tagged.
PlayerTimer timer = plugin.getTimerManager().getCombatTimer();
long remaining;
if ((remaining = timer.getRemaining(player)) > 0L) {
message(player, ChatColor.RED + "You cannot enter the End whilst your " + timer.getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD
+ DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + " remaining]");
event.setCancelled(true);
return;
}
// Prevent entering the end if the player is PVP Protected.
timer = plugin.getTimerManager().getInvincibilityTimer();
if ((remaining = timer.getRemaining(player)) > 0L) {
message(player, ChatColor.RED + "You cannot enter the End whilst your " + timer.getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD
+ DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + " remaining]");
event.setCancelled(true);
return;
}
event.useTravelAgent(false);
event.setTo(toWorld.getSpawnLocation().add(0.5, 0, 0.5));
}
}
示例9: onPlayerPortal
import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerPortal(final PlayerPortalEvent event) {
if (event.isCancelled()) {
return;
}
final Player player = event.getPlayer();
// Ok so a player portal event begins
// Find the nearest gate!
final WorldCoord playerCoord = new WorldCoord(this.playerLocationAtEvent.get(player));
final Gate nearestGate = Gates.gateFromPortal(playerCoord);
if (nearestGate != null) {
event.setCancelled(true);
// Check teleportation method
if (!Conf.useVanillaPortals) {
return;
}
// Check player is not carrying a passenger
if (player.getPassenger() != null) {
return;
}
// Get current time
final Long now = Calendar.getInstance().getTimeInMillis();
// Check player has passed cooldown period
if (Plugin.lastTeleportTime.containsKey(player.getName()) && Plugin.lastTeleportTime.get(player.getName()) > now - Conf.getGateCooldownMillis()) {
return;
}
// Check player has permission to enter the gate.
if (!Plugin.hasPermManage(player, "ancientgates.use." + nearestGate.getId()) && !Plugin.hasPermManage(player, "ancientgates.use.*") && Conf.enforceAccess) {
player.sendMessage("You lack the permissions to enter this gate.");
return;
}
// Handle economy (check player has funds to use gate)
if (!Plugin.handleEconManage(player, nearestGate.getCost())) {
player.sendMessage("This gate costs: " + nearestGate.getCost() + ". You have insufficient funds.");
return;
}
// Handle BungeeCord gates (BungeeCord support disabled)
if (nearestGate.getBungeeTo() != null && Conf.bungeeCordSupport == false) {
player.sendMessage(String.format("BungeeCord support not enabled."));
return;
}
// Teleport the player (Nether method)
if (nearestGate.getTo() == null && nearestGate.getBungeeTo() == null && nearestGate.getCommand() == null) {
player.sendMessage(String.format("This gate does not point anywhere :P"));
} else if (nearestGate.getTo() != null) {
TeleportUtil.teleportPlayer(player, nearestGate.getTo(), nearestGate.getTeleportEntities(), nearestGate.getTeleportInventory());
if (nearestGate.getCommand() != null)
ExecuteUtil.execCommand(player, nearestGate.getCommand(), nearestGate.getCommandType());
if (nearestGate.getMessage() != null)
player.sendMessage(nearestGate.getMessage());
Plugin.lastTeleportTime.put(player.getName(), now);
} else if (nearestGate.getBungeeTo() != null) {
TeleportUtil.teleportPlayer(player, nearestGate.getBungeeTo(), nearestGate.getBungeeType(), nearestGate.getTeleportEntities(), nearestGate.getTeleportInventory(), false, nearestGate.getCommand(), nearestGate.getCommandType(),
nearestGate.getMessage());
} else {
ExecuteUtil.execCommand(player, nearestGate.getCommand(), nearestGate.getCommandType(), true);
Plugin.lastTeleportTime.put(player.getName(), now);
}
}
}