类org.bukkit.Difficulty源码实例Demo

下面列出了怎么用org.bukkit.Difficulty的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: PGM   文件: MapInfoImpl.java
public MapInfoImpl(Element root) throws InvalidXMLException {
  this(
      checkNotNull(root).getChildTextNormalize("slug"),
      XMLUtils.parseSemanticVersion(Node.fromRequiredAttr(root, "proto")),
      XMLUtils.parseSemanticVersion(Node.fromRequiredChildOrAttr(root, "version")),
      Node.fromRequiredChildOrAttr(root, "name").getValueNormalize(),
      Node.fromRequiredChildOrAttr(root, "objective", "description").getValueNormalize(),
      parseContributors(root, "author"),
      parseContributors(root, "contributor"),
      parseRules(root),
      XMLUtils.parseEnum(
              Node.fromLastChildOrAttr(root, "difficulty"),
              Difficulty.class,
              "difficulty",
              Difficulty.NORMAL)
          .ordinal(),
      null,
      null,
      parseWorld(root),
      XMLUtils.parseFormattedText(root, "game"));
}
 
源代码2 项目: CardinalPGM   文件: MapDifficultyBuilder.java
@Override
public ModuleCollection<MapDifficulty> load(Match match) {
    ModuleCollection<MapDifficulty> results = new ModuleCollection<>();
    try {
        switch (Numbers.parseInt(match.getDocument().getRootElement().getChildText("difficulty"))) {
            case 0:
                results.add(new MapDifficulty(Difficulty.PEACEFUL));
                break;
            case 1:
                results.add(new MapDifficulty(Difficulty.EASY));
                break;
            case 2:
                results.add(new MapDifficulty(Difficulty.NORMAL));
                break;
            case 3:
                results.add(new MapDifficulty(Difficulty.HARD));
                break;
        }
    } catch (NumberFormatException | NullPointerException e) {
    }
    return results;
}
 
源代码3 项目: PGM   文件: MapInfoImpl.java
public MapInfoImpl(
    @Nullable String id,
    Version proto,
    Version version,
    String name,
    String description,
    @Nullable Collection<Contributor> authors,
    @Nullable Collection<Contributor> contributors,
    @Nullable Collection<String> rules,
    @Nullable Integer difficulty,
    @Nullable Collection<MapTag> tags,
    @Nullable Collection<Integer> players,
    @Nullable WorldInfo world,
    Component gamemode) {
  this.name = checkNotNull(name);
  this.id = checkNotNull(MapInfo.normalizeName(id == null ? name : id));
  this.proto = checkNotNull(proto);
  this.version = checkNotNull(version);
  this.description = checkNotNull(description);
  this.authors = authors == null ? new LinkedList<>() : authors;
  this.contributors = contributors == null ? new LinkedList<>() : contributors;
  this.rules = rules == null ? new LinkedList<>() : rules;
  this.difficulty = difficulty == null ? Difficulty.NORMAL.ordinal() : difficulty;
  this.tags = tags == null ? new TreeSet<>() : tags;
  this.players = players == null ? new LinkedList<>() : players;
  this.world = world == null ? new WorldInfoImpl() : world;
  this.gamemode = gamemode == null ? TextComponent.empty() : gamemode;
}
 
源代码4 项目: ProjectAres   文件: MapInfo.java
public MapInfo(SemanticVersion proto,
               @Nullable String slug,
               String name,
               SemanticVersion version,
               MapDoc.Edition edition,
               MapDoc.Phase phase,
               @Nullable BaseComponent game,
               MapDoc.Genre genre,
               Set<MapDoc.Gamemode> gamemodes,
               BaseComponent objective,
               List<Contributor> authors,
               List<Contributor> contributors,
               List<String> rules,
               @Nullable Difficulty difficulty,
               Environment dimension,
               boolean friendlyFire) {

    this.id = new MapId(slug != null ? slug : MapId.slugifyName(name), edition, phase);

    this.proto = checkNotNull(proto);
    this.name = checkNotNull(name);
    this.version = checkNotNull(version);
    this.game = game;
    this.genre = checkNotNull(genre);
    this.gamemodes = checkNotNull(gamemodes);
    this.objective = checkNotNull(objective);
    this.authors = checkNotNull(authors);
    this.contributors = checkNotNull(contributors);
    this.rules = checkNotNull(rules);
    this.difficulty = difficulty;
    this.dimension = checkNotNull(dimension);
    this.friendlyFire = friendlyFire;

}
 
源代码5 项目: Skript   文件: ExprDifficulty.java
@Override
@Nullable
public Class<?>[] acceptChange(ChangeMode mode) {
	if (mode == ChangeMode.SET)
		return CollectionUtils.array(Difficulty.class);
	return null;
}
 
源代码6 项目: Skript   文件: ExprDifficulty.java
@Override
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
	if (delta == null)
		return;
	
	Difficulty difficulty = (Difficulty) delta[0];
	for (World world : getExpr().getArray(e)) {
		world.setDifficulty(difficulty);
	}
}
 
源代码7 项目: NickNamer   文件: NickNamerSelfUpdateEvent.java
public NickNamerSelfUpdateEvent(Player player, String name, Object gameProfile,Difficulty difficulty, GameMode gameMode, boolean async) {
	super(async);
	this.player = player;
	this.name = name;
	this.gameProfile = gameProfile;
	this.difficulty = difficulty;
	this.gameMode = gameMode;
}
 
源代码8 项目: NickNamer   文件: NickNamerSelfUpdateEvent.java
public NickNamerSelfUpdateEvent(Player player, String name, Object gameProfile,Difficulty difficulty, GameMode gameMode) {
	this.player = player;
	this.name = name;
	this.gameProfile = gameProfile;
	this.difficulty = difficulty;
	this.gameMode = gameMode;
}
 
源代码9 项目: UHC   文件: DifficultyModule.java
@Override
public void onEnable() {
    for (final World world : Bukkit.getWorlds()) {
        if (worlds.worldMatches(world)) {
            world.setDifficulty(Difficulty.HARD);
        }
    }
}
 
源代码10 项目: UHC   文件: DifficultyModule.java
@EventHandler
public void on(WorldLoadEvent event) {
    if (isEnabled()) {
        if (worlds.worldMatches(event.getWorld())) {
            event.getWorld().setDifficulty(Difficulty.HARD);
        }
    }
}
 
源代码11 项目: ProjectAres   文件: InfoModule.java
@Override
public InfoModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    Element root = doc.getRootElement();

    String name = Node.fromRequiredChildOrAttr(root, "name").getValueNormalize();
    SemanticVersion version = XMLUtils.parseSemanticVersion(Node.fromRequiredChildOrAttr(root, "version"));
    MapDoc.Phase phase = XMLUtils.parseEnum(Node.fromLastChildOrAttr(root, "phase"), MapDoc.Phase.class, "phase", MapDoc.Phase.PRODUCTION);
    MapDoc.Edition edition = XMLUtils.parseEnum(Node.fromLastChildOrAttr(root, "edition"), MapDoc.Edition.class, "edition", MapDoc.Edition.STANDARD);

    // Allow multiple <objective> elements, so include files can provide defaults
    final BaseComponent objective = XMLUtils.parseLocalizedText(Node.fromRequiredLastChildOrAttr(root, "objective"));

    String slug = root.getChildTextNormalize("slug");
    BaseComponent game = XMLUtils.parseFormattedText(root, "game");

    MapDoc.Genre genre = XMLUtils.parseEnum(Node.fromNullable(root.getChild("genre")), MapDoc.Genre.class, "genre", MapDoc.Genre.OTHER);

    final TreeSet<MapDoc.Gamemode> gamemodes = new TreeSet<>();
    for(Element elGamemode : root.getChildren("gamemode")) {
        gamemodes.add(XMLUtils.parseEnum(elGamemode, MapDoc.Gamemode.class));
    }

    List<Contributor> authors = readContributorList(root, "authors", "author");

    if(game == null) {
        Element blitz = root.getChild("blitz");
        if(blitz != null) {
            Element title = blitz.getChild("title");
            if(title != null) {
                if(context.getProto().isNoOlderThan(ProtoVersions.REMOVE_BLITZ_TITLE)) {
                    throw new InvalidXMLException("<title> inside <blitz> is no longer supported, use <map game=\"...\">", title);
                }
                game = new Component(title.getTextNormalize());
            }
        }
    }

    List<Contributor> contributors = readContributorList(root, "contributors", "contributor");

    List<String> rules = new ArrayList<String>();
    for(Element parent : root.getChildren("rules")) {
        for(Element rule : parent.getChildren("rule")) {
            rules.add(rule.getTextNormalize());
        }
    }

    Difficulty difficulty = XMLUtils.parseEnum(Node.fromLastChildOrAttr(root, "difficulty"), Difficulty.class, "difficulty");

    Environment dimension = XMLUtils.parseEnum(Node.fromLastChildOrAttr(root, "dimension"), Environment.class, "dimension", Environment.NORMAL);

    boolean friendlyFire = XMLUtils.parseBoolean(Node.fromLastChildOrAttr(root, "friendly-fire", "friendlyfire"), false);

    return new InfoModule(new MapInfo(context.getProto(), slug, name, version, edition, phase, game, genre, ImmutableSet.copyOf(gamemodes), objective, authors, contributors, rules, difficulty, dimension, friendlyFire));
}
 
源代码12 项目: UhcCore   文件: MainConfiguration.java
public Difficulty getGameDifficulty() {
	return gameDifficulty;
}
 
源代码13 项目: Skript   文件: ExprDifficulty.java
@Override
@Nullable
public Difficulty convert(World world) {
	return world.getDifficulty();
}
 
源代码14 项目: Skript   文件: ExprDifficulty.java
@Override
public Class<Difficulty> getReturnType() {
	return Difficulty.class;
}
 
源代码15 项目: NickNamer   文件: NickNamerSelfUpdateEvent.java
public Difficulty getDifficulty() {
	return difficulty;
}
 
源代码16 项目: NickNamer   文件: NickNamerSelfUpdateEvent.java
public void setDifficulty(Difficulty difficulty) {
	this.difficulty = difficulty;
}
 
源代码17 项目: Thermos   文件: CraftWorld.java
public void setDifficulty(Difficulty difficulty) {
    this.getHandle().difficultySetting = net.minecraft.world.EnumDifficulty.getDifficultyEnum(difficulty.getValue());
}
 
源代码18 项目: Thermos   文件: CraftWorld.java
public Difficulty getDifficulty() {
    return Difficulty.getByValue(this.getHandle().difficultySetting.ordinal());
}
 
源代码19 项目: FastAsyncWorldedit   文件: AsyncWorld.java
@Override
public void setDifficulty(Difficulty difficulty) {
    parent.setDifficulty(difficulty);
}
 
源代码20 项目: FastAsyncWorldedit   文件: AsyncWorld.java
@Override
public Difficulty getDifficulty() {
    return parent.getDifficulty();
}
 
源代码21 项目: CardinalPGM   文件: MapDifficulty.java
protected MapDifficulty(Difficulty difficulty) {
    GameHandler.getGameHandler().getMatchWorld().setDifficulty(difficulty);
}
 
 类所在包
 同包方法