本文整理汇总了Java中org.spongepowered.api.entity.living.player.gamemode.GameModes.SURVIVAL属性的典型用法代码示例。如果您正苦于以下问题:Java GameModes.SURVIVAL属性的具体用法?Java GameModes.SURVIVAL怎么用?Java GameModes.SURVIVAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.spongepowered.api.entity.living.player.gamemode.GameModes
的用法示例。
在下文中一共展示了GameModes.SURVIVAL属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDefaultGameMode
@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: reset
@Override
public LanternWorldArchetypeBuilder reset() {
this.usesMapFeatures = true;
this.gameMode = GameModes.SURVIVAL;
this.difficulty = Difficulties.NORMAL;
this.portalAgentType = (LanternPortalAgentType) PortalAgentTypes.DEFAULT;
this.hardcore = false;
this.keepsSpawnLoaded = null;
this.loadsOnStartup = false;
this.generateSpawnOnLoad = true;
this.enabled = true;
this.generateBonusChest = false;
this.commandsAllowed = true;
this.dimensionType = null;
this.generatorModifiers = Collections.emptySet();
this.seed = null;
this.generatorType = null;
this.generatorSettings = null;
this.waterEvaporates = null;
this.buildHeight = 256;
this.serializationBehavior = SerializationBehaviors.AUTOMATIC;
return this;
}
示例3: onItemPickup
@Listener
public void onItemPickup(ChangeInventoryEvent.Pickup event, @First(typeFilter = {Player.class}) Player player) {
IActiveCharacter character = characterService.getCharacter(player.getUniqueId());
if (character.isStub()) {
return;
}
if (player.get(Keys.GAME_MODE).get() != GameModes.SURVIVAL)
return;
for (SlotTransaction slotTransaction : event.getTransactions()) {
Slot i = slotTransaction.getSlot();
int index = ((SlotAdapter) i).getOrdinal();
if (Utils.isHotbar(index)) {
ItemStack a = slotTransaction.getFinal().createStack();
if (inventoryService.canUse(a, character) != CannotUseItemReson.OK) {
event.setCancelled(true);
return;
} else {
inventoryService.initializeHotbar(character, index, a);
}
}
}
}
示例4: run
@Override
public void run() {
PotionEffect speedEffect = PotionEffect.builder()
.duration(3 * 20)
.amplifier(5)
.particles(false)
.potionType(PotionEffectTypes.SPEED)
.build();
for (World world : getWorlds()) {
for (Entity entity : world.getEntities(p -> p.getType().equals(EntityTypes.PLAYER))) {
if (entity.get(Keys.GAME_MODE).orElse(GameModes.CREATIVE) != GameModes.SURVIVAL) {
continue;
}
List<PotionEffect> potionEffects = entity.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
potionEffects.add(speedEffect);
entity.offer(Keys.POTION_EFFECTS, potionEffects);
}
}
}
示例5: reset
@Override
public WorldCreationSettings.Builder reset() {
this.dimensionType = DimensionTypes.OVERWORLD;
this.generatorType = GeneratorTypes.DEFAULT;
this.gameMode = GameModes.SURVIVAL;
this.serializationBehavior = SerializationBehaviors.AUTOMATIC;
this.isEnabled = true;
this.loadOnStartup = true;
this.doesKeepSpawnLoaded = true;
this.generateSpawnOnLoad = true;
this.usesMapFeatures = true;
this.isHardcore = false;
this.commandsAllowed = true;
this.doesGenerateBonusChest = false;
this.isPvpEnabled = true;
this.seed = SpongeGame.instance.getConfiguration().getSeed();
return this;
}
示例6: getSpongeGamemode
private org.spongepowered.api.entity.living.player.gamemode.GameMode getSpongeGamemode(GameMode gameMode) {
if (gameMode == GameMode.SURVIVAL) {
return GameModes.SURVIVAL;
} else if (gameMode == GameMode.ADVENTURE) {
return GameModes.ADVENTURE;
} else if (gameMode == GameMode.CREATIVE) {
return GameModes.CREATIVE;
} else if (gameMode == GameMode.SPECTATOR) {
return GameModes.SPECTATOR;
}
return GameModes.NOT_SET;
}
示例7: spawn
private void spawn(EntityProtocolUpdateContext context, String name) {
final LanternGameProfile gameProfile = new LanternGameProfile(this.entity.getUniqueId(), name);
final MessagePlayOutTabListEntries.Entry.Add addEntry = new MessagePlayOutTabListEntries.Entry.Add(
gameProfile, GameModes.SURVIVAL, null, 0);
context.sendToAllExceptSelf(() -> new MessagePlayOutTabListEntries(Collections.singleton(addEntry)));
super.spawn(context);
final MessagePlayOutTabListEntries.Entry.Remove removeEntry = new MessagePlayOutTabListEntries.Entry.Remove(gameProfile);
context.sendToAllExceptSelf(() -> new MessagePlayOutTabListEntries(Collections.singleton(removeEntry)));
}
示例8: onRightClick
@Listener
public void onRightClick(InteractBlockEvent.Secondary.MainHand event, @First Player player) {
boolean survival = player.get(Keys.GAME_MODE).orElse(GameModes.CREATIVE) == GameModes.SURVIVAL;
Optional<ItemStack> optHeldItem = player.getItemInHand(HandTypes.MAIN_HAND);
if (!optHeldItem.isPresent()) {
return;
}
if (optHeldItem.get().getItem() != this) {
return;
}
event.setUseBlockResult(Tristate.FALSE);
Optional<Location<World>> optLoc = event.getTargetBlock().getLocation();
if (!optLoc.isPresent()) {
return;
}
Location<World> loc = optLoc.get();
BlockType targetType = loc.getBlockType();
if (targetType == CustomBlockTypes.MAGIC_LADDER) {
MagicBlockStateHelper.startLadder(loc);
} else if (targetType == CustomBlockTypes.MAGIC_PLATFORM) {
MagicBlockStateHelper.startPlatform(loc);
} else {
return;
}
if (!survival) {
MagicBlockStateHelper.resetCounts();
return;
}
MagicBlockStateHelper.dropItems(loc, event.getCause());
}
示例9: getGameMode
@Override
public PlotGameMode getGameMode() {
GameMode gamemode = this.player.getGameModeData().type().get();
if (gamemode == GameModes.ADVENTURE) {
return PlotGameMode.ADVENTURE;
} else if (gamemode == GameModes.CREATIVE) {
return PlotGameMode.CREATIVE;
} else if (gamemode == GameModes.SPECTATOR) {
return PlotGameMode.SPECTATOR;
} else if (gamemode == GameModes.SURVIVAL) {
return PlotGameMode.SURVIVAL;
} else {
return PlotGameMode.NOT_SET;
}
}
示例10: execute
@Override
public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
checkPermission(sender, GamemodePermissions.UC_GAMEMODE_GAMEMODE_BASE);
GameMode gm = args.<GameMode>getOne("gamemode").get();
if (!args.hasAny("player")) {
checkIfPlayer(sender);
Player p = (Player) sender;
//Perm check
if (gm == GameModes.SURVIVAL) {
checkPermission(sender, GamemodePermissions.UC_GAMEMODE_GAMEMODE_SELF_ADVENTURE);
} else if (gm == GameModes.CREATIVE) {
checkPermission(sender, GamemodePermissions.UC_GAMEMODE_GAMEMODE_SELF_CREATIVE);
} else if (gm == GameModes.ADVENTURE) {
checkPermission(sender, GamemodePermissions.UC_GAMEMODE_GAMEMODE_SELF_ADVENTURE);
} else if (gm == GameModes.SPECTATOR) {
checkPermission(sender, GamemodePermissions.UC_GAMEMODE_GAMEMODE_SELF_SPECTATOR);
}
p.offer(Keys.GAME_MODE, gm);
Messages.send(sender, "gamemode.command.gamemode.success", "%gamemode%", gm.getName());
return CommandResult.success();
} else {
checkPermission(sender, GamemodePermissions.UC_GAMEMODE_GAMEMODE_OTHERS_BASE);
Player t = args.<Player>getOne("player").get();
//Perm check
if (gm == GameModes.SURVIVAL) {
checkPermission(sender, GamemodePermissions.UC_GAMEMODE_GAMEMODE_OTHERS_ADVENTURE);
} else if (gm == GameModes.CREATIVE) {
checkPermission(sender, GamemodePermissions.UC_GAMEMODE_GAMEMODE_OTHERS_CREATIVE);
} else if (gm == GameModes.ADVENTURE) {
checkPermission(sender, GamemodePermissions.UC_GAMEMODE_GAMEMODE_OTHERS_ADVENTURE);
} else if (gm == GameModes.SPECTATOR) {
checkPermission(sender, GamemodePermissions.UC_GAMEMODE_GAMEMODE_OTHERS_SPECTATOR);
}
t.offer(Keys.GAME_MODE, gm);
Messages.send(t, "gamemode.command.gamemode.success.others", "%sender%", sender, "%gamemode%", gm.getName());
Messages.send(sender, "gamemode.command.gamemode.success.self", "%player%", t, "%gamemode%", gm.getName());
return CommandResult.success();
}
}
示例11: parseValue
@Nullable
@Override
public GameMode parseValue(CommandSource sender, CommandArgs args) throws ArgumentParseException {
String value = args.next();
try {
if (Sponge.getRegistry().getType(CatalogTypes.GAME_MODE, value).isPresent()) {
return Sponge.getRegistry().getType(CatalogTypes.GAME_MODE, value).get();
}
} catch (NullPointerException ignore) {
}
switch (value.toLowerCase()) {
case "survival":
case "0":
case "s":
return GameModes.SURVIVAL;
case "creative":
case "c":
case "1":
return GameModes.CREATIVE;
case "adventure":
case "2":
case "a":
return GameModes.ADVENTURE;
case "spectator":
case "3":
case "spec":
case "sp":
return GameModes.SPECTATOR;
default:
throw (args.createError(Messages.getFormatted(sender, "gamemode.command.gamemode.invalidgamemode", "%gamemode%", value)));
}
}