本文整理汇总了Java中org.spongepowered.api.event.entity.MoveEntityEvent.Teleport方法的典型用法代码示例。如果您正苦于以下问题:Java MoveEntityEvent.Teleport方法的具体用法?Java MoveEntityEvent.Teleport怎么用?Java MoveEntityEvent.Teleport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.event.entity.MoveEntityEvent
的用法示例。
在下文中一共展示了MoveEntityEvent.Teleport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityTeleport
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.LAST)
public void onEntityTeleport(MoveEntityEvent.Teleport event) {
if (event.getTargetEntity().getType() != EntityTypes.PLAYER) {
return; // not a player
}
if (event.getFromTransform().getPosition().equals(event.getToTransform().getPosition())) {
return; // player hasn't moved
}
Optional<Challenger> chal = CommonCore.getChallenger(event.getTargetEntity().getUniqueId());
if (chal.isPresent() && !((CommonChallenger) chal.get()).isLeaving()) {
Boundary bound = chal.get().getRound().getArena().getBoundary();
if (!bound.contains(LocationConverter.of(event.getToTransform().getPosition()))) {
if (chal.get().getRound().getConfigValue(ConfigNode.ALLOW_EXIT_BOUNDARY)) {
chal.get().removeFromRound();;
} else {
event.setCancelled(true);
}
}
}
}
示例2: onMoveEntityEventTeleport
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
@IsCancelled(Tristate.FALSE)
public void onMoveEntityEventTeleport(MoveEntityEvent.Teleport event, @Root Player player) {
if (event.getFromTransform().getExtent().equals(event.getToTransform().getExtent())) {
return;
}
World world = event.getToTransform().getExtent();
Vector3d rotation = null;
for (SpawnEntity spawnEntity : SpawnCache.instance.get()) {
if (spawnEntity.getWorld().getIdentifier().equals(world.getUniqueId().toString())) {
rotation = spawnEntity.getRotation();
}
}
if (rotation != null) {
Transform<World> to = new Transform<>(world.getSpawnLocation());
event.setToTransform(to.setRotation(rotation));
}
}
示例3: onWorldChange
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onWorldChange(MoveEntityEvent.Teleport event)
{
World from = event.getFromTransform().getExtent();
World to = event.getToTransform().getExtent();
Entity target = event.getTargetEntity();
if (from.equals(to) || module.getUniverse(from).equals(module.getUniverse(to)))
{
return;
}
if (target instanceof Player)
{
MultiverseData data = target.get(MultiverseData.class).get();
data.from(module.getUniverse(from), from).applyFromPlayer(((Player)target)); // save playerdata
data.from(module.getUniverse(to), to).applyToPlayer(((Player)target)); // load playerdata
target.offer(data);
module.getLogger().info("{} entered the universe {}", ((Player)target).getName(), module.getUniverse(to));
}
else
{
event.setCancelled(true);
}
}
示例4: onTeleport
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onTeleport(MoveEntityEvent.Teleport event)
{
if ((this.module.getConfig().disableVanillaPortals || this.module.getConfig().disabledVanillaPortalsInWorlds.getOrDefault(new ConfigWorld(event.getFromTransform().getExtent()), false))
&& event.getCause().getContext().get(EventContextKeys.TELEPORT_TYPE).orElse(null) == TeleportTypes.PORTAL)
{
event.setToTransform(event.getFromTransform().addTranslation(new Vector3d(0,1.2,0)));
// event.setCancelled(true);
return;
}
Transform<World> target = event.getToTransform();
Entity player = event.getTargetEntity();
if (player instanceof Player)
{
onTeleport(target, ((Player) player)); // TODO event listener parameter
}
}
示例5: onEntityTeleport
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityTeleport(MoveEntityEvent.Teleport event)
{
if (event.getTargetEntity() instanceof Player)
{
return;
}
List<Portal> portals = module.getPortalsInChunk(event.getFromTransform().getLocation());
if (portals == null)
{
return;
}
for (Portal portal : portals)
{
List<Entity> entities = module.getEntitiesInPortal(portal);
if (portal.has(event.getToTransform().getLocation()))
{
entities.add(event.getTargetEntity());
return;
}
else
{
entities.remove(event.getTargetEntity());
}
}
}
示例6: onWorldChange
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onWorldChange(MoveEntityEvent.Teleport e) {
if (!(e.getTargetEntity() instanceof Player)) return;
if (!e.getFromTransform().getExtent().getUniqueId().equals(e.getToTransform().getExtent().getUniqueId())) {
sendArmorUpdate((Player) e.getTargetEntity());
}
}
示例7: move
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void move(MoveEntityEvent event, @Getter("getTargetEntity") Player player) {
// If the player teleported, just send the distance event (not including
// their new location) and remove their player path
if (event instanceof MoveEntityEvent.Teleport) {
processEvent(event, player);
sendAndRemove(player.getUniqueId());
return;
}
PlayerPath playerPath;
if (this.playerPaths.containsKey(player.getUniqueId())) {
playerPath = this.playerPaths.get(player.getUniqueId());
} else {
playerPath = new PlayerPath();
this.playerPaths.put(player.getUniqueId(), playerPath);
}
Vector3i position = player.getLocation().getBlockPosition();
playerPath.addPoint(position);
// Send the event every 20 blocks moved
if (playerPath.size() >= 20) {
sendAndRemove(player.getUniqueId());
}
}
示例8: onEntityTeleport
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityTeleport(MoveEntityEvent.Teleport event, @First(typeFilter = EnderPearl.class) EnderPearl ep) {
Entity targetEntity = event.getTargetEntity();
IActiveCharacter iEntity = characterService.getCharacter(targetEntity.getUniqueId());
if (iEntity.hasEffect(EnderPearlEffect.name)) {
EnderPearlEffect.Container container = (EnderPearlEffect.Container) iEntity.getEffect(EnderPearlEffect.name);
if (container.getLastTimeUsed() < System.currentTimeMillis() - container.getStackedValue()) {
Gui.sendCooldownMessage(iEntity, "Ender Pearl", System.currentTimeMillis() - container.getStackedValue());
event.setCancelled(true);
} else {
container.setLastTimeUsed(System.currentTimeMillis());
}
}
}
示例9: onPlayerTeleport
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerTeleport(MoveEntityEvent.Teleport event, @Getter("getTargetEntity") Player player) {
Optional<JungleRaidInstance> optInst = manager.getApplicableZone(event.getFromTransform().getLocation());
if (optInst.isPresent() && !manager.getApplicableZone(event.getToTransform().getLocation()).isPresent()) {
JungleRaidInstance inst = optInst.get();
inst.playerLost(player);
inst.tryInventoryRestore(player);
}
}
示例10: onPlayerTeleport
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerTeleport(MoveEntityEvent.Teleport event, @Getter("getTargetEntity") Player player) {
Optional<GoldRushInstance> optInst = manager.getApplicableZone(event.getFromTransform().getLocation());
if (optInst.isPresent() && !manager.getApplicableZone(event.getToTransform().getLocation()).isPresent()) {
GoldRushInstance inst = optInst.get();
inst.invalidate(player);
inst.tryInventoryRestore(player);
}
}
示例11: onPlayerTeleport
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerTeleport(MoveEntityEvent.Teleport event) {
Entity entity = event.getTargetEntity();
if (!(entity instanceof Player)) {
return;
}
Player player = (Player) entity;
Optional<CursedMineInstance> optInst = manager.getApplicableZone(player);
HitList hitList = manager.getHitList();
if ((optInst.isPresent() && optInst.get().hasRecordForPlayer(player)) || hitList.isOnHitList(player)) {
event.setCancelled(true);
player.sendMessage(Text.of(TextColors.RED, "You have been tele-blocked!"));
}
}
示例12: onPlayerMove
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onPlayerMove(MoveEntityEvent playerMoveEvent, @First Player player) {
if (playerMoveEvent instanceof MoveEntityEvent.Teleport) {
return;
}
Vector3d oldLocation = playerMoveEvent.getFromTransform().getPosition();
Vector3d newLocation = playerMoveEvent.getToTransform().getPosition();
if ((oldLocation.getFloorX() != newLocation.getFloorX()
|| oldLocation.getFloorZ() != newLocation.getFloorZ())) {
checkLoginStatus(playerMoveEvent, player);
}
}
示例13: onTeleport
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onTeleport(MoveEntityEvent.Teleport event)
{
if (event.getTargetEntity() instanceof Player)
{
lastLocations.put(event.getTargetEntity().getUniqueId(), event.getFromTransform());
}
}
示例14: changeWorld
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void changeWorld(MoveEntityEvent.Teleport event)
{
if (!(event.getTargetEntity() instanceof Player))
{
return;
}
if (!((Player)event.getTargetEntity()).hasPermission(module.perms().EDIT_USE.getId()))
{
manager.exitEditMode(((Player)event.getTargetEntity()));
}
}
示例15: onMove
import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onMove(MoveEntityEvent event, @Getter("getTargetEntity") Player player)
{
List<Region> from = manager.getRegionsAt(event.getFromTransform().getLocation());
List<Region> to = manager.getRegionsAt(event.getToTransform().getLocation());
if (from.isEmpty() && to.isEmpty())
{
return;
}
// Ignore subblock movements
if (event.getFromTransform().getPosition().toInt().equals(event.getToTransform().getPosition().toInt()))
{
return;
}
if (event instanceof MoveEntityEvent.Teleport)
{
if (checkMove(event, player, from, to, MoveType.TELEPORT, false))
{
return; // Teleport out denied
}
if (checkMove(event, player, to, from, MoveType.TELEPORT, false))
{
return; // Teleport in denied
}
}
else if (event.getCause().root() instanceof Player)
{
if (checkMove(event, player, from, to, MoveType.MOVE, false))
{
i18n.send(ACTION_BAR, player, NEGATIVE, "You are not allowed to move in here.");
return; // Move in from denied
}
if (checkMove(event, player, from, to, MoveType.EXIT, true))
{
i18n.send(ACTION_BAR, player, NEGATIVE, "You are not allowed to exit this area.");
return; // Move out of from denied
}
if (checkMove(event, player, to, from, MoveType.ENTER, true))
{
i18n.send(ACTION_BAR, player, NEGATIVE, "You are not allowed to enter this area.");
return; // Move into to denied
}
}
}