#333 1.13 compatibility

This commit is contained in:
Daniel Saukel 2018-01-24 14:37:26 +01:00
parent db5738ff4c
commit 33c1fe53e4
18 changed files with 156 additions and 58 deletions

View File

@ -26,6 +26,7 @@ import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
import io.github.dre2n.dungeonsxl.player.DGroup; import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.util.DColor; import io.github.dre2n.dungeonsxl.util.DColor;
import io.github.dre2n.dungeonsxl.util.GUIUtil; import io.github.dre2n.dungeonsxl.util.GUIUtil;
import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -36,7 +37,6 @@ import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -440,7 +440,7 @@ public class Announcer {
boolean full = playerCount >= maxPlayersPerGroup; boolean full = playerCount >= maxPlayersPerGroup;
ItemStack button = new ItemStack(Material.WOOL, 1, plugin.getMainConfig().getGroupColorPriority().get(groupCount).getWoolData()); ItemStack button = LegacyUtil.createColoredWool(plugin.getMainConfig().getGroupColorPriority().get(groupCount));
ItemMeta meta = button.getItemMeta(); ItemMeta meta = button.getItemMeta();
meta.setDisplayName(name + (full ? ChatColor.DARK_RED : ChatColor.GREEN) + " [" + playerCount + "/" + maxPlayersPerGroup + "]"); meta.setDisplayName(name + (full ? ChatColor.DARK_RED : ChatColor.GREEN) + " [" + playerCount + "/" + maxPlayersPerGroup + "]");
meta.setLore(lore); meta.setLore(lore);

View File

@ -24,6 +24,7 @@ import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.player.DGamePlayer; import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer; import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
import io.github.dre2n.dungeonsxl.player.DPermission; import io.github.dre2n.dungeonsxl.player.DPermission;
import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -72,7 +73,7 @@ public class PortalCommand extends DRECommand {
dGlobalPlayer.setCreatingPortal(dPortal); dGlobalPlayer.setCreatingPortal(dPortal);
dPortal.setWorld(player.getWorld()); dPortal.setWorld(player.getWorld());
dGlobalPlayer.setCachedItem(player.getItemInHand()); dGlobalPlayer.setCachedItem(player.getItemInHand());
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD)); player.getInventory().setItemInHand(new ItemStack(LegacyUtil.WOODEN_SWORD));
MessageUtil.sendMessage(player, DMessage.PLAYER_PORTAL_INTRODUCTION.getMessage()); MessageUtil.sendMessage(player, DMessage.PLAYER_PORTAL_INTRODUCTION.getMessage());
} else { } else {

View File

@ -23,6 +23,7 @@ import io.github.dre2n.dungeonsxl.config.DMessage;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon; import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.game.Game; import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.player.DGroup; import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import io.github.dre2n.dungeonsxl.world.DResourceWorld; import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -242,7 +243,7 @@ public class GameSign extends GlobalProtection {
* a block which is protected by the returned GameSign * a block which is protected by the returned GameSign
*/ */
public static GameSign getByBlock(Block block) { public static GameSign getByBlock(Block block) {
if (!(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) { if (!LegacyUtil.isSign(block)) {
return null; return null;
} }

View File

@ -21,9 +21,9 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessage; import io.github.dre2n.dungeonsxl.config.DMessage;
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer; import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
import io.github.dre2n.dungeonsxl.player.DPermission; import io.github.dre2n.dungeonsxl.player.DPermission;
import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import io.github.dre2n.dungeonsxl.world.DEditWorld; import io.github.dre2n.dungeonsxl.world.DEditWorld;
import java.util.List; import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
@ -59,7 +59,7 @@ public class GlobalProtectionListener implements Listener {
} }
//return if above block is not a sign //return if above block is not a sign
if (blockAbove.getType() != Material.SIGN_POST && blockAbove.getType() != Material.WALL_SIGN) { if (!LegacyUtil.isSign(blockAbove)) {
return; return;
} }
@ -146,7 +146,7 @@ public class GlobalProtectionListener implements Listener {
} }
ItemStack item = event.getItem(); ItemStack item = event.getItem();
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
if (item.getType() != Material.WOOD_SWORD || block == null) { if (item.getType() != LegacyUtil.WOODEN_SWORD || block == null) {
return; return;
} }
@ -185,7 +185,7 @@ public class GlobalProtectionListener implements Listener {
return; return;
} }
if (clickedBlock.getType() == Material.WALL_SIGN || clickedBlock.getType() == Material.SIGN_POST) { if (LegacyUtil.isSign(clickedBlock)) {
// Check Group Signs // Check Group Signs
if (GroupSign.playerInteract(clickedBlock, player)) { if (GroupSign.playerInteract(clickedBlock, player)) {
event.setCancelled(true); event.setCancelled(true);

View File

@ -22,6 +22,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DMessage; import io.github.dre2n.dungeonsxl.config.DMessage;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon; import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.player.DGroup; import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import io.github.dre2n.dungeonsxl.world.DResourceWorld; import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -241,7 +242,7 @@ public class GroupSign extends GlobalProtection {
* a block which is protected by the returned GroupSign * a block which is protected by the returned GroupSign
*/ */
public static GroupSign getByBlock(Block block) { public static GroupSign getByBlock(Block block) {
if (!(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) { if (!LegacyUtil.isSign(block)) {
return null; return null;
} }

View File

@ -20,6 +20,7 @@ import io.github.dre2n.commons.chat.MessageUtil;
import io.github.dre2n.commons.misc.EnumUtil; import io.github.dre2n.commons.misc.EnumUtil;
import io.github.dre2n.commons.misc.NumberUtil; import io.github.dre2n.commons.misc.NumberUtil;
import io.github.dre2n.dungeonsxl.config.DMessage; import io.github.dre2n.dungeonsxl.config.DMessage;
import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
@ -89,23 +90,23 @@ public class DMobType {
// Load Items // Load Items
if (config.contains("itemHelmet")) { if (config.contains("itemHelmet")) {
itemHelmet = new ItemStack(config.getInt("itemHelmet")); itemHelmet = new ItemStack(LegacyUtil.getMaterial(config.getInt("itemHelmet")));
} }
if (config.contains("itemChestplate")) { if (config.contains("itemChestplate")) {
itemChestplate = new ItemStack(config.getInt("itemChestplate")); itemChestplate = new ItemStack(LegacyUtil.getMaterial(config.getInt("itemChestplate")));
} }
if (config.contains("itemBoots")) { if (config.contains("itemBoots")) {
itemBoots = new ItemStack(config.getInt("itemBoots")); itemBoots = new ItemStack(LegacyUtil.getMaterial(config.getInt("itemBoots")));
} }
if (config.contains("itemLeggings")) { if (config.contains("itemLeggings")) {
itemLeggings = new ItemStack(config.getInt("itemLeggings")); itemLeggings = new ItemStack(LegacyUtil.getMaterial(config.getInt("itemLeggings")));
} }
if (config.contains("itemHand")) { if (config.contains("itemHand")) {
itemHand = new ItemStack(config.getInt("itemHand")); itemHand = new ItemStack(LegacyUtil.getMaterial(config.getInt("itemHand")));
} }
// Load different Mob options // Load different Mob options
@ -127,7 +128,7 @@ public class DMobType {
int chance = 100; int chance = 100;
/* Item Stack */ /* Item Stack */
Material mat = Material.getMaterial(configSetion.getInt(dropPath + ".id")); Material mat = LegacyUtil.getMaterial(configSetion.getInt(dropPath + ".id"));
int amount = 1; int amount = 1;
short data = 0; short data = 0;

View File

@ -34,6 +34,7 @@ import io.github.dre2n.dungeonsxl.mob.DMob;
import io.github.dre2n.dungeonsxl.requirement.Requirement; import io.github.dre2n.dungeonsxl.requirement.Requirement;
import io.github.dre2n.dungeonsxl.reward.Reward; import io.github.dre2n.dungeonsxl.reward.Reward;
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger; import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import io.github.dre2n.dungeonsxl.world.DResourceWorld; import io.github.dre2n.dungeonsxl.world.DResourceWorld;
import io.github.dre2n.dungeonsxl.world.block.TeamFlag; import io.github.dre2n.dungeonsxl.world.block.TeamFlag;
@ -273,19 +274,19 @@ public class DGamePlayer extends DInstancePlayer {
// Leggings // Leggings
if (istack.getType() == Material.LEATHER_LEGGINGS || istack.getType() == Material.CHAINMAIL_LEGGINGS || istack.getType() == Material.IRON_LEGGINGS if (istack.getType() == Material.LEATHER_LEGGINGS || istack.getType() == Material.CHAINMAIL_LEGGINGS || istack.getType() == Material.IRON_LEGGINGS
|| istack.getType() == Material.DIAMOND_LEGGINGS || istack.getType() == Material.GOLD_LEGGINGS) { || istack.getType() == Material.DIAMOND_LEGGINGS || istack.getType() == LegacyUtil.GOLDEN_LEGGINGS) {
getPlayer().getInventory().setLeggings(istack); getPlayer().getInventory().setLeggings(istack);
} // Helmet } // Helmet
else if (istack.getType() == Material.LEATHER_HELMET || istack.getType() == Material.CHAINMAIL_HELMET || istack.getType() == Material.IRON_HELMET else if (istack.getType() == Material.LEATHER_HELMET || istack.getType() == Material.CHAINMAIL_HELMET || istack.getType() == Material.IRON_HELMET
|| istack.getType() == Material.DIAMOND_HELMET || istack.getType() == Material.GOLD_HELMET) { || istack.getType() == Material.DIAMOND_HELMET || istack.getType() == LegacyUtil.GOLDEN_HELMET) {
getPlayer().getInventory().setHelmet(istack); getPlayer().getInventory().setHelmet(istack);
} // Chestplate } // Chestplate
else if (istack.getType() == Material.LEATHER_CHESTPLATE || istack.getType() == Material.CHAINMAIL_CHESTPLATE || istack.getType() == Material.IRON_CHESTPLATE else if (istack.getType() == Material.LEATHER_CHESTPLATE || istack.getType() == Material.CHAINMAIL_CHESTPLATE || istack.getType() == Material.IRON_CHESTPLATE
|| istack.getType() == Material.DIAMOND_CHESTPLATE || istack.getType() == Material.GOLD_CHESTPLATE) { || istack.getType() == Material.DIAMOND_CHESTPLATE || istack.getType() == LegacyUtil.GOLDEN_CESTPLATE) {
getPlayer().getInventory().setChestplate(istack); getPlayer().getInventory().setChestplate(istack);
} // Boots } // Boots
else if (istack.getType() == Material.LEATHER_BOOTS || istack.getType() == Material.CHAINMAIL_BOOTS || istack.getType() == Material.IRON_BOOTS else if (istack.getType() == Material.LEATHER_BOOTS || istack.getType() == Material.CHAINMAIL_BOOTS || istack.getType() == Material.IRON_BOOTS
|| istack.getType() == Material.DIAMOND_BOOTS || istack.getType() == Material.GOLD_BOOTS) { || istack.getType() == Material.DIAMOND_BOOTS || istack.getType() == LegacyUtil.GOLDEN_BOOTS) {
getPlayer().getInventory().setBoots(istack); getPlayer().getInventory().setBoots(istack);
} else { } else {
getPlayer().getInventory().addItem(istack); getPlayer().getInventory().addItem(istack);
@ -406,7 +407,7 @@ public class DGamePlayer extends DInstancePlayer {
public void setRobbedGroup(DGroup dGroup) { public void setRobbedGroup(DGroup dGroup) {
if (dGroup != null) { if (dGroup != null) {
oldHelmet = player.getInventory().getHelmet(); oldHelmet = player.getInventory().getHelmet();
player.getInventory().setHelmet(new ItemStack(Material.WOOL, 1, getDGroup().getDColor().getWoolData())); player.getInventory().setHelmet(LegacyUtil.createColoredWool(getDGroup().getDColor()));
} }
stealing = dGroup; stealing = dGroup;

View File

@ -19,8 +19,7 @@ package io.github.dre2n.dungeonsxl.player;
import com.gmail.filoghost.holographicdisplays.api.Hologram; import com.gmail.filoghost.holographicdisplays.api.Hologram;
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI; import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
import io.github.dre2n.dungeonsxl.DungeonsXL; import io.github.dre2n.dungeonsxl.DungeonsXL;
import org.bukkit.Material; import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import org.bukkit.inventory.ItemStack;
/** /**
* @author Daniel Saukel * @author Daniel Saukel
@ -35,7 +34,7 @@ public class DGroupTag {
DGroup group = player.getDGroup(); DGroup group = player.getDGroup();
if (group != null) { if (group != null) {
hologram = HologramsAPI.createHologram(DungeonsXL.getInstance(), player.getPlayer().getLocation().clone().add(0, 3.5, 0)); hologram = HologramsAPI.createHologram(DungeonsXL.getInstance(), player.getPlayer().getLocation().clone().add(0, 3.5, 0));
hologram.appendItemLine(new ItemStack(Material.WOOL, 1, group.getDColor().getWoolData())); hologram.appendItemLine(LegacyUtil.createColoredWool(group.getDColor()));
hologram.appendTextLine(group.getName()); hologram.appendTextLine(group.getName());
} }
} }

View File

@ -23,6 +23,7 @@ import io.github.dre2n.dungeonsxl.config.MainConfig;
import io.github.dre2n.dungeonsxl.game.Game; import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.mob.DMob; import io.github.dre2n.dungeonsxl.mob.DMob;
import io.github.dre2n.dungeonsxl.trigger.UseItemTrigger; import io.github.dre2n.dungeonsxl.trigger.UseItemTrigger;
import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import io.github.dre2n.dungeonsxl.util.ParsingUtil; import io.github.dre2n.dungeonsxl.util.ParsingUtil;
import io.github.dre2n.dungeonsxl.world.DEditWorld; import io.github.dre2n.dungeonsxl.world.DEditWorld;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
@ -563,7 +564,7 @@ public class DPlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
} else if (clickedBlock.getType() == Material.BED_BLOCK) { } else if (LegacyUtil.isBed(clickedBlock.getType())) {
if (!DPermission.hasPermission(player, DPermission.BYPASS)) { if (!DPermission.hasPermission(player, DPermission.BYPASS)) {
MessageUtil.sendMessage(player, DMessage.ERROR_BED.getMessage()); MessageUtil.sendMessage(player, DMessage.ERROR_BED.getMessage());
event.setCancelled(true); event.setCancelled(true);
@ -618,7 +619,7 @@ public class DPlayerListener implements Listener {
if (item.getItemMeta().hasDisplayName()) { if (item.getItemMeta().hasDisplayName()) {
name = item.getItemMeta().getDisplayName(); name = item.getItemMeta().getDisplayName();
} else if (item.getType() == Material.WRITTEN_BOOK || item.getType() == Material.BOOK_AND_QUILL) { } else if (item.getType() == Material.WRITTEN_BOOK || item.getType() == LegacyUtil.WRITABLE_BOOK) {
if (item.getItemMeta() instanceof BookMeta) { if (item.getItemMeta() instanceof BookMeta) {
BookMeta meta = (BookMeta) item.getItemMeta(); BookMeta meta = (BookMeta) item.getItemMeta();
if (meta.hasTitle()) { if (meta.hasTitle()) {

View File

@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commons.misc.BlockUtil; import io.github.dre2n.commons.misc.BlockUtil;
import io.github.dre2n.commons.misc.NumberUtil; import io.github.dre2n.commons.misc.NumberUtil;
import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import io.github.dre2n.dungeonsxl.world.block.TeamBed; import io.github.dre2n.dungeonsxl.world.block.TeamBed;
import org.bukkit.Material; import org.bukkit.Material;
@ -54,7 +55,7 @@ public class BedSign extends DSign {
this.team = NumberUtil.parseInt(lines[1]); this.team = NumberUtil.parseInt(lines[1]);
Block block = BlockUtil.getAttachedBlock(getSign().getBlock()); Block block = BlockUtil.getAttachedBlock(getSign().getBlock());
if (block.getType() == Material.BED_BLOCK) { if (LegacyUtil.isBed(block.getType())) {
if (getGame().getDGroups().size() > team) { if (getGame().getDGroups().size() > team) {
getGameWorld().addGameBlock(new TeamBed(block, getGame().getDGroups().get(team))); getGameWorld().addGameBlock(new TeamBed(block, getGame().getDGroups().get(team)));
} }

View File

@ -27,6 +27,7 @@ import io.github.dre2n.commons.misc.NumberUtil;
import io.github.dre2n.dungeonsxl.sign.DSign; import io.github.dre2n.dungeonsxl.sign.DSign;
import io.github.dre2n.dungeonsxl.sign.DSignType; import io.github.dre2n.dungeonsxl.sign.DSignType;
import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault; import io.github.dre2n.dungeonsxl.sign.DSignTypeDefault;
import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -83,7 +84,7 @@ public class HologramSign extends DSign {
item = new ItemStack(Material.valueOf(id)); item = new ItemStack(Material.valueOf(id));
} else { } else {
item = new ItemStack(NumberUtil.parseInt(id, 1)); item = new ItemStack(LegacyUtil.getMaterial(NumberUtil.parseInt(id, 1)));
} }
} }

View File

@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.util;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Material;
/** /**
* Links different color types together. * Links different color types together.
@ -26,29 +27,31 @@ import org.bukkit.DyeColor;
*/ */
public enum DColor { public enum DColor {
BLACK(ChatColor.BLACK, DyeColor.BLACK), BLACK(ChatColor.BLACK, DyeColor.BLACK, Material.BLACK_WOOL),
DARK_GRAY(ChatColor.DARK_GRAY, DyeColor.GRAY), DARK_GRAY(ChatColor.DARK_GRAY, DyeColor.GRAY, Material.GRAY_WOOL),
LIGHT_GRAY(ChatColor.GRAY, DyeColor.SILVER), LIGHT_GRAY(ChatColor.GRAY, DyeColor.SILVER, Material.LIGHT_GRAY_WOOL),
WHITE(ChatColor.WHITE, DyeColor.WHITE), WHITE(ChatColor.WHITE, DyeColor.WHITE, Material.WHITE_WOOL),
DARK_GREEN(ChatColor.DARK_GREEN, DyeColor.GREEN), DARK_GREEN(ChatColor.DARK_GREEN, DyeColor.GREEN, Material.GREEN_WOOL),
LIGHT_GREEN(ChatColor.GREEN, DyeColor.LIME), LIGHT_GREEN(ChatColor.GREEN, DyeColor.LIME, Material.LIME_WOOL),
CYAN(ChatColor.DARK_AQUA, DyeColor.CYAN), CYAN(ChatColor.DARK_AQUA, DyeColor.CYAN, Material.CYAN_WOOL),
DARK_BLUE(ChatColor.DARK_BLUE, DyeColor.BLUE), DARK_BLUE(ChatColor.DARK_BLUE, DyeColor.BLUE, Material.BLUE_WOOL),
LIGHT_BLUE(ChatColor.AQUA, DyeColor.LIGHT_BLUE), LIGHT_BLUE(ChatColor.AQUA, DyeColor.LIGHT_BLUE, Material.LIGHT_BLUE_WOOL),
PURPLE(ChatColor.DARK_PURPLE, DyeColor.PURPLE), PURPLE(ChatColor.DARK_PURPLE, DyeColor.PURPLE, Material.PURPLE_WOOL),
MAGENTA(ChatColor.LIGHT_PURPLE, DyeColor.MAGENTA), MAGENTA(ChatColor.LIGHT_PURPLE, DyeColor.MAGENTA, Material.MAGENTA_WOOL),
DARK_RED(ChatColor.DARK_RED, DyeColor.BROWN), DARK_RED(ChatColor.DARK_RED, DyeColor.BROWN, Material.BROWN_WOOL),
LIGHT_RED(ChatColor.RED, DyeColor.RED), LIGHT_RED(ChatColor.RED, DyeColor.RED, Material.RED_WOOL),
ORANGE(ChatColor.GOLD, DyeColor.ORANGE), ORANGE(ChatColor.GOLD, DyeColor.ORANGE, Material.ORANGE_WOOL),
YELLOW(ChatColor.YELLOW, DyeColor.YELLOW), YELLOW(ChatColor.YELLOW, DyeColor.YELLOW, Material.YELLOW_WOOL),
DEFAULT(ChatColor.BLUE, DyeColor.PINK); DEFAULT(ChatColor.BLUE, DyeColor.PINK, Material.PINK_WOOL);
private ChatColor chat; private ChatColor chat;
private DyeColor dye; private DyeColor dye;
private Material woolMaterial;
DColor(ChatColor chat, DyeColor dye) { DColor(ChatColor chat, DyeColor dye, Material woolMaterial) {
this.chat = chat; this.chat = chat;
this.dye = dye; this.dye = dye;
this.woolMaterial = woolMaterial;
} }
/** /**
@ -73,7 +76,7 @@ public enum DColor {
} }
/** /**
* @deprecated Use getDyeColor() instead * @deprecated Use getDyeColor() or getMaterial() instead
* @return the wool DV * @return the wool DV
*/ */
@Deprecated @Deprecated
@ -81,6 +84,13 @@ public enum DColor {
return dye.getWoolData(); return dye.getWoolData();
} }
/**
* @return the wool material
*/
public Material getWoolMaterial() {
return woolMaterial;
}
/** /**
* @param color * @param color
* the DyeColor to check * the DyeColor to check

View File

@ -19,6 +19,7 @@ package io.github.dre2n.dungeonsxl.util;
import io.github.dre2n.commons.misc.NumberUtil; import io.github.dre2n.commons.misc.NumberUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -62,7 +63,7 @@ public class DeserializationUtil {
} }
// Add Item to Stacks // Add Item to Stacks
ItemStack itemStack = new ItemStack(itemId, itemSize, (short) itemData); ItemStack itemStack = new ItemStack(LegacyUtil.getMaterial(itemId), itemSize, (short) itemData);
if (itemEnchantment != null) { if (itemEnchantment != null) {
itemStack.addEnchantment(itemEnchantment, itemLvlEnchantment); itemStack.addEnchantment(itemEnchantment, itemLvlEnchantment);
} }

View File

@ -33,14 +33,14 @@ import org.bukkit.potion.PotionType;
public class GUIButton { public class GUIButton {
/* Raw skulls */ /* Raw skulls */
public static final ItemStack SKULL = new ItemStack(Material.SKULL_ITEM, 1, (short) 3); public static final ItemStack LEFT = ItemUtil.setSkullOwner(LegacyUtil.RAW_PLAYER_HEAD, "69b9a08d-4e89-4878-8be8-551caeacbf2a", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2ViZjkwNzQ5NGE5MzVlOTU1YmZjYWRhYjgxYmVhZmI5MGZiOWJlNDljNzAyNmJhOTdkNzk4ZDVmMWEyMyJ9fX0=");
public static final ItemStack LEFT = ItemUtil.setSkullOwner(SKULL, "69b9a08d-4e89-4878-8be8-551caeacbf2a", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2ViZjkwNzQ5NGE5MzVlOTU1YmZjYWRhYjgxYmVhZmI5MGZiOWJlNDljNzAyNmJhOTdkNzk4ZDVmMWEyMyJ9fX0="); public static final ItemStack RIGHT = ItemUtil.setSkullOwner(LegacyUtil.RAW_PLAYER_HEAD, "15f49744-9b61-46af-b1c3-71c6261a0d0e", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ==");
public static final ItemStack RIGHT = ItemUtil.setSkullOwner(SKULL, "15f49744-9b61-46af-b1c3-71c6261a0d0e", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ==");
/* GUI buttons */ /* GUI buttons */
public static final ItemStack NEXT_PAGE = setDisplayName(RIGHT, DMessage.MISC_NEXT_PAGE.getMessage()); public static final ItemStack NEXT_PAGE = setDisplayName(RIGHT, DMessage.MISC_NEXT_PAGE.getMessage());
public static final ItemStack PREVIOUS_PAGE = setDisplayName(LEFT, DMessage.MISC_PREVIOUS_PAGE.getMessage()); public static final ItemStack PREVIOUS_PAGE = setDisplayName(LEFT, DMessage.MISC_PREVIOUS_PAGE.getMessage());
public static final ItemStack PLACEHOLDER = setDisplayName(new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15), ChatColor.RESET.toString()); public static final ItemStack PLACEHOLDER = setDisplayName(LegacyUtil.RAW_PLACEHOLDER, ChatColor.RESET.toString());
;
/* Blank items that show meta stuff by default */ /* Blank items that show meta stuff by default */
public static final ItemStack GUI_SWORD = new ItemStack(Material.IRON_SWORD); public static final ItemStack GUI_SWORD = new ItemStack(Material.IRON_SWORD);

View File

@ -0,0 +1,79 @@
/*
* 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 io.github.dre2n.dungeonsxl.util;
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
import io.github.dre2n.commons.compatibility.Version;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
/**
* Methods for backwards compatibility
*
* @author Daniel Saukel
*/
@Deprecated
public class LegacyUtil {
public static boolean is1_9 = Version.andHigher(Version.MC1_9).contains(CompatibilityHandler.getInstance().getVersion());
public static boolean is1_13 = Version.andHigher(Version.MC1_13).contains(CompatibilityHandler.getInstance().getVersion());
public static Material WOODEN_SWORD = is1_13 ? Material.valueOf("WOODEN_SWORD") : Material.valueOf("WOOD_SWORD");
public static Material GOLDEN_HELMET = is1_13 ? Material.valueOf("GOLDEN_HELMET") : Material.valueOf("GOLD_HELMET");
public static Material GOLDEN_CESTPLATE = is1_13 ? Material.valueOf("GOLDEN_CHESTPLATE") : Material.valueOf("GOLD_CHESTPLATE");
public static Material GOLDEN_LEGGINGS = is1_13 ? Material.valueOf("GOLDEN_LEGGINGS") : Material.valueOf("GOLD_LEGGINGS");
public static Material GOLDEN_BOOTS = is1_13 ? Material.valueOf("GOLDEN_BOOTS") : Material.valueOf("GOLD_BOOTS");
public static Material WRITABLE_BOOK = is1_13 ? Material.valueOf("WRITABLE_BOOK") : Material.valueOf("BOOK_AND_QUILL");
private static Material LEGACY_WOOL = Material.valueOf("WOOL");
private static Material LEGACY_SIGN_POST = Material.valueOf("SIGN_POST");
public static ItemStack RAW_PLACEHOLDER = is1_13 ? new ItemStack(Material.valueOf("BLACK_STAINED_GLASS_PANE")) : new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 15);
public static ItemStack RAW_PLAYER_HEAD = is1_13 ? new ItemStack(Material.valueOf("PLAYER_HEAD")) : new ItemStack(Material.valueOf("SKULL"), 1, (short) 3);
public static boolean isSign(Block block) {
if (is1_13) {
return block.getType() == Material.SIGN || block.getType() == Material.WALL_SIGN;
} else {
return block.getType() == LEGACY_SIGN_POST || block.getType() == Material.WALL_SIGN;
}
}
public static boolean isBed(Material material) {
return material.name().endsWith("_BED") || material.name().equals("BED_BLOCK") || material.name().equals("BED");
}
public static ItemStack createColoredWool(DColor color) {
if (is1_13) {
return new ItemStack(color.getWoolMaterial());
} else {
return new ItemStack(LEGACY_WOOL, 1, color.getWoolData());
}
}
public static void setBlockWoolColor(Block block, DColor color) {
if (is1_13) {
block.setType(color.getWoolMaterial());
} else {
block.setTypeIdAndData(35, color.getWoolData(), false);
}
}
public static Material getMaterial(int id) {
return Material.getMaterial(id);
}
}

View File

@ -17,6 +17,7 @@
package io.github.dre2n.dungeonsxl.world.block; package io.github.dre2n.dungeonsxl.world.block;
import io.github.dre2n.commons.misc.NumberUtil; import io.github.dre2n.commons.misc.NumberUtil;
import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -47,7 +48,7 @@ public class PlaceableBlock extends GameBlock {
if (!ids.isEmpty()) { if (!ids.isEmpty()) {
String[] splittedIds = ids.split(","); String[] splittedIds = ids.split(",");
for (String id : splittedIds) { for (String id : splittedIds) {
Material material = Material.getMaterial(NumberUtil.parseInt(id)); Material material = LegacyUtil.getMaterial(NumberUtil.parseInt(id));
if (material != null) { if (material != null) {
materials.add(material); materials.add(material);
} }

View File

@ -20,6 +20,7 @@ import io.github.dre2n.commons.chat.MessageUtil;
import io.github.dre2n.dungeonsxl.config.DMessage; import io.github.dre2n.dungeonsxl.config.DMessage;
import io.github.dre2n.dungeonsxl.player.DGamePlayer; import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup; import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -41,16 +42,16 @@ public class TeamBed extends TeamBlock implements MultiBlock {
/* Getters and setters */ /* Getters and setters */
public Block getAttachedBlock(Block block) { public Block getAttachedBlock(Block block) {
if (block.getRelative(BlockFace.EAST).getType() == Material.BED_BLOCK) { if (LegacyUtil.isBed(block.getRelative(BlockFace.EAST).getType())) {
return block.getRelative(BlockFace.EAST); return block.getRelative(BlockFace.EAST);
} else if (block.getRelative(BlockFace.NORTH).getType() == Material.BED_BLOCK) { } else if (LegacyUtil.isBed(block.getRelative(BlockFace.NORTH).getType())) {
return block.getRelative(BlockFace.NORTH); return block.getRelative(BlockFace.NORTH);
} else if (block.getRelative(BlockFace.WEST).getType() == Material.BED_BLOCK) { } else if (LegacyUtil.isBed(block.getRelative(BlockFace.WEST).getType())) {
return block.getRelative(BlockFace.WEST); return block.getRelative(BlockFace.WEST);
} else if (block.getRelative(BlockFace.SOUTH).getType() == Material.BED_BLOCK) { } else if (LegacyUtil.isBed(block.getRelative(BlockFace.SOUTH).getType())) {
return block.getRelative(BlockFace.SOUTH); return block.getRelative(BlockFace.SOUTH);
} else { } else {

View File

@ -20,6 +20,7 @@ import io.github.dre2n.commons.chat.MessageUtil;
import io.github.dre2n.dungeonsxl.config.DMessage; import io.github.dre2n.dungeonsxl.config.DMessage;
import io.github.dre2n.dungeonsxl.player.DGamePlayer; import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup; import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.util.LegacyUtil;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -30,8 +31,6 @@ import org.bukkit.event.block.BlockBreakEvent;
*/ */
public class TeamFlag extends TeamBlock { public class TeamFlag extends TeamBlock {
public static final int WOOL = 35;
public TeamFlag(Block block, DGroup owner) { public TeamFlag(Block block, DGroup owner) {
super(block, owner); super(block, owner);
reset(); reset();
@ -42,7 +41,7 @@ public class TeamFlag extends TeamBlock {
* Reset a team flag when the capturer dies. * Reset a team flag when the capturer dies.
*/ */
public void reset() { public void reset() {
block.setTypeIdAndData(WOOL, owner.getDColor().getWoolData(), false); LegacyUtil.setBlockWoolColor(block, owner.getDColor());
} }
@Override @Override