本文整理汇总了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
}
示例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())));
}
示例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)));
}
示例4: setWhitelist
import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public void setWhitelist(boolean value) {
if (!Sponge.isServerAvailable()) {
return;
}
Sponge.getServer().setHasWhitelist(value);
}
示例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())));
}
示例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());
}
示例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));
}
示例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
}
示例9: getWorld
import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public World getWorld() {
if (!Sponge.isServerAvailable()) return null;
return Bukkit.getWorld(getSpongeEntity().getWorld().getName());
}
示例10: teleport
import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public boolean teleport(Location location) {
if (!Sponge.isServerAvailable()) return false;
return getSpongeEntity().setLocation(convertToSpongeLocation(location));
}
示例11: getOnlineMode
import org.spongepowered.api.Sponge; //导入方法依赖的package包/类
@Override
public boolean getOnlineMode() {
return Sponge.isServerAvailable() && Sponge.getServer().getOnlineMode();
}
示例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);
}
示例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()));
}