Package org.bukkit

Examples of org.bukkit.Difficulty


        // @tags
        // <w@world.difficulty>
        // -->
        if (mechanism.matches("difficulty") && mechanism.requireEnum(true, Difficulty.values())) {
            String upper = value.asString().toUpperCase();
            Difficulty diff = null;
            if (upper.matches("(PEACEFUL|EASY|NORMAL|HARD)")) {
                diff = Difficulty.valueOf(upper);
            }
            else {
                diff = Difficulty.getByValue(value.asInt());
View Full Code Here


        if (args.length != 1 || args[0].length() == 0) {
            sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
            return false;
        }

        Difficulty difficulty = Difficulty.getByValue(getDifficultyForString(sender, args[0]));

        if (Bukkit.isHardcore()) {
            difficulty = Difficulty.HARD;
        }

        Bukkit.getWorlds().get(0).setDifficulty(difficulty);

        int levelCount = 1;
        if (Bukkit.getAllowNether()) {
            Bukkit.getWorlds().get(levelCount).setDifficulty(difficulty);
            levelCount++;
        }

        if (Bukkit.getAllowEnd()) {
            Bukkit.getWorlds().get(levelCount).setDifficulty(difficulty);
        }

        Command.broadcastCommandMessage(sender, "Set difficulty to " + difficulty.toString());
        return true;
    }
View Full Code Here

            }
        }

        if(isEntityEnabled(event.getEntity(), visionEnabled)) {
            if(event.getTarget() == null) return;
            Difficulty diff = event.getEntity().getWorld().getDifficulty();

            if (event.getReason() != TargetReason.CLOSEST_PLAYER && event.getReason() != TargetReason.RANDOM_TARGET)
                return; // Just making sure

            LivingEntity enemy = (LivingEntity) event.getEntity();
View Full Code Here

  }

  @Override
  public Difficulty select(String arg, CommandSender sender)
  {
    Difficulty ret = null;
   
    arg = arg.toLowerCase();

    if (arg.startsWith("p"))
    {
View Full Code Here

      WorldConfig wc = WorldConfig.get(worldname);
        if (args.length == 0) {
          String diff = wc.difficulty.toString().toLowerCase();
          message(ChatColor.YELLOW + "Difficulty of world '" + worldname + "' is set at " + ChatColor.WHITE + diff);
        } else {
          Difficulty diff = Conversion.toDifficulty.convert(args[0]);
          if (diff != null) {
          wc.difficulty = diff;
          wc.updateDifficulty(wc.getWorld());
          message(ChatColor.YELLOW + "Difficulty of world '" + worldname + "' set to " + ChatColor.WHITE + diff.toString().toLowerCase());
          } else {
            message(ChatColor.RED + "Difficulty '" + args[0] + "' has not been recognized!");
          }
        }
    }
View Full Code Here

                    world.setSpawnLocation(spawnLoc);
                }

                // migrate difficulty
                if (section.isString("difficulty")) {
                    final Difficulty difficulty = Difficulty.valueOf(section.getString("difficulty").toUpperCase());
                    if (difficulty != null) {
                        world.setDifficulty(difficulty);
                    }
                }
View Full Code Here

    setupScoreboardObjectives();
  }

  private static Difficulty getDifficulty(String d)
  {
    Difficulty diff = Difficulty.valueOf(d.toUpperCase());
    try { diff = Difficulty.getByValue(Integer.parseInt(d)); }
    catch (NumberFormatException ignored) {  }

    return diff;
  }
View Full Code Here

    // allow or disallow friendly fire
    if (gameplay.getChild("friendlyfire") != null)
      setFriendlyFire(Boolean.parseBoolean(gameplay.getChildText("friendlyfire")));

    // attempt to set world difficulty as best as possible
    Difficulty diff = Difficulty.HARD;
    if (gameplay.getChild("difficulty") != null)
      diff = getDifficulty(gameplay.getChildText("difficulty"));
    primaryWorld.setDifficulty(diff);

    if (gameplay.getChild("maxtime") != null)
View Full Code Here

TOP

Related Classes of org.bukkit.Difficulty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.