use of org.spongepowered.api.entity.living.player.gamemode.GameMode in project Nucleus by NucleusPowered.
the class IgniteCommand method executeWithPlayer.
@Override
protected CommandResult executeWithPlayer(CommandSource pl, Player target, CommandContext args, boolean isSelf) throws Exception {
int ticksInput = args.<Integer>getOne(ticks).get();
GameMode gm = target.get(Keys.GAME_MODE).orElse(GameModes.SURVIVAL);
if (gm == GameModes.CREATIVE || gm == GameModes.SPECTATOR) {
pl.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.ignite.gamemode", target.getName()));
return CommandResult.empty();
}
if (target.offer(Keys.FIRE_TICKS, ticksInput).isSuccessful()) {
pl.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.ignite.success", target.getName(), String.valueOf(ticksInput)));
return CommandResult.success();
} else {
pl.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.ignite.error", target.getName()));
return CommandResult.empty();
}
}
use of org.spongepowered.api.entity.living.player.gamemode.GameMode in project Nucleus by NucleusPowered.
the class GamemodeCommand method executeCommand.
@Override
protected CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
Player user;
if (args.hasAny(MarkerArgument.MARKER)) {
user = this.getUserFromArgs(Player.class, src, userKey, args);
} else {
user = this.getUserFromArgs(Player.class, src, "thisisjunk", args);
}
Optional<GameMode> ogm = args.getOne(gamemodeKey);
if (!ogm.isPresent()) {
String mode = user.get(Keys.GAME_MODE).orElse(GameModes.SURVIVAL).getName();
if (src.equals(user)) {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.gamemode.get.base", mode));
} else {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.gamemode.get.other", user.getName(), mode));
}
return CommandResult.success();
}
GameMode gm = ogm.get();
return baseCommand(src, user, gm);
}
use of org.spongepowered.api.entity.living.player.gamemode.GameMode in project Nucleus by NucleusPowered.
the class SuicideCommand method executeCommand.
@Override
public CommandResult executeCommand(Player src, CommandContext args) throws Exception {
GameMode gm = src.gameMode().getDirect().orElse(src.gameMode().getDefault());
if (gm != GameModes.SURVIVAL && gm != GameModes.NOT_SET) {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.suicide.wronggm"));
return CommandResult.empty();
}
src.offer(Keys.HEALTH, 0d);
return CommandResult.success();
}
use of org.spongepowered.api.entity.living.player.gamemode.GameMode in project SpongeCommon by SpongePowered.
the class LevelStemMixin method bridge$populateFromLevelData.
@Override
public void bridge$populateFromLevelData(final PrimaryLevelData levelData) {
final PrimaryLevelDataBridge levelDataBridge = (PrimaryLevelDataBridge) levelData;
this.impl$gameMode = (ResourceLocation) (Object) RegistryTypes.GAME_MODE.get().valueKey((GameMode) (Object) levelData.getGameType());
this.impl$difficulty = (ResourceLocation) (Object) RegistryTypes.DIFFICULTY.get().valueKey((Difficulty) (Object) levelData.getDifficulty());
this.impl$serializationBehavior = levelDataBridge.bridge$serializationBehavior().orElse(null);
this.impl$displayName = levelDataBridge.bridge$displayName().orElse(null);
this.impl$viewDistance = levelDataBridge.bridge$viewDistance().orElse(null);
this.impl$spawnPosition = new Vector3i(levelData.getXSpawn(), levelData.getYSpawn(), levelData.getZSpawn());
this.impl$loadOnStartup = levelDataBridge.bridge$loadOnStartup();
this.impl$performsSpawnLogic = levelDataBridge.bridge$performsSpawnLogic();
this.impl$hardcore = levelData.isHardcore();
this.impl$commands = levelData.getAllowCommands();
this.impl$pvp = levelDataBridge.bridge$pvp().orElse(null);
}
use of org.spongepowered.api.entity.living.player.gamemode.GameMode in project SpongeCommon by SpongePowered.
the class SpongeTabList method addEntry.
private void addEntry(final ClientboundPlayerInfoPacket.PlayerUpdate entry) {
final GameProfile profile = entry.getProfile();
if (!this.entries.containsKey(profile.getId())) {
final net.minecraft.network.chat.Component displayName = entry.getDisplayName();
this.addEntry(new SpongeTabListEntry(this, SpongeGameProfile.of(profile), displayName == null ? null : SpongeAdventure.asAdventure(displayName), entry.getLatency(), (GameMode) (Object) entry.getGameMode()), false);
}
}
Aggregations