org.bukkit.Difficulty Java Examples
The following examples show how to use
org.bukkit.Difficulty.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapInfoImpl.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
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")); }
Example #2
Source File: MapDifficultyBuilder.java From CardinalPGM with MIT License | 6 votes |
@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; }
Example #3
Source File: NickNamerSelfUpdateEvent.java From NickNamer with MIT License | 5 votes |
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; }
Example #4
Source File: DifficultyModule.java From UHC with MIT License | 5 votes |
@EventHandler public void on(WorldLoadEvent event) { if (isEnabled()) { if (worlds.worldMatches(event.getWorld())) { event.getWorld().setDifficulty(Difficulty.HARD); } } }
Example #5
Source File: DifficultyModule.java From UHC with MIT License | 5 votes |
@Override public void onEnable() { for (final World world : Bukkit.getWorlds()) { if (worlds.worldMatches(world)) { world.setDifficulty(Difficulty.HARD); } } }
Example #6
Source File: MapInfoImpl.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
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; }
Example #7
Source File: NickNamerSelfUpdateEvent.java From NickNamer with MIT License | 5 votes |
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; }
Example #8
Source File: ExprDifficulty.java From Skript with GNU General Public License v3.0 | 5 votes |
@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); } }
Example #9
Source File: ExprDifficulty.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @Nullable public Class<?>[] acceptChange(ChangeMode mode) { if (mode == ChangeMode.SET) return CollectionUtils.array(Difficulty.class); return null; }
Example #10
Source File: MapInfo.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
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; }
Example #11
Source File: ExprDifficulty.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public Class<Difficulty> getReturnType() { return Difficulty.class; }
Example #12
Source File: ExprDifficulty.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override @Nullable public Difficulty convert(World world) { return world.getDifficulty(); }
Example #13
Source File: NickNamerSelfUpdateEvent.java From NickNamer with MIT License | 4 votes |
public Difficulty getDifficulty() { return difficulty; }
Example #14
Source File: NickNamerSelfUpdateEvent.java From NickNamer with MIT License | 4 votes |
public void setDifficulty(Difficulty difficulty) { this.difficulty = difficulty; }
Example #15
Source File: CraftWorld.java From Thermos with GNU General Public License v3.0 | 4 votes |
public void setDifficulty(Difficulty difficulty) { this.getHandle().difficultySetting = net.minecraft.world.EnumDifficulty.getDifficultyEnum(difficulty.getValue()); }
Example #16
Source File: CraftWorld.java From Thermos with GNU General Public License v3.0 | 4 votes |
public Difficulty getDifficulty() { return Difficulty.getByValue(this.getHandle().difficultySetting.ordinal()); }
Example #17
Source File: AsyncWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void setDifficulty(Difficulty difficulty) { parent.setDifficulty(difficulty); }
Example #18
Source File: AsyncWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public Difficulty getDifficulty() { return parent.getDifficulty(); }
Example #19
Source File: MainConfiguration.java From UhcCore with GNU General Public License v3.0 | 4 votes |
public Difficulty getGameDifficulty() { return gameDifficulty; }
Example #20
Source File: InfoModule.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@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)); }
Example #21
Source File: MapDifficulty.java From CardinalPGM with MIT License | 4 votes |
protected MapDifficulty(Difficulty difficulty) { GameHandler.getGameHandler().getMatchWorld().setDifficulty(difficulty); }