Compile against 1.13 final Bukkit build

This commit is contained in:
Daniel Saukel 2018-07-22 17:39:51 +02:00
parent d8f3734198
commit ffe73d777c
10 changed files with 63 additions and 17 deletions

View File

@ -65,7 +65,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13-pre7-R0.1-SNAPSHOT</version>
<version>1.13-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -89,7 +89,7 @@
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens</artifactId>
<version>2.0.22-SNAPSHOT</version>
<version>2.0.23-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -17,7 +17,6 @@
package de.erethon.dungeonsxl.config;
import de.erethon.commons.chat.MessageUtil;
import de.erethon.commons.compatibility.CompatibilityHandler;
import de.erethon.commons.compatibility.Internals;
import de.erethon.commons.config.DREConfig;
import de.erethon.commons.misc.EnumUtil;
@ -682,7 +681,7 @@ public class MainConfig extends DREConfig {
}
if (config.contains("tweaksEnabled")) {
if (Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals())) {
if (Internals.isAtLeast(Internals.v1_9_R1)) {
tweaksEnabled = config.getBoolean("tweaksEnabled");
} else {
tweaksEnabled = false;

View File

@ -26,6 +26,7 @@ import de.erethon.dungeonsxl.game.Game;
import de.erethon.dungeonsxl.player.DGamePlayer;
import de.erethon.dungeonsxl.player.DGlobalPlayer;
import de.erethon.dungeonsxl.player.DGroup;
import de.erethon.dungeonsxl.util.MagicValueUtil;
import de.erethon.dungeonsxl.world.DGameWorld;
import de.erethon.dungeonsxl.world.DResourceWorld;
import java.util.HashSet;
@ -168,7 +169,7 @@ public class DPortal extends GlobalProtection {
Block block = getWorld().getBlockAt(xx, yy, zz);
block.setType(material.getMaterial(), false);
if (material == VanillaItem.NETHER_PORTAL) {
block.setData(axis);
MagicValueUtil.setBlockData(block, axis);
}
}

View File

@ -17,7 +17,6 @@
package de.erethon.dungeonsxl.player;
import de.erethon.commons.chat.MessageUtil;
import de.erethon.commons.compatibility.CompatibilityHandler;
import de.erethon.commons.compatibility.Internals;
import de.erethon.commons.player.PlayerUtil;
import de.erethon.commons.player.PlayerWrapper;
@ -48,7 +47,7 @@ public class DGlobalPlayer implements PlayerWrapper {
DungeonsXL plugin = DungeonsXL.getInstance();
boolean is1_9 = Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals());
boolean is1_9 = Internals.isAtLeast(Internals.v1_9_R1);
protected Player player;

View File

@ -17,7 +17,6 @@
package de.erethon.dungeonsxl.player;
import de.erethon.commons.chat.MessageUtil;
import de.erethon.commons.compatibility.CompatibilityHandler;
import de.erethon.commons.compatibility.Internals;
import de.erethon.commons.config.DREConfig;
import de.erethon.commons.misc.EnumUtil;
@ -46,7 +45,7 @@ import org.bukkit.potion.PotionEffect;
*/
public class DPlayerData extends DREConfig {
boolean is1_9 = Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals());
boolean is1_9 = Internals.isAtLeast(Internals.v1_9_R1);
public static final int CONFIG_VERSION = 4;

View File

@ -19,6 +19,7 @@ package de.erethon.dungeonsxl.sign;
import de.erethon.caliburn.item.ExItem;
import de.erethon.caliburn.item.VanillaItem;
import de.erethon.commons.misc.NumberUtil;
import de.erethon.dungeonsxl.util.MagicValueUtil;
import de.erethon.dungeonsxl.world.DGameWorld;
import org.bukkit.block.Sign;
@ -80,7 +81,7 @@ public class BlockSign extends DSign {
getSign().getBlock().setType(offBlock.getMaterial());
try {
getSign().getBlock().setData(offBlockData);
MagicValueUtil.setBlockData(getSign().getBlock(), offBlockData);
} catch (IllegalArgumentException exception) {
markAsErroneous("offBlock data value " + offBlockData + " cannot be applied to given type " + offBlock.getId());
return;
@ -93,7 +94,7 @@ public class BlockSign extends DSign {
if (initialized && !active) {
getSign().getBlock().setType(onBlock.getMaterial());
try {
getSign().getBlock().setData(onBlockData);
MagicValueUtil.setBlockData(getSign().getBlock(), onBlockData);
} catch (IllegalArgumentException exception) {
markAsErroneous("onBlock data value " + onBlockData + " cannot be applied to given type " + onBlock.getId());
return;
@ -106,7 +107,7 @@ public class BlockSign extends DSign {
public void onDisable() {
if (initialized && active) {
getSign().getBlock().setType(offBlock.getMaterial());
getSign().getBlock().setData(offBlockData);
MagicValueUtil.setBlockData(getSign().getBlock(), offBlockData);
active = false;
}
}

View File

@ -17,7 +17,6 @@
package de.erethon.dungeonsxl.sign.message;
import de.erethon.caliburn.item.VanillaItem;
import de.erethon.commons.compatibility.CompatibilityHandler;
import de.erethon.commons.compatibility.Internals;
import de.erethon.commons.misc.EnumUtil;
import de.erethon.commons.misc.NumberUtil;
@ -64,7 +63,7 @@ public class SoundMessageSign extends DSign {
sound = lines[1];
if (!lines[2].isEmpty()) {
String[] args = lines[2].split(",");
if (args.length >= 1 && args.length != 2 && Internals.andHigher(Internals.v1_11_R1).contains(CompatibilityHandler.getInstance().getInternals())) {
if (args.length >= 1 && args.length != 2 && Internals.isAtLeast(Internals.v1_11_R1)) {
category = EnumUtil.getEnumIgnoreCase(SoundCategory.class, args[0]);
if (category == null) {
category = SoundCategory.MASTER;
@ -100,7 +99,7 @@ public class SoundMessageSign extends DSign {
if (initialized) {
if (!done.contains(player)) {
done.add(player);
if (Internals.andHigher(Internals.v1_11_R1).contains(CompatibilityHandler.getInstance().getInternals())) {
if (Internals.isAtLeast(Internals.v1_11_R1)) {
player.playSound(getSign().getLocation(), sound, category, volume, pitch);
} else {
player.playSound(getSign().getLocation(), sound, volume, pitch);

View File

@ -17,6 +17,7 @@
package de.erethon.dungeonsxl.util;
import de.erethon.caliburn.item.VanillaItem;
import de.erethon.commons.compatibility.Internals;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
@ -29,7 +30,7 @@ public enum DColor {
BLACK(ChatColor.BLACK, DyeColor.BLACK, VanillaItem.BLACK_WOOL),
DARK_GRAY(ChatColor.DARK_GRAY, DyeColor.GRAY, VanillaItem.GRAY_WOOL),
LIGHT_GRAY(ChatColor.GRAY, DyeColor.SILVER, VanillaItem.LIGHT_GRAY_WOOL),
LIGHT_GRAY(ChatColor.GRAY, DyeColor.valueOf(Internals.isAtLeast(Internals.v1_13_R1) ? "LIGHT_GRAY" : "SILVER"), VanillaItem.LIGHT_GRAY_WOOL),
WHITE(ChatColor.WHITE, DyeColor.WHITE, VanillaItem.WHITE_WOOL),
DARK_GREEN(ChatColor.DARK_GREEN, DyeColor.GREEN, VanillaItem.GREEN_WOOL),
LIGHT_GREEN(ChatColor.GREEN, DyeColor.LIME, VanillaItem.LIME_WOOL),

View File

@ -0,0 +1,46 @@
/*
* Copyright (C) 2012-2018 Frank Baumann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.erethon.dungeonsxl.util;
import de.erethon.commons.misc.ReflectionUtil;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.bukkit.block.Block;
/**
* @author Daniel Saukel
*/
@Deprecated
public class MagicValueUtil {
private static Method CRAFT_BLOCK_SET_DATA;
static {
try {
CRAFT_BLOCK_SET_DATA = Class.forName(ReflectionUtil.ORG_BUKKIT_CRAFTBUKKIT + ".block.CraftBlock").getDeclaredMethod("setData", byte.class);
} catch (NoSuchMethodException | SecurityException | ClassNotFoundException exception) {
}
}
public static void setBlockData(Block block, byte data) {
try {
CRAFT_BLOCK_SET_DATA.invoke(block, data);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) {
}
}
}

View File

@ -23,6 +23,7 @@ import de.erethon.dungeonsxl.config.DMessage;
import de.erethon.dungeonsxl.player.DGamePlayer;
import de.erethon.dungeonsxl.player.DGroup;
import de.erethon.dungeonsxl.util.DColor;
import de.erethon.dungeonsxl.util.MagicValueUtil;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
@ -67,7 +68,7 @@ public class TeamFlag extends TeamBlock {
public static void setBlockWoolColor(Block block, DColor color) {
block.setType(color.getWoolMaterial().getMaterial());
if (!CompatibilityHandler.getInstance().getVersion().useNewMaterials()) {
block.setData(color.getWoolData());
MagicValueUtil.setBlockData(block, color.getWoolData());
}
}