当前位置: 首页>>代码示例>>Java>>正文


Java GameModes.ADVENTURE属性代码示例

本文整理汇总了Java中org.spongepowered.api.entity.living.player.gamemode.GameModes.ADVENTURE属性的典型用法代码示例。如果您正苦于以下问题:Java GameModes.ADVENTURE属性的具体用法?Java GameModes.ADVENTURE怎么用?Java GameModes.ADVENTURE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.spongepowered.api.entity.living.player.gamemode.GameModes的用法示例。


在下文中一共展示了GameModes.ADVENTURE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:23,代码来源:FakeServer.java

示例2: 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;
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:12,代码来源:FakeServer.java

示例3: 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;
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:15,代码来源:SpongePlayer.java

示例4: 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();
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:39,代码来源:GamemodeCommand.java

示例5: 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)));
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:33,代码来源:GamemodeArgument.java


注:本文中的org.spongepowered.api.entity.living.player.gamemode.GameModes.ADVENTURE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。