當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。