本文整理匯總了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()));
}