mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-15 12:13:54 -07:00
Add ItemMeta factory and interfaces. This adds BUKKIT-15
Included with ItemMeta is a new serializable class Color. PotionEffects are now serializable. By: Wesley Wolfe <weswolf@aol.com>
This commit is contained in:
@@ -3,6 +3,8 @@ package org.bukkit.configuration;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -664,6 +666,43 @@ public interface ConfigurationSection {
|
||||
*/
|
||||
public boolean isItemStack(String path);
|
||||
|
||||
/**
|
||||
* Gets the requested Color by path.
|
||||
* <p />
|
||||
* If the Color does not exist but a default value has been specified, this
|
||||
* will return the default value. If the Color does not exist and no default
|
||||
* value was specified, this will return null.
|
||||
*
|
||||
* @param path Path of the Color to get.
|
||||
* @return Requested Color.
|
||||
*/
|
||||
public Color getColor(String path);
|
||||
|
||||
/**
|
||||
* Gets the requested {@link Color} by path, returning a default value if not found.
|
||||
* <p />
|
||||
* If the Color does not exist then the specified default value will returned
|
||||
* regardless of if a default has been identified in the root {@link Configuration}.
|
||||
*
|
||||
* @param path Path of the Color to get.
|
||||
* @param def The default value to return if the path is not found or is not an Color.
|
||||
* @return Requested Color.
|
||||
*/
|
||||
public Color getColor(String path, Color def);
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a Color.
|
||||
* <p />
|
||||
* If the path exists but is not a Color, this will return false. If the path does not
|
||||
* exist, this will return false. If the path does not exist but a default value
|
||||
* has been specified, this will check if that default value is a Color and return
|
||||
* appropriately.
|
||||
*
|
||||
* @param path Path of the Color to check.
|
||||
* @return Whether or not the specified path is an Color.
|
||||
*/
|
||||
public boolean isColor(String path);
|
||||
|
||||
/**
|
||||
* Gets the requested ConfigurationSection by path.
|
||||
* <p />
|
||||
|
@@ -1,16 +1,19 @@
|
||||
package org.bukkit.configuration;
|
||||
|
||||
import static org.bukkit.util.NumberConversions.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
import static org.bukkit.util.NumberConversions.*;
|
||||
|
||||
/**
|
||||
* A type of {@link ConfigurationSection} that is stored in memory.
|
||||
@@ -653,6 +656,21 @@ public class MemorySection implements ConfigurationSection {
|
||||
return val instanceof ItemStack;
|
||||
}
|
||||
|
||||
public Color getColor(String path) {
|
||||
Object def = getDefault(path);
|
||||
return getColor(path, (def instanceof Color) ? (Color) def : null);
|
||||
}
|
||||
|
||||
public Color getColor(String path, Color def) {
|
||||
Object val = get(path, def);
|
||||
return (val instanceof Color) ? (Color) val : def;
|
||||
}
|
||||
|
||||
public boolean isColor(String path) {
|
||||
Object val = get(path);
|
||||
return val instanceof Color;
|
||||
}
|
||||
|
||||
public ConfigurationSection getConfigurationSection(String path) {
|
||||
Object val = get(path, null);
|
||||
if (val != null) {
|
||||
|
@@ -10,8 +10,10 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@@ -27,6 +29,8 @@ public class ConfigurationSerialization {
|
||||
registerClass(Vector.class);
|
||||
registerClass(BlockVector.class);
|
||||
registerClass(ItemStack.class);
|
||||
registerClass(Color.class);
|
||||
registerClass(PotionEffect.class);
|
||||
}
|
||||
|
||||
protected ConfigurationSerialization(Class<? extends ConfigurationSerializable> clazz) {
|
||||
|
Reference in New Issue
Block a user