mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-13 11:18:23 +01:00
Added Difficulty API.
By: EvilSeph <evilseph@gmail.com>
This commit is contained in:
parent
903b75184d
commit
3ea8302a86
3 changed files with 79 additions and 4 deletions
paper-api/src/main/java/org/bukkit
61
paper-api/src/main/java/org/bukkit/Difficulty.java
Normal file
61
paper-api/src/main/java/org/bukkit/Difficulty.java
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
package org.bukkit;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the various difficulty levels that are available.
|
||||||
|
*/
|
||||||
|
public enum Difficulty {
|
||||||
|
/**
|
||||||
|
* Players regain health over time, hostile mobs don't spawn, the hunger bar does not deplete.
|
||||||
|
*/
|
||||||
|
PEACEFUL(0),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hostile mobs spawn, enemies deal less damage than on normal difficulty, the hunger bar does deplete and starving deals up to 5 hearts of damage. (Default value)
|
||||||
|
*/
|
||||||
|
EASY(1),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hostile mobs spawn, enemies deal normal amounts of damage, the hunger bar does deplete and starving deals up to 9.5 hearts of damage.
|
||||||
|
*/
|
||||||
|
NORMAL(2),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hostile mobs spawn, enemies deal greater damage than on normal difficulty, the hunger bar does deplete and starving can kill players.
|
||||||
|
*/
|
||||||
|
HARD(3);
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
private final static Map<Integer, Difficulty> difficulties = new HashMap<Integer, Difficulty>();
|
||||||
|
|
||||||
|
private Difficulty(final int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the difficulty value associated with this Difficulty.
|
||||||
|
*
|
||||||
|
* @return An integer value of this difficulty
|
||||||
|
*/
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Difficulty represented by the specified value
|
||||||
|
*
|
||||||
|
* @param value Value to check
|
||||||
|
* @return Associative {@link Difficulty} with the given value, or null if it doesn't exist
|
||||||
|
*/
|
||||||
|
public static Difficulty getByValue(final int value) {
|
||||||
|
return difficulties.get(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (Difficulty diff : Difficulty.values()) {
|
||||||
|
difficulties.put(diff.getValue(), diff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -323,18 +323,18 @@ public interface Server {
|
||||||
* @return World with the given Unique ID, or null if none exists.
|
* @return World with the given Unique ID, or null if none exists.
|
||||||
*/
|
*/
|
||||||
public World getWorld(UUID uid);
|
public World getWorld(UUID uid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the map from the given item ID.
|
* Gets the map from the given item ID.
|
||||||
*
|
*
|
||||||
* @param id ID of the map to get.
|
* @param id ID of the map to get.
|
||||||
* @return The MapView if it exists, or null otherwise.
|
* @return The MapView if it exists, or null otherwise.
|
||||||
*/
|
*/
|
||||||
public MapView getMap(short id);
|
public MapView getMap(short id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new map with an automatically assigned ID.
|
* Create a new map with an automatically assigned ID.
|
||||||
*
|
*
|
||||||
* @param world The world the map will belong to.
|
* @param world The world the map will belong to.
|
||||||
* @return The MapView just created.
|
* @return The MapView just created.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -725,6 +725,20 @@ public interface World {
|
||||||
*/
|
*/
|
||||||
public void setAutoSave(boolean value);
|
public void setAutoSave(boolean value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the Difficulty of the world.
|
||||||
|
*
|
||||||
|
* @param difficulty the new difficulty you want to set the world to
|
||||||
|
*/
|
||||||
|
public void setDifficulty(Difficulty difficulty);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Difficulty of the world.
|
||||||
|
*
|
||||||
|
* @return The difficulty of the world.
|
||||||
|
*/
|
||||||
|
public Difficulty getDifficulty();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents various map environment types that a world may be
|
* Represents various map environment types that a world may be
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue