Update to Minecraft 1.8

For more information please see http://www.spigotmc.org/

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot
2014-11-26 08:15:59 +11:00
parent 84fc1478c5
commit 8344aacc6e
29 changed files with 1184 additions and 87 deletions

View File

@@ -0,0 +1,77 @@
package org.bukkit.block;
import org.bukkit.DyeColor;
import org.bukkit.block.banner.Pattern;
import java.util.List;
public interface Banner extends BlockState {
/**
* Returns the base color for this banner
*
* @return the base color
*/
DyeColor getBaseColor();
/**
* Sets the base color for this banner
*
* @param color the base color
*/
void setBaseColor(DyeColor color);
/**
* Returns a list of patterns on this banner
*
* @return the patterns
*/
List<Pattern> getPatterns();
/**
* Sets the patterns used on this banner
*
* @param patterns the new list of patterns
*/
void setPatterns(List<Pattern> patterns);
/**
* Adds a new pattern on top of the existing
* patterns
*
* @param pattern the new pattern to add
*/
void addPattern(Pattern pattern);
/**
* Returns the pattern at the specified index
*
* @param i the index
* @return the pattern
*/
Pattern getPattern(int i);
/**
* Removes the pattern at the specified index
*
* @param i the index
* @return the removed pattern
*/
Pattern removePattern(int i);
/**
* Sets the pattern at the specified index
*
* @param i the index
* @param pattern the new pattern
*/
void setPattern(int i, Pattern pattern);
/**
* Returns the number of patterns on this
* banner
*
* @return the number of patterns
*/
int numberOfPatterns();
}

View File

@@ -0,0 +1,61 @@
package org.bukkit.block.banner;
import org.bukkit.DyeColor;
import org.bukkit.configuration.serialization.SerializableAs;
@SerializableAs("Pattern")
public class Pattern {
private final DyeColor color;
private final PatternType pattern;
/**
* Creates a new pattern from the specified color and
* pattern type
*
* @param color the pattern color
* @param pattern the pattern type
*/
public Pattern(DyeColor color, PatternType pattern) {
this.color = color;
this.pattern = pattern;
}
/**
* Returns the color of the pattern
*
* @return the color of the pattern
*/
public DyeColor getColor() {
return color;
}
/**
* Returns the type of pattern
*
* @return the pattern type
*/
public PatternType getPattern() {
return pattern;
}
@Override
public int hashCode() {
int hash = 3;
hash = 97 * hash + (this.color != null ? this.color.hashCode() : 0);
hash = 97 * hash + (this.pattern != null ? this.pattern.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Pattern other = (Pattern) obj;
return this.color == other.color && this.pattern == other.pattern;
}
}

View File

@@ -0,0 +1,80 @@
package org.bukkit.block.banner;
import java.util.HashMap;
import java.util.Map;
public enum PatternType {
BASE("b"),
SQUARE_BOTTOM_LEFT("bl"),
SQUARE_BOTTOM_RIGHT("br"),
SQUARE_TOP_LEFT("tl"),
SQUARE_TOP_RIGHT("tr"),
STRIPE_BOTTOM("bs"),
STRIPE_TOP("ts"),
STRIPE_LEFT("ls"),
STRIPE_RIGHT("rs"),
STRIPE_CENTER("cs"),
STRIPE_MIDDLE("ms"),
STRIPE_DOWNRIGHT("drs"),
STRIPE_DOWNLEFT("dls"),
STRIPE_SMALL("ss"),
CROSS("cr"),
STRAIGHT_CROSS("sc"),
TRIANGLE_BOTTOM("bt"),
TRIANGLE_TOP("tt"),
TRIANGLES_BOTTOM("bts"),
TRIANGLES_TOP("tts"),
DIAGONAL_LEFT("ld"),
DIAGONAL_RIGHT("rd"),
DIAGONAL_LEFT_MIRROR("lud"),
DIAGONAL_RIGHT_MIRROR("rud"),
CIRCLE_MIDDLE("mc"),
RHOMBUS_MIDDLE("mr"),
HALF_VERTICAL("vh"),
HALF_HORIZONTAL("hh"),
HALF_VERTICAL_MIRROR("vhr"),
HALF_HORIZONTAL_MIRROR("hhb"),
BORDER("bo"),
CURLY_BORDER("cbo"),
CREEPER("cre"),
GRADIENT("gra"),
GRADIENT_UP("gru"),
BRICKS("bri"),
SKULL("sku"),
FLOWER("flo"),
MOJANG("moj");
private final String identifier;
private static final Map<String, PatternType> byString = new HashMap<String, PatternType>();
static {
for (PatternType p : values()) {
byString.put(p.identifier, p);
}
}
private PatternType(String key) {
this.identifier = key;
}
/**
* Returns the identifier used to represent
* this pattern type
*
* @return the pattern's identifier
*/
public String getIdentifier() {
return identifier;
}
/**
* Returns the pattern type which matches the passed
* identifier or null if no matches are found
*
* @param identifier the identifier
* @return the matched pattern type or null
*/
public static PatternType getByIdentifier(String identifier) {
return byString.get(identifier);
}
}