当前位置: 首页>>代码示例>>Java>>正文


Java TravelAgent类代码示例

本文整理汇总了Java中org.bukkit.TravelAgent的典型用法代码示例。如果您正苦于以下问题:Java TravelAgent类的具体用法?Java TravelAgent怎么用?Java TravelAgent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TravelAgent类属于org.bukkit包,在下文中一共展示了TravelAgent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldTeleportBecauseNotItem

import org.bukkit.TravelAgent; //导入依赖的package包/类
@Test
public void shouldTeleportBecauseNotItem() {
    // given
    Pig entity = mock(Pig.class);
    World world = mock(World.class);
    Location from = new Location(world, 1, 2, 3);
    World worldNether = mock(World.class);
    Location to = new Location(worldNether, 1, 2, 3);
    EntityPortalEvent event = new EntityPortalEvent(entity, from, to, mock(TravelAgent.class));

    // when
    listener.onEntityPortalTeleport(event);

    // then
    assertThat(event.isCancelled(), equalTo(false));
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:17,代码来源:EntityPortalEventListenerTest.java

示例2: shouldTeleportBecauseSameGroup

import org.bukkit.TravelAgent; //导入依赖的package包/类
@Test
public void shouldTeleportBecauseSameGroup() {
    // given
    Group group = mockGroup("test_group", GameMode.SURVIVAL, false);

    Item entity = mock(Item.class);

    World world = mock(World.class);
    given(world.getName()).willReturn("test_group");
    Location from = new Location(world, 1, 2, 3);

    World worldNether = mock(World.class);
    given(worldNether.getName()).willReturn("test_group_nether");
    Location to = new Location(worldNether, 1, 2, 3);

    given(groupManager.getGroupFromWorld("test_group")).willReturn(group);
    given(groupManager.getGroupFromWorld("test_group_nether")).willReturn(group);

    EntityPortalEvent event = new EntityPortalEvent(entity, from, to, mock(TravelAgent.class));

    // when
    listener.onEntityPortalTeleport(event);

    // then
    assertThat(event.isCancelled(), equalTo(false));
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:27,代码来源:EntityPortalEventListenerTest.java

示例3: onPortalEvent

import org.bukkit.TravelAgent; //导入依赖的package包/类
/**
 * When a portal event happends
 *
 * @param entityPortalEvent the portal event
 */
@EventHandler
public void onPortalEvent(PlayerPortalEvent entityPortalEvent)
{
    //if we're enabled
    if(isEnabled()) {

        //create a travel agent for the portal
        TravelAgent ta = entityPortalEvent.getPortalTravelAgent();
        //if they're in the nether
        if(entityPortalEvent.getPlayer().getWorld().getEnvironment() == World.Environment.NETHER) {
            //set data from the nether
            ta.setCanCreatePortal(config.getBoolean("PortalRanges.from_nether.allowed"));
            ta.setCreationRadius(config.getInt("PortalRanges.from_nether.creation_radius"));
            ta.setSearchRadius(config.getInt("PortalRanges.from_nether.search_radius"));
        } else {
            //set the data to the nether
            ta.setCanCreatePortal(config.getBoolean("PortalRanges.to_nether.allowed"));
            ta.setCreationRadius(config.getInt("PortalRanges.to_nether.creation_radius"));
            ta.setSearchRadius(config.getInt("PortalRanges.to_nether.search_radius"));
        }
    }
}
 
开发者ID:Eluinhost,项目名称:ultrahardcore,代码行数:28,代码来源:PortalsFeature.java

示例4: onPlayerPortal

import org.bukkit.TravelAgent; //导入依赖的package包/类
/**
 * Patch player teleporting through portals to be INSIDE the world border
 *
 * @param event Event
 */
@EventHandler
public void onPlayerPortal(PlayerPortalEvent event)
{
    if (!this.game.getPlugin().getServer().getAllowNether() || this.game.getSurvivalGameLoop().isNetherClosed())
    {
        event.setCancelled(true);
        return;
    }
    TravelAgent travelAgent = event.getPortalTravelAgent();
    Location destination = travelAgent.findPortal(event.getTo());

    if (destination != null)
    {
        if (!SafePortalsUtils.isInsideBorder(destination))
        {
            event.useTravelAgent(false);
            boolean success = travelAgent.createPortal(event.getTo());

            if (success)
            {
                event.setTo(travelAgent.findPortal(event.getTo()));

                if (!SafePortalsUtils.isSafeSpot(event.getTo()))
                {
                    Location safeTo = SafePortalsUtils.searchSafeSpot(event.getTo());
                    if (safeTo != null)
                    {
                        event.setTo(safeTo);
                    }
                }
            }
        }
    }
    else
    {
        event.useTravelAgent(true);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:44,代码来源:SecurityListener.java

示例5: createPortal

import org.bukkit.TravelAgent; //导入依赖的package包/类
public static Location createPortal(Location targetLoc, int radius, TravelAgent travelAgent) {
    travelAgent.setCanCreatePortal(true);
    travelAgent.setCreationRadius(radius);
    travelAgent.setSearchRadius(radius);
    if (travelAgent.createPortal(targetLoc)) {
        return travelAgent.findPortal(targetLoc);
    } else {
        return null;
    }
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:11,代码来源:ExprNewPortal.java

示例6: shouldNotTeleportBecauseDifferentGroups

import org.bukkit.TravelAgent; //导入依赖的package包/类
@Test
public void shouldNotTeleportBecauseDifferentGroups() {
    // given
    Group group = mockGroup("test_group", GameMode.SURVIVAL, false);
    Group otherGroup = mockGroup("other_group", GameMode.SURVIVAL, false);

    Item entity = mock(Item.class);

    World world = mock(World.class);
    given(world.getName()).willReturn("test_group");
    Location from = new Location(world, 1, 2, 3);

    World worldNether = mock(World.class);
    given(worldNether.getName()).willReturn("other_group_nether");
    Location to = new Location(worldNether, 1, 2, 3);

    given(groupManager.getGroupFromWorld("test_group")).willReturn(group);
    given(groupManager.getGroupFromWorld("other_group_nether")).willReturn(otherGroup);

    EntityPortalEvent event = new EntityPortalEvent(entity, from, to, mock(TravelAgent.class));

    // when
    listener.onEntityPortalTeleport(event);

    // then
    assertThat(event.isCancelled(), equalTo(true));
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:28,代码来源:EntityPortalEventListenerTest.java

示例7: travelToDimension

import org.bukkit.TravelAgent; //导入依赖的package包/类
public void travelToDimension(int p_71027_1_)
{
    if (!this.worldObj.isRemote && !this.isDead)
    {
        this.worldObj.theProfiler.startSection("changeDimension");
        MinecraftServer minecraftserver = MinecraftServer.getServer();
        // CraftBukkit start - Move logic into new function "teleportToLocation"
        // int j = this.dimension;
        // Cauldron start - Allow Forge hotloading on teleport
        WorldServer exitWorld = minecraftserver.worldServerForDimension(p_71027_1_);

        Location enter = this.getBukkitEntity().getLocation();
        Location exit = exitWorld != null ? minecraftserver.getConfigurationManager().calculateTarget(enter, minecraftserver.worldServerForDimension(p_71027_1_)) : null;
        boolean useTravelAgent = exitWorld != null && !(this.dimension == 1 && exitWorld.dimension == 1); // don't use agent for custom worlds or return from THE_END
        // Cauldron start - check if teleporter is instance of TravelAgent before attempting to cast to it
        Teleporter teleporter = exit != null ? ((CraftWorld) exit.getWorld()).getHandle().getDefaultTeleporter() : null;
        TravelAgent agent = (teleporter != null && teleporter instanceof TravelAgent) ? (TravelAgent)teleporter : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT;  // return arbitrary TA to compensate for implementation dependent plugins
        // Cauldron end
        EntityPortalEvent event = new EntityPortalEvent(this.getBukkitEntity(), enter, exit, agent);
        event.useTravelAgent(useTravelAgent);
        event.getEntity().getServer().getPluginManager().callEvent(event);

        if (event.isCancelled() || event.getTo() == null || !this.isEntityAlive())
        {
            return;
        }

        exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
        this.teleportTo(exit, true);
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:32,代码来源:Entity.java

示例8: setSearchRadius

import org.bukkit.TravelAgent; //导入依赖的package包/类
public TravelAgent setSearchRadius(int radius) {
    this.searchRadius = radius;
    return this;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:5,代码来源:CraftTravelAgent.java

示例9: setCreationRadius

import org.bukkit.TravelAgent; //导入依赖的package包/类
public TravelAgent setCreationRadius(int radius) {
    this.creationRadius = radius < 2 ? 0 : radius;
    return this;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:5,代码来源:CraftTravelAgent.java

示例10: EntityPortalEvent

import org.bukkit.TravelAgent; //导入依赖的package包/类
public EntityPortalEvent(final Entity entity, final Location from, final Location to, final TravelAgent pta) {
    super(entity, from, to);
    this.travelAgent = pta;
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:5,代码来源:EntityPortalEvent.java

示例11: PlayerPortalEvent

import org.bukkit.TravelAgent; //导入依赖的package包/类
public PlayerPortalEvent(final Player player, final Location from, final Location to, final TravelAgent pta) {
    super(player, from, to);
    this.travelAgent = pta;
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:5,代码来源:PlayerPortalEvent.java

示例12: changeDimension

import org.bukkit.TravelAgent; //导入依赖的package包/类
public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) {
    WorldServer exitWorld = null;
    if (entityplayer.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds
        // only target existing worlds (compensate for allow-nether/allow-end as false)
        for (WorldServer world : this.server.worlds) {
            if (world.dimension == i) {
                exitWorld = world;
            }
        }
    }

    Location enter = entityplayer.getBukkitEntity().getLocation();
    Location exit = null;
    boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END
    if (exitWorld != null) {
        if ((cause == TeleportCause.END_PORTAL) && (i == 0)) {
            // THE_END -> NORMAL; use bed if available, otherwise default spawn
            exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
            if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) {
                exit = exitWorld.getWorld().getSpawnLocation();
            }
        } else {
            // NORMAL <-> NETHER or NORMAL -> THE_END
            exit = this.calculateTarget(enter, exitWorld);
            useTravelAgent = true;
        }
    }

    TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().getTravelAgent() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
    PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause);
    event.useTravelAgent(useTravelAgent);
    Bukkit.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled() || event.getTo() == null) {
        return;
    }

    exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
    if (exit == null) {
        return;
    }
    exitWorld = ((CraftWorld) exit.getWorld()).getHandle();

    Vector velocity = entityplayer.getBukkitEntity().getVelocity();
    boolean before = exitWorld.chunkProviderServer.forceChunkLoad;
    exitWorld.chunkProviderServer.forceChunkLoad = true;
    exitWorld.getTravelAgent().adjustExit(entityplayer, exit, velocity);
    exitWorld.chunkProviderServer.forceChunkLoad = before;

    this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we
    if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) {
        entityplayer.getBukkitEntity().setVelocity(velocity);
    }
    // CraftBukkit end
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:55,代码来源:PlayerList.java

示例13: setSearchRadius

import org.bukkit.TravelAgent; //导入依赖的package包/类
@Override
public TravelAgent setSearchRadius(int radius) {
    this.searchRadius = radius;
    return this;
}
 
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:6,代码来源:CraftTravelAgent.java

示例14: setCreationRadius

import org.bukkit.TravelAgent; //导入依赖的package包/类
@Override
public TravelAgent setCreationRadius(int radius) {
    this.creationRadius = radius < 2 ? 0 : radius;
    return this;
}
 
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:6,代码来源:CraftTravelAgent.java

示例15: changeDimension

import org.bukkit.TravelAgent; //导入依赖的package包/类
public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) {
    WorldServer exitWorld = null;
    if (entityplayer.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds
        // only target existing worlds (compensate for allow-nether/allow-end as false)
        for (WorldServer world : this.server.worlds) {
            if (world.dimension == i) {
                exitWorld = world;
            }
        }
    }

    Location enter = entityplayer.getBukkitEntity().getLocation();
    Location exit = null;
    boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END
    if (exitWorld != null) {
        if ((cause == TeleportCause.END_PORTAL) && (i == 0)) {
            // THE_END -> NORMAL; use bed if available, otherwise default spawn
            exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
            if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) {
                exit = exitWorld.getWorld().getSpawnLocation();
            }
        } else {
            // NORMAL <-> NETHER or NORMAL -> THE_END
            exit = this.calculateTarget(enter, exitWorld);
            useTravelAgent = true;
        }
    }

    TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().t() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
    PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause);
    event.useTravelAgent(useTravelAgent);
    Bukkit.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled() || event.getTo() == null) {
        return;
    }

    exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
    if (exit == null) {
        return;
    }
    exitWorld = ((CraftWorld) exit.getWorld()).getHandle();

    Vector velocity = entityplayer.getBukkitEntity().getVelocity();
    boolean before = exitWorld.chunkProviderServer.forceChunkLoad;
    exitWorld.chunkProviderServer.forceChunkLoad = true;
    exitWorld.t().adjustExit(entityplayer, exit, velocity); // Should be getTravelAgent
    exitWorld.chunkProviderServer.forceChunkLoad = before;

    this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we
    if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) {
        entityplayer.getBukkitEntity().setVelocity(velocity);
    }
    // CraftBukkit end
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:55,代码来源:PlayerList.java


注:本文中的org.bukkit.TravelAgent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。