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


Java Sponge.isServerAvailable方法代码示例

本文整理汇总了Java中org.spongepowered.api.Sponge.isServerAvailable方法的典型用法代码示例。如果您正苦于以下问题:Java Sponge.isServerAvailable方法的具体用法?Java Sponge.isServerAvailable怎么用?Java Sponge.isServerAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.Sponge的用法示例。


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

示例1: getDefaultGameMode

import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public GameMode getDefaultGameMode() {
    if (!Sponge.isServerAvailable()) {
        return GameMode.SURVIVAL;
    }
    Optional<WorldProperties>properties = Sponge.getServer().getDefaultWorld();
    if (!properties.isPresent()) {
        return GameMode.SURVIVAL;
    }
    org.spongepowered.api.entity.living.player.gamemode.GameMode gameMode = properties.get().getGameMode();

    if (gameMode == GameModes.SURVIVAL) {
        return GameMode.SURVIVAL;
    } else if (gameMode == GameModes.ADVENTURE) {
        return GameMode.ADVENTURE;
    } else if (gameMode == GameModes.CREATIVE) {
        return GameMode.CREATIVE;
    } else if (gameMode == GameModes.SPECTATOR) {
        return GameMode.SPECTATOR;
    }

    return GameMode.SURVIVAL; // Unimplemented gamemode's and NOT_SET
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:24,代码来源:FakeServer.java

示例2: spawnParticle

import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public void spawnParticle(Particle particle, Location location, int count) {
    if (!Sponge.isServerAvailable()) return;
    Optional<Player> optionalP = Sponge.getServer().getPlayer(this.getUniqueId());
    ParticleType type = DummyObjectProvider.createFor(ParticleType.class, particle.name());
    optionalP.ifPresent(p -> p.spawnParticles(ParticleEffect.builder().type(type).quantity(count).build(), new Vector3d(location.getX(), location.getY(), location.getZ())));
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:8,代码来源:LinkedPlayer.java

示例3: setDefaultGameMode

import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public void setDefaultGameMode(GameMode mode) {
    if (!Sponge.isServerAvailable()) {
        return;
    }
    Optional<WorldProperties>properties = Sponge.getServer().getDefaultWorld();
    properties.ifPresent((it) -> it.setGameMode(getSpongeGamemode(mode)));
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:9,代码来源:FakeServer.java

示例4: setWhitelist

import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public void setWhitelist(boolean value) {
    if (!Sponge.isServerAvailable()) {
        return;
    }
    Sponge.getServer().setHasWhitelist(value);
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:8,代码来源:FakeServer.java

示例5: playEffect

import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public <T> void playEffect(Location loc, Effect effect, T data) {
    if (!Sponge.isServerAvailable()) return;
    Optional<Player> optionalP = Sponge.getServer().getPlayer(this.getUniqueId());
    ParticleType type = DummyObjectProvider.createFor(ParticleType.class, effect.name());
    optionalP.ifPresent(p -> p.spawnParticles(ParticleEffect.builder().type(type).build(), new Vector3d(loc.getX(), loc.getY(), loc.getZ())));
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:8,代码来源:LinkedPlayer.java

示例6: convertToSpongeLocation

import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
private org.spongepowered.api.world.Location<org.spongepowered.api.world.World> convertToSpongeLocation(Location loc) {
    if (!Sponge.isServerAvailable()) return null;
    org.spongepowered.api.world.World spongeWorld = Sponge.getServer().getWorld(loc.getWorld().getName()).orElse(null);
    return new org.spongepowered.api.world.Location<>(spongeWorld, loc.getX(), loc.getY(), loc.getZ());
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:6,代码来源:LinkedEntity.java

示例7: kickPlayer

import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public void kickPlayer(String message) {
    if (!Sponge.isServerAvailable()) return;
    Optional<Player> optionalP = Sponge.getServer().getPlayer(this.getUniqueId());
    optionalP.ifPresent(p -> kickPlayer(message));
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:7,代码来源:LinkedPlayer.java

示例8: stopSound

import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public void stopSound(String sound) {
    if (!Sponge.isServerAvailable()) return;
    Optional<Player> optionalP = Sponge.getServer().getPlayer(this.getUniqueId());
    optionalP.ifPresent(p -> performCommand("stopsound "+this.getName()+" "+sound)); //TODO: Is there a better way to do this? On github there was an issue that was never answered
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:7,代码来源:LinkedPlayer.java

示例9: getWorld

import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public World getWorld() {
    if (!Sponge.isServerAvailable()) return null;
    return Bukkit.getWorld(getSpongeEntity().getWorld().getName());
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:6,代码来源:LinkedEntity.java

示例10: teleport

import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public boolean teleport(Location location) {
    if (!Sponge.isServerAvailable()) return false;
    return getSpongeEntity().setLocation(convertToSpongeLocation(location));
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:6,代码来源:LinkedEntity.java

示例11: getOnlineMode

import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public boolean getOnlineMode() {
    return Sponge.isServerAvailable() && Sponge.getServer().getOnlineMode();
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:5,代码来源:FakeServer.java

示例12: setMetadata

import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
    if (!Sponge.isServerAvailable()) return;
    metaManager.removeMeta(getSpongeEntity(), metadataKey);
    metaManager.addMeta(getSpongeEntity(), metadataKey, newMetadataValue);
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:7,代码来源:LinkedEntity.java

示例13: damage

import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public void damage(double amount) {
    if (!Sponge.isServerAvailable()) return;
    Optional<Player> optionalP = Sponge.getServer().getPlayer(this.getUniqueId());
    optionalP.ifPresent(p -> p.damage(amount, DamageSource.builder().absolute().build()));
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:7,代码来源:LinkedPlayer.java


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