Merge branch '2.x' into 1.13

This commit is contained in:
md678685 2018-08-14 18:58:06 +01:00
commit 6c11569ac9

View file

@ -11,6 +11,7 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.yaml.snakeyaml.constructor.BaseConstructor;
import org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor; import org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor;
import org.yaml.snakeyaml.introspector.PropertyUtils; import org.yaml.snakeyaml.introspector.PropertyUtils;
import org.yaml.snakeyaml.nodes.*; import org.yaml.snakeyaml.nodes.*;
@ -34,15 +35,12 @@ public class BukkitConstructor extends CustomClassLoaderConstructor {
setPropertyUtils(propertyUtils); setPropertyUtils(propertyUtils);
} }
private class ConstructBukkitScalar extends ConstructScalar {
private Method constructScalarMethod = null; private Method constructScalarMethod = null;
protected String constructScalarRefl(ScalarNode scalarNode) { protected String constructScalarRefl(ScalarNode scalarNode) {
try { try {
if (constructScalarMethod == null) { if (constructScalarMethod == null) {
constructScalarMethod = ConstructScalar.class.getMethod("constructScalar", ScalarNode.class); constructScalarMethod = BaseConstructor.class.getDeclaredMethod("constructScalar", ScalarNode.class);
} }
return (String) constructScalarMethod.invoke(this, scalarNode); return (String) constructScalarMethod.invoke(this, scalarNode);
} catch (NoSuchMethodException } catch (NoSuchMethodException
@ -56,6 +54,9 @@ public class BukkitConstructor extends CustomClassLoaderConstructor {
return null; return null;
} }
private class ConstructBukkitScalar extends ConstructScalar {
@Override @Override
public Object construct(final Node node) { public Object construct(final Node node) {
if (node.getType().equals(Material.class)) { if (node.getType().equals(Material.class)) {
@ -167,6 +168,7 @@ public class BukkitConstructor extends CustomClassLoaderConstructor {
} }
private class ConstructBukkitMapping extends ConstructMapping { private class ConstructBukkitMapping extends ConstructMapping {
@Override @Override
public Object construct(final Node node) { public Object construct(final Node node) {
if (node.getType().equals(Location.class)) { if (node.getType().equals(Location.class)) {
@ -179,25 +181,25 @@ public class BukkitConstructor extends CustomClassLoaderConstructor {
return null; return null;
} }
for (NodeTuple nodeTuple : mnode.getValue()) { for (NodeTuple nodeTuple : mnode.getValue()) {
final String key = (String) constructScalar((ScalarNode) nodeTuple.getKeyNode()); final String key = constructScalarRefl((ScalarNode) nodeTuple.getKeyNode());
final ScalarNode snode = (ScalarNode) nodeTuple.getValueNode(); final ScalarNode snode = (ScalarNode) nodeTuple.getValueNode();
if (key.equalsIgnoreCase("world")) { if (key.equalsIgnoreCase("world")) {
worldName = (String) constructScalar(snode); worldName = constructScalarRefl(snode);
} }
if (key.equalsIgnoreCase("x")) { if (key.equalsIgnoreCase("x")) {
x = Double.parseDouble((String) constructScalar(snode)); x = Double.parseDouble(constructScalarRefl(snode));
} }
if (key.equalsIgnoreCase("y")) { if (key.equalsIgnoreCase("y")) {
y = Double.parseDouble((String) constructScalar(snode)); y = Double.parseDouble(constructScalarRefl(snode));
} }
if (key.equalsIgnoreCase("z")) { if (key.equalsIgnoreCase("z")) {
z = Double.parseDouble((String) constructScalar(snode)); z = Double.parseDouble(constructScalarRefl(snode));
} }
if (key.equalsIgnoreCase("yaw")) { if (key.equalsIgnoreCase("yaw")) {
yaw = Float.parseFloat((String) constructScalar(snode)); yaw = Float.parseFloat(constructScalarRefl(snode));
} }
if (key.equalsIgnoreCase("pitch")) { if (key.equalsIgnoreCase("pitch")) {
pitch = Float.parseFloat((String) constructScalar(snode)); pitch = Float.parseFloat(constructScalarRefl(snode));
} }
} }
if (worldName == null || worldName.isEmpty()) { if (worldName == null || worldName.isEmpty()) {