mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-02-17 21:02:12 +01:00
Implement Caliburn 0.4
This commit is contained in:
parent
46607b539e
commit
3829e33e40
8
pom.xml
8
pom.xml
@ -11,7 +11,7 @@
|
||||
<buildNo></buildNo>
|
||||
</properties>
|
||||
<build>
|
||||
<finalName>dungeonsxl-${project.version}${buildNo}</finalName>
|
||||
<finalName>${project.artifactId}-${project.version}${buildNo}</finalName>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
@ -45,7 +45,7 @@
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>io.github.dre2n:caliburn</include>
|
||||
<include>de.erethon:caliburn</include>
|
||||
<include>de.erethon:commons</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
@ -81,9 +81,9 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<groupId>de.erethon</groupId>
|
||||
<artifactId>caliburn</artifactId>
|
||||
<version>0.3</version>
|
||||
<version>0.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -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<Material, HashSet<Material>> breakWhitelist;
|
||||
protected Map<ExItem, HashSet<ExItem>> breakWhitelist;
|
||||
protected Set<EntityType> damageProtectedEntities;
|
||||
protected Set<EntityType> interactionProtectedEntities;
|
||||
protected Boolean placeBlocks;
|
||||
protected Set<Material> placeWhitelist;
|
||||
protected Set<ExItem> placeWhitelist;
|
||||
protected Boolean rain;
|
||||
protected Boolean thunder;
|
||||
protected Long time;
|
||||
@ -164,7 +163,7 @@ public class GameRuleProvider {
|
||||
|
||||
/* Misc */
|
||||
protected Map<Integer, String> msgs;
|
||||
protected List<ItemStack> secureObjects;
|
||||
protected List<ExItem> 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<Material, HashSet<Material>> getBreakWhitelist() {
|
||||
public Map<ExItem, HashSet<ExItem>> getBreakWhitelist() {
|
||||
return breakWhitelist;
|
||||
}
|
||||
|
||||
@ -257,7 +256,7 @@ public class GameRuleProvider {
|
||||
/**
|
||||
* @return the placeable materials
|
||||
*/
|
||||
public Set<Material> getPlaceWhitelist() {
|
||||
public Set<ExItem> 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<ItemStack> getSecureObjects() {
|
||||
public List<ExItem> getSecureObjects() {
|
||||
if (secureObjects == null) {
|
||||
secureObjects = new ArrayList<>();
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Entry> 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<Entry> 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<ItemStack> generateLootList() {
|
||||
List<ItemStack> lootList = new ArrayList<>();
|
||||
for (Entry entry : entries) {
|
||||
if (new Random().nextInt(100) < entry.getLootChance()) {
|
||||
lootList.add(entry.getLootItem());
|
||||
}
|
||||
}
|
||||
return lootList;
|
||||
}
|
||||
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<DLootTable> 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<DLootTable> 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);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<DMobType> 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<DMobType> 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);
|
||||
}
|
||||
|
||||
}
|
@ -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")) {
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<ItemStack> deserializeStackList(List<String> items) {
|
||||
List<ItemStack> 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;
|
||||
}
|
||||
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -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<Material, HashSet<Material>> whitelist = rules.getBreakWhitelist();
|
||||
Material material = block.getType();
|
||||
Material breakTool = player.getItemInHand().getType();
|
||||
Map<ExItem, HashSet<ExItem>> 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<Material> whitelist = rules.getPlaceWhitelist();
|
||||
if (whitelist == null || whitelist.contains(block.getType())) {
|
||||
Set<ExItem> whitelist = rules.getPlaceWhitelist();
|
||||
if (whitelist == null || whitelist.contains(VanillaItem.get(block.getType()))) {
|
||||
placedBlocks.add(block);
|
||||
return false;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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<String, Object> entry : configFile.getConfigurationSection("breakWhitelist").getValues(true).entrySet()) {
|
||||
Material breakable = Material.matchMaterial(entry.getKey());
|
||||
ExItem breakable = caliburn.getExItem(entry.getKey());
|
||||
|
||||
HashSet<Material> tools = new HashSet<>();
|
||||
HashSet<ExItem> tools = new HashSet<>();
|
||||
if (entry.getValue() instanceof List) {
|
||||
for (String materialString : (List<String>) 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<String> 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);
|
||||
|
@ -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<Material> materials = new HashSet<>();
|
||||
private Set<ExItem> 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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user