Esempio n. 1
0
  @Override
  public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!testPermission(sender)) return true;
    if (args.length == 0) {
      sender.sendMessage("Usage: " + usageMessage);
      return false;
    }

    String modeArg = args[0];
    int value = -1;

    try {
      value = Integer.parseInt(modeArg);
    } catch (NumberFormatException ex) {
    }

    GameMode mode = GameMode.getByValue(value);

    if (mode == null) {
      if (modeArg.equalsIgnoreCase("creative") || modeArg.equalsIgnoreCase("c")) {
        mode = GameMode.CREATIVE;
      } else if (modeArg.equalsIgnoreCase("adventure") || modeArg.equalsIgnoreCase("a")) {
        mode = GameMode.ADVENTURE;
      } else {
        mode = GameMode.SURVIVAL;
      }
    }

    Bukkit.getServer().setDefaultGameMode(mode);
    Command.broadcastCommandMessage(
        sender, "Default game mode set to " + mode.toString().toLowerCase());

    return true;
  }
Esempio n. 2
0
 public void setGameMode(Player player, GameMode gm) {
   player.setGameMode(gm);
   sendMessage(
       "Set &6"
           + (player == sender ? "your" : player.getName() + "'s")
           + color
           + " gamemode to &c"
           + gm.toString().toLowerCase());
 }
Esempio n. 3
0
 @SuppressWarnings("deprecation")
 public void setGameMode(Player player, String param) {
   param = param.toLowerCase();
   for (GameMode gm : GameMode.values()) {
     if (gm.toString().toLowerCase().startsWith(param)
         || param.equalsIgnoreCase(gm.getValue() + "")) {
       setGameMode(player, gm);
       return;
     }
   }
   sendMessage("No such gamemode: &c" + param);
 }
 public GameModeConfigProperty(
     ConfigurationSection section,
     String name,
     GameMode defaultValue,
     String configNode,
     String help) {
   this.name = name;
   this.configNode = configNode;
   this.section = section;
   this.help = help;
   this.value = defaultValue;
   this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
 }
 @Override
 public String toString() {
   return value.toString();
 }