From 3829e33e40f69e1c51bdf3bf0a98225a7ad0fe5d Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Tue, 8 May 2018 21:34:37 +0200 Subject: [PATCH] Implement Caliburn 0.4 --- pom.xml | 8 +- .../de/erethon/dungeonsxl/DungeonsXL.java | 60 +++--- .../dungeonsxl/announcer/Announcer.java | 4 +- .../dungeonsxl/command/PortalCommand.java | 17 +- .../dungeonsxl/game/GameRuleProvider.java | 15 +- .../de/erethon/dungeonsxl/global/DPortal.java | 3 +- .../erethon/dungeonsxl/global/GameSign.java | 5 +- .../global/GlobalProtectionCache.java | 5 +- .../global/GlobalProtectionListener.java | 9 +- .../erethon/dungeonsxl/global/GroupSign.java | 5 +- .../dungeonsxl/loottable/DLootTable.java | 178 ------------------ .../dungeonsxl/loottable/DLootTableCache.java | 77 -------- .../dungeonsxl/mob/CitizensMobProvider.java | 2 +- .../java/de/erethon/dungeonsxl/mob/DMob.java | 26 ++- .../de/erethon/dungeonsxl/mob/DMobType.java | 67 ++++--- .../erethon/dungeonsxl/mob/DMobTypeCache.java | 78 -------- .../de/erethon/dungeonsxl/player/DClass.java | 11 +- .../dungeonsxl/player/DGamePlayer.java | 25 ++- .../erethon/dungeonsxl/player/DGroupTag.java | 3 +- .../dungeonsxl/player/DPlayerListener.java | 19 +- .../dungeonsxl/reward/RewardListener.java | 10 +- .../de/erethon/dungeonsxl/sign/BedSign.java | 8 +- .../erethon/dungeonsxl/sign/BossShopSign.java | 4 +- .../dungeonsxl/sign/CheckpointSign.java | 4 +- .../de/erethon/dungeonsxl/sign/ChestSign.java | 21 ++- .../dungeonsxl/sign/ChunkUpdaterSign.java | 4 +- .../erethon/dungeonsxl/sign/CommandSign.java | 4 +- .../de/erethon/dungeonsxl/sign/DropSign.java | 11 +- .../de/erethon/dungeonsxl/sign/EndSign.java | 4 +- .../de/erethon/dungeonsxl/sign/FloorSign.java | 4 +- .../de/erethon/dungeonsxl/sign/LeaveSign.java | 4 +- .../dungeonsxl/sign/LivesModifierSign.java | 4 +- .../erethon/dungeonsxl/sign/OpenDoorSign.java | 4 +- .../de/erethon/dungeonsxl/sign/PlaceSign.java | 4 +- .../dungeonsxl/sign/ProtectionSign.java | 4 +- .../erethon/dungeonsxl/sign/RedstoneSign.java | 8 +- .../dungeonsxl/sign/ResourcePackSign.java | 4 +- .../erethon/dungeonsxl/sign/ScriptSign.java | 4 +- .../erethon/dungeonsxl/sign/TeleportSign.java | 4 +- .../erethon/dungeonsxl/sign/TriggerSign.java | 4 +- .../de/erethon/dungeonsxl/sign/WaveSign.java | 4 +- .../dungeonsxl/sign/lobby/LobbySign.java | 4 +- .../dungeonsxl/sign/lobby/ReadySign.java | 4 +- .../dungeonsxl/sign/lobby/StartSign.java | 4 +- .../sign/message/ActionBarSign.java | 4 +- .../dungeonsxl/sign/message/HologramSign.java | 28 +-- .../dungeonsxl/sign/message/MessageSign.java | 4 +- .../sign/message/SoundMessageSign.java | 4 +- .../dungeonsxl/sign/message/TitleSign.java | 4 +- .../erethon/dungeonsxl/sign/mob/DMobSign.java | 4 +- .../dungeonsxl/sign/mob/ExternalMobSign.java | 4 +- .../sign/mob/ExternalMobSpawnTask.java | 2 +- .../dungeonsxl/sign/mob/MobSpawnTask.java | 10 +- .../dungeonsxl/trigger/RedstoneTrigger.java | 25 +-- .../dungeonsxl/trigger/UseItemTrigger.java | 9 +- .../de/erethon/dungeonsxl/util/DColor.java | 47 +++-- .../dungeonsxl/util/DeserializationUtil.java | 76 -------- .../erethon/dungeonsxl/util/LegacyUtil.java | 78 -------- .../erethon/dungeonsxl/world/DGameWorld.java | 17 +- .../dungeonsxl/world/DWorldListener.java | 6 +- .../erethon/dungeonsxl/world/WorldConfig.java | 31 ++- .../world/block/PlaceableBlock.java | 20 +- .../dungeonsxl/world/block/TeamBed.java | 16 +- .../dungeonsxl/world/block/TeamFlag.java | 16 +- 64 files changed, 325 insertions(+), 831 deletions(-) delete mode 100644 src/main/java/de/erethon/dungeonsxl/loottable/DLootTable.java delete mode 100644 src/main/java/de/erethon/dungeonsxl/loottable/DLootTableCache.java delete mode 100644 src/main/java/de/erethon/dungeonsxl/mob/DMobTypeCache.java delete mode 100644 src/main/java/de/erethon/dungeonsxl/util/DeserializationUtil.java delete mode 100644 src/main/java/de/erethon/dungeonsxl/util/LegacyUtil.java diff --git a/pom.xml b/pom.xml index 067d939f..5acb8675 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ - dungeonsxl-${project.version}${buildNo} + ${project.artifactId}-${project.version}${buildNo} src/main/java @@ -45,7 +45,7 @@ - io.github.dre2n:caliburn + de.erethon:caliburn de.erethon:commons @@ -81,9 +81,9 @@ compile - io.github.dre2n + de.erethon caliburn - 0.3 + 0.4-SNAPSHOT compile diff --git a/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java b/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java index c5685dc9..25fcfc43 100644 --- a/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java +++ b/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java @@ -16,10 +16,13 @@ */ package de.erethon.dungeonsxl; +import de.erethon.caliburn.CaliburnAPI; +import de.erethon.caliburn.loottable.LootTable; import de.erethon.commons.compatibility.Internals; import de.erethon.commons.config.MessageConfig; import de.erethon.commons.javaplugin.DREPlugin; import de.erethon.commons.javaplugin.DREPluginSettings; +import de.erethon.commons.misc.FileUtil; import de.erethon.dungeonsxl.announcer.AnnouncerCache; import de.erethon.dungeonsxl.command.DCommandCache; import de.erethon.dungeonsxl.config.DMessage; @@ -29,8 +32,8 @@ import de.erethon.dungeonsxl.dungeon.DungeonCache; import de.erethon.dungeonsxl.game.Game; import de.erethon.dungeonsxl.game.GameTypeCache; import de.erethon.dungeonsxl.global.GlobalProtectionCache; -import de.erethon.dungeonsxl.loottable.DLootTableCache; -import de.erethon.dungeonsxl.mob.DMobTypeCache; +import de.erethon.dungeonsxl.mob.DMobListener; +import de.erethon.dungeonsxl.mob.DMobType; import de.erethon.dungeonsxl.mob.ExternalMobProviderCache; import de.erethon.dungeonsxl.player.DClassCache; import de.erethon.dungeonsxl.player.DGamePlayer; @@ -44,12 +47,12 @@ import de.erethon.dungeonsxl.sign.SignScriptCache; import de.erethon.dungeonsxl.trigger.TriggerTypeCache; import de.erethon.dungeonsxl.util.NoReload; import de.erethon.dungeonsxl.world.DWorldCache; -import io.github.dre2n.caliburn.CaliburnAPI; import java.io.File; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; +import org.bukkit.Bukkit; import org.bukkit.event.HandlerList; import org.bukkit.inventory.Inventory; @@ -62,6 +65,7 @@ import org.bukkit.inventory.Inventory; public class DungeonsXL extends DREPlugin { private static DungeonsXL instance; + private CaliburnAPI caliburn; public static final String[] EXCLUDED_FILES = {"config.yml", "uid.dat", "DXLData.data", "data"}; public static File BACKUPS; @@ -91,8 +95,6 @@ public class DungeonsXL extends DREPlugin { private DPlayerCache dPlayers; private AnnouncerCache announcers; private DClassCache dClasses; - private DLootTableCache dLootTables; - private DMobTypeCache dMobTypes; private SignScriptCache signScripts; private DWorldCache dWorlds; @@ -239,8 +241,8 @@ public class DungeonsXL extends DREPlugin { loadDPlayers(); loadAnnouncers(ANNOUNCERS); loadDClasses(CLASSES); - loadDLootTables(LOOT_TABLES); - loadDMobTypes(MOBS); + loadLootTables(LOOT_TABLES); + loadMobs(MOBS); loadSignScripts(SIGNS); loadDCommandCache(); } @@ -265,13 +267,18 @@ public class DungeonsXL extends DREPlugin { return instance; } + /** + * @return the loaded instance of CaliburnAPI + */ + public CaliburnAPI getCaliburn() { + return caliburn; + } + /** * load / reload a new instance of CaliburnAPI if none exists */ private void loadCaliburnAPI() { - if (CaliburnAPI.getInstance() == null) { - new CaliburnAPI(this).setupClean(); - } + caliburn = CaliburnAPI.getInstance() == null ? new CaliburnAPI(this) : CaliburnAPI.getInstance(); } /** @@ -480,31 +487,24 @@ public class DungeonsXL extends DREPlugin { } /** - * @return the loaded instance of DLootTableCache + * load / reload loot tables */ - public DLootTableCache getDLootTables() { - return dLootTables; + public void loadLootTables(File file) { + for (File script : FileUtil.getFilesForFolder(file)) { + new LootTable(caliburn, script); + } } /** - * load / reload a new instance of DLootTableCache + * load / reload DMob types */ - public void loadDLootTables(File file) { - dLootTables = new DLootTableCache(file); - } - - /** - * @return the loaded instance of DMobTypeCache - */ - public DMobTypeCache getDMobTypes() { - return dMobTypes; - } - - /** - * load / reload a new instance of DMobTypeCache - */ - public void loadDMobTypes(File file) { - dMobTypes = new DMobTypeCache(file); + public void loadMobs(File file) { + if (file.isDirectory()) { + for (File script : FileUtil.getFilesForFolder(file)) { + caliburn.getExMobs().add(new DMobType(script)); + } + } + Bukkit.getPluginManager().registerEvents(new DMobListener(), this); } /** diff --git a/src/main/java/de/erethon/dungeonsxl/announcer/Announcer.java b/src/main/java/de/erethon/dungeonsxl/announcer/Announcer.java index 11131325..21b570e6 100644 --- a/src/main/java/de/erethon/dungeonsxl/announcer/Announcer.java +++ b/src/main/java/de/erethon/dungeonsxl/announcer/Announcer.java @@ -26,7 +26,6 @@ import de.erethon.dungeonsxl.event.dgroup.DGroupCreateEvent; import de.erethon.dungeonsxl.player.DGroup; import de.erethon.dungeonsxl.util.DColor; import de.erethon.dungeonsxl.util.GUIUtil; -import de.erethon.dungeonsxl.util.LegacyUtil; import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -440,7 +439,8 @@ public class Announcer { boolean full = playerCount >= maxPlayersPerGroup; - ItemStack button = LegacyUtil.createColoredWool(plugin.getMainConfig().getGroupColorPriority().get(groupCount)); + DColor color = plugin.getMainConfig().getGroupColorPriority().get(groupCount); + ItemStack button = color.getWoolMaterial().toItemStack(); ItemMeta meta = button.getItemMeta(); meta.setDisplayName(name + (full ? ChatColor.DARK_RED : ChatColor.GREEN) + " [" + playerCount + "/" + maxPlayersPerGroup + "]"); meta.setLore(lore); diff --git a/src/main/java/de/erethon/dungeonsxl/command/PortalCommand.java b/src/main/java/de/erethon/dungeonsxl/command/PortalCommand.java index d679710b..6d5d3440 100644 --- a/src/main/java/de/erethon/dungeonsxl/command/PortalCommand.java +++ b/src/main/java/de/erethon/dungeonsxl/command/PortalCommand.java @@ -16,6 +16,9 @@ */ package de.erethon.dungeonsxl.command; +import de.erethon.caliburn.CaliburnAPI; +import de.erethon.caliburn.item.ExItem; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.command.DRECommand; import de.erethon.dungeonsxl.DungeonsXL; @@ -24,11 +27,8 @@ import de.erethon.dungeonsxl.global.DPortal; import de.erethon.dungeonsxl.player.DGamePlayer; import de.erethon.dungeonsxl.player.DGlobalPlayer; import de.erethon.dungeonsxl.player.DPermission; -import de.erethon.dungeonsxl.util.LegacyUtil; -import org.bukkit.Material; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; /** * @author Frank Baumann, Daniel Saukel @@ -36,6 +36,7 @@ import org.bukkit.inventory.ItemStack; public class PortalCommand extends DRECommand { DungeonsXL plugin = DungeonsXL.getInstance(); + CaliburnAPI caliburn = plugin.getCaliburn(); public PortalCommand() { setCommand("portal"); @@ -56,24 +57,24 @@ public class PortalCommand extends DRECommand { return; } - Material material = null; + ExItem material = null; if (args.length == 2) { - material = Material.matchMaterial(args[1]); + material = caliburn.getExItem(args[1]); } if (material == null) { - material = Material.PORTAL; + material = VanillaItem.PORTAL; } DPortal dPortal = dGlobalPlayer.getPortal(); if (dPortal == null) { - dPortal = new DPortal(plugin.getGlobalProtections().generateId(DPortal.class, player.getWorld()), player.getWorld(), material, false); + dPortal = new DPortal(plugin.getGlobalProtections().generateId(DPortal.class, player.getWorld()), player.getWorld(), material.getMaterial(), false); dGlobalPlayer.setCreatingPortal(dPortal); dPortal.setWorld(player.getWorld()); dGlobalPlayer.setCachedItem(player.getItemInHand()); - player.getInventory().setItemInHand(new ItemStack(LegacyUtil.WOODEN_SWORD)); + player.getInventory().setItemInHand(VanillaItem.WOODEN_SWORD.toItemStack()); MessageUtil.sendMessage(player, DMessage.PLAYER_PORTAL_INTRODUCTION.getMessage()); } else { diff --git a/src/main/java/de/erethon/dungeonsxl/game/GameRuleProvider.java b/src/main/java/de/erethon/dungeonsxl/game/GameRuleProvider.java index 22e28d96..f5c53911 100644 --- a/src/main/java/de/erethon/dungeonsxl/game/GameRuleProvider.java +++ b/src/main/java/de/erethon/dungeonsxl/game/GameRuleProvider.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.game; +import de.erethon.caliburn.item.ExItem; import de.erethon.dungeonsxl.requirement.Requirement; import de.erethon.dungeonsxl.reward.Reward; import java.util.ArrayList; @@ -27,9 +28,7 @@ import java.util.Map; import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.GameMode; -import org.bukkit.Material; import org.bukkit.entity.EntityType; -import org.bukkit.inventory.ItemStack; /** * See {@link de.erethon.dungeonsxl.config.WorldConfig} @@ -117,11 +116,11 @@ public class GameRuleProvider { protected GameMode gameMode; protected Boolean breakBlocks; protected Boolean breakPlacedBlocks; - protected Map> breakWhitelist; + protected Map> breakWhitelist; protected Set damageProtectedEntities; protected Set interactionProtectedEntities; protected Boolean placeBlocks; - protected Set placeWhitelist; + protected Set placeWhitelist; protected Boolean rain; protected Boolean thunder; protected Long time; @@ -164,7 +163,7 @@ public class GameRuleProvider { /* Misc */ protected Map msgs; - protected List secureObjects; + protected List secureObjects; protected Boolean groupTagEnabled; /* Getters and setters */ @@ -229,7 +228,7 @@ public class GameRuleProvider { /** * @return the destroyable materials and the materials that may be used to break them or null if any */ - public Map> getBreakWhitelist() { + public Map> getBreakWhitelist() { return breakWhitelist; } @@ -257,7 +256,7 @@ public class GameRuleProvider { /** * @return the placeable materials */ - public Set getPlaceWhitelist() { + public Set getPlaceWhitelist() { return placeWhitelist; } @@ -615,7 +614,7 @@ public class GameRuleProvider { /** * @return the objects to get passed to another player of the group when this player leaves */ - public List getSecureObjects() { + public List getSecureObjects() { if (secureObjects == null) { secureObjects = new ArrayList<>(); } diff --git a/src/main/java/de/erethon/dungeonsxl/global/DPortal.java b/src/main/java/de/erethon/dungeonsxl/global/DPortal.java index 7663641d..b5ae2ca6 100644 --- a/src/main/java/de/erethon/dungeonsxl/global/DPortal.java +++ b/src/main/java/de/erethon/dungeonsxl/global/DPortal.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.global; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.misc.BlockUtil; import de.erethon.dungeonsxl.DungeonsXL; @@ -267,7 +268,7 @@ public class DPortal extends GlobalProtection { configFile.set(preString + ".loc2.y", block2.getY()); configFile.set(preString + ".loc2.z", block2.getZ()); - configFile.set(preString + ".material", material.toString()); + configFile.set(preString + ".material", VanillaItem.get(material).getId()); if (material == Material.PORTAL) { configFile.set(preString + ".axis", axis == 2 ? "z" : "x"); } diff --git a/src/main/java/de/erethon/dungeonsxl/global/GameSign.java b/src/main/java/de/erethon/dungeonsxl/global/GameSign.java index 4de72344..4fa4297f 100644 --- a/src/main/java/de/erethon/dungeonsxl/global/GameSign.java +++ b/src/main/java/de/erethon/dungeonsxl/global/GameSign.java @@ -16,6 +16,8 @@ */ package de.erethon.dungeonsxl.global; +import de.erethon.caliburn.category.Category; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.misc.BlockUtil; import de.erethon.dungeonsxl.DungeonsXL; @@ -23,7 +25,6 @@ import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.dungeon.Dungeon; import de.erethon.dungeonsxl.game.Game; import de.erethon.dungeonsxl.player.DGroup; -import de.erethon.dungeonsxl.util.LegacyUtil; import de.erethon.dungeonsxl.world.DResourceWorld; import java.util.HashSet; import java.util.Set; @@ -235,7 +236,7 @@ public class GameSign extends GlobalProtection { * a block which is protected by the returned GameSign */ public static GameSign getByBlock(Block block) { - if (!LegacyUtil.isSign(block)) { + if (!Category.SIGNS.containsBlock(block)) { return null; } diff --git a/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionCache.java b/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionCache.java index c942abf4..a6f9a8e1 100644 --- a/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionCache.java +++ b/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionCache.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.global; +import de.erethon.caliburn.item.ExItem; import de.erethon.dungeonsxl.DungeonsXL; import java.io.File; import java.util.HashSet; @@ -234,9 +235,9 @@ public class GlobalProtectionCache { if (data.contains(preString)) { Block block1 = world.getBlockAt(data.getInt(preString + "loc1.x"), data.getInt(preString + "loc1.y"), data.getInt(preString + "loc1.z")); Block block2 = world.getBlockAt(data.getInt(preString + "loc2.x"), data.getInt(preString + "loc2.y"), data.getInt(preString + "loc2.z")); - Material material = Material.getMaterial(data.getString(preString + "material")); + ExItem material = plugin.getCaliburn().getExItem(data.getString(preString + "material")); String axis = data.getString(preString + "axis"); - DPortal dPortal = new DPortal(id, block1, block2, material != null ? material : Material.PORTAL, (byte) (axis != null && axis.equals("z") ? 2 : 1), true); + DPortal dPortal = new DPortal(id, block1, block2, material != null ? material.getMaterial() : Material.PORTAL, (byte) (axis != null && axis.equals("z") ? 2 : 1), true); dPortal.create(null); } diff --git a/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionListener.java b/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionListener.java index 9b506949..b07ee709 100644 --- a/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionListener.java +++ b/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionListener.java @@ -16,12 +16,13 @@ */ package de.erethon.dungeonsxl.global; +import de.erethon.caliburn.category.Category; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.player.DGlobalPlayer; import de.erethon.dungeonsxl.player.DPermission; -import de.erethon.dungeonsxl.util.LegacyUtil; import de.erethon.dungeonsxl.world.DEditWorld; import java.util.List; import org.bukkit.block.Block; @@ -62,7 +63,7 @@ public class GlobalProtectionListener implements Listener { } //return if above block is not a sign - if (!LegacyUtil.isSign(blockAbove)) { + if (!Category.SIGNS.containsBlock(blockAbove)) { return; } @@ -166,7 +167,7 @@ public class GlobalProtectionListener implements Listener { } ItemStack item = event.getItem(); Block block = event.getClickedBlock(); - if (item == null || item.getType() != LegacyUtil.WOODEN_SWORD || block == null) { + if (item == null || !VanillaItem.WOODEN_SWORD.is(item) || block == null) { return; } @@ -205,7 +206,7 @@ public class GlobalProtectionListener implements Listener { return; } - if (LegacyUtil.isSign(clickedBlock)) { + if (!Category.SIGNS.containsBlock(clickedBlock)) { // Check Group Signs if (GroupSign.playerInteract(clickedBlock, player)) { event.setCancelled(true); diff --git a/src/main/java/de/erethon/dungeonsxl/global/GroupSign.java b/src/main/java/de/erethon/dungeonsxl/global/GroupSign.java index 6eb7eb4d..3131ed09 100644 --- a/src/main/java/de/erethon/dungeonsxl/global/GroupSign.java +++ b/src/main/java/de/erethon/dungeonsxl/global/GroupSign.java @@ -16,13 +16,14 @@ */ package de.erethon.dungeonsxl.global; +import de.erethon.caliburn.category.Category; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.misc.BlockUtil; import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.dungeon.Dungeon; import de.erethon.dungeonsxl.player.DGroup; -import de.erethon.dungeonsxl.util.LegacyUtil; import de.erethon.dungeonsxl.world.DResourceWorld; import java.util.HashSet; import java.util.Set; @@ -234,7 +235,7 @@ public class GroupSign extends GlobalProtection { * a block which is protected by the returned GroupSign */ public static GroupSign getByBlock(Block block) { - if (!LegacyUtil.isSign(block)) { + if (!Category.SIGNS.containsBlock(block)) { return null; } diff --git a/src/main/java/de/erethon/dungeonsxl/loottable/DLootTable.java b/src/main/java/de/erethon/dungeonsxl/loottable/DLootTable.java deleted file mode 100644 index 2f0f52a2..00000000 --- a/src/main/java/de/erethon/dungeonsxl/loottable/DLootTable.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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 . - */ -package de.erethon.dungeonsxl.loottable; - -import io.github.dre2n.caliburn.item.UniversalItemStack; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.inventory.ItemStack; - -/** - * A loot table for rewards and mob drops. - * - * @author Daniel Saukel - */ -public class DLootTable { - - public class Entry { - - private String id; - private ItemStack item; - private double chance; - - public Entry(String id, ItemStack item, double chance) { - this.id = id; - this.item = item; - this.chance = chance; - } - - /* Getters and setters */ - /** - * @return the id of the loot table entry - */ - public String getId() { - return id; - } - - /** - * @param id - * the id of the loot table entry to set - */ - public void setId(String id) { - this.id = id; - } - - /** - * @return the loot item stack - */ - public ItemStack getLootItem() { - return item; - } - - /** - * @param item - * the loot item to set - */ - public void setLootItem(ItemStack item) { - this.item = item; - } - - /** - * @return the loot chance - */ - public double getLootChance() { - return chance; - } - - /** - * @param chance - * the loot chance to set - */ - public void setLootChance(double chance) { - this.chance = chance; - } - - } - - private String name; - private List entries = new ArrayList<>(); - - /** - * @param file - * the script file - */ - public DLootTable(File file) { - this(file.getName().substring(0, file.getName().length() - 4), YamlConfiguration.loadConfiguration(file)); - } - - /** - * @param name - * the name of the loot table - * @param config - * the config that stores the information - */ - public DLootTable(String name, FileConfiguration config) { - this.name = name; - - for (String id : config.getKeys(true)) { - ItemStack item = null; - Object itemObj = config.get(id + ".item"); - if (itemObj instanceof ItemStack) { - item = (ItemStack) itemObj; - } else if (itemObj instanceof UniversalItemStack) { - item = ((UniversalItemStack) itemObj).toItemStack(); - } else if (itemObj instanceof String) { - item = UniversalItemStack.deserializeSimple((String) itemObj).toItemStack(); - } - - double chance = config.getDouble(id + ".chance"); - entries.add(new Entry(id, item, chance)); - } - } - - /* Getters and setters */ - /** - * @return the name of the loot table - */ - public String getName() { - return name; - } - - /** - * @return the entries - */ - public List getEntries() { - return entries; - } - - /** - * @param entry - * the entry to add - */ - public void addEntry(Entry entry) { - entries.add(entry); - } - - /** - * @param entry - * the entry to remove - */ - public void removeEntry(Entry entry) { - entries.remove(entry); - } - - /* Actions */ - /** - * Adds loot to a list randomly based on the chance value - * - * @return a list of the loot - */ - public List generateLootList() { - List lootList = new ArrayList<>(); - for (Entry entry : entries) { - if (new Random().nextInt(100) < entry.getLootChance()) { - lootList.add(entry.getLootItem()); - } - } - return lootList; - } - -} diff --git a/src/main/java/de/erethon/dungeonsxl/loottable/DLootTableCache.java b/src/main/java/de/erethon/dungeonsxl/loottable/DLootTableCache.java deleted file mode 100644 index 2b28a084..00000000 --- a/src/main/java/de/erethon/dungeonsxl/loottable/DLootTableCache.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 . - */ -package de.erethon.dungeonsxl.loottable; - -import de.erethon.commons.misc.FileUtil; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * DLootTable instance manager. - * - * @author Daniel Saukel - */ -public class DLootTableCache { - - private List lootTables = new ArrayList<>(); - - public DLootTableCache(File file) { - if (file.isDirectory()) { - for (File script : FileUtil.getFilesForFolder(file)) { - lootTables.add(new DLootTable(script)); - } - } - } - - /** - * @return the loot table that has the name - */ - public DLootTable getByName(String name) { - for (DLootTable lootTable : lootTables) { - if (lootTable.getName().equalsIgnoreCase(name)) { - return lootTable; - } - } - - return null; - } - - /** - * @return the loot tables - */ - public List getDLootTables() { - return lootTables; - } - - /** - * @param lootTable - * the DLootTable to add - */ - public void addDLootTable(DLootTable lootTable) { - lootTables.add(lootTable); - } - - /** - * @param lootTable - * the DLootTable to remove - */ - public void removeDLootTable(DLootTable lootTable) { - lootTables.remove(lootTable); - } - -} diff --git a/src/main/java/de/erethon/dungeonsxl/mob/CitizensMobProvider.java b/src/main/java/de/erethon/dungeonsxl/mob/CitizensMobProvider.java index bed5103b..2ecebb03 100644 --- a/src/main/java/de/erethon/dungeonsxl/mob/CitizensMobProvider.java +++ b/src/main/java/de/erethon/dungeonsxl/mob/CitizensMobProvider.java @@ -99,7 +99,7 @@ public class CitizensMobProvider implements ExternalMobProvider, Listener { spawnedNPCs.add(npc); DGameWorld gameWorld = DGameWorld.getByWorld(location.getWorld()); - new DMob((LivingEntity) npc.getEntity(), gameWorld, null, mob); + new DMob((LivingEntity) npc.getEntity(), gameWorld, mob); } } diff --git a/src/main/java/de/erethon/dungeonsxl/mob/DMob.java b/src/main/java/de/erethon/dungeonsxl/mob/DMob.java index 95b41c5b..b1f3eac8 100644 --- a/src/main/java/de/erethon/dungeonsxl/mob/DMob.java +++ b/src/main/java/de/erethon/dungeonsxl/mob/DMob.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.mob; +import de.erethon.caliburn.mob.ExMob; import de.erethon.dungeonsxl.event.dmob.DMobDeathEvent; import de.erethon.dungeonsxl.event.dmob.DMobSpawnEvent; import de.erethon.dungeonsxl.game.Game; @@ -37,15 +38,14 @@ public class DMob { // Variables private LivingEntity entity; - private DMobType type; + private ExMob type; private String trigger; - public DMob(LivingEntity entity, DGameWorld gameWorld, DMobType type) { + public DMob(LivingEntity entity, DGameWorld gameWorld) { gameWorld.addDMob(this); this.entity = entity; - this.type = type; /* Remove DropChance of equipment */ if (!isExternalMob()) { @@ -64,7 +64,17 @@ public class DMob { } } - public DMob(LivingEntity entity, DGameWorld gameWorld, DMobType type, String trigger) { + public DMob(LivingEntity entity, DGameWorld gameWorld, String trigger) { + this(entity, gameWorld); + this.trigger = trigger; + } + + public DMob(LivingEntity entity, DGameWorld gameWorld, ExMob type) { + this(entity, gameWorld); + this.type = type; + } + + public DMob(LivingEntity entity, DGameWorld gameWorld, ExMob type, String trigger) { this(entity, gameWorld, type); this.trigger = trigger; } @@ -80,7 +90,7 @@ public class DMob { /** * @return the DMobType or null if the mob is an external mob */ - public DMobType getType() { + public ExMob getType() { return type; } @@ -115,14 +125,14 @@ public class DMob { return; } - if (type != null) { + if (type instanceof DMobType) { event.getDrops().clear(); - for (ItemStack itemStack : type.getDrops().keySet()) { + for (ItemStack itemStack : ((DMobType) type).getDrops().keySet()) { Random randomGenerator = new Random(); int random = randomGenerator.nextInt(100); - if (type.getDrops().get(itemStack) > random) { + if (((DMobType) type).getDrops().get(itemStack) > random) { event.getDrops().add(itemStack); } } diff --git a/src/main/java/de/erethon/dungeonsxl/mob/DMobType.java b/src/main/java/de/erethon/dungeonsxl/mob/DMobType.java index 2c77ea67..8ccb0183 100644 --- a/src/main/java/de/erethon/dungeonsxl/mob/DMobType.java +++ b/src/main/java/de/erethon/dungeonsxl/mob/DMobType.java @@ -16,11 +16,13 @@ */ package de.erethon.dungeonsxl.mob; +import de.erethon.caliburn.CaliburnAPI; +import de.erethon.caliburn.item.ExItem; +import de.erethon.caliburn.mob.ExMob; import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.misc.EnumUtil; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.config.DMessage; -import de.erethon.dungeonsxl.util.LegacyUtil; import de.erethon.dungeonsxl.world.DGameWorld; import java.io.File; import java.util.Arrays; @@ -28,11 +30,12 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; import org.bukkit.Location; -import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Ocelot; @@ -44,7 +47,10 @@ import org.bukkit.inventory.meta.ItemMeta; /** * @author Frank Baumann, Milan Albrecht, Daniel Saukel */ -public class DMobType { +@Deprecated +public class DMobType extends ExMob { + + CaliburnAPI caliburn = CaliburnAPI.getInstance(); private String name; private EntityType type; @@ -89,34 +95,35 @@ public class DMobType { } // Load Items - if (config.contains("itemHelmet")) { - itemHelmet = new ItemStack(LegacyUtil.getMaterial(config.getInt("itemHelmet"))); + ExItem itemHelmet = caliburn.deserializeExItem(config, "itemHelmet"); + if (itemHelmet != null) { + this.itemHelmet = itemHelmet.toItemStack(); } - if (config.contains("itemChestplate")) { - itemChestplate = new ItemStack(LegacyUtil.getMaterial(config.getInt("itemChestplate"))); + ExItem itemChestplate = caliburn.deserializeExItem(config, "itemChestplate"); + if (itemChestplate != null) { + this.itemChestplate = itemChestplate.toItemStack(); } - if (config.contains("itemBoots")) { - itemBoots = new ItemStack(LegacyUtil.getMaterial(config.getInt("itemBoots"))); + ExItem itemBoots = caliburn.deserializeExItem(config, "itemBoots"); + if (itemBoots != null) { + this.itemBoots = itemBoots.toItemStack(); } - if (config.contains("itemLeggings")) { - itemLeggings = new ItemStack(LegacyUtil.getMaterial(config.getInt("itemLeggings"))); + ExItem itemLeggings = caliburn.deserializeExItem(config, "itemLeggings"); + if (itemLeggings != null) { + this.itemLeggings = itemLeggings.toItemStack(); } - if (config.contains("itemHand")) { - itemHand = new ItemStack(LegacyUtil.getMaterial(config.getInt("itemHand"))); + ExItem itemHand = caliburn.deserializeExItem(config, "itemHand"); + if (itemHand != null) { + this.itemHand = itemHand.toItemStack(); } // Load different Mob options - if (config.contains("isWitherSkeleton")) { - witherSkeleton = config.getBoolean("isWitherSkeleton"); - } + witherSkeleton = config.getBoolean("isWitherSkeleton", false); - if (config.contains("ocelotType")) { - ocelotType = config.getString("ocelotType"); - } + ocelotType = config.getString("ocelotType", null); // Drops ConfigurationSection configSetion = config.getConfigurationSection("drops"); @@ -128,7 +135,7 @@ public class DMobType { int chance = 100; /* Item Stack */ - Material mat = LegacyUtil.getMaterial(configSetion.getInt(dropPath + ".id")); + ExItem mat = caliburn.deserializeExItem(configSetion, dropPath + ".id"); int amount = 1; short data = 0; @@ -139,7 +146,8 @@ public class DMobType { data = Short.parseShort(configSetion.getString(dropPath + ".data")); } - item = new ItemStack(mat, amount, data); + item = mat.toItemStack(amount); + item.setDurability(data); itemMeta = item.getItemMeta(); /* Enchantments */ @@ -359,16 +367,14 @@ public class DMobType { } /* Actions */ - public void spawn(DGameWorld gameWorld, Location loc) { - if (type == null) { - return; + @Override + public Entity toEntity(Location loc) { + World world = loc.getWorld(); + DGameWorld gameWorld = DGameWorld.getByWorld(world); + if (gameWorld == null) { + return null; } - - if (!type.isAlive()) { - return; - } - - LivingEntity entity = (LivingEntity) gameWorld.getWorld().spawnEntity(loc, type); + LivingEntity entity = (LivingEntity) world.spawnEntity(loc, type); /* Set the Items */ entity.getEquipment().setItemInHand(itemHand); @@ -404,6 +410,7 @@ public class DMobType { /* Spawn Mob */ new DMob(entity, gameWorld, this); + return entity; } } diff --git a/src/main/java/de/erethon/dungeonsxl/mob/DMobTypeCache.java b/src/main/java/de/erethon/dungeonsxl/mob/DMobTypeCache.java deleted file mode 100644 index 9f6fb512..00000000 --- a/src/main/java/de/erethon/dungeonsxl/mob/DMobTypeCache.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 . - */ -package de.erethon.dungeonsxl.mob; - -import de.erethon.commons.misc.FileUtil; -import de.erethon.dungeonsxl.DungeonsXL; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import org.bukkit.Bukkit; - -/** - * @author Daniel Saukel - */ -public class DMobTypeCache { - - private List dMobTypes = new ArrayList<>(); - - public DMobTypeCache(File file) { - if (file.isDirectory()) { - for (File script : FileUtil.getFilesForFolder(file)) { - dMobTypes.add(new DMobType(script)); - } - } - Bukkit.getPluginManager().registerEvents(new DMobListener(), DungeonsXL.getInstance()); - } - - /** - * @return the dMobType that has the name - */ - public DMobType getByName(String name) { - for (DMobType dMobType : dMobTypes) { - if (dMobType.getName().equalsIgnoreCase(name)) { - return dMobType; - } - } - - return null; - } - - /** - * @return the dMobTypes - */ - public List getDMobTypes() { - return dMobTypes; - } - - /** - * @param dMobType - * the DMobType to add - */ - public void addDMobType(DMobType dMobType) { - dMobTypes.add(dMobType); - } - - /** - * @param dMobType - * the DMobType to remove - */ - public void removeDMobType(DMobType dMobType) { - dMobTypes.remove(dMobType); - } - -} diff --git a/src/main/java/de/erethon/dungeonsxl/player/DClass.java b/src/main/java/de/erethon/dungeonsxl/player/DClass.java index 63a10295..a1bb0498 100644 --- a/src/main/java/de/erethon/dungeonsxl/player/DClass.java +++ b/src/main/java/de/erethon/dungeonsxl/player/DClass.java @@ -16,10 +16,8 @@ */ package de.erethon.dungeonsxl.player; +import de.erethon.caliburn.CaliburnAPI; import de.erethon.commons.compatibility.CompatibilityHandler; -import de.erethon.commons.compatibility.Version; -import de.erethon.dungeonsxl.util.DeserializationUtil; -import io.github.dre2n.caliburn.item.UniversalItemStack; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -34,6 +32,7 @@ import org.bukkit.inventory.ItemStack; */ public class DClass { + CaliburnAPI caliburn = CaliburnAPI.getInstance(); CompatibilityHandler compat = CompatibilityHandler.getInstance(); private String name; @@ -49,11 +48,7 @@ public class DClass { this.name = name; if (config.contains("items")) { - if (Version.andHigher(Version.MC1_9).contains(compat.getVersion())) { - items = UniversalItemStack.deserializeList(config.getList("items")); - } else { - items = DeserializationUtil.deserializeStackList(config.getStringList("items")); - } + items = caliburn.deserializeStackList(config, "items"); } if (config.contains("dog")) { diff --git a/src/main/java/de/erethon/dungeonsxl/player/DGamePlayer.java b/src/main/java/de/erethon/dungeonsxl/player/DGamePlayer.java index 2bbc7282..ddb69012 100644 --- a/src/main/java/de/erethon/dungeonsxl/player/DGamePlayer.java +++ b/src/main/java/de/erethon/dungeonsxl/player/DGamePlayer.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.player; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.player.PlayerUtil; import de.erethon.dungeonsxl.DungeonsXL; @@ -35,7 +36,6 @@ import de.erethon.dungeonsxl.mob.DMob; import de.erethon.dungeonsxl.requirement.Requirement; import de.erethon.dungeonsxl.reward.Reward; import de.erethon.dungeonsxl.trigger.DistanceTrigger; -import de.erethon.dungeonsxl.util.LegacyUtil; import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.DResourceWorld; import de.erethon.dungeonsxl.world.block.TeamFlag; @@ -45,7 +45,6 @@ import java.util.List; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.entity.Damageable; import org.bukkit.entity.EntityType; @@ -260,7 +259,7 @@ public class DGamePlayer extends DInstancePlayer { /* Delete Inventory */ getPlayer().getInventory().clear(); getPlayer().getInventory().setArmorContents(null); - getPlayer().getInventory().setItemInHand(new ItemStack(Material.AIR)); + getPlayer().getInventory().setItemInHand(VanillaItem.AIR.toItemStack()); // Remove Potion Effects for (PotionEffect effect : getPlayer().getActivePotionEffects()) { @@ -275,20 +274,20 @@ public class DGamePlayer extends DInstancePlayer { for (ItemStack istack : dClass.getItems()) { // Leggings - if (istack.getType() == Material.LEATHER_LEGGINGS || istack.getType() == Material.CHAINMAIL_LEGGINGS || istack.getType() == Material.IRON_LEGGINGS - || istack.getType() == Material.DIAMOND_LEGGINGS || istack.getType() == LegacyUtil.GOLDEN_LEGGINGS) { + if (VanillaItem.LEATHER_LEGGINGS.is(istack) || VanillaItem.CHAINMAIL_LEGGINGS.is(istack) || VanillaItem.IRON_LEGGINGS.is(istack) + || VanillaItem.DIAMOND_LEGGINGS.is(istack) || VanillaItem.GOLDEN_LEGGINGS.is(istack)) { getPlayer().getInventory().setLeggings(istack); } // 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() == LegacyUtil.GOLDEN_HELMET) { + else if (VanillaItem.LEATHER_HELMET.is(istack) || VanillaItem.CHAINMAIL_HELMET.is(istack) || VanillaItem.IRON_HELMET.is(istack) + || VanillaItem.DIAMOND_HELMET.is(istack) || VanillaItem.GOLDEN_HELMET.is(istack)) { getPlayer().getInventory().setHelmet(istack); } // 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() == LegacyUtil.GOLDEN_CESTPLATE) { + else if (VanillaItem.LEATHER_CHESTPLATE.is(istack) || VanillaItem.CHAINMAIL_CHESTPLATE.is(istack) || VanillaItem.IRON_CHESTPLATE.is(istack) + || VanillaItem.DIAMOND_CHESTPLATE.is(istack) || VanillaItem.GOLDEN_CHESTPLATE.is(istack)) { getPlayer().getInventory().setChestplate(istack); } // 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() == LegacyUtil.GOLDEN_BOOTS) { + else if (VanillaItem.LEATHER_BOOTS.is(istack) || VanillaItem.CHAINMAIL_BOOTS.is(istack) || VanillaItem.IRON_BOOTS.is(istack) + || VanillaItem.DIAMOND_BOOTS.is(istack) || VanillaItem.GOLDEN_BOOTS.is(istack)) { getPlayer().getInventory().setBoots(istack); } else { getPlayer().getInventory().addItem(istack); @@ -407,7 +406,7 @@ public class DGamePlayer extends DInstancePlayer { public void setRobbedGroup(DGroup dGroup) { if (dGroup != null) { oldHelmet = player.getInventory().getHelmet(); - player.getInventory().setHelmet(LegacyUtil.createColoredWool(getDGroup().getDColor())); + player.getInventory().setHelmet(getDGroup().getDColor().getWoolMaterial().toItemStack()); } stealing = dGroup; @@ -860,7 +859,7 @@ public class DGamePlayer extends DInstancePlayer { setRespawnArmor(event.getEntity().getInventory().getArmorContents()); // Delete all drops for (ItemStack item : event.getDrops()) { - item.setType(Material.AIR); + item.setType(VanillaItem.AIR.getMaterial()); } } diff --git a/src/main/java/de/erethon/dungeonsxl/player/DGroupTag.java b/src/main/java/de/erethon/dungeonsxl/player/DGroupTag.java index bc6b1ca0..21583098 100644 --- a/src/main/java/de/erethon/dungeonsxl/player/DGroupTag.java +++ b/src/main/java/de/erethon/dungeonsxl/player/DGroupTag.java @@ -19,7 +19,6 @@ package de.erethon.dungeonsxl.player; import com.gmail.filoghost.holographicdisplays.api.Hologram; import com.gmail.filoghost.holographicdisplays.api.HologramsAPI; import de.erethon.dungeonsxl.DungeonsXL; -import de.erethon.dungeonsxl.util.LegacyUtil; /** * @author Daniel Saukel @@ -34,7 +33,7 @@ public class DGroupTag { DGroup group = player.getDGroup(); if (group != null) { hologram = HologramsAPI.createHologram(DungeonsXL.getInstance(), player.getPlayer().getLocation().clone().add(0, 3.5, 0)); - hologram.appendItemLine(LegacyUtil.createColoredWool(group.getDColor())); + hologram.appendItemLine(group.getDColor().getWoolMaterial().toItemStack()); hologram.appendTextLine(group.getName()); } } diff --git a/src/main/java/de/erethon/dungeonsxl/player/DPlayerListener.java b/src/main/java/de/erethon/dungeonsxl/player/DPlayerListener.java index c488af32..2fe6c6a1 100644 --- a/src/main/java/de/erethon/dungeonsxl/player/DPlayerListener.java +++ b/src/main/java/de/erethon/dungeonsxl/player/DPlayerListener.java @@ -16,6 +16,9 @@ */ package de.erethon.dungeonsxl.player; +import de.erethon.caliburn.category.Category; +import de.erethon.caliburn.item.ExItem; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.config.DMessage; @@ -23,14 +26,12 @@ import de.erethon.dungeonsxl.config.MainConfig; import de.erethon.dungeonsxl.game.Game; import de.erethon.dungeonsxl.mob.DMob; import de.erethon.dungeonsxl.trigger.UseItemTrigger; -import de.erethon.dungeonsxl.util.LegacyUtil; import de.erethon.dungeonsxl.util.ParsingUtil; import de.erethon.dungeonsxl.world.DEditWorld; import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.block.LockedDoor; import java.util.ArrayList; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Entity; @@ -346,8 +347,8 @@ public class DPlayerListener implements Listener { Game game = Game.getByWorld(gamePlayer.getWorld()); - for (ItemStack item : game.getRules().getSecureObjects()) { - if (event.getItemDrop().getItemStack().isSimilar(item)) { + for (ExItem item : game.getRules().getSecureObjects()) { + if (event.getItemDrop().getItemStack().isSimilar(item.toItemStack())) { event.setCancelled(true); MessageUtil.sendMessage(player, DMessage.ERROR_DROP.getMessage()); return; @@ -551,13 +552,13 @@ public class DPlayerListener implements Listener { // Block Enderchests if (dGameWorld != null || DEditWorld.getByWorld(player.getWorld()) != null) { if (event.getAction() != Action.LEFT_CLICK_BLOCK) { - if (clickedBlock.getType() == Material.ENDER_CHEST) { + if (VanillaItem.ENDER_CHEST.is(clickedBlock)) { if (!DPermission.hasPermission(player, DPermission.BYPASS)) { MessageUtil.sendMessage(player, DMessage.ERROR_ENDERCHEST.getMessage()); event.setCancelled(true); } - } else if (LegacyUtil.isBed(clickedBlock.getType())) { + } else if (Category.BEDS.containsBlock(clickedBlock)) { if (!DPermission.hasPermission(player, DPermission.BYPASS)) { MessageUtil.sendMessage(player, DMessage.ERROR_BED.getMessage()); event.setCancelled(true); @@ -569,7 +570,7 @@ public class DPlayerListener implements Listener { // Block Dispensers if (dGameWorld != null) { if (event.getAction() != Action.LEFT_CLICK_BLOCK) { - if (clickedBlock.getType() == Material.DISPENSER) { + if (VanillaItem.DISPENSER.is(clickedBlock)) { if (!DPermission.hasPermission(player, DPermission.BYPASS)) { MessageUtil.sendMessage(player, DMessage.ERROR_DISPENSER.getMessage()); event.setCancelled(true); @@ -593,7 +594,7 @@ public class DPlayerListener implements Listener { // Copy/Paste a Sign and Block-info if (DEditWorld.getByWorld(player.getWorld()) != null) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { - if (item.getType() == Material.STICK) { + if (VanillaItem.STICK.is(item)) { DEditPlayer dPlayer = DEditPlayer.getByPlayer(player); if (dPlayer != null) { dPlayer.poke(clickedBlock); @@ -612,7 +613,7 @@ public class DPlayerListener implements Listener { if (item.getItemMeta().hasDisplayName()) { name = item.getItemMeta().getDisplayName(); - } else if (item.getType() == Material.WRITTEN_BOOK || item.getType() == LegacyUtil.WRITABLE_BOOK) { + } else if (VanillaItem.WRITTEN_BOOK.is(item) || VanillaItem.WRITABLE_BOOK.is(item)) { if (item.getItemMeta() instanceof BookMeta) { BookMeta meta = (BookMeta) item.getItemMeta(); if (meta.hasTitle()) { diff --git a/src/main/java/de/erethon/dungeonsxl/reward/RewardListener.java b/src/main/java/de/erethon/dungeonsxl/reward/RewardListener.java index fab240a6..1441b860 100644 --- a/src/main/java/de/erethon/dungeonsxl/reward/RewardListener.java +++ b/src/main/java/de/erethon/dungeonsxl/reward/RewardListener.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.reward; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.gui.PageGUI; import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.config.DMessage; @@ -24,8 +25,8 @@ import de.erethon.dungeonsxl.player.DPermission; import de.erethon.dungeonsxl.world.DEditWorld; import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.block.RewardChest; -import org.bukkit.Material; import org.bukkit.World; +import org.bukkit.block.Block; import org.bukkit.block.Chest; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -112,9 +113,10 @@ public class RewardListener implements Listener { if (plugin.getDWorlds().getInstanceByWorld(player.getWorld()) != null) { return; } - if (dPlayer.hasRewardItemsLeft() && player.getLocation().getBlock().getRelative(0, 1, 0).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(0, -1, 0).getType() != Material.PORTAL - && player.getLocation().getBlock().getRelative(1, 0, 0).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(-1, 0, 0).getType() != Material.PORTAL - && player.getLocation().getBlock().getRelative(0, 0, 1).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(0, 0, -1).getType() != Material.PORTAL) { + Block block = player.getLocation().getBlock(); + if (dPlayer.hasRewardItemsLeft() && !VanillaItem.PORTAL.is(block.getRelative(0, 1, 0)) && !VanillaItem.PORTAL.is(block.getRelative(0, -1, 0)) + && !VanillaItem.PORTAL.is(block.getRelative(1, 0, 0)) && !VanillaItem.PORTAL.is(block.getRelative(-1, 0, 0)) + && !VanillaItem.PORTAL.is(block.getRelative(0, 0, 1)) && !VanillaItem.PORTAL.is(block.getRelative(0, 0, -1))) { PageGUI lootInventory = new PageGUI(DMessage.PLAYER_TREASURES.getMessage(), true); for (ItemStack item : dPlayer.getRewardItems()) { if (item != null) { diff --git a/src/main/java/de/erethon/dungeonsxl/sign/BedSign.java b/src/main/java/de/erethon/dungeonsxl/sign/BedSign.java index 805267ef..47ed2b1f 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/BedSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/BedSign.java @@ -16,12 +16,12 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.category.Category; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.BlockUtil; import de.erethon.commons.misc.NumberUtil; -import de.erethon.dungeonsxl.util.LegacyUtil; import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.block.TeamBed; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Sign; @@ -55,11 +55,11 @@ public class BedSign extends DSign { this.team = NumberUtil.parseInt(lines[1]); Block block = BlockUtil.getAttachedBlock(getSign().getBlock()); - if (LegacyUtil.isBed(block.getType())) { + if (Category.BEDS.containsBlock(block)) { if (getGame().getDGroups().size() > team) { getGameWorld().addGameBlock(new TeamBed(block, getGame().getDGroups().get(team))); } - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } else { markAsErroneous(); } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/BossShopSign.java b/src/main/java/de/erethon/dungeonsxl/sign/BossShopSign.java index 2d841114..038c78c3 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/BossShopSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/BossShopSign.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.trigger.InteractTrigger; @@ -24,7 +25,6 @@ import org.black_ixx.bossshop.BossShop; import org.black_ixx.bossshop.core.BSShop; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -75,7 +75,7 @@ public class BossShopSign extends DSign { shopName = lines[1]; if (!getTriggers().isEmpty()) { - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); return; } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/CheckpointSign.java b/src/main/java/de/erethon/dungeonsxl/sign/CheckpointSign.java index b11034a9..b21dbec4 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/CheckpointSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/CheckpointSign.java @@ -16,12 +16,12 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.player.DGamePlayer; import de.erethon.dungeonsxl.world.DGameWorld; import java.util.concurrent.CopyOnWriteArrayList; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -47,7 +47,7 @@ public class CheckpointSign extends DSign { @Override public void onInit() { - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); initialized = true; } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/ChestSign.java b/src/main/java/de/erethon/dungeonsxl/sign/ChestSign.java index 8a18cb09..8c81cb99 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/ChestSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/ChestSign.java @@ -16,14 +16,15 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.category.Category; +import de.erethon.caliburn.item.VanillaItem; +import de.erethon.caliburn.loottable.LootTable; import de.erethon.commons.misc.NumberUtil; -import de.erethon.dungeonsxl.loottable.DLootTable; import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.block.RewardChest; import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Chest; import org.bukkit.block.Sign; @@ -41,7 +42,7 @@ public class ChestSign extends DSign { private double moneyReward; private int levelReward; private ItemStack[] chestContent; - private DLootTable lootTable; + private LootTable lootTable; public ChestSign(Sign sign, String[] lines, DGameWorld gameWorld) { super(sign, lines, gameWorld); @@ -99,7 +100,7 @@ public class ChestSign extends DSign { /** * @return the custom loot table */ - public DLootTable getLootTable() { + public LootTable getLootTable() { return lootTable; } @@ -107,7 +108,7 @@ public class ChestSign extends DSign { * @param lootTable * the loot table to set */ - public void setLootTable(DLootTable lootTable) { + public void setLootTable(LootTable lootTable) { this.lootTable = lootTable; } @@ -127,19 +128,19 @@ public class ChestSign extends DSign { Block yRelative = sign.getRelative(0, i, 0); Block zRelative = sign.getRelative(0, 0, i); - if (xRelative.getType() == Material.CHEST) { + if (Category.CHESTS.containsBlock(xRelative)) { if (chestContent == null) { chestContent = ((Chest) xRelative.getState()).getBlockInventory().getContents(); } chest = xRelative; - } else if (yRelative.getType() == Material.CHEST) { + } else if (Category.CHESTS.containsBlock(yRelative)) { if (chestContent == null) { chestContent = ((Chest) yRelative.getState()).getBlockInventory().getContents(); } chest = yRelative; - } else if (zRelative.getType() == Material.CHEST) { + } else if (Category.CHESTS.containsBlock(zRelative)) { if (chestContent == null) { chestContent = ((Chest) zRelative.getState()).getBlockInventory().getContents(); } @@ -166,7 +167,7 @@ public class ChestSign extends DSign { } if (!lines[2].isEmpty()) { - lootTable = plugin.getDLootTables().getByName(lines[2]); + lootTable = plugin.getCaliburn().getLootTable(lines[2]); } if (chest == null) { @@ -182,7 +183,7 @@ public class ChestSign extends DSign { } getGameWorld().addGameBlock(new RewardChest(chest, moneyReward, levelReward, itemReward)); - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } else { markAsErroneous(); diff --git a/src/main/java/de/erethon/dungeonsxl/sign/ChunkUpdaterSign.java b/src/main/java/de/erethon/dungeonsxl/sign/ChunkUpdaterSign.java index 06fb58f2..a3a2b1d9 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/ChunkUpdaterSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/ChunkUpdaterSign.java @@ -16,10 +16,10 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.world.DGameWorld; import org.bukkit.Chunk; -import org.bukkit.Material; import org.bukkit.block.Sign; /** @@ -57,7 +57,7 @@ public class ChunkUpdaterSign extends DSign { getGameWorld().getLoadedChunks().add(chunk); } - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } @Override diff --git a/src/main/java/de/erethon/dungeonsxl/sign/CommandSign.java b/src/main/java/de/erethon/dungeonsxl/sign/CommandSign.java index 2c1e7910..6c97482f 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/CommandSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/CommandSign.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.trigger.InteractTrigger; import de.erethon.dungeonsxl.world.DGameWorld; @@ -24,7 +25,6 @@ import io.github.dre2n.commandsxl.command.CCommand; import io.github.dre2n.commandsxl.command.CCommandExecutorTask; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -78,7 +78,7 @@ public class CommandSign extends DSign { cCommand = CommandsXL.getPlugin().getCCommands().getCCommand(command); if (!getTriggers().isEmpty()) { - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); return; } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/DropSign.java b/src/main/java/de/erethon/dungeonsxl/sign/DropSign.java index 5d88321d..c88f3675 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/DropSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/DropSign.java @@ -16,12 +16,11 @@ */ 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.world.DGameWorld; -import io.github.dre2n.caliburn.CaliburnAPI; -import io.github.dre2n.caliburn.item.UniversalItem; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; @@ -59,12 +58,12 @@ public class DropSign extends DSign { /* Actions */ @Override public boolean check() { - return CaliburnAPI.getInstance().getItems().getById(lines[1]) != null; + return plugin.getCaliburn().getExItem(lines[1]) != null; } @Override public void onInit() { - UniversalItem item = CaliburnAPI.getInstance().getItems().getById(lines[1]); + ExItem item = plugin.getCaliburn().getExItem(lines[1]); String[] attributes = lines[2].split(","); if (attributes.length >= 1) { @@ -74,7 +73,7 @@ public class DropSign extends DSign { interval = NumberUtil.parseDouble(attributes[1]); } - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } @Override diff --git a/src/main/java/de/erethon/dungeonsxl/sign/EndSign.java b/src/main/java/de/erethon/dungeonsxl/sign/EndSign.java index 817ea420..71495bf0 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/EndSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/EndSign.java @@ -16,12 +16,12 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.player.DGamePlayer; import de.erethon.dungeonsxl.trigger.InteractTrigger; import de.erethon.dungeonsxl.world.DGameWorld; import org.bukkit.ChatColor; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -44,7 +44,7 @@ public class EndSign extends DSign { @Override public void onInit() { if (!getTriggers().isEmpty()) { - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); return; } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/FloorSign.java b/src/main/java/de/erethon/dungeonsxl/sign/FloorSign.java index 1ad09892..13b56e00 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/FloorSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/FloorSign.java @@ -16,13 +16,13 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.player.DGamePlayer; import de.erethon.dungeonsxl.trigger.InteractTrigger; import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.DResourceWorld; import org.bukkit.ChatColor; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -66,7 +66,7 @@ public class FloorSign extends DSign { } if (!getTriggers().isEmpty()) { - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); return; } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/LeaveSign.java b/src/main/java/de/erethon/dungeonsxl/sign/LeaveSign.java index bb9fd64c..0cc01fcd 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/LeaveSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/LeaveSign.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.event.dplayer.instance.game.DGamePlayerEscapeEvent; import de.erethon.dungeonsxl.player.DGamePlayer; @@ -23,7 +24,6 @@ import de.erethon.dungeonsxl.trigger.InteractTrigger; import de.erethon.dungeonsxl.world.DGameWorld; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -46,7 +46,7 @@ public class LeaveSign extends DSign { @Override public void onInit() { if (!getTriggers().isEmpty()) { - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); return; } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/LivesModifierSign.java b/src/main/java/de/erethon/dungeonsxl/sign/LivesModifierSign.java index 17cefbff..225413e1 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/LivesModifierSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/LivesModifierSign.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.misc.EnumUtil; import de.erethon.commons.misc.NumberUtil; @@ -24,7 +25,6 @@ import de.erethon.dungeonsxl.game.Game; import de.erethon.dungeonsxl.player.DGamePlayer; import de.erethon.dungeonsxl.player.DGroup; import de.erethon.dungeonsxl.world.DGameWorld; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -77,7 +77,7 @@ public class LivesModifierSign extends DSign { target = Target.valueOf(lines[2].toUpperCase()); } - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } @Override diff --git a/src/main/java/de/erethon/dungeonsxl/sign/OpenDoorSign.java b/src/main/java/de/erethon/dungeonsxl/sign/OpenDoorSign.java index 539ad081..f090316a 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/OpenDoorSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/OpenDoorSign.java @@ -16,10 +16,10 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.BlockUtil; import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.block.LockedDoor; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; @@ -92,7 +92,7 @@ public class OpenDoorSign extends DSign { } getGameWorld().addGameBlock(door); - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } else { markAsErroneous(); diff --git a/src/main/java/de/erethon/dungeonsxl/sign/PlaceSign.java b/src/main/java/de/erethon/dungeonsxl/sign/PlaceSign.java index 04faa56e..8c552217 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/PlaceSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/PlaceSign.java @@ -16,9 +16,9 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.block.PlaceableBlock; -import org.bukkit.Material; import org.bukkit.block.Sign; /** @@ -40,7 +40,7 @@ public class PlaceSign extends DSign { @Override public void onInit() { getGameWorld().addGameBlock(new PlaceableBlock(getSign().getBlock(), lines[1], lines[2])); - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } @Override diff --git a/src/main/java/de/erethon/dungeonsxl/sign/ProtectionSign.java b/src/main/java/de/erethon/dungeonsxl/sign/ProtectionSign.java index 09f22d89..4f69bcb5 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/ProtectionSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/ProtectionSign.java @@ -16,10 +16,10 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.BlockUtil; import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.block.ProtectedBlock; -import org.bukkit.Material; import org.bukkit.block.Sign; /** @@ -48,7 +48,7 @@ public class ProtectionSign extends DSign { @Override public void onInit() { getGameWorld().addGameBlock(new ProtectedBlock(BlockUtil.getAttachedBlock(getSign().getBlock()))); - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/RedstoneSign.java b/src/main/java/de/erethon/dungeonsxl/sign/RedstoneSign.java index 4c24ff24..b94fdf50 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/RedstoneSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/RedstoneSign.java @@ -16,9 +16,9 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.world.DGameWorld; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Sign; import org.bukkit.scheduler.BukkitTask; @@ -215,7 +215,7 @@ public class RedstoneSign extends DSign { } block = getSign().getBlock(); - block.setType(Material.AIR); + block.setType(VanillaItem.AIR.getMaterial()); initialized = true; } @@ -260,11 +260,11 @@ public class RedstoneSign extends DSign { } public void power() { - block.setType(Material.REDSTONE_BLOCK); + block.setType(VanillaItem.REDSTONE_BLOCK.getMaterial()); } public void unpower() { - block.setType(Material.AIR); + block.setType(VanillaItem.AIR.getMaterial()); } @Override diff --git a/src/main/java/de/erethon/dungeonsxl/sign/ResourcePackSign.java b/src/main/java/de/erethon/dungeonsxl/sign/ResourcePackSign.java index 25536d40..d88c6c2f 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/ResourcePackSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/ResourcePackSign.java @@ -16,11 +16,11 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.trigger.InteractTrigger; import de.erethon.dungeonsxl.world.DGameWorld; import org.bukkit.ChatColor; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -83,7 +83,7 @@ public class ResourcePackSign extends DSign { } if (!getTriggers().isEmpty()) { - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); return; } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/ScriptSign.java b/src/main/java/de/erethon/dungeonsxl/sign/ScriptSign.java index cc3b348a..52ba0ff4 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/ScriptSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/ScriptSign.java @@ -16,8 +16,8 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.dungeonsxl.world.DGameWorld; -import org.bukkit.Material; import org.bukkit.block.Sign; /** @@ -59,7 +59,7 @@ public class ScriptSign extends DSign { } } - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } @Override diff --git a/src/main/java/de/erethon/dungeonsxl/sign/TeleportSign.java b/src/main/java/de/erethon/dungeonsxl/sign/TeleportSign.java index e274acc0..29176e29 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/TeleportSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/TeleportSign.java @@ -16,9 +16,9 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.world.DGameWorld; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -73,7 +73,7 @@ public class TeleportSign extends LocationSign { } } } - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } @Override diff --git a/src/main/java/de/erethon/dungeonsxl/sign/TriggerSign.java b/src/main/java/de/erethon/dungeonsxl/sign/TriggerSign.java index a90a1521..999c3b77 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/TriggerSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/TriggerSign.java @@ -16,13 +16,13 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.trigger.SignTrigger; import de.erethon.dungeonsxl.world.DEditWorld; import de.erethon.dungeonsxl.world.DGameWorld; import java.util.HashSet; import java.util.Set; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Sign; @@ -88,7 +88,7 @@ public class TriggerSign extends DSign { @Override public void onInit() { triggerId = NumberUtil.parseInt(getSign().getLine(1)); - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); initialized = true; } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/WaveSign.java b/src/main/java/de/erethon/dungeonsxl/sign/WaveSign.java index 5c84928a..a2022228 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/WaveSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/WaveSign.java @@ -16,12 +16,12 @@ */ package de.erethon.dungeonsxl.sign; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.trigger.InteractTrigger; import de.erethon.dungeonsxl.world.DGameWorld; import org.bukkit.ChatColor; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -85,7 +85,7 @@ public class WaveSign extends DSign { } if (!getTriggers().isEmpty()) { - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); return; } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/lobby/LobbySign.java b/src/main/java/de/erethon/dungeonsxl/sign/lobby/LobbySign.java index f67696a6..2877afc2 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/lobby/LobbySign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/lobby/LobbySign.java @@ -16,11 +16,11 @@ */ package de.erethon.dungeonsxl.sign.lobby; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.dungeonsxl.sign.DSignType; import de.erethon.dungeonsxl.sign.DSignTypeDefault; import de.erethon.dungeonsxl.sign.LocationSign; import de.erethon.dungeonsxl.world.DGameWorld; -import org.bukkit.Material; import org.bukkit.block.Sign; /** @@ -42,7 +42,7 @@ public class LobbySign extends LocationSign { @Override public void onInit() { getGameWorld().setLobbyLocation(getLocation()); - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } @Override diff --git a/src/main/java/de/erethon/dungeonsxl/sign/lobby/ReadySign.java b/src/main/java/de/erethon/dungeonsxl/sign/lobby/ReadySign.java index c03f8d41..67c4e6e0 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/lobby/ReadySign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/lobby/ReadySign.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.sign.lobby; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.config.DMessage; @@ -30,7 +31,6 @@ import de.erethon.dungeonsxl.trigger.InteractTrigger; import de.erethon.dungeonsxl.util.ProgressBar; import de.erethon.dungeonsxl.world.DGameWorld; import org.bukkit.ChatColor; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -99,7 +99,7 @@ public class ReadySign extends DSign { } if (!getTriggers().isEmpty()) { - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); return; } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/lobby/StartSign.java b/src/main/java/de/erethon/dungeonsxl/sign/lobby/StartSign.java index a0ac105f..1a139b64 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/lobby/StartSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/lobby/StartSign.java @@ -16,12 +16,12 @@ */ package de.erethon.dungeonsxl.sign.lobby; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.sign.DSignType; import de.erethon.dungeonsxl.sign.DSignTypeDefault; import de.erethon.dungeonsxl.sign.LocationSign; import de.erethon.dungeonsxl.world.DGameWorld; -import org.bukkit.Material; import org.bukkit.block.Sign; /** @@ -62,7 +62,7 @@ public class StartSign extends LocationSign { @Override public void onInit() { id = NumberUtil.parseInt(lines[1]); - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } @Override diff --git a/src/main/java/de/erethon/dungeonsxl/sign/message/ActionBarSign.java b/src/main/java/de/erethon/dungeonsxl/sign/message/ActionBarSign.java index cecd1fda..eb1491db 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/message/ActionBarSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/message/ActionBarSign.java @@ -16,12 +16,12 @@ */ package de.erethon.dungeonsxl.sign.message; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.dungeonsxl.sign.DSignType; import de.erethon.dungeonsxl.sign.DSignTypeDefault; import de.erethon.dungeonsxl.sign.PerPlayerSign; import de.erethon.dungeonsxl.world.DGameWorld; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -65,7 +65,7 @@ public class ActionBarSign extends PerPlayerSign { public void onInit() { text = lines[1]; text += lines[2]; - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } @Override diff --git a/src/main/java/de/erethon/dungeonsxl/sign/message/HologramSign.java b/src/main/java/de/erethon/dungeonsxl/sign/message/HologramSign.java index 33556eff..aef18e99 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/message/HologramSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/message/HologramSign.java @@ -18,21 +18,16 @@ package de.erethon.dungeonsxl.sign.message; import com.gmail.filoghost.holographicdisplays.api.Hologram; import com.gmail.filoghost.holographicdisplays.api.HologramsAPI; -import de.erethon.commons.compatibility.CompatibilityHandler; -import de.erethon.commons.compatibility.Version; -import de.erethon.commons.misc.EnumUtil; +import de.erethon.caliburn.item.ExItem; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.sign.DSign; import de.erethon.dungeonsxl.sign.DSignType; import de.erethon.dungeonsxl.sign.DSignTypeDefault; -import de.erethon.dungeonsxl.util.LegacyUtil; import de.erethon.dungeonsxl.world.DGameWorld; -import io.github.dre2n.caliburn.CaliburnAPI; -import io.github.dre2n.caliburn.item.UniversalItem; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.inventory.ItemStack; @@ -60,7 +55,7 @@ public class HologramSign extends DSign { markAsErroneous(); return; } - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); String[] holoLines = lines[1].split("/"); Location location = getSign().getLocation(); @@ -72,20 +67,9 @@ public class HologramSign extends DSign { String id = line.replace("Item:", ""); ItemStack item = null; - if (Version.andHigher(Version.MC1_9).contains(CompatibilityHandler.getInstance().getVersion())) { - UniversalItem universalItem = CaliburnAPI.getInstance().getItems().getById(id); - if (universalItem != null) { - item = universalItem.toItemStack(1); - } - } - - if (item == null) { - if (EnumUtil.isValidEnum(Material.class, id)) { - item = new ItemStack(Material.valueOf(id)); - - } else { - item = new ItemStack(LegacyUtil.getMaterial(NumberUtil.parseInt(id, 1))); - } + ExItem exItem = plugin.getCaliburn().getExItem(id); + if (exItem != null) { + item = exItem.toItemStack(); } hologram.appendItemLine(item); diff --git a/src/main/java/de/erethon/dungeonsxl/sign/message/MessageSign.java b/src/main/java/de/erethon/dungeonsxl/sign/message/MessageSign.java index c7987459..9f84ee64 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/message/MessageSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/message/MessageSign.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.sign.message; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.sign.DSign; @@ -23,7 +24,6 @@ import de.erethon.dungeonsxl.sign.DSignType; import de.erethon.dungeonsxl.sign.DSignTypeDefault; import de.erethon.dungeonsxl.world.DGameWorld; import java.util.concurrent.CopyOnWriteArrayList; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -61,7 +61,7 @@ public class MessageSign extends DSign { } } - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); initialized = true; } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/message/SoundMessageSign.java b/src/main/java/de/erethon/dungeonsxl/sign/message/SoundMessageSign.java index 0341bb9a..7ad87713 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/message/SoundMessageSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/message/SoundMessageSign.java @@ -16,6 +16,7 @@ */ 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; @@ -25,7 +26,6 @@ import de.erethon.dungeonsxl.sign.DSignType; import de.erethon.dungeonsxl.sign.DSignTypeDefault; import de.erethon.dungeonsxl.world.DGameWorld; import java.util.concurrent.CopyOnWriteArrayList; -import org.bukkit.Material; import org.bukkit.SoundCategory; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -78,7 +78,7 @@ public class SoundMessageSign extends DSign { pitch = (float) NumberUtil.parseDouble(args[2], 1.0); } } - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); initialized = true; } else { markAsErroneous(); diff --git a/src/main/java/de/erethon/dungeonsxl/sign/message/TitleSign.java b/src/main/java/de/erethon/dungeonsxl/sign/message/TitleSign.java index 0c3c0cb8..03454625 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/message/TitleSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/message/TitleSign.java @@ -16,12 +16,12 @@ */ package de.erethon.dungeonsxl.sign.message; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.dungeonsxl.sign.DSignType; import de.erethon.dungeonsxl.sign.DSignTypeDefault; import de.erethon.dungeonsxl.sign.PerPlayerSign; import de.erethon.dungeonsxl.world.DGameWorld; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -82,7 +82,7 @@ public class TitleSign extends PerPlayerSign { public void onInit() { title = lines[1]; subtitle = lines[2]; - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); } @Override diff --git a/src/main/java/de/erethon/dungeonsxl/sign/mob/DMobSign.java b/src/main/java/de/erethon/dungeonsxl/sign/mob/DMobSign.java index e130dacf..f5a7ba84 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/mob/DMobSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/mob/DMobSign.java @@ -16,12 +16,12 @@ */ package de.erethon.dungeonsxl.sign.mob; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.sign.DSign; import de.erethon.dungeonsxl.sign.DSignType; import de.erethon.dungeonsxl.sign.DSignTypeDefault; import de.erethon.dungeonsxl.world.DGameWorld; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.scheduler.BukkitTask; @@ -164,7 +164,7 @@ public class DMobSign extends DSign implements MobSign { } } } - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); initialized = true; } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/mob/ExternalMobSign.java b/src/main/java/de/erethon/dungeonsxl/sign/mob/ExternalMobSign.java index ecbf13f2..b34f4bf7 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/mob/ExternalMobSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/mob/ExternalMobSign.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.sign.mob; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.mob.ExternalMobPlugin; import de.erethon.dungeonsxl.mob.ExternalMobProvider; @@ -26,7 +27,6 @@ import de.erethon.dungeonsxl.world.DGameWorld; import java.util.ArrayList; import java.util.List; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -239,7 +239,7 @@ public class ExternalMobSign extends DSign implements MobSign { } } - getSign().getBlock().setType(Material.AIR); + getSign().getBlock().setType(VanillaItem.AIR.getMaterial()); initialized = true; } diff --git a/src/main/java/de/erethon/dungeonsxl/sign/mob/ExternalMobSpawnTask.java b/src/main/java/de/erethon/dungeonsxl/sign/mob/ExternalMobSpawnTask.java index 5a4d6673..39b48fd9 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/mob/ExternalMobSpawnTask.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/mob/ExternalMobSpawnTask.java @@ -48,7 +48,7 @@ public class ExternalMobSpawnTask extends BukkitRunnable { sign.setExternalMobs(); if (sign.getExternalMob() != null) { - new DMob(sign.getExternalMob(), sign.getGameWorld(), null, sign.getMob()); + new DMob(sign.getExternalMob(), sign.getGameWorld(), sign.getMob()); } // Set the amount diff --git a/src/main/java/de/erethon/dungeonsxl/sign/mob/MobSpawnTask.java b/src/main/java/de/erethon/dungeonsxl/sign/mob/MobSpawnTask.java index f93fbe20..979b64ff 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/mob/MobSpawnTask.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/mob/MobSpawnTask.java @@ -16,9 +16,9 @@ */ package de.erethon.dungeonsxl.sign.mob; -import de.erethon.dungeonsxl.DungeonsXL; +import de.erethon.caliburn.CaliburnAPI; +import de.erethon.caliburn.mob.ExMob; import de.erethon.dungeonsxl.mob.DMob; -import de.erethon.dungeonsxl.mob.DMobType; import de.erethon.dungeonsxl.world.DGameWorld; import org.bukkit.Location; import org.bukkit.Material; @@ -66,15 +66,15 @@ public class MobSpawnTask extends BukkitRunnable { // Disable Despawning entity.setRemoveWhenFarAway(false); - new DMob(entity, sign.getGameWorld(), null); + new DMob(entity, sign.getGameWorld(), sign.getMob()); } } // Check custom mobs - DMobType mobType = DungeonsXL.getInstance().getDMobTypes().getByName(sign.getMob()); + ExMob mobType = CaliburnAPI.getInstance().getExMob(sign.getMob()); if (mobType != null) { - mobType.spawn(gameWorld, spawnLoc); + mobType.toEntity(spawnLoc); } // Set the amount diff --git a/src/main/java/de/erethon/dungeonsxl/trigger/RedstoneTrigger.java b/src/main/java/de/erethon/dungeonsxl/trigger/RedstoneTrigger.java index 5d6fff05..b9ce2995 100644 --- a/src/main/java/de/erethon/dungeonsxl/trigger/RedstoneTrigger.java +++ b/src/main/java/de/erethon/dungeonsxl/trigger/RedstoneTrigger.java @@ -16,12 +16,11 @@ */ package de.erethon.dungeonsxl.trigger; +import de.erethon.commons.misc.BlockUtil; import de.erethon.dungeonsxl.event.trigger.TriggerActionEvent; import de.erethon.dungeonsxl.world.DGameWorld; import org.bukkit.Bukkit; -import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; /** @@ -64,27 +63,7 @@ public class RedstoneTrigger extends Trigger { /* Statics */ public static RedstoneTrigger getOrCreate(Sign sign, DGameWorld gameWorld) { - Block rtBlock = null; - if (sign.getBlock().getType() == Material.WALL_SIGN) { - switch (sign.getData().getData()) { - case 5: - rtBlock = sign.getBlock().getRelative(BlockFace.WEST); - break; - case 4: - rtBlock = sign.getBlock().getRelative(BlockFace.EAST); - break; - case 3: - rtBlock = sign.getBlock().getRelative(BlockFace.NORTH); - break; - case 2: - rtBlock = sign.getBlock().getRelative(BlockFace.SOUTH); - break; - } - - } else { - rtBlock = sign.getBlock().getRelative(BlockFace.DOWN); - } - + Block rtBlock = BlockUtil.getAttachedBlock(sign.getBlock()); if (rtBlock != null) { for (Trigger uncasted : gameWorld.getTriggers(TriggerTypeDefault.REDSTONE)) { RedstoneTrigger trigger = (RedstoneTrigger) uncasted; diff --git a/src/main/java/de/erethon/dungeonsxl/trigger/UseItemTrigger.java b/src/main/java/de/erethon/dungeonsxl/trigger/UseItemTrigger.java index be3b05c3..6eba0d67 100644 --- a/src/main/java/de/erethon/dungeonsxl/trigger/UseItemTrigger.java +++ b/src/main/java/de/erethon/dungeonsxl/trigger/UseItemTrigger.java @@ -16,10 +16,11 @@ */ package de.erethon.dungeonsxl.trigger; +import de.erethon.caliburn.CaliburnAPI; +import de.erethon.caliburn.item.ExItem; import de.erethon.dungeonsxl.event.trigger.TriggerActionEvent; import de.erethon.dungeonsxl.world.DGameWorld; import org.bukkit.Bukkit; -import org.bukkit.Material; import org.bukkit.entity.Player; /** @@ -34,9 +35,9 @@ public class UseItemTrigger extends Trigger { public UseItemTrigger(String name) { this.name = name; - Material mat = Material.matchMaterial(name); - if (mat != null) { - matchedName = mat.toString(); + ExItem item = CaliburnAPI.getInstance().getExItem(name); + if (item != null) { + matchedName = item.toString(); } } diff --git a/src/main/java/de/erethon/dungeonsxl/util/DColor.java b/src/main/java/de/erethon/dungeonsxl/util/DColor.java index 0c442afb..7af76425 100644 --- a/src/main/java/de/erethon/dungeonsxl/util/DColor.java +++ b/src/main/java/de/erethon/dungeonsxl/util/DColor.java @@ -16,10 +16,9 @@ */ package de.erethon.dungeonsxl.util; -import de.erethon.commons.misc.EnumUtil; +import de.erethon.caliburn.item.VanillaItem; import org.bukkit.ChatColor; import org.bukkit.DyeColor; -import org.bukkit.Material; /** * Links different color types together. @@ -28,35 +27,31 @@ import org.bukkit.Material; */ public enum DColor { - BLACK(ChatColor.BLACK, DyeColor.BLACK, "BLACK_WOOL"), - DARK_GRAY(ChatColor.DARK_GRAY, DyeColor.GRAY, "GRAY_WOOL"), - LIGHT_GRAY(ChatColor.GRAY, DyeColor.SILVER, "LIGHT_GRAY_WOOL"), - WHITE(ChatColor.WHITE, DyeColor.WHITE, "WHITE_WOOL"), - DARK_GREEN(ChatColor.DARK_GREEN, DyeColor.GREEN, "GREEN_WOOL"), - LIGHT_GREEN(ChatColor.GREEN, DyeColor.LIME, "LIME_WOOL"), - CYAN(ChatColor.DARK_AQUA, DyeColor.CYAN, "CYAN_WOOL"), - DARK_BLUE(ChatColor.DARK_BLUE, DyeColor.BLUE, "BLUE_WOOL"), - LIGHT_BLUE(ChatColor.AQUA, DyeColor.LIGHT_BLUE, "LIGHT_BLUE_WOOL"), - PURPLE(ChatColor.DARK_PURPLE, DyeColor.PURPLE, "PURPLE_WOOL"), - MAGENTA(ChatColor.LIGHT_PURPLE, DyeColor.MAGENTA, "MAGENTA_WOOL"), - DARK_RED(ChatColor.DARK_RED, DyeColor.BROWN, "BROWN_WOOL"), - LIGHT_RED(ChatColor.RED, DyeColor.RED, "RED_WOOL"), - ORANGE(ChatColor.GOLD, DyeColor.ORANGE, "ORANGE_WOOL"), - YELLOW(ChatColor.YELLOW, DyeColor.YELLOW, "YELLOW_WOOL"), - DEFAULT(ChatColor.BLUE, DyeColor.PINK, "PINK_WOOL"); + 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), + 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), + CYAN(ChatColor.DARK_AQUA, DyeColor.CYAN, VanillaItem.CYAN_WOOL), + DARK_BLUE(ChatColor.DARK_BLUE, DyeColor.BLUE, VanillaItem.BLUE_WOOL), + LIGHT_BLUE(ChatColor.AQUA, DyeColor.LIGHT_BLUE, VanillaItem.LIGHT_BLUE_WOOL), + PURPLE(ChatColor.DARK_PURPLE, DyeColor.PURPLE, VanillaItem.PURPLE_WOOL), + MAGENTA(ChatColor.LIGHT_PURPLE, DyeColor.MAGENTA, VanillaItem.MAGENTA_WOOL), + DARK_RED(ChatColor.DARK_RED, DyeColor.BROWN, VanillaItem.BROWN_WOOL), + LIGHT_RED(ChatColor.RED, DyeColor.RED, VanillaItem.RED_WOOL), + ORANGE(ChatColor.GOLD, DyeColor.ORANGE, VanillaItem.ORANGE_WOOL), + YELLOW(ChatColor.YELLOW, DyeColor.YELLOW, VanillaItem.YELLOW_WOOL), + DEFAULT(ChatColor.BLUE, DyeColor.PINK, VanillaItem.PINK_WOOL); private ChatColor chat; private DyeColor dye; - private Material woolMaterial; + private VanillaItem woolMaterial; - DColor(ChatColor chat, DyeColor dye, String woolMaterial) { + DColor(ChatColor chat, DyeColor dye, VanillaItem woolMaterial) { this.chat = chat; this.dye = dye; - if (EnumUtil.isValidEnum(Material.class, woolMaterial)) { - this.woolMaterial = Material.valueOf(woolMaterial); - } else { - this.woolMaterial = LegacyUtil.LEGACY_WOOL; - } + this.woolMaterial = woolMaterial; } /** @@ -92,7 +87,7 @@ public enum DColor { /** * @return the wool material */ - public Material getWoolMaterial() { + public VanillaItem getWoolMaterial() { return woolMaterial; } diff --git a/src/main/java/de/erethon/dungeonsxl/util/DeserializationUtil.java b/src/main/java/de/erethon/dungeonsxl/util/DeserializationUtil.java deleted file mode 100644 index 42abc784..00000000 --- a/src/main/java/de/erethon/dungeonsxl/util/DeserializationUtil.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 . - */ -package de.erethon.dungeonsxl.util; - -import de.erethon.commons.misc.NumberUtil; -import java.util.ArrayList; -import java.util.List; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemStack; - -/** - * Deprecated deserialization methods for compatibility with 1.7.8-1.8.x - * - * @author Frank Baumann, Daniel Saukel - */ -@Deprecated -public class DeserializationUtil { - - public static List deserializeStackList(List items) { - List itemStacks = new ArrayList<>(); - - for (String item : items) { - String[] itemSplit = item.split(","); - if (itemSplit.length > 0) { - int itemId = 0, itemData = 0, itemSize = 1, itemLvlEnchantment = 1; - Enchantment itemEnchantment = null; - // Check Id & Data - String[] idAndData = itemSplit[0].split("/"); - itemId = NumberUtil.parseInt(idAndData[0]); - - if (idAndData.length > 1) { - itemData = NumberUtil.parseInt(idAndData[1]); - } - - // Size - if (itemSplit.length > 1) { - itemSize = NumberUtil.parseInt(itemSplit[1]); - } - // Enchantment - if (itemSplit.length > 2) { - String[] enchantmentSplit = itemSplit[2].split("/"); - - itemEnchantment = Enchantment.getByName(enchantmentSplit[0]); - - if (enchantmentSplit.length > 1) { - itemLvlEnchantment = NumberUtil.parseInt(enchantmentSplit[1]); - } - } - - // Add Item to Stacks - ItemStack itemStack = new ItemStack(LegacyUtil.getMaterial(itemId), itemSize, (short) itemData); - if (itemEnchantment != null) { - itemStack.addEnchantment(itemEnchantment, itemLvlEnchantment); - } - itemStacks.add(itemStack); - } - } - - return itemStacks; - } - -} diff --git a/src/main/java/de/erethon/dungeonsxl/util/LegacyUtil.java b/src/main/java/de/erethon/dungeonsxl/util/LegacyUtil.java deleted file mode 100644 index 8095ee61..00000000 --- a/src/main/java/de/erethon/dungeonsxl/util/LegacyUtil.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 . - */ -package de.erethon.dungeonsxl.util; - -import de.erethon.commons.compatibility.CompatibilityHandler; -import de.erethon.commons.compatibility.Version; -import de.erethon.commons.misc.EnumUtil; -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 = CompatibilityHandler.getInstance().getVersion().useNewMaterials(); - - public static Material WOODEN_SWORD = Material.valueOf(is1_13 ? "WOODEN_SWORD" : "WOOD_SWORD"); - public static Material GOLDEN_HELMET = Material.valueOf(is1_13 ? "GOLDEN_HELMET" : "GOLD_HELMET"); - public static Material GOLDEN_CESTPLATE = Material.valueOf(is1_13 ? "GOLDEN_CHESTPLATE" : "GOLD_CHESTPLATE"); - public static Material GOLDEN_LEGGINGS = Material.valueOf(is1_13 ? "GOLDEN_LEGGINGS" : "GOLD_LEGGINGS"); - public static Material GOLDEN_BOOTS = Material.valueOf(is1_13 ? "GOLDEN_BOOTS" : "GOLD_BOOTS"); - public static Material WRITABLE_BOOK = Material.valueOf(is1_13 ? "WRITABLE_BOOK" : "BOOK_AND_QUILL"); - public static Material LEGACY_WOOL = EnumUtil.getEnum(Material.class, "WOOL"); - public static Material LEGACY_SIGN_POST = EnumUtil.getEnum(Material.class, "SIGN_POST"); - - 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); - } - -} diff --git a/src/main/java/de/erethon/dungeonsxl/world/DGameWorld.java b/src/main/java/de/erethon/dungeonsxl/world/DGameWorld.java index 0f1dc04d..9f576c28 100644 --- a/src/main/java/de/erethon/dungeonsxl/world/DGameWorld.java +++ b/src/main/java/de/erethon/dungeonsxl/world/DGameWorld.java @@ -16,6 +16,9 @@ */ package de.erethon.dungeonsxl.world; +import de.erethon.caliburn.CaliburnAPI; +import de.erethon.caliburn.item.ExItem; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.misc.BlockUtil; import de.erethon.commons.misc.FileUtil; import de.erethon.dungeonsxl.DungeonsXL; @@ -56,7 +59,6 @@ import java.util.concurrent.CopyOnWriteArrayList; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.Sign; @@ -84,6 +86,7 @@ public class DGameWorld extends DInstanceWorld { DEFAULT } + CaliburnAPI caliburn = plugin.getCaliburn(); Game game; // Variables @@ -596,9 +599,9 @@ public class DGameWorld extends DInstanceWorld { } } - Map> whitelist = rules.getBreakWhitelist(); - Material material = block.getType(); - Material breakTool = player.getItemInHand().getType(); + Map> whitelist = rules.getBreakWhitelist(); + ExItem material = VanillaItem.get(block.getType()); + ExItem breakTool = caliburn.getExItem(player.getItemInHand()); if (whitelist == null) { if (rules.canBreakPlacedBlocks()) { @@ -635,7 +638,7 @@ public class DGameWorld extends DInstanceWorld { } GameRuleProvider rules = game.getRules(); - if (!rules.canPlaceBlocks() && !PlaceableBlock.canBuildHere(block, block.getFace(against), hand.getType(), this)) { + if (!rules.canPlaceBlocks() && !PlaceableBlock.canBuildHere(block, block.getFace(against), caliburn.getExItem(hand), this)) { // Workaround for a bug that would allow 3-Block-high jumping Location loc = player.getLocation(); if (loc.getY() > block.getY() + 1.0 && loc.getY() <= block.getY() + 1.5) { @@ -652,8 +655,8 @@ public class DGameWorld extends DInstanceWorld { return true; } - Set whitelist = rules.getPlaceWhitelist(); - if (whitelist == null || whitelist.contains(block.getType())) { + Set whitelist = rules.getPlaceWhitelist(); + if (whitelist == null || whitelist.contains(VanillaItem.get(block.getType()))) { placedBlocks.add(block); return false; } diff --git a/src/main/java/de/erethon/dungeonsxl/world/DWorldListener.java b/src/main/java/de/erethon/dungeonsxl/world/DWorldListener.java index 744b4915..0a8c5212 100644 --- a/src/main/java/de/erethon/dungeonsxl/world/DWorldListener.java +++ b/src/main/java/de/erethon/dungeonsxl/world/DWorldListener.java @@ -16,8 +16,8 @@ */ package de.erethon.dungeonsxl.world; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.dungeonsxl.game.Game; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; @@ -94,7 +94,7 @@ public class DWorldListener implements Listener { Block block = event.getSource(); DInstanceWorld instance = dWorlds.getInstanceByWorld(block.getWorld()); - if (instance != null && block.getType() == Material.VINE) { + if (instance != null && VanillaItem.VINE.is(block)) { event.setCancelled(true); } } @@ -151,7 +151,7 @@ public class DWorldListener implements Listener { @EventHandler public void onItemSpawn(ItemSpawnEvent event) { if (DGameWorld.getByWorld(event.getLocation().getWorld()) != null) { - if (event.getEntity().getItemStack().getType() == Material.SIGN) { + if (VanillaItem.SIGN.is(event.getEntity().getItemStack())) { event.setCancelled(true); } } diff --git a/src/main/java/de/erethon/dungeonsxl/world/WorldConfig.java b/src/main/java/de/erethon/dungeonsxl/world/WorldConfig.java index 2a4adb84..ad42686d 100644 --- a/src/main/java/de/erethon/dungeonsxl/world/WorldConfig.java +++ b/src/main/java/de/erethon/dungeonsxl/world/WorldConfig.java @@ -16,17 +16,15 @@ */ package de.erethon.dungeonsxl.world; +import de.erethon.caliburn.CaliburnAPI; +import de.erethon.caliburn.item.ExItem; import de.erethon.commons.compatibility.CompatibilityHandler; -import de.erethon.commons.compatibility.Version; import de.erethon.commons.misc.EnumUtil; import de.erethon.commons.misc.NumberUtil; import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.game.GameRuleProvider; import de.erethon.dungeonsxl.game.GameType; import de.erethon.dungeonsxl.requirement.Requirement; -import de.erethon.dungeonsxl.util.DeserializationUtil; -import io.github.dre2n.caliburn.CaliburnAPI; -import io.github.dre2n.caliburn.item.UniversalItemStack; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -37,13 +35,11 @@ import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import org.bukkit.GameMode; -import org.bukkit.Material; import org.bukkit.World.Environment; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.EntityType; -import org.bukkit.inventory.ItemStack; /** * The world configuration is a simple game rule source. @@ -54,6 +50,7 @@ import org.bukkit.inventory.ItemStack; */ public class WorldConfig extends GameRuleProvider { + CaliburnAPI caliburn = CaliburnAPI.getInstance(); CompatibilityHandler compat = CompatibilityHandler.getInstance(); private File file; @@ -89,11 +86,7 @@ public class WorldConfig extends GameRuleProvider { /* Secure Objects */ if (configFile.contains("secureObjects")) { - if (Version.andHigher(Version.MC1_9).contains(compat.getVersion())) { - secureObjects = UniversalItemStack.deserializeList(configFile.getList("secureObjects")); - } else { - secureObjects = DeserializationUtil.deserializeStackList(configFile.getStringList("secureObjects")); - } + secureObjects = caliburn.deserializeExItemList(configFile, "secureObjects"); } /* Invited Players */ @@ -156,12 +149,12 @@ public class WorldConfig extends GameRuleProvider { if (configFile.contains("breakWhitelist")) { breakWhitelist = new HashMap<>(); for (Entry entry : configFile.getConfigurationSection("breakWhitelist").getValues(true).entrySet()) { - Material breakable = Material.matchMaterial(entry.getKey()); + ExItem breakable = caliburn.getExItem(entry.getKey()); - HashSet tools = new HashSet<>(); + HashSet tools = new HashSet<>(); if (entry.getValue() instanceof List) { for (String materialString : (List) entry.getValue()) { - Material tool = Material.matchMaterial(materialString); + ExItem tool = caliburn.getExItem(materialString); if (tool != null) { tools.add(tool); } @@ -189,9 +182,9 @@ public class WorldConfig extends GameRuleProvider { if (configFile.contains("placeWhitelist")) { placeWhitelist = new HashSet<>(); for (String materialString : configFile.getStringList("placeWhitelist")) { - Material material = Material.matchMaterial(materialString); - if (material != null) { - placeWhitelist.add(material); + ExItem item = caliburn.getExItem(materialString); + if (item != null) { + placeWhitelist.add(item); } } } @@ -351,8 +344,8 @@ public class WorldConfig extends GameRuleProvider { } List secureObjectIds = new ArrayList<>(); - for (ItemStack item : getSecureObjects()) { - secureObjectIds.add(CaliburnAPI.getInstance().getItems().getCustomItemId(item)); + for (ExItem item : getSecureObjects()) { + secureObjectIds.add(item.getId()); } configFile.set("secureObjects", secureObjects); diff --git a/src/main/java/de/erethon/dungeonsxl/world/block/PlaceableBlock.java b/src/main/java/de/erethon/dungeonsxl/world/block/PlaceableBlock.java index 9b7d372f..b300ed59 100644 --- a/src/main/java/de/erethon/dungeonsxl/world/block/PlaceableBlock.java +++ b/src/main/java/de/erethon/dungeonsxl/world/block/PlaceableBlock.java @@ -16,8 +16,8 @@ */ package de.erethon.dungeonsxl.world.block; -import de.erethon.commons.misc.NumberUtil; -import de.erethon.dungeonsxl.util.LegacyUtil; +import de.erethon.caliburn.CaliburnAPI; +import de.erethon.caliburn.item.ExItem; import de.erethon.dungeonsxl.world.DGameWorld; import java.util.HashSet; import java.util.Set; @@ -32,7 +32,7 @@ import org.bukkit.event.block.BlockBreakEvent; public class PlaceableBlock extends GameBlock { // Variables - private Set materials = new HashSet<>(); + private Set materials = new HashSet<>(); private boolean onTop = false; private boolean onBottom = false; @@ -48,16 +48,16 @@ public class PlaceableBlock extends GameBlock { if (!ids.isEmpty()) { String[] splittedIds = ids.split(","); for (String id : splittedIds) { - Material material = LegacyUtil.getMaterial(NumberUtil.parseInt(id)); - if (material != null) { - materials.add(material); + ExItem item = CaliburnAPI.getInstance().getExItem(id); + if (item != null) { + materials.add(item); } } } // Read directions if (directions.length() == 6) { - for (int direction = 0; direction < 6; direction++) { + for (byte direction = 0; direction < 6; direction++) { boolean positive = String.valueOf(directions.charAt(direction)).equals("x"); if (!positive) { @@ -73,7 +73,7 @@ public class PlaceableBlock extends GameBlock { } if (block.getType() == Material.WALL_SIGN) { - int data = block.getData(); + byte data = block.getData(); switch (data) { case 3: if (direction == 2) { @@ -153,7 +153,7 @@ public class PlaceableBlock extends GameBlock { } } else { - int data = block.getData(); + byte data = block.getData(); switch (data) { case 0: case 1: @@ -261,7 +261,7 @@ public class PlaceableBlock extends GameBlock { } // Can build - public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, DGameWorld gameWorld) { + public static boolean canBuildHere(Block block, BlockFace blockFace, ExItem mat, DGameWorld gameWorld) { for (PlaceableBlock gamePlacableBlock : gameWorld.getPlaceableBlocks()) { if (gamePlacableBlock.block.getFace(block) != BlockFace.SELF) { continue; diff --git a/src/main/java/de/erethon/dungeonsxl/world/block/TeamBed.java b/src/main/java/de/erethon/dungeonsxl/world/block/TeamBed.java index 242da9f4..9270ec60 100644 --- a/src/main/java/de/erethon/dungeonsxl/world/block/TeamBed.java +++ b/src/main/java/de/erethon/dungeonsxl/world/block/TeamBed.java @@ -16,12 +16,12 @@ */ package de.erethon.dungeonsxl.world.block; +import de.erethon.caliburn.category.Category; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.player.DGamePlayer; import de.erethon.dungeonsxl.player.DGroup; -import de.erethon.dungeonsxl.util.LegacyUtil; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -42,16 +42,16 @@ public class TeamBed extends TeamBlock implements MultiBlock { /* Getters and setters */ public Block getAttachedBlock(Block block) { - if (LegacyUtil.isBed(block.getRelative(BlockFace.EAST).getType())) { + if (Category.BEDS.containsBlock(block.getRelative(BlockFace.EAST))) { return block.getRelative(BlockFace.EAST); - } else if (LegacyUtil.isBed(block.getRelative(BlockFace.NORTH).getType())) { + } else if (Category.BEDS.containsBlock(block.getRelative(BlockFace.NORTH))) { return block.getRelative(BlockFace.NORTH); - } else if (LegacyUtil.isBed(block.getRelative(BlockFace.WEST).getType())) { + } else if (Category.BEDS.containsBlock(block.getRelative(BlockFace.WEST))) { return block.getRelative(BlockFace.WEST); - } else if (LegacyUtil.isBed(block.getRelative(BlockFace.SOUTH).getType())) { + } else if (Category.BEDS.containsBlock(block.getRelative(BlockFace.SOUTH))) { return block.getRelative(BlockFace.SOUTH); } else { @@ -88,10 +88,10 @@ public class TeamBed extends TeamBlock implements MultiBlock { if (((Bed) block1.getState().getData()).isHeadOfBed()) { Block block2 = getAttachedBlock(block1); if (block2 != null) { - block2.setType(Material.AIR); + block2.setType(VanillaItem.AIR.getMaterial()); } } - block1.setType(Material.AIR); + block1.setType(VanillaItem.AIR.getMaterial()); return true; } diff --git a/src/main/java/de/erethon/dungeonsxl/world/block/TeamFlag.java b/src/main/java/de/erethon/dungeonsxl/world/block/TeamFlag.java index fb6067ed..852fc16c 100644 --- a/src/main/java/de/erethon/dungeonsxl/world/block/TeamFlag.java +++ b/src/main/java/de/erethon/dungeonsxl/world/block/TeamFlag.java @@ -16,12 +16,13 @@ */ package de.erethon.dungeonsxl.world.block; +import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; +import de.erethon.commons.compatibility.CompatibilityHandler; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.player.DGamePlayer; import de.erethon.dungeonsxl.player.DGroup; -import de.erethon.dungeonsxl.util.LegacyUtil; -import org.bukkit.Material; +import de.erethon.dungeonsxl.util.DColor; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; @@ -41,7 +42,7 @@ public class TeamFlag extends TeamBlock { * Reset a team flag when the capturer dies. */ public void reset() { - LegacyUtil.setBlockWoolColor(block, owner.getDColor()); + setBlockWoolColor(block, owner.getDColor()); } @Override @@ -59,8 +60,15 @@ public class TeamFlag extends TeamBlock { owner.getGameWorld().sendMessage(DMessage.GROUP_FLAG_STEALING.getMessage(gamePlayer.getName(), owner.getName())); gamePlayer.setRobbedGroup(owner); - event.getBlock().setType(Material.AIR); + event.getBlock().setType(VanillaItem.AIR.getMaterial()); return true; } + public static void setBlockWoolColor(Block block, DColor color) { + block.setType(color.getWoolMaterial().getMaterial()); + if (!CompatibilityHandler.getInstance().getVersion().useNewMaterials()) { + block.setData(color.getWoolData()); + } + } + }