@@ -1,245 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache license, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the license for the specific language governing permissions and
|
||||
* limitations under the license.
|
||||
*/
|
||||
package org.apache.logging.log4j.core.appender;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.apache.logging.log4j.core.Filter;
|
||||
import org.apache.logging.log4j.core.Layout;
|
||||
import org.apache.logging.log4j.core.config.plugins.Plugin;
|
||||
import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
|
||||
import org.apache.logging.log4j.core.config.plugins.PluginElement;
|
||||
import org.apache.logging.log4j.core.config.plugins.PluginFactory;
|
||||
import org.apache.logging.log4j.core.helpers.Booleans;
|
||||
import org.apache.logging.log4j.core.helpers.Loader;
|
||||
import org.apache.logging.log4j.core.layout.PatternLayout;
|
||||
import org.apache.logging.log4j.util.PropertiesUtil;
|
||||
|
||||
/**
|
||||
* ConsoleAppender appends log events to <code>System.out</code> or
|
||||
* <code>System.err</code> using a layout specified by the user. The
|
||||
* default target is <code>System.out</code>.
|
||||
* @doubt accessing System.out or .err as a byte stream instead of a writer
|
||||
* bypasses the JVM's knowledge of the proper encoding. (RG) Encoding
|
||||
* is handled within the Layout. Typically, a Layout will generate a String
|
||||
* and then call getBytes which may use a configured encoding or the system
|
||||
* default. OTOH, a Writer cannot print byte streams.
|
||||
*/
|
||||
@Plugin(name = "Console", category = "Core", elementType = "appender", printObject = true)
|
||||
public final class ConsoleAppender extends AbstractOutputStreamAppender {
|
||||
|
||||
private static final String JANSI_CLASS = "org.fusesource.jansi.WindowsAnsiOutputStream";
|
||||
private static ConsoleManagerFactory factory = new ConsoleManagerFactory();
|
||||
|
||||
/**
|
||||
* Enumeration of console destinations.
|
||||
*/
|
||||
public enum Target {
|
||||
/** Standard output. */
|
||||
SYSTEM_OUT,
|
||||
/** Standard error output. */
|
||||
SYSTEM_ERR
|
||||
}
|
||||
|
||||
private ConsoleAppender(final String name, final Layout<? extends Serializable> layout, final Filter filter,
|
||||
final OutputStreamManager manager,
|
||||
final boolean ignoreExceptions) {
|
||||
super(name, layout, filter, ignoreExceptions, true, manager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Console Appender.
|
||||
* @param layout The layout to use (required).
|
||||
* @param filter The Filter or null.
|
||||
* @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
|
||||
* @param follow If true will follow changes to the underlying output stream.
|
||||
* @param name The name of the Appender (required).
|
||||
* @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
|
||||
* they are propagated to the caller.
|
||||
* @return The ConsoleAppender.
|
||||
*/
|
||||
@PluginFactory
|
||||
public static ConsoleAppender createAppender(
|
||||
@PluginElement("Layout") Layout<? extends Serializable> layout,
|
||||
@PluginElement("Filters") final Filter filter,
|
||||
@PluginAttribute("target") final String t,
|
||||
@PluginAttribute("name") final String name,
|
||||
@PluginAttribute("follow") final String follow,
|
||||
@PluginAttribute("ignoreExceptions") final String ignore) {
|
||||
if (name == null) {
|
||||
LOGGER.error("No name provided for ConsoleAppender");
|
||||
return null;
|
||||
}
|
||||
if (layout == null) {
|
||||
layout = PatternLayout.createLayout(null, null, null, null, null);
|
||||
}
|
||||
final boolean isFollow = Boolean.parseBoolean(follow);
|
||||
final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
|
||||
final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
|
||||
return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
|
||||
}
|
||||
|
||||
private static OutputStreamManager getManager(final boolean follow, final Target target, final Layout<? extends Serializable> layout) {
|
||||
final String type = target.name();
|
||||
final OutputStream os = getOutputStream(follow, target);
|
||||
return OutputStreamManager.getManager(target.name() + "." + follow, new FactoryData(os, type, layout), factory);
|
||||
}
|
||||
|
||||
private static OutputStream getOutputStream(final boolean follow, final Target target) {
|
||||
final String enc = Charset.defaultCharset().name();
|
||||
PrintStream printStream = null;
|
||||
try {
|
||||
printStream = target == Target.SYSTEM_OUT ?
|
||||
follow ? new PrintStream(new SystemOutStream(), true, enc) : System.out :
|
||||
follow ? new PrintStream(new SystemErrStream(), true, enc) : System.err;
|
||||
} catch (final UnsupportedEncodingException ex) { // should never happen
|
||||
throw new IllegalStateException("Unsupported default encoding " + enc, ex);
|
||||
}
|
||||
final PropertiesUtil propsUtil = PropertiesUtil.getProperties();
|
||||
if (!propsUtil.getStringProperty("os.name").startsWith("Windows") ||
|
||||
propsUtil.getBooleanProperty("log4j.skipJansi")) {
|
||||
return printStream;
|
||||
}
|
||||
try {
|
||||
final ClassLoader loader = Loader.getClassLoader();
|
||||
// We type the parameter as a wildcard to avoid a hard reference to Jansi.
|
||||
final Class<?> clazz = loader.loadClass(JANSI_CLASS);
|
||||
final Constructor<?> constructor = clazz.getConstructor(OutputStream.class);
|
||||
return (OutputStream) constructor.newInstance(printStream);
|
||||
} catch (final ClassNotFoundException cnfe) {
|
||||
LOGGER.debug("Jansi is not installed, cannot find {}", JANSI_CLASS);
|
||||
} catch (final NoSuchMethodException nsme) {
|
||||
LOGGER.warn("{} is missing the proper constructor", JANSI_CLASS);
|
||||
} catch (final Throwable ex) { // CraftBukkit - Exception -> Throwable
|
||||
LOGGER.warn("Unable to instantiate {}", JANSI_CLASS);
|
||||
}
|
||||
return printStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* An implementation of OutputStream that redirects to the current System.err.
|
||||
*/
|
||||
private static class SystemErrStream extends OutputStream {
|
||||
public SystemErrStream() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// do not close sys err!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
System.err.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final byte[] b) throws IOException {
|
||||
System.err.write(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final byte[] b, final int off, final int len)
|
||||
throws IOException {
|
||||
System.err.write(b, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final int b) {
|
||||
System.err.write(b);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An implementation of OutputStream that redirects to the current System.out.
|
||||
*/
|
||||
private static class SystemOutStream extends OutputStream {
|
||||
public SystemOutStream() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// do not close sys out!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
System.out.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final byte[] b) throws IOException {
|
||||
System.out.write(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final byte[] b, final int off, final int len)
|
||||
throws IOException {
|
||||
System.out.write(b, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final int b) throws IOException {
|
||||
System.out.write(b);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Data to pass to factory method.
|
||||
*/
|
||||
private static class FactoryData {
|
||||
private final OutputStream os;
|
||||
private final String type;
|
||||
private final Layout<? extends Serializable> layout;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param os The OutputStream.
|
||||
* @param type The name of the target.
|
||||
* @param layout A Serializable layout
|
||||
*/
|
||||
public FactoryData(final OutputStream os, final String type, final Layout<? extends Serializable> layout) {
|
||||
this.os = os;
|
||||
this.type = type;
|
||||
this.layout = layout;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory to create the Appender.
|
||||
*/
|
||||
private static class ConsoleManagerFactory implements ManagerFactory<OutputStreamManager, FactoryData> {
|
||||
|
||||
/**
|
||||
* Create an OutputStreamManager.
|
||||
* @param name The name of the entity to manage.
|
||||
* @param data The data required to create the entity.
|
||||
* @return The OutputStreamManager
|
||||
*/
|
||||
@Override
|
||||
public OutputStreamManager createManager(final String name, final FactoryData data) {
|
||||
return new OutputStreamManager(data.os, data.type, data.layout);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -114,12 +114,9 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
import org.yaml.snakeyaml.error.MarkedYAMLException;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import com.avaje.ebean.config.DataSourceConfig;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.dbplatform.SQLitePlatform;
|
||||
import com.avaje.ebeaninternal.server.lib.sql.TransactionIsolation;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapMaker;
|
||||
@@ -130,6 +127,8 @@ import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.base64.Base64;
|
||||
import jline.console.ConsoleReader;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.event.server.TabCompleteEvent;
|
||||
|
||||
public final class CraftServer implements Server {
|
||||
@@ -150,7 +149,7 @@ public final class CraftServer implements Server {
|
||||
private YamlConfiguration configuration;
|
||||
private YamlConfiguration commandsConfiguration;
|
||||
private final Yaml yaml = new Yaml(new SafeConstructor());
|
||||
private final Map<UUID, OfflinePlayer> offlinePlayers = new MapMaker().softValues().makeMap();
|
||||
private final Map<UUID, OfflinePlayer> offlinePlayers = new MapMaker().weakValues().makeMap();
|
||||
private final EntityMetadataStore entityMetadata = new EntityMetadataStore();
|
||||
private final PlayerMetadataStore playerMetadata = new PlayerMetadataStore();
|
||||
private final WorldMetadataStore worldMetadata = new WorldMetadataStore();
|
||||
@@ -379,13 +378,6 @@ public final class CraftServer implements Server {
|
||||
return bukkitVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public Player[] _INVALID_getOnlinePlayers() {
|
||||
return getOnlinePlayers().toArray(EMPTY_PLAYER_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CraftPlayer> getOnlinePlayers() {
|
||||
return this.playerView;
|
||||
@@ -698,6 +690,7 @@ public final class CraftServer implements Server {
|
||||
pluginManager.clearPlugins();
|
||||
commandMap.clearCommands();
|
||||
resetRecipes();
|
||||
reloadData();
|
||||
overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
|
||||
int pollCount = 0;
|
||||
@@ -729,6 +722,11 @@ public final class CraftServer implements Server {
|
||||
enablePlugins(PluginLoadOrder.POSTWORLD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadData() {
|
||||
console.reload();
|
||||
}
|
||||
|
||||
private void loadIcon() {
|
||||
icon = new CraftIconCache(null);
|
||||
try {
|
||||
@@ -832,7 +830,7 @@ public final class CraftServer implements Server {
|
||||
generator = getGenerator(name);
|
||||
}
|
||||
|
||||
Convertable converter = new WorldLoaderServer(getWorldContainer(), getHandle().getServer().getDataConverterManager());
|
||||
Convertable converter = new WorldLoaderServer(getWorldContainer(), getHandle().getServer().dataConverterManager);
|
||||
if (converter.isConvertable(name)) {
|
||||
getLogger().info("Converting world '" + name + "'");
|
||||
converter.convert(name, new IProgressUpdate() {
|
||||
@@ -865,7 +863,7 @@ public final class CraftServer implements Server {
|
||||
} while(used);
|
||||
boolean hardcore = false;
|
||||
|
||||
IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, true, getHandle().getServer().getDataConverterManager());
|
||||
IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, true, getHandle().getServer().dataConverterManager);
|
||||
WorldData worlddata = sdm.getWorldData();
|
||||
WorldSettings worldSettings = null;
|
||||
if (worlddata == null) {
|
||||
@@ -1024,25 +1022,6 @@ public final class CraftServer implements Server {
|
||||
playerList.savePlayers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureDbConfig(ServerConfig config) {
|
||||
Validate.notNull(config, "Config cannot be null");
|
||||
|
||||
DataSourceConfig ds = new DataSourceConfig();
|
||||
ds.setDriver(configuration.getString("database.driver"));
|
||||
ds.setUrl(configuration.getString("database.url"));
|
||||
ds.setUsername(configuration.getString("database.username"));
|
||||
ds.setPassword(configuration.getString("database.password"));
|
||||
ds.setIsolationLevel(TransactionIsolation.getLevel(configuration.getString("database.isolation")));
|
||||
|
||||
if (ds.getDriver().contains("sqlite")) {
|
||||
config.setDatabasePlatform(new SQLitePlatform());
|
||||
config.getDatabasePlatform().getDbDdlSyntax().setIdentity("");
|
||||
}
|
||||
|
||||
config.setDataSourceConfig(ds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addRecipe(Recipe recipe) {
|
||||
CraftRecipe toAdd;
|
||||
@@ -1060,7 +1039,6 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
}
|
||||
toAdd.addToCraftingManager();
|
||||
CraftingManager.getInstance().sort();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1090,7 +1068,7 @@ public final class CraftServer implements Server {
|
||||
|
||||
@Override
|
||||
public void clearRecipes() {
|
||||
CraftingManager.getInstance().recipes.clear();
|
||||
CraftingManager.recipes = new RegistryMaterials();
|
||||
RecipesFurnace.getInstance().recipes.clear();
|
||||
RecipesFurnace.getInstance().customRecipes.clear();
|
||||
RecipesFurnace.getInstance().customExperience.clear();
|
||||
@@ -1098,7 +1076,8 @@ public final class CraftServer implements Server {
|
||||
|
||||
@Override
|
||||
public void resetRecipes() {
|
||||
CraftingManager.getInstance().recipes = new CraftingManager().recipes;
|
||||
CraftingManager.recipes = new RegistryMaterials();
|
||||
CraftingManager.init();
|
||||
RecipesFurnace.getInstance().recipes = new RecipesFurnace().recipes;
|
||||
RecipesFurnace.getInstance().customRecipes.clear();
|
||||
RecipesFurnace.getInstance().customExperience.clear();
|
||||
@@ -1674,6 +1653,14 @@ public final class CraftServer implements Server {
|
||||
return entity == null ? null : entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.advancement.Advancement getAdvancement(NamespacedKey key) {
|
||||
Preconditions.checkArgument(key != null, "key");
|
||||
|
||||
Advancement advancement = console.getAdvancementData().a(CraftNamespacedKey.toMinecraft(key));
|
||||
return (advancement == null) ? null : advancement.bukkit;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public UnsafeValues getUnsafe() {
|
||||
|
||||
@@ -37,6 +37,8 @@ public enum CraftSound {
|
||||
BLOCK_ENDERCHEST_CLOSE("block.enderchest.close"),
|
||||
BLOCK_ENDERCHEST_OPEN("block.enderchest.open"),
|
||||
BLOCK_END_GATEWAY_SPAWN("block.end_gateway.spawn"),
|
||||
BLOCK_END_PORTAL_FRAME_FILL("block.end_portal_frame.fill"),
|
||||
BLOCK_END_PORTAL_SPAWN("block.end_portal.spawn"),
|
||||
BLOCK_FENCE_GATE_CLOSE("block.fence_gate.close"),
|
||||
BLOCK_FENCE_GATE_OPEN("block.fence_gate.open"),
|
||||
BLOCK_FIRE_AMBIENT("block.fire.ambient"),
|
||||
@@ -79,10 +81,15 @@ public enum CraftSound {
|
||||
BLOCK_METAL_STEP("block.metal.step"),
|
||||
BLOCK_NOTE_BASEDRUM("block.note.basedrum"),
|
||||
BLOCK_NOTE_BASS("block.note.bass"),
|
||||
BLOCK_NOTE_BELL("block.note.bell"),
|
||||
BLOCK_NOTE_CHIME("block.note.chime"),
|
||||
BLOCK_NOTE_FLUTE("block.note.flute"),
|
||||
BLOCK_NOTE_GUITAR("block.note.guitar"),
|
||||
BLOCK_NOTE_HARP("block.note.harp"),
|
||||
BLOCK_NOTE_HAT("block.note.hat"),
|
||||
BLOCK_NOTE_PLING("block.note.pling"),
|
||||
BLOCK_NOTE_SNARE("block.note.snare"),
|
||||
BLOCK_NOTE_XYLOPHONE("block.note.xylophone"),
|
||||
BLOCK_PISTON_CONTRACT("block.piston.contract"),
|
||||
BLOCK_PISTON_EXTEND("block.piston.extend"),
|
||||
BLOCK_PORTAL_AMBIENT("block.portal.ambient"),
|
||||
@@ -152,6 +159,9 @@ public enum CraftSound {
|
||||
ENTITY_BLAZE_DEATH("entity.blaze.death"),
|
||||
ENTITY_BLAZE_HURT("entity.blaze.hurt"),
|
||||
ENTITY_BLAZE_SHOOT("entity.blaze.shoot"),
|
||||
ENTITY_BOAT_PADDLE_LAND("entity.boat.paddle_land"),
|
||||
ENTITY_BOAT_PADDLE_WATER("entity.boat.paddle_water"),
|
||||
ENTITY_BOBBER_RETRIEVE("entity.bobber.retrieve"),
|
||||
ENTITY_BOBBER_SPLASH("entity.bobber.splash"),
|
||||
ENTITY_BOBBER_THROW("entity.bobber.throw"),
|
||||
ENTITY_CAT_AMBIENT("entity.cat.ambient"),
|
||||
@@ -194,6 +204,7 @@ public enum CraftSound {
|
||||
ENTITY_ENDERDRAGON_GROWL("entity.enderdragon.growl"),
|
||||
ENTITY_ENDERDRAGON_HURT("entity.enderdragon.hurt"),
|
||||
ENTITY_ENDERDRAGON_SHOOT("entity.enderdragon.shoot"),
|
||||
ENTITY_ENDEREYE_DEATH("entity.endereye.death"),
|
||||
ENTITY_ENDEREYE_LAUNCH("entity.endereye.launch"),
|
||||
ENTITY_ENDERMEN_AMBIENT("entity.endermen.ambient"),
|
||||
ENTITY_ENDERMEN_DEATH("entity.endermen.death"),
|
||||
@@ -272,6 +283,13 @@ public enum CraftSound {
|
||||
ENTITY_HUSK_DEATH("entity.husk.death"),
|
||||
ENTITY_HUSK_HURT("entity.husk.hurt"),
|
||||
ENTITY_HUSK_STEP("entity.husk.step"),
|
||||
ENTITY_ILLUSION_ILLAGER_AMBIENT("entity.illusion_illager.ambient"),
|
||||
ENTITY_ILLUSION_ILLAGER_CAST_SPELL("entity.illusion_illager.cast_spell"),
|
||||
ENTITY_ILLUSION_ILLAGER_DEATH("entity.illusion_illager.death"),
|
||||
ENTITY_ILLUSION_ILLAGER_HURT("entity.illusion_illager.hurt"),
|
||||
ENTITY_ILLUSION_ILLAGER_MIRROR_MOVE("entity.illusion_illager.mirror_move"),
|
||||
ENTITY_ILLUSION_ILLAGER_PREPARE_BLINDNESS("entity.illusion_illager.prepare_blindness"),
|
||||
ENTITY_ILLUSION_ILLAGER_PREPARE_MIRROR("entity.illusion_illager.prepare_mirror"),
|
||||
ENTITY_IRONGOLEM_ATTACK("entity.irongolem.attack"),
|
||||
ENTITY_IRONGOLEM_DEATH("entity.irongolem.death"),
|
||||
ENTITY_IRONGOLEM_HURT("entity.irongolem.hurt"),
|
||||
@@ -310,6 +328,39 @@ public enum CraftSound {
|
||||
ENTITY_MULE_HURT("entity.mule.hurt"),
|
||||
ENTITY_PAINTING_BREAK("entity.painting.break"),
|
||||
ENTITY_PAINTING_PLACE("entity.painting.place"),
|
||||
ENTITY_PARROT_AMBIENT("entity.parrot.ambient"),
|
||||
ENTITY_PARROT_DEATH("entity.parrot.death"),
|
||||
ENTITY_PARROT_EAT("entity.parrot.eat"),
|
||||
ENTITY_PARROT_FLY("entity.parrot.fly"),
|
||||
ENTITY_PARROT_HURT("entity.parrot.hurt"),
|
||||
ENTITY_PARROT_IMITATE_BLAZE("entity.parrot.imitate.blaze"),
|
||||
ENTITY_PARROT_IMITATE_CREEPER("entity.parrot.imitate.creeper"),
|
||||
ENTITY_PARROT_IMITATE_ELDER_GUARDIAN("entity.parrot.imitate.elder_guardian"),
|
||||
ENTITY_PARROT_IMITATE_ENDERDRAGON("entity.parrot.imitate.enderdragon"),
|
||||
ENTITY_PARROT_IMITATE_ENDERMAN("entity.parrot.imitate.enderman"),
|
||||
ENTITY_PARROT_IMITATE_ENDERMITE("entity.parrot.imitate.endermite"),
|
||||
ENTITY_PARROT_IMITATE_EVOCATION_ILLAGER("entity.parrot.imitate.evocation_illager"),
|
||||
ENTITY_PARROT_IMITATE_GHAST("entity.parrot.imitate.ghast"),
|
||||
ENTITY_PARROT_IMITATE_HUSK("entity.parrot.imitate.husk"),
|
||||
ENTITY_PARROT_IMITATE_ILLUSION_ILLAGER("entity.parrot.imitate.illusion_illager"),
|
||||
ENTITY_PARROT_IMITATE_MAGMACUBE("entity.parrot.imitate.magmacube"),
|
||||
ENTITY_PARROT_IMITATE_POLAR_BEAR("entity.parrot.imitate.polar_bear"),
|
||||
ENTITY_PARROT_IMITATE_SHULKER("entity.parrot.imitate.shulker"),
|
||||
ENTITY_PARROT_IMITATE_SILVERFISH("entity.parrot.imitate.silverfish"),
|
||||
ENTITY_PARROT_IMITATE_SKELETON("entity.parrot.imitate.skeleton"),
|
||||
ENTITY_PARROT_IMITATE_SLIME("entity.parrot.imitate.slime"),
|
||||
ENTITY_PARROT_IMITATE_SPIDER("entity.parrot.imitate.spider"),
|
||||
ENTITY_PARROT_IMITATE_STRAY("entity.parrot.imitate.stray"),
|
||||
ENTITY_PARROT_IMITATE_VEX("entity.parrot.imitate.vex"),
|
||||
ENTITY_PARROT_IMITATE_VINDICATION_ILLAGER("entity.parrot.imitate.vindication_illager"),
|
||||
ENTITY_PARROT_IMITATE_WITCH("entity.parrot.imitate.witch"),
|
||||
ENTITY_PARROT_IMITATE_WITHER("entity.parrot.imitate.wither"),
|
||||
ENTITY_PARROT_IMITATE_WITHER_SKELETON("entity.parrot.imitate.wither_skeleton"),
|
||||
ENTITY_PARROT_IMITATE_WOLF("entity.parrot.imitate.wolf"),
|
||||
ENTITY_PARROT_IMITATE_ZOMBIE("entity.parrot.imitate.zombie"),
|
||||
ENTITY_PARROT_IMITATE_ZOMBIE_PIGMAN("entity.parrot.imitate.zombie_pigman"),
|
||||
ENTITY_PARROT_IMITATE_ZOMBIE_VILLAGER("entity.parrot.imitate.zombie_villager"),
|
||||
ENTITY_PARROT_STEP("entity.parrot.step"),
|
||||
ENTITY_PIG_AMBIENT("entity.pig.ambient"),
|
||||
ENTITY_PIG_DEATH("entity.pig.death"),
|
||||
ENTITY_PIG_HURT("entity.pig.hurt"),
|
||||
@@ -326,6 +377,8 @@ public enum CraftSound {
|
||||
ENTITY_PLAYER_BURP("entity.player.burp"),
|
||||
ENTITY_PLAYER_DEATH("entity.player.death"),
|
||||
ENTITY_PLAYER_HURT("entity.player.hurt"),
|
||||
ENTITY_PLAYER_HURT_DROWN("entity.player.hurt_drown"),
|
||||
ENTITY_PLAYER_HURT_ON_FIRE("entity.player.hurt_on_fire"),
|
||||
ENTITY_PLAYER_LEVELUP("entity.player.levelup"),
|
||||
ENTITY_PLAYER_SMALL_FALL("entity.player.small_fall"),
|
||||
ENTITY_PLAYER_SPLASH("entity.player.splash"),
|
||||
|
||||
@@ -4,7 +4,6 @@ import net.minecraft.server.EntityTypes;
|
||||
import net.minecraft.server.EntityTypes.MonsterEggInfo;
|
||||
import net.minecraft.server.StatisticList;
|
||||
|
||||
import org.bukkit.Achievement;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -12,7 +11,6 @@ import org.bukkit.entity.EntityType;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
@@ -20,21 +18,9 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
|
||||
public class CraftStatistic {
|
||||
private static final BiMap<String, org.bukkit.Statistic> statistics;
|
||||
private static final BiMap<String, org.bukkit.Achievement> achievements;
|
||||
|
||||
static {
|
||||
ImmutableMap<String, org.bukkit.Achievement> specialCases = ImmutableMap.<String, org.bukkit.Achievement> builder()
|
||||
.put("achievement.buildWorkBench", Achievement.BUILD_WORKBENCH)
|
||||
.put("achievement.diamonds", Achievement.GET_DIAMONDS)
|
||||
.put("achievement.portal", Achievement.NETHER_PORTAL)
|
||||
.put("achievement.ghast", Achievement.GHAST_RETURN)
|
||||
.put("achievement.theEnd", Achievement.END_PORTAL)
|
||||
.put("achievement.theEnd2", Achievement.THE_END)
|
||||
.put("achievement.blazeRod", Achievement.GET_BLAZE_ROD)
|
||||
.put("achievement.potion", Achievement.BREW_POTION)
|
||||
.build();
|
||||
ImmutableBiMap.Builder<String, org.bukkit.Statistic> statisticBuilder = ImmutableBiMap.<String, org.bukkit.Statistic>builder();
|
||||
ImmutableBiMap.Builder<String, org.bukkit.Achievement> achievementBuilder = ImmutableBiMap.<String, org.bukkit.Achievement>builder();
|
||||
for (Statistic statistic : Statistic.values()) {
|
||||
if (statistic == Statistic.PLAY_ONE_TICK) {
|
||||
statisticBuilder.put("stat.playOneMinute", statistic);
|
||||
@@ -42,29 +28,12 @@ public class CraftStatistic {
|
||||
statisticBuilder.put("stat." + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, statistic.name()), statistic);
|
||||
}
|
||||
}
|
||||
for (Achievement achievement : Achievement.values()) {
|
||||
if (specialCases.values().contains(achievement)) {
|
||||
continue;
|
||||
}
|
||||
achievementBuilder.put("achievement." + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, achievement.name()), achievement);
|
||||
}
|
||||
|
||||
achievementBuilder.putAll(specialCases);
|
||||
|
||||
statistics = statisticBuilder.build();
|
||||
achievements = achievementBuilder.build();
|
||||
}
|
||||
|
||||
private CraftStatistic() {}
|
||||
|
||||
public static org.bukkit.Achievement getBukkitAchievement(net.minecraft.server.Achievement achievement) {
|
||||
return getBukkitAchievementByName(achievement.name);
|
||||
}
|
||||
|
||||
public static org.bukkit.Achievement getBukkitAchievementByName(String name) {
|
||||
return achievements.get(name);
|
||||
}
|
||||
|
||||
public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.server.Statistic statistic) {
|
||||
return getBukkitStatisticByName(statistic.name);
|
||||
}
|
||||
@@ -101,10 +70,6 @@ public class CraftStatistic {
|
||||
return StatisticList.getStatistic(statistics.inverse().get(statistic));
|
||||
}
|
||||
|
||||
public static net.minecraft.server.Achievement getNMSAchievement(org.bukkit.Achievement achievement) {
|
||||
return (net.minecraft.server.Achievement) StatisticList.getStatistic(achievements.inverse().get(achievement));
|
||||
}
|
||||
|
||||
public static net.minecraft.server.Statistic getMaterialStatistic(org.bukkit.Statistic stat, Material material) {
|
||||
try {
|
||||
if (stat == Statistic.MINE_BLOCK) {
|
||||
|
||||
@@ -599,7 +599,7 @@ public class CraftWorld implements World {
|
||||
byte[] biomevals = chunk.getBiomeIndex();
|
||||
biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte) BiomeBase.REGISTRY_ID.a(bb);
|
||||
|
||||
chunk.e(); // SPIGOT-2890 // PAIL: markDirty
|
||||
chunk.markDirty(); // SPIGOT-2890
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1041,6 +1041,8 @@ public class CraftWorld implements World {
|
||||
entity = new EntityWolf(world);
|
||||
} else if (Ocelot.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityOcelot(world);
|
||||
} else if (Parrot.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityParrot(world);
|
||||
}
|
||||
} else if (PigZombie.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityPigZombie(world);
|
||||
@@ -1088,12 +1090,18 @@ public class CraftWorld implements World {
|
||||
entity = new EntityArmorStand(world, x, y, z);
|
||||
} else if (PolarBear.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityPolarBear(world);
|
||||
} else if (Evoker.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityEvoker(world);
|
||||
} else if (Vex.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityVex(world);
|
||||
} else if (Vindicator.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityVindicator(world);
|
||||
} else if (Illager.class.isAssignableFrom(clazz)) {
|
||||
if (Spellcaster.class.isAssignableFrom(clazz)) {
|
||||
if (Evoker.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityEvoker(world);
|
||||
} else if (Illusioner.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityIllagerIllusioner(world);
|
||||
}
|
||||
} else if (Vindicator.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityVindicator(world);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
@@ -1227,7 +1235,7 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
public int getSeaLevel() {
|
||||
return world.K(); // PAIL: rename
|
||||
return world.getSeaLevel();
|
||||
}
|
||||
|
||||
public boolean getKeepSpawnInMemory() {
|
||||
|
||||
@@ -169,11 +169,11 @@ public class Main {
|
||||
useConsole = false;
|
||||
}
|
||||
|
||||
if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
|
||||
if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
|
||||
Date buildDate = new SimpleDateFormat("yyyyMMdd-HHmm").parse(Main.class.getPackage().getImplementationVendor());
|
||||
|
||||
Calendar deadline = Calendar.getInstance();
|
||||
deadline.add(Calendar.DAY_OF_YEAR, -14);
|
||||
deadline.add(Calendar.DAY_OF_YEAR, -3);
|
||||
if (buildDate.before(deadline.getTime())) {
|
||||
System.err.println("*** Error, this build is outdated ***");
|
||||
System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/ ***");
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.bukkit.craftbukkit.advancement;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import net.minecraft.server.Advancement;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
|
||||
public class CraftAdvancement implements org.bukkit.advancement.Advancement {
|
||||
|
||||
private final Advancement handle;
|
||||
|
||||
public CraftAdvancement(Advancement handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
public Advancement getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return CraftNamespacedKey.fromMinecraft(handle.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getCriteria() {
|
||||
return Collections.unmodifiableCollection(handle.getCriteria().keySet());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package org.bukkit.craftbukkit.advancement;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import net.minecraft.server.AdvancementDataPlayer;
|
||||
import net.minecraft.server.CriterionProgress;
|
||||
import org.bukkit.advancement.Advancement;
|
||||
import org.bukkit.advancement.AdvancementProgress;
|
||||
|
||||
public class CraftAdvancementProgress implements AdvancementProgress {
|
||||
|
||||
private final CraftAdvancement advancement;
|
||||
private final AdvancementDataPlayer playerData;
|
||||
private final net.minecraft.server.AdvancementProgress handle;
|
||||
|
||||
public CraftAdvancementProgress(CraftAdvancement advancement, AdvancementDataPlayer player, net.minecraft.server.AdvancementProgress handle) {
|
||||
this.advancement = advancement;
|
||||
this.playerData = player;
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Advancement getAdvancement() {
|
||||
return advancement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDone() {
|
||||
return handle.isDone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean awardCriteria(String criteria) {
|
||||
return playerData.grantCriteria(advancement.getHandle(), criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeCriteria(String criteria) {
|
||||
return playerData.revokeCritera(advancement.getHandle(), criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getDateAwarded(String criteria) {
|
||||
CriterionProgress criterion = handle.getCriterionProgress(criteria);
|
||||
return (criterion == null) ? null : criterion.getDate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getRemainingCriteria() {
|
||||
return Collections.unmodifiableCollection(Lists.newArrayList(handle.getRemainingCriteria()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getAwardedCriteria() {
|
||||
return Collections.unmodifiableCollection(Lists.newArrayList(handle.getAwardedCriteria()));
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,6 @@ public class CraftBeacon extends CraftContainer implements Beacon {
|
||||
|
||||
@Override
|
||||
public void setCustomName(String name) {
|
||||
beacon.a(name); // PAIL: setCustomName
|
||||
beacon.setCustomName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.server.EnumColor;
|
||||
import net.minecraft.server.TileEntity;
|
||||
import net.minecraft.server.TileEntityBed;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Bed;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
|
||||
public class CraftBed extends CraftBlockState implements Bed {
|
||||
|
||||
private final TileEntityBed bed;
|
||||
private DyeColor color;
|
||||
|
||||
public CraftBed(Block block) {
|
||||
super(block);
|
||||
|
||||
bed = (TileEntityBed) ((CraftWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ());
|
||||
color = DyeColor.getByWoolData((byte) bed.a().getColorIndex());
|
||||
}
|
||||
|
||||
public CraftBed(Material material, TileEntityBed te) {
|
||||
super(material);
|
||||
|
||||
bed = te;
|
||||
color = DyeColor.getByWoolData((byte) bed.a().getColorIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() {
|
||||
return bed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DyeColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(DyeColor color) {
|
||||
Preconditions.checkArgument(color != null, "color");
|
||||
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean force, boolean applyPhysics) {
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
if (result) {
|
||||
bed.a(EnumColor.fromColorIndex(color.getWoolData()));
|
||||
bed.update();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -333,6 +333,8 @@ public class CraftBlock implements Block {
|
||||
case REDSTONE_COMPARATOR_OFF:
|
||||
case REDSTONE_COMPARATOR_ON:
|
||||
return new CraftComparator(this);
|
||||
case BED_BLOCK:
|
||||
return new CraftBed(this);
|
||||
default:
|
||||
return new CraftBlockState(this);
|
||||
}
|
||||
@@ -351,7 +353,7 @@ public class CraftBlock implements Block {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Biome.valueOf(BiomeBase.REGISTRY_ID.b(base).a().toUpperCase(java.util.Locale.ENGLISH));
|
||||
return Biome.valueOf(BiomeBase.REGISTRY_ID.b(base).getKey().toUpperCase(java.util.Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public static BiomeBase biomeToBiomeBase(Biome bio) {
|
||||
|
||||
@@ -67,6 +67,6 @@ public class CraftBrewingStand extends CraftContainer implements BrewingStand {
|
||||
|
||||
@Override
|
||||
public void setCustomName(String name) {
|
||||
brewingStand.a(name); // PAIL: setCustomName
|
||||
brewingStand.setCustomName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,11 @@ public class CraftContainer extends CraftBlockState implements Lockable {
|
||||
|
||||
@Override
|
||||
public String getLock() {
|
||||
return container.getLock().b(); // PAIL: getKey
|
||||
return container.getLock().getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLock(String key) {
|
||||
container.a(key == null ? ChestLock.a : new ChestLock(key)); // PAIL: setLock
|
||||
container.setLock(key == null ? ChestLock.a : new ChestLock(key));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpa
|
||||
|
||||
public EntityType getSpawnedType() {
|
||||
MinecraftKey key = spawner.getSpawner().getMobName();
|
||||
return (key == null) ? EntityType.PIG : EntityType.fromName(key.a());
|
||||
return (key == null) ? EntityType.PIG : EntityType.fromName(key.getKey());
|
||||
}
|
||||
|
||||
public void setSpawnedType(EntityType entityType) {
|
||||
@@ -37,7 +37,7 @@ public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpa
|
||||
}
|
||||
|
||||
public String getCreatureTypeName() {
|
||||
return spawner.getSpawner().getMobName().a();
|
||||
return spawner.getSpawner().getMobName().getKey();
|
||||
}
|
||||
|
||||
public void setCreatureTypeByName(String creatureType) {
|
||||
|
||||
@@ -38,6 +38,6 @@ public class CraftEnchantingTable extends CraftBlockState implements EnchantingT
|
||||
|
||||
@Override
|
||||
public void setCustomName(String name) {
|
||||
enchant.a(name); // PAIL: setCustomName
|
||||
enchant.setCustomName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class CraftFurnace extends CraftContainer implements Furnace {
|
||||
|
||||
@Override
|
||||
public void setCustomName(String name) {
|
||||
furnace.a(name); // PAIL: setCustomName
|
||||
furnace.setCustomName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,6 +29,6 @@ public class CraftLootable extends CraftContainer implements Nameable {
|
||||
|
||||
@Override
|
||||
public void setCustomName(String name) {
|
||||
te.a(name); // PAIL: setCustomName
|
||||
te.setCustomName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,6 @@ public class CraftShulkerBox extends CraftLootable implements ShulkerBox {
|
||||
|
||||
@Override
|
||||
public DyeColor getColor() {
|
||||
return DyeColor.getByWoolData((byte) ((BlockShulkerBox) box.getBlock()).b.getColorIndex());
|
||||
return DyeColor.getByWoolData((byte) ((BlockShulkerBox) box.getBlock()).color.getColorIndex());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,18 +9,18 @@ import org.apache.commons.lang.Validate;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.command.ProxiedCommandSender;
|
||||
import org.bukkit.command.RemoteConsoleCommandSender;
|
||||
import org.bukkit.command.defaults.*;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftMinecartCommand;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.minecart.CommandMinecart;
|
||||
|
||||
public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
public final class VanillaCommandWrapper extends Command {
|
||||
protected final CommandAbstract vanillaCommand;
|
||||
|
||||
public VanillaCommandWrapper(CommandAbstract vanillaCommand, String usage) {
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CraftEnchantment extends Enchantment {
|
||||
|
||||
@Override
|
||||
public boolean isCursed() {
|
||||
return target.d(); // PAIL isCursed
|
||||
return target.isCursed();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,7 +107,7 @@ public class CraftEnchantment extends Enchantment {
|
||||
case 21:
|
||||
return "LOOT_BONUS_MOBS";
|
||||
case 22:
|
||||
return "SWEEPING";
|
||||
return "SWEEPING_EDGE";
|
||||
case 32:
|
||||
return "DIG_SPEED";
|
||||
case 33:
|
||||
|
||||
@@ -24,6 +24,6 @@ public abstract class CraftChestedHorse extends CraftAbstractHorse implements Ch
|
||||
public void setCarryingChest(boolean chest) {
|
||||
if (chest == isCarryingChest()) return;
|
||||
getHandle().setCarryingChest(chest);
|
||||
getHandle().dx();
|
||||
getHandle().loadChest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else if (entity instanceof EntityTameableAnimal) {
|
||||
if (entity instanceof EntityWolf) { return new CraftWolf(server, (EntityWolf) entity); }
|
||||
else if (entity instanceof EntityOcelot) { return new CraftOcelot(server, (EntityOcelot) entity); }
|
||||
else if (entity instanceof EntityParrot) { return new CraftParrot(server, (EntityParrot) entity); }
|
||||
}
|
||||
else if (entity instanceof EntitySheep) { return new CraftSheep(server, (EntitySheep) entity); }
|
||||
else if (entity instanceof EntityHorseAbstract) {
|
||||
@@ -109,9 +110,16 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
if (entity instanceof EntityGuardianElder) { return new CraftElderGuardian(server, (EntityGuardianElder) entity); }
|
||||
else { return new CraftGuardian(server, (EntityGuardian) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityEvoker) { return new CraftEvoker(server, (EntityEvoker) entity); }
|
||||
else if (entity instanceof EntityVex) { return new CraftVex(server, (EntityVex) entity); }
|
||||
else if (entity instanceof EntityVindicator) { return new CraftVindicator(server, (EntityVindicator) entity); }
|
||||
else if (entity instanceof EntityIllagerAbstract) {
|
||||
if (entity instanceof EntityIllagerWizard) {
|
||||
if (entity instanceof EntityEvoker) { return new CraftEvoker(server, (EntityEvoker) entity); }
|
||||
else if (entity instanceof EntityIllagerIllusioner) { return new CraftIllusioner(server, (EntityIllagerIllusioner) entity); }
|
||||
else { return new CraftSpellcaster(server, (EntityIllagerWizard) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityVindicator) { return new CraftVindicator(server, (EntityVindicator) entity); }
|
||||
else { return new CraftIllager(server, (EntityIllagerAbstract) entity); }
|
||||
}
|
||||
|
||||
else { return new CraftMonster(server, (EntityMonster) entity); }
|
||||
}
|
||||
@@ -383,7 +391,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
return false;
|
||||
}
|
||||
|
||||
getHandle().az(); // PAIL: rename
|
||||
getHandle().leaveVehicle();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -657,17 +665,26 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
|
||||
@Override
|
||||
public Set<String> getScoreboardTags() {
|
||||
return getHandle().P(); // PAIL: getScoreboardTags
|
||||
return getHandle().getScoreboardTags();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addScoreboardTag(String tag) {
|
||||
return getHandle().a(tag); // PAIL: addScoreboardTag
|
||||
return getHandle().addScoreboardTag(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeScoreboardTag(String tag) {
|
||||
return getHandle().b(tag); // PAIL: removeScoreboardTag
|
||||
return getHandle().removeScoreboardTag(tag);
|
||||
}
|
||||
|
||||
protected NBTTagCompound save() {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
|
||||
nbttagcompound.setString("id", getHandle().getSaveID());
|
||||
getHandle().save(nbttagcompound);
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
private static PermissibleBase getPermissibleBase() {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityEvoker;
|
||||
import net.minecraft.server.EntityIllagerWizard;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Evoker;
|
||||
|
||||
public class CraftEvoker extends CraftMonster implements Evoker {
|
||||
public class CraftEvoker extends CraftSpellcaster implements Evoker {
|
||||
|
||||
public CraftEvoker(CraftServer server, EntityEvoker entity) {
|
||||
super(server, entity);
|
||||
@@ -27,12 +28,12 @@ public class CraftEvoker extends CraftMonster implements Evoker {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spell getCurrentSpell() {
|
||||
return Spell.values()[getHandle().getSpell()];
|
||||
public Evoker.Spell getCurrentSpell() {
|
||||
return Evoker.Spell.values()[getHandle().getSpell().ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentSpell(Spell spell) {
|
||||
getHandle().a(spell == null ? 0 : spell.ordinal());
|
||||
public void setCurrentSpell(Evoker.Spell spell) {
|
||||
getHandle().setSpell(spell == null ? EntityIllagerWizard.Spell.NONE : EntityIllagerWizard.Spell.a(spell.ordinal()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class CraftEvokerFangs extends CraftEntity implements EvokerFangs {
|
||||
|
||||
@Override
|
||||
public LivingEntity getOwner() {
|
||||
EntityLiving owner = getHandle().j(); // PAIL: rename
|
||||
EntityLiving owner = getHandle().getOwner();
|
||||
|
||||
return (owner == null) ? null : (LivingEntity) owner.getBukkitEntity();
|
||||
}
|
||||
|
||||
@@ -422,15 +422,15 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
public boolean hasCooldown(Material material) {
|
||||
Preconditions.checkArgument(material != null, "material");
|
||||
|
||||
return getHandle().di().a(CraftMagicNumbers.getItem(material)); // PAIL: getCooldownTracker
|
||||
return getHandle().getCooldownTracker().a(CraftMagicNumbers.getItem(material));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldown(Material material) {
|
||||
Preconditions.checkArgument(material != null, "material");
|
||||
|
||||
ItemCooldown.Info cooldown = getHandle().di().a.get(CraftMagicNumbers.getItem(material));
|
||||
return (cooldown == null) ? 0 : Math.max(0, cooldown.b - getHandle().di().b);
|
||||
ItemCooldown.Info cooldown = getHandle().getCooldownTracker().cooldowns.get(CraftMagicNumbers.getItem(material));
|
||||
return (cooldown == null) ? 0 : Math.max(0, cooldown.endTick - getHandle().getCooldownTracker().currentTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -438,6 +438,44 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
Preconditions.checkArgument(material != null, "material");
|
||||
Preconditions.checkArgument(ticks >= 0, "Cannot have negative cooldown");
|
||||
|
||||
getHandle().di().a(CraftMagicNumbers.getItem(material), ticks);
|
||||
getHandle().getCooldownTracker().a(CraftMagicNumbers.getItem(material), ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getShoulderEntityLeft() {
|
||||
if (getHandle().getShoulderEntityLeft() != null) {
|
||||
Entity shoulder = EntityTypes.a(getHandle().getShoulderEntityLeft(), getHandle().world);
|
||||
|
||||
return (shoulder == null) ? null : shoulder.getBukkitEntity();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShoulderEntityLeft(org.bukkit.entity.Entity entity) {
|
||||
getHandle().setShoulderEntityLeft(entity == null ? null : ((CraftEntity) entity).save());
|
||||
if (entity != null) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getShoulderEntityRight() {
|
||||
if (getHandle().getShoulderEntityRight() != null) {
|
||||
Entity shoulder = EntityTypes.a(getHandle().getShoulderEntityRight(), getHandle().world);
|
||||
|
||||
return (shoulder == null) ? null : shoulder.getBukkitEntity();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShoulderEntityRight(org.bukkit.entity.Entity entity) {
|
||||
getHandle().setShoulderEntityRight(entity == null ? null : ((CraftEntity) entity).save());
|
||||
if (entity != null) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityIllagerAbstract;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Illager;
|
||||
|
||||
public class CraftIllager extends CraftMonster implements Illager {
|
||||
|
||||
public CraftIllager(CraftServer server, EntityIllagerAbstract entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIllagerAbstract getHandle() {
|
||||
return (EntityIllagerAbstract) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftIllager";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityIllagerIllusioner;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Illusioner;
|
||||
|
||||
public class CraftIllusioner extends CraftSpellcaster implements Illusioner {
|
||||
|
||||
public CraftIllusioner(CraftServer server, EntityIllagerIllusioner entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIllagerIllusioner getHandle() {
|
||||
return (EntityIllagerIllusioner) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftIllusioner";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.ILLUSIONER;
|
||||
}
|
||||
}
|
||||
@@ -39,15 +39,15 @@ public class CraftLlama extends CraftChestedHorse implements Llama {
|
||||
|
||||
@Override
|
||||
public int getStrength() {
|
||||
return getHandle().dL();
|
||||
return getHandle().getStrength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStrength(int strength) {
|
||||
Preconditions.checkArgument(1 <= strength && strength <= 5, "strength must be [1,5]");
|
||||
if (strength == getStrength()) return;
|
||||
getHandle().p(strength);
|
||||
getHandle().dx();
|
||||
getHandle().setStrength(strength);
|
||||
getHandle().loadChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.bukkit.craftbukkit.entity;
|
||||
import net.minecraft.server.EntityLlamaSpit;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.LlamaSpit;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
@@ -28,21 +27,11 @@ public class CraftLlamaSpit extends AbstractProjectile implements LlamaSpit {
|
||||
return EntityType.LLAMA_SPIT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity _INVALID_getShooter() {
|
||||
return (getHandle().shooter != null) ? (LivingEntity) getHandle().shooter.getBukkitEntity() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectileSource getShooter() {
|
||||
return (getHandle().shooter != null) ? (ProjectileSource) getHandle().shooter.getBukkitEntity() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void _INVALID_setShooter(LivingEntity shooter) {
|
||||
getHandle().shooter = (shooter != null) ? ((CraftLivingEntity) shooter).getHandle() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShooter(ProjectileSource source) {
|
||||
getHandle().shooter = (source != null) ? ((CraftLivingEntity) source).getHandle() : null;
|
||||
|
||||
@@ -7,8 +7,8 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
|
||||
public class CraftOcelot extends CraftTameableAnimal implements Ocelot {
|
||||
public CraftOcelot(CraftServer server, EntityOcelot wolf) {
|
||||
super(server, wolf);
|
||||
public CraftOcelot(CraftServer server, EntityOcelot ocelot) {
|
||||
super(server, ocelot);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,6 +25,11 @@ public class CraftOcelot extends CraftTameableAnimal implements Ocelot {
|
||||
getHandle().setCatType(type.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftOcelot";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.OCELOT;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.server.EntityParrot;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Parrot;
|
||||
|
||||
public class CraftParrot extends CraftTameableAnimal implements Parrot {
|
||||
|
||||
public CraftParrot(CraftServer server, EntityParrot parrot) {
|
||||
super(server, parrot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityParrot getHandle() {
|
||||
return (EntityParrot) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Variant getVariant() {
|
||||
return Variant.values()[getHandle().getVariant()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVariant(Variant variant) {
|
||||
Preconditions.checkArgument(variant != null, "variant");
|
||||
|
||||
getHandle().setVariant(variant.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftParrot";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.PARROT;
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,8 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftSound;
|
||||
import org.bukkit.craftbukkit.CraftStatistic;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.advancement.CraftAdvancement;
|
||||
import org.bukkit.craftbukkit.advancement.CraftAdvancementProgress;
|
||||
import org.bukkit.craftbukkit.map.CraftMapView;
|
||||
import org.bukkit.craftbukkit.map.RenderData;
|
||||
import org.bukkit.craftbukkit.scoreboard.CraftScoreboard;
|
||||
@@ -559,29 +561,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public void awardAchievement(Achievement achievement) {
|
||||
Validate.notNull(achievement, "Achievement cannot be null");
|
||||
if (achievement.hasParent() && !hasAchievement(achievement.getParent())) {
|
||||
awardAchievement(achievement.getParent());
|
||||
}
|
||||
getHandle().getStatisticManager().setStatistic(getHandle(), CraftStatistic.getNMSAchievement(achievement), 1);
|
||||
getHandle().getStatisticManager().updateStatistics(getHandle());
|
||||
throw new UnsupportedOperationException("Not supported in this Minecraft version.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAchievement(Achievement achievement) {
|
||||
Validate.notNull(achievement, "Achievement cannot be null");
|
||||
for (Achievement achieve : Achievement.values()) {
|
||||
if (achieve.getParent() == achievement && hasAchievement(achieve)) {
|
||||
removeAchievement(achieve);
|
||||
}
|
||||
}
|
||||
getHandle().getStatisticManager().setStatistic(getHandle(), CraftStatistic.getNMSAchievement(achievement), 0);
|
||||
throw new UnsupportedOperationException("Not supported in this Minecraft version.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAchievement(Achievement achievement) {
|
||||
Validate.notNull(achievement, "Achievement cannot be null");
|
||||
return getHandle().getStatisticManager().hasAchievement(CraftStatistic.getNMSAchievement(achievement));
|
||||
throw new UnsupportedOperationException("Not supported in this Minecraft version.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -754,15 +744,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
return server.getBanList(BanList.Type.NAME).isBanned(getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanned(boolean value) {
|
||||
if (value) {
|
||||
server.getBanList(BanList.Type.NAME).addBan(getName(), null, null, null);
|
||||
} else {
|
||||
server.getBanList(BanList.Type.NAME).pardon(getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted() {
|
||||
return server.getHandle().getWhitelist().isWhitelisted(getProfile());
|
||||
@@ -1454,4 +1435,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
getHandle().playerConnection.sendPacket(packetplayoutworldparticles);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.advancement.AdvancementProgress getAdvancementProgress(org.bukkit.advancement.Advancement advancement) {
|
||||
Preconditions.checkArgument(advancement != null, "advancement");
|
||||
|
||||
CraftAdvancement craft = (CraftAdvancement) advancement;
|
||||
AdvancementDataPlayer data = getHandle().getAdvancementData();
|
||||
AdvancementProgress progress = data.getProgress(craft.getHandle());
|
||||
|
||||
return new CraftAdvancementProgress(craft, data, progress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ public class CraftShulker extends CraftGolem implements Shulker {
|
||||
|
||||
@Override
|
||||
public DyeColor getColor() {
|
||||
return DyeColor.getByWoolData(getHandle().getDataWatcher().get(EntityShulker.bw));
|
||||
return DyeColor.getByWoolData(getHandle().getDataWatcher().get(EntityShulker.COLOR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(DyeColor color) {
|
||||
Preconditions.checkArgument(color != null, "color");
|
||||
|
||||
getHandle().getDataWatcher().set(EntityShulker.bw, color.getWoolData());
|
||||
getHandle().getDataWatcher().set(EntityShulker.COLOR, color.getWoolData());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.server.EntityIllagerWizard;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Spellcaster;
|
||||
|
||||
public class CraftSpellcaster extends CraftIllager implements Spellcaster {
|
||||
|
||||
public CraftSpellcaster(CraftServer server, EntityIllagerWizard entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIllagerWizard getHandle() {
|
||||
return (EntityIllagerWizard) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftSpellcaster";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spell getSpell() {
|
||||
return Spell.valueOf(getHandle().getSpell().name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpell(Spell spell) {
|
||||
Preconditions.checkArgument(spell != null, "Use Spell.NONE");
|
||||
|
||||
getHandle().setSpell(EntityIllagerWizard.Spell.a(spell.ordinal()));
|
||||
}
|
||||
}
|
||||
@@ -123,11 +123,11 @@ public class CraftTippedArrow extends CraftArrow implements TippedArrow {
|
||||
|
||||
@Override
|
||||
public void setColor(Color color) {
|
||||
getHandle().d(color.asRGB());
|
||||
getHandle().setColor(color.asRGB());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor() {
|
||||
return Color.fromRGB(getHandle().o());
|
||||
return Color.fromRGB(getHandle().getColor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Vindicator;
|
||||
|
||||
public class CraftVindicator extends CraftMonster implements Vindicator {
|
||||
public class CraftVindicator extends CraftIllager implements Vindicator {
|
||||
|
||||
public CraftVindicator(CraftServer server, EntityVindicator entity) {
|
||||
super(server, entity);
|
||||
|
||||
@@ -953,12 +953,7 @@ public class CraftEventFactory {
|
||||
public static Cancellable handleStatisticsIncrease(EntityHuman entityHuman, net.minecraft.server.Statistic statistic, int current, int incrementation) {
|
||||
Player player = ((EntityPlayer) entityHuman).getBukkitEntity();
|
||||
Event event;
|
||||
if (statistic instanceof net.minecraft.server.Achievement) {
|
||||
if (current != 0) {
|
||||
return null;
|
||||
}
|
||||
event = new PlayerAchievementAwardedEvent(player, CraftStatistic.getBukkitAchievement((net.minecraft.server.Achievement) statistic));
|
||||
} else {
|
||||
if (true) {
|
||||
org.bukkit.Statistic stat = CraftStatistic.getBukkitStatistic(statistic);
|
||||
if (stat == null) {
|
||||
System.err.println("Unhandled statistic: " + statistic);
|
||||
|
||||
@@ -220,6 +220,11 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
return biomebase == null ? null : biomebase.getMobs(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(World world, String type, BlockPosition position) {
|
||||
return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.b(position) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPosition findNearestMapFeature(World world, String type, BlockPosition position, boolean flag) {
|
||||
return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.getNearestGeneratedFeature(world, position, flag) : null;
|
||||
|
||||
@@ -60,4 +60,9 @@ public class NormalChunkGenerator extends InternalChunkGenerator {
|
||||
public void recreateStructures(Chunk chunk, int i, int i1) {
|
||||
generator.recreateStructures(chunk, i, i1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(World world, String string, BlockPosition bp) {
|
||||
return generator.a(world, string, bp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.google.common.collect.Collections2;
|
||||
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.command.defaults.VanillaCommand;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
|
||||
import org.bukkit.help.*;
|
||||
@@ -184,7 +183,7 @@ public class SimpleHelpMap implements HelpMap {
|
||||
if (command instanceof VanillaCommandWrapper) {
|
||||
return "Minecraft";
|
||||
}
|
||||
if (command instanceof BukkitCommand || command instanceof VanillaCommand) {
|
||||
if (command instanceof BukkitCommand) {
|
||||
return "Bukkit";
|
||||
}
|
||||
if (command instanceof PluginIdentifiableCommand) {
|
||||
@@ -194,7 +193,7 @@ public class SimpleHelpMap implements HelpMap {
|
||||
}
|
||||
|
||||
private boolean commandInIgnoredPlugin(Command command, Set<String> ignoredPlugins) {
|
||||
if ((command instanceof BukkitCommand || command instanceof VanillaCommand) && ignoredPlugins.contains("Bukkit")) {
|
||||
if ((command instanceof BukkitCommand) && ignoredPlugins.contains("Bukkit")) {
|
||||
return true;
|
||||
}
|
||||
if (command instanceof PluginIdentifiableCommand && ignoredPlugins.contains(((PluginIdentifiableCommand)command).getPlugin().getName())) {
|
||||
|
||||
@@ -59,16 +59,16 @@ public class CraftInventoryAnvil extends CraftInventory implements AnvilInventor
|
||||
|
||||
@Override
|
||||
public String getRenameText() {
|
||||
return container.l; // PAIL: renameText
|
||||
return container.renameText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRepairCost() {
|
||||
return container.a; // PAIL: levelCost
|
||||
return container.levelCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRepairCost(int i) {
|
||||
container.a = i; // PAIL:levelCost
|
||||
container.levelCost = i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public class CraftInventoryCustom extends CraftInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean w_() {
|
||||
public boolean x_() {
|
||||
Iterator iterator = this.items.iterator();
|
||||
|
||||
ItemStack itemstack;
|
||||
|
||||
@@ -28,6 +28,7 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
.add("generic.knockbackResistance")
|
||||
.add("generic.maxHealth")
|
||||
.add("generic.movementSpeed")
|
||||
.add("generic.flyingSpeed")
|
||||
.add("generic.attackSpeed")
|
||||
.add("generic.luck")
|
||||
.add("horse.jumpStrength")
|
||||
@@ -93,6 +94,8 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
return meta instanceof CraftMetaBanner ? meta : new CraftMetaBanner(meta);
|
||||
case MONSTER_EGG:
|
||||
return meta instanceof CraftMetaSpawnEgg ? meta : new CraftMetaSpawnEgg(meta);
|
||||
case KNOWLEDGE_BOOK:
|
||||
return meta instanceof CraftMetaKnowledgeBook ? meta : new CraftMetaKnowledgeBook(meta);
|
||||
case FURNACE:
|
||||
case CHEST:
|
||||
case TRAPPED_CHEST:
|
||||
|
||||
@@ -353,6 +353,8 @@ public final class CraftItemStack extends ItemStack {
|
||||
return new CraftMetaBanner(item.getTag());
|
||||
case MONSTER_EGG:
|
||||
return new CraftMetaSpawnEgg(item.getTag());
|
||||
case KNOWLEDGE_BOOK:
|
||||
return new CraftMetaKnowledgeBook(item.getTag());
|
||||
case FURNACE:
|
||||
case CHEST:
|
||||
case TRAPPED_CHEST:
|
||||
|
||||
@@ -49,7 +49,7 @@ public class CraftMerchantCustom extends CraftMerchant {
|
||||
@Override
|
||||
public void a(MerchantRecipe merchantrecipe) {
|
||||
// increase recipe's uses
|
||||
merchantrecipe.g(); // PAIL: rename
|
||||
merchantrecipe.increaseUses();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,12 +62,12 @@ public class CraftMerchantCustom extends CraftMerchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public World t_() {
|
||||
public World u_() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPosition u_() {
|
||||
public BlockPosition v_() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,6 +119,7 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
||||
.put(CraftMetaEnchantedBook.class, "ENCHANTED")
|
||||
.put(CraftMetaFirework.class, "FIREWORK")
|
||||
.put(CraftMetaCharge.class, "FIREWORK_EFFECT")
|
||||
.put(CraftMetaKnowledgeBook.class, "KNOWLEDGE_BOOK")
|
||||
.put(CraftMetaItem.class, "UNSPECIFIC")
|
||||
.build();
|
||||
|
||||
@@ -890,7 +891,8 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
||||
CraftMetaFirework.FIREWORKS.NBT,
|
||||
CraftMetaEnchantedBook.STORED_ENCHANTMENTS.NBT,
|
||||
CraftMetaCharge.EXPLOSION.NBT,
|
||||
CraftMetaBlockState.BLOCK_ENTITY_TAG.NBT
|
||||
CraftMetaBlockState.BLOCK_ENTITY_TAG.NBT,
|
||||
CraftMetaKnowledgeBook.BOOK_RECIPES.NBT
|
||||
));
|
||||
}
|
||||
return HANDLED_TAGS;
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.NBTTagList;
|
||||
import net.minecraft.server.NBTTagString;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||
import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.inventory.meta.KnowledgeBookMeta;
|
||||
|
||||
@DelegateDeserialization(SerializableMeta.class)
|
||||
public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBookMeta {
|
||||
|
||||
static final ItemMetaKey BOOK_RECIPES = new ItemMetaKey("Recipes");
|
||||
static final int MAX_RECIPES = Short.MAX_VALUE;
|
||||
|
||||
protected List<NamespacedKey> recipes = new ArrayList<NamespacedKey>();
|
||||
|
||||
CraftMetaKnowledgeBook(CraftMetaItem meta) {
|
||||
super(meta);
|
||||
|
||||
if (meta instanceof CraftMetaKnowledgeBook) {
|
||||
CraftMetaKnowledgeBook bookMeta = (CraftMetaKnowledgeBook) meta;
|
||||
this.recipes.addAll(bookMeta.recipes);
|
||||
}
|
||||
}
|
||||
|
||||
CraftMetaKnowledgeBook(NBTTagCompound tag) {
|
||||
super(tag);
|
||||
|
||||
if (tag.hasKey(BOOK_RECIPES.NBT)) {
|
||||
NBTTagList pages = tag.getList(BOOK_RECIPES.NBT, 8);
|
||||
|
||||
for (int i = 0; i < pages.size(); i++) {
|
||||
String recipe = pages.getString(i);
|
||||
|
||||
addRecipe(CraftNamespacedKey.fromString(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CraftMetaKnowledgeBook(Map<String, Object> map) {
|
||||
super(map);
|
||||
|
||||
Iterable<?> pages = SerializableMeta.getObject(Iterable.class, map, BOOK_RECIPES.BUKKIT, true);
|
||||
if (pages != null) {
|
||||
for (Object page : pages) {
|
||||
if (page instanceof String) {
|
||||
addRecipe(CraftNamespacedKey.fromString((String) page));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void applyToItem(NBTTagCompound itemData) {
|
||||
super.applyToItem(itemData);
|
||||
|
||||
if (hasRecipes()) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (NamespacedKey recipe : this.recipes) {
|
||||
list.add(new NBTTagString(recipe.toString()));
|
||||
}
|
||||
itemData.set(BOOK_RECIPES.NBT, list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isEmpty() {
|
||||
return super.isEmpty() && isBookEmpty();
|
||||
}
|
||||
|
||||
boolean isBookEmpty() {
|
||||
return !(hasRecipes());
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean applicableTo(Material type) {
|
||||
switch (type) {
|
||||
case KNOWLEDGE_BOOK:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRecipes() {
|
||||
return !recipes.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(NamespacedKey... recipes) {
|
||||
for (NamespacedKey recipe : recipes) {
|
||||
if (recipe != null) {
|
||||
if (this.recipes.size() >= MAX_RECIPES) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NamespacedKey> getRecipes() {
|
||||
return Collections.unmodifiableList(recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipes(List<NamespacedKey> recipes) {
|
||||
this.recipes.clear();
|
||||
for (NamespacedKey recipe : this.recipes) {
|
||||
addRecipe(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftMetaKnowledgeBook clone() {
|
||||
CraftMetaKnowledgeBook meta = (CraftMetaKnowledgeBook) super.clone();
|
||||
meta.recipes = new ArrayList<NamespacedKey>(recipes);
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
int applyHash() {
|
||||
final int original;
|
||||
int hash = original = super.applyHash();
|
||||
if (hasRecipes()) {
|
||||
hash = 61 * hash + 17 * this.recipes.hashCode();
|
||||
}
|
||||
return original != hash ? CraftMetaKnowledgeBook.class.hashCode() ^ hash : hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean equalsCommon(CraftMetaItem meta) {
|
||||
if (!super.equalsCommon(meta)) {
|
||||
return false;
|
||||
}
|
||||
if (meta instanceof CraftMetaKnowledgeBook) {
|
||||
CraftMetaKnowledgeBook that = (CraftMetaKnowledgeBook) meta;
|
||||
|
||||
return (hasRecipes() ? that.hasRecipes() && this.recipes.equals(that.recipes) : !that.hasRecipes());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean notUncommon(CraftMetaItem meta) {
|
||||
return super.notUncommon(meta) && (meta instanceof CraftMetaKnowledgeBook || isBookEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
Builder<String, Object> serialize(Builder<String, Object> builder) {
|
||||
super.serialize(builder);
|
||||
|
||||
if (hasRecipes()) {
|
||||
List<String> recipesString = new ArrayList<String>();
|
||||
for (NamespacedKey recipe : recipes) {
|
||||
recipesString.add(recipe.toString());
|
||||
}
|
||||
builder.put(BOOK_RECIPES.BUKKIT, recipesString);
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta {
|
||||
entityTag = tag.getCompound(ENTITY_TAG.NBT);
|
||||
|
||||
if (entityTag.hasKey(ENTITY_ID.NBT)) {
|
||||
this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).a()); // PAIL: rename
|
||||
this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,10 +58,10 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta {
|
||||
|
||||
if (tag.hasKey(ENTITY_TAG.NBT)) {
|
||||
entityTag = tag.getCompound(ENTITY_TAG.NBT);
|
||||
MinecraftServer.getServer().getDataConverterManager().a(DataConverterTypes.ENTITY, entityTag); // PAIL: convert
|
||||
MinecraftServer.getServer().dataConverterManager.a(DataConverterTypes.ENTITY, entityTag); // PAIL: convert
|
||||
|
||||
if (entityTag.hasKey(ENTITY_ID.NBT)) {
|
||||
this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).a()); // PAIL: rename
|
||||
this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@ package org.bukkit.craftbukkit.inventory;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.server.CraftingManager;
|
||||
import net.minecraft.server.NonNullList;
|
||||
import net.minecraft.server.RecipeItemStack;
|
||||
import net.minecraft.server.ShapedRecipes;
|
||||
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
@@ -13,12 +16,12 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe {
|
||||
// TODO: Could eventually use this to add a matches() method or some such
|
||||
private ShapedRecipes recipe;
|
||||
|
||||
public CraftShapedRecipe(ItemStack result) {
|
||||
super(result);
|
||||
public CraftShapedRecipe(NamespacedKey key, ItemStack result) {
|
||||
super(key, result);
|
||||
}
|
||||
|
||||
public CraftShapedRecipe(ItemStack result, ShapedRecipes recipe) {
|
||||
this(result);
|
||||
this(CraftNamespacedKey.fromMinecraft(CraftingManager.recipes.b(recipe)), result);
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
@@ -26,7 +29,7 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe {
|
||||
if (recipe instanceof CraftShapedRecipe) {
|
||||
return (CraftShapedRecipe) recipe;
|
||||
}
|
||||
CraftShapedRecipe ret = new CraftShapedRecipe(recipe.getResult());
|
||||
CraftShapedRecipe ret = new CraftShapedRecipe(recipe.getKey(), recipe.getResult());
|
||||
String[] shape = recipe.getShape();
|
||||
ret.shape(shape);
|
||||
Map<Character, ItemStack> ingredientMap = recipe.getIngredientMap();
|
||||
@@ -40,26 +43,18 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe {
|
||||
}
|
||||
|
||||
public void addToCraftingManager() {
|
||||
Object[] data;
|
||||
String[] shape = this.getShape();
|
||||
Map<Character, ItemStack> ingred = this.getIngredientMap();
|
||||
int datalen = shape.length;
|
||||
datalen += ingred.size() * 2;
|
||||
int i = 0;
|
||||
data = new Object[datalen];
|
||||
for (; i < shape.length; i++) {
|
||||
data[i] = shape[i];
|
||||
int width = shape[0].length();
|
||||
NonNullList<RecipeItemStack> data = NonNullList.a(shape.length * width, RecipeItemStack.a);
|
||||
|
||||
for (int i = 0; i < shape.length; i++) {
|
||||
String row = shape[i];
|
||||
for (int j = 0; j < row.length(); j++) {
|
||||
data.set(i * width + j, new RecipeItemStack(CraftItemStack.asNMSCopy(ingred.get(row.charAt(j)))));
|
||||
}
|
||||
}
|
||||
for (char c : ingred.keySet()) {
|
||||
ItemStack mdata = ingred.get(c);
|
||||
if (mdata == null) continue;
|
||||
data[i] = c;
|
||||
i++;
|
||||
int id = mdata.getTypeId();
|
||||
short dmg = mdata.getDurability();
|
||||
data[i] = new net.minecraft.server.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg);
|
||||
i++;
|
||||
}
|
||||
CraftingManager.getInstance().registerShapedRecipe(CraftItemStack.asNMSCopy(this.getResult()), data);
|
||||
|
||||
CraftingManager.a(CraftNamespacedKey.toMinecraft(this.getKey()), new ShapedRecipes("", width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@ package org.bukkit.craftbukkit.inventory;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.CraftingManager;
|
||||
import net.minecraft.server.NonNullList;
|
||||
import net.minecraft.server.RecipeItemStack;
|
||||
import net.minecraft.server.ShapelessRecipes;
|
||||
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
|
||||
@@ -13,12 +16,12 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe
|
||||
// TODO: Could eventually use this to add a matches() method or some such
|
||||
private ShapelessRecipes recipe;
|
||||
|
||||
public CraftShapelessRecipe(ItemStack result) {
|
||||
super(result);
|
||||
public CraftShapelessRecipe(NamespacedKey key, ItemStack result) {
|
||||
super(key, result);
|
||||
}
|
||||
|
||||
public CraftShapelessRecipe(ItemStack result, ShapelessRecipes recipe) {
|
||||
this(result);
|
||||
this(CraftNamespacedKey.fromMinecraft(recipe.key != null ? recipe.key : CraftingManager.recipes.b(recipe)), result);
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
@@ -26,7 +29,7 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe
|
||||
if (recipe instanceof CraftShapelessRecipe) {
|
||||
return (CraftShapelessRecipe) recipe;
|
||||
}
|
||||
CraftShapelessRecipe ret = new CraftShapelessRecipe(recipe.getResult());
|
||||
CraftShapelessRecipe ret = new CraftShapelessRecipe(recipe.getKey(), recipe.getResult());
|
||||
for (ItemStack ingred : recipe.getIngredientList()) {
|
||||
ret.addIngredient(ingred.getType(), ingred.getDurability());
|
||||
}
|
||||
@@ -35,14 +38,11 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe
|
||||
|
||||
public void addToCraftingManager() {
|
||||
List<ItemStack> ingred = this.getIngredientList();
|
||||
Object[] data = new Object[ingred.size()];
|
||||
int i = 0;
|
||||
for (ItemStack mdata : ingred) {
|
||||
int id = mdata.getTypeId();
|
||||
short dmg = mdata.getDurability();
|
||||
data[i] = new net.minecraft.server.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg);
|
||||
i++;
|
||||
NonNullList<RecipeItemStack> data = NonNullList.a(ingred.size(), RecipeItemStack.a);
|
||||
for (int i = 0; i < ingred.size(); i++) {
|
||||
data.set(i, new RecipeItemStack(CraftItemStack.asNMSCopy(ingred.get(i))));
|
||||
}
|
||||
CraftingManager.getInstance().registerShapelessRecipe(CraftItemStack.asNMSCopy(this.getResult()), data);
|
||||
|
||||
CraftingManager.a(CraftNamespacedKey.toMinecraft(this.getKey()), new ShapelessRecipes("", CraftItemStack.asNMSCopy(this.getResult()), data));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public class InventoryWrapper implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean w_() {
|
||||
public boolean x_() {
|
||||
return Iterables.any(inventory, Predicates.notNull());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class RecipeIterator implements Iterator<Recipe> {
|
||||
private Iterator<?> removeFrom = null;
|
||||
|
||||
public RecipeIterator() {
|
||||
this.recipes = CraftingManager.getInstance().getRecipes().iterator();
|
||||
this.recipes = CraftingManager.recipes.iterator();
|
||||
this.smeltingCustom = RecipesFurnace.getInstance().customRecipes.keySet().iterator();
|
||||
this.smeltingVanilla = RecipesFurnace.getInstance().recipes.keySet().iterator();
|
||||
}
|
||||
|
||||
@@ -1,26 +1,39 @@
|
||||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.io.Files;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.AdvancementDataWorld;
|
||||
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.ChatDeserializer;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.MojangsonParseException;
|
||||
import net.minecraft.server.MojangsonParser;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.StatisticList;
|
||||
|
||||
import org.bukkit.Achievement;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.UnsafeValues;
|
||||
import org.bukkit.advancement.Advancement;
|
||||
import org.bukkit.craftbukkit.CraftStatistic;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -131,7 +144,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
|
||||
@Override
|
||||
public Achievement getAchievementFromInternalName(String name) {
|
||||
return CraftStatistic.getBukkitAchievementByName(name);
|
||||
throw new UnsupportedOperationException("Not supported in this Minecraft version.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,6 +160,42 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
return matches;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Advancement loadAdvancement(NamespacedKey key, String advancement) {
|
||||
if (Bukkit.getAdvancement(key) != null) {
|
||||
throw new IllegalArgumentException("Advancement " + key + " already exists.");
|
||||
}
|
||||
|
||||
net.minecraft.server.Advancement.SerializedAdvancement nms = (net.minecraft.server.Advancement.SerializedAdvancement) ChatDeserializer.a(AdvancementDataWorld.DESERIALIZER, advancement, net.minecraft.server.Advancement.SerializedAdvancement.class);
|
||||
if (nms != null) {
|
||||
AdvancementDataWorld.REGISTRY.a(Maps.newHashMap(Collections.singletonMap(CraftNamespacedKey.toMinecraft(key), nms)));
|
||||
Advancement bukkit = Bukkit.getAdvancement(key);
|
||||
|
||||
if (bukkit != null) {
|
||||
File file = new File(MinecraftServer.getServer().getAdvancementData().folder, key.getNamespace() + File.separator + key.getKey() + ".json");
|
||||
file.getParentFile().mkdirs();
|
||||
|
||||
try {
|
||||
Files.write(advancement, file, Charsets.UTF_8);
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error saving advancement " + key, ex);
|
||||
}
|
||||
|
||||
MinecraftServer.getServer().getPlayerList().reload();
|
||||
|
||||
return bukkit;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAdvancement(NamespacedKey key) {
|
||||
File file = new File(MinecraftServer.getServer().getAdvancementData().folder, key.getNamespace() + File.separator + key.getKey() + ".json");
|
||||
return file.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper class represents the different NBT Tags.
|
||||
* <p>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
import org.bukkit.NamespacedKey;
|
||||
|
||||
public final class CraftNamespacedKey {
|
||||
|
||||
public CraftNamespacedKey() {
|
||||
}
|
||||
|
||||
public static NamespacedKey fromString(String string) {
|
||||
return fromMinecraft(new MinecraftKey(string));
|
||||
}
|
||||
|
||||
public static NamespacedKey fromMinecraft(MinecraftKey minecraft) {
|
||||
return new NamespacedKey(minecraft.b(), minecraft.getKey());
|
||||
}
|
||||
|
||||
public static MinecraftKey toMinecraft(NamespacedKey key) {
|
||||
return new MinecraftKey(key.getNamespace(), key.getKey());
|
||||
}
|
||||
}
|
||||
@@ -35,9 +35,3 @@ ticks-per:
|
||||
monster-spawns: 1
|
||||
autosave: 6000
|
||||
aliases: now-in-commands.yml
|
||||
database:
|
||||
username: bukkit
|
||||
isolation: SERIALIZABLE
|
||||
driver: org.sqlite.JDBC
|
||||
password: walrus
|
||||
url: jdbc:sqlite:{DIR}{NAME}.db
|
||||
|
||||
@@ -6,7 +6,6 @@ import static org.hamcrest.Matchers.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.EntitySheep;
|
||||
import net.minecraft.server.EnumColor;
|
||||
import net.minecraft.server.ItemDye;
|
||||
|
||||
@@ -34,7 +33,7 @@ public class DyeColorsTest extends AbstractTestingBase {
|
||||
@Test
|
||||
public void checkColor() {
|
||||
Color color = dye.getColor();
|
||||
float[] nmsColorArray = EntitySheep.a(EnumColor.fromColorIndex(dye.getWoolData()));
|
||||
float[] nmsColorArray = EnumColor.fromColorIndex(dye.getWoolData()).f();
|
||||
Color nmsColor = Color.fromRGB((int) (nmsColorArray[0] * 255), (int) (nmsColorArray[1] * 255), (int) (nmsColorArray[2] * 255));
|
||||
assertThat(color, is(nmsColor));
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class SoundTest {
|
||||
@Test
|
||||
public void testReverse() {
|
||||
for (MinecraftKey effect : SoundEffect.a.keySet()) {
|
||||
assertNotNull(effect + "", Sound.valueOf(effect.a().replace('.', '_').toUpperCase(java.util.Locale.ENGLISH)));
|
||||
assertNotNull(effect + "", Sound.valueOf(effect.getKey().replace('.', '_').toUpperCase(java.util.Locale.ENGLISH)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,8 @@ package org.bukkit;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.AchievementList;
|
||||
import net.minecraft.server.StatisticList;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftStatistic;
|
||||
@@ -14,35 +12,14 @@ import org.bukkit.support.AbstractTestingBase;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class StatisticsAndAchievementsTest extends AbstractTestingBase {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void verifyAchievementMapping() throws Throwable {
|
||||
List<Achievement> achievements = Lists.newArrayList(Achievement.values());
|
||||
for (net.minecraft.server.Achievement achievement : (List<net.minecraft.server.Achievement>) AchievementList.e) {
|
||||
String name = achievement.name;
|
||||
|
||||
String message = String.format("org.bukkit.Achievement is missing: '%s'", name);
|
||||
|
||||
Achievement subject = CraftStatistic.getBukkitAchievement(achievement);
|
||||
assertThat(message, subject, is(not(nullValue())));
|
||||
|
||||
assertThat(name, achievements.remove(subject), is(true));
|
||||
}
|
||||
|
||||
assertThat("org.bukkit.Achievement has too many achievements", achievements, is(empty()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void verifyStatisticMapping() throws Throwable {
|
||||
HashMultiset<Statistic> statistics = HashMultiset.create();
|
||||
for (net.minecraft.server.Statistic statistic : (List<net.minecraft.server.Statistic>) StatisticList.stats) {
|
||||
if (statistic instanceof net.minecraft.server.Achievement) {
|
||||
continue;
|
||||
}
|
||||
String name = statistic.name;
|
||||
|
||||
String message = String.format("org.bukkit.Statistic is missing: '%s'", name);
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.bukkit.DyeColor;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.craftbukkit.inventory.ItemStackTest.StackProvider;
|
||||
@@ -33,6 +34,7 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.FireworkEffectMeta;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.KnowledgeBookMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.MapMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
@@ -264,6 +266,14 @@ public class ItemMetaTest extends AbstractTestingBase {
|
||||
meta.setSpawnedType(EntityType.ZOMBIE);
|
||||
cleanStack.setItemMeta(meta);
|
||||
return cleanStack;
|
||||
}
|
||||
},
|
||||
new StackProvider(Material.KNOWLEDGE_BOOK) {
|
||||
@Override ItemStack operate(ItemStack cleanStack) {
|
||||
final KnowledgeBookMeta meta = (KnowledgeBookMeta) cleanStack.getItemMeta();
|
||||
meta.addRecipe(new NamespacedKey("minecraft", "test"), new NamespacedKey("plugin", "test"));
|
||||
cleanStack.setItemMeta(meta);
|
||||
return cleanStack;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -24,13 +24,13 @@ public class MapTest {
|
||||
if (nmsColors[i] == null) {
|
||||
break;
|
||||
}
|
||||
int rgb = nmsColors[i].L;
|
||||
int rgb = nmsColors[i].ac;
|
||||
|
||||
int r = (rgb >> 16) & 0xFF;
|
||||
int g = (rgb >> 8) & 0xFF;
|
||||
int b = rgb & 0xFF;
|
||||
|
||||
if (i > bukkitColors.length/4) {
|
||||
if (i + 1 > bukkitColors.length / 4) {
|
||||
for (int modi : modifiers) {
|
||||
int mr = (r * modi) / 255;
|
||||
int mg = (g * modi) / 255;
|
||||
|
||||
Reference in New Issue
Block a user