本文整理汇总了Java中org.spongepowered.api.entity.living.player.gamemode.GameMode类的典型用法代码示例。如果您正苦于以下问题:Java GameMode类的具体用法?Java GameMode怎么用?Java GameMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GameMode类属于org.spongepowered.api.entity.living.player.gamemode包,在下文中一共展示了GameMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ImmutableViewerDataManipulator
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
protected ImmutableViewerDataManipulator(String camera, String world, Double locX, Double locY, Double locZ, GameMode gameMode, Boolean isFlying, Boolean affectsSpawning, Boolean vanish,
Boolean vanishPreventsTargeting, Boolean vanishIgnoresCollision, Double flyingSpeed) {
this.camera = camera;
this.world = world;
this.locX = locX;
this.locY = locY;
this.locZ = locZ;
this.gameMode = gameMode;
this.isFlying = isFlying;
this.affectsSpawning = affectsSpawning;
this.vanish = vanish;
this.vanishPreventsTargeting = vanishPreventsTargeting;
this.vanishIgnoresCollision = vanishIgnoresCollision;
this.flyingSpeed = flyingSpeed;
registerGetters();
}
示例2: ViewerData
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
protected ViewerData(String camera, String world, Double locX, Double locY, Double locZ, GameMode gameMode, Boolean isFlying, Boolean affectsSpawning, Boolean vanish,
Boolean vanishPreventsTargeting, Boolean vanishIgnoresCollision, Double flyingSpeed) {
this.camera = camera;
this.world = world;
this.locX = locX;
this.locY = locY;
this.locZ = locZ;
this.gameMode = gameMode;
this.isFlying = isFlying;
this.affectsSpawning = affectsSpawning;
this.vanish = vanish;
this.vanishPreventsTargeting = vanishPreventsTargeting;
this.vanishIgnoresCollision = vanishIgnoresCollision;
this.flyingSpeed = flyingSpeed;
registerGettersAndSetters();
}
示例3: getName
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
public static Text getName(final GameMode gamemode) {
if (gamemode == null) return Text.EMPTY;
if (gamemode.equals(GameModes.SURVIVAL)){
return EAMessages.GAMEMODE_SURVIVAL.getText();
} else if (gamemode.equals(GameModes.CREATIVE)) {
return EAMessages.GAMEMODE_CREATIVE.getText();
} else if (gamemode.equals(GameModes.ADVENTURE)) {
return EAMessages.GAMEMODE_ADVENTURE.getText();
} else if (gamemode.equals(GameModes.SPECTATOR)) {
return EAMessages.GAMEMODE_SPECTATOR.getText();
} else if (gamemode.equals(GameModes.NOT_SET)) {
return EAMessages.GAMEMODE_NOT_SET.getText();
}
return Text.EMPTY;
}
示例4: getGameMode
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
public static Optional<GameMode> getGameMode(final String arg) {
if (arg == null) return Optional.empty();
switch (arg) {
case "0":
case "s":
return Optional.of(GameModes.SURVIVAL);
case "1":
case "c":
return Optional.of(GameModes.CREATIVE);
case "2":
case "a":
return Optional.of(GameModes.ADVENTURE);
case "3":
case "sp":
return Optional.of(GameModes.SPECTATOR);
case "-1":
return Optional.of(GameModes.NOT_SET);
default:
return Sponge.getGame().getRegistry().getType(GameMode.class, arg);
}
}
示例5: commandGameMode
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
private CompletableFuture<Boolean> commandGameMode(final EPlayer player, final String gamemode_name) {
Optional<GameMode> optGamemode = UtilsGameMode.getGameMode(gamemode_name);
// Nom du gamemode inconnue
if (!optGamemode.isPresent()) {
EEMessages.GAMEMODE_ERROR_NAME.sendTo(player);
return CompletableFuture.completedFuture(false);
}
GameMode gamemode = optGamemode.get();
// Gamemode identique à celui du joueur
if (gamemode.equals(player.getGameMode())) {
EEMessages.GAMEMODE_PLAYER_EQUAL.sender()
.replace("{gamemode}", UtilsGameMode.getName(gamemode))
.sendTo(player);
return CompletableFuture.completedFuture(false);
}
player.setGameMode(gamemode);
EEMessages.GAMEMODE_PLAYER_CHANGE.sender()
.replace("{gamemode}", UtilsGameMode.getName(gamemode))
.sendTo(player);
return CompletableFuture.completedFuture(true);
}
示例6: handleEvent
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
@Override
protected void handleEvent(EntityProtocolUpdateContext context, EntityEvent event) {
if (event instanceof SpectateEntityEvent) {
final Entity entity = ((SpectateEntityEvent) event).getSpectatedEntity().orElse(null);
if (entity == null) {
context.sendToSelf(() -> new MessagePlayOutSetCamera(getRootEntityId()));
} else {
context.getId(entity).ifPresent(id -> context.sendToSelf(() -> new MessagePlayOutSetCamera(id)));
}
} else if (event instanceof RefreshAbilitiesPlayerEvent) {
final GameMode gameMode = this.entity.get(Keys.GAME_MODE).get();
final float flySpeed = getFlySpeed();
final float fov = getFovModifier();
context.sendToSelf(() -> new MessagePlayOutPlayerAbilities(
this.entity.get(Keys.IS_FLYING).orElse(false), canFly(), false, gameMode == GameModes.CREATIVE, flySpeed, fov));
} else {
super.handleEvent(context, event);
}
}
示例7: getState
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
@Override
public PlayerState getState() {
Player player = getPlayer().orElseThrow(IllegalStateException::new);
ImmutableList.Builder<WarItem> builder = ImmutableList.builder();
for (Inventory inventory : player.getInventory().slots()) {
Optional<ItemStack> peek = inventory.peek();
if (peek.isPresent()) {
builder.add(plugin.getWarItem(peek.get()));
}
}
int gameMode = 0;
GameMode gameMode1 = player.getGameModeData().getValue(Keys.GAME_MODE).orElseThrow(IllegalStateException::new).get();
if (gameMode1 == GameModes.CREATIVE)
gameMode = WarGameMode.CREATIVE;
// return new PlayerState(gameMode, (WarItem[]) builder.build().toArray(),
// null, null, null, null,
// player.getHealthData().getValue(Keys.HEALTH).orElseThrow(IllegalStateException::new).get(),
// player.getS);
throw new UnsupportedOperationException("Not implemented yet");
}
示例8: execute
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
Optional<PlayerStateService> optService = Sponge.getServiceManager().provide(PlayerStateService.class);
if (!optService.isPresent()) {
src.sendMessage(Text.of(TextColors.DARK_RED, "The player state service is not currently running."));
return CommandResult.empty();
}
PlayerStateService service = optService.get();
GameMode mode = args.<GameMode>getOne("mode").get();
Player target = args.<Player>getOne("target").get();
if (service.hasInventoryStored(target) && !args.hasAny("f")) {
src.sendMessage(Text.of(TextColors.RED, "Player has an omni-state stored, action denied."));
src.sendMessage(Text.of(TextColors.RED, "This can be overwritten using -f."));
return CommandResult.empty();
}
service.save(target, target.get(Keys.GAME_MODE).get().getId());
target.offer(Keys.FALL_DISTANCE, 0F);
target.offer(Keys.GAME_MODE, mode);
service.load(target, mode.getId());
target.sendMessage(Text.of(TextColors.YELLOW, "Changed game mode to " + mode.getName() + '.'));
return CommandResult.success();
}
示例9: aquireSpec
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
public static CommandSpec aquireSpec() {
Map<String, GameMode> map = new HashMap<>();
map.put("survival", GameModes.SURVIVAL);
map.put("creative", GameModes.CREATIVE);
map.put("adventure", GameModes.ADVENTURE);
map.put("spectator", GameModes.SPECTATOR);
return CommandSpec.builder()
.description(Text.of("Change gamemode"))
.permission("skree.gamemode")
.arguments(
flags().flag("f").buildWith(
seq(
onlyOne(choices(Text.of("mode"), map)),
onlyOne(playerOrSource(Text.of("target")))
)
)
).executor(new GameModeCommand()).build();
}
示例10: isInIgnoredGameMode
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
boolean isInIgnoredGameMode(Player player) {
Optional<GameMode> optionalGameMode = player.getGameModeData().get(Keys.GAME_MODE);
if (optionalGameMode.isPresent()) {
GameMode gameMode = optionalGameMode.get();
return (gameMode.equals(GameModes.SURVIVAL) && ignoredGameModes[0]) ||
(gameMode.equals(GameModes.CREATIVE) && ignoredGameModes[1]) ||
(gameMode.equals(GameModes.ADVENTURE) && ignoredGameModes[2]) ||
(gameMode.equals(GameModes.SPECTATOR) && ignoredGameModes[3]);
}
return true;
}
示例11: execute
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
@Override
public void execute(CommandQueue queue, CommandEntry entry) {
PlayerTag player = (PlayerTag) entry.getArgumentObject(queue, 0);
String gamemode = entry.getArgumentObject(queue, 1).toString();
Optional<GameMode> type = Sponge.getRegistry().getType(GameMode.class, gamemode);
if (!type.isPresent()) {
queue.handleError(entry, "Invalid gamemode: '" + gamemode + "'!");
return;
}
player.getInternal().offer(Keys.GAME_MODE, type.get());
if (queue.shouldShowGood()) {
queue.outGood("Set gamemode of player '" + ColorSet.emphasis + player.debug()
+ ColorSet.good + "' to: " + ColorSet.emphasis + type.get().getName() + ColorSet.good + "!");
}
}
示例12: LanternWorldArchetype
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
LanternWorldArchetype(String id, String name, GameMode gameMode, LanternDimensionType<?> dimensionType, @Nullable GeneratorType generatorType,
Collection<WorldGeneratorModifier> generatorModifiers, @Nullable DataContainer generatorSettings, Difficulty difficulty,
SerializationBehavior serializationBehavior, LanternPortalAgentType portalAgentType, boolean hardcore, boolean enabled,
boolean loadsOnStartup, @Nullable Boolean keepsSpawnLoaded, boolean usesMapFeatures, boolean pvpEnabled, boolean generateBonusChest,
boolean commandsAllowed, @Nullable Boolean waterEvaporates, @Nullable Boolean allowPlayerRespawns, boolean generateSpawnOnLoad,
boolean isSeedRandomized, long seed, int buildHeight) {
this.serializationBehavior = serializationBehavior;
this.generateSpawnOnLoad = generateSpawnOnLoad;
this.allowPlayerRespawns = allowPlayerRespawns;
this.generatorModifiers = generatorModifiers;
this.generatorSettings = generatorSettings;
this.generateBonusChest = generateBonusChest;
this.keepsSpawnLoaded = keepsSpawnLoaded;
this.usesMapFeatures = usesMapFeatures;
this.portalAgentType = portalAgentType;
this.commandsAllowed = commandsAllowed;
this.waterEvaporates = waterEvaporates;
this.loadsOnStartup = loadsOnStartup;
this.dimensionType = dimensionType;
this.generatorType = generatorType;
this.isSeedRandomized = isSeedRandomized;
this.buildHeight = buildHeight;
this.pvpEnabled = pvpEnabled;
this.difficulty = difficulty;
this.hardcore = hardcore;
this.gameMode = gameMode;
this.enabled = enabled;
this.name = name;
this.seed = seed;
this.id = id;
}
示例13: setGameMode
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
public void setGameMode(GameMode gameMode) {
if (this.tabListEntries.isEmpty()) {
return;
}
MessagePlayOutTabListEntries message = new MessagePlayOutTabListEntries(Collections.singletonList(
new MessagePlayOutTabListEntries.Entry.UpdateGameMode(this.gameProfile, gameMode)));
this.tabListEntries.forEach(tabListEntry -> {
tabListEntry.setRawGameMode(gameMode);
tabListEntry.getList().getPlayer().getConnection().send(message);
});
}
示例14: LanternTabListEntry
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
LanternTabListEntry(GlobalTabListEntry globalEntry, LanternTabList tabList, GameMode gameMode, int latency, @Nullable Text displayName) {
this.displayName = Optional.ofNullable(displayName);
this.globalEntry = globalEntry;
this.gameMode = gameMode;
this.tabList = tabList;
this.latency = latency;
}
示例15: setGameMode
import org.spongepowered.api.entity.living.player.gamemode.GameMode; //导入依赖的package包/类
@Override
public LanternTabListEntry setGameMode(GameMode gameMode) {
this.setRawGameMode(gameMode);
if (this.attached) {
this.tabList.getPlayer().getConnection().send(new MessagePlayOutTabListEntries(Collections.singletonList(
new MessagePlayOutTabListEntries.Entry.UpdateGameMode(this.getProfile(), gameMode))));
}
return this;
}