本文整理匯總了Java中org.bukkit.event.player.PlayerTeleportEvent.getFrom方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerTeleportEvent.getFrom方法的具體用法?Java PlayerTeleportEvent.getFrom怎麽用?Java PlayerTeleportEvent.getFrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.player.PlayerTeleportEvent
的用法示例。
在下文中一共展示了PlayerTeleportEvent.getFrom方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerTeleport(PlayerTeleportEvent event) {
if (event.isCancelled()) {
return;
}
Location from = event.getFrom();
Location to = event.getTo();
if (from.getWorld().equals(to.getWorld())) {
return;
}
ConsoleLogger.debug("[EVENTS] Player '" + event.getPlayer().getName() + "' going from world '" + from + "' to world '" + to + "'");
Group groupFrom = groupManager.getGroupFromWorld(from.getWorld().getName());
Group groupTo = groupManager.getGroupFromWorld(to.getWorld().getName());
if (groupFrom.equals(groupTo)) {
return;
}
playerManager.addPlayer(event.getPlayer(), groupFrom);
event.getPlayer().closeInventory();
}
示例2: 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);
}
}
}
示例3: onTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent event) {
if (event.getTo() == null || event.getFrom() == null || !event.getFrom().getWorld().equals(event.getTo().getWorld())) {
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location");
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot");
org.bukkit.Location to = event.getTo();
if (to != null) {
Player player = event.getPlayer();
PlotPlayer pp = PlotPlayer.wrap(player);
Location loc = BukkitUtil.getLocation(to);
PlotArea area = PS.get().getPlotAreaAbs(loc);
if (area == null) {
return;
}
Plot plot = area.getPlot(loc);
if (plot != null) {
plotEntry(pp, plot);
}
}
return;
}
playerMove(event);
}
示例4: onTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent event)
{
Location from = event.getFrom();
Location to = event.getTo();
PlayerTeleport action = this.newAction(PlayerTeleport.class, from.getWorld());
if (action != null)
{
action.setLocation(from);
action.setOtherLocation(to, true);
action.setPlayer(event.getPlayer());
this.logAction(action);
}
PlayerTeleport action2 = this.newAction(PlayerTeleport.class, to.getWorld());
if (action2 != null)
{
action2.setLocation(to);
action2.setOtherLocation(from, false);
action2.setPlayer(event.getPlayer());
this.logAction(action2);
}
}
示例5: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(PlayerTeleportEvent event) {
// Strangely, sometimes these worlds can be null
if (event.getFrom() == null || event.getTo() == null) {
return;
}
// Check if they changed worlds
UUID uuid = event.getPlayer().getUniqueId();
if (plugin.getPlayerGHouse(uuid) == null || plugin.getPlayerGHouse(uuid).isEmpty()) {
return;
}
World fromWorld = event.getFrom().getWorld();
World toWorld = event.getTo().getWorld();
// Check we are in the right world
if (!Settings.worldName.contains(fromWorld.getName()) && !Settings.worldName.contains(toWorld.getName())) {
return;
}
// Did we move a block?
checkMove(event.getPlayer(), event.getFrom(), event.getTo(), uuid);
}
示例6: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
private void onPlayerTeleport(PlayerTeleportEvent event) {
if (event.getTo() == null) {
NucMsg.warning("Teleport using a null destination location detected.");
return;
}
if (event.getTo().getWorld() == null) {
NucMsg.warning("Teleport using a null world in destination location detected.");
return;
}
if (event.getFrom() != null && event.getTo().getWorld().equals(event.getFrom().getWorld()))
return;
synchronized (_sync) {
_lastWorldChange.put(event.getPlayer(), new Date());
}
}
示例7: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
private void onPlayerTeleport(PlayerTeleportEvent event) {
if (event.getFrom() == null || event.getTo() == null)
return;
// player teleporting to a different world
if (!event.getFrom().getWorld().equals(event.getTo().getWorld())) {
PlayList.clearQueue(event.getPlayer());
}
if (event.getCause() != TeleportCause.UNKNOWN) {
_regionManager.getPlayerWatcher()
.updatePlayerLocation(event.getPlayer(), event.getTo(), RegionEventReason.TELEPORT);
}
}
示例8: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
TeleportCause cause = event.getCause();
if(cause == null || cause != TeleportCause.NETHER_PORTAL) return;
Location from = event.getFrom();
if(from.getBlock().getType() != Material.PORTAL)
{
event.setCancelled(true);
return;
}
Player player = event.getPlayer();
Flag flag = this.GetFlagInstanceAtLocation(from, player);
if(flag == null) return;
event.setCancelled(true);
String [] commandLines = flag.parameters.replace("%name%", player.getName()).replace("%uuid%", player.getUniqueId().toString()).split(";");
for(String commandLine : commandLines)
{
GPFlags.AddLogEntry("Nether portal command: " + commandLine);
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandLine);
}
}
示例9: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) {
Player player = event.getPlayer();
Location from = event.getFrom();
Location to = event.getTo();
if (from != null && to != null && !this.canTeleport(player, from.getWorld(), to.getWorld())) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You cannot leave the world until the bloodmoon has ended.");
}
}
示例10: 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());
}
}
}
示例11: a
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
public void a(double d0, double d1, double d2, float f, float f1) {
// CraftBukkit start - Delegate to teleport(Location)
Player player = this.getPlayer();
Location from = player.getLocation();
Location to = new Location(this.getPlayer().getWorld(), d0, d1, d2, f, f1);
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to, PlayerTeleportEvent.TeleportCause.UNKNOWN);
this.server.getPluginManager().callEvent(event);
from = event.getFrom();
to = event.isCancelled() ? from : event.getTo();
this.teleport(to);
}
示例12: onTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(final PlayerTeleportEvent event) {
if (event.getTo() == null || event.getFrom() == null) {
return;
}
final Location f = BukkitUtil.getLocation(event.getFrom());
final Location t = BukkitUtil.getLocation(event.getTo());
final Location q = new Location(t.getWorld(), t.getX(), 64, t.getZ());
final Player player = event.getPlayer();
if (PlotSquared.isPlotWorld(q.getWorld())) {
final Plot plot = MainUtil.getPlot(q);
if (plot != null) {
final PlotPlayer pp = BukkitUtil.getPlayer(player);
if (plot.isDenied(pp.getUUID())) {
if (Permissions.hasPermission(pp, "plots.admin.enter.denied")) {
return;
}
MainUtil.sendMessage(pp, C.YOU_BE_DENIED);
event.setCancelled(true);
return;
} else {
if (MainUtil.enteredPlot(f, t)) {
plotEntry(pp, plot);
}
}
} else {
if (MainUtil.leftPlot(f, t)) {
final Plot plot2 = MainUtil.getPlot(f);
APlotListener.manager.plotExit(BukkitUtil.getPlayer(player), plot2);
}
}
if ((q.getX() >= 29999999) || (q.getX() <= -29999999) || (q.getZ() >= 29999999) || (q.getZ() <= -29999999)) {
event.setCancelled(true);
return;
}
}
}
示例13: onPlayerTeleport
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent e) {
Location from = e.getFrom();
Location to = e.getTo();
final Player p = e.getPlayer();
// Wait till the chunk should have loaded on the client
// Update IF worlds are different OR chunks are different (as many teleports are in same chunk)
if (!from.getWorld().getName().equals(to.getWorld().getName())
|| from.getChunk().getX() != to.getChunk().getX()
|| from.getChunk().getZ() != to.getChunk().getZ()) {
// Wait for 15 ticks before we actually put it in the queue
new BukkitRunnable() {
@Override
public void run() {
plugin.getUpdater().beforeNext(new Runnable() {
@Override
public void run() {
if (p.isOnline()) {
for (Shop shop : plugin.getShopUtils().getShops()) {
if (shop.hasItem()) {
shop.getItem().hidePlayer(p);
}
if (shop.hasHologram()) {
shop.getHologram().hidePlayer(p);
}
}
// so next update will update correctly
plugin.getShopUtils().resetPlayerLocation(p);
}
}
});
}
}.runTaskLater(plugin, 15L);
}
}
示例14: setPlayerLocation
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
public void setPlayerLocation(double p_147364_1_, double p_147364_3_, double p_147364_5_, float p_147364_7_, float p_147364_8_)
{
// CraftBukkit start - Delegate to teleport(Location)
Player player = this.getPlayerB();
Location from = player.getLocation();
Location to = new Location(this.getPlayerB().getWorld(), p_147364_1_, p_147364_3_, p_147364_5_, p_147364_7_, p_147364_8_);
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to, PlayerTeleportEvent.TeleportCause.UNKNOWN);
this.server.getPluginManager().callEvent(event);
from = event.getFrom();
to = event.isCancelled() ? from : event.getTo();
this.teleport(to);
}
示例15: TeleporZone
import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler
public void TeleporZone(PlayerTeleportEvent event)
{
BytecraftPlayer player = plugin.getPlayer(event.getPlayer());
Location to = event.getTo();
Location from = event.getFrom();
ZoneWorld toWorld = plugin.getWorld(to.getWorld());
Zone newZone = toWorld.findZone(to);
String newName;
ZoneWorld fromWorld = plugin.getWorld(from.getWorld());
Zone fromZone = fromWorld.findZone(from);
String fromName;
if (fromZone == null && newZone == null) {
return;
}
if (fromZone == null) {
fromName = "null";
} else {
fromName = fromZone.getName();
}
if (newZone == null) {
newName = "null";
} else {
newName = newZone.getName();
}
if (fromName.equalsIgnoreCase(newName)) {
return;
}
PlayerChangeZoneEvent customEvent = new PlayerChangeZoneEvent(to, from, player, fromZone, newZone);
Bukkit.getServer().getPluginManager().callEvent(customEvent);
}