本文整理汇总了Java中org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent类的典型用法代码示例。如果您正苦于以下问题:Java RespawnPlayerEvent类的具体用法?Java RespawnPlayerEvent怎么用?Java RespawnPlayerEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RespawnPlayerEvent类属于org.spongepowered.api.event.entity.living.humanoid.player包,在下文中一共展示了RespawnPlayerEvent类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRespawnPlayerEvent
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
@Listener
public void onRespawnPlayerEvent(RespawnPlayerEvent event) {
if (event.isBedSpawn()) {
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));
}
}
示例2: onPlayerRespawn
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
@Listener(order = Order.LAST)
public void onPlayerRespawn(RespawnPlayerEvent event) {
GPTimings.PLAYER_RESPAWN_EVENT.startTimingIfSync();
Player player = event.getTargetEntity();
if (!GriefPreventionPlugin.instance.claimsEnabledForWorld(player.getWorld().getProperties())) {
GPTimings.PLAYER_RESPAWN_EVENT.stopTimingIfSync();
return;
}
GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
playerData.lastSpawn = Calendar.getInstance().getTimeInMillis();
playerData.lastPvpTimestamp = 0; // no longer in pvp combat
// also send him any messaged from grief prevention he would have
// received while dead
if (playerData.messageOnRespawn != null) {
// color is already embedded inmessage in this case
GriefPreventionPlugin.sendMessage(player, Text.of(playerData.messageOnRespawn), 40L);
playerData.messageOnRespawn = null;
}
GriefPreventionPlugin.instance.checkPvpProtectionNeeded(player);
GPTimings.PLAYER_RESPAWN_EVENT.stopTimingIfSync();
}
示例3: onRespawn
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
@Listener
public void onRespawn(RespawnPlayerEvent event) {
EntityPlayer player = tf(event.getTargetEntity());
NonNullList<net.minecraft.item.ItemStack> mainInv = player.inventory.mainInventory;
Task.builder().delayTicks(1).execute(() -> {
Deque<ItemStack> queue = playerQueue.remove(player.getUniqueID());
if (queue != null) {
for (int i = 0; !queue.isEmpty() && i < mainInv.size(); ++i) {
if (mainInv.get(i) == net.minecraft.item.ItemStack.EMPTY) {
mainInv.set(i, tf(queue.poll()));
}
}
if (!queue.isEmpty()) {
enque(tf(player), queue);
}
}
}).submit(SkreePlugin.inst());
}
示例4: onRespawn
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
@Listener
public void onRespawn(RespawnPlayerEvent 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;
}
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);
}
示例5: handleRespawn
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
public void handleRespawn() {
Transform<World> transform = getTransform();
final LanternWorld world = (LanternWorld) transform.getExtent();
if (isDead()) {
// TODO: Get the proper spawn location
final Transform<World> toTransform = new Transform<>(transform.getExtent(), new Vector3d(0, 100, 0));
// Make the player less dead...
setDead(false);
// Reset player settings
offer(Keys.HEALTH, get(Keys.MAX_HEALTH).get());
offer(Keys.FOOD_LEVEL, get(LanternKeys.MAX_FOOD_LEVEL).get());
offer(Keys.ABSORPTION, 0.0);
offer(Keys.EXHAUSTION, DEFAULT_EXHAUSTION);
offer(Keys.SATURATION, DEFAULT_SATURATION);
offer(Keys.POTION_EFFECTS, new ArrayList<>());
offer(LanternKeys.SCORE, 0);
final CauseStack causeStack = CauseStack.current();
try (CauseStack.Frame frame = causeStack.pushCauseFrame()) {
frame.pushCause(this);
frame.addContext(EventContextKeys.PLAYER, this);
final RespawnPlayerEvent event = SpongeEventFactory.createRespawnPlayerEvent(causeStack.getCurrentCause(),
transform, toTransform, this, this, false, true);
Sponge.getEventManager().post(event);
// Get the to transform, this can be overridden in the event
transform = event.getToTransform();
}
}
setWorld(world, (LanternWorld) transform.getExtent());
setPosition(transform.getPosition());
}
示例6: onRespawn
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
@Listener
public void onRespawn(RespawnPlayerEvent event) {
Entity type = event.getTargetEntity();
if (type.getType() == EntityTypes.PLAYER) {
IActiveCharacter character = characterService.getCharacter(type.getUniqueId());
if (character.isStub())
return;
characterService.respawnCharacter(character, event.getTargetEntity());
}
}
示例7: onRespawn
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
@Listener
public void onRespawn(RespawnPlayerEvent event) {
if (isApplicable(event.getToTransform().getExtent())) {
Optional<WorldService> optWorldService = Sponge.getServiceManager().provide(WorldService.class);
if (optWorldService.isPresent()) {
Collection<World> worlds = optWorldService.get().getEffectWrapper(MainWorldWrapper.class).get().getWorlds();
event.setToTransform(new Transform<>(worlds.iterator().next().getSpawnLocation()));
}
}
}
示例8: onPlayerRespawn
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
@Listener(order = Order.LAST)
public void onPlayerRespawn(RespawnPlayerEvent event) {
Player player = event.getTargetEntity();
if (hasReleasedInventoryStored(player)) {
try {
loadInventory(player);
} catch (InventoryStorageStateException e) {
e.printStackTrace();
}
}
}
示例9: onPlayerRespawn
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
@Listener
public void onPlayerRespawn(RespawnPlayerEvent event) {
Player player = event.getTargetEntity();
if (respawnDataPackets.containsKey(player.getUniqueId())) {
RespawnDataPacket packet = respawnDataPackets.remove(player.getUniqueId());
event.setToTransform(event.getToTransform().setRotation(packet.getRespawnRotation()).setPosition(packet.getRespawnLocation().toDouble()));
player.sendMessage(packet.getRespawnMessage());
}
}
示例10: onSpawn
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
@Listener(order = Order.LATE)
public void onSpawn(RespawnPlayerEvent event)
{
if (!event.isBedSpawn())
{
Subject subject = pm.getUserSubjects().loadSubject(event.getTargetEntity().getIdentifier()).join();
subject.getOption(SpawnCommands.ROLESPAWN).ifPresent(s -> event.setToTransform(getSpawnLocation(s)));
}
}
示例11: handle
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
@Override
public void handle(RespawnPlayerEvent e) {
millisLived.put(e.getOriginalPlayer(), System.currentTimeMillis());
}
示例12: onRespawn
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
@Listener
public void onRespawn(RespawnPlayerEvent e) {
sendDelayedArmorUpdate(e.getTargetEntity());
}
示例13: onRespawnPlayer
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
@Listener(order=Order.FIRST)
public void onRespawnPlayer(final RespawnPlayerEvent event) {
event.setToTransform(this.plugin.getEServer().getEPlayer(event.getOriginalPlayer()).getSpawn());
}
示例14: onPlayerRespawn
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; //导入依赖的package包/类
@Listener
public void onPlayerRespawn(RespawnPlayerEvent event) {
Player player = event.getTargetEntity();
event.setToTransform(new Transform<>(pop(player).orElse(getDefault(player))));
}