本文整理汇总了Java中org.spongepowered.api.event.entity.DisplaceEntityEvent类的典型用法代码示例。如果您正苦于以下问题:Java DisplaceEntityEvent类的具体用法?Java DisplaceEntityEvent怎么用?Java DisplaceEntityEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DisplaceEntityEvent类属于org.spongepowered.api.event.entity包,在下文中一共展示了DisplaceEntityEvent类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onDisplaceEntity
import org.spongepowered.api.event.entity.DisplaceEntityEvent; //导入依赖的package包/类
@Listener
public void onDisplaceEntity(DisplaceEntityEvent.Move.TargetPlayer event) {
Player player = event.getTargetEntity();
Location<World> location = player.getLocation();
Sponge.getScheduler().createTaskBuilder().execute(() -> {
if (PvPToggle.togglePlayers.contains(player.getUniqueId())) {
Location<World> newLocation = player.getLocation();
if (location.getX() != newLocation.getX()
|| location.getY() != newLocation.getY()
|| location.getZ() != newLocation.getZ()) {
PvPToggle.togglePlayers.remove(player.getUniqueId());
player.sendMessage(TranslationHelper.t("text.player.commandCancelled", player.getLocale()));
}
}
}).delay(500, TimeUnit.MILLISECONDS).name("PvPToggle - Get Movement Change")
.submit(Sponge.getPluginManager().getPlugin("io.tehtotalpwnage.pvptoggle").get().getInstance().get());
}
开发者ID:TehTotalPwnage,项目名称:PvPToggle,代码行数:18,代码来源:MovementListener.java
示例2: onWorldChange
import org.spongepowered.api.event.entity.DisplaceEntityEvent; //导入依赖的package包/类
@Listener
public void onWorldChange(DisplaceEntityEvent.Teleport e) {
if (!(e.getTargetEntity() instanceof Player)) return;
if (!e.getFromTransform().getExtent().getUniqueId().equals(e.getToTransform().getExtent().getUniqueId())) {
sendArmorUpdate((Player) e.getTargetEntity());
}
}
开发者ID:MylesIsCool,项目名称:ViaVersion,代码行数:8,代码来源:Sponge4ArmorListener.java
示例3: onPlayerMove
import org.spongepowered.api.event.entity.DisplaceEntityEvent; //导入依赖的package包/类
@Listener
public void onPlayerMove(DisplaceEntityEvent.Move event) {
if (event.getTargetEntity() instanceof Player) {
Bedrock.getAFKManager().lastActivity((Player) event.getTargetEntity());
if (Bedrock.getJailManager().isFrozen((Player) event.getTargetEntity())) {
event.setCancelled(true);
}
}
}
开发者ID:prism,项目名称:Bedrock,代码行数:11,代码来源:MoveListener.java
示例4: onMove
import org.spongepowered.api.event.entity.DisplaceEntityEvent; //导入依赖的package包/类
@Listener
public void onMove(DisplaceEntityEvent.Move event, @Root Player player) {
Vector3d from = event.getFromTransform().getPosition();
Vector3d to = event.getToTransform().getPosition();
Set<Region> discovered = discoveredBy.computeIfAbsent(player.getUniqueId(), this::regionsFor);
// We only care if the player actually moved across a block boundary
if (from.getFloorX() != to.getFloorX() || from.getFloorZ() != to.getFloorZ()) {
// Discover any regions the player hasn't already
this.regions.stream()
.filter(region -> inside(region, to) && !discovered.contains(region))
.forEach(region -> discover(player, region));
}
}
开发者ID:phroa,项目名称:Discovery,代码行数:16,代码来源:Discovery.java
示例5: onPlayerMove
import org.spongepowered.api.event.entity.DisplaceEntityEvent; //导入依赖的package包/类
@Listener
public void onPlayerMove(DisplaceEntityEvent.TargetPlayer event) {
WarPlayer player = plugin.getWarPlayer(event.getTargetEntity());
WarLocation from = plugin.getWarLocation(event.getFromTransform());
WarLocation to = plugin.getWarLocation(event.getToTransform());
boolean b = plugin.getListener().handlePlayerMovement(player, from, to);
event.setCancelled(b);
}
开发者ID:cmastudios,项目名称:war-sponge,代码行数:9,代码来源:PlayerListener.java
示例6: onMove
import org.spongepowered.api.event.entity.DisplaceEntityEvent; //导入依赖的package包/类
@Listener
public void onMove(DisplaceEntityEvent.Move.TargetPlayer event) {
Player player = event.getTargetEntity();
if (arena.getOnlinePlayers().contains(player.getUniqueId()) && arena.getCurrentState().equals(ArenaStates.GAME_PLAYING)) {
if (player.getLocation().getBlockY() < arena.getCenter().getBlockY() && player.get(Keys.GAME_MODE).get().equals(GameModes.SURVIVAL)) {
arena.broadcast(messages.getMessage("arena.died", "player", player.getName()));
player.setLocationSafely(arena.getCenter().add(0, 5, 0));
player.offer(Keys.GAME_MODE, GameModes.SPECTATOR);
player.playSound(SoundTypes.FALL_BIG, player.getLocation().getPosition(), 3);
arena.removeAlive(player.getUniqueId());
if (arena.getAlive().size() == 1) {
// The player is the winner
Optional<Player> wOpt = arena.resolvePlayer(arena.getAlive().get(0));
if (wOpt.isPresent()) {
Player winner = wOpt.get();
arena.broadcast(messages.getMessage("arena.winner", "player", winner.getName()));
if (economyManager.foundEconomy()) {
winner.sendMessage(messages.getMessage("arena.reward", "reward",
economyManager.getCurrency().get().format(BigDecimal.valueOf(25)), "reason", Text.of("winning")));
economyManager.addCurrency(winner.getUniqueId(), BigDecimal.valueOf(25));
}
arena.arenaStateChange(ArenaStates.GAME_OVER);
}
} else if (arena.getAlive().size() == 0) {
// Everyone lost
arena.broadcast(messages.getMessage("arena.winner", "player", "Nobody"));
arena.arenaStateChange(ArenaStates.GAME_OVER);
}
}
}
}
开发者ID:FlibioStudio,项目名称:Ultimate-Spleef,代码行数:32,代码来源:GamePlayingRunnable.java
示例7: onMove
import org.spongepowered.api.event.entity.DisplaceEntityEvent; //导入依赖的package包/类
@Listener
public void onMove(final DisplaceEntityEvent.Move event) {
if (event.getTargetEntity() instanceof Monster && !SafeGuard.getZoneManager().allows(spawnMonsterFlag, event.getTargetEntity().getLocation())) {
event.getTargetEntity().remove();
}
}
开发者ID:prism,项目名称:SafeGuard,代码行数:7,代码来源:MoveEntityListener.java
示例8: onWorldChange
import org.spongepowered.api.event.entity.DisplaceEntityEvent; //导入依赖的package包/类
@Listener(order = Order.POST)
public void onWorldChange(DisplaceEntityEvent.Teleport.TargetPlayer event) {
sendRestrictions(event.getTargetEntity(), event.getToTransform().getExtent());
}
开发者ID:ReplayMod,项目名称:replay-restrictions,代码行数:5,代码来源:SpongePlugin.java
示例9: playerMove
import org.spongepowered.api.event.entity.DisplaceEntityEvent; //导入依赖的package包/类
@Listener
public void playerMove(DisplaceEntityEvent.Move.TargetPlayer event) throws Exception {
if (event.getFromTransform().getPosition().equals(event.getToTransform().getPosition())) {
// Don't do anything if a player just looks around, but doesn't move
return;
}
Player player = event.getTargetEntity();
Location<World> location = event.getToTransform().getLocation();
// If pvp-protect config setting is on, cancel the warp
if (this.plugin.getConfig().isPvpProtect()) {
if (this.plugin.getWarpManager().isWarping(player)) {
this.plugin.getWarpManager().cancelWarp(player);
}
}
List<WarpRegion> warpRegions = getContainingRegions(location);
if (warpRegions.isEmpty()) {
return;
}
if (warpRegions.size() != 1) {
// There should only ever be 1 WarpRegion in the list - if not,
// there are more than one warp regions occupying the same space
throw new MultipleWarpRegionsException(location);
}
WarpRegion region = warpRegions.get(0);
Optional<Warp> linkedWarpOpt = this.plugin.getWarpManager().getOne(region.getLinkedWarpId());
if (!linkedWarpOpt.isPresent()) {
this.plugin.getLogger().warn(
"Player " + player.getName() + " attempted to use warp region " + region.getName() + ", but the linked warp "
+ region.getLinkedWarpId() + " was not found!");
return;
}
Optional<Warp> existingDestinationOpt = this.plugin.getWarpManager().getPlayerDestination(player);
// Cancel the possibly existing scheduled warp before warping to the new
// warp
if (existingDestinationOpt.isPresent()) {
// System.out.println("Player already warping: " + existingDestinationOpt.get().getName());
// Only cancel it if the existing scheduled warp is different than
// the new one
if (!existingDestinationOpt.get().getName().equals(linkedWarpOpt.get().getName())) {
this.plugin.getWarpManager().cancelWarp(player);
this.plugin.getWarpManager().scheduleWarp(player, linkedWarpOpt.get());
}
} else {
// System.out.println("Player not warping");
this.plugin.getWarpManager().scheduleWarp(player, linkedWarpOpt.get());
}
}
开发者ID:RobertHerhold,项目名称:BLWarps,代码行数:58,代码来源:DisplaceEntityEventHandler.java
示例10: PorePlayerMoveEvent
import org.spongepowered.api.event.entity.DisplaceEntityEvent; //导入依赖的package包/类
public PorePlayerMoveEvent(DisplaceEntityEvent.Move.TargetPlayer handle) {
super(null, null, null);
this.handle = checkNotNull(handle, "handle");
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:5,代码来源:PorePlayerMoveEvent.java
示例11: getHandle
import org.spongepowered.api.event.entity.DisplaceEntityEvent; //导入依赖的package包/类
public DisplaceEntityEvent.Move.TargetPlayer getHandle() {
return handle;
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:4,代码来源:PorePlayerMoveEvent.java
注:本文中的org.spongepowered.api.event.entity.DisplaceEntityEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论